meixioacomponent 2.0.38 → 2.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/meixioacomponent.common.js +289 -11796
- package/lib/meixioacomponent.umd.js +274 -11781
- package/lib/meixioacomponent.umd.min.js +3 -3
- package/package.json +1 -1
- package/packages/components/base/baseArea/api.js +7 -0
- package/packages/components/base/baseArea/areaConfig.js +1 -0
- package/packages/components/base/baseArea/baseArea.vue +590 -590
- package/packages/components/base/baseArea/baseAreaV2.vue +185 -0
- package/packages/components/base/baseArea/index.js +1 -2
- package/packages/components/proForm/proForm/pro_form.vue +1 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="base-area-select-wrap">
|
|
3
|
+
<t-cascader
|
|
4
|
+
ref="cascader"
|
|
5
|
+
:keys="{
|
|
6
|
+
value:'code',
|
|
7
|
+
label:'name',
|
|
8
|
+
children: 'children',
|
|
9
|
+
}"
|
|
10
|
+
:load="load"
|
|
11
|
+
:options="options"
|
|
12
|
+
:disabled="disable||loading"
|
|
13
|
+
:size="componentSize" @change="onChange"
|
|
14
|
+
:placeholder="placeholder"
|
|
15
|
+
:input-props="inputProps"
|
|
16
|
+
v-model="localValue">
|
|
17
|
+
</t-cascader>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
import baseButtonHandleVue from '../baseButtonHandle/baseButtonHandle.vue'
|
|
23
|
+
import {GetAreaTree} from "./api";
|
|
24
|
+
import areaConfig from "./areaConfig";
|
|
25
|
+
import {TransomComponentSize} from "../../../utils/utils";
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
name: 'baseArea',
|
|
30
|
+
data() {
|
|
31
|
+
return {
|
|
32
|
+
loading: false,
|
|
33
|
+
localValue: [],
|
|
34
|
+
localDetailValue: {},
|
|
35
|
+
placeholder: '请选择省市区镇',
|
|
36
|
+
options: [],
|
|
37
|
+
inputProps: {
|
|
38
|
+
value: '',
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
created() {
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
mounted() {
|
|
46
|
+
this.loadArea('').then(res => {
|
|
47
|
+
this.options = res;
|
|
48
|
+
})
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
props: {
|
|
52
|
+
value: {
|
|
53
|
+
default: null,
|
|
54
|
+
},
|
|
55
|
+
disable: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false,
|
|
58
|
+
},
|
|
59
|
+
size: {type: String, default: 'small'}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
components: {
|
|
63
|
+
baseButtonHandleVue,
|
|
64
|
+
},
|
|
65
|
+
computed: {
|
|
66
|
+
module: {
|
|
67
|
+
set(val) {
|
|
68
|
+
this.$emit('input', val)
|
|
69
|
+
},
|
|
70
|
+
get() {
|
|
71
|
+
return this.$props.value
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
componentSize() {
|
|
75
|
+
return TransomComponentSize(this.$props.size);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
},
|
|
79
|
+
methods: {
|
|
80
|
+
init() {
|
|
81
|
+
if (this.module) {
|
|
82
|
+
const {province, city, district, town} = this.module;
|
|
83
|
+
this.inputProps.value = `${province}/${city}/${district}`
|
|
84
|
+
if (town) {
|
|
85
|
+
this.inputProps.value += `/${town}`
|
|
86
|
+
this.localValue = [province, city, district, town]
|
|
87
|
+
} else {
|
|
88
|
+
this.localValue = [province, city, district]
|
|
89
|
+
}
|
|
90
|
+
this.localDetailValue = {
|
|
91
|
+
province,
|
|
92
|
+
city,
|
|
93
|
+
district,
|
|
94
|
+
town
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
load(node) {
|
|
99
|
+
const {value} = node;
|
|
100
|
+
return new Promise((resolve) => {
|
|
101
|
+
this.loadArea(value).then(res => {
|
|
102
|
+
resolve(res);
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
loadArea(keyword) {
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
this.loading = true;
|
|
110
|
+
GetAreaTree({
|
|
111
|
+
keyword: keyword
|
|
112
|
+
}).then(res => {
|
|
113
|
+
if (Array.isArray(res)) {
|
|
114
|
+
res.forEach(item => {
|
|
115
|
+
item[`children`] = item.level !== 4;
|
|
116
|
+
})
|
|
117
|
+
this.loading = false;
|
|
118
|
+
resolve(res);
|
|
119
|
+
} else {
|
|
120
|
+
resolve([]);
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
onChange() {
|
|
126
|
+
this.inputProps.value = '';
|
|
127
|
+
this.$nextTick(() => {
|
|
128
|
+
const list = this.$refs.cascader.panels;
|
|
129
|
+
list.forEach(itemList => {
|
|
130
|
+
this.onAreaChange(itemList)
|
|
131
|
+
})
|
|
132
|
+
const _value = {
|
|
133
|
+
...this.localDetailValue,
|
|
134
|
+
}
|
|
135
|
+
this.$emit('confirmAreaValue', _value)
|
|
136
|
+
this.module = _value;
|
|
137
|
+
console.log(this.localValue);
|
|
138
|
+
})
|
|
139
|
+
},
|
|
140
|
+
onAreaChange(list) {
|
|
141
|
+
try {
|
|
142
|
+
let index = null;
|
|
143
|
+
for (let i = 0; i < list.length; i++) {
|
|
144
|
+
const item = list[i];
|
|
145
|
+
if (item.indeterminate || item.checked) {
|
|
146
|
+
index = i;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const value = list[index];
|
|
150
|
+
const {data} = value;
|
|
151
|
+
const {name, code, level} = data;
|
|
152
|
+
if (!level) return;
|
|
153
|
+
if (!this.localDetailValue[`idList`]) {
|
|
154
|
+
this.localDetailValue[`idList`] = [0, 0, 0, 0];
|
|
155
|
+
}
|
|
156
|
+
this.localDetailValue[`${areaConfig[level - 1].value}`] = name;
|
|
157
|
+
this.localDetailValue[`idList`][level - 1] = code;
|
|
158
|
+
console.log(this.localDetailValue);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.log(error);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
watch: {
|
|
165
|
+
module: {
|
|
166
|
+
deep: true,
|
|
167
|
+
handler() {
|
|
168
|
+
this.$nextTick(() => {
|
|
169
|
+
this.init();
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
</script>
|
|
176
|
+
|
|
177
|
+
<style lang="less" scoped>
|
|
178
|
+
.base-area-select-wrap {
|
|
179
|
+
width: 100%;
|
|
180
|
+
height: auto;
|
|
181
|
+
overflow: hidden;
|
|
182
|
+
border-radius: calc(var(--radius) * 2);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
</style>
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
|
|
128
128
|
<script>
|
|
129
129
|
import pro_form_itemVue from './proFormItem/pro_form_item.vue'
|
|
130
|
-
import baseAreaVue from '../../base/baseArea/
|
|
130
|
+
import baseAreaVue from '../../base/baseArea/baseAreaV2.vue'
|
|
131
131
|
import baseUploadVue from '../../base/baseUpload/baseUpload.vue'
|
|
132
132
|
import pro_formItem_skeletonVue from './pro_form-item_skeleton.vue'
|
|
133
133
|
import baseButtonHandleVue from '../../base/baseButtonHandle/baseButtonHandle.vue'
|