@xuekl/cli-components 1.6.0 → 1.6.1
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/XklFormInfo.vue +29 -2
- package/package.json +1 -1
package/XklFormInfo.vue
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
<template v-for="item in formList" :key="item.prop">
|
|
5
5
|
<el-col :span="item.span" v-if="item.show()">
|
|
6
6
|
<el-form-item :label="item.label + ':'" :label-width="item.labelWidth">
|
|
7
|
-
<span v-if="item.type">{{
|
|
7
|
+
<span v-if="item.type === 'dict-select'">{{ dictLabel(item.config.dict, form[item.prop]) }}</span>
|
|
8
|
+
<span v-else-if="item.type">{{ form[item.reflect] || form[item.prop] }}</span>
|
|
8
9
|
<slot v-else :name="item.prop"></slot>
|
|
9
10
|
</el-form-item>
|
|
10
11
|
</el-col>
|
|
@@ -19,9 +20,11 @@ export default {
|
|
|
19
20
|
}
|
|
20
21
|
</script>
|
|
21
22
|
<script setup lang="ts">
|
|
23
|
+
import http from "@/utils/httpRequest"
|
|
24
|
+
import { baseConf } from './index'
|
|
22
25
|
import { setUpperFirst } from '@xuekl/cli-utils'
|
|
23
26
|
import { FormItem } from '@xuekl/cli-base/type.d'
|
|
24
|
-
import { ref } from 'vue'
|
|
27
|
+
import { ref, computed } from 'vue'
|
|
25
28
|
|
|
26
29
|
const props = defineProps(['form'])
|
|
27
30
|
const XklFormRef = ref(null)
|
|
@@ -29,6 +32,7 @@ const { form } = props
|
|
|
29
32
|
const formList: FormItem[] = []
|
|
30
33
|
const opts = form._opts || {}
|
|
31
34
|
|
|
35
|
+
|
|
32
36
|
// 获取符合mode的字段
|
|
33
37
|
Object.keys(form).forEach(prop => {
|
|
34
38
|
if (form['get' + setUpperFirst(prop)]) {
|
|
@@ -56,6 +60,29 @@ Object.keys(form).forEach(prop => {
|
|
|
56
60
|
}
|
|
57
61
|
})
|
|
58
62
|
|
|
63
|
+
const dictTypes = formList.map(item => item.config?.dict).filter(res => !!res)
|
|
64
|
+
const dictStore = ref({})
|
|
65
|
+
|
|
66
|
+
dictTypes.forEach((dict: string) => {
|
|
67
|
+
http({
|
|
68
|
+
url: http.adornUrl(`${baseConf.dict_api_url}${dict}`),
|
|
69
|
+
method: 'get',
|
|
70
|
+
params: http.adornParams({})
|
|
71
|
+
}).then(({ data }) => {
|
|
72
|
+
dictStore.value[dict] = data.data
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const dictLabel = computed(() => {
|
|
77
|
+
return function (dict: string, val: string | number) {
|
|
78
|
+
if (dictStore.value[dict]) {
|
|
79
|
+
const item = dictStore.value[dict].find(res => res.dictValue == val) || {}
|
|
80
|
+
return item.dictLabel
|
|
81
|
+
}
|
|
82
|
+
return ''
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
59
86
|
|
|
60
87
|
</script>
|
|
61
88
|
<style lang="scss" scoped>
|