bri-components 1.3.69 → 1.3.71

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bri-components",
3
- "version": "1.3.69",
3
+ "version": "1.3.71",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -119,7 +119,7 @@
119
119
  const curDateStr = this.$transformDate(date, "/", this.subType);
120
120
 
121
121
  // 日期字段的对比
122
- const compareResult = this.$validateComparedRuleFunc(
122
+ const compareResult = this.$normalComparedFunc(
123
123
  this.selfPropsObj,
124
124
  {
125
125
  ...this.value,
@@ -154,6 +154,12 @@
154
154
  return {};
155
155
  }
156
156
  },
157
+ inTableType: {
158
+ type: String,
159
+ validator (val) {
160
+ return ["flatTable", "cascaderTable", "treeTable"].includes(val);
161
+ }
162
+ },
157
163
 
158
164
  changedFields: {
159
165
  type: Array,
@@ -346,21 +352,6 @@
346
352
  let rules = [];
347
353
  let ruleConfig = this.$getFieldRuleConfig(formItem);
348
354
 
349
- // 格式校验 (不依赖必填)
350
- if (ruleConfig.regs.length) {
351
- rules.push({
352
- message: formItem._regMessage || `${formItem._name} 格式不正确!`,
353
- trigger: "blur",
354
- transform: (val) => {
355
- if (this.$isEmptyData(val)) {
356
- return val;
357
- } else {
358
- return ruleConfig.regs.every(regItem => regItem.test(val)) && val;
359
- }
360
- },
361
- ...ruleConfig
362
- });
363
- }
364
355
  // 必填校验
365
356
  if (formItem._required) {
366
357
  // 其他配置
@@ -383,6 +374,15 @@
383
374
  }
384
375
  }
385
376
  },
377
+ cascaderTable: {
378
+ fields: {
379
+ tree: {
380
+ required: true,
381
+ message: `${formItem._name} 不能为空行!`,
382
+ type: "array"
383
+ }
384
+ }
385
+ },
386
386
  referenceBy: {
387
387
  fields: {
388
388
  count: {
@@ -410,6 +410,49 @@
410
410
  });
411
411
  }
412
412
 
413
+ // 格式校验 (不依赖必填)
414
+ if (ruleConfig.regs.length) {
415
+ rules.push({
416
+ message: formItem._regMessage || `${formItem._name} 格式不正确!`,
417
+ trigger: "blur",
418
+ transform: (val) => {
419
+ if (this.$isEmptyData(val)) {
420
+ return val;
421
+ } else {
422
+ return ruleConfig.regs.every(regItem => regItem.test(val)) && val;
423
+ }
424
+ },
425
+ ...ruleConfig
426
+ });
427
+ }
428
+
429
+ // 对比校验(横向对比和层级对比)
430
+ if (["number", "date"].includes(formItem._type)) {
431
+ const tipObj = {};
432
+ rules.push({
433
+ message: "对比不通过!",
434
+ trigger: "blur, change",
435
+ transform: (val) => {
436
+ const comparedBool = this.$normalComparedFunc(
437
+ formItem,
438
+ this.formData,
439
+ this.parentObj,
440
+ formItem._isCompareByParent ? this.parentObj : undefined,
441
+ formItem._isCompareByParent ? this.parentFormList : this.allFormList,
442
+ tipObj,
443
+ this.inTableType
444
+ ) && this.$levelComparedFunc(formItem, this.formData, tipObj, this.inTableType);
445
+
446
+ if (comparedBool) {
447
+ return val;
448
+ } else {
449
+ return false;
450
+ }
451
+ },
452
+ ...ruleConfig
453
+ });
454
+ }
455
+
413
456
  return rules;
414
457
  },
415
458
  // 强行执行一些校验
@@ -7,7 +7,7 @@ export default {
7
7
  },
8
8
  computed: {
9
9
  allListData () {
10
- console.log("allListData");
10
+ // console.log("allListData");
11
11
  this.data.forEach(item => {
12
12
  !item._id && this.$set(item, "_id", this.$ObjectID().str);
13
13
 
@@ -20,7 +20,6 @@ export default {
20
20
  item.__isSearchShow__ = false;
21
21
  });
22
22
 
23
- console.log(this.initFlag);
24
23
  this.initFlag = false;
25
24
  return this.data;
26
25
  },
@@ -22,31 +22,31 @@ export default {
22
22
  },
23
23
 
24
24
  allTreeData () {
25
- console.log("allTreeData");
25
+ // console.log("allTreeData");
26
26
  return this.getCalcuedTree(this.data, this.columns);
27
27
  },
28
28
  allListData () {
29
- console.log("allListData");
29
+ // console.log("allListData");
30
30
  return this.$getTreeFlatArr(this.allTreeData);
31
31
  },
32
32
  footerData () {
33
- console.log("footerData");
33
+ // console.log("footerData");
34
34
  return this.isSearching
35
35
  ? []
36
36
  : this.useSummary && this.allListData.length
37
37
  ? [
38
- this.filterColumns.reduce((obj, col) => {
38
+ this.filterColumns.reduce((obj, column) => {
39
39
  return {
40
40
  ...obj,
41
- [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
41
+ [column._key]: column._type === "number" && ![undefined, null, "", "no"].includes(column._summaryType)
42
42
  ? this.$calNumList(
43
43
  this.allListData
44
44
  .filter(item => item.level === 1)
45
- .map(item => item[col._key]),
46
- col._summaryType,
47
- { ...col, _defaultDigit: 2 }
45
+ .map(item => item[column._key]),
46
+ column._summaryType,
47
+ { ...column, _defaultDigit: 2 }
48
48
  )
49
- : (obj[col._key] || "--")
49
+ : (obj[column._key] || "--")
50
50
  };
51
51
  }, {
52
52
  _id: this.$ObjectID().str,
@@ -76,11 +76,11 @@ export default {
76
76
  ? row.__isSearchShow__ === false
77
77
  ? " bri-table-td-hide"
78
78
  : ""
79
- : row.__isShow__ === false
80
- ? " bri-table-td-hide"
81
- : this.isExpandAction
79
+ : row.__isShow__ === true
80
+ ? this.isExpandAction
82
81
  ? " bri-table-td-visible"
83
82
  : ""
83
+ : " bri-table-td-hide"
84
84
  }` +
85
85
  `${["__isExpand__"].includes(column._key)
86
86
  ? " bri-table-td-expand"
@@ -214,7 +214,6 @@ export default {
214
214
  // 展开/隐藏节点
215
215
  toggleExpand (row, bool = true) {
216
216
  this.isExpandAction = true;
217
- // row.__isExpand__ = bool;
218
217
  this.$set(row, "__isExpand__", bool);
219
218
 
220
219
  this.toggleDescendantsShow(row, bool);
@@ -268,21 +267,18 @@ export default {
268
267
  getCalcuedTree (treeData = [], columns = []) {
269
268
  const loop = (list = [], parentRow) =>
270
269
  list.forEach((row) => {
271
- // 递归到叶子节点前 从上往下要处理的
272
- columns.reduce((newRow, col) => {
273
- const isNumberSummary = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType);
274
- const isDateSummary = col._type === "date" && ![undefined, null, ""].includes(col._writeSort);
275
-
276
- if (isNumberSummary || isDateSummary) {
277
- const val = isNumberSummary
278
- ? newRow[col._key]
279
- : ["downToUp"].includes(col._writeSort)
280
- ? newRow[col._key]
281
- : !parentRow || parentRow[col._key]
282
- ? newRow[col._key]
283
- : undefined;
270
+ // 递归到叶子节点前 从上往下执行 要处理的
271
+ columns.reduce((newRow, column) => {
272
+ if (
273
+ ["number", "date"].includes(column._type) &&
274
+ ["upToDown"].includes(column._writeSort)
275
+ ) {
276
+ // 第一级的和父级有值的,否则置空
277
+ const val = parentRow && !parentRow[column._key]
278
+ ? this.$deepCopy(this.initDftValMap[column._type])
279
+ : newRow[column._key];
284
280
 
285
- this.$set(newRow, col._key, val);
281
+ this.$set(newRow, column._key, val);
286
282
  }
287
283
 
288
284
  return newRow;
@@ -292,34 +288,54 @@ export default {
292
288
  row.isLeaf = false;
293
289
  loop(row.children, row);
294
290
 
295
- // 递归到叶子节点后 从下往上要处理的
296
- columns.reduce((newRow, col) => {
297
- const isNumberSummary = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType);
298
- const isDateSummary = col._type === "date" && ![undefined, null, ""].includes(col._writeSort);
291
+ // 递归到叶子节点后到 从下往上执行 要处理的(非叶子节点)
292
+ columns.reduce((newRow, column) => {
293
+ // if (
294
+ // ["number", "date"].includes(column._type) &&
295
+ // ["downToUp"].includes(column._writeSort)
296
+ // ) {
297
+ // // 第一级的和父级有值的,否则置空
298
+ // const val = newRow[column._key];
299
+
300
+ // this.$set(newRow, column._key, val);
301
+ // }
299
302
 
300
- if (isNumberSummary || isDateSummary) {
301
- const val = isNumberSummary
303
+ if (
304
+ ["number", "date"].includes(column._type) &&
305
+ ![undefined, null, "", "no"].includes(column._summaryType)
306
+ ) {
307
+ const val = ["number"].includes(column._type)
302
308
  ? this.$calNumList(
303
- newRow.children.map(subRow => subRow[col._key]),
304
- col._summaryType,
305
- { ...col, _defaultDigit: 2 },
309
+ newRow.children.map(subRow => subRow[column._key]),
310
+ column._summaryType,
311
+ { ...column, _defaultDigit: 2 },
306
312
  false
307
313
  )
308
- : ["downToUp"].includes(col._writeSort)
309
- ? this.$calDateList(
310
- newRow.children.map(subRow => subRow[col._key]),
311
- col._compareOperator,
312
- col._dateType
313
- )
314
- : newRow[col._key];
314
+ : this.$calDateList(
315
+ newRow.children.map(subRow => subRow[column._key]),
316
+ column._summaryType,
317
+ column._dateType
318
+ );
315
319
 
316
- this.$set(newRow, col._key, val);
320
+ this.$set(newRow, column._key, val);
317
321
  }
318
322
 
319
323
  return newRow;
320
324
  }, row);
321
325
  } else {
322
326
  row.isLeaf = true;
327
+
328
+ // 递归到叶子节点前 从上往下执行 要处理的(叶子节点)
329
+ columns.reduce((newRow, column) => {
330
+ if (
331
+ ["number", "date"].includes(column._type) &&
332
+ ![undefined, null, "", "no"].includes(column._summaryType)
333
+ ) {
334
+ this.$set(newRow, column._key, newRow[column._key]);
335
+ }
336
+
337
+ return newRow;
338
+ }, row);
323
339
  }
324
340
 
325
341
  // 初次进来把前端存的状态值全部清除(除了__readonly__)
@@ -329,6 +345,7 @@ export default {
329
345
  });
330
346
 
331
347
  row.__old__ = true; // 老的数据都打上标记 尽管不一定会用
348
+
332
349
  // row.__isExpand__ = false;
333
350
  // row.__isSearchShow__ = false;
334
351
  // 第一级的需要显示出来
@@ -223,6 +223,11 @@ export default {
223
223
  ...this.commonPropsObj
224
224
  };
225
225
  },
226
+ inTableType () {
227
+ return this.controlType === "cascaderTable" && ["treeTable"].includes(this.selfPropsObj._showMode)
228
+ ? this.selfPropsObj._showMode
229
+ : this.controlType;
230
+ },
226
231
  // isShare () {
227
232
  // return this.selfPropsObj.isShare;
228
233
  // },
@@ -337,7 +342,7 @@ export default {
337
342
  },
338
343
 
339
344
  renderedListData () {
340
- console.log("renderedListData");
345
+ // console.log("renderedListData");
341
346
  return this.allListData.filter(row => {
342
347
  if (this.isSearching) {
343
348
  const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, row);
@@ -354,7 +359,7 @@ export default {
354
359
  });
355
360
  },
356
361
  showListData () {
357
- console.log("showListData");
362
+ // console.log("showListData");
358
363
  return this.renderedListData.filter(row =>
359
364
  this.isSearching
360
365
  ? !!row.__isSearchShow__
@@ -446,18 +451,24 @@ export default {
446
451
  return {
447
452
  _id: this.parentDataId,
448
453
  _key: this.controlKey,
449
- importType: this.controlType === "cascaderTable" && ["treeTable"].includes(this.selfPropsObj._showMode)
450
- ? this.selfPropsObj._showMode
451
- : this.controlType
454
+ importType: this.inTableType
455
+ };
456
+ },
457
+ exportParams () {
458
+ return {
459
+ screenKey: this.screenKey,
460
+ _id: this.parentDataId,
461
+ _key: this.controlKey,
462
+ advSearch: this.finalTableAdvSearch
452
463
  };
453
464
  },
454
465
 
455
466
  filterColumns () {
456
- console.log("filterColumns");
467
+ // console.log("filterColumns");
457
468
  return this.columns.filter(col => this.$isAdvRelyShow(col, this.allListData, this.parentObj, true));
458
469
  },
459
470
  contentColumns () {
460
- console.log("contentColumns");
471
+ // console.log("contentColumns");
461
472
  return this.filterColumns.map(colItem => ({
462
473
  filter: undefined,
463
474
  sortBy: undefined,
@@ -465,6 +476,7 @@ export default {
465
476
  column = this.$transformDynamicProperty(column, row, this.parentObj);
466
477
  column = this.resetCol(column, row);
467
478
  const unitCanEdit = this.getUnitCanEdit(column, row);
479
+ const ruleResultObj = this.getColRuleResult(column, row, rowIndex);
468
480
 
469
481
  return [
470
482
  this.isShowCompare(column, row, this.compareListData[rowIndex])
@@ -517,10 +529,10 @@ export default {
517
529
  }),
518
530
 
519
531
  // 校验文字
520
- !this.getColRuleResult(column, row, rowIndex).bool
532
+ !ruleResultObj.bool
521
533
  ? h("span", {
522
534
  class: "bri-table-td-tip"
523
- }, this.getColRuleResult(column, row, rowIndex).message)
535
+ }, ruleResultObj.message)
524
536
  : undefined
525
537
  ];
526
538
  },
@@ -718,15 +730,26 @@ export default {
718
730
  // 引用回调
719
731
  quoteCb (dataObj) {
720
732
  if (dataObj) {
721
- const cb = () => {
722
- this.$Message.success("引用成功!");
723
- this.reset();
724
- this.selfReset && this.selfReset();
733
+ const fieldVal = dataObj[this.controlKey];
734
+ const isEmpty = this.$isEmptyData(fieldVal) || (
735
+ ["flatTable"].includes(this.controlType)
736
+ ? !fieldVal.list || !fieldVal.list.length
737
+ : ["cascaderTable"].includes(this.controlType)
738
+ ? !fieldVal.tree || !fieldVal.tree.length
739
+ : false
740
+ );
725
741
 
742
+ if (isEmpty) {
743
+ this.$Modal.confirm({
744
+ title: "提示",
745
+ content: "该数据下此内容为空,无法引用!",
746
+ onOk: () => { }
747
+ });
748
+ } else {
726
749
  if (["flatTable"].includes(this.controlType)) {
727
750
  this.parentObj[this.controlKey] = {
728
- ...dataObj[this.controlKey],
729
- list: dataObj[this.controlKey].list.map(item => ({
751
+ ...fieldVal,
752
+ list: fieldVal.list.map(item => ({
730
753
  ...item,
731
754
  __isQuote__: true
732
755
  }))
@@ -744,28 +767,15 @@ export default {
744
767
  };
745
768
 
746
769
  this.parentObj[this.controlKey] = {
747
- ...dataObj[this.controlKey],
748
- tree: transformData(dataObj[this.controlKey].tree)
770
+ ...fieldVal,
771
+ tree: transformData(fieldVal.tree)
749
772
  };
750
773
  }
751
774
 
775
+ this.$Message.success("引用成功!");
776
+ this.reset();
777
+ this.selfReset && this.selfReset();
752
778
  this.change("quote");
753
- };
754
-
755
- const isEmpty = this.$isEmptyData(dataObj[this.controlKey]) ||
756
- (["flatTable"].includes(this.controlType)
757
- ? !dataObj[this.controlKey].list || !dataObj[this.controlKey].list.length
758
- : ["cascaderTable"].includes(this.controlType)
759
- ? !dataObj[this.controlKey].tree || !dataObj[this.controlKey].tree.length
760
- : false);
761
- if (isEmpty) {
762
- this.$Modal.confirm({
763
- title: "提示",
764
- content: "该数据下此内容为空,无法引用!",
765
- onOk: () => { }
766
- });
767
- } else {
768
- cb();
769
779
  }
770
780
  } else {
771
781
  this.$Message.error("未选择引用数据!");
@@ -816,12 +826,7 @@ export default {
816
826
  module: "sheet",
817
827
  name: ["flatTable"].includes(this.controlType) ? "exportFlatTableExcel" : "exportCascaderTableExcel"
818
828
  },
819
- params: {
820
- screenKey: this.screenKey,
821
- _id: this.parentObj._id,
822
- _key: this.controlKey,
823
- advSearch: this.finalTableAdvSearch
824
- },
829
+ params: this.exportParams,
825
830
  callback: data => {
826
831
  this.getJobStatus(operationItem, data.jobId, data.excel_url);
827
832
  this.exportTimer = setInterval(() => {
@@ -1001,7 +1006,27 @@ export default {
1001
1006
  col = this.$transformDynamicProperty(col, row, this.parentObj);
1002
1007
 
1003
1008
  if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || this.showRuleMessage) {
1004
- return this.$getFieldRuleResult(col, row);
1009
+ const ruleResultObj = this.$getFieldRuleResult(col, row);
1010
+
1011
+ if (ruleResultObj.bool) {
1012
+ const tipObj = {};
1013
+ const comparedBool = this.$normalComparedFunc(
1014
+ col,
1015
+ row,
1016
+ this.parentObj,
1017
+ col._isCompareByParent ? this.parentObj : undefined,
1018
+ col._isCompareByParent ? this.allFormList : this.columns,
1019
+ tipObj,
1020
+ this.inTableType
1021
+ ) && this.$levelComparedFunc(col, row, tipObj, this.inTableType);
1022
+
1023
+ return {
1024
+ bool: comparedBool,
1025
+ message: tipObj.message
1026
+ };
1027
+ } else {
1028
+ return ruleResultObj;
1029
+ }
1005
1030
  } else {
1006
1031
  return {
1007
1032
  bool: true
@@ -1021,22 +1046,14 @@ export default {
1021
1046
  // 列本身是否可编辑
1022
1047
  getColCanEdit (col, row) {
1023
1048
  return (
1024
- ["cascaderTable"].includes(this.controlType)
1025
- ? (
1026
- // 树形表格 -“需要计算的数字列 且 不是叶子行的”不可编辑(必须用isLeaf !== false判断,因为牵扯内部表格也在用)
1027
- ["number"].includes(col._type) && ![undefined, null, "", "no"].includes(col._summaryType)
1028
- ? row.isLeaf === true
1029
- : true
1030
- ) && (
1031
- // 树形表格 -“需要限制的日期列 且 不是叶子行的”不可编辑(必须用isLeaf !== false判断,因为牵扯内部表格也在用)
1032
- ["date"].includes(col._type)
1033
- ? ["downToUp"].includes(col._writeSort)
1034
- ? row.isLeaf === true
1035
- : ["upToDown"].includes(col._writeSort)
1036
- ? row.level === 1 || !!this.getParentNode(row, this.allTreeData)[col._key]
1037
- : true
1049
+ ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(col._type)
1050
+ ? ![undefined, null, "", "no"].includes(col._summaryType)
1051
+ ? row.isLeaf === true
1052
+ // : ["downToUp"].includes(col._writeSort)
1053
+ // ? row.isLeaf === true
1054
+ : ["upToDown"].includes(col._writeSort)
1055
+ ? row.level === 1 || !!this.getParentNode(row, this.allTreeData)[col._key]
1038
1056
  : true
1039
- )
1040
1057
  : true
1041
1058
  ) &&
1042
1059
  (col._oldReadonly ? row.__old__ !== true : true) && // 老数据行里某些列不可编辑