bri-components 1.3.31 → 1.3.33

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,21 +1,24 @@
1
1
  <template>
2
2
  <div class="DshTreeTable">
3
- <dsh-buttons
4
- class="DshTreeTable-btns"
5
- itemClass="DshTreeTable-btns-item"
6
- :list="$getOperationList(topOperationBtns)"
7
- @click="$dispatchEvent($event)"
8
- ></dsh-buttons>
3
+ <div class="DshTreeTable-top">
4
+ <div class="DshTreeTable-top-total">{{ rowsNumStr }}</div>
5
+
6
+ <dsh-buttons
7
+ class="DshTreeTable-top-btns"
8
+ itemClass="DshTreeTable-top-btns-item"
9
+ :list="$getOperationList(topOperationBtns)"
10
+ @click="$dispatchEvent($event)"
11
+ ></dsh-buttons>
12
+ </div>
9
13
 
10
14
  <!-- 搜索条件 -->
11
- <template v-if="searchFormList.length">
12
- <dsh-default-search
13
- :formList="searchFormList"
14
- :initValue="advSearchObj.conditions"
15
- :labelWidth="searchLabelWidth"
16
- @change="searchCb"
17
- ></dsh-default-search>
18
- </template>
15
+ <dsh-default-search
16
+ v-if="searchFormList.length && !isEnlarge"
17
+ :formList="searchFormList"
18
+ :initValue="advSearchObj.conditions"
19
+ :labelWidth="searchLabelWidth"
20
+ @change="searchCb"
21
+ ></dsh-default-search>
19
22
 
20
23
  <!-- 表格 -->
21
24
  <bri-table
@@ -42,7 +45,7 @@
42
45
  mode="custom"
43
46
  :propsObj="modalPropsObj"
44
47
  >
45
- <template v-if="enlargeFlag">
48
+ <template v-if="isEnlargeFlag">
46
49
  <!-- 搜索条件 -->
47
50
  <template v-if="searchFormList.length">
48
51
  <dsh-default-search
@@ -72,6 +75,9 @@
72
75
  ></dsh-buttons>
73
76
  </template>
74
77
  </dsh-modal>
78
+
79
+ <!-- 各种模态框共用 -->
80
+ <dsh-render :render="dshRender"></dsh-render>
75
81
  </div>
76
82
  </template>
77
83
 
@@ -89,7 +95,7 @@
89
95
  props: {},
90
96
  data () {
91
97
  return {
92
- deleteProperties: ["__treeIndex__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchingShow__"], // 除了__old__
98
+ deleteProperties: ["__treeIndex__", "__old__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchingShow__"], // 除了__old__
93
99
  isExpandAction: false,
94
100
 
95
101
  searchMode: "flat", // "flat", "tree"
@@ -101,53 +107,75 @@
101
107
  },
102
108
  computed: {
103
109
  isSearching () {
104
- return this.searchFormList.length && this.advSearchObj.conditions.some(conditionItem => conditionItem.fieldValue.length);
110
+ return this.searchFormList.length && this.advSearchObj.conditions.some(conditionItem =>
111
+ conditionItem.fieldValue.length && conditionItem.fieldValue.some(valItem => !this.$isEmptyData(valItem))
112
+ );
113
+ },
114
+ allTreeData () {
115
+ console.log("allTreeData");
116
+ return this.getCalcuedTree(this.data, this.filterColumns);
117
+ },
118
+ allListData () {
119
+ return this.$getTreeFlatArr(this.allTreeData);
105
120
  },
106
121
  listData () {
107
- console.log("listData");
108
- const treeData = this.getCalcuedTree(this.data, this.filterColumns);
109
- return this.$getTreeFlatArr(treeData, node => {
122
+ return this.allListData.filter(row => {
110
123
  if (this.isSearching) {
111
- if (node.__isRendered__ === true) {
112
- node.__isSearchingShow__ = false;
113
- }
124
+ // 重置__isSearchingShow__为false
125
+ row.__isSearchingShow__ = false;
114
126
 
115
- const bool = this.$isAdvRelyAccord(this.advSearchObj, node);
127
+ const bool = this.$isAdvRelyAccord(this.advSearchObj, row);
116
128
  if (bool) {
117
- node.__isRendered__ = true;
118
- node.__isSearchingShow__ = true;
129
+ row.__isRendered__ = true;
130
+ row.__isSearchingShow__ = true;
119
131
  }
120
- return bool || node.__isRendered__;
132
+
133
+ return bool || row.__isRendered__;
121
134
  } else {
122
- return node.__isRendered__;
135
+ return row.__isRendered__;
123
136
  }
124
137
  });
125
138
  },
139
+ showListData () {
140
+ return this.listData.filter(row =>
141
+ this.isSearching ? !!row.__isSearchingShow__ : !!row.__isShow__
142
+ );
143
+ },
144
+ rowsNum () {
145
+ return this.isSearching
146
+ ? this.showListData.length
147
+ : this.allListData.length;
148
+ },
149
+ rowsNumStr () {
150
+ return `当前范围“${this.isSearching ? "筛选" : "全部"}”, 共 ${this.rowsNum} 行`;
151
+ },
126
152
  footerData () {
127
153
  console.log("footerData");
128
- return this.useSummary && this.listData.length
129
- ? [
130
- this.filterColumns.reduce((obj, col) => {
131
- return {
132
- ...obj,
133
- [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
134
- ? this.$calNumList(
135
- this.listData
136
- .filter(item => item.level === 1)
137
- .map(item => item[col._key]),
138
- col._summaryType,
139
- { ...col, _defaultDigit: 2 }
140
- )
141
- : (obj[col._key] || "--")
142
- };
143
- }, {
144
- _id: this.$ObjectID().str,
145
- __index__: "汇总",
146
- __isExpand__: "-",
147
- __operation__: "——"
148
- })
149
- ]
150
- : [];
154
+ return this.isSearching
155
+ ? []
156
+ : this.useSummary && this.listData.length
157
+ ? [
158
+ this.filterColumns.reduce((obj, col) => {
159
+ return {
160
+ ...obj,
161
+ [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
162
+ ? this.$calNumList(
163
+ this.listData
164
+ .filter(item => item.level === 1)
165
+ .map(item => item[col._key]),
166
+ col._summaryType,
167
+ { ...col, _defaultDigit: 2 }
168
+ )
169
+ : (obj[col._key] || "--")
170
+ };
171
+ }, {
172
+ _id: this.$ObjectID().str,
173
+ __index__: "汇总",
174
+ __isExpand__: "-",
175
+ __operation__: "——"
176
+ })
177
+ ]
178
+ : [];
151
179
  },
152
180
 
153
181
  selfPropsObj () {
@@ -189,7 +217,7 @@
189
217
  bodyCellClass: ({ row, column, rowIndex }) => {
190
218
  return "bri-table-td" +
191
219
  `${
192
- this.canEdit
220
+ this.getRowCanEdit(row)
193
221
  ? " bri-table-td-edit"
194
222
  : " bri-table-td-show"
195
223
  }` +
@@ -200,7 +228,7 @@
200
228
  : ""
201
229
  : !row.__isShow__
202
230
  ? " bri-table-td-hide"
203
- : row.__isShow__ === true && this.isExpandAction
231
+ : this.isExpandAction
204
232
  ? " bri-table-td-visible"
205
233
  : ""
206
234
  }` +
@@ -228,7 +256,11 @@
228
256
  this.expandColumn,
229
257
  ...(this.useIndex === true ? [this.indexColumn] : []),
230
258
  ...this.$transformToColumns(this.contentColumns),
231
- ...(!this.isSearching && this.$getOperationList(["canDelete"]).length ? [this.operationColumn] : [])
259
+ ...(this.isSearching
260
+ ? []
261
+ : this.$getOperationList(["canDelete"]).length
262
+ ? [this.operationColumn]
263
+ : [])
232
264
  ];
233
265
  },
234
266
  expandColumn () {
@@ -241,26 +273,28 @@
241
273
  align: "center",
242
274
  fixed: "left",
243
275
  renderBodyCell: ({ row, column, rowIndex }, h) => {
244
- return row.children && row.children.length && (this.isSearching ? this.searchMode === "tree" : true)
245
- ? h("Icon", {
246
- style: {
247
- width: "16px",
248
- height: "16px",
249
- cursor: "pointer",
250
- transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
251
- transition: "transform 0.3s"
252
- },
253
- props: {
254
- type: "ios-arrow-forward",
255
- size: "18"
256
- },
257
- on: {
258
- click: () => {
259
- this.toggleExpand(row, !row.__isExpand__);
276
+ return this.isSearching && this.searchMode === "flat"
277
+ ? h("span", "")
278
+ : row.children && row.children.length
279
+ ? h("Icon", {
280
+ style: {
281
+ width: "16px",
282
+ height: "16px",
283
+ cursor: "pointer",
284
+ transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
285
+ transition: "transform 0.3s"
286
+ },
287
+ props: {
288
+ type: "ios-arrow-forward",
289
+ size: "18"
290
+ },
291
+ on: {
292
+ click: () => {
293
+ this.toggleExpand(row, !row.__isExpand__);
294
+ }
260
295
  }
261
- }
262
- })
263
- : h("span", "");
296
+ })
297
+ : h("span", "");
264
298
  }
265
299
  };
266
300
  },
@@ -323,6 +357,16 @@
323
357
  },
324
358
  created () {},
325
359
  methods: {
360
+ // 本身的初始化
361
+ selfReset () {
362
+ this.isExpandAction = false;
363
+ this.searchMode = "flat";
364
+ this.advSearchObj = {
365
+ logic: "and",
366
+ conditions: []
367
+ };
368
+ },
369
+
326
370
  // 筛选回调
327
371
  searchCb (conditions) {
328
372
  this.isExpandAction = false;
@@ -334,12 +378,11 @@
334
378
  // 展开/隐藏节点
335
379
  toggleExpand (row, bool = true) {
336
380
  this.isExpandAction = true;
337
- // this.$set(row, "__isRendered__", true);
338
- // this.$set(row, "__isShow__", true);
339
381
  this.$set(row, "__isExpand__", bool);
340
382
 
341
383
  this.toggleDescendantsShow(row, bool);
342
384
  },
385
+
343
386
  // 点击 -添加一行
344
387
  clickCreate (operationItem, row, rowIndex) {
345
388
  // !row代表最上级节点
@@ -377,19 +420,15 @@
377
420
  }
378
421
  });
379
422
  },
380
- // 点击导出
381
- clickExport (operationItem) {
382
- // operationItem.disabled = true;
383
- },
384
423
 
385
424
  /* ------ 工具方法 ------- */
386
425
  // 加工树形数据
387
426
  getCalcuedTree (treeData = [], columns) {
388
427
  const loop = (list = []) =>
389
- list.reduce((newList, node) => {
428
+ list.forEach((node) => {
390
429
  if (node.children && node.children.length) {
391
430
  node.isLeaf = false;
392
- node.children = loop(node.children);
431
+ loop(node.children);
393
432
 
394
433
  columns.reduce((newNode, col) => {
395
434
  if (col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)) {
@@ -409,26 +448,25 @@
409
448
  node.isLeaf = true;
410
449
  }
411
450
 
412
- // 初次进来把前端存的状态值全部清除,除了__old__
413
- if (!this.initFlag) {
451
+ // 初次进来把前端存的状态值全部清除(除了__readonly__)
452
+ if (this.initFlag) {
414
453
  this.deleteProperties.forEach(property => {
415
454
  delete node[property];
416
455
  });
417
456
 
457
+ node.__old__ = true; // 老的数据都打上标记 尽管不一定会用
458
+ // 第一级的需要显示出来
418
459
  if (node.level == 1) {
419
460
  node.__isRendered__ = true;
420
461
  node.__isShow__ = true;
462
+ node.__isTmpShow__ = true;
421
463
  }
422
464
  }
465
+ });
423
466
 
424
- return [
425
- ...newList,
426
- node
427
- ];
428
- }, []);
429
-
430
- treeData = loop(treeData);
431
- this.initFlag = true;
467
+ loop(treeData);
468
+ console.log("treeee");
469
+ this.initFlag = false;
432
470
  return treeData;
433
471
  },
434
472
  // 获取父节点
@@ -451,8 +489,8 @@
451
489
  }
452
490
  });
453
491
  };
454
-
455
492
  loop(tree);
493
+
456
494
  return parentNode;
457
495
  }
458
496
  },
@@ -464,11 +502,11 @@
464
502
  if (isFirstSon) {
465
503
  this.$set(subNode, "__isRendered__", true);
466
504
  this.$set(subNode, "__isShow__", bool);
505
+ this.$set(subNode, "__isTmpShow__", bool);
467
506
  } else {
468
507
  if (bool) {
469
508
  this.$set(subNode, "__isShow__", subNode.__isTmpShow__);
470
509
  } else {
471
- this.$set(subNode, "__isTmpShow__", subNode.__isShow__);
472
510
  this.$set(subNode, "__isShow__", false);
473
511
  }
474
512
  }
@@ -486,13 +524,23 @@
486
524
 
487
525
  <style lang="less" scoped>
488
526
  .DshTreeTable {
489
- &-btns {
490
- margin-bottom: 5px;
491
- text-align: right;
492
- color: @textColor;
527
+ &-top {
528
+ display: flex;
529
+ flex-direction: row;
530
+ justify-content: space-between;
531
+ align-items: center;
532
+
533
+ &-total {
534
+ font-weight: 500;
535
+ }
493
536
 
494
- &-item {
537
+ &-btns {
538
+ text-align: right;
539
+ color: @textColor;
495
540
 
541
+ &-item {
542
+
543
+ }
496
544
  }
497
545
  }
498
546
 
@@ -237,15 +237,7 @@
237
237
  </script>
238
238
 
239
239
  <style lang="less">
240
- .sheetBatchImportModal {
241
- &-file {
242
- position: relative;
240
+ .flatTableImportModal {
243
241
 
244
- &-cancel {
245
- cursor: pointer;
246
- float: right;
247
- font-size: @titleSize;
248
- }
249
- }
250
242
  }
251
243
  </style>
@@ -32,7 +32,13 @@ export default {
32
32
  listData () {
33
33
  this.data.forEach(item => {
34
34
  !item._id && this.$set(item, "_id", this.$ObjectID().str);
35
+
36
+ if (!this.initFlag) {
37
+ item.__old__ = true; // 标记老数据(initFlag不用在data中声明)
38
+ }
35
39
  });
40
+
41
+ this.initFlag = true;
36
42
  return this.data;
37
43
  },
38
44
  oldListData () {
@@ -78,7 +84,7 @@ export default {
78
84
  cellStyleOption: {
79
85
  bodyCellClass: ({ row, column, rowIndex }) => {
80
86
  return "bri-table-td" +
81
- `${this.canEdit
87
+ `${this.getRowCanEdit(row)
82
88
  ? " bri-table-td-edit"
83
89
  : " bri-table-td-show"
84
90
  }`;
@@ -137,7 +143,7 @@ export default {
137
143
  props: {
138
144
  list: operationList.map(btnItem => ({
139
145
  ...btnItem,
140
- disabled: this.disabledOldDataRow && !row.__isCreate__
146
+ disabled: !this.getRowCanEdit(row)
141
147
  }))
142
148
  },
143
149
  on: {
@@ -231,13 +237,12 @@ export default {
231
237
  created () { },
232
238
  methods: {
233
239
  // 点击 -添加行
234
- clickCreate (operationItem, row, index, list) {
240
+ clickCreate (operationItem, row, rowIndex, list) {
235
241
  const newRow = {
236
242
  ...this.$deepCopy(this.selfRowDefault),
237
- __isCreate__: true,
238
243
  _id: this.$ObjectID().str
239
244
  };
240
- const newRowIndex = index == null ? list.length : index + 1;
245
+ const newRowIndex = rowIndex == null ? list.length : rowIndex + 1;
241
246
  list.splice(newRowIndex, 0, newRow);
242
247
  this.$forceUpdate(); // 自定义页中点击添加一行没有更新页面
243
248
 
@@ -246,7 +251,7 @@ export default {
246
251
  // 点击 -删除行
247
252
  clickDelete (operationItem, row, rowIndex, list) {
248
253
  this.$Modal.confirm({
249
- title: "警告",
254
+ title: "提示",
250
255
  content: "确定删除吗?",
251
256
  onOk: () => {
252
257
  list.splice(rowIndex, 1);
@@ -0,0 +1,215 @@
1
+ <template>
2
+ <div class="quoteListModal">
3
+ <Drawer
4
+ v-model="showModal"
5
+ class="quoteListModal-drawer"
6
+ width="400"
7
+ :title="'引用列表'"
8
+ :mask-closable="true"
9
+ :closable="true"
10
+ :draggable="true"
11
+ >
12
+ <div class="quoteListModal-drawer-body">
13
+ <div class="list">
14
+ <template v-if="listData.length">
15
+ <div
16
+ v-for="dataItem in listData"
17
+ :key="dataItem._id"
18
+ :class="{
19
+ 'list-item': true,
20
+ 'list-item-active': curDataItem && curDataItem._id === dataItem._id
21
+ }"
22
+ @click="clickItem(dataItem)"
23
+ >
24
+ {{ listFields.length ? dataItem[listFields[0]] : dataItem.createdAt }}
25
+ </div>
26
+ </template>
27
+
28
+ <div
29
+ v-else
30
+ class="list-nodata"
31
+ >
32
+ 暂无数据…
33
+ </div>
34
+ </div>
35
+
36
+ <dsh-buttons
37
+ class="quoteListModal-drawer-body-btns"
38
+ itemClass="quoteListModal-drawer-body-btns-item"
39
+ :list="$getOperationList()"
40
+ @click="$dispatchEvent($event)"
41
+ ></dsh-buttons>
42
+ </div>
43
+ </Drawer>
44
+ </div>
45
+ </template>
46
+
47
+ <script>
48
+ export default {
49
+ name: "quoteListModal",
50
+ props: {
51
+ value: {
52
+ type: Boolean,
53
+ default: false
54
+ },
55
+ propsObj: {
56
+ type: Object,
57
+ default () {
58
+ return {};
59
+ }
60
+ },
61
+ listParams: {
62
+ type: Object,
63
+ default () {
64
+ return {};
65
+ }
66
+ }
67
+ },
68
+ data () {
69
+ return {
70
+ listData: [],
71
+ listPropsObj: {
72
+ isLoading: false
73
+ },
74
+ curDataItem: undefined,
75
+
76
+ operationMap: {
77
+ canReset: {
78
+ name: "重 置",
79
+ type: "canReset",
80
+ size: "small",
81
+ event: "clickReset"
82
+ },
83
+ confirm: {
84
+ name: "确 认",
85
+ type: "confirm",
86
+ btnType: "primary",
87
+ size: "small",
88
+ event: "clickConfirm"
89
+ }
90
+ }
91
+ };
92
+ },
93
+ computed: {
94
+ showModal: {
95
+ get () {
96
+ return this.value;
97
+ },
98
+ set (val) {
99
+ this.$emit("input", val);
100
+ }
101
+ },
102
+
103
+ modKey () {
104
+ return this.propsObj.modKey;
105
+ },
106
+ screenKey () {
107
+ return this.propsObj.screenKey;
108
+ },
109
+ listFields () {
110
+ return this.propsObj._quoteListFields || [];
111
+ }
112
+ },
113
+ created () {
114
+ this.init();
115
+ },
116
+ methods: {
117
+ init () {
118
+ this.getListData();
119
+ },
120
+ clickItem (dataItem) {
121
+ if (this.curDataItem && this.curDataItem._id === dataItem._id) {
122
+ this.curDataItem = undefined;
123
+ } else {
124
+ this.curDataItem = dataItem;
125
+ }
126
+ },
127
+ // 点击重置
128
+ clickReset () {
129
+
130
+ },
131
+ // 点击确认
132
+ clickConfirm () {
133
+ this.showModal = false;
134
+ this.$emit("confirm", this.curDataItem);
135
+ },
136
+
137
+ getListData () {
138
+ this.$https({
139
+ url: {
140
+ module: "sheet",
141
+ name: "index"
142
+ },
143
+ params: this.listParams,
144
+ loadingName: "listPropsObj.isLoading",
145
+ callback: data => {
146
+ this.listData = data.list;
147
+ this.curDataItem = this.listData[0];
148
+ }
149
+ });
150
+ }
151
+ }
152
+ };
153
+ </script>
154
+
155
+ <style lang="less">
156
+ .quoteListModal {
157
+ &-drawer {
158
+ &-body {
159
+ width: 100%;
160
+ height: 100%;
161
+ padding: 20px;
162
+ overflow: auto;
163
+
164
+ .list {
165
+ &-item {
166
+ padding: 8px 12px;
167
+ margin-bottom: 8px;
168
+ border-radius: 4px;
169
+ cursor: pointer;
170
+
171
+ &-active {
172
+ background-color: @theme-hover;
173
+ }
174
+ }
175
+
176
+ &-nodata {
177
+ #dsh-nodata();
178
+ }
179
+ }
180
+
181
+ &-btns {
182
+ position: absolute;
183
+ bottom: 0px;
184
+ left: 0px;
185
+ .dsh-flex-row-start-stretch();
186
+ width: calc(100% - 48px);
187
+ height: 51px;
188
+ margin: 25px 20px 25px 28px;
189
+
190
+ &-item {
191
+ flex: 1;
192
+ margin: 5px;
193
+ height: 40px;
194
+ }
195
+ }
196
+ }
197
+
198
+ .ivu-drawer-mask,
199
+ .ivu-drawer-wrap {
200
+ // z-index: 88888888;
201
+ }
202
+ .ivu-drawer-body {
203
+ padding: 0px;
204
+ padding-bottom: 50px;
205
+ overflow: hidden;
206
+ }
207
+ .ivu-drawer-header-inner {
208
+ font-size: @titleSize;
209
+ font-family: @titleFontFamily;
210
+ color: #333;
211
+ font-weight: bold;
212
+ }
213
+ }
214
+ }
215
+ </style>