bri-components 1.4.6 → 1.4.7

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.
@@ -15,6 +15,12 @@ export default {
15
15
  type: Boolean,
16
16
  default: true
17
17
  },
18
+ tableDataObj: {
19
+ type: Object,
20
+ default () {
21
+ return {};
22
+ }
23
+ },
18
24
  data: {
19
25
  type: Array,
20
26
  default () {
@@ -45,12 +51,6 @@ export default {
45
51
  return {};
46
52
  }
47
53
  },
48
- tableDataObj: {
49
- type: Object,
50
- default () {
51
- return {};
52
- }
53
- },
54
54
 
55
55
  allFormList: {
56
56
  type: Array,
@@ -73,10 +73,12 @@ export default {
73
73
  resetProperties: ["__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__", "__isExpand__", "__treeIndex__"],
74
74
 
75
75
  initFlag: true,
76
+ isExpandAction: false,
76
77
  showRuleMessage: false, // 进行全体校验
77
- ruleRecordMap: {}, // 单元格是否发生校验的记录映射
78
+
79
+ idRecordMap: {}, // 默认id转换映射
78
80
  hoverRecordMap: {},
79
- isExpandAction: false,
81
+ ruleRecordMap: {}, // 单元格是否发生校验的记录映射
80
82
 
81
83
  showTopSearch: true,
82
84
  selfLogicPropsObj: {
@@ -137,8 +139,13 @@ export default {
137
139
  }
138
140
  },
139
141
  otherOperationMap: {
142
+ canQuickChangeVal: {
143
+ name: "立即改变值事件",
144
+ type: "canQuickChangeVal",
145
+ event: "quickChangeVal"
146
+ },
140
147
  canChangeVal: {
141
- name: "改变输入框值",
148
+ name: "改变值事件",
142
149
  type: "canChangeVal",
143
150
  event: "changeVal"
144
151
  }
@@ -237,6 +244,8 @@ export default {
237
244
  _useSelection: false, // 使用选择列 -配置端暂时用不到
238
245
  _useIndex: true, // 使用序号列
239
246
  _useSummary: false, // 使用汇总行
247
+ _noborderColKeys: [], // 无边线的列
248
+ _bgColKeys: [], // 带背景色的列
240
249
 
241
250
  _disabledBtns: false, // 禁用增删按钮
242
251
  _showCreateBtnColKeys: [], // 显示增删图标的列
@@ -321,6 +330,12 @@ export default {
321
330
  useSummary () {
322
331
  return this.selfPropsObj._useSummary;
323
332
  },
333
+ noborderColKeys () {
334
+ return this.selfPropsObj._noborderColKeys;
335
+ },
336
+ bgColKeys () {
337
+ return this.selfPropsObj._bgColKeys;
338
+ },
324
339
 
325
340
  disabledBtns () {
326
341
  return this.isDftSet ? false : this.selfPropsObj._disabledBtns;
@@ -707,10 +722,13 @@ export default {
707
722
  // 重置
708
723
  reset () {
709
724
  this.initFlag = true;
725
+ this.isExpandAction = false;
710
726
  this.showRuleMessage = false;
711
- this.ruleRecordMap = {};
727
+
728
+ this.idRecordMap = {};
712
729
  this.hoverRecordMap = {};
713
- this.isExpandAction = false;
730
+ this.ruleRecordMap = {};
731
+
714
732
  this.dftAdvSearch = {
715
733
  logic: "and",
716
734
  conditions: []
@@ -734,16 +752,21 @@ export default {
734
752
  this.$emit("changeSelect", list);
735
753
  },
736
754
  // 输入框失去焦点
737
- controlBlur (operationItem, row, rowIndex, col, params) {
738
- this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
755
+ controlBlur (operationItem, row, rowIndex, column, params) {
756
+ this.$set(this.ruleRecordMap, this.getMixKey(row, column), { showRuleMessage: true });
757
+ },
758
+ // 输入框值改变立即
759
+ quickChangeVal (operationItem, row, rowIndex, column, params) {
760
+ this.$set(this.ruleRecordMap, this.getMixKey(row, column), { showRuleMessage: true });
761
+ this.change("quickChangeVal", row, rowIndex, column, ...params);
739
762
  },
740
763
  // 输入框值改变
741
- changeVal (operationItem, row, rowIndex, col, params) {
742
- this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
743
- this.change("changeVal", row, rowIndex, col, ...params);
764
+ changeVal (operationItem, row, rowIndex, column, params) {
765
+ this.$set(this.ruleRecordMap, this.getMixKey(row, column), { showRuleMessage: true });
766
+ this.change("changeVal", row, rowIndex, column, ...params);
744
767
  },
745
- change (eventType, row, rowIndex, col, ...params) {
746
- this.$emit("change", this.tableDataObj, eventType, col, row, rowIndex, ...params);
768
+ change (eventType, row, rowIndex, column, ...params) {
769
+ this.$emit("change", this.tableDataObj, eventType, column, row, rowIndex, ...params);
747
770
  },
748
771
 
749
772
  /* ----------- 隐藏/显示字段 ---------- */
@@ -1089,15 +1112,7 @@ export default {
1089
1112
  formData: row,
1090
1113
  formItem: {
1091
1114
  ...column,
1092
- ...(
1093
- column.colType === "tree"
1094
- ? {
1095
- _key: "name",
1096
- _heightAuto: true,
1097
- _placeholder: " "
1098
- }
1099
- : column
1100
- )
1115
+ _key: column.colType === "tree" ? "name" : column._key
1101
1116
  },
1102
1117
  allFormList: this.selfColumns,
1103
1118
  inTableType: this.inTableType,
@@ -1108,6 +1123,7 @@ export default {
1108
1123
  },
1109
1124
  on: {
1110
1125
  blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1126
+ quickChange: () => this.$dispatchEvent(this.operationMap.canQuickChangeVal, row, rowIndex, column, arguments),
1111
1127
  change: () => this.$dispatchEvent(this.operationMap.canChangeVal, row, rowIndex, column, arguments)
1112
1128
  }
1113
1129
  })
@@ -1119,15 +1135,7 @@ export default {
1119
1135
  formData: row,
1120
1136
  formItem: {
1121
1137
  ...column,
1122
- ...(
1123
- column.colType === "tree"
1124
- ? {
1125
- _key: "name",
1126
- _heightAuto: true,
1127
- _placeholder: " "
1128
- }
1129
- : column
1130
- )
1138
+ _key: column.colType === "tree" ? "name" : column._key
1131
1139
  },
1132
1140
  allFormList: this.selfColumns,
1133
1141
  inTableType: this.inTableType,
@@ -1138,6 +1146,7 @@ export default {
1138
1146
  },
1139
1147
  on: {
1140
1148
  blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1149
+ quickChange: () => this.$dispatchEvent(this.operationMap.canQuickChangeVal, row, rowIndex, column, arguments),
1141
1150
  change: () => this.$dispatchEvent(this.operationMap.canChangeVal, row, rowIndex, column, arguments)
1142
1151
  }
1143
1152
  }),
@@ -1266,6 +1275,14 @@ export default {
1266
1275
  : ""
1267
1276
  : " bri-table-td-hide"
1268
1277
  }` +
1278
+ `${this.noborderColKeys.includes(column._key)
1279
+ ? " bri-table-td-noborder"
1280
+ : ""
1281
+ }` +
1282
+ `${this.bgColKeys.includes(column._key)
1283
+ ? " bri-table-td-bg"
1284
+ : ""
1285
+ }` +
1269
1286
  `${this.selfBodyCellClass
1270
1287
  ? this.selfBodyCellClass({ row, rowIndex, column })
1271
1288
  : ""
@@ -1292,38 +1309,6 @@ export default {
1292
1309
  },
1293
1310
 
1294
1311
  /* ----------- 方法 ---------- */
1295
- // 生成新的一行数据
1296
- getNewRowData (level, list) {
1297
- if (["cascaderTable"].includes(this.controlType)) {
1298
- return {
1299
- ...this.$deepCopy(this.selfRowDft),
1300
- ...(this.getRowOtherDft ? this.$deepCopy(this.getRowOtherDft(level, list)) : {}),
1301
- _id: this.$ObjectID().str,
1302
- level: level,
1303
- isLeaf: true,
1304
- children: [],
1305
- // __old__: false,
1306
- __isDefault__: this.isDftSet,
1307
- __isRendered__: true,
1308
- __isShow__: true,
1309
- __isTmpShow__: true,
1310
- __isSearchShow__: false,
1311
- __isExpand__: false
1312
- };
1313
- } else {
1314
- return {
1315
- ...this.$deepCopy(this.selfRowDft),
1316
- _id: this.$ObjectID().str,
1317
- // __old__: false,
1318
- __isDefault__: this.isDftSet,
1319
- __isRendered__: true,
1320
- __isShow__: true,
1321
- __isTmpShow__: true,
1322
- __isSearchShow__: false,
1323
- __isExpand__: false
1324
- };
1325
- }
1326
- },
1327
1312
  // 整行校验结果
1328
1313
  getRowRuleResult (row, rowIndex) {
1329
1314
  return this.filterColumns.every(column => this.getColRuleResult({ row, rowIndex, column }).bool);
@@ -1362,7 +1347,7 @@ export default {
1362
1347
  column = this.$transformDynamicProperty(column, row, this.parentObj);
1363
1348
 
1364
1349
  // 未触发校验时 不显示错误
1365
- if ((this.ruleRecordMap[`${row._id}dsh${column._key}`] || {}).showRuleMessage || this.showRuleMessage) {
1350
+ if ((this.ruleRecordMap[this.getMixKey(row, column)] || {}).showRuleMessage || this.showRuleMessage) {
1366
1351
  // 校验必填不通过 => 校验对比
1367
1352
  const resultObj = {};
1368
1353
  this.$getFieldRuleResult(column, row, resultObj) &&
@@ -1378,38 +1363,36 @@ export default {
1378
1363
  };
1379
1364
  }
1380
1365
  },
1381
- // 单元格是否显示对比
1382
- isShowCompare ({ row, rowIndex, column }) {
1383
- const oldRow = this.compareListData[rowIndex] || {};
1384
- const curVal = row[column._key];
1385
- const oldVal = oldRow[column._key];
1386
-
1387
- return this.useCampare &&
1388
- ["number"].includes(column._type) &&
1389
- !(this.$isEmptyData(curVal) && this.$isEmptyData(oldVal)) &&
1390
- curVal !== oldVal;
1391
- },
1392
1366
  // 加工单元格对应的配置
1393
1367
  getResetCol ({ row, rowIndex, column }) {
1394
1368
  return {
1395
1369
  // isShare: this.isShare,
1396
1370
  ...column,
1397
- _heightAuto: this.heightAuto
1371
+ _heightAuto: this.heightAuto,
1372
+ ...(
1373
+ this.noborderColKeys.includes(column._key)
1374
+ ? { _placeholder: " " }
1375
+ : {}
1376
+ ),
1377
+ ...(
1378
+ this.getSelfResetCol
1379
+ ? this.getSelfResetCol({ row, rowIndex, column })
1380
+ : {}
1381
+ )
1398
1382
  };
1399
1383
  },
1400
- // 单元格最终编辑状态
1384
+ // 单元格最终是否可编辑性
1401
1385
  getUnitCanEdit ({ row, rowIndex, column }) {
1402
1386
  return this.getRowCanEdit(row, rowIndex) &&
1403
1387
  this.getColCanEdit({ row, rowIndex, column }) &&
1404
1388
  this.$isAdvRelyShow(column, row, this.parentObj, true);
1405
1389
  },
1406
- // 列本身是否可编辑
1390
+ // 单元格本身是否可编辑性
1407
1391
  getColCanEdit ({ row, rowIndex, column }) {
1408
- return (column._oldReadonly ? row.__old__ !== true : true) && // 某些列在老数据行里不可编辑
1409
- (this.getIsDftRow(row) ? !this.dftReadonlyColKeys.includes(column._key) : true) && // 默认行的某列是否可编辑
1392
+ return (this.getIsDftRow(row) ? !this.dftReadonlyColKeys.includes(column._key) : true) && // 默认行的某列是否可编辑
1410
1393
  (row.__old__ === true ? !this.oldReadonlyColKeys.includes(column._key) : true) && // 老数据行里某些列不可编辑
1411
1394
  (row.__isQuote__ ? !this.quoteReadonlyColKeys.includes(column._key) : true) && // 引用过来的数据是否可编辑
1412
- (!this.getTypeColCanEdit || this.getTypeColCanEdit({ row, rowIndex, column })) &&
1395
+ (this.getSelfColCanEdit ? this.getSelfColCanEdit({ row, rowIndex, column }) : true) &&
1413
1396
  (
1414
1397
  ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(column._type)
1415
1398
  ? column._summaryType
@@ -1430,46 +1413,19 @@ export default {
1430
1413
  },
1431
1414
 
1432
1415
  /* ----------- 工具方法 ---------- */
1433
- // 获取父级行
1434
- getParentRow (row, tree = []) {
1435
- if (row.level === 1) {
1436
- return {
1437
- children: tree
1438
- };
1439
- } else {
1440
- let parentRow;
1441
-
1442
- const loop = (list = []) => {
1443
- return list.some(rowItem => {
1444
- if (rowItem.level === row.level - 1) {
1445
- const isExist = rowItem.children.some(childRowItem => childRowItem._id === row._id);
1446
- parentRow = rowItem;
1447
- return isExist;
1448
- } else {
1449
- return loop(rowItem.children);
1450
- }
1451
- });
1452
- };
1453
- loop(tree);
1454
-
1455
- return parentRow;
1456
- }
1457
- },
1458
1416
  // 初始化时 修复数据
1459
1417
  fixRowItem (row, levelNum) {
1460
1418
  if (this.initFlag) {
1461
- // TODO:修正数据level属性,后期可以删除
1462
- if (["cascaderTable"].includes(this.controlType)) {
1463
- row.level = row.level || levelNum;
1464
- }
1465
-
1466
1419
  // 配置端设置的地方,不会运行下面的,因为_default被过滤掉没值,defaultListDataIds就是空的
1467
1420
  if (row._id) {
1468
1421
  if (this.defaultListDataIds.includes(row._id)) {
1469
1422
  row.__isDefault__ = true;
1470
1423
 
1471
1424
  // 默认数据的id置换一遍,不然每条数据里该列表的id都是重复的
1472
- row._id = this.$ObjectID().str;
1425
+ const oldId = row._id;
1426
+ const newId = this.$ObjectID().str;
1427
+ row._id = newId;
1428
+ this.idRecordMap[newId] = oldId;
1473
1429
  }
1474
1430
  } else {
1475
1431
  row._id = this.$ObjectID().str;
@@ -1528,7 +1484,67 @@ export default {
1528
1484
  row.__isExpand__ = Object.prototype.hasOwnProperty.call(row, "__isExpand__") ? row.__isExpand__ : false;
1529
1485
  }
1530
1486
  }
1487
+
1488
+ this.selfFixRowItem && this.selfFixRowItem(row, levelNum);
1531
1489
  },
1490
+ // 生成新的一行数据
1491
+ getNewRowData (level, list) {
1492
+ if (["cascaderTable"].includes(this.controlType)) {
1493
+ return {
1494
+ ...this.$deepCopy(this.selfRowDft),
1495
+ ...(this.getSelfNewRowData ? this.$deepCopy(this.getSelfNewRowData(level, list)) : {}),
1496
+ _id: this.$ObjectID().str,
1497
+ level: level,
1498
+ isLeaf: true,
1499
+ children: [],
1500
+ // __old__: false,
1501
+ __isDefault__: this.isDftSet,
1502
+ __isRendered__: true,
1503
+ __isShow__: true,
1504
+ __isTmpShow__: true,
1505
+ __isSearchShow__: false,
1506
+ __isExpand__: false
1507
+ };
1508
+ } else {
1509
+ return {
1510
+ ...this.$deepCopy(this.selfRowDft),
1511
+ _id: this.$ObjectID().str,
1512
+ // __old__: false,
1513
+ __isDefault__: this.isDftSet,
1514
+ __isRendered__: true,
1515
+ __isShow__: true,
1516
+ __isTmpShow__: true,
1517
+ __isSearchShow__: false,
1518
+ __isExpand__: false
1519
+ };
1520
+ }
1521
+ },
1522
+ // 获取父级行
1523
+ getParentRow (row, tree = []) {
1524
+ if (row.level === 1) {
1525
+ return {
1526
+ children: tree
1527
+ };
1528
+ } else {
1529
+ let parentRow;
1530
+
1531
+ const loop = (list = []) => {
1532
+ return list.some(rowItem => {
1533
+ if (rowItem.level === row.level - 1) {
1534
+ const isExist = rowItem.children.some(childRowItem => childRowItem._id === row._id);
1535
+ parentRow = rowItem;
1536
+ return isExist;
1537
+ } else {
1538
+ return loop(rowItem.children);
1539
+ }
1540
+ });
1541
+ };
1542
+ loop(tree);
1543
+
1544
+ return parentRow;
1545
+ }
1546
+ },
1547
+ // 判断是否符合搜索条件,且处理行状态值等
1532
1548
  dealSearchShow (rowItem) {
1533
1549
  if (this.isSearching) {
1534
1550
  const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, rowItem);
@@ -1545,6 +1561,34 @@ export default {
1545
1561
  else {
1546
1562
  return true;
1547
1563
  }
1564
+ },
1565
+ // 单元格是否显示对比
1566
+ isShowCompare ({ row, rowIndex, column }) {
1567
+ const oldRow = this.compareListData[rowIndex] || {};
1568
+ const curVal = row[column._key];
1569
+ const oldVal = oldRow[column._key];
1570
+
1571
+ return this.useCampare &&
1572
+ ["number"].includes(column._type) &&
1573
+ !(this.$isEmptyData(curVal) && this.$isEmptyData(oldVal)) &&
1574
+ curVal !== oldVal;
1575
+ },
1576
+ // 比较两行某列的值是否相等
1577
+ isCompareSame (column, row, compareRow) {
1578
+ const curColKey = column ? column._key : undefined;
1579
+ const curColType = column ? column._type : undefined;
1580
+
1581
+ return this.$isEmptyData(compareRow[curColKey]) && this.$isEmptyData(row[curColKey])
1582
+ ? true
1583
+ : ["users", "departments"].includes(curColType)
1584
+ ? compareRow[curColKey].length === row[curColKey].length && compareRow[curColKey].every((item, index) => item._key === row[curColKey][index]._key)
1585
+ : compareRow[curColKey] === row[curColKey];
1586
+ },
1587
+ // 行id+列key组成键
1588
+ getMixKey (row, column, useDsh = true) {
1589
+ return useDsh
1590
+ ? `${row._id}dsh${column._key}`
1591
+ : `${row._id}${column._key}`;
1548
1592
  }
1549
1593
  }
1550
1594
  };
@@ -141,6 +141,12 @@ export default {
141
141
  // });
142
142
  // },
143
143
 
144
+ selfFixRowItem (row, levelNum) {
145
+ if (this.initFlag) {
146
+ // TODO:修正数据level属性,后期可以删除
147
+ row.level = row.level || levelNum;
148
+ }
149
+ },
144
150
  // 展开/隐藏节点
145
151
  toggleExpand (row, bool = true) {
146
152
  this.isExpandAction = true;
@@ -127,10 +127,16 @@
127
127
  return this.getItemDisabled(item) === false && this.propsObj.closable;
128
128
  },
129
129
  getItemIcon (item) {
130
- return (this.$dataType(item) === "object" ? item.icon || item._icon : undefined) || this.propsObj.icon;
130
+ return (
131
+ this.$dataType(item) === "object"
132
+ ? item.icon || item._icon
133
+ : undefined
134
+ ) || this.propsObj.icon;
131
135
  },
132
136
  getItemName (item) {
133
- return this.$dataType(item) === "object" ? item.realname || item.full_name || item.name || item._name || item._id : item;
137
+ return this.$dataType(item) === "object"
138
+ ? item.realname || item.full_name || item.name || item._name || item._id
139
+ : item;
134
140
  }
135
141
  };
136
142
  },
@@ -30,6 +30,7 @@
30
30
  :parentFormList="parentFormList"
31
31
  :parentObj="parentObj"
32
32
  @blur="blur"
33
+ @quickChange="quickChange"
33
34
  @change="change"
34
35
  ></component>
35
36
  </template>
@@ -67,6 +67,9 @@ export default {
67
67
  },
68
68
  created () { },
69
69
  methods: {
70
+ quickChange (...params) {
71
+ this.$emit("quickChange", this.formItem, ...params);
72
+ },
70
73
  change (...params) {
71
74
  this.$emit("change", this.formItem, ...params);
72
75
  },
@@ -91,6 +91,32 @@
91
91
  td.ve-table-body-td {
92
92
  height: 40px;
93
93
  padding: 4px 16px;
94
+
95
+ &.bri-table-td-noborder {
96
+ .ivu-input,
97
+ textarea.ivu-input,
98
+ .ivu-select-selection {
99
+ min-height: 18px;
100
+ padding: 0px;
101
+ border: none;
102
+ background-color: transparent;
103
+ box-shadow: none;
104
+ line-height: 18px;
105
+ }
106
+
107
+ .ivu-input-prefix,
108
+ .ivu-input-suffix {
109
+ width: 0px;
110
+ display: none;
111
+ }
112
+
113
+ .ivu-date-picker-focused input:not([disabled]) {
114
+ box-shadow: none;
115
+ }
116
+ }
117
+ &.bri-table-td-bg {
118
+ background-color: #fbfbfb;
119
+ }
94
120
  }
95
121
  }
96
122
  }
@@ -224,10 +250,10 @@
224
250
  display: none!important;
225
251
  }
226
252
 
227
- &-merge {
228
- background-color: #fbfbfb!important;
229
-
230
- textarea.ivu-input {
253
+ &-noborder {
254
+ .ivu-input,
255
+ textarea.ivu-input,
256
+ .ivu-select-selection {
231
257
  min-height: 18px;
232
258
  padding: 0px;
233
259
  border: none;
@@ -235,6 +261,19 @@
235
261
  box-shadow: none;
236
262
  line-height: 18px;
237
263
  }
264
+
265
+ .ivu-input-prefix,
266
+ .ivu-input-suffix {
267
+ width: 0px;
268
+ display: none;
269
+ }
270
+
271
+ .ivu-date-picker-focused input:not([disabled]) {
272
+ box-shadow: none;
273
+ }
274
+ }
275
+ &-bg {
276
+ background-color: #fbfbfb;
238
277
  }
239
278
  }
240
279