You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/vc-tree-select/demo/big-data-generator.js

66 lines
1.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import PropTypes from '../../_util/vue-types';
import { generateData, calcTotal } from './util';
const Gen = {
props: {
x: PropTypes.number.def(20),
y: PropTypes.number.def(18),
z: PropTypes.number.def(1),
},
data() {
return {
nums: '',
};
},
mounted() {
this.$refs.x.value = this.x;
this.$refs.y.value = this.y;
this.$refs.z.value = this.z;
const vals = this.getVals();
this.$emit('gen', generateData(vals.x, vals.y, vals.z));
},
methods: {
onGen(e) {
e.preventDefault();
const vals = this.getVals();
this.$emit('gen', generateData(vals.x, vals.y, vals.z));
this.nums = calcTotal(vals.x, vals.y, vals.z);
},
getVals() {
return {
x: parseInt(this.$refs.x.value, 10),
y: parseInt(this.$refs.y.value, 10),
z: parseInt(this.$refs.z.value, 10),
};
},
},
render() {
const { x, y, z } = this;
return (
<div style={{ padding: '0 20px' }}>
<h2>big data generator</h2>
<form onSubmit={this.onGen}>
<span style={{ marginRight: '10px' }}>
x: <input ref="x" type="number" min="1" required style={{ width: '50px' }} />
</span>
<span style={{ marginRight: '10px' }}>
y: <input ref="y" type="number" min="1" required style={{ width: '50px' }} />
</span>
<span style={{ marginRight: '10px' }}>
z: <input ref="z" type="number" min="1" required style={{ width: '50px' }} />
</span>
<button type="submit">Generate</button>
<p>total nodes: {this.nums || calcTotal(x, y, z)}</p>
</form>
<p style={{ fontSize: '12px' }}>
x每一级下的节点总数y每级节点里有y个节点存在子节点z树的level层级数0表示一级
</p>
</div>
);
},
};
export default Gen;