bri-components 1.3.60 → 1.3.62

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.
@@ -1,10 +1,12 @@
1
1
  import DshListUnit from "../../unit/DshListUnit.vue";
2
+ import importModal from "../common/importModal.vue";
2
3
  import quoteListModal from "../common/quoteListModal.vue";
3
4
 
4
5
  export default {
5
6
  mixins: [],
6
7
  components: {
7
8
  DshListUnit,
9
+ importModal,
8
10
  quoteListModal
9
11
  },
10
12
  props: {
@@ -12,7 +14,7 @@ export default {
12
14
  type: Boolean,
13
15
  default: true
14
16
  },
15
- compareData: {
17
+ data: {
16
18
  type: Array,
17
19
  default () {
18
20
  return [];
@@ -24,6 +26,12 @@ export default {
24
26
  return {};
25
27
  }
26
28
  },
29
+ compareData: {
30
+ type: Array,
31
+ default () {
32
+ return [];
33
+ }
34
+ },
27
35
  columns: {
28
36
  type: Array,
29
37
  default () {
@@ -36,13 +44,13 @@ export default {
36
44
  return {};
37
45
  }
38
46
  },
47
+
39
48
  allFormList: {
40
49
  type: Array,
41
50
  default () {
42
51
  return [];
43
52
  }
44
53
  },
45
-
46
54
  parentObj: {
47
55
  type: Object,
48
56
  default () {
@@ -164,6 +172,7 @@ export default {
164
172
  allScreenKey () {
165
173
  return this.propsObj.allScreenKey;
166
174
  },
175
+
167
176
  commonPropsObj () {
168
177
  return {
169
178
  // isShare: false, // 是否是分享页在用
@@ -199,6 +208,11 @@ export default {
199
208
  _contentHeight: this.propsObj._contentHeight || 500 // 表格最大高度
200
209
  };
201
210
  },
211
+ selfPropsObj () {
212
+ return {
213
+ ...this.commonPropsObj
214
+ };
215
+ },
202
216
  // isShare () {
203
217
  // return this.selfPropsObj.isShare;
204
218
  // },
@@ -263,9 +277,6 @@ export default {
263
277
  searchListFields () {
264
278
  return this.searchList.map(searchItem => searchItem._key);
265
279
  },
266
- searchLabelWidth () {
267
- return this.selfPropsObj._searchLabelWidth;
268
- },
269
280
  tableAdvSearch () {
270
281
  return this.$transformAdvSearch(this.selfPropsObj._tableAdvSearch, this.allFormList, this.parentObj);
271
282
  },
@@ -288,6 +299,9 @@ export default {
288
299
  ]
289
300
  };
290
301
  },
302
+ isSearching () {
303
+ return this.$isAdvSearching(this.finalTableAdvSearch);
304
+ },
291
305
  searchFormList () {
292
306
  return this.$filterList(this.searchListFields, this.columns).map(formItem => ({
293
307
  ...formItem,
@@ -295,10 +309,45 @@ export default {
295
309
  _name: formItem._name
296
310
  }));
297
311
  },
298
- isSearching () {
299
- return this.$isAdvSearching(this.finalTableAdvSearch);
312
+ searchLabelWidth () {
313
+ return this.selfPropsObj._searchLabelWidth;
314
+ },
315
+ rowsNum () {
316
+ return this.showListData.length;
300
317
  },
318
+ rowsNumStr () {
319
+ return `当前“${this.isSearching ? "筛选" : "全部"}”范围, 共 ${this.rowsNum} 行`;
320
+ },
321
+
322
+ showListData () {
323
+ console.log("showListData");
324
+ return this.allListData.filter(row => {
325
+ if (this.isSearching) {
326
+ const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, row);
301
327
 
328
+ // 重置
329
+ row.__isSearchShow__ = false;
330
+ if (bool) {
331
+ row.__isRendered__ = true;
332
+ row.__isSearchShow__ = true;
333
+ }
334
+
335
+ return bool;
336
+ } else {
337
+ return true;
338
+ }
339
+ });
340
+ },
341
+ renderedListData () {
342
+ console.log("renderedListData");
343
+ return this.allListData.filter(row =>
344
+ row.__isRendered__ || (
345
+ this.isSearching
346
+ ? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
347
+ : false
348
+ )
349
+ );
350
+ },
302
351
  parentDataId () {
303
352
  return this.parentObj._id;
304
353
  },
@@ -347,7 +396,11 @@ export default {
347
396
  quoteParams () {
348
397
  return {
349
398
  screenKey: this.allScreenKey,
350
- fields: [...this.quoteListFields, this.controlKey, "createdAt"],
399
+ fields: [
400
+ ...this.quoteListFields,
401
+ this.controlKey,
402
+ "createdAt"
403
+ ],
351
404
  advSearch: {
352
405
  logic: "and",
353
406
  conditions: [
@@ -369,6 +422,7 @@ export default {
369
422
  },
370
423
 
371
424
  filterColumns () {
425
+ console.log("filterColumns");
372
426
  return this.columns.filter(col => this.$isAdvRelyShow(col, this.allListData, this.parentObj, true));
373
427
  },
374
428
  contentColumns () {
@@ -450,6 +504,45 @@ export default {
450
504
  ...colItem
451
505
  }));
452
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
+ },
453
546
 
454
547
  topOperationBtns () {
455
548
  return Object.keys(this.topOperationMap);
@@ -525,6 +618,9 @@ export default {
525
618
  this.isExpandAction = false;
526
619
  this.dftAdvSearch.conditions = conditions;
527
620
  },
621
+ changeSelect (list) {
622
+ this.$emit("changeSelect", list);
623
+ },
528
624
  // 表单控件失去焦点
529
625
  controlBlur (operationItem, col, row, rowIndex, params) {
530
626
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
@@ -534,24 +630,22 @@ export default {
534
630
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
535
631
  this.change("changeVal", col, row, rowIndex, ...params);
536
632
  },
537
- // 点击引用
538
- clickQuote () {
539
- this.dshRenderName = "quoteModalRender";
540
- this.showQuoteModal = true;
541
- },
542
- // 点击导入
543
- clickImport () {
544
- this.showImportModal = true;
545
- },
546
- // 点击导出
547
- clickExport (operationItem) {
548
- this.handleExport(operationItem);
633
+ change (...params) {
634
+ this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, ...params);
549
635
  },
636
+
637
+ /* ----------- 全屏 ---------- */
550
638
  // 打开全屏模态框
551
639
  clickEnlarge (operationItem) {
552
640
  this.isEnlarge = true;
553
641
  },
554
642
 
643
+ /* ----------- 引用 ---------- */
644
+ // 点击引用
645
+ clickQuote () {
646
+ this.dshRenderName = "quoteModalRender";
647
+ this.showQuoteModal = true;
648
+ },
555
649
  // 引用模态框渲染函数
556
650
  quoteModalRender (h, params) {
557
651
  return this.showQuoteModal
@@ -591,7 +685,7 @@ export default {
591
685
  const loop = (list = []) =>
592
686
  list.map(item => ({
593
687
  ...item,
594
- children: item.children && item.children.length ? loop(item.children) : item.children,
688
+ children: item.children ? loop(item.children) : item.children,
595
689
  __isQuote__: true
596
690
  }));
597
691
 
@@ -626,11 +720,42 @@ export default {
626
720
  this.$Message.error("未选择引用数据!");
627
721
  }
628
722
  },
723
+
724
+ /* ----------- 导入 ---------- */
725
+ // 点击导入
726
+ clickImport () {
727
+ this.dshRenderName = "importModalRender";
728
+ this.showImportModal = true;
729
+ },
730
+ // 导入模态框渲染函数
731
+ importModalRender (h, params) {
732
+ return this.showImportModal
733
+ ? h("import-modal", {
734
+ props: {
735
+ value: this.showImportModal,
736
+ propsObj: this.propsObj,
737
+ listParams: this.importParams
738
+ },
739
+ on: {
740
+ input: bool => {
741
+ this.showImportModal = bool;
742
+ },
743
+ importCb: this.importCb
744
+ }
745
+ })
746
+ : undefined;
747
+ },
629
748
  // 导入回调
630
749
  importCb (dataObj) {
631
750
  this.parentObj[this.controlKey] = dataObj;
632
751
  this.change("import");
633
752
  },
753
+
754
+ /* ----------- 导出 ---------- */
755
+ // 点击导出
756
+ clickExport (operationItem) {
757
+ this.handleExport(operationItem);
758
+ },
634
759
  // 接口 -导出
635
760
  handleExport (operationItem) {
636
761
  operationItem.disabled = true;
@@ -682,7 +807,118 @@ export default {
682
807
  });
683
808
  },
684
809
 
685
- /* --------------- 工具方法 ------------- */
810
+ /* ----------- 渲染函数 ---------- */
811
+ getTableTopRender (isEnlarge = false) {
812
+ return (h, params) => {
813
+ return h("div", {
814
+ style: {
815
+ "margin-bottom": "3px",
816
+ "display": "flex",
817
+ "flex-direction": "row",
818
+ "justify-content": "space-between",
819
+ "align-items": "center"
820
+ }
821
+ }, [
822
+ // 左 -统计,逻辑
823
+ this.topSummaryRender(h, params),
824
+
825
+ // 右 -功能按钮
826
+ isEnlarge ? undefined : this.topOperationRender(h, params)
827
+ ]);
828
+ };
829
+ },
830
+ topSearchRender (h, params) {
831
+ return this.searchFormList.length
832
+ ? h("dsh-default-search", {
833
+ props: {
834
+ formList: this.searchFormList,
835
+ initValue: this.dftAdvSearch.conditions,
836
+ labelWidth: this.searchLabelWidth
837
+ },
838
+ on: {
839
+ change: this.searchCb
840
+ }
841
+ })
842
+ : undefined;
843
+ },
844
+ topSummaryRender (h, params) {
845
+ return h("div", {
846
+ style: {
847
+ "display": "flex",
848
+ "flex-direction": "row",
849
+ "align-items": "center"
850
+ }
851
+ }, [
852
+ h("span", {
853
+ style: {
854
+ "font-weight": "500"
855
+ }
856
+ }, this.rowsNumStr + ";"),
857
+
858
+ this.searchFormList.length
859
+ ? h("div", {
860
+ style: {
861
+ "display": "flex",
862
+ "flex-direction": "row",
863
+ "align-items": "center",
864
+ "margin-left": "16px"
865
+ }
866
+ }, [
867
+ h("div", {
868
+ style: {
869
+ "font-weight": "500"
870
+ }
871
+ }, this.selfLogicPropsObj._name + ":"),
872
+ h("dsh-select", {
873
+ style: {
874
+ "margin-left": "8px",
875
+ "margin-top": "-4px"
876
+ },
877
+ props: {
878
+ value: this.dftAdvSearch,
879
+ propsObj: this.selfLogicPropsObj
880
+ }
881
+ })
882
+ ])
883
+ : undefined
884
+ ]);
885
+ },
886
+ topOperationRender (h, params) {
887
+ return h("dsh-buttons", {
888
+ style: {
889
+ "text-align": "right"
890
+ },
891
+ props: {
892
+ itemClass: undefined,
893
+ list: this.$getOperationList(this.topOperationBtns)
894
+ },
895
+ on: {
896
+ click: (event) => {
897
+ this.$dispatchEvent(event);
898
+ }
899
+ }
900
+ });
901
+ },
902
+ createOperationRender (h, params) {
903
+ return !this.isSearching
904
+ ? h("dsh-buttons", {
905
+ style: {
906
+ "margin-top": "3px"
907
+ },
908
+ props: {
909
+ itemClass: undefined,
910
+ list: this.$getOperationList(["canCreate"])
911
+ },
912
+ on: {
913
+ click: (event) => {
914
+ this.$dispatchEvent(event);
915
+ }
916
+ }
917
+ })
918
+ : undefined;
919
+ },
920
+
921
+ /* ----------- 工具方法 ---------- */
686
922
  resetCol (col, row) {
687
923
  let resetMap = {
688
924
  select: {
@@ -1,154 +0,0 @@
1
- export default {
2
- mixins: [],
3
- components: {},
4
- props: {
5
- data: {
6
- type: Array,
7
- default () {
8
- return [];
9
- }
10
- }
11
- },
12
- model: {
13
- prop: "data",
14
- event: "change"
15
- },
16
- data () {
17
- return {};
18
- },
19
- computed: {
20
- selfPropsObj () {
21
- return {
22
- ...this.commonPropsObj
23
- };
24
- },
25
-
26
- allListData () {
27
- this.data.forEach(item => {
28
- !item._id && this.$set(item, "_id", this.$ObjectID().str);
29
-
30
- if (this.initFlag) {
31
- item.__old__ = true; // 标记老数据(initFlag不用在data中声明)
32
- }
33
- });
34
-
35
- this.initFlag = false;
36
- return this.data;
37
- },
38
- footerData () {
39
- return this.useSummary && this.allListData.length
40
- ? [
41
- this.filterColumns.reduce((obj, col) => {
42
- return {
43
- ...obj,
44
- [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
45
- ? this.$calNumList(
46
- this.allListData.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
- __operation__: "——"
56
- })
57
- ]
58
- : [];
59
- },
60
-
61
- showColumns () {
62
- return [
63
- ...(this.useSelection === true ? [this.selectionColumn] : []),
64
- ...(this.useIndex === true ? [this.indexColumn] : []),
65
- ...this.$transformToColumns(this.contentColumns),
66
- ...(this.$getOperationList(["canDelete"]).length ? [this.operationColumn] : [])
67
- ];
68
- },
69
- selectionColumn () {
70
- return {
71
- _key: "__selection__",
72
- key: "__selection__",
73
- field: "__selection__",
74
- type: "checkbox",
75
- width: 66,
76
- align: "center",
77
- fixed: "left"
78
- };
79
- },
80
- indexColumn () {
81
- return {
82
- title: "序号",
83
- _key: "__index__",
84
- key: "__index__",
85
- field: "__index__",
86
- width: 76,
87
- align: "center",
88
- fixed: "left",
89
- renderBodyCell: ({ column, row, rowIndex }) => ++rowIndex
90
- };
91
- },
92
- operationColumn () {
93
- return {
94
- title: "操作",
95
- _key: "__operation__",
96
- key: "__operation__",
97
- field: "__operation__",
98
- align: "center",
99
- fixed: "right",
100
- width: 100,
101
- renderBodyCell: ({ column, row, rowIndex }, h) => {
102
- const operationList = this.$getOperationList(["canDelete"]);
103
-
104
- return h("dsh-buttons", {
105
- props: {
106
- list: operationList.map(btnItem => ({
107
- ...btnItem,
108
- disabled: !this.getRowBtnCanEdit(row)
109
- }))
110
- },
111
- on: {
112
- click: (operationItem) => {
113
- this.$dispatchEvent(operationItem, row, rowIndex, this.allListData);
114
- }
115
- }
116
- });
117
- }
118
- };
119
- }
120
- },
121
- created () { },
122
- methods: {
123
- // 点击 -添加行
124
- clickCreate (operationItem, row, rowIndex, list) {
125
- const newRow = {
126
- ...this.$deepCopy(this.selfRowDefault),
127
- _id: this.$ObjectID().str
128
- };
129
- const newRowIndex = rowIndex == null ? list.length : rowIndex + 1;
130
- list.splice(newRowIndex, 0, newRow);
131
- this.$forceUpdate(); // 自定义页中点击添加一行没有更新页面
132
-
133
- this.change("createRow", null, newRow, newRowIndex);
134
- },
135
- // 点击 -删除行
136
- clickDelete (operationItem, row, rowIndex, list) {
137
- this.$Modal.confirm({
138
- title: "提示",
139
- content: "确定删除吗?",
140
- onOk: () => {
141
- list.splice(rowIndex, 1);
142
-
143
- this.change("deleteRow", null, row, rowIndex);
144
- }
145
- });
146
- },
147
- changeSelect (list) {
148
- this.$emit("changeSelect", list);
149
- },
150
- change (...params) {
151
- this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, ...params);
152
- }
153
- }
154
- };