bri-components 1.4.4 → 1.4.6

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.4.4",
3
+ "version": "1.4.6",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -330,6 +330,14 @@
330
330
  this.$emit("input", val);
331
331
  this.$emit("on-change", val);
332
332
  this.dispatch("FormItem", "on-form-change", val);
333
+ } else {
334
+ clearTimeout(this.timer);
335
+ this.timer = setTimeout(() => {
336
+ this.currentValue = val;
337
+ this.$emit("input", val);
338
+ this.$emit("on-change", val);
339
+ this.dispatch("FormItem", "on-form-change", val);
340
+ }, 600);
333
341
  }
334
342
  });
335
343
  },
@@ -340,10 +348,6 @@
340
348
  blur () {
341
349
  this.focused = false;
342
350
  if (this.transferValue !== this.currentValue) {
343
- this.currentValue = this.transferValue;
344
- this.$emit("input", this.transferValue);
345
- this.$emit("on-change", this.transferValue);
346
- this.dispatch("FormItem", "on-form-change", this.transferValue);
347
351
  this.focused = false;
348
352
  this.$emit("on-blur");
349
353
  if (!findComponentUpward(this, ["DatePicker", "TimePicker", "Cascader", "Search"])) {
@@ -364,6 +368,7 @@
364
368
  if (event.type == "change" && this.activeChange) return;
365
369
 
366
370
  if (event.type == "input" && !this.activeChange) return;
371
+
367
372
  let val = event.target.value.trim();
368
373
  if (this.parser) {
369
374
  val = this.parser(val);
@@ -165,7 +165,7 @@ export default {
165
165
  {
166
166
  key: column._id,
167
167
  class: "bri-table-th",
168
- style: this.getThStyle(column)
168
+ style: this.getThStyle({ column, colIndex })
169
169
  },
170
170
  [
171
171
  this.contentThCellRender(h, { column, colIndex })
@@ -189,12 +189,11 @@ export default {
189
189
  return h(
190
190
  "td",
191
191
  {
192
- class: this.bodyCellClass({ row, rowIndex, column }) +
193
- `${["tree"].includes(column.colType) ? " bri-table-td-merge" : ""}`,
194
- style: this.getTdStyle(row, rowIndex, column),
192
+ class: this.bodyCellClass({ row, rowIndex, column }),
193
+ style: this.getTdStyle({ row, rowIndex, column }),
195
194
  attrs: {
196
- rowspan: this.getTdRowSpan(row, rowIndex, column),
197
- colspan: this.getTdColSpan(row, rowIndex, column)
195
+ rowspan: this.getTdRowSpan({ row, rowIndex, column }),
196
+ colspan: this.getTdColSpan({ row, rowIndex, column })
198
197
  },
199
198
  on: {
200
199
  mouseenter: (event) => {
@@ -206,7 +205,7 @@ export default {
206
205
  }
207
206
  },
208
207
  column.colType === "summary"
209
- ? this.getSummaryTdVal(row, rowIndex, column)
208
+ ? this.getSummaryTdVal({ row, rowIndex, column })
210
209
  : column.colType === "operation"
211
210
  ? this.operationTdCellRender(h, { row, rowIndex, column })
212
211
  : this.contentTdCellRender(h, { row, rowIndex, column })
@@ -214,13 +213,19 @@ export default {
214
213
  },
215
214
 
216
215
  /* ----------- 方法 ---------- */
216
+ selfBodyCellClass ({ row, rowIndex, column }) {
217
+ return `${["tree"].includes(column.colType)
218
+ ? " bri-table-td-merge"
219
+ : ""
220
+ }`;
221
+ },
217
222
  // 表头 -获取样式
218
- getThStyle (col) {
219
- const typeData = this.$modFieldMap[col._type] || {};
223
+ getThStyle ({ column, colIndex }) {
224
+ const typeData = this.$modFieldMap[column._type] || {};
220
225
  const boxColWidth = this.boxWidth / this.showColumns.length;
221
- const calcWidth = (col._name ? col._name.length * 12 : 48) + (col._type === "reference" ? 200 : 32);
222
- const dftWidth = Math.max(boxColWidth, this.widthMap[col._type], calcWidth);
223
- const width = col._width || dftWidth;
226
+ const calcWidth = (column._name ? column._name.length * 12 : 48) + (column._type === "reference" ? 200 : 32);
227
+ const dftWidth = Math.max(boxColWidth, this.widthMap[column._type], calcWidth);
228
+ const width = column._width || dftWidth;
224
229
 
225
230
  return {
226
231
  width: `${width}px`,
@@ -228,33 +233,33 @@ export default {
228
233
  maxWidth: `${width}px`,
229
234
  paddingTop: !this.headHeightAuto ? "10px" : undefined,
230
235
  paddingBottom: !this.headHeightAuto ? "10px" : undefined,
231
- textAlign: col._align || typeData.align,
236
+ textAlign: column._align || typeData.align,
232
237
  "word-break": "break-all",
233
238
  cursor: "pointer"
234
239
  };
235
240
  },
236
241
 
237
242
  // 单元格 -获取样式
238
- getTdStyle (row, rowIndex, col) {
243
+ getTdStyle ({ row, rowIndex, column }) {
239
244
  return {
240
- ...this.getThStyle(col),
245
+ ...this.getThStyle({ column }),
241
246
  paddingTop: undefined,
242
247
  paddingBottom: undefined,
243
248
  backgroundColor: "#ffffff"
244
249
  };
245
250
  },
246
251
  // 单元格 -获取行合并数
247
- getTdRowSpan (row, rowIndex, col) {
252
+ getTdRowSpan ({ row, rowIndex, column }) {
248
253
  return row.total || 1;
249
254
  },
250
255
  // 单元格 -获取列合并数
251
- getTdColSpan (row, rowIndex, col) {
256
+ getTdColSpan ({ row, rowIndex, column }) {
252
257
  return 1;
253
258
  },
254
259
  // 单元格 -汇总节点单元格-获取值
255
- getSummaryTdVal (row, rowIndex, col) {
256
- if (col._calField && col._operator) {
257
- const calFieldFormItem = this.selfColumns.find(item => item._key === col._calField);
260
+ getSummaryTdVal ({ row, rowIndex, column }) {
261
+ if (column._calField && column._operator) {
262
+ const calFieldFormItem = this.selfColumns.find(item => item._key === column._calField);
258
263
 
259
264
  if (calFieldFormItem) {
260
265
  let loop = (nodes, arr) => {
@@ -262,32 +267,32 @@ export default {
262
267
  if (node.children.length) {
263
268
  return loop(node.children, arr);
264
269
  } else {
265
- arr.push(node[col._calField] || 0);
270
+ arr.push(node[column._calField] || 0);
266
271
  return arr;
267
272
  }
268
273
  }, arr);
269
274
  };
270
275
  let list = loop(row.children, []);
271
276
 
272
- return this.$calNumList(list, col._operator, calFieldFormItem);
277
+ return this.$calNumList(list, column._operator, calFieldFormItem);
273
278
  } else {
274
- return `来源列${col._calField}被删除`;
279
+ return `来源列${column._calField}被删除`;
275
280
  }
276
281
  } else {
277
- return !col._calField && !col._operator
282
+ return !column._calField && !column._operator
278
283
  ? "未选择来源列和算法"
279
- : !col._calField
284
+ : !column._calField
280
285
  ? "未选择来源列"
281
286
  : "未选择算法";
282
287
  }
283
288
  },
284
289
  // 列本身是否可编辑 -针对表头列
285
- getTypeColCanEdit (row, rowIndex, col) {
286
- return (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
287
- (row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(col._key) : true); // 老数据行里某些列不可编辑
290
+ getTypeColCanEdit ({ row, rowIndex, column }) {
291
+ return (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(column._key) : true) && // 默认行的某列是否可编辑
292
+ (row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(column._key) : true); // 老数据行里某些列不可编辑
288
293
  },
289
294
  // getNewRowData时,额外补充的行相关的数据(针对层级属性的列)
290
- getRowOtherDft (level, list) {
295
+ getRowOtherDft (level, list = []) {
291
296
  const column = this.treeForm[level - 1];
292
297
  const dftVal = column._default;
293
298
  const initDftVal = this.initDftValMap[column._type];
@@ -142,6 +142,12 @@ export default {
142
142
  },
143
143
 
144
144
  /* ----------- 方法 ---------- */
145
+ selfBodyCellClass ({ row, rowIndex, column }) {
146
+ return `${this.mergeRowColKeys && this.mergeRowColKeys.includes(column._key)
147
+ ? " bri-table-td-merge"
148
+ : ""
149
+ }`;
150
+ },
145
151
  bodyCellSpan ({ row, rowIndex, column }) {
146
152
  rowIndex = this.showListData.findIndex(dataItem => dataItem._id === row._id);
147
153
 
@@ -1064,12 +1064,12 @@ export default {
1064
1064
  },
1065
1065
  contentTdCellRender (h, { row, rowIndex, column }) {
1066
1066
  column = this.$transformDynamicProperty(column, row, this.parentObj);
1067
- column = this.getResetCol(row, rowIndex, column);
1068
- const unitCanEdit = this.getUnitCanEdit(row, rowIndex, column);
1069
- const ruleResultObj = this.getColRuleResult(row, rowIndex, column);
1067
+ column = this.getResetCol({ row, rowIndex, column });
1068
+ const unitCanEdit = this.getUnitCanEdit({ row, rowIndex, column });
1069
+ const ruleResultObj = this.getColRuleResult({ row, rowIndex, column });
1070
1070
 
1071
1071
  return [
1072
- this.isShowCompare(row, rowIndex, column)
1072
+ this.isShowCompare({ row, rowIndex, column })
1073
1073
  ? h("Tooltip", {
1074
1074
  style: {
1075
1075
  width: "100%"
@@ -1248,10 +1248,6 @@ export default {
1248
1248
  },
1249
1249
  bodyCellClass ({ row, rowIndex, column }) {
1250
1250
  return "bri-table-td" +
1251
- `${this.mergeRowColKeys && this.mergeRowColKeys.includes(column._key)
1252
- ? " bri-table-td-merge"
1253
- : ""
1254
- }` +
1255
1251
  `${["__isExpand__"].includes(column._key)
1256
1252
  ? " bri-table-td-expand"
1257
1253
  : ["__treeIndex__"].includes(column._key)
@@ -1269,6 +1265,10 @@ export default {
1269
1265
  ? " bri-table-td-visible"
1270
1266
  : ""
1271
1267
  : " bri-table-td-hide"
1268
+ }` +
1269
+ `${this.selfBodyCellClass
1270
+ ? this.selfBodyCellClass({ row, rowIndex, column })
1271
+ : ""
1272
1272
  }`;
1273
1273
  },
1274
1274
  eventCustomOption ({ row, rowIndex, column }) {
@@ -1326,15 +1326,15 @@ export default {
1326
1326
  },
1327
1327
  // 整行校验结果
1328
1328
  getRowRuleResult (row, rowIndex) {
1329
- return this.filterColumns.every(colItem => this.getColRuleResult(row, rowIndex, colItem).bool);
1329
+ return this.filterColumns.every(column => this.getColRuleResult({ row, rowIndex, column }).bool);
1330
1330
  },
1331
1331
  getRowFormList (row, rowIndex) {
1332
- return this.selfColumns.map(colItem => {
1333
- colItem = this.$transformDynamicProperty(colItem, row, this.parentObj);
1334
- const unitCanEdit = this.getColCanEdit(row, rowIndex, colItem);
1332
+ return this.selfColumns.map(column => {
1333
+ column = this.$transformDynamicProperty(column, row, this.parentObj);
1334
+ const unitCanEdit = this.getColCanEdit({ row, rowIndex, column });
1335
1335
 
1336
1336
  return {
1337
- ...colItem,
1337
+ ...column,
1338
1338
  canEdit: unitCanEdit
1339
1339
  };
1340
1340
  });
@@ -1358,16 +1358,16 @@ export default {
1358
1358
  },
1359
1359
 
1360
1360
  // 单元格校验结果
1361
- getColRuleResult (row, rowIndex, col) {
1362
- col = this.$transformDynamicProperty(col, row, this.parentObj);
1361
+ getColRuleResult ({ row, rowIndex, column }) {
1362
+ column = this.$transformDynamicProperty(column, row, this.parentObj);
1363
1363
 
1364
1364
  // 未触发校验时 不显示错误
1365
- if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || this.showRuleMessage) {
1365
+ if ((this.ruleRecordMap[`${row._id}dsh${column._key}`] || {}).showRuleMessage || this.showRuleMessage) {
1366
1366
  // 校验必填不通过 => 校验对比
1367
1367
  const resultObj = {};
1368
- this.$getFieldRuleResult(col, row, resultObj) &&
1369
- this.$normalComparedFunc(col, row, this.selfColumns, this.parentObj, this.allFormList, this.inTableType, resultObj) &&
1370
- this.$levelComparedFunc(col, row, this.allListData, this.inTableType, resultObj);
1368
+ this.$getFieldRuleResult(column, row, resultObj) &&
1369
+ this.$normalComparedFunc(column, row, this.selfColumns, this.parentObj, this.allFormList, this.inTableType, resultObj) &&
1370
+ this.$levelComparedFunc(column, row, this.allListData, this.inTableType, resultObj);
1371
1371
 
1372
1372
  return resultObj;
1373
1373
  }
@@ -1379,54 +1379,54 @@ export default {
1379
1379
  }
1380
1380
  },
1381
1381
  // 单元格是否显示对比
1382
- isShowCompare (row, rowIndex, col) {
1382
+ isShowCompare ({ row, rowIndex, column }) {
1383
1383
  const oldRow = this.compareListData[rowIndex] || {};
1384
- const curVal = row[col._key];
1385
- const oldVal = oldRow[col._key];
1384
+ const curVal = row[column._key];
1385
+ const oldVal = oldRow[column._key];
1386
1386
 
1387
1387
  return this.useCampare &&
1388
- ["number"].includes(col._type) &&
1388
+ ["number"].includes(column._type) &&
1389
1389
  !(this.$isEmptyData(curVal) && this.$isEmptyData(oldVal)) &&
1390
1390
  curVal !== oldVal;
1391
1391
  },
1392
1392
  // 加工单元格对应的配置
1393
- getResetCol (row, rowIndex, col) {
1393
+ getResetCol ({ row, rowIndex, column }) {
1394
1394
  return {
1395
1395
  // isShare: this.isShare,
1396
- ...col,
1396
+ ...column,
1397
1397
  _heightAuto: this.heightAuto
1398
1398
  };
1399
1399
  },
1400
+ // 单元格最终编辑状态
1401
+ getUnitCanEdit ({ row, rowIndex, column }) {
1402
+ return this.getRowCanEdit(row, rowIndex) &&
1403
+ this.getColCanEdit({ row, rowIndex, column }) &&
1404
+ this.$isAdvRelyShow(column, row, this.parentObj, true);
1405
+ },
1400
1406
  // 列本身是否可编辑
1401
- getColCanEdit (row, rowIndex, col) {
1402
- return (col._oldReadonly ? row.__old__ !== true : true) && // 某些列在老数据行里不可编辑
1403
- (this.getIsDftRow(row) ? !this.dftReadonlyColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
1404
- (row.__old__ === true ? !this.oldReadonlyColKeys.includes(col._key) : true) && // 老数据行里某些列不可编辑
1405
- (row.__isQuote__ ? !this.quoteReadonlyColKeys.includes(col._key) : true) && // 引用过来的数据是否可编辑
1406
- (!this.getTypeColCanEdit || this.getTypeColCanEdit(row, rowIndex, col)) &&
1407
+ getColCanEdit ({ row, rowIndex, column }) {
1408
+ return (column._oldReadonly ? row.__old__ !== true : true) && // 某些列在老数据行里不可编辑
1409
+ (this.getIsDftRow(row) ? !this.dftReadonlyColKeys.includes(column._key) : true) && // 默认行的某列是否可编辑
1410
+ (row.__old__ === true ? !this.oldReadonlyColKeys.includes(column._key) : true) && // 老数据行里某些列不可编辑
1411
+ (row.__isQuote__ ? !this.quoteReadonlyColKeys.includes(column._key) : true) && // 引用过来的数据是否可编辑
1412
+ (!this.getTypeColCanEdit || this.getTypeColCanEdit({ row, rowIndex, column })) &&
1407
1413
  (
1408
- ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(col._type)
1409
- ? col._summaryType
1414
+ ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(column._type)
1415
+ ? column._summaryType
1410
1416
  ? row.isLeaf === true
1411
- : ["downToUp", "upToDown"].includes(col._writeSort)
1412
- ? col._noLimitWrite === true
1417
+ : ["downToUp", "upToDown"].includes(column._writeSort)
1418
+ ? column._noLimitWrite === true
1413
1419
  ? true
1414
- : ["downToUp"].includes(col._writeSort)
1415
- ? !(row.children && row.children.length) || row.children.every(sonRow => !this.$isEmptyData(sonRow[col._key]))
1416
- : row.level === 1 || !this.$isEmptyData(this.getParentRow(row, this.data)[col._key])
1420
+ : ["downToUp"].includes(column._writeSort)
1421
+ ? !(row.children && row.children.length) || row.children.every(sonRow => !this.$isEmptyData(sonRow[column._key]))
1422
+ : row.level === 1 || !this.$isEmptyData(this.getParentRow(row, this.data)[column._key])
1417
1423
  : true
1418
1424
  : true
1419
1425
  ) &&
1420
- !(["cascaderTable"].includes(this.controlType) && ["level", "children"].includes(col._key)) && // 层级表格的固定字段不可编辑
1421
- col._enterType !== "calculate" && // 计算的不可编辑
1422
- col._readonly !== true && // 只读
1423
- col.canEdit !== false; // 字段本身编辑权限 考虑为undefined时候
1424
- },
1425
- // 单元格最终编辑状态
1426
- getUnitCanEdit (row, rowIndex, col) {
1427
- return this.getRowCanEdit(row, rowIndex) &&
1428
- this.getColCanEdit(row, rowIndex, col) &&
1429
- this.$isAdvRelyShow(col, row, this.parentObj, true);
1426
+ !(["cascaderTable"].includes(this.controlType) && ["level", "children"].includes(column._key)) && // 层级表格的固定字段不可编辑
1427
+ column._enterType !== "calculate" && // 计算的不可编辑
1428
+ column._readonly !== true && // 只读
1429
+ column.canEdit !== false; // 字段本身编辑权限 考虑为undefined时候
1430
1430
  },
1431
1431
 
1432
1432
  /* ----------- 工具方法 ---------- */
@@ -1485,6 +1485,7 @@ export default {
1485
1485
  if (["treeTable"].includes(this.inTableType)) {
1486
1486
  // row.__isSearchShow__ = false;
1487
1487
  // row.__isExpand__ = false;
1488
+
1488
1489
  // 第一级的需要显示出来
1489
1490
  if (row.level == 1) {
1490
1491
  row.__isRendered__ = true;
@@ -1503,6 +1504,30 @@ export default {
1503
1504
  row.__isExpand__ = false;
1504
1505
  }
1505
1506
  }
1507
+ // 计算或其它重新传进来值时
1508
+ else {
1509
+ if (["treeTable"].includes(this.inTableType)) {
1510
+ // row.__isSearchShow__ = Object.prototype.hasOwnProperty.call(row, "__isSearchShow__") ? row.__isSearchShow__ : false;
1511
+ // row.__isExpand__ = Object.prototype.hasOwnProperty.call(row, "__isExpand__") ? row.__isExpand__ : false;
1512
+
1513
+ // 第一级的需要显示出来
1514
+ if (row.level == 1) {
1515
+ row.__isRendered__ = Object.prototype.hasOwnProperty.call(row, "__isRendered__") ? row.__isRendered__ : true;
1516
+ row.__isShow__ = Object.prototype.hasOwnProperty.call(row, "__isShow__") ? row.__isShow__ : true;
1517
+ row.__isTmpShow__ = Object.prototype.hasOwnProperty.call(row, "__isTmpShow__") ? row.__isTmpShow__ : true;
1518
+ } else {
1519
+ // row.__isRendered__ = Object.prototype.hasOwnProperty.call(row, "__isRendered__") ? row.__isRendered__ : false;
1520
+ // row.__isShow__ = Object.prototype.hasOwnProperty.call(row, "__isShow__") ? row.__isShow__ : false;
1521
+ // row.__isTmpShow__ = Object.prototype.hasOwnProperty.call(row, "__isTmpShow__") ? row.__isTmpShow__ : false;
1522
+ }
1523
+ } else {
1524
+ row.__isRendered__ = Object.prototype.hasOwnProperty.call(row, "__isRendered__") ? row.__isRendered__ : true;
1525
+ row.__isShow__ = Object.prototype.hasOwnProperty.call(row, "__isShow__") ? row.__isShow__ : true;
1526
+ row.__isTmpShow__ = Object.prototype.hasOwnProperty.call(row, "__isTmpShow__") ? row.__isTmpShow__ : true;
1527
+ row.__isSearchShow__ = Object.prototype.hasOwnProperty.call(row, "__isSearchShow__") ? row.__isSearchShow__ : false;
1528
+ row.__isExpand__ = Object.prototype.hasOwnProperty.call(row, "__isExpand__") ? row.__isExpand__ : false;
1529
+ }
1530
+ }
1506
1531
  },
1507
1532
  dealSearchShow (rowItem) {
1508
1533
  if (this.isSearching) {