bri-components 1.3.93 → 1.3.94

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.94",
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
 
@@ -71,12 +71,14 @@
71
71
 
72
72
  <script>
73
73
  import tableBaseMixin from "./mixins/tableBaseMixin.js";
74
+ import treeTableBaseMixin from "./mixins/treeTableBaseMixin.js";
74
75
  import DshCascaderTableMixin from "./mixins/DshCascaderTableMixin.js";
75
76
 
76
77
  export default {
77
78
  name: "DshCascaderTable",
78
79
  mixins: [
79
80
  tableBaseMixin,
81
+ treeTableBaseMixin,
80
82
  DshCascaderTableMixin
81
83
  ],
82
84
  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
 
@@ -126,6 +126,7 @@
126
126
 
127
127
  <script>
128
128
  import tableBaseMixin from "./mixins/tableBaseMixin.js";
129
+ import treeTableBaseMixin from "./mixins/treeTableBaseMixin.js";
129
130
  import DshFlatTableMixin from "./mixins/DshFlatTableMixin.js";
130
131
  import DshDivider from "../controls/base/DshDivider.vue";
131
132
 
@@ -133,6 +134,7 @@
133
134
  name: "DshFlatTable",
134
135
  mixins: [
135
136
  tableBaseMixin,
137
+ treeTableBaseMixin,
136
138
  DshFlatTableMixin
137
139
  ],
138
140
  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
 
@@ -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: {
@@ -59,43 +54,16 @@ export default {
59
54
  event: "changeNode"
60
55
  },
61
56
 
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",
57
+ canClearNode: {
58
+ name: "清除内容",
59
+ type: "canClearNode",
92
60
  icon: "md-trash",
93
61
  divided: true,
94
62
  event: "clickClearNode"
95
63
  },
96
- clearChildNodes: {
97
- name: "清除所有子节点内容",
98
- type: "clearChildNodes",
64
+ canClearChildNodes: {
65
+ name: "清除所有下级内容",
66
+ type: "canClearChildNodes",
99
67
  icon: "md-trash",
100
68
  event: "clickClearChildNodes"
101
69
  }
@@ -103,19 +71,6 @@ export default {
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,58 +165,17 @@ export default {
214
165
  changeNode (operationItem, col, row, rowIndex) {
215
166
  this.change("changeNode", col, row, rowIndex);
216
167
  },
217
-
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);
223
-
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
168
  // 节点操作 -清除该节点内容
257
169
  clickClearNode (operationItem, row, rowIndex, col) {
258
- const nodeData = this.getNodeData(col, row, rowIndex);
259
- nodeData.dataObj.name = "";
170
+ row.name = "";
260
171
 
261
- this.change("clearNode", col, row, rowIndex);
172
+ this.change("clearNode", null, row, rowIndex);
262
173
  },
263
174
  // 节点操作 -清除所有子节点内容
264
175
  clickClearChildNodes (operationItem, row, rowIndex, col) {
265
- let nodeData = this.getNodeData(col, row, rowIndex);
266
- this.$clearPropertyValToLeaf(nodeData.childList);
176
+ this.$clearPropertyValToLeaf(row.children);
267
177
 
268
- this.change("clearChildNodes", col, row, rowIndex);
178
+ this.change("clearChildNodes", null, row, rowIndex);
269
179
  },
270
180
  change (eventType, col, row, rowIndex, ...params) {
271
181
  this.$emit("change", this.tableDataObj, eventType, col, row, rowIndex, ...params);
@@ -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)
@@ -484,9 +389,16 @@ export default {
484
389
  },
485
390
  // 下拉渲染函数
486
391
  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));
392
+ const list = this.$getOperationList(
393
+ position === "th"
394
+ ? [
395
+ ...(column.level <= this.maxLevel ? ["canCreateCol"] : []), // 限制最大添加到几级
396
+ ...(column.level > 1 && column.canDelete === true ? ["canDeleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
397
+ ]
398
+ : row.isLeaf === true
399
+ ? ["canCreate", "canDelete", "canClearNode"]
400
+ : ["canCreate", "canCreateChild", "canDelete", "canDeleteChilds", "canClearNode", "canClearChildNodes"]
401
+ );
490
402
 
491
403
  return !this.isSearching &&
492
404
  list.length &&
@@ -567,13 +479,6 @@ export default {
567
479
  ...selfStyle
568
480
  };
569
481
  },
570
- // 表头 -树节点表头-获取下拉操作
571
- getTreeThBtns (col) {
572
- return [
573
- ...(col.level <= this.maxLevel ? ["createCol"] : []), // 限制最大添加到几级
574
- ...(col.level > 1 && col.canDelete === true ? ["deleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
575
- ];
576
- },
577
482
 
578
483
  // 单元格 -获取样式
579
484
  getTdStyle (col, row, rowIndex) {
@@ -620,41 +525,6 @@ export default {
620
525
  : "未选择算法";
621
526
  }
622
527
  },
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
528
 
659
529
  /* ----------- 工具方法 ---------- */
660
530
  // 合并表头
@@ -739,7 +609,7 @@ export default {
739
609
  // 非最后一列的 新增的非根节点(此时是新增一列或新增非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点
740
610
  // 特别提示:新增的是根节点行,不会走此处代码
741
611
  else {
742
- const newNode = this.getNewNode(rowItem.level + 1, rowItem.children);
612
+ const newNode = this.getNewRowData(rowItem.level + 1, rowItem.children);
743
613
  subForm.forEach(subFormItem => {
744
614
  // 用$set也可以
745
615
  newNode[subFormItem._key] = rowItem[subFormItem._key];
@@ -77,37 +77,39 @@ 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];
86
-
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
- }
95
-
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
80
  const list = this.data;
81
+ const newRow = this.getNewRowData();
108
82
  const newRowIndex = row
109
83
  ? list.findIndex(rowItem => rowItem._id === row._id) + 1
110
84
  : list.length;
85
+
86
+ // 处理单元格合并相关(当前列是合并列,则该列之前的合并列,要复制这一行对应列的值;当前列是普通列,按最后合并列的操作处理)
87
+ if (col) {
88
+ if (col._mergeRow === true) {
89
+ const newList = this.allListData.slice(rowIndex); // 从该行开始截取
90
+ const nextRowIndex = newList.findIndex(rowItem => rowItem[col._key] !== row[col._key]); // 寻找该单元格值开始不一样的行(特殊情况是最后一行,nextRowIndex为-1)
91
+ row = nextRowIndex < 0 ? newList[newList.length - 1] : newList[nextRowIndex - 1]; // 取该单元格值一样的最后一行
92
+
93
+ const colIndex = this.mergeRowColumns.findIndex(column => column._key === col._key);
94
+ this.mergeRowColumns.reduce((obj, column, columnIndex) => {
95
+ return columnIndex < colIndex
96
+ ? Object.assign(obj, {
97
+ [column._key]: this.$deepCopy(row[column._key])
98
+ })
99
+ : obj;
100
+ }, newRow);
101
+ }
102
+ else {
103
+ const colIndex = this.selfColumns.findIndex(column => column._key === col._key);
104
+ const mergeRowColumns = this.selfColumns.filter((column, columnIndex) => columnIndex < colIndex && column._mergeRow === true);
105
+ mergeRowColumns.slice(0, mergeRowColumns.length - 1).reduce((obj, column) => {
106
+ return Object.assign(obj, {
107
+ [column._key]: this.$deepCopy(row[column._key])
108
+ });
109
+ }, newRow);
110
+ }
111
+ }
112
+
111
113
  list.splice(newRowIndex, 0, newRow);
112
114
 
113
115
  this.change("createRow", null, newRow, newRowIndex);
@@ -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
67
  resetProperties: ["__treeIndex__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"],
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));
@@ -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 {
@@ -1230,6 +1252,43 @@ 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
+ };
1290
+ }
1291
+ },
1233
1292
  // 整行校验结果
1234
1293
  getRowRuleResult (row, rowIndex) {
1235
1294
  return this.filterColumns.every(column => this.getColRuleResult(column, row, rowIndex).bool);
@@ -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 newRowIndex = row
54
+ ? list.findIndex(rowItem => rowItem._id === row._id) + 1
55
+ : list.length;
56
+ const newRow = this.getNewRowData(row ? row.level : 1, list);
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 newRowIndex = list.length;
65
+ const newRow = this.getNewRowData(row.level + 1, list);
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
+ };