UNPKG

4.3 kBJavaScriptView Raw
1module.exports = function (row) {
2 /**
3 *
4 */
5 const codes = {
6 // 以下类型输出门洞宽高深,并且仅验证门洞深必填,其他填写则验证
7 types1: [
8 '029', //门套(木门)
9 '091', //筒子板(木门)
10 '093', // 筒子板(铝框门)
11 '084', //门套(铝框门)
12 '028' //飘窗板
13 ],
14 // 以下两个类型输出门洞宽高深并且严格验证
15 types2: [
16 '026', //垭口木门
17 '027' // 窗套
18 ],
19 // 以下类型 仅输出一个form 为 门洞深
20 types3: [
21 '098', // "遮轮板(木门)"
22 '099' // "遮轮板(铝框门)"
23 ]
24 }
25
26 const allCodes = [...codes.types1, ...codes.types2, ...codes.types3]
27 // 构造表单
28
29 var form1 = [{
30 key: this.utils.getKey('门洞宽'),
31 label: '门洞宽',
32 type:'txt',
33 tip: `范围应在${row[this.utils.getKey('门洞宽最小值')]}~${row[this.utils.getKey('门洞宽极限值')]}之间`,
34 value: ""
35 },
36 {
37 key: this.utils.getKey('门洞高'),
38 label: '门洞高',
39 type:'txt',
40 tip: `范围应在${row[this.utils.getKey('门洞高最小值')]}~${row[this.utils.getKey('门洞高极限值')]}之间`,
41 value: ""
42 },
43 {
44 key: this.utils.getKey('门洞深'),
45 label: '门洞深',
46 type:'txt',
47 tip: `范围应在${row[this.utils.getKey('门洞深最小值')]}~${row[this.utils.getKey('门洞深极限值')]}之间`,
48 value: ""
49 }
50 ]
51 var form2 = [
52 {
53 key: this.utils.getKey('门洞深'),
54 label: '门洞深',
55 type:'txt',
56 tip: `范围应在${row[this.utils.getKey('门洞深最小值')]}~${row[this.utils.getKey('门洞深极限值')]}之间`,
57 value: ""
58 }
59 ];
60 var validateMap = {
61 [`${this.utils.getKey('门洞宽')}_valid`]: (value, fd, fo) => {
62 let errorMsg = '';
63 // 校验type1的时候 非必填的验证
64 if(codes.types1.indexOf(row.Code) != -1) {
65 if(!value || value == '') return '';
66 }
67 errorMsg = this.utils.staValidFun('门洞宽', value);
68 errorMsg = this.utils.runAction([
69 {condition: () => {return errorMsg}, msg: errorMsg},
70 {condition: () => {return (value * 1 < row[this.utils.getKey('门洞宽最小值')] || value * 1 > row[this.utils.getKey('门洞宽极限值')])}, msg: `门洞宽${fo.tip}`}
71 ]);
72 return errorMsg;
73 },
74 [`${this.utils.getKey('门洞高')}_valid`]: (value, fd, fo) => {
75 let errorMsg = '';
76 // 校验type1的时候 非必填的验证
77 if(codes.types1.indexOf(row.Code) != -1) {
78 if(!value || value == '') return '';
79 }
80 errorMsg = this.utils.staValidFun('门洞高', value);
81 errorMsg = this.utils.runAction([
82 {condition: () => {return errorMsg}, msg: errorMsg},
83 {condition: () => {return (value * 1 < row[this.utils.getKey('门洞高最小值')] || value * 1 > row[this.utils.getKey('门洞高极限值')])}, msg: `门洞高${fo.tip}`}
84 ]);
85 return errorMsg;
86 },
87 [`${this.utils.getKey('门洞深')}_valid`]: function (value, fd, fo) {
88 let errorMsg = '';
89 errorMsg = this.utils.staValidFun('门洞深', value);
90 errorMsg = this.utils.runAction([
91 {condition: ()=> {return errorMsg}, msg: errorMsg},
92 {condition: ()=> {return (value * 1 < row[this.utils.getKey('门洞深最小值')] || value * 1 > row[this.utils.getKey('门洞深极限值')])}, msg: `门洞深${fo.tip}`}
93 ]);
94 return errorMsg;
95 }
96 }
97 var self= this;
98 return {
99 validateMap: validateMap,
100 codes: allCodes,
101 forms: codes.types3.indexOf(row[self.utils.getKey('三级分类')])==-1?form1:form2
102 }
103}
\No newline at end of file