ruleMixin.js
2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { mapGetters } from 'vuex'
import ruleConfig from '@/api/ruleConfig'
let mixin = {
computed: {
...mapGetters(['dicData', 'rules','Edit'])
},
data () {
return {
key: 0,
typeNum: { type: 'number' },
initRules: {},
subRules: {}
}
},
created () {
this.featchData()
},
methods: {
/**
* @description: featchData
* @author: renchao
*/
featchData () {
},
/**
* @description: verificationForm
* @author: renchao
*/
verificationForm () {
return new Promise((resolve) => {
this.$refs['formList'].validate((valid) => {
if (valid) {
resolve(true)
} else {
resolve(false)
}
})
})
},
/**
* @description: changeCertificate
* @author: renchao
*/
changeCertificate() {
},
/**
* @description: featchRule
* @author: renchao
*/
async featchRule () {
try {
let { result: { sysywsjbfieldlist } } = await ruleConfig.getRuleList(this.bsmYwsjb)
sysywsjbfieldlist.forEach((item) => {
this.subRules[item.FIELD] = [
{
required: item.REQUIRED == '1' ? true : false,
pattern: item.EXPRESSION? new RegExp(item.EXPRESSION): null,
message: item.MESSAGE || '请输入内容',
trigger: item.TRIGGERS || 'change'
}
]
this.initRules[item.FIELD] = [
{
required: item.REQUIRED == '1' ? true : false,
message: item.MESSAGE || '请输入内容',
trigger: item.TRIGGERS || 'change'
}
]
})
if (this.Edit) {
this.$store.dispatch('business/setRules', {})
}else {
this.$store.dispatch('business/setRules', this.initRules)
}
this.$store.dispatch('business/setInitRules', this.initRules)
this.$store.dispatch('business/setSubRules', this.subRules)
this.key++
this.$nextTick(() => {
this.$refs['formList'] && this.$refs['formList'].validate((valid) => {
if (!valid) {
return false
}
})
})
} catch (error) {
if (this.$refs.msg) {
this.$refs.msg.messageShow()
}
}
}
}
}
export default mixin