vue2-client 1.12.45 → 1.12.49
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.json +1 -1
- package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +24 -14
- package/src/base-client/components/common/XForm/XForm.vue +404 -393
- package/src/base-client/components/common/XForm/XFormItem.vue +1310 -1265
- package/src/base-client/components/common/XForm/XTreeSelect.vue +263 -263
- package/src/base-client/components/common/XFormGroup/demo.vue +4 -2
- package/src/base-client/components/common/XFormTable/demo.vue +1 -1
- package/src/components/FilePreview/FilePreview.vue +30 -10
- package/src/components/FilePreview/FilePreviewDemo.vue +30 -0
- package/src/mixins/formValidationMixin.js +46 -0
- package/src/router/async/router.map.js +2 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
data () {
|
|
3
|
+
return {
|
|
4
|
+
rules: {}
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
methods: {
|
|
8
|
+
// 设置某个字段必填项
|
|
9
|
+
setRequired (key) {
|
|
10
|
+
if (!this.rules[key]) {
|
|
11
|
+
this.$set(this.rules, key, [])
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 检查是否已存在必填规则
|
|
15
|
+
const hasRequired = this.rules[key].some(rule => rule.required)
|
|
16
|
+
if (!hasRequired) {
|
|
17
|
+
const targetItem = this.formItems.find(item => item.model === key || `${item.name}${item.model}` === key)
|
|
18
|
+
|
|
19
|
+
this.rules[key].push({
|
|
20
|
+
required: true,
|
|
21
|
+
message: `${targetItem?.name || '该字段'}不能为空`,
|
|
22
|
+
trigger: 'blur'
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// 触发表单重新验证
|
|
26
|
+
this.$nextTick(() => {
|
|
27
|
+
this.$refs.selectForm.validateField(key)
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
// 移除某个字段必填项
|
|
33
|
+
removeRequired (key) {
|
|
34
|
+
if (this.rules[key]) {
|
|
35
|
+
// 过滤掉必填规则
|
|
36
|
+
this.rules[key] = this.rules[key].filter(rule => !rule.required)
|
|
37
|
+
// 清除验证状态
|
|
38
|
+
this.$nextTick(() => {
|
|
39
|
+
this.$refs.selectForm.clearValidate(key)
|
|
40
|
+
})
|
|
41
|
+
console.log('移除必填项', this.rules[key])
|
|
42
|
+
this.$forceUpdate()
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -56,7 +56,7 @@ routerResource.example = {
|
|
|
56
56
|
// component: () => import('@vue2-client/base-client/components/common/XAddNativeForm/demo.vue'),
|
|
57
57
|
// component: () => import('@vue2-client/base-client/components/common/XFormGroup/demo.vue'),
|
|
58
58
|
// component: () => import('@vue2-client/base-client/components/common/XReport/XReportDemo.vue'),
|
|
59
|
-
component: () => import('@vue2-client/base-client/components/common/XFormTable/demo.vue'),
|
|
59
|
+
// component: () => import('@vue2-client/base-client/components/common/XFormTable/demo.vue'),
|
|
60
60
|
// component: () => import('@vue2-client/base-client/components/common/XDatePicker/demo.vue'),
|
|
61
61
|
// component: () => import('@vue2-client/base-client/components/common/XTab/XTabDemo.vue'),
|
|
62
62
|
// component: () => import('@vue2-client/base-client/components/common/XRate/demo.vue'),
|
|
@@ -70,6 +70,7 @@ routerResource.example = {
|
|
|
70
70
|
// component: () => import('@vue2-client/base-client/components/AI/demo.vue'),
|
|
71
71
|
// component: () => import('@vue2-client/components/g2Charts/demo.vue'),
|
|
72
72
|
// component: () => import('@vue2-client/pages/LogicCallExample/index.vue'),
|
|
73
|
+
component: () => import('@vue2-client/components/FilePreview/FilePreviewDemo.vue'),
|
|
73
74
|
}
|
|
74
75
|
// routerResource.example = () =>
|
|
75
76
|
// import('@vue2-client/pages/Example')
|