bri-components 1.3.61 → 1.3.63

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.
@@ -0,0 +1,124 @@
1
+ export default {
2
+ mixins: [],
3
+ components: {},
4
+ props: {},
5
+ data () {
6
+ return {};
7
+ },
8
+ computed: {
9
+ allListData () {
10
+ console.log("allListData");
11
+ this.data.forEach(item => {
12
+ !item._id && this.$set(item, "_id", this.$ObjectID().str);
13
+
14
+ if (this.initFlag) {
15
+ item.__old__ = true; // 标记老数据(initFlag不用在data中声明)
16
+ item.__isRendered__ = true;
17
+ item.__isShow__ = true;
18
+ item.__isTmpShow__ = true;
19
+ item.__isSearchShow__ = false;
20
+ }
21
+ });
22
+
23
+ this.initFlag = false;
24
+ return this.data;
25
+ },
26
+ footerData () {
27
+ return this.isSearching
28
+ ? []
29
+ : this.useSummary && this.allListData.length
30
+ ? [
31
+ this.filterColumns.reduce((obj, col) => {
32
+ return {
33
+ ...obj,
34
+ [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
35
+ ? this.$calNumList(
36
+ this.allListData.map(item => item[col._key]),
37
+ col._summaryType,
38
+ { ...col, _defaultDigit: 2 }
39
+ )
40
+ : (obj[col._key] || "--")
41
+ };
42
+ }, {
43
+ _id: this.$ObjectID().str,
44
+ __index__: "汇总",
45
+ __operation__: "——"
46
+ })
47
+ ]
48
+ : [];
49
+ },
50
+
51
+ tablePropsObj () {
52
+ return {
53
+ maxHeight: this.contentHeight,
54
+ cellStyleOption: {
55
+ bodyCellClass: ({ column, row, rowIndex }) => {
56
+ return "bri-table-td" +
57
+ `${this.getRowCanEdit(row)
58
+ ? " bri-table-td-edit"
59
+ : ""
60
+ }` +
61
+ `${this.isSearching
62
+ ? !row.__isSearchShow__
63
+ ? " bri-table-td-hide"
64
+ : ""
65
+ : ""
66
+ }`;
67
+ }
68
+ }
69
+ };
70
+ },
71
+ showColumns () {
72
+ return [
73
+ ...(this.useSelection === true ? [this.selectionColumn] : []),
74
+ ...(this.useIndex === true ? [this.indexColumn] : []),
75
+ ...this.$transformToColumns(this.contentColumns),
76
+ ...(this.$getOperationList(["canDelete"]).length ? [this.operationColumn] : [])
77
+ ];
78
+ },
79
+ indexColumn () {
80
+ return {
81
+ title: "序号",
82
+ _key: "__index__",
83
+ key: "__index__",
84
+ field: "__index__",
85
+ width: 76,
86
+ align: "center",
87
+ fixed: "left",
88
+ renderBodyCell: ({ column, row, rowIndex }) => ++rowIndex
89
+ };
90
+ }
91
+ },
92
+ created () { },
93
+ methods: {
94
+ // 点击 -添加行
95
+ clickCreate (operationItem, row, rowIndex) {
96
+ const list = this.allListData;
97
+ const newRow = {
98
+ ...this.$deepCopy(this.selfRowDefault),
99
+ _id: this.$ObjectID().str,
100
+ __isRendered__: true,
101
+ __isShow__: true,
102
+ __isTmpShow__: true,
103
+ __isSearchShow__: false
104
+ };
105
+ const newRowIndex = rowIndex == null ? list.length : rowIndex + 1;
106
+ list.splice(newRowIndex, 0, newRow);
107
+ this.$forceUpdate(); // 自定义页中点击添加一行没有更新页面
108
+
109
+ this.change("createRow", null, newRow, newRowIndex);
110
+ },
111
+ // 点击 -删除行
112
+ clickDelete (operationItem, row, rowIndex) {
113
+ this.$Modal.confirm({
114
+ title: "提示",
115
+ content: "确定删除吗?",
116
+ onOk: () => {
117
+ this.allListData.splice(rowIndex, 1);
118
+
119
+ this.change("deleteRow", null, row, rowIndex);
120
+ }
121
+ });
122
+ }
123
+ }
124
+ };
@@ -0,0 +1,410 @@
1
+ export default {
2
+ mixins: [],
3
+ components: {},
4
+ props: {},
5
+ data () {
6
+ return {
7
+ deleteProperties: ["__treeIndex__", "__old__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"], // 除了__readonly__和__isQuote__不处理
8
+ isExpandAction: false,
9
+
10
+ searchMode: "flat" // "flat", "tree"
11
+
12
+ };
13
+ },
14
+ computed: {
15
+ selfPropsObj () {
16
+ return {
17
+ _maxLevel: 3, // 最大级数
18
+ ...this.commonPropsObj
19
+ };
20
+ },
21
+ maxLevel () {
22
+ return this.selfPropsObj._maxLevel || 3;
23
+ },
24
+
25
+ allTreeData () {
26
+ console.log("allTreeData");
27
+ return this.getCalcuedTree(this.data, this.columns);
28
+ },
29
+ allListData () {
30
+ console.log("allListData");
31
+ return this.$getTreeFlatArr(this.allTreeData);
32
+ },
33
+ footerData () {
34
+ console.log("footerData");
35
+ return this.isSearching
36
+ ? []
37
+ : this.useSummary && this.allListData.length
38
+ ? [
39
+ this.filterColumns.reduce((obj, col) => {
40
+ return {
41
+ ...obj,
42
+ [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
43
+ ? this.$calNumList(
44
+ this.allListData
45
+ .filter(item => item.level === 1)
46
+ .map(item => item[col._key]),
47
+ col._summaryType,
48
+ { ...col, _defaultDigit: 2 }
49
+ )
50
+ : (obj[col._key] || "--")
51
+ };
52
+ }, {
53
+ _id: this.$ObjectID().str,
54
+ __index__: "汇总",
55
+ __isExpand__: "-",
56
+ __operation__: "——"
57
+ })
58
+ ]
59
+ : [];
60
+ },
61
+
62
+ tablePropsObj () {
63
+ return {
64
+ maxHeight: this.contentHeight,
65
+ // rowStyleOption: {
66
+ // hoverHighlight: true,
67
+ // clickHighlight: true,
68
+ // stripe: true // 斑马纹
69
+ // },
70
+ cellStyleOption: {
71
+ bodyCellClass: ({ row, column, rowIndex }) => {
72
+ return "bri-table-td" +
73
+ `${this.getRowCanEdit(row)
74
+ ? " bri-table-td-edit"
75
+ : ""
76
+ }` +
77
+ `${this.isSearching
78
+ ? !row.__isSearchShow__
79
+ ? " bri-table-td-hide"
80
+ : ""
81
+ : !row.__isShow__
82
+ ? " bri-table-td-hide"
83
+ : this.isExpandAction
84
+ ? " bri-table-td-visible"
85
+ : ""
86
+ }` +
87
+ `${["__isExpand__"].includes(column._key)
88
+ ? " bri-table-td-expand"
89
+ : ["__index__"].includes(column._key)
90
+ ? " bri-table-td-index"
91
+ : ""
92
+ }`;
93
+ }
94
+ },
95
+ // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
96
+ columnHiddenOption: {
97
+ defaultHiddenColumnKeys: []
98
+ }
99
+ };
100
+ },
101
+ showColumns () {
102
+ return [
103
+ ...(this.useSelection === true ? [this.selectionColumn] : []),
104
+ this.expandColumn,
105
+ ...(this.useIndex === true ? [this.indexColumn] : []),
106
+ ...this.$transformToColumns(this.contentColumns),
107
+ ...(this.isSearching
108
+ ? []
109
+ : this.$getOperationList(["canDelete"]).length
110
+ ? [this.operationColumn]
111
+ : [])
112
+ ];
113
+ },
114
+ expandColumn () {
115
+ return {
116
+ // title: "开/合",
117
+ _key: "__isExpand__",
118
+ key: "__isExpand__",
119
+ field: "__isExpand__",
120
+ width: 48,
121
+ align: "center",
122
+ fixed: "left",
123
+ renderBodyCell: ({ row, column, rowIndex }, h) => {
124
+ return this.isSearching && this.searchMode === "flat"
125
+ ? h("span", "")
126
+ : row.children && row.children.length
127
+ ? h("Icon", {
128
+ style: {
129
+ width: "16px",
130
+ height: "16px",
131
+ cursor: "pointer",
132
+ transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
133
+ transition: "transform 0.3s"
134
+ },
135
+ props: {
136
+ type: "ios-arrow-forward",
137
+ size: "18"
138
+ },
139
+ on: {
140
+ click: () => {
141
+ this.toggleExpand(row, !row.__isExpand__);
142
+ }
143
+ }
144
+ })
145
+ : h("span", "");
146
+ }
147
+ };
148
+ },
149
+ indexColumn () {
150
+ return {
151
+ title: "序号",
152
+ _key: "__index__",
153
+ key: "__index__",
154
+ field: "__index__",
155
+ width: 28 + 16 + (this.maxLevel - 1) * 38,
156
+ align: "left",
157
+ fixed: "left",
158
+ renderBodyCell: ({ row, column, rowIndex }, h) => {
159
+ return [
160
+ h("div", {
161
+ style: {
162
+ paddingLeft: `${(row.level - 1) * 18}px`,
163
+ fontWeight: "500"
164
+ }
165
+ }, row.__treeIndex__),
166
+
167
+ // 添加符
168
+ this.operationMap.canCreate && row.level < this.maxLevel && !this.isSearching
169
+ ? h("div", {
170
+ style: {
171
+ position: "absolute",
172
+ bottom: "0px",
173
+ right: "0px",
174
+ display: "inline-block",
175
+ width: "16px",
176
+ height: " 16px",
177
+ border: "1px solid #dcdee2",
178
+ backgroundColor: "#ffffff",
179
+ lineHeight: "12px",
180
+ cursor: "pointer",
181
+ verticalAlign: "middle",
182
+ transition: "color .2s ease-in-out,border-color .2s ease-in-out"
183
+ }
184
+ }, [
185
+ h("Icon", {
186
+ style: {
187
+ fontWeight: "500"
188
+ },
189
+ props: {
190
+ type: "ios-add", // "md-add-circle"
191
+ size: "14"
192
+ },
193
+ on: {
194
+ click: () => {
195
+ this.clickCreate(this.operationMap.canCreate, row, rowIndex);
196
+ }
197
+ }
198
+ })
199
+ ])
200
+ : h("span", "")
201
+ ];
202
+ }
203
+ };
204
+ }
205
+ },
206
+ created () { },
207
+ methods: {
208
+ // 本身的初始化
209
+ selfReset () {
210
+ this.isExpandAction = false;
211
+ this.searchMode = "flat";
212
+ this.dftAdvSearch = {
213
+ logic: "and",
214
+ conditions: []
215
+ };
216
+ },
217
+
218
+ // 筛选回调
219
+ searchCb (conditions) {
220
+ this.isExpandAction = false;
221
+ this.dftAdvSearch.conditions = conditions;
222
+ },
223
+ // 展开/隐藏节点
224
+ toggleExpand (row, bool = true) {
225
+ this.isExpandAction = true;
226
+ // row.__isExpand__ = bool;
227
+ this.$set(row, "__isExpand__", bool);
228
+
229
+ this.toggleDescendantsShow(row, bool);
230
+ },
231
+
232
+ // 点击 -添加一行
233
+ clickCreate (operationItem, row, rowIndex) {
234
+ const newRow = {
235
+ ...this.$deepCopy(this.selfRowDefault),
236
+ _id: this.$ObjectID().str,
237
+ isLeaf: true,
238
+ children: [],
239
+ // __old__: false,
240
+ __isExpand__: false,
241
+ __isRendered__: true,
242
+ __isShow__: true,
243
+ __isTmpShow__: false,
244
+ __isSearchShow__: false
245
+ };
246
+
247
+ // !row代表最上级节点
248
+ if (!row) {
249
+ this.data.push({
250
+ ...newRow,
251
+ level: 1
252
+ });
253
+ } else {
254
+ row.children.push({
255
+ ...newRow,
256
+ level: row.level + 1
257
+ });
258
+
259
+ this.toggleExpand(row, true);
260
+ }
261
+ },
262
+ // 点击 -删除行
263
+ clickDelete (operationItem, row, rowIndex) {
264
+ this.$Modal.confirm({
265
+ title: "警告",
266
+ content: "确定删除吗?",
267
+ onOk: () => {
268
+ const parentNode = this.getParentNode(row, this.data);
269
+ const index = parentNode.children.findIndex(childNode => childNode._id === row._id);
270
+ parentNode.children.splice(index, 1);
271
+ }
272
+ });
273
+ },
274
+
275
+ /* ------ 工具方法 ------- */
276
+ // 加工树形数据
277
+ getCalcuedTree (treeData = [], columns = []) {
278
+ const loop = (list = [], parentRow) =>
279
+ list.forEach((row) => {
280
+ // 递归到叶子节点前 从上往下要处理的
281
+ columns.reduce((newRow, col) => {
282
+ const isNumberSummary = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType);
283
+ const isDateSummary = col._type === "date" && ![undefined, null, ""].includes(col._writeSort);
284
+
285
+ if (isNumberSummary || isDateSummary) {
286
+ const val = isNumberSummary
287
+ ? newRow[col._key]
288
+ : ["downToUp"].includes(col._writeSort)
289
+ ? newRow[col._key]
290
+ : !parentRow || parentRow[col._key]
291
+ ? newRow[col._key]
292
+ : undefined;
293
+
294
+ this.$set(newRow, col._key, val);
295
+ }
296
+
297
+ return newRow;
298
+ }, row);
299
+
300
+ if (row.children && row.children.length) {
301
+ row.isLeaf = false;
302
+ loop(row.children, row);
303
+
304
+ // 递归到叶子节点后 从下往上要处理的
305
+ columns.reduce((newRow, col) => {
306
+ const isNumberSummary = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType);
307
+ const isDateSummary = col._type === "date" && ![undefined, null, ""].includes(col._writeSort);
308
+
309
+ if (isNumberSummary || isDateSummary) {
310
+ const val = isNumberSummary
311
+ ? this.$calNumList(
312
+ newRow.children.map(subRow => subRow[col._key]),
313
+ col._summaryType,
314
+ { ...col, _defaultDigit: 2 },
315
+ false
316
+ )
317
+ : ["downToUp"].includes(col._writeSort)
318
+ ? this.$calDateList(
319
+ newRow.children.map(subRow => subRow[col._key]),
320
+ col._compareOperator,
321
+ col._dateType
322
+ )
323
+ : newRow[col._key];
324
+
325
+ this.$set(newRow, col._key, val);
326
+ }
327
+
328
+ return newRow;
329
+ }, row);
330
+ } else {
331
+ row.isLeaf = true;
332
+ }
333
+
334
+ // 初次进来把前端存的状态值全部清除(除了__readonly__)
335
+ if (this.initFlag) {
336
+ this.deleteProperties.forEach(property => {
337
+ delete row[property];
338
+ });
339
+
340
+ row.__old__ = true; // 老的数据都打上标记 尽管不一定会用
341
+ // row.__isExpand__ = false;
342
+ // row.__isSearchShow__ = false;
343
+ // 第一级的需要显示出来
344
+ if (row.level == 1) {
345
+ row.__isRendered__ = true;
346
+ row.__isShow__ = true;
347
+ row.__isTmpShow__ = true;
348
+ } else {
349
+ // row.__isRendered__ = false;
350
+ // row.__isShow__ = false;
351
+ // row.__isTmpShow__ = false;
352
+ }
353
+ }
354
+ });
355
+ loop(treeData);
356
+
357
+ this.initFlag = false;
358
+ return treeData;
359
+ },
360
+ // 获取父节点
361
+ getParentNode (curRow, tree = []) {
362
+ if (curRow.level === 1) {
363
+ return {
364
+ children: tree
365
+ };
366
+ } else {
367
+ let parentNode;
368
+
369
+ const loop = (list = []) => {
370
+ return list.some(row => {
371
+ if (row.level === curRow.level - 1) {
372
+ const isExist = row.children.some(childNode => childNode._id === curRow._id);
373
+ parentNode = row;
374
+ return isExist;
375
+ } else {
376
+ return loop(row.children);
377
+ }
378
+ });
379
+ };
380
+ loop(tree);
381
+
382
+ return parentNode;
383
+ }
384
+ },
385
+ // 切换子孙后代的显示/隐藏
386
+ toggleDescendantsShow (row, bool) {
387
+ const loop = (row, isFirstSon) => {
388
+ if (row.children && row.children.length) {
389
+ row.children.forEach(subRow => {
390
+ if (isFirstSon) {
391
+ this.$set(subRow, "__isRendered__", true);
392
+ this.$set(subRow, "__isShow__", bool);
393
+ this.$set(subRow, "__isTmpShow__", bool);
394
+ } else {
395
+ if (bool) {
396
+ this.$set(subRow, "__isShow__", subRow.__isTmpShow__);
397
+ } else {
398
+ this.$set(subRow, "__isShow__", false);
399
+ }
400
+ }
401
+
402
+ loop(subRow);
403
+ });
404
+ }
405
+ };
406
+
407
+ loop(row, true);
408
+ }
409
+ }
410
+ };
@@ -14,7 +14,7 @@ export default {
14
14
  type: Boolean,
15
15
  default: true
16
16
  },
17
- compareData: {
17
+ data: {
18
18
  type: Array,
19
19
  default () {
20
20
  return [];
@@ -26,6 +26,12 @@ export default {
26
26
  return {};
27
27
  }
28
28
  },
29
+ compareData: {
30
+ type: Array,
31
+ default () {
32
+ return [];
33
+ }
34
+ },
29
35
  columns: {
30
36
  type: Array,
31
37
  default () {
@@ -38,13 +44,13 @@ export default {
38
44
  return {};
39
45
  }
40
46
  },
47
+
41
48
  allFormList: {
42
49
  type: Array,
43
50
  default () {
44
51
  return [];
45
52
  }
46
53
  },
47
-
48
54
  parentObj: {
49
55
  type: Object,
50
56
  default () {
@@ -166,6 +172,7 @@ export default {
166
172
  allScreenKey () {
167
173
  return this.propsObj.allScreenKey;
168
174
  },
175
+
169
176
  commonPropsObj () {
170
177
  return {
171
178
  // isShare: false, // 是否是分享页在用
@@ -201,6 +208,11 @@ export default {
201
208
  _contentHeight: this.propsObj._contentHeight || 500 // 表格最大高度
202
209
  };
203
210
  },
211
+ selfPropsObj () {
212
+ return {
213
+ ...this.commonPropsObj
214
+ };
215
+ },
204
216
  // isShare () {
205
217
  // return this.selfPropsObj.isShare;
206
218
  // },
@@ -265,9 +277,6 @@ export default {
265
277
  searchListFields () {
266
278
  return this.searchList.map(searchItem => searchItem._key);
267
279
  },
268
- searchLabelWidth () {
269
- return this.selfPropsObj._searchLabelWidth;
270
- },
271
280
  tableAdvSearch () {
272
281
  return this.$transformAdvSearch(this.selfPropsObj._tableAdvSearch, this.allFormList, this.parentObj);
273
282
  },
@@ -290,6 +299,9 @@ export default {
290
299
  ]
291
300
  };
292
301
  },
302
+ isSearching () {
303
+ return this.$isAdvSearching(this.finalTableAdvSearch);
304
+ },
293
305
  searchFormList () {
294
306
  return this.$filterList(this.searchListFields, this.columns).map(formItem => ({
295
307
  ...formItem,
@@ -297,8 +309,8 @@ export default {
297
309
  _name: formItem._name
298
310
  }));
299
311
  },
300
- isSearching () {
301
- return this.$isAdvSearching(this.finalTableAdvSearch);
312
+ searchLabelWidth () {
313
+ return this.selfPropsObj._searchLabelWidth;
302
314
  },
303
315
  rowsNum () {
304
316
  return this.showListData.length;
@@ -492,6 +504,45 @@ export default {
492
504
  ...colItem
493
505
  }));
494
506
  },
507
+ selectionColumn () {
508
+ return {
509
+ _key: "__selection__",
510
+ key: "__selection__",
511
+ field: "__selection__",
512
+ type: "checkbox",
513
+ width: 66,
514
+ align: "center",
515
+ fixed: "left"
516
+ };
517
+ },
518
+ operationColumn () {
519
+ return {
520
+ title: "操作",
521
+ _key: "__operation__",
522
+ key: "__operation__",
523
+ field: "__operation__",
524
+ align: "center",
525
+ fixed: "right",
526
+ width: 100,
527
+ renderBodyCell: ({ column, row, rowIndex }, h) => {
528
+ const operationList = this.$getOperationList(["canDelete"]);
529
+
530
+ return h("dsh-buttons", {
531
+ props: {
532
+ list: operationList.map(btnItem => ({
533
+ ...btnItem,
534
+ disabled: !this.getRowBtnCanEdit(row)
535
+ }))
536
+ },
537
+ on: {
538
+ click: (operationItem) => {
539
+ this.$dispatchEvent(operationItem, row, rowIndex);
540
+ }
541
+ }
542
+ });
543
+ }
544
+ };
545
+ },
495
546
 
496
547
  topOperationBtns () {
497
548
  return Object.keys(this.topOperationMap);
@@ -567,6 +618,9 @@ export default {
567
618
  this.isExpandAction = false;
568
619
  this.dftAdvSearch.conditions = conditions;
569
620
  },
621
+ changeSelect (list) {
622
+ this.$emit("changeSelect", list);
623
+ },
570
624
  // 表单控件失去焦点
571
625
  controlBlur (operationItem, col, row, rowIndex, params) {
572
626
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
@@ -576,6 +630,11 @@ export default {
576
630
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
577
631
  this.change("changeVal", col, row, rowIndex, ...params);
578
632
  },
633
+ change (...params) {
634
+ this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, ...params);
635
+ },
636
+
637
+ /* ----------- 全屏 ---------- */
579
638
  // 打开全屏模态框
580
639
  clickEnlarge (operationItem) {
581
640
  this.isEnlarge = true;
@@ -709,7 +768,8 @@ export default {
709
768
  params: {
710
769
  screenKey: this.screenKey,
711
770
  _id: this.parentObj._id,
712
- _key: this.controlKey
771
+ _key: this.controlKey,
772
+ advSearch: this.finalTableAdvSearch
713
773
  },
714
774
  callback: data => {
715
775
  this.getJobStatus(operationItem, data.jobId, data.excel_url);