qtsk-vue3 0.0.18 → 0.0.19
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/package/components/Area/index.vue +16 -15
- package/package/components/DatePicker/index.vue +1 -1
- package/package/components/FormItem/index.vue +1 -1
- package/package/components/Input/index.vue +4 -2
- package/package/index.backup.js +1 -2
- package/package/index.js +2 -0
- package/package/utils/common.js +27 -1
- package/package.json +1 -1
@@ -4,35 +4,36 @@
|
|
4
4
|
placeholder="请选择省市区"
|
5
5
|
size="default"
|
6
6
|
:options="regionData"
|
7
|
-
v-model="
|
7
|
+
v-model="modelValue"
|
8
|
+
clearable
|
9
|
+
@change="handleChange"
|
8
10
|
>
|
9
11
|
</el-cascader>
|
10
12
|
</div>
|
11
13
|
</template>
|
12
14
|
|
13
15
|
<script setup>
|
14
|
-
import { computed } from 'vue'
|
15
16
|
import { ElCascader } from 'element-plus'
|
16
17
|
import { regionData } from 'element-china-area-data'
|
18
|
+
import { treeToArray } from '../../utils/common'
|
19
|
+
const regionFlatData = treeToArray(regionData)
|
17
20
|
defineOptions({
|
18
21
|
name: 'Area',
|
19
22
|
})
|
20
23
|
const props = defineProps({
|
21
|
-
|
22
|
-
type: Array,
|
23
|
-
default: () => ([])
|
24
|
-
}
|
24
|
+
idx: Number
|
25
25
|
})
|
26
|
-
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
|
27
|
+
const emits = defineEmits(['update:modelValue', 'change'])
|
28
|
+
const modelValue = defineModel('modelValue')
|
29
|
+
|
30
|
+
const handleChange = (value) => {
|
31
|
+
emits('change', {index: props.idx, value})
|
32
|
+
}
|
33
|
+
defineExpose({
|
34
|
+
regionFlatData
|
35
35
|
})
|
36
|
+
|
36
37
|
</script>
|
37
38
|
|
38
39
|
<style lang="less" scoped>
|
@@ -37,9 +37,10 @@ const props = defineProps({
|
|
37
37
|
type: [String, Number],
|
38
38
|
default: ''
|
39
39
|
},
|
40
|
-
disabled: Boolean
|
40
|
+
disabled: Boolean,
|
41
|
+
idx: Number
|
41
42
|
})
|
42
|
-
const emits = defineEmits(['update:modelValue'])
|
43
|
+
const emits = defineEmits(['update:modelValue', 'change'])
|
43
44
|
const formData = defineModel('formData')
|
44
45
|
const inputValue = computed({
|
45
46
|
get () {
|
@@ -50,6 +51,7 @@ const inputValue = computed({
|
|
50
51
|
value = value.trim()
|
51
52
|
}
|
52
53
|
if (formData.value?.loc) formData.value.loc = ''
|
54
|
+
emits('change', {index: props.idx || 0, keyWord: value})
|
53
55
|
emits('update:modelValue', value)
|
54
56
|
}
|
55
57
|
})
|
package/package/index.backup.js
CHANGED
@@ -19,5 +19,4 @@ const install = makeInstaller(Components)
|
|
19
19
|
|
20
20
|
export { Message, MessageBox, install, install as default }
|
21
21
|
|
22
|
-
console.info('%c====== Editing in local package ======', 'font-size:16px;color:pink;')
|
23
|
-
|
22
|
+
console.info('%c====== Editing in local package ======', 'font-size:16px;color:pink;')
|
package/package/index.js
CHANGED
package/package/utils/common.js
CHANGED
@@ -52,4 +52,30 @@ export const dateFormat = (time, format) => {
|
|
52
52
|
} else {
|
53
53
|
return ''
|
54
54
|
}
|
55
|
-
}
|
55
|
+
}
|
56
|
+
|
57
|
+
// 将树形结构数组对象转换为二维数组
|
58
|
+
export const treeToArray = (treeArray) => {
|
59
|
+
const result = []
|
60
|
+
|
61
|
+
function flatten (node, level) {
|
62
|
+
result.push({
|
63
|
+
id: node.value,
|
64
|
+
name: node.label,
|
65
|
+
level: level
|
66
|
+
})
|
67
|
+
|
68
|
+
if (node.children && node.children.length > 0) {
|
69
|
+
node.children.forEach(child => {
|
70
|
+
flatten(child, level + 1)
|
71
|
+
})
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
treeArray.forEach(node => {
|
76
|
+
flatten(node, 0)
|
77
|
+
})
|
78
|
+
|
79
|
+
return result
|
80
|
+
}
|
81
|
+
|