centaline-data-driven-v3 0.0.97 → 0.0.99
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/dist/centaline-data-driven-v3.umd.js +91 -91
- package/package.json +1 -1
- package/src/components/web/Button.vue +84 -26
- package/src/components/web/Form.vue +35 -28
- package/src/components/web/FormList.vue +13 -2
- package/src/components/web/photo.vue +29 -17
- package/src/loader/src/Button.js +7 -0
- package/src/loader/src/Form.js +3 -2
- package/src/loader/src/Photo.js +23 -7
- package/src/loader/src/Router.js +12 -1
- package/src/utils/Enum.js +5 -1
- package/src/utils/common.js +19 -2
- package/src/utils/formData.js +362 -358
package/src/utils/formData.js
CHANGED
|
@@ -2,396 +2,400 @@ import common from './common';
|
|
|
2
2
|
import Enum from './Enum';
|
|
3
3
|
import request from './request';
|
|
4
4
|
const formData = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
form: null,
|
|
6
|
+
formTable: null,
|
|
7
|
+
excuteData: null,//fields
|
|
8
|
+
fieldsDic: null,//fieldsDic
|
|
9
|
+
source: null,
|
|
10
|
+
_excuteListData: undefined,
|
|
11
|
+
enableRelationFields(FlagRelation) {
|
|
12
|
+
this.form.enableRelationFields = FlagRelation
|
|
13
|
+
},
|
|
14
|
+
//获取code1
|
|
15
|
+
getCode1ByField1(id) {
|
|
16
|
+
var rtn1 = this.fieldsDic[id];
|
|
17
|
+
if (rtn1) {
|
|
18
|
+
return rtn1.code1;
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
//获取code2
|
|
23
|
+
getCode2ByField1(id) {
|
|
24
|
+
var rtn1 = this.fieldsDic[id];
|
|
25
|
+
if (rtn1) {
|
|
26
|
+
return rtn1.code2;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
setActionRouter(id, attrKey, attrValue) {
|
|
30
|
+
var router = this.form.actionRouters.find((v1) => {
|
|
31
|
+
return v1.key === id;
|
|
32
|
+
});
|
|
33
|
+
if (router) {
|
|
34
|
+
router[attrKey] = attrValue;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
//获取Field的属性attrKey的值
|
|
38
|
+
getValueByFieldName(id, attrKey) {
|
|
39
|
+
attrKey = common.initialsToLowerCase(attrKey);
|
|
40
|
+
var rtn1 = this.fieldsDic[id];
|
|
41
|
+
if (rtn1) {
|
|
42
|
+
return rtn1[attrKey];
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
getValueByFieldNameFromParent(id, attrKey) {
|
|
46
|
+
if (this.form && this.form.parentModelForm) {
|
|
47
|
+
return this.form.parentModelForm.getValueByFieldName(id, attrKey);
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
//设置Field的属性attrKey的值
|
|
52
|
+
setValueByFieldName(id, attrKey, attrValue) {
|
|
53
|
+
attrKey = common.initialsToLowerCase(attrKey);
|
|
54
|
+
var rtn1 = this.fieldsDic[id];
|
|
55
|
+
if (rtn1) {
|
|
56
|
+
if (attrKey == 'code1' && rtn1.controlType === Enum.ControlType.NumericTextBox
|
|
57
|
+
&& attrValue != undefined && attrValue != null && attrValue != '') {
|
|
58
|
+
if (rtn1.decimals1 != undefined && rtn1.decimals1 != null && rtn1.decimals1 > -1) {
|
|
59
|
+
attrValue = Number(attrValue).toFixed(rtn1.decimals1)
|
|
43
60
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
//设置Field的属性attrKey的值
|
|
52
|
-
setValueByFieldName(id, attrKey, attrValue) {
|
|
53
|
-
attrKey = common.initialsToLowerCase(attrKey);
|
|
54
|
-
var rtn1 = this.fieldsDic[id];
|
|
55
|
-
if (rtn1) {
|
|
56
|
-
if (attrKey == 'code1' && rtn1.controlType === Enum.ControlType.NumericTextBox
|
|
57
|
-
&& attrValue != undefined && attrValue != null && attrValue != '') {
|
|
58
|
-
if (rtn1.decimals1 != undefined && rtn1.decimals1 != null && rtn1.decimals1 > -1) {
|
|
59
|
-
attrValue = Number(attrValue).toFixed(rtn1.decimals1)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else if (attrKey == 'code1' && (rtn1.controlType === Enum.ControlType.File
|
|
63
|
-
|| rtn1.controlType === Enum.ControlType.SliceUpload || rtn1.controlType === Enum.ControlType.PhotoSelect)
|
|
64
|
-
&& attrValue != undefined && attrValue != null && attrValue != '') {
|
|
65
|
-
rtn1.jsSetFile(attrValue, rtn1);
|
|
66
|
-
}
|
|
67
|
-
rtn1[attrKey] = attrValue;
|
|
68
|
-
if (rtn1.controlType === Enum.ControlType.Tags) {
|
|
69
|
-
rtn1["value"] = JSON.parse(attrValue);
|
|
70
|
-
}
|
|
71
|
-
if (rtn1.controlType === Enum.ControlType.SearchListBox
|
|
72
|
-
|| rtn1.controlType === Enum.ControlType.ComboBox
|
|
73
|
-
|| rtn1.controlType === Enum.ControlType.MultiSelectWithSearch
|
|
74
|
-
|| rtn1.controlType === Enum.ControlType.MultiSelectNoSearch
|
|
75
|
-
) {
|
|
76
|
-
if (rtn1["options"].length == 0) {
|
|
77
|
-
rtn1["options"] = [{ value: '', label: '' }];
|
|
78
|
-
}
|
|
79
|
-
if (attrKey == 'code1') {
|
|
80
|
-
rtn1["value"] = attrValue;
|
|
81
|
-
rtn1["options"][0]["value"] = attrValue
|
|
82
|
-
}
|
|
83
|
-
if (attrKey == 'name1') {
|
|
84
|
-
rtn1["options"][0]["label"] = attrValue
|
|
85
|
-
}
|
|
86
|
-
if (rtn1.itemKey) rtn1.itemKey = Math.random()
|
|
87
|
-
}
|
|
88
|
-
if (rtn1.is == 'ct-button') {
|
|
89
|
-
if (common.flagApp() && this.form.$vue.loaded) {
|
|
90
|
-
this.form.$vue.loaded(this.form)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
this.source.hiddenHandle(rtn1, this.form);
|
|
94
|
-
if(this.source.requiredHandle){
|
|
95
|
-
this.source.requiredHandle(rtn1, this.form);
|
|
96
|
-
}
|
|
61
|
+
}
|
|
62
|
+
else if ((rtn1.controlType === Enum.ControlType.File
|
|
63
|
+
|| rtn1.controlType === Enum.ControlType.SliceUpload || rtn1.controlType === Enum.ControlType.PhotoSelect)
|
|
64
|
+
&& attrValue != undefined && attrValue != null && attrValue != '') {
|
|
65
|
+
if (attrKey == 'code1') {
|
|
66
|
+
rtn1.jsSetFile(attrValue, rtn1);
|
|
97
67
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (this.form && this.form.parentModelForm) {
|
|
101
|
-
return this.form.parentModelForm.setValueByFieldName(id, attrKey, attrValue);
|
|
68
|
+
else if (attrKey == 'file') {
|
|
69
|
+
rtn1.jsAddFile(attrValue, rtn1);
|
|
102
70
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
71
|
+
}
|
|
72
|
+
rtn1[attrKey] = attrValue;
|
|
73
|
+
if (rtn1.controlType === Enum.ControlType.Tags) {
|
|
74
|
+
rtn1["value"] = JSON.parse(attrValue);
|
|
75
|
+
}
|
|
76
|
+
if (rtn1.controlType === Enum.ControlType.SearchListBox
|
|
77
|
+
|| rtn1.controlType === Enum.ControlType.ComboBox
|
|
78
|
+
|| rtn1.controlType === Enum.ControlType.MultiSelectWithSearch
|
|
79
|
+
|| rtn1.controlType === Enum.ControlType.MultiSelectNoSearch
|
|
80
|
+
) {
|
|
81
|
+
if (rtn1["options"].length == 0) {
|
|
82
|
+
rtn1["options"] = [{ value: '', label: '' }];
|
|
116
83
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
for (let i = 0; i < rtn1.fileSourceList.length; i++) {
|
|
121
|
-
rtn1.fileSourceList[i].flagDeleted = true;
|
|
84
|
+
if (attrKey == 'code1') {
|
|
85
|
+
rtn1["value"] = attrValue;
|
|
86
|
+
rtn1["options"][0]["value"] = attrValue
|
|
122
87
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
setTabsSelect(id) {
|
|
126
|
-
if (this.form && this.form.$vue) {
|
|
127
|
-
var f = this.fieldsDic[id];
|
|
128
|
-
if (this.form.isHorizontalLayout) {
|
|
129
|
-
this.form.$vue.activeName = f.collapseName.toString() === '-1' ? this.form.$vue.activeName : f.collapseName.toString();
|
|
130
|
-
}
|
|
88
|
+
if (attrKey == 'name1') {
|
|
89
|
+
rtn1["options"][0]["label"] = attrValue
|
|
131
90
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
this.form.$vue.
|
|
91
|
+
if (rtn1.itemKey) rtn1.itemKey = Math.random()
|
|
92
|
+
}
|
|
93
|
+
if (rtn1.is == 'ct-button') {
|
|
94
|
+
if (common.flagApp() && this.form.$vue.loaded) {
|
|
95
|
+
this.form.$vue.loaded(this.form)
|
|
137
96
|
}
|
|
138
|
-
}
|
|
97
|
+
}
|
|
98
|
+
this.source.hiddenHandle(rtn1, this.form);
|
|
99
|
+
if (this.source.requiredHandle) {
|
|
100
|
+
this.source.requiredHandle(rtn1, this.form);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
setValueByFieldNameFromParent(id, attrKey, attrValue) {
|
|
105
|
+
if (this.form && this.form.parentModelForm) {
|
|
106
|
+
return this.form.parentModelForm.setValueByFieldName(id, attrKey, attrValue);
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
},
|
|
110
|
+
//设置Field的v1、v2的值
|
|
111
|
+
setV1AndV2ByField1(id, code1, code2) {
|
|
112
|
+
var rtn1 = this.fieldsDic[id];
|
|
113
|
+
if (rtn1) {
|
|
114
|
+
if (typeof rtn1.code1 !== 'undefined') {
|
|
115
|
+
rtn1.code1 = code1;
|
|
116
|
+
this.source.hiddenHandle(rtn1);//隐藏关联的
|
|
117
|
+
}
|
|
118
|
+
if (typeof rtn1.code2 !== 'undefined') {
|
|
119
|
+
rtn1.code2 = code2;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
clearMedia(id) {
|
|
124
|
+
var rtn1 = this.fieldsDic[id];
|
|
125
|
+
for (let i = 0; i < rtn1.fileSourceList.length; i++) {
|
|
126
|
+
rtn1.fileSourceList[i].flagDeleted = true;
|
|
127
|
+
}
|
|
128
|
+
rtn1.fileList = [];
|
|
129
|
+
},
|
|
130
|
+
setTabsSelect(id) {
|
|
131
|
+
if (this.form && this.form.$vue) {
|
|
132
|
+
var f = this.fieldsDic[id];
|
|
133
|
+
if (this.form.isHorizontalLayout) {
|
|
134
|
+
this.form.$vue.activeName = f.collapseName.toString() === '-1' ? this.form.$vue.activeName : f.collapseName.toString();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
//路由提交
|
|
139
|
+
submit(fieldName1) {
|
|
140
|
+
if (this.form && this.form.$vue) {
|
|
141
|
+
this.form.$vue.fieldClickHandler({ fieldName1: fieldName1 });
|
|
142
|
+
}
|
|
143
|
+
},
|
|
139
144
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return this._excuteListData;
|
|
153
|
-
},
|
|
154
|
-
setExcuteListData(fields) {
|
|
155
|
-
this._excuteListData = null;
|
|
156
|
-
if (fields !== null) {
|
|
157
|
-
this.excuteData = fields;
|
|
158
|
-
this._excuteListData = fields.filter((v) => {
|
|
159
|
-
return typeof v.is !== undefined && (v.is === 'ct-formlist' || v.is === 'ct-repeat');
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
//获取列表的Field
|
|
164
|
-
getListField(tableName, rowNum, fiedlId) {
|
|
165
|
-
let listData = this.excuteListData.find((v) => {
|
|
166
|
-
return v.name === tableName;
|
|
145
|
+
//获取列表数据
|
|
146
|
+
get excuteListData() {
|
|
147
|
+
if (this._excuteListData) {
|
|
148
|
+
return this._excuteListData;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
if (this.excuteData !== null) {
|
|
152
|
+
this._excuteListData = this.excuteData.filter((v) => {
|
|
153
|
+
return typeof v.is !== undefined && (v.is === 'ct-formlist' || v.is === 'ct-repeat');
|
|
167
154
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return this._excuteListData;
|
|
158
|
+
},
|
|
159
|
+
setExcuteListData(fields) {
|
|
160
|
+
this._excuteListData = null;
|
|
161
|
+
if (fields !== null) {
|
|
162
|
+
this.excuteData = fields;
|
|
163
|
+
this._excuteListData = fields.filter((v) => {
|
|
164
|
+
return typeof v.is !== undefined && (v.is === 'ct-formlist' || v.is === 'ct-repeat');
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
//获取列表的Field
|
|
169
|
+
getListField(tableName, rowNum, fiedlId) {
|
|
170
|
+
let listData = this.excuteListData.find((v) => {
|
|
171
|
+
return v.name === tableName;
|
|
172
|
+
});
|
|
173
|
+
if (listData) {
|
|
174
|
+
let field = null;
|
|
175
|
+
//正在编辑的Field
|
|
176
|
+
if (rowNum === null && (fiedlId === null || listData.currentEventField.fieldName1 === fiedlId)) {
|
|
177
|
+
field = listData.currentEventField;
|
|
178
|
+
}
|
|
179
|
+
//正在编辑的行
|
|
180
|
+
else if (rowNum === null && listData.currentRowIndex === 0) {
|
|
181
|
+
let fields = listData.currentRow.data;
|
|
182
|
+
field = fields[fiedlId];
|
|
183
|
+
}
|
|
184
|
+
//源数据
|
|
185
|
+
else {
|
|
186
|
+
if (rowNum === null && listData.currentRowIndex) {
|
|
187
|
+
rowNum = listData.currentRowIndex;
|
|
188
|
+
}
|
|
184
189
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
}
|
|
190
|
+
if (rowNum === 0 || (rowNum && fiedlId)) {
|
|
191
|
+
try {
|
|
192
|
+
let fields = listData.rows[rowNum].field;
|
|
193
|
+
field = fields.find((v) => {
|
|
194
|
+
return v.fieldName1 === fiedlId;
|
|
195
|
+
});
|
|
196
|
+
} catch (e) {
|
|
197
|
+
if (listData.rows.length <= rowNum) {
|
|
198
|
+
common.message('获取列表行索引超出界限', 'error')
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
|
-
|
|
199
|
-
return { listData: listData, field: field };
|
|
200
201
|
}
|
|
201
|
-
}
|
|
202
|
-
//获取列表的行数(注意 这里包括列头)
|
|
203
|
-
getListCount(tableName) {
|
|
204
|
-
tableName = tableName ? tableName : this.form.scripts.$fd;
|
|
205
|
-
let data = this.getListField(tableName, null, null);
|
|
206
|
-
if (data) {
|
|
207
|
-
return data.listData.rows.length;
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
//获取表格某行某列的值
|
|
211
|
-
getListFieldValue(tableName, rowNum, fiedlId, attrName, defaultValue) {
|
|
212
|
-
tableName = tableName ? tableName : this.form.scripts.$fd;
|
|
213
|
-
let data = this.getListField(tableName, rowNum, fiedlId);
|
|
202
|
+
}
|
|
214
203
|
|
|
215
|
-
|
|
216
|
-
|
|
204
|
+
return { listData: listData, field: field };
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
//获取列表的行数(注意 这里包括列头)
|
|
208
|
+
getListCount(tableName) {
|
|
209
|
+
tableName = tableName ? tableName : this.form.scripts.$fd;
|
|
210
|
+
let data = this.getListField(tableName, null, null);
|
|
211
|
+
if (data) {
|
|
212
|
+
return data.listData.rows.length;
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
//获取表格某行某列的值
|
|
216
|
+
getListFieldValue(tableName, rowNum, fiedlId, attrName, defaultValue) {
|
|
217
|
+
tableName = tableName ? tableName : this.form.scripts.$fd;
|
|
218
|
+
let data = this.getListField(tableName, rowNum, fiedlId);
|
|
217
219
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
if (fiedlId && rowNum === null && fiedlId === data.listData.currentEventField.fieldName1) {
|
|
222
|
-
data.field = data.listData.currentEventField;
|
|
223
|
-
}
|
|
224
|
-
rowNum = rowNum !== null ? rowNum : data.listData.currentRowIndex;
|
|
225
|
-
|
|
226
|
-
//若该行正在编辑,则取编辑状态的。
|
|
227
|
-
if (data && data.listData && data.listData.currentRow.data && data.listData.currentRow.data[fiedlId]
|
|
228
|
-
&& data.listData.currentRow.data.$sourceIndex === rowNum && data.listData.currentRow.isSet) {
|
|
229
|
-
return data.listData.currentRow.data[fiedlId][attrName];
|
|
230
|
-
}
|
|
231
|
-
else if (data && data.field) {
|
|
232
|
-
if (typeof defaultValue !== 'undefined' && data.listData.rows[rowNum].deleted) {//若该行被删除时,则直接返回默认值
|
|
233
|
-
return defaultValue;
|
|
234
|
-
}
|
|
235
|
-
return data.field[attrName];
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
//设置表格某行某列的值
|
|
239
|
-
setListFieldValue(value, tableName, rowNum, fiedlId, attrName, flagTemplate) {
|
|
240
|
-
value = value == undefined ? "" : value.toString();
|
|
241
|
-
tableName = tableName ? tableName : this.form.scripts.$fd;
|
|
242
|
-
let data = this.getListField(tableName, rowNum, fiedlId);
|
|
243
|
-
|
|
244
|
-
attrName = common.initialsToLowerCase(attrName);
|
|
245
|
-
attrName = attrName ? attrName : 'code1';
|
|
220
|
+
attrName = common.initialsToLowerCase(attrName);
|
|
221
|
+
attrName = attrName ? attrName : 'code1';
|
|
246
222
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
223
|
+
if (!fiedlId) {
|
|
224
|
+
fiedlId = data.listData.currentEventField.fieldName1;
|
|
225
|
+
}
|
|
226
|
+
if (fiedlId && rowNum === null && fiedlId === data.listData.currentEventField.fieldName1) {
|
|
227
|
+
data.field = data.listData.currentEventField;
|
|
228
|
+
}
|
|
229
|
+
rowNum = rowNum !== null ? rowNum : data.listData.currentRowIndex;
|
|
250
230
|
|
|
251
|
-
|
|
231
|
+
//若该行正在编辑,则取编辑状态的。
|
|
232
|
+
if (data && data.listData && data.listData.currentRow.data && data.listData.currentRow.data[fiedlId]
|
|
233
|
+
&& data.listData.currentRow.data.$sourceIndex === rowNum && data.listData.currentRow.isSet) {
|
|
234
|
+
return data.listData.currentRow.data[fiedlId][attrName];
|
|
235
|
+
}
|
|
236
|
+
else if (data && data.field) {
|
|
237
|
+
if (typeof defaultValue !== 'undefined' && data.listData.rows[rowNum].deleted) {//若该行被删除时,则直接返回默认值
|
|
238
|
+
return defaultValue;
|
|
239
|
+
}
|
|
240
|
+
return data.field[attrName];
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
//设置表格某行某列的值
|
|
244
|
+
setListFieldValue(value, tableName, rowNum, fiedlId, attrName, flagTemplate, flagTostring) {
|
|
245
|
+
value = value == undefined ? "" :flagTostring==false?value:value.toString();
|
|
246
|
+
tableName = tableName ? tableName : this.form.scripts.$fd;
|
|
247
|
+
let data = this.getListField(tableName, rowNum, fiedlId);
|
|
252
248
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (data.listData.currentRow.data && data.listData.currentRow.data[fiedlId] && rowNum > -1
|
|
256
|
-
&& data.listData.currentRow.data.$sourceIndex === data.listData.source.rows[rowNum].$sourceIndex) {
|
|
257
|
-
let currentField = data.listData.currentRow.data[fiedlId];
|
|
258
|
-
currentField[attrName] = value;
|
|
259
|
-
//校验自己
|
|
260
|
-
if (currentField.validExcute) {
|
|
261
|
-
currentField.validExcute();
|
|
262
|
-
}
|
|
263
|
-
if (data.field) {
|
|
264
|
-
data.field[attrName] = value;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
else if (data.field) {
|
|
268
|
-
if (data.field) {
|
|
269
|
-
data.field[attrName] = value;
|
|
270
|
-
}
|
|
271
|
-
if (data.field.source) {
|
|
272
|
-
data.field.source[attrName] = value;
|
|
273
|
-
}
|
|
274
|
-
if (flagTemplate) {
|
|
275
|
-
data.field[attrName] = value;
|
|
276
|
-
}
|
|
277
|
-
if (data.listData.flagTemplate && data.listData.$vue) {
|
|
278
|
-
data.listData.$vue.itemKey = Math.random()
|
|
279
|
-
}
|
|
280
|
-
}
|
|
249
|
+
attrName = common.initialsToLowerCase(attrName);
|
|
250
|
+
attrName = attrName ? attrName : 'code1';
|
|
281
251
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
252
|
+
if (!fiedlId) {
|
|
253
|
+
fiedlId = data.listData.currentEventField.id;
|
|
254
|
+
}
|
|
255
|
+
rowNum = rowNum ? rowNum : data.listData.currentRowIndex;
|
|
287
256
|
|
|
288
|
-
|
|
257
|
+
if (data) {
|
|
258
|
+
//正在编辑的行
|
|
259
|
+
if (data.listData.currentRow.data && data.listData.currentRow.data[fiedlId] && rowNum > -1
|
|
260
|
+
&& data.listData.currentRow.data.$sourceIndex === data.listData.source.rows[rowNum].$sourceIndex) {
|
|
261
|
+
let currentField = data.listData.currentRow.data[fiedlId];
|
|
262
|
+
currentField[attrName] = value;
|
|
263
|
+
//校验自己
|
|
264
|
+
if (currentField.validExcute) {
|
|
265
|
+
currentField.validExcute();
|
|
289
266
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
//设置表格选择路由
|
|
293
|
-
setListSelectRouter(tableId, attrKey, attrValue) {
|
|
294
|
-
let listData = this.excuteListData.find((v) => {
|
|
295
|
-
return v.fieldName1 === tableId;
|
|
296
|
-
});
|
|
297
|
-
if (listData) {
|
|
298
|
-
var router = listData.selectRouter;
|
|
299
|
-
if (router) {
|
|
300
|
-
router[attrKey] = attrValue;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
//设置表格属性值
|
|
305
|
-
setListAttr(tableId, attrName, attrValue) {
|
|
306
|
-
let listData = this.excuteListData.find((v) => {
|
|
307
|
-
return v.fieldName1 === tableId;
|
|
308
|
-
});
|
|
309
|
-
if (listData) {
|
|
310
|
-
listData[attrName] = attrValue
|
|
267
|
+
if (data.field) {
|
|
268
|
+
data.field[attrName] = value;
|
|
311
269
|
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return v.fieldName1 === tableId;
|
|
317
|
-
});
|
|
318
|
-
if (listData) {
|
|
319
|
-
listData.$vue.insertRow(rows);
|
|
270
|
+
}
|
|
271
|
+
else if (data.field) {
|
|
272
|
+
if (data.field) {
|
|
273
|
+
data.field[attrName] = value;
|
|
320
274
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
insertSingleRow(tableId, row) {
|
|
324
|
-
let listData = this.excuteListData.find((v) => {
|
|
325
|
-
return v.fieldName1 === tableId;
|
|
326
|
-
});
|
|
327
|
-
if (listData) {
|
|
328
|
-
listData.$vue.insertSingleRow(row);
|
|
275
|
+
if (data.field.source) {
|
|
276
|
+
data.field.source[attrName] = value;
|
|
329
277
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
insertOrUpdateRow(tableId, row) {
|
|
333
|
-
let listData = this.excuteListData.find((v) => {
|
|
334
|
-
return v.fieldName1 === tableId;
|
|
335
|
-
});
|
|
336
|
-
if (listData) {
|
|
337
|
-
listData.$vue.insertOrUpdateRow(row);
|
|
278
|
+
if (flagTemplate) {
|
|
279
|
+
data.field[attrName] = value;
|
|
338
280
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
deleteRow(tableId, row) {
|
|
342
|
-
let listData = this.excuteListData.find((v) => {
|
|
343
|
-
return v.id === tableId;
|
|
344
|
-
});
|
|
345
|
-
if (listData) {
|
|
346
|
-
listData.$vue.delRow(row);
|
|
281
|
+
if (data.listData.flagTemplate && data.listData.$vue) {
|
|
282
|
+
data.listData.$vue.itemKey = Math.random()
|
|
347
283
|
}
|
|
348
|
-
}
|
|
349
|
-
//清空表格数据
|
|
350
|
-
clear(tableId) {
|
|
351
|
-
let listData = this.excuteListData.find((v) => {
|
|
352
|
-
return v.fieldName1 === tableId;
|
|
353
|
-
});
|
|
354
|
-
if (listData) {
|
|
355
|
-
listData.$vue.deleteAll();
|
|
356
|
-
}
|
|
357
|
-
},
|
|
284
|
+
}
|
|
358
285
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
286
|
+
//如果有汇总列,触发重新计算汇总
|
|
287
|
+
if (data.listData.showSummary) {
|
|
288
|
+
data.listData.tableData.push({});
|
|
289
|
+
data.listData.tableData.pop();
|
|
290
|
+
}
|
|
362
291
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
return false;
|
|
295
|
+
},
|
|
296
|
+
//设置表格选择路由
|
|
297
|
+
setListSelectRouter(tableId, attrKey, attrValue) {
|
|
298
|
+
let listData = this.excuteListData.find((v) => {
|
|
299
|
+
return v.fieldName1 === tableId;
|
|
300
|
+
});
|
|
301
|
+
if (listData) {
|
|
302
|
+
var router = listData.selectRouter;
|
|
303
|
+
if (router) {
|
|
304
|
+
router[attrKey] = attrValue;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
//设置表格属性值
|
|
309
|
+
setListAttr(tableId, attrName, attrValue) {
|
|
310
|
+
let listData = this.excuteListData.find((v) => {
|
|
311
|
+
return v.fieldName1 === tableId;
|
|
312
|
+
});
|
|
313
|
+
if (listData) {
|
|
314
|
+
listData[attrName] = attrValue
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
//新增表格数据
|
|
318
|
+
insertRow(tableId, rows) {
|
|
319
|
+
let listData = this.excuteListData.find((v) => {
|
|
320
|
+
return v.fieldName1 === tableId;
|
|
321
|
+
});
|
|
322
|
+
if (listData) {
|
|
323
|
+
listData.$vue.insertRow(rows);
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
//添加单选表格数据
|
|
327
|
+
insertSingleRow(tableId, row) {
|
|
328
|
+
let listData = this.excuteListData.find((v) => {
|
|
329
|
+
return v.fieldName1 === tableId;
|
|
330
|
+
});
|
|
331
|
+
if (listData) {
|
|
332
|
+
listData.$vue.insertSingleRow(row);
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
//新增或替换表格数据
|
|
336
|
+
insertOrUpdateRow(tableId, row) {
|
|
337
|
+
let listData = this.excuteListData.find((v) => {
|
|
338
|
+
return v.fieldName1 === tableId;
|
|
339
|
+
});
|
|
340
|
+
if (listData) {
|
|
341
|
+
listData.$vue.insertOrUpdateRow(row);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
//删除表格数据
|
|
345
|
+
deleteRow(tableId, row) {
|
|
346
|
+
let listData = this.excuteListData.find((v) => {
|
|
347
|
+
return v.id === tableId;
|
|
348
|
+
});
|
|
349
|
+
if (listData) {
|
|
350
|
+
listData.$vue.delRow(row);
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
//清空表格数据
|
|
354
|
+
clear(tableId) {
|
|
355
|
+
let listData = this.excuteListData.find((v) => {
|
|
356
|
+
return v.fieldName1 === tableId;
|
|
357
|
+
});
|
|
358
|
+
if (listData) {
|
|
359
|
+
listData.$vue.deleteAll();
|
|
360
|
+
}
|
|
361
|
+
},
|
|
366
362
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
var data = response.content;
|
|
371
|
-
if (response.clientActionType === Enum.ClientActionType.ExcuteScript && data) {
|
|
372
|
-
common.excute.call(formData.form.scripts, data);
|
|
373
|
-
}
|
|
374
|
-
else
|
|
375
|
-
if (response.clientActionType === Enum.ClientActionType.None && data && successCallback) {
|
|
376
|
-
//因为要传参,并直接执行方法,故successCallback回调里要使用formData的话,要加this
|
|
377
|
-
//若不能接受this,也可修改common.excute方法
|
|
378
|
-
//successCallback.call(formData.form.scripts, data);
|
|
363
|
+
//获取后台数据,并返回脚本。
|
|
364
|
+
execServerScript(action, object, successCallback) {
|
|
365
|
+
let formData = this;//作用域保存
|
|
379
366
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
367
|
+
//是否是行内触发的
|
|
368
|
+
let data = this.getListField(this.form.scripts.$fd, null, null);
|
|
369
|
+
object.editMode = data ? 1 : 0;
|
|
370
|
+
|
|
371
|
+
request.postHandler(common.globalUri(), { action: action, para: object }).then(
|
|
372
|
+
function (response) {
|
|
373
|
+
if (response.rtnCode === Enum.ReturnCode.Successful) {
|
|
374
|
+
var data = response.content;
|
|
375
|
+
if (response.clientActionType === Enum.ClientActionType.ExcuteScript && data) {
|
|
376
|
+
common.excute.call(formData.form.scripts, data);
|
|
384
377
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
378
|
+
else
|
|
379
|
+
if (response.clientActionType === Enum.ClientActionType.None && data && successCallback) {
|
|
380
|
+
//因为要传参,并直接执行方法,故successCallback回调里要使用formData的话,要加this
|
|
381
|
+
//若不能接受this,也可修改common.excute方法
|
|
382
|
+
//successCallback.call(formData.form.scripts, data);
|
|
383
|
+
|
|
384
|
+
//优化,不需要加this
|
|
385
|
+
common.excuteFun.call(formData.form.scripts, successCallback, data);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
},
|
|
391
|
+
execRouter(routerKey) {
|
|
392
|
+
let field = { fieldName1: routerKey };
|
|
393
|
+
this.form.$vue.fieldClickHandler(field);
|
|
394
|
+
},
|
|
395
|
+
//消息提示 type主题:success/warning/info/error。 duration 显示时间, 毫秒。设为 0 则不会自动关闭。 showClose 是否显示关闭按钮。
|
|
396
|
+
message(message, type, center, duration, showClose, dangerouslyUseHTMLString) {
|
|
397
|
+
common.message(message, type, center, duration, showClose, dangerouslyUseHTMLString)
|
|
398
|
+
},
|
|
395
399
|
};
|
|
396
400
|
|
|
397
401
|
export default formData;
|