1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| import { type PropType, defineComponent } from 'vue';
| import data from '../data/pca.json';
| import { useCool } from '/@/cool';
|
| export default defineComponent({
| name: 'cl-distpicker',
|
| props: {
| props: Object,
| type: {
| type: String as PropType<'pc' | 'pca'>,
| default: 'pca'
| }
| },
|
| setup(props, { expose }) {
| const { refs, setRefs } = useCool();
|
| function focus() {
| refs.cascader?.togglePopperVisible();
| }
|
| expose({
| focus
| });
|
| return () => {
| return (
| <el-cascader
| ref={setRefs('cascader')}
| clearable
| options={data.map(e => {
| if (props.type === 'pc') {
| return {
| ...e,
| children: e.children.map(a => {
| return {
| ...a,
| children: undefined
| };
| })
| };
| }
|
| return e;
| })}
| props={{ label: 'name', value: 'name', ...props.props }}
| />
| );
| };
| }
| });
|
|