centaline-data-driven 1.1.33 → 1.1.37

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.
@@ -1,10 +1,10 @@
1
1
  import base from '../../index';
2
- import Axios from 'axios';
3
2
  import LibFunction from './lib/LibFunction';
4
3
  import Enum from './lib/Enum';
5
4
  import Router from './Router';
6
5
  import valid from '../../../validate/index';
7
6
  import common from '../../../common';
7
+ import formData from '../../../formData';
8
8
  import Vue from 'vue';
9
9
 
10
10
  const Form = function (source, callBack, apiParam, failCallBack, isFormList) {
@@ -144,324 +144,7 @@ const Form = function (source, callBack, apiParam, failCallBack, isFormList) {
144
144
  }
145
145
  }
146
146
  },
147
- formData: {
148
- common: common,
149
- Axios: Axios,
150
- form: null,
151
-
152
- excuteData: null,//fields
153
- fieldsDic: null,//fieldsDic
154
- getCode1ByField1(id) {
155
- //var rtn1 = this.excuteData.find((v) => {
156
- // return v.id === arguments[0];
157
- //});
158
- var rtn1 = this.fieldsDic[id];
159
- if (rtn1) {
160
- return rtn1.value;
161
- }
162
- },
163
- getCode2ByField1(id) {
164
- var rtn1 = this.fieldsDic[id];
165
- if (rtn1) {
166
- return rtn1.value1;
167
- }
168
- },
169
- /**
170
- * @method
171
- * @param {string} id 指定Field的fieldName1
172
- * @param {string} attrKey 指定Field的属性attrKey
173
- * @desc 获取指定Field的指定Field的值
174
- * @returns {string} 指定Field的指定Field的值
175
- */
176
- getValueByFieldName(id, attrKey) {
177
- attrKey = this.common.initialsToUpperCase(attrKey);
178
- var rtn1 = this.fieldsDic[id];
179
- if (rtn1) {
180
- return rtn1.source[attrKey];
181
- }
182
- },
183
- /**
184
- * @method
185
- * @param {string} id 指定Field的fieldName1
186
- * @param {string} attrKey 指定Field的属性名
187
- * @param {string} attrValue 需要设置的属性值
188
- * @desc 设置指定Field的指定Field的值
189
- * @returns {boolean} 是否成功
190
- */
191
- setValueByFieldName(id, attrKey, attrValue) {
192
- attrKey = this.common.initialsToUpperCase(attrKey);
193
- var rtn1 = this.fieldsDic[id];
194
- if (rtn1) {
195
- rtn1.source[attrKey] = attrValue;
196
-
197
- this.form.hatchHandle(id, attrKey, attrValue, rtn1);
198
- //this.form.hiddenHandle(rtn1);//隐藏关联的
199
-
200
- //用于处理源数据改动,强制更新视图数据 todo
201
- if (rtn1.self.$forceUpdate) {
202
- rtn1.self.$forceUpdate();
203
- }
204
- }
205
- },
206
- setV1AndV2ByField1(id, code1, code2) {
207
- var rtn1 = this.fieldsDic[id];
208
- if (rtn1) {
209
- if (typeof rtn1.value !== 'undefined') {
210
- rtn1.value = code1;
211
-
212
- this.form.validMrf(rtn1);//验证必填关联组件
213
- this.form.hiddenHandle(rtn1, true);//隐藏关联的
214
- }
215
- if (typeof rtn1.value1 !== 'undefined') {
216
- rtn1.value1 = code2;
217
- }
218
-
219
- if (rtn1.self.$forceUpdate) {
220
- rtn1.self.$forceUpdate();
221
- }
222
- }
223
- },
224
-
225
- _excuteListData: undefined,
226
- get excuteListData() {
227
- if (this._excuteListData) {
228
- return this._excuteListData;
229
- }
230
- else {
231
- if (this.excuteData !== null) {
232
- this._excuteListData = this.excuteData.filter((v) => {
233
- return typeof v.is !== undefined && v.is === 'ct-form-list-table';
234
- });
235
- }
236
- }
237
- return this._excuteListData;
238
- },
239
- //获取列表的Field
240
- getListField(tableName, rowNum, fiedlId) {
241
- let listData = this.excuteListData.find((v) => {
242
- return v.id === tableName;
243
- });
244
- if (listData) {
245
- let field = null;
246
- //正在编辑的Field
247
- if (rowNum === null && (fiedlId === null || listData.currentEventField.id === fiedlId)) {
248
- field = listData.currentEventField;
249
- }
250
- //正在编辑的行
251
- else if (rowNum === null && listData.currentRowIndex === 0) {
252
- let fields = listData.currentRow.data;
253
- field = fields[fiedlId];
254
- }
255
- //源数据
256
- else {
257
- if (rowNum === null && listData.currentRowIndex) {
258
- rowNum = listData.currentRowIndex;
259
- }
260
-
261
- if (rowNum === 0 || (rowNum && fiedlId)) {
262
- try {
263
- let fields = listData.rows[rowNum].field;
264
- field = fields.find((v) => {
265
- return v.id === fiedlId;
266
- });
267
- } catch (e) {
268
- if (listData.rows.length <= rowNum) {
269
- var checkMsg = "获取列表行索引超出界限";
270
- this.message(checkMsg);
271
- }
272
- }
273
- }
274
- }
275
-
276
- return { listData: listData, field: field };
277
- }
278
- },
279
- /**
280
- * @method
281
- * @param {string} tableName 指定的表fieldName1 默认当前表
282
- * @desc 获取指定列表的行数(注意 这里包括列头)
283
- * @returns {number} 列表行数
284
- */
285
- getListCount(tableName) {
286
- tableName = tableName ? tableName : this.form.scripts.$fd;
287
-
288
- let data = this.getListField(tableName, null, null);
289
-
290
- if (data) {
291
- return data.listData.rows.length;
292
- }
293
- },
294
-
295
- /**
296
- * @method
297
- * @param {String} tableName 表fieldName1 默认当前表
298
- * @param {Number} rowNum 行号 默认当前行号(注意 这里第0行是列头)
299
- * @param {String} fiedlId 列fieldName1 默认当前列fieldName1
300
- * @param {String} attrName 需要获取attr,如code1,code2 默认code1
301
- * @param {String} defaultValue 默认值,若该行被删除时,则直接返回这个值,可空
302
- * @desc 获取指定列表中的指定Field的指定属性值
303
- * @returns {String} 指定列表中的指定Field的指定属性值
304
- */
305
- getListFieldValue(tableName, rowNum, fiedlId, attrName, defaultValue) {
306
- tableName = tableName ? tableName : this.form.scripts.$fd;
307
-
308
- let data = this.getListField(tableName, rowNum, fiedlId);
309
-
310
- attrName = this.common.initialsToUpperCase(attrName);
311
- attrName = attrName ? attrName : 'code1';
312
-
313
- if (!fiedlId) {
314
- fiedlId = data.listData.currentEventField.id;
315
- }
316
- if (fiedlId && rowNum === null && fiedlId === data.listData.currentEventField.id) {
317
- data.field = data.listData.currentEventField;
318
- }
319
- rowNum = rowNum !== null ? rowNum : data.listData.currentRowIndex;
320
-
321
- //若该行正在编辑,则取编辑状态的。
322
- if (data && data.listData && data.listData.currentRow.data && data.listData.currentRow.data[fiedlId]
323
- && data.listData.currentRow.data.$sourceIndex === rowNum && data.listData.currentRow.isSet) {
324
- return data.listData.currentRow.data[fiedlId].source[attrName];
325
- }
326
- else if (data && data.field) {
327
- if (typeof defaultValue !== 'undefined' && data.listData.rows[rowNum].deleted) {//若该行被删除时,则直接返回默认值
328
- return defaultValue;
329
- }
330
- return data.field.source[attrName];
331
- }
332
- },
333
-
334
- /**
335
- * @method
336
- * @param {String} value 设置的值
337
- * @param {String} tableName 表fieldName1
338
- * @param {Number} rowNum 行号 默认当前行号(注意 这里第0行是列头)
339
- * @param {String} fiedlId 列fieldName1
340
- * @param {String} attrName 需要改的attrName,如code1,code2
341
- * @desc 设置指定列表中的指定Field的指定属性
342
- * @returns {boolean} 是否成功
343
- */
344
- setListFieldValue(value, tableName, rowNum, fiedlId, attrName) {
345
- value = value.toString();
346
- tableName = tableName ? tableName : this.form.scripts.$fd;
347
- let data = this.getListField(tableName, rowNum, fiedlId);
348
-
349
- attrName = this.common.initialsToUpperCase(attrName);
350
- attrName = attrName ? attrName : 'code1';
351
-
352
- if (!fiedlId) {
353
- fiedlId = data.listData.currentEventField.id;
354
- }
355
- if (fiedlId && !rowNum && fiedlId === data.listData.currentEventField.id) {
356
- //data.field = data.listData.currentEventField;
357
- }
358
- rowNum = rowNum ? rowNum : data.listData.currentRowIndex;
359
-
360
- if (data) {
361
- if (data.field) {
362
- data.field.source[attrName] = value;
363
- data.listData.updateListField(data.listData.refFieldsLabel, rowNum, fiedlId);
364
- }
365
- //data.field.self.$forceUpdate();
366
-
367
- //正在编辑的行
368
- if (data.listData.currentRow.data && data.listData.currentRow.data[fiedlId] && data.listData.currentRow.data.$sourceIndex === rowNum) {
369
- let currentField = data.listData.currentRow.data[fiedlId];
370
- currentField.source[attrName] = value;
371
- //校验自己
372
- if (currentField.self && currentField.self.validExcute) {
373
- currentField.self.validExcute();
374
- }
375
- if (typeof currentField.self.$forceUpdate === "function") {
376
- currentField.self.$forceUpdate();
377
- }
378
- }
379
-
380
- //如果有汇总列,触发重新计算汇总
381
- if (data.listData.showSummary) {
382
- data.listData.tableData.push({});
383
- data.listData.tableData.pop();
384
- }
385
-
386
- return true;
387
- }
388
- return false;
389
- },
390
-
391
- setListAttr(tableId, attrName, attrValue) {
392
- let listData = this.excuteListData.find((v) => {
393
- return v.id === tableId;
394
- });
395
- listData[attrName] = attrValue
396
-
397
- },
398
-
399
- /**
400
- * @method
401
- * @param {String} action action。
402
- * @param {Object} object 传到后台的数据。
403
- * @param {Function} successCallback 成功后的回调,只有请求成功且response.ClientAction==1时才执行。
404
- * @desc 获取后台数据,并返回脚本。
405
- */
406
- execServerScript(action, object, successCallback) {
407
- let formData = this;//作用域保存
408
-
409
- //是否是行内触发的
410
- let data = this.getListField(this.form.scripts.$fd, null, null);
411
- object.editMode = data ? 1 : 0;
412
-
413
- Vue.prototype.$api.postHandler(this.common.globalUri(), { action: action, para: object }).then(
414
- function (response) {
415
- if (response.rtnCode === Enum.ReturnCode.Successful) {
416
- var data = response.content;
417
- if (response.clientActionType === Enum.ClientActionType.ExcuteScript && data) {
418
- formData.common.excute.call(formData.form.scripts, data);
419
- }
420
- else
421
- if (response.clientActionType === Enum.ClientActionType.None && data && successCallback) {
422
- //因为要传参,并直接执行方法,故successCallback回调里要使用formData的话,要加this
423
- //若不能接受this,也可修改common.excute方法
424
- //successCallback.call(formData.form.scripts, data);
425
-
426
- //优化,不需要加this
427
- formData.common.excuteFun.call(formData.form.scripts, successCallback, data);
428
- }
429
- }
430
- }
431
- );
432
- },
433
-
434
- /**
435
- * @method
436
- * @param {string} message 消息文字。
437
- * @param {string} type 主题:success/warning/info/error。
438
- * @param {boolean} center 是否居中。
439
- * @param {number} duration 显示时间, 毫秒。设为 0 则不会自动关闭。
440
- * @param {boolean} showClose 是否显示关闭按钮。
441
- * @param {boolean} dangerouslyUseHTMLString 是否将message作为html处理。
442
- * @desc 消息提示。常用于主动操作后的反馈提示。
443
- */
444
- message(message, type, center, duration, showClose, dangerouslyUseHTMLString) {
445
- if (typeof center === 'undefined') {
446
- center = true;
447
- }
448
- if (typeof duration === 'undefined') {
449
- duration = 1500;
450
- }
451
- if (typeof showClose === 'undefined') {
452
- showClose = false;
453
- }
454
-
455
- Vue.prototype.$message({
456
- message: message,//消息文字
457
- dangerouslyUseHTMLString: dangerouslyUseHTMLString || false,
458
- type: type || 'error',//主题:success/warning/info/error
459
- center: center,//是否居中
460
- duration: duration, //显示时间, 毫秒。设为 0 则不会自动关闭
461
- showClose: showClose,//是否显示关闭按钮
462
- });
463
- }
464
- },
147
+ formData:formData,
465
148
  getFormObj() {
466
149
  var rtnFormObj = {};
467
150
  rtn.fields.forEach((f) => {
@@ -3,6 +3,7 @@ import common from '../../../common';
3
3
  import Router from './Router';
4
4
  import Vue from 'vue';
5
5
  import Enum from './lib/Enum';
6
+ import formData from '../../../formData';
6
7
  const SearchTable = function (data, callBack, searchModel, flagSearch, defaultSearchData) {
7
8
  var init = function (source) {
8
9
  var rtn = {
@@ -725,7 +726,24 @@ const SearchTable = function (data, callBack, searchModel, flagSearch, defaultSe
725
726
  }
726
727
  }
727
728
  });
728
- }
729
+ },
730
+ _scripts: null,
731
+ get scripts() {
732
+ if (rtn._scripts !== null) {
733
+ return rtn._scripts;
734
+ }
735
+ else {
736
+ if (typeof source.scripts !== 'undefined') {
737
+ rtn._scripts = base.common.eval(source.scripts);
738
+ return rtn._scripts;
739
+ }
740
+ else{
741
+ rtn._scripts={};
742
+ return rtn._scripts;
743
+ }
744
+ }
745
+ },
746
+ formData:formData,
729
747
  };
730
748
  if (rtn.template) {
731
749
  var tempLoader = template.loader(rtn.template).default;
@@ -62,7 +62,15 @@ const actions = {
62
62
  }
63
63
  },
64
64
  number(v, o) {
65
- var reg = /^[0-9]+$|^[0-9]+\.[0-9]*$|^[0-9]{1,3}([,'][0-9]{3})+$|^[0-9]{1,3}([,'][0-9]{3})+\.[0-9]*$/;
65
+ // var reg = /^[0-9]+$|^[0-9]+\.[0-9]*$|^[0-9]{1,3}([,'][0-9]{3})+$|^[0-9]{1,3}([,'][0-9]{3})+\.[0-9]*$/;
66
+ var reg = '';
67
+ let dc = v.decimals;
68
+ if (dc == undefined || dc == "" || dc === "0") {
69
+ reg = /^(\-)?\d*$/;
70
+ }
71
+ else{
72
+ reg = new RegExp("^(\\-)?\\d*[.]{0,1}(\\d{1," + dc + "})?$");
73
+ }
66
74
  if (v.value === '') {
67
75
  return true;
68
76
  } else if (reg.test(v.value)) {
@@ -87,7 +95,15 @@ const actions = {
87
95
  }
88
96
  },
89
97
  numberArea(v, o, o1) {
90
- var reg = /^[0-9]+$|^[0-9]+\.[0-9]*$|^[0-9]{1,3}([,'][0-9]{3})+$|^[0-9]{1,3}([,'][0-9]{3})+\.[0-9]*$/;
98
+ // var reg = /^[0-9]+$|^[0-9]+\.[0-9]*$|^[0-9]{1,3}([,'][0-9]{3})+$|^[0-9]{1,3}([,'][0-9]{3})+\.[0-9]*$/;
99
+ var reg = '';
100
+ let dc = v.decimals;
101
+ if (dc == undefined || dc == "" || dc === "0") {
102
+ reg = /^(\-)?\d*$/;
103
+ }
104
+ else{
105
+ reg = new RegExp("^(\\-)?\\d*[.]{0,1}(\\d{1," + dc + "})?$");
106
+ }
91
107
  if (v.value === '' && v.value1 === '') {
92
108
  return true;
93
109
  } else if ((v.value === '' || reg.test(v.value)) && (v.value1 === '' || reg.test(v.value1))) {
@@ -172,7 +188,6 @@ const valid = {
172
188
  switch (model.type) {
173
189
  case Enum.ControlType.NumericTextBox:
174
190
  rtnValidate.push(valid.number);
175
- //rtnValidate.push(valid.numberDecimal);
176
191
  break;
177
192
  case Enum.ControlType.NumericRange:
178
193
  rtnValidate.push(valid.numberArea);
@@ -219,7 +234,6 @@ const valid = {
219
234
  switch (model.type) {
220
235
  case Enum.ControlType.NumericTextBox:
221
236
  rtnValidate.push(valid.number);
222
- //rtnValidate.push(valid.numberDecimal);
223
237
  break;
224
238
  case Enum.ControlType.NumericRange:
225
239
  rtnValidate.push(valid.numberArea);
package/src/main.js CHANGED
@@ -20,6 +20,12 @@ Vue.use(centaline, {
20
20
  openTab: function (action) {
21
21
  alert("打开tab页:" + action)
22
22
  },
23
+ openDetail: function (action) {
24
+ alert("打开tab页:" + action)
25
+ },
26
+ openPropertyDetailRET: function (submitData, pageTitle, parentModel) {
27
+ alert("打开tab页:" + pageTitle)
28
+ },
23
29
  // 关闭当前tab
24
30
  closeTab: function () {
25
31
  alert("关闭当前tab")
@@ -27,7 +33,7 @@ Vue.use(centaline, {
27
33
  // 获取请求头
28
34
  getRequestHeaders: function () {
29
35
  return {
30
- oldToken: 'd09609ec-e13a-4b97-8c15-e003b1c36cbc',
36
+ oldToken: '2db49cf6-0026-428b-9167-4273376a076f',
31
37
  estateId: '20210729104021C49F04B55C50F6AF58',
32
38
  };
33
39
  },