@xuekl/cli-components 1.5.9 → 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/XklButton.vue CHANGED
@@ -37,7 +37,9 @@ const btnClick = () => {
37
37
  }
38
38
 
39
39
  if (attrs.onConfirm) {
40
- if (props.prevent) {
40
+ if (props.prevent === false) {
41
+ attrs.onConfirm()
42
+ } else {
41
43
  ElMessageBox.confirm(
42
44
  '当前内容可能存在修改,确认继续?',
43
45
  '提示',
@@ -50,8 +52,6 @@ const btnClick = () => {
50
52
  attrs.onConfirm()
51
53
  }).catch(() => {
52
54
  })
53
- } else {
54
- attrs.onConfirm()
55
55
  }
56
56
  }
57
57
  }
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">{{ form[item.reflect] || form[item.prop] }}</span>
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuekl/cli-components",
3
- "version": "1.5.9",
3
+ "version": "1.6.1",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {