bri-components 1.3.72 → 1.3.74

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.72",
3
+ "version": "1.3.74",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -309,7 +309,7 @@
309
309
  return compareDateStr
310
310
  ? this.isDynDateKey(compareDateStr)
311
311
  ? true
312
- : !this.$isComparedAccord(curDateStr, compareDateStr, compareOperator, "date", this.subType, this.subType).bool
312
+ : !this.$isComparedAccord(curDateStr, compareDateStr, compareOperator, "date", this.subType, this.subType)
313
313
  : false;
314
314
  }
315
315
  };
@@ -355,59 +355,21 @@
355
355
 
356
356
  // 必填校验
357
357
  if (formItem._required) {
358
- // 其他配置
359
- const subFieldsMap = {
360
- coordinates: {
361
- fields: {
362
- lnglat: {
363
- required: true,
364
- message: `${formItem._name}为必填项!`,
365
- type: "array"
366
- }
367
- }
368
- },
369
- flatTable: {
370
- fields: {
371
- list: {
372
- required: true,
373
- message: `${formItem._name}不能为空行!`,
374
- type: "array"
375
- }
376
- }
377
- },
378
- cascaderTable: {
379
- fields: {
380
- tree: {
381
- required: true,
382
- message: `${formItem._name}不能为空行!`,
383
- type: "array"
384
- }
385
- }
386
- },
387
- referenceBy: {
388
- fields: {
389
- count: {
390
- message: `${formItem._name}必须关联数据!`,
391
- type: "number",
392
- transform: (val) => {
393
- if (val && val > 0) {
394
- return val;
395
- } else {
396
- return false;
397
- }
398
- }
399
- }
400
- }
401
- }
402
- };
403
-
404
358
  rules.push({
405
359
  required: true,
406
360
  message: `${formItem._name}为必填项!`,
407
361
  trigger: "blur, change",
408
362
  type: "string",
409
- ...(subFieldsMap[formItem._type] || {}),
410
- ...ruleConfig
363
+ ...ruleConfig,
364
+ fields: ruleConfig.fields && Object.entries(ruleConfig.fields).reduce((obj, arr) => {
365
+ return {
366
+ ...obj,
367
+ [arr[0]]: {
368
+ ...arr[1],
369
+ message: `${formItem._name}${arr[1].message || ""}`
370
+ }
371
+ };
372
+ }, ruleConfig.fields)
411
373
  });
412
374
  }
413
375
 
@@ -416,32 +378,34 @@
416
378
  rules.push({
417
379
  message: formItem._regMessage || `${formItem._name}格式不正确!`,
418
380
  trigger: "blur",
381
+ type: "string",
419
382
  transform: (val) => {
420
- if (this.$isEmptyData(val)) {
421
- return val;
422
- } else {
423
- return ruleConfig.regs.every(regItem => regItem.test(val)) && val;
424
- }
383
+ return this.$isEmptyData(val)
384
+ ? val
385
+ : ruleConfig.regs.every(regItem => regItem.test(val)) && val;
425
386
  },
426
387
  ...ruleConfig
427
388
  });
428
389
  }
429
390
 
430
- // 对比校验(横向对比和层级对比)
431
- const tipObj = {
432
- message: `${formItem._name}对比不通过!`,
433
- trigger: "blur, change",
434
- transform: (val) => {
435
- const comparedBool = (
436
- this.$normalComparedFunc(formItem, this.formData, this.allFormList, this.parentObj, this.parentFormList, this.inTableType, tipObj) &&
437
- this.$levelComparedFunc(formItem, this.formData, this.allListRows, this.inTableType, tipObj)
438
- );
439
-
440
- return comparedBool ? val : false;
441
- },
442
- ...ruleConfig
443
- };
444
- rules.push(tipObj);
391
+ // 对比校验(横向对比和层级对比)-虽然暂时只number和date对比校验,但为了扩展到其他类型时,不修改此处。用type判断:大量使用DshForm的地方有复合类型,type参数(数据类型)没有定义,会出现校验文字
392
+ // if (ruleConfig.type) {
393
+ if (["number", "date"].includes(formItem._type)) {
394
+ const ruleObj = {
395
+ message: `${formItem._name}对比不通过!`,
396
+ trigger: "blur, change",
397
+ type: "string",
398
+ transform: (val) => {
399
+ return this.$normalComparedFunc(formItem, this.formData, this.allFormList, this.parentObj, this.parentFormList, this.inTableType, ruleObj) &&
400
+ this.$levelComparedFunc(formItem, this.formData, this.allListRows, this.inTableType, ruleObj)
401
+ ? val
402
+ : false;
403
+ },
404
+ ...ruleConfig
405
+ };
406
+
407
+ rules.push(ruleObj);
408
+ }
445
409
 
446
410
  return rules;
447
411
  },
@@ -112,7 +112,7 @@ export default {
112
112
  },
113
113
 
114
114
  allTreeData () {
115
- console.log("allTreeData");
115
+ // console.log("allTreeData");
116
116
  return this.getCalcuedTree(this.data, this.treeColumns, this.columns);
117
117
  },
118
118
  allListData () {
@@ -313,7 +313,7 @@ export default {
313
313
  colType: "data"
314
314
  }
315
315
  ))
316
- );
316
+ );
317
317
  },
318
318
  // 转化树数据
319
319
  getCalcuedTree (nodes = [], treeForm = [], subForm = []) {
@@ -593,8 +593,10 @@ export default {
593
593
  ]);
594
594
  };
595
595
  },
596
- // 表头单元格渲染函数
596
+ // 表头单元格渲染函数 (无法共用contentColumns的renderHeaderCell,因为级联表头的无renderHeaderCell)
597
597
  getThRender (column, colIndex) {
598
+ column = this.$transformDynamicProperty(column, undefined, this.parentObj);
599
+
598
600
  return (h) => {
599
601
  return h("div", [
600
602
  this.$getHeadRender(h, column, {
@@ -783,7 +785,7 @@ export default {
783
785
  }
784
786
  : {
785
787
  textAlign: col._align || "left"
786
- };
788
+ };
787
789
 
788
790
  return {
789
791
  width: `${width}px`,
@@ -1010,20 +1010,17 @@ export default {
1010
1010
  // 未触发校验时 不显示错误
1011
1011
  if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || this.showRuleMessage) {
1012
1012
  // 校验必填不通过 => 校验对比
1013
- const tipObj = this.$getFieldRuleResult(col, row);
1014
- const comparedBool = (
1015
- tipObj.bool &&
1016
- this.$normalComparedFunc(col, row, this.columns, this.parentObj, this.allFormList, this.inTableType, tipObj) &&
1017
- this.$levelComparedFunc(col, row, this.allListData, this.inTableType, tipObj)
1018
- );
1013
+ const resultObj = {};
1014
+ this.$getFieldRuleResult(col, row, resultObj) &&
1015
+ this.$normalComparedFunc(col, row, this.columns, this.parentObj, this.allFormList, this.inTableType, resultObj) &&
1016
+ this.$levelComparedFunc(col, row, this.allListData, this.inTableType, resultObj);
1019
1017
 
1018
+ return resultObj;
1019
+ }
1020
+ else {
1020
1021
  return {
1021
- bool: comparedBool,
1022
- message: tipObj.message
1023
- };
1024
- } else {
1025
- return {
1026
- bool: true
1022
+ bool: true,
1023
+ message: "未触发校验,通过!"
1027
1024
  };
1028
1025
  }
1029
1026
  },