bri-components 1.3.31 → 1.3.32

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.3.31",
3
+ "version": "1.3.32",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -77,11 +77,11 @@
77
77
  <!-- 编辑和查看 列表 -->
78
78
  <slot name="list">
79
79
  <upload-list
80
+ :showMode="showMode"
80
81
  :canEdit="finalCanEdit"
81
82
  :files="curValList"
82
- :emptyShowVal="emptyShowVal"
83
- :showMode="showMode"
84
83
  :propsObj="propsObj"
84
+ :emptyShowVal="emptyShowVal"
85
85
  @deleteItem="clickDeteItem"
86
86
  ></upload-list>
87
87
  </slot>
@@ -370,16 +370,6 @@
370
370
  height: 80px;
371
371
  }
372
372
  }
373
-
374
- &-inline {
375
- .bri-scrollbar6();
376
- height: 48px;
377
- line-height: 48px;
378
-
379
- .item {
380
- flex: 0 0 48px
381
- }
382
- }
383
373
  }
384
374
  }
385
375
 
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <div
3
- class="uploadList"
4
- :class="`uploadList-${showMode}`"
5
- >
2
+ <div :class="{
3
+ uploadList: true,
4
+ [`uploadList-${showMode}`]: true
5
+ }">
6
6
  <!-- 普通文本模式 -->
7
7
  <template v-if="showMode ==='old'">
8
8
  <!-- 有值 -->
@@ -50,7 +50,7 @@
50
50
  class="uploadList-nodata"
51
51
  >
52
52
  <Icon type="ios-time" />
53
- <span>{{ noText }}</span>
53
+ <span>{{ noDataText }}</span>
54
54
  </div>
55
55
  </template>
56
56
 
@@ -93,7 +93,7 @@
93
93
  v-else
94
94
  class="uploadList-inline-nodata"
95
95
  >
96
- {{ noText }}
96
+ {{ noDataText }}
97
97
  </span>
98
98
  </template>
99
99
  </div>
@@ -106,6 +106,10 @@
106
106
  export default {
107
107
  name: "uploadList",
108
108
  props: {
109
+ showMode: {
110
+ type: String,
111
+ default: "old" // inline, old, normal
112
+ },
109
113
  canEdit: {
110
114
  type: Boolean,
111
115
  default: true
@@ -116,23 +120,19 @@
116
120
  return [];
117
121
  }
118
122
  },
119
- showMode: {
120
- type: String,
121
- default: "old" // inline, old, normal
122
- },
123
- emptyShowVal: String,
124
123
  propsObj: {
125
124
  type: Object,
126
125
  default () {
127
126
  return {};
128
127
  }
129
- }
128
+ },
129
+ emptyShowVal: String
130
130
  },
131
131
  computed: {
132
132
  imageResizeConfig () {
133
133
  return {};
134
134
  },
135
- noText () {
135
+ noDataText () {
136
136
  return this.canEdit
137
137
  ? `未上传${this.propsObj._fileType === "image" ? "图片" : "文件"}`
138
138
  : this.emptyShowVal;
@@ -334,13 +334,13 @@
334
334
  }
335
335
 
336
336
  &-action {
337
- background-color: @placeholderColor;
338
- display: none !important;
339
337
  position: absolute;
340
338
  right: 0px;
341
339
  top: 0px;
342
340
  left: 0px;
343
341
  bottom: 0px;
342
+ background-color: @placeholderColor;
343
+ display: none !important;
344
344
  align-items: center;
345
345
  justify-content: center;
346
346
 
@@ -349,7 +349,6 @@
349
349
  height: 22px;
350
350
  line-height: 22px;
351
351
  color: #fff;
352
- margin-left: 2px;
353
352
  }
354
353
  }
355
354
  }
@@ -357,31 +356,25 @@
357
356
 
358
357
  // 内部表格inline模式
359
358
  &-inline {
360
- height: 30px;
361
- line-height: 30px;
359
+ height: 32px;
360
+ line-height: 32px;
362
361
 
363
362
  &-list {
364
363
  width: 100%;
365
364
  height: 100%;
365
+ padding-left: 3px;
366
366
  display: flex;
367
367
  flex-wrap: nowrap;
368
368
  overflow-x: auto;
369
369
  overflow-y: hidden;
370
- padding-left: 3px;
371
370
 
372
371
  .item {
373
- flex: 0 0 48px;
374
- background: #f4f5fa;
372
+ flex: 0 0 32px;
375
373
  margin-right: 3px;
376
- position: relative;
377
374
  border-radius: @borderRadius;
375
+ background: #f4f5fa;
378
376
  text-align: center;
379
- &:hover {
380
- .item-action {
381
- display: flex !important;
382
- animation: toTop 0.1s;
383
- }
384
- }
377
+ position: relative;
385
378
 
386
379
  img {
387
380
  max-width: 100%;
@@ -390,18 +383,22 @@
390
383
  }
391
384
 
392
385
  &-action {
393
- display: none !important;
394
386
  position: absolute;
395
387
  left: 0;
396
388
  right: 0;
397
389
  top: 0;
398
390
  bottom: 0;
391
+ display: none !important;
399
392
  background-color: @placeholderColor;
400
393
  color: #fff;
401
394
  align-items: center;
402
395
  justify-content: center;
403
- i {
404
- margin: 0px;
396
+
397
+ &-icon {
398
+ width: 18px;
399
+ height: 18px;
400
+ line-height: 18px;
401
+ color: #fff;
405
402
  }
406
403
  }
407
404
 
@@ -414,6 +411,13 @@
414
411
  top: 0;
415
412
  }
416
413
  }
414
+
415
+ &:hover {
416
+ .item-action {
417
+ display: flex !important;
418
+ animation: toTop 0.1s;
419
+ }
420
+ }
417
421
  }
418
422
  }
419
423
 
@@ -28,18 +28,19 @@
28
28
  }"
29
29
  >
30
30
  <template v-if="!$isEmptyData(curValList)">
31
- <img
32
- v-for="item in curValList"
33
- :src="item.avatarurl ? $imageResize(item.avatarurl, imageResizeConfig) : $imageSrcMap.system.boy"
34
- :key="item._key"
35
- class="selectUsers-unit-img"
36
- />
37
- <span
38
- v-if="curValList[0]"
39
- class="selectUsers-unit-text"
40
- >
41
- {{ curValList[0].name || curValList[0].realname || curValList[0].mobile }}
42
- </span>
31
+ <template v-for="item in curValList">
32
+ <img
33
+ :src="item.avatarurl ? $imageResize(item.avatarurl, imageResizeConfig) : $imageSrcMap.system.boy"
34
+ :key="item._key"
35
+ class="selectUsers-unit-img"
36
+ />
37
+ <span
38
+ :key="item._key + 'span'"
39
+ class="selectUsers-unit-text"
40
+ >
41
+ {{ item.name || item.realname || item.mobile }}
42
+ </span>
43
+ </template>
43
44
  </template>
44
45
 
45
46
  <template v-else>
@@ -274,7 +275,9 @@
274
275
  m: "fixed",
275
276
  w: 18,
276
277
  h: 18
277
- }
278
+ },
279
+
280
+ allListFilterVals: []
278
281
  };
279
282
  },
280
283
  computed: {
@@ -186,8 +186,7 @@
186
186
 
187
187
  &-item {
188
188
  padding: 6px 0px;
189
- margin-top: 0px;
190
- margin-bottom: 0px;
189
+ margin: 0px;
191
190
 
192
191
  &-name {}
193
192
  }
@@ -209,7 +209,7 @@
209
209
  :propsObj="modalPropsObj"
210
210
  >
211
211
  <div
212
- v-if="enlargeFlag"
212
+ v-if="isEnlargeFlag"
213
213
  class="DshCasTable-wrap"
214
214
  >
215
215
  <div
@@ -32,7 +32,7 @@
32
32
  mode="custom"
33
33
  :propsObj="modalPropsObj"
34
34
  >
35
- <template v-if="enlargeFlag">
35
+ <template v-if="isEnlargeFlag">
36
36
  <!-- 表格 -->
37
37
  <bri-table
38
38
  class="DshFlatTable-main"
@@ -80,9 +80,7 @@
80
80
  },
81
81
  props: {},
82
82
  data () {
83
- return {
84
- isDshFlatTable: true // 做标记的
85
- };
83
+ return {};
86
84
  },
87
85
  computed: {},
88
86
  created () {},
@@ -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>
@@ -1,9 +1,11 @@
1
1
  import DshListUnit from "../../unit/DshListUnit.vue";
2
+ import quoteListModal from "./quoteListModal.vue";
2
3
 
3
4
  export default {
4
5
  mixins: [],
5
6
  components: {
6
- DshListUnit
7
+ DshListUnit,
8
+ quoteListModal
7
9
  },
8
10
  props: {
9
11
  canEdit: {
@@ -38,15 +40,26 @@ export default {
38
40
  },
39
41
  data () {
40
42
  return {
41
- showRuleMessage: false, // 显示校验文字
42
- ruleRecordMap: {},
43
+ initFlag: true,
44
+ showRuleMessage: false, // 进行全体校验
45
+ ruleRecordMap: {}, // 单元格是否发生校验的记录映射
43
46
 
44
- isEnlarge: false,
45
- enlargeFlag: true, // 为重渲染膜态框内容而用
47
+ dshRenderName: undefined,
48
+ showQuoteModal: false,
46
49
  showImportModal: false,
47
- timer: null,
50
+ exportTimer: null,
51
+ isEnlarge: false,
52
+ isEnlargeFlag: true, // 为重渲染膜态框内容而用
48
53
 
49
54
  topOperationMap: {
55
+ canQuote: {
56
+ name: "引用",
57
+ type: "canQuote",
58
+ icon: "ios-copy",
59
+ size: "small",
60
+ btnType: "text",
61
+ event: "clickQuote"
62
+ },
50
63
  canImport: {
51
64
  name: "导入",
52
65
  type: "canImport",
@@ -100,10 +113,31 @@ export default {
100
113
  };
101
114
  },
102
115
  computed: {
116
+ dshRender () {
117
+ return this[this.dshRenderName];
118
+ },
119
+ parentDataId () {
120
+ return this.parentObj._id;
121
+ },
103
122
  selfRowDefault () {
104
123
  return this.$filterObj(this.filterColumns, this.rowDefault);
105
124
  },
106
125
 
126
+ controlKey () {
127
+ return this.propsObj._key;
128
+ },
129
+ controlType () {
130
+ return this.propsObj._type;
131
+ },
132
+ controlName () {
133
+ return this.propsObj._name;
134
+ },
135
+ modKey () {
136
+ return this.propsObj.modKey;
137
+ },
138
+ screenKey () {
139
+ return this.propsObj.screenKey;
140
+ },
107
141
  commonPropsObj () {
108
142
  return {
109
143
  // isShare: false, // 是否是分享页在用
@@ -120,6 +154,8 @@ export default {
120
154
  _disabledOldDataRow: false, // 置灰老数据行包含删除
121
155
  _isImport: false, // 导入
122
156
  _isExport: false, // 导出
157
+ _isQuote: false, // 引用
158
+ _quoteListFields: [], // 引用列表的显示字段
123
159
  ...this.propsObj,
124
160
 
125
161
  _contentHeight: this.propsObj._contentHeight || 500 // 表格最大高度
@@ -161,6 +197,12 @@ export default {
161
197
  disabledOldDataRow () {
162
198
  return this.selfPropsObj._disabledOldDataRow;
163
199
  },
200
+ isQuote () {
201
+ return this.selfPropsObj._isQuote;
202
+ },
203
+ quoteListFields () {
204
+ return this.selfPropsObj._quoteListFields;
205
+ },
164
206
  isImport () {
165
207
  return this.selfPropsObj._isImport;
166
208
  },
@@ -170,16 +212,32 @@ export default {
170
212
 
171
213
  modalPropsObj () {
172
214
  return {
173
- title: this.propsObj._key,
215
+ title: this.controlName,
174
216
  fullscreen: true,
175
217
  showSlotClose: false,
176
218
  closable: true
177
219
  };
178
220
  },
221
+ quoteParams () {
222
+ return {
223
+ screenKey: this.screenKey,
224
+ fields: [...this.quoteListFields, this.controlKey, "createdAt"],
225
+ advSearch: {
226
+ logic: "and",
227
+ conditions: [
228
+ {
229
+ fieldKey: "_id",
230
+ fieldOperator: "ne",
231
+ fieldValue: [this.parentDataId]
232
+ }
233
+ ]
234
+ }
235
+ };
236
+ },
179
237
  importParams () {
180
238
  return {
181
- _key: this.propsObj._key,
182
- _id: this.parentObj._id
239
+ _id: this.parentDataId,
240
+ _key: this.controlKey
183
241
  };
184
242
  },
185
243
 
@@ -207,14 +265,15 @@ export default {
207
265
  undefined,
208
266
  this.canEdit
209
267
  ? [
210
- "canEnlarge",
268
+ ...(this.isQuote ? ["canQuote"] : []),
211
269
  ...(this.isImport ? ["canImport"] : []),
212
270
  ...(this.isExport ? ["canExport"] : []),
271
+ "canEnlarge",
213
272
  ...(this.disabledBtns ? ["changeVal"] : this.baseOperationBtns)
214
273
  ]
215
274
  : [
216
- "canEnlarge",
217
- ...(this.isExport ? ["canExport"] : [])
275
+ ...(this.isExport ? ["canExport"] : []),
276
+ "canEnlarge"
218
277
  ]
219
278
  );
220
279
  }
@@ -222,7 +281,7 @@ export default {
222
281
  watch: {
223
282
  isEnlarge (bool) {
224
283
  setTimeout(() => {
225
- this.enlargeFlag = bool;
284
+ this.isEnlargeFlag = bool;
226
285
  }, 0);
227
286
  }
228
287
  },
@@ -234,10 +293,17 @@ export default {
234
293
 
235
294
  return this.listData.every((row, rowIndex) => this.getRowRuleResult(row, rowIndex));
236
295
  },
296
+ // 重置
297
+ reset () {
298
+ this.initFlag = true;
299
+ this.showRuleMessage = false;
300
+ this.ruleRecordMap = {};
301
+ },
237
302
 
238
- // 打开全屏模态框
239
- clickEnlarge (operationItem) {
240
- this.isEnlarge = true;
303
+ // 点击引用
304
+ clickQuote () {
305
+ this.dshRenderName = "quoteModalRender";
306
+ this.showQuoteModal = true;
241
307
  },
242
308
  // 点击导入
243
309
  clickImport () {
@@ -247,10 +313,88 @@ export default {
247
313
  clickExport (operationItem) {
248
314
  this.handleExport(operationItem);
249
315
  },
316
+ // 打开全屏模态框
317
+ clickEnlarge (operationItem) {
318
+ this.isEnlarge = true;
319
+ },
320
+
321
+ // 引用模态框渲染函数
322
+ quoteModalRender (h, params) {
323
+ return this.showQuoteModal
324
+ ? h("quote-list-modal", {
325
+ props: {
326
+ value: this.showQuoteModal,
327
+ propsObj: this.propsObj,
328
+ listParams: this.quoteParams
329
+ },
330
+ on: {
331
+ input: bool => {
332
+ this.showQuoteModal = bool;
333
+ },
334
+ confirm: this.quoteCb
335
+ }
336
+ })
337
+ : undefined;
338
+ },
339
+ // 引用回调
340
+ quoteCb (dataObj) {
341
+ if (dataObj) {
342
+ const cb = () => {
343
+ this.$Message.success("引用成功!");
344
+ this.reset();
345
+ this.selfReset && this.selfReset();
250
346
 
251
- // 导入成功回调
347
+ if (["flatTable"].includes(this.controlType)) {
348
+ this.parentObj[this.controlKey] = {
349
+ ...dataObj[this.controlKey],
350
+ list: dataObj[this.controlKey].list.map(item => ({
351
+ ...item,
352
+ __readonly__: true
353
+ }))
354
+ };
355
+ } else if (["cascaderTable"].includes(this.controlType)) {
356
+ const transformData = (data = []) => {
357
+ const loop = (list = []) =>
358
+ list.map(item => ({
359
+ ...item,
360
+ children: item.children && item.children.length ? loop(item.children) : item.children,
361
+ __readonly__: true
362
+ }));
363
+
364
+ return loop(data);
365
+ };
366
+
367
+ this.parentObj[this.controlKey] = {
368
+ ...dataObj[this.controlKey],
369
+ tree: transformData(dataObj[this.controlKey].tree)
370
+ };
371
+ }
372
+
373
+ this.change("quote");
374
+ };
375
+
376
+ const isEmpty = this.$isEmptyData(dataObj[this.controlKey]) ||
377
+ (["flatTable"].includes(this.controlType)
378
+ ? !dataObj[this.controlKey].list || !dataObj[this.controlKey].list.length
379
+ : ["cascaderTable"].includes(this.controlType)
380
+ ? !dataObj[this.controlKey].tree || !dataObj[this.controlKey].tree.length
381
+ : false);
382
+ if (isEmpty) {
383
+ this.$Modal.confirm({
384
+ title: "提示",
385
+ content: "该数据下此内容为空,无法引用!",
386
+ onOk: () => { }
387
+ });
388
+ } else {
389
+ cb();
390
+ }
391
+ } else {
392
+ this.$Message.error("未选择引用数据!");
393
+ }
394
+ },
395
+ // 导入回调
252
396
  importCb (data) {
253
- this.parentObj[this.propsObj._key] = data;
397
+ this.parentObj[this.controlKey] = data;
254
398
  this.change("import");
255
399
  },
256
400
  // 接口 -导出
@@ -260,19 +404,16 @@ export default {
260
404
  this.$https({
261
405
  url: {
262
406
  module: "sheet",
263
- name: this.isDshFlatTable ? "exportFlatTableExcel" : "exportCascaderTableExcel",
264
- params: {
265
- modKey: this.propsObj.modKey
266
- }
407
+ name: ["flatTable"].includes(this.controlType) ? "exportFlatTableExcel" : "exportCascaderTableExcel"
267
408
  },
268
409
  params: {
269
- screenKey: this.propsObj.screenKey,
270
- _key: this.propsObj._key,
271
- _id: this.parentObj._id
410
+ screenKey: this.screenKey,
411
+ _id: this.parentObj._id,
412
+ _key: this.controlKey
272
413
  },
273
414
  callback: data => {
274
415
  this.getJobStatus(operationItem, data.jobId, data.excel_url);
275
- this.timer = setInterval(() => {
416
+ this.exportTimer = setInterval(() => {
276
417
  this.getJobStatus(operationItem, data.jobId, data.excel_url);
277
418
  }, 1000);
278
419
  }
@@ -290,7 +431,7 @@ export default {
290
431
  },
291
432
  callback: data => {
292
433
  operationItem.disabled = false;
293
- clearInterval(this.timer);
434
+ clearInterval(this.exportTimer);
294
435
 
295
436
  if (data.status === "completed") {
296
437
  window.location.href = data.url;
@@ -302,7 +443,7 @@ export default {
302
443
  },
303
444
  error: data => {
304
445
  operationItem.disabled = false;
305
- this.timer = null;
446
+ this.exportTimer = null;
306
447
  }
307
448
  });
308
449
  },
@@ -324,12 +465,12 @@ export default {
324
465
  }
325
466
  },
326
467
  getRowCanEdit (row) {
327
- return this.canEdit && ( // 是否是编辑状态
328
- this.disabledOldDataRow ? !!row.__isCreate__ : true); // 是否让老数据行置灰
468
+ return this.canEdit && // 是编辑状态
469
+ (this.disabledOldDataRow ? !row.__old__ : true) && // 老数据行不置灰/置灰时是新增数据
470
+ !row.__readonly__; // 不能为只读数据
329
471
  },
330
472
  getColCanEdit (col, row) {
331
- return (col.dependRowCanEdit ? row.canEdit !== false : true) && // 在老数据行里某些列不可编辑
332
- (row.__old__ ? col._oldCanEdit : true) && // 在老数据行不可编辑(除_oldCanEdit=true的外)
473
+ return (col._oldReadonly ? !row.__old__ : true) && // 老数据行里某些列不可编辑
333
474
  (["number"].includes(col._type) && ![undefined, null, "", "no"].includes(col._summaryType) ? row.isLeaf !== false : true) && // 级联表格 -“需要计的数字列 且 不是叶子行的”不可编辑(必须用isLeaf !== false判断,因为牵扯内部表格也在用)
334
475
  col._enterType !== "calculate" && // 计算的不可编辑
335
476
  col._readonly !== true; // 不能为只读
@@ -151,8 +151,9 @@
151
151
  }
152
152
  }
153
153
 
154
- &-show {
155
-
154
+ &-show { // 级联表格会生效 自己写的table
155
+ height: 40px;
156
+ padding: 4px 16px;
156
157
  }
157
158
  &-edit {
158
159
  padding: 4px 16px 12px 16px!important;
@@ -161,7 +162,7 @@
161
162
  &-visible {
162
163
  @keyframes slideDown {
163
164
  from {
164
- top: -40px;
165
+ top: -49px;
165
166
  opacity: 0.9;
166
167
  }
167
168
 
@@ -174,20 +175,7 @@
174
175
  animation: slideDown .2s linear;
175
176
  }
176
177
  &-hide {
177
- // @keyframes slideDown2 {
178
- // from {
179
- // top: 0px;
180
- // opacity: 1;
181
- // }
182
-
183
- // to {
184
- // top: -40px;
185
- // opacity: 0.9;
186
- // }
187
- // }
188
-
189
178
  display: none!important;
190
- // animation: slideDown2 .2s linear;
191
179
  }
192
180
 
193
181
  &-index {