UNPKG

1.92 kBJavaScriptView Raw
1const utils = require('./varies/utils');
2let vArray = [];
3let v1 = require('./varies/v1.js');
4let v2 = require('./varies/v2.js');
5let v3 = require('./varies/v3.js');
6let v4 = require('./varies/v4.js');
7let v5 = require('./varies/v5.js');
8let v6 = require('./varies/v6.js');
9let v7 = require('./varies/v7.js');
10let v8 = require('./varies/v8.js');
11let v9 = require('./varies/v9.js');
12vArray.push(v1);
13vArray.push(v2);
14vArray.push(v3);
15vArray.push(v4);
16vArray.push(v5);
17vArray.push(v6);
18vArray.push(v7);
19vArray.push(v8);
20vArray.push(v9);
21(function(f) {
22 module.exports = f;
23 if(typeof(window) != 'undefined') window.ecomps = {actionFun: f}
24})(function(row, plant) {
25 if(!plant) plant = 1;
26 let funMap = {
27 validate: function (newforms) {
28 let realForms = newforms || this.forms;
29 // 构造新formData
30 let formData = {};
31 for (let i = 0; i < realForms.length; i++) {
32 let rone = realForms[i];
33 formData[rone.key] = rone.value;
34 }
35 let errorMsg = '';
36 for (let i = 0; i < realForms.length; i++) {
37 let rone = realForms[i];
38 errorMsg = this.validateMap[rone.key+'_valid'](rone.value, formData, rone);
39 if (errorMsg) break
40 }
41 return {
42 errorMsg: errorMsg,
43 formData: formData
44 }
45 }
46 }
47 vArray.map(function(v) {
48 let utilsScope = v.prototype.utils = new utils(plant);
49 // 1大写 2 小写
50 let itemMap = new v(row);
51 if(itemMap.codes.indexOf(row[utilsScope.getKey('三级分类')]) != -1) {
52 Object.assign(funMap, itemMap);
53 funMap.forms.map(function(item) {
54 Object.assign(item, {disabled: false});
55 })
56 }
57 })
58 return funMap;
59})