bri-components 1.3.93 → 1.3.95

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.93",
3
+ "version": "1.3.95",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -348,13 +348,33 @@
348
348
  let rules = [];
349
349
  let ruleConfig = this.$getFieldRuleConfig(formItem);
350
350
 
351
+ // 数据格式校验
352
+ if (ruleConfig.type) {
353
+ rules.push({
354
+ message: `${formItem._name}数据格式有错!`,
355
+ trigger: "blur, change",
356
+ type: "string",
357
+ ...ruleConfig,
358
+ fields: ruleConfig.fields && Object.entries(ruleConfig.fields).reduce((obj, arr) => {
359
+ return {
360
+ ...obj,
361
+ [arr[0]]: {
362
+ ...arr[1],
363
+ required: false,
364
+ message: `${formItem._name}${arr[1].message || ""}`
365
+ }
366
+ };
367
+ }, ruleConfig.fields)
368
+ });
369
+ }
370
+
351
371
  // 必填校验
352
372
  if (formItem._required) {
353
373
  rules.push({
354
- required: true,
355
374
  message: `${formItem._name}为必填项!`,
356
375
  trigger: "blur, change",
357
376
  type: "string",
377
+ required: true,
358
378
  ...ruleConfig,
359
379
  fields: ruleConfig.fields && Object.entries(ruleConfig.fields).reduce((obj, arr) => {
360
380
  return {
@@ -384,7 +404,7 @@
384
404
  }
385
405
 
386
406
  // 对比校验(横向同类型字段对比)-暂时只number和date对比校验
387
- if (formItem._saveRuleConfigs) {
407
+ if (formItem._saveRuleConfigs && formItem._saveRuleConfigs.length) {
388
408
  const ruleObj = {
389
409
  message: `${formItem._name}对比不通过!`,
390
410
  trigger: "blur, change",
@@ -8,7 +8,7 @@
8
8
 
9
9
  <!-- 搜索条件 -->
10
10
  <dsh-render
11
- v-if="!this.isEnlarge"
11
+ v-if="!isEnlarge && showTopSearch"
12
12
  :render="topSearchRender"
13
13
  ></dsh-render>
14
14
 
@@ -29,6 +29,9 @@
29
29
  </div>
30
30
  </div>
31
31
 
32
+ <!-- 添加行 -->
33
+ <dsh-render :render="createBtnRender"></dsh-render>
34
+
32
35
  <!-- 各种模态框共用 -->
33
36
  <dsh-render :render="dshRender"></dsh-render>
34
37
 
@@ -71,12 +74,14 @@
71
74
 
72
75
  <script>
73
76
  import tableBaseMixin from "./mixins/tableBaseMixin.js";
77
+ import treeTableBaseMixin from "./mixins/treeTableBaseMixin.js";
74
78
  import DshCascaderTableMixin from "./mixins/DshCascaderTableMixin.js";
75
79
 
76
80
  export default {
77
81
  name: "DshCascaderTable",
78
82
  mixins: [
79
83
  tableBaseMixin,
84
+ treeTableBaseMixin,
80
85
  DshCascaderTableMixin
81
86
  ],
82
87
  components: {},
@@ -5,7 +5,7 @@
5
5
 
6
6
  <!-- 搜索条件 -->
7
7
  <dsh-render
8
- v-if="!this.isEnlarge"
8
+ v-if="!isEnlarge && showTopSearch"
9
9
  :render="topSearchRender"
10
10
  ></dsh-render>
11
11
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  <!-- 搜索条件 -->
7
7
  <dsh-render
8
- v-if="!this.isEnlarge"
8
+ v-if="!isEnlarge && showTopSearch"
9
9
  :render="topSearchRender"
10
10
  ></dsh-render>
11
11
 
@@ -86,12 +86,14 @@
86
86
 
87
87
  <script>
88
88
  import tableBaseMixin from "./mixins/tableBaseMixin.js";
89
+ import treeTableBaseMixin from "./mixins/treeTableBaseMixin.js";
89
90
  import DshTreeTableMixin from "./mixins/DshTreeTableMixin.js";
90
91
 
91
92
  export default {
92
93
  name: "DshTreeTable",
93
94
  mixins: [
94
95
  tableBaseMixin,
96
+ treeTableBaseMixin,
95
97
  DshTreeTableMixin
96
98
  ],
97
99
  components: {},
@@ -24,23 +24,18 @@ export default {
24
24
  boxWidth: 0,
25
25
 
26
26
  baseOperationMap: {
27
- clickTh: {
28
- name: "点击列的表头",
29
- type: "clickTh",
30
- event: "clickTh"
31
- },
32
- createCol: {
27
+ canCreateCol: {
33
28
  name: "添加一列",
34
- type: "createCol",
29
+ type: "canCreateCol",
35
30
  icon: "md-add",
36
- event: "createCol"
31
+ event: "clickCreateCol"
37
32
  },
38
- deleteCol: {
33
+ canDeleteCol: {
39
34
  name: "删除该列",
40
- type: "deleteCol",
35
+ type: "canDeleteCol",
41
36
  icon: "md-trash",
42
37
  color: "red",
43
- event: "deleteCol"
38
+ event: "clickDeleteCol"
44
39
  },
45
40
 
46
41
  clickNode: {
@@ -57,65 +52,25 @@ export default {
57
52
  name: "改变节点值",
58
53
  type: "changeNode",
59
54
  event: "changeNode"
60
- },
61
-
62
- canCreateBrother: {
63
- name: "添加同级节点",
64
- type: "canCreateBrother",
65
- icon: "md-add",
66
- event: "clickCreate"
67
- },
68
- canCreateChildNode: {
69
- name: "添加子节点",
70
- type: "canCreateChildNode",
71
- icon: "md-add",
72
- event: "clickCreateChild"
73
- },
74
- deleteSelfAndChildNodes: {
75
- name: "删除该节点",
76
- type: "deleteSelfAndChildNodes",
77
- icon: "md-trash",
78
- color: "red",
79
- divided: true,
80
- event: "clickDelete"
81
- },
82
- deleteChildNodes: {
83
- name: "删除所有子节点",
84
- type: "deleteChildNodes",
85
- icon: "md-trash",
86
- color: "red",
87
- event: "clickDeleteChilds"
88
- },
89
- clearNode: {
90
- name: "清除该节点内容",
91
- type: "clearNode",
92
- icon: "md-trash",
93
- divided: true,
94
- event: "clickClearNode"
95
- },
96
- clearChildNodes: {
97
- name: "清除所有子节点内容",
98
- type: "clearChildNodes",
99
- icon: "md-trash",
100
- event: "clickClearChildNodes"
101
55
  }
56
+
57
+ // canClearNode: {
58
+ // name: "清除内容",
59
+ // type: "canClearNode",
60
+ // icon: "md-trash",
61
+ // divided: true,
62
+ // event: "clickClearNode"
63
+ // },
64
+ // canClearChildNodes: {
65
+ // name: "清除所有下级内容",
66
+ // type: "canClearChildNodes",
67
+ // icon: "md-trash",
68
+ // event: "clickClearChildNodes"
69
+ // }
102
70
  }
103
71
  };
104
72
  },
105
73
  computed: {
106
- selfPropsObj () {
107
- return {
108
- _treeForm: [],
109
- ...this.commonPropsObj,
110
-
111
- _maxLevel: this.commonPropsObj._maxLevel || 3, // 最大级数
112
- _contentHeight: this.propsObj._contentHeight || 400 // 表格最大高度
113
- };
114
- },
115
- maxLevel () {
116
- return this.selfPropsObj._maxLevel;
117
- },
118
-
119
74
  allTreeData () {
120
75
  // console.log("allTreeData");
121
76
  return this.getCalcuedTree(this.data, this.treeColumns, this.selfColumns);
@@ -156,12 +111,8 @@ export default {
156
111
  },
157
112
 
158
113
  /* ----------- 操作 ---------- */
159
- // 表头操作 -点击
160
- clickTh (operationItem, col, colIndex) {
161
- this.$emit("clickTh", col, colIndex);
162
- },
163
114
  // 表头操作 -树形表头-添加一列
164
- createCol (operationItem, col, colIndex) {
115
+ clickCreateCol (operationItem, col, colIndex) {
165
116
  if (col.colType === "tree" && col.level === this.treeColumns.length) {
166
117
  this.treeColumns.push({
167
118
  _id: this.$ObjectID().str,
@@ -178,7 +129,7 @@ export default {
178
129
  }
179
130
  },
180
131
  // 表头操作 -树形表头-删除一列
181
- deleteCol (operationItem, col, colIndex) {
132
+ clickDeleteCol (operationItem, col, colIndex) {
182
133
  if (col.colType === "tree" && col.canDelete !== false) {
183
134
  this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
184
135
  this.treeColumns.pop();
@@ -214,59 +165,18 @@ export default {
214
165
  changeNode (operationItem, col, row, rowIndex) {
215
166
  this.change("changeNode", col, row, rowIndex);
216
167
  },
168
+ // // 节点操作 -清除该节点内容
169
+ // clickClearNode (operationItem, row, rowIndex, col) {
170
+ // row.name = "";
217
171
 
218
- // 节点操作 -插入一行
219
- clickCreate (operationItem, row, rowIndex, col) {
220
- const nodeData = this.getNodeData(col, row, rowIndex);
221
- const newNode = this.getNewNode(nodeData.level, nodeData.brotherList);
222
- nodeData.brotherList.splice(nodeData.index + 1, 0, newNode);
172
+ // this.change("clearNode", null, row, rowIndex);
173
+ // },
174
+ // // 节点操作 -清除所有子节点内容
175
+ // clickClearChildNodes (operationItem, row, rowIndex, col) {
176
+ // this.$clearPropertyValToLeaf(row.children);
223
177
 
224
- this.change("createRow", col, row, rowIndex);
225
- },
226
- // 节点操作 -添加子行
227
- clickCreateChild (operationItem, row, rowIndex, col) {
228
- const nodeData = this.getNodeData(col, row, rowIndex);
229
- const newNode = this.getNewNode(nodeData.level + 1, nodeData.childList);
230
- nodeData.childList.splice(nodeData.childList.length, 0, newNode);
231
-
232
- this.change("createChildRow", col, row, rowIndex);
233
- },
234
- // 节点操作 -删除该行
235
- clickDelete (operationItem, row, rowIndex, col) {
236
- const nodeData = this.getNodeData(col, row, rowIndex);
237
- nodeData.brotherList.splice(nodeData.index, 1);
238
- // 此处应该判断子节点是否是最后一个,是的话就要添加一个一直到叶子节点,不过现在只需要添加一个子节点,transforBriTreeData会捎带着处理了
239
- if (!nodeData.brotherList.length) {
240
- const newNode = this.getNewNode(nodeData.level, nodeData.brotherList);
241
- nodeData.brotherList.push(newNode);
242
- }
243
-
244
- this.change("deleteRow", col, row, rowIndex);
245
- },
246
- // 节点操作 -删除所有子行
247
- clickDeleteChilds (operationItem, row, rowIndex, col) {
248
- const nodeData = this.getNodeData(col, row, rowIndex);
249
- nodeData.childList.splice(0);
250
- // 删除完应该添加一个子节点一直到叶子节点,不过现在只需要添加一个子节点,transforBriTreeData会捎带着处理了
251
- const newNode = this.getNewNode(nodeData.level + 1, nodeData.childList);
252
- nodeData.childList.push(newNode);
253
-
254
- this.change("deleteChildRows", col, row, rowIndex);
255
- },
256
- // 节点操作 -清除该节点内容
257
- clickClearNode (operationItem, row, rowIndex, col) {
258
- const nodeData = this.getNodeData(col, row, rowIndex);
259
- nodeData.dataObj.name = "";
260
-
261
- this.change("clearNode", col, row, rowIndex);
262
- },
263
- // 节点操作 -清除所有子节点内容
264
- clickClearChildNodes (operationItem, row, rowIndex, col) {
265
- let nodeData = this.getNodeData(col, row, rowIndex);
266
- this.$clearPropertyValToLeaf(nodeData.childList);
267
-
268
- this.change("clearChildNodes", col, row, rowIndex);
269
- },
178
+ // this.change("clearChildNodes", null, row, rowIndex);
179
+ // },
270
180
  change (eventType, col, row, rowIndex, ...params) {
271
181
  this.$emit("change", this.tableDataObj, eventType, col, row, rowIndex, ...params);
272
182
  },
@@ -299,12 +209,7 @@ export default {
299
209
  return h("th", {
300
210
  key: column._id,
301
211
  class: "bri-table-th",
302
- style: this.getThStyle(column, "th"),
303
- on: {
304
- click: () => {
305
- this.$dispatchEvent(this.operationMap.clickTh, column, colIndex);
306
- }
307
- }
212
+ style: this.getThStyle(column, "th")
308
213
  }, [
309
214
  // 表头单元格
310
215
  this.getThRender(column, colIndex)(h)
@@ -474,7 +379,15 @@ export default {
474
379
  "td",
475
380
  {
476
381
  class: this.tablePropsObj.cellStyleOption.bodyCellClass({ row, rowIndex, column }),
477
- style: this.getTdStyle(column, row, rowIndex)
382
+ style: this.getTdStyle(column, row, rowIndex),
383
+ on: {
384
+ mouseenter: (event) => {
385
+ this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
386
+ },
387
+ mouseleave: (event) => {
388
+ this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
389
+ }
390
+ }
478
391
  },
479
392
  column
480
393
  ? column.renderBodyCell({ row, rowIndex, column }, h)
@@ -484,9 +397,18 @@ export default {
484
397
  },
485
398
  // 下拉渲染函数
486
399
  getDropdownRender (h, position = "th", column, colIndex, row, rowIndex) {
487
- const list = position === "th"
488
- ? this.$getOperationList(this.getTreeThBtns(column, colIndex))
489
- : this.$getOperationList(this.getTreeTdBtns(column, row, rowIndex));
400
+ const list = this.$getOperationList(
401
+ position === "th"
402
+ ? [
403
+ ...(column.level < this.maxLevel ? ["canCreateCol"] : []), // 限制最大添加到几级
404
+ ...(column.level > 1 && column.canDelete === true ? ["canDeleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
405
+ ]
406
+ : this.getRowIsDftDisabled(row)
407
+ ? []
408
+ : row.isLeaf === true
409
+ ? ["canCreate", "canDelete"]
410
+ : ["canCreate", "canCreateChild", "canDelete", "canDeleteChilds"]
411
+ );
490
412
 
491
413
  return !this.isSearching &&
492
414
  list.length &&
@@ -567,13 +489,6 @@ export default {
567
489
  ...selfStyle
568
490
  };
569
491
  },
570
- // 表头 -树节点表头-获取下拉操作
571
- getTreeThBtns (col) {
572
- return [
573
- ...(col.level <= this.maxLevel ? ["createCol"] : []), // 限制最大添加到几级
574
- ...(col.level > 1 && col.canDelete === true ? ["deleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
575
- ];
576
- },
577
492
 
578
493
  // 单元格 -获取样式
579
494
  getTdStyle (col, row, rowIndex) {
@@ -620,41 +535,6 @@ export default {
620
535
  : "未选择算法";
621
536
  }
622
537
  },
623
- // 单元格 -树节点单元格-获取下拉操作
624
- getTreeTdBtns (col, row, rowIndex) {
625
- return row.children.length === 0
626
- ? ["canCreateBrother", "deleteSelfAndChildNodes", "clearNode"]
627
- : ["canCreateBrother", "canCreateChildNode", "deleteSelfAndChildNodes", "deleteChildNodes", "clearNode", "clearChildNodes"];
628
- },
629
- // 单元格 -普通单元格-获取节点系列数据
630
- getNodeData (col, row, rowIndex) {
631
- const parentRow = this.getParentRow(row, this.data);
632
-
633
- return {
634
- level: col.level,
635
- dataObj: row,
636
- childList: row.children,
637
- brotherList: parentRow.children,
638
- index: parentRow.children.findIndex(childRowItem => childRowItem._id === row._id)
639
- };
640
- },
641
- // 单元格 -普通单元格-新增节点数据
642
- getNewNode (level, list) {
643
- return {
644
- ...this.$deepCopy(this.selfRowDefault),
645
- _id: this.$ObjectID().str,
646
- name: `${this.$numToChinese(level)}级节点${list.length + 1}`,
647
- level: level,
648
- isLeaf: true,
649
- children: [],
650
- // __old__: false,
651
- __isDefault__: this.controlKey === "_default",
652
- __isRendered__: true,
653
- __isShow__: true,
654
- __isTmpShow__: true,
655
- __isSearchShow__: false
656
- };
657
- },
658
538
 
659
539
  /* ----------- 工具方法 ---------- */
660
540
  // 合并表头
@@ -739,7 +619,7 @@ export default {
739
619
  // 非最后一列的 新增的非根节点(此时是新增一列或新增非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点
740
620
  // 特别提示:新增的是根节点行,不会走此处代码
741
621
  else {
742
- const newNode = this.getNewNode(rowItem.level + 1, rowItem.children);
622
+ const newNode = this.getNewRowData(rowItem.level + 1, rowItem.children);
743
623
  subForm.forEach(subFormItem => {
744
624
  // 用$set也可以
745
625
  newNode[subFormItem._key] = rowItem[subFormItem._key];
@@ -77,34 +77,35 @@ export default {
77
77
  methods: {
78
78
  // 点击 -添加行
79
79
  clickCreate (operationItem, row, rowIndex, col) {
80
- // 处理单元格合并相关
81
- let mergeRowData = {};
82
- if (col && col._mergeRow) {
83
- const newList = this.showListData.slice(rowIndex);
84
- const newIndex = newList.findIndex(rowItem => row[col._key] !== rowItem[col._key]);
85
- row = newList[newIndex - 1];
80
+ const list = this.data;
81
+ const newRow = this.getNewRowData();
86
82
 
87
- // 当前列是合并列,则该列之前的合并列,要复制这一行对应列的值;当前列是普通列,则所有的合并列不用处理
88
- const curIndex = this.mergeRowColumns.findIndex(column => col._key === column._key);
89
- mergeRowData = this.mergeRowColumns.reduce((obj, column, colIndex) => {
90
- return colIndex < curIndex
91
- ? Object.assign(obj, { [column._key]: row[column._key] })
92
- : obj;
93
- }, {});
94
- }
83
+ // 处理单元格合并相关(当前列是合并列,则该列之前的合并列,要复制这一行对应列的值;当前列是普通列,按最后合并列的操作处理)
84
+ if (col) {
85
+ if (col._mergeRow === true) {
86
+ const newList = this.allListData.slice(rowIndex); // 从该行开始截取
87
+ const nextRowIndex = newList.findIndex(rowItem => rowItem[col._key] !== row[col._key]); // 寻找该单元格值开始不一样的行(特殊情况是最后一行,nextRowIndex为-1)
88
+ row = nextRowIndex < 0 ? newList[newList.length - 1] : newList[nextRowIndex - 1]; // 取该单元格值一样的最后一行
95
89
 
96
- const newRow = {
97
- ...this.$deepCopy(this.selfRowDefault),
98
- ...this.$deepCopy(mergeRowData),
99
- _id: this.$ObjectID().str,
100
- // __old__: false,
101
- __isDefault__: this.controlKey === "_default",
102
- __isRendered__: true,
103
- __isShow__: true,
104
- __isTmpShow__: true,
105
- __isSearchShow__: false
106
- };
107
- const list = this.data;
90
+ const colIndex = this.mergeRowColumns.findIndex(column => column._key === col._key);
91
+ this.mergeRowColumns.reduce((obj, column, columnIndex) => {
92
+ return columnIndex < colIndex
93
+ ? Object.assign(obj, {
94
+ [column._key]: this.$deepCopy(row[column._key])
95
+ })
96
+ : obj;
97
+ }, newRow);
98
+ }
99
+ else {
100
+ const colIndex = this.selfColumns.findIndex(column => column._key === col._key);
101
+ const mergeRowColumns = this.selfColumns.filter((column, columnIndex) => columnIndex < colIndex && column._mergeRow === true);
102
+ mergeRowColumns.slice(0, mergeRowColumns.length - 1).reduce((obj, column) => {
103
+ return Object.assign(obj, {
104
+ [column._key]: this.$deepCopy(row[column._key])
105
+ });
106
+ }, newRow);
107
+ }
108
+ }
108
109
  const newRowIndex = row
109
110
  ? list.findIndex(rowItem => rowItem._id === row._id) + 1
110
111
  : list.length;
@@ -1,42 +1,11 @@
1
- import { resourceData } from "bri-datas";
2
-
3
1
  export default {
4
2
  mixins: [],
5
3
  components: {},
6
4
  props: {},
7
5
  data () {
8
- return {
9
- searchMode: "flat" // "flat", "tree"
10
- };
6
+ return {};
11
7
  },
12
8
  computed: {
13
- selfColumns () {
14
- return this.columns.map(column => {
15
- // 层级表格类型,level字段的进行特殊处理(_treeForm加工成_data)
16
- return column._key === "level"
17
- ? {
18
- ...column,
19
- _data: this.selfPropsObj._treeForm.map((treeFormItem, treeFormIndex) => ({
20
- name: treeFormItem._name,
21
- _key: (treeFormIndex + 1),
22
- color: Object.keys(resourceData.colorMap)[treeFormIndex + 1]
23
- }))
24
- }
25
- : column;
26
- });
27
- },
28
- selfPropsObj () {
29
- return {
30
- _treeForm: [],
31
- ...this.commonPropsObj,
32
-
33
- _maxLevel: this.commonPropsObj._maxLevel || 3 // 最大级数
34
- };
35
- },
36
- maxLevel () {
37
- return this.selfPropsObj._maxLevel;
38
- },
39
-
40
9
  allTreeData () {
41
10
  return this.getCalcuedTree(this.data, this.selfColumns);
42
11
  },
@@ -148,79 +117,6 @@ export default {
148
117
  },
149
118
  created () { },
150
119
  methods: {
151
- // 本身的初始化
152
- selfReset () {
153
- this.searchMode = "flat";
154
- this.dftAdvSearch = {
155
- logic: "and",
156
- conditions: []
157
- };
158
- },
159
-
160
- // 点击 -添加一行
161
- clickCreate (operationItem, row, rowIndex, col) {
162
- const newRow = {
163
- ...this.$deepCopy(this.selfRowDefault),
164
- _id: this.$ObjectID().str,
165
- level: row ? row.level : 1,
166
- isLeaf: true,
167
- children: [],
168
- // __old__: false,
169
- __isDefault__: this.controlKey === "_default",
170
- __isRendered__: true,
171
- __isShow__: true,
172
- __isTmpShow__: true,
173
- __isSearchShow__: false,
174
- __isExpand__: false
175
- };
176
- const list = row
177
- ? this.getParentRow(row, this.data).children
178
- : this.data;
179
- const newRowIndex = row
180
- ? list.findIndex(rowItem => rowItem._id === row._id) + 1
181
- : list.length;
182
- list.splice(newRowIndex, 0, newRow);
183
-
184
- this.change("createRow", null, newRow, newRowIndex);
185
- },
186
- // 点击 -添加子行
187
- clickCreateChild (operationItem, row, rowIndex, col) {
188
- const newRow = {
189
- ...this.$deepCopy(this.selfRowDefault),
190
- _id: this.$ObjectID().str,
191
- level: row.level + 1,
192
- isLeaf: true,
193
- children: [],
194
- // __old__: false,
195
- __isDefault__: this.controlKey === "_default",
196
- __isRendered__: true,
197
- __isShow__: true,
198
- __isTmpShow__: true,
199
- __isSearchShow__: false,
200
- __isExpand__: false
201
- };
202
- const list = row.children;
203
- const newRowIndex = list.length;
204
- list.splice(newRowIndex, 0, newRow);
205
- // 展开子级
206
- this.toggleExpand(row, true);
207
-
208
- this.change("createChildRow", null, newRow, newRowIndex);
209
- },
210
- // 点击 -删除行
211
- clickDelete (operationItem, row, rowIndex) {
212
- this.$Modal.confirm({
213
- title: "警告",
214
- content: "确定删除吗?",
215
- onOk: () => {
216
- const parentRow = this.getParentRow(row, this.data);
217
- const index = parentRow.children.findIndex(childRowItem => childRowItem._id === row._id);
218
- parentRow.children.splice(index, 1);
219
-
220
- this.change("deleteRow", null, row, rowIndex);
221
- }
222
- });
223
- },
224
120
  change (eventType, col, row, rowIndex, ...params) {
225
121
  this.$emit("change", { tree: this.data, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
226
122
  },
@@ -308,37 +204,6 @@ export default {
308
204
 
309
205
  this.initFlag = false;
310
206
  return treeData;
311
- },
312
- // 展开/隐藏节点
313
- toggleExpand (row, bool = true) {
314
- this.isExpandAction = true;
315
- this.$set(row, "__isExpand__", bool);
316
-
317
- this.toggleDescendantsShow(row, bool);
318
- },
319
- // 切换子孙后代的显示/隐藏
320
- toggleDescendantsShow (row, bool) {
321
- const loop = (row, isFirstSon) => {
322
- if (row.children && row.children.length) {
323
- row.children.forEach(subRow => {
324
- if (isFirstSon) {
325
- this.$set(subRow, "__isRendered__", true);
326
- this.$set(subRow, "__isShow__", bool);
327
- this.$set(subRow, "__isTmpShow__", bool);
328
- } else {
329
- if (bool) {
330
- this.$set(subRow, "__isShow__", subRow.__isTmpShow__);
331
- } else {
332
- this.$set(subRow, "__isShow__", false);
333
- }
334
- }
335
-
336
- loop(subRow);
337
- });
338
- }
339
- };
340
-
341
- loop(row, true);
342
207
  }
343
208
  }
344
209
  };
@@ -63,19 +63,16 @@ export default {
63
63
  return {
64
64
  widthMap: this.$getModFieldPropertyMap("width"),
65
65
  initDftValMap: this.$getModFieldPropertyMap("initDefaultVal"),
66
-
67
66
  saveProperties: ["__readonly__", "__isDefault__", "__old__", "__isQuote__"],
68
- resetProperties: ["__treeIndex__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"],
67
+ resetProperties: ["__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__", "__isExpand__", "__treeIndex__"],
68
+
69
69
  initFlag: true,
70
70
  showRuleMessage: false, // 进行全体校验
71
71
  ruleRecordMap: {}, // 单元格是否发生校验的记录映射
72
72
  hoverRecordMap: {},
73
73
  isExpandAction: false,
74
74
 
75
- dftAdvSearch: {
76
- logic: "and",
77
- conditions: []
78
- },
75
+ showTopSearch: true,
79
76
  selfLogicPropsObj: {
80
77
  _name: "逻辑",
81
78
  _key: "logic",
@@ -86,6 +83,10 @@ export default {
86
83
  { _key: "or", name: "或" }
87
84
  ]
88
85
  },
86
+ dftAdvSearch: {
87
+ logic: "and",
88
+ conditions: []
89
+ },
89
90
 
90
91
  dshRenderName: undefined,
91
92
  hideStatus: true,
@@ -169,6 +170,16 @@ export default {
169
170
  disabled: false,
170
171
  event: "clickDelete"
171
172
  },
173
+ canDeleteChilds: {
174
+ name: "删除所有子级",
175
+ type: "canDeleteChilds",
176
+ btnType: "errorText",
177
+ icon: "ios-trash-outline",
178
+ size: "small",
179
+ color: "#E83636",
180
+ disabled: false,
181
+ event: "clickDeleteChilds"
182
+ },
172
183
  changeVal: {
173
184
  name: "改变输入框值",
174
185
  type: "changeVal",
@@ -209,7 +220,7 @@ export default {
209
220
  return this.columns;
210
221
  },
211
222
  mergeRowColumns () {
212
- return this.columns.filter(column => column._mergeRow === true);
223
+ return this.selfColumns.filter(column => column._mergeRow === true);
213
224
  },
214
225
  filterColumns () {
215
226
  return this.selfColumns.filter(col => this.$isAdvRelyShow(col, this.allListData, this.parentObj, true));
@@ -624,7 +635,7 @@ export default {
624
635
  : undefined,
625
636
 
626
637
  // 添加符
627
- ...this.createIconRender(h, { row, rowIndex, column })
638
+ ...this.createIconRender(h, { row, rowIndex, column }, 12)
628
639
  ];
629
640
  },
630
641
  ...colItem
@@ -809,7 +820,13 @@ export default {
809
820
  this.initFlag = true;
810
821
  this.showRuleMessage = false;
811
822
  this.ruleRecordMap = {};
823
+ this.hoverRecordMap = {};
812
824
  this.isExpandAction = false;
825
+ this.dftAdvSearch = {
826
+ logic: "and",
827
+ conditions: []
828
+ };
829
+ this.hideStatus = true;
813
830
  this.selfReset && this.selfReset();
814
831
  },
815
832
  // 共外部使用
@@ -879,10 +896,10 @@ export default {
879
896
  if (dataObj) {
880
897
  const fieldVal = dataObj[this.controlKey];
881
898
  const isEmpty = this.$isEmptyData(fieldVal) || (
882
- ["flatTable"].includes(this.controlType)
883
- ? !fieldVal.list || !fieldVal.list.length
884
- : ["cascaderTable"].includes(this.controlType)
885
- ? !fieldVal.tree || !fieldVal.tree.length
899
+ ["cascaderTable"].includes(this.controlType)
900
+ ? !fieldVal.tree || !fieldVal.tree.length
901
+ : ["flatTable"].includes(this.controlType)
902
+ ? !fieldVal.list || !fieldVal.list.length
886
903
  : false
887
904
  );
888
905
 
@@ -894,17 +911,7 @@ export default {
894
911
  });
895
912
  }
896
913
  else {
897
- if (["flatTable"].includes(this.controlType)) {
898
- this.parentObj[this.controlKey] = {
899
- ...fieldVal,
900
- list: fieldVal.list.map(item => ({
901
- ...item,
902
- __isQuote__: true,
903
- __old__: false
904
- }))
905
- };
906
- }
907
- else if (["cascaderTable"].includes(this.controlType)) {
914
+ if (["cascaderTable"].includes(this.controlType)) {
908
915
  const transformData = (list = []) => {
909
916
  const loop = (list = []) =>
910
917
  list.map(item => ({
@@ -922,9 +929,24 @@ export default {
922
929
  tree: transformData(fieldVal.tree)
923
930
  };
924
931
  }
932
+ else if (["flatTable"].includes(this.controlType)) {
933
+ this.parentObj[this.controlKey] = {
934
+ ...fieldVal,
935
+ list: fieldVal.list.map(item => ({
936
+ ...item,
937
+ __isQuote__: true,
938
+ __old__: false
939
+ }))
940
+ };
941
+ }
925
942
 
926
943
  this.$Message.success("引用成功!");
927
944
  this.reset();
945
+ this.showTopSearch = false;
946
+ this.$nextTick(() => {
947
+ this.showTopSearch = true;
948
+ });
949
+
928
950
  this.change("quote");
929
951
  }
930
952
  } else {
@@ -1130,7 +1152,7 @@ export default {
1130
1152
  })
1131
1153
  : undefined;
1132
1154
  },
1133
- createIconRender (h, { row, rowIndex, column }) {
1155
+ createIconRender (h, { row, rowIndex, column }, iconSize = 14) {
1134
1156
  return [
1135
1157
  // 插入一行添加符
1136
1158
  (this.operationMap.canCreate && this.operationMap.canCreate.disabled !== true) &&
@@ -1142,11 +1164,11 @@ export default {
1142
1164
  position: "absolute",
1143
1165
  bottom: "0px",
1144
1166
  right: "0px",
1145
- width: "16px",
1146
- height: "16px",
1167
+ width: `${iconSize + 2}px`,
1168
+ height: `${iconSize + 2}px`,
1147
1169
  border: `1px solid ${this.appColor}`,
1148
1170
  backgroundColor: "#ffffff",
1149
- lineHeight: "12px",
1171
+ lineHeight: `${iconSize - 2}px`,
1150
1172
  cursor: "pointer",
1151
1173
  verticalAlign: "middle",
1152
1174
  transition: "color .2s ease-in-out,border-color .2s ease-in-out"
@@ -1166,7 +1188,7 @@ export default {
1166
1188
  },
1167
1189
  props: {
1168
1190
  type: this.operationMap.canCreate.icon,
1169
- size: "14"
1191
+ size: iconSize
1170
1192
  },
1171
1193
  on: {
1172
1194
  click: () => {
@@ -1179,7 +1201,7 @@ export default {
1179
1201
  : h("span", ""),
1180
1202
 
1181
1203
  // 添加一行下级添加符
1182
- ["cascaderTable"].includes(this.controlType) &&
1204
+ ["treeTable"].includes(this.inTableType) &&
1183
1205
  (this.operationMap.canCreateChild && this.operationMap.canCreateChild.disabled !== true) &&
1184
1206
  !this.isSearching &&
1185
1207
  (column._key === "__index__" ? !this.showCreateBtnColKeys.length : this.showCreateBtnColKeys.includes(column._key)) &&
@@ -1189,13 +1211,13 @@ export default {
1189
1211
  style: {
1190
1212
  position: "absolute",
1191
1213
  bottom: "0px",
1192
- right: "17px",
1214
+ right: `${iconSize + 3}px`,
1193
1215
  display: "inline-block",
1194
- width: "16px",
1195
- height: " 16px",
1216
+ width: `${iconSize + 2}px`,
1217
+ height: `${iconSize + 2}px`,
1196
1218
  border: `1px solid ${this.appColor}`,
1197
1219
  backgroundColor: "#ffffff",
1198
- lineHeight: "12px",
1220
+ lineHeight: `${iconSize - 2}px`,
1199
1221
  cursor: "pointer",
1200
1222
  verticalAlign: "middle",
1201
1223
  transition: "color .2s ease-in-out,border-color .2s ease-in-out"
@@ -1215,7 +1237,7 @@ export default {
1215
1237
  },
1216
1238
  props: {
1217
1239
  type: this.operationMap.canCreateChild.icon,
1218
- size: "14"
1240
+ size: iconSize
1219
1241
  },
1220
1242
  on: {
1221
1243
  click: () => {
@@ -1230,6 +1252,44 @@ export default {
1230
1252
  },
1231
1253
 
1232
1254
  /* ----------- 方法 ---------- */
1255
+ // 生成新的一行数据
1256
+ getNewRowData (level, list) {
1257
+ if (["cascaderTable"].includes(this.controlType)) {
1258
+ return {
1259
+ ...this.$deepCopy(this.selfRowDefault),
1260
+ _id: this.$ObjectID().str,
1261
+ level: level,
1262
+ isLeaf: true,
1263
+ children: [],
1264
+ ...(
1265
+ ["treeTable"].includes(this.inTableType)
1266
+ ? {}
1267
+ : {
1268
+ name: `${this.$numToChinese(level)}级节点${list.length + 1}`
1269
+ }
1270
+ ),
1271
+ // __old__: false,
1272
+ __isDefault__: this.controlKey === "_default",
1273
+ __isRendered__: true,
1274
+ __isShow__: true,
1275
+ __isTmpShow__: true,
1276
+ __isSearchShow__: false,
1277
+ __isExpand__: false
1278
+ };
1279
+ } else {
1280
+ return {
1281
+ ...this.$deepCopy(this.selfRowDefault),
1282
+ _id: this.$ObjectID().str,
1283
+ // __old__: false,
1284
+ __isDefault__: this.controlKey === "_default",
1285
+ __isRendered__: true,
1286
+ __isShow__: true,
1287
+ __isTmpShow__: true,
1288
+ __isSearchShow__: false,
1289
+ __isExpand__: false
1290
+ };
1291
+ }
1292
+ },
1233
1293
  // 整行校验结果
1234
1294
  getRowRuleResult (row, rowIndex) {
1235
1295
  return this.filterColumns.every(column => this.getColRuleResult(column, row, rowIndex).bool);
@@ -1392,8 +1452,8 @@ export default {
1392
1452
  delete row[property];
1393
1453
  });
1394
1454
  if (["treeTable"].includes(this.inTableType)) {
1395
- // row.__isExpand__ = false;
1396
1455
  // row.__isSearchShow__ = false;
1456
+ // row.__isExpand__ = false;
1397
1457
  // 第一级的需要显示出来
1398
1458
  if (row.level == 1) {
1399
1459
  row.__isRendered__ = true;
@@ -1409,6 +1469,7 @@ export default {
1409
1469
  row.__isShow__ = true;
1410
1470
  row.__isTmpShow__ = true;
1411
1471
  row.__isSearchShow__ = false;
1472
+ row.__isExpand__ = false;
1412
1473
  }
1413
1474
  }
1414
1475
  }
@@ -0,0 +1,132 @@
1
+ import { resourceData } from "bri-datas";
2
+
3
+ export default {
4
+ mixins: [],
5
+ components: {},
6
+ props: {},
7
+ data () {
8
+ return {
9
+ searchMode: "flat" // "flat", "tree"
10
+ };
11
+ },
12
+ computed: {
13
+ selfPropsObj () {
14
+ return {
15
+ _treeForm: [],
16
+ ...this.commonPropsObj,
17
+
18
+ _maxLevel: this.commonPropsObj._maxLevel || 3 // 最大级数
19
+ };
20
+ },
21
+ maxLevel () {
22
+ return this.selfPropsObj._maxLevel;
23
+ },
24
+
25
+ selfColumns () {
26
+ return this.columns.map(column => {
27
+ // 层级表格类型,level字段的进行特殊处理(_treeForm加工成_data)
28
+ return column._key === "level"
29
+ ? {
30
+ ...column,
31
+ _data: this.selfPropsObj._treeForm.map((treeFormItem, treeFormIndex) => ({
32
+ name: treeFormItem._name,
33
+ _key: (treeFormIndex + 1),
34
+ color: Object.keys(resourceData.colorMap)[treeFormIndex + 1]
35
+ }))
36
+ }
37
+ : column;
38
+ });
39
+ }
40
+ },
41
+ created () { },
42
+ methods: {
43
+ // 本身的初始化
44
+ selfReset () {
45
+ this.searchMode = "flat";
46
+ },
47
+
48
+ // 节点操作 -添加一行
49
+ clickCreate (operationItem, row, rowIndex, col) {
50
+ const list = row
51
+ ? this.getParentRow(row, this.data).children
52
+ : this.data;
53
+ const newRow = this.getNewRowData(row ? row.level : 1, list);
54
+ const newRowIndex = row
55
+ ? list.findIndex(rowItem => rowItem._id === row._id) + 1
56
+ : list.length;
57
+ list.splice(newRowIndex, 0, newRow);
58
+
59
+ this.change("createRow", null, newRow, newRowIndex);
60
+ },
61
+ // 节点操作 -添加子行
62
+ clickCreateChild (operationItem, row, rowIndex, col) {
63
+ const list = row.children;
64
+ const newRow = this.getNewRowData(row.level + 1, list);
65
+ const newRowIndex = list.length;
66
+ list.splice(newRowIndex, 0, newRow);
67
+
68
+ // 展开子级
69
+ this.toggleExpand(row, true);
70
+
71
+ this.change("createChildRow", null, newRow, newRowIndex);
72
+ },
73
+ // 节点操作 -删除行
74
+ clickDelete (operationItem, row, rowIndex, col) {
75
+ this.$Modal.confirm({
76
+ title: "警告",
77
+ content: "确定删除该行及其所有下级吗?",
78
+ onOk: () => {
79
+ const parentRow = this.getParentRow(row, this.data);
80
+ const index = parentRow.children.findIndex(childRowItem => childRowItem._id === row._id);
81
+ parentRow.children.splice(index, 1);
82
+
83
+ this.change("deleteRow", null, row, rowIndex);
84
+ }
85
+ });
86
+ },
87
+ // 节点操作 -删除所有子行
88
+ clickDeleteChilds (operationItem, row, rowIndex, col) {
89
+ this.$Modal.confirm({
90
+ title: "警告",
91
+ content: "确定删除该行及其所有下级吗?",
92
+ onOk: () => {
93
+ row.children.splice(0);
94
+
95
+ this.change("deleteChildRows", null, row, rowIndex);
96
+ }
97
+ });
98
+ },
99
+
100
+ // 展开/隐藏节点
101
+ toggleExpand (row, bool = true) {
102
+ this.isExpandAction = true;
103
+ this.$set(row, "__isExpand__", bool);
104
+
105
+ this.toggleDescendantsShow(row, bool);
106
+ },
107
+ // 切换子孙后代的显示/隐藏
108
+ toggleDescendantsShow (row, bool) {
109
+ const loop = (row, isFirstSon) => {
110
+ if (row.children && row.children.length) {
111
+ row.children.forEach(subRow => {
112
+ if (isFirstSon) {
113
+ this.$set(subRow, "__isRendered__", true);
114
+ this.$set(subRow, "__isShow__", bool);
115
+ this.$set(subRow, "__isTmpShow__", bool);
116
+ } else {
117
+ if (bool) {
118
+ this.$set(subRow, "__isShow__", subRow.__isTmpShow__);
119
+ } else {
120
+ this.$set(subRow, "__isShow__", false);
121
+ }
122
+ }
123
+
124
+ loop(subRow);
125
+ });
126
+ }
127
+ };
128
+
129
+ loop(row, true);
130
+ }
131
+ }
132
+ };