bri-components 1.3.18 → 1.3.20

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.18",
3
+ "version": "1.3.20",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -300,19 +300,19 @@
300
300
  border: 1px @borderColor dashed;
301
301
  border-radius: @borderRadius;
302
302
  color: @themeColor;
303
-
303
+
304
304
  &:hover {
305
305
  border-color: @themeColor;
306
306
  background-color: @theme-focus;
307
307
  }
308
308
  }
309
-
309
+
310
310
  &-circle {
311
311
  width: 50px!important;
312
312
  height: 50px!important;
313
313
  background-color: @inputBg-readonly;
314
314
  color: @themeColor;
315
-
315
+
316
316
  i {
317
317
  color: @scuess-color;
318
318
  font-size: 40px;
@@ -70,7 +70,7 @@ const pathMap = {
70
70
  selectDepartments: "./senior/selectDepartments.vue",
71
71
  BriLabels: "./senior/BriLabels.vue",
72
72
  DshPackage: "./senior/DshPackage.vue",
73
- flatTable: "./senior/flatTable.vue",
73
+ flatTable: "./senior/flatTable/flatTable.vue",
74
74
  cascaderTable: "./senior/cascaderTable"
75
75
  },
76
76
  special: {
@@ -162,7 +162,11 @@ export default {
162
162
  },
163
163
  // 已选择项的对象列表
164
164
  curValObjList () {
165
- return this.curValList.map(arrItem => this.getItemObj(arrItem));
165
+ return this.curValList.map((item, index) =>
166
+ index < this.curValList.length - 1
167
+ ? this.getItemObj(item, { marginRight: "4px" })
168
+ : this.getItemObj(item)
169
+ );
166
170
  },
167
171
  curValNameList () {
168
172
  return this.curValObjList.map(item => item[this.nameKey]);
@@ -203,32 +207,33 @@ export default {
203
207
  },
204
208
 
205
209
  /* --------- 工具类 -------- */
206
- getItemObj (val) {
210
+ getItemObj (val, selfStyle = {}) {
207
211
  const objArr = this.$getTreeLinealDatas(val, this.cascaderAllData, undefined, this.saveKey);
212
+ const obj = objArr.length
213
+ ? {
214
+ ...objArr.slice(-1)[0],
215
+ [this.nameKey]: this.transformFullName(val)
216
+ }
217
+ : {
218
+ [this.saveKey]: val,
219
+ [this.nameKey]: `提示:选项${val}已不存在`
220
+ };
208
221
 
209
222
  return !this.$isEmptyData(val)
210
- ? objArr.length
211
- ? {
212
- ...objArr.slice(-1)[0],
213
- [this.nameKey]: this.transformFullName(val),
214
- // 查看状态时tag用
215
- style: {
216
- ...this.tagStyle,
217
- ...this.getItemColorStyle(objArr.slice(-1)[0])
218
- },
219
- color: undefined
220
- }
221
- : {
222
- _key: val,
223
- name: `提示:选项${val}已不存在`,
224
- style: {
225
- ...this.tagStyle
226
- }
227
- }
223
+ ? {
224
+ name: obj[this.nameKey], // 查看状态时tag用
225
+ ...obj,
226
+ style: {
227
+ ...this.tagStyle,
228
+ ...this.getItemColorStyle(obj),
229
+ ...selfStyle
230
+ }, // 查看状态时tag用
231
+ color: undefined
232
+ }
228
233
  : undefined;
229
234
  },
230
235
  // 每项的颜色相关style --flat方式在用
231
- getItemColorStyle (item) {
236
+ getItemColorStyle (item = {}) {
232
237
  const color = this.colorMap[item.color] || this.colorMap["color-default"];
233
238
  return this.useColor
234
239
  ? {
@@ -27,7 +27,7 @@ export default {
27
27
  },
28
28
  /* 列表形式下用到的 */
29
29
  rowIndex: Number,
30
- parentData: {
30
+ parentListData: {
31
31
  type: Array,
32
32
  default () {
33
33
  return [];
@@ -43,7 +43,7 @@ export default {
43
43
  "max-width": "100%",
44
44
  height: "24px",
45
45
  padding: "4px 8px",
46
- margin: "2px 4px 2px 0px",
46
+ margin: "2px 0px",
47
47
  "border-radius": "4px",
48
48
  "line-height": "16px",
49
49
  "font-size": "12px",
@@ -88,7 +88,11 @@ export default {
88
88
  },
89
89
  // 已选择项的对象列表
90
90
  curValObjList () {
91
- return this.curValList.map(key => this.getItemObj(key));
91
+ return this.curValList.map((item, index) =>
92
+ index < this.curValList.length - 1
93
+ ? this.getItemObj(item, { marginRight: "4px" })
94
+ : this.getItemObj(item)
95
+ );
92
96
  },
93
97
  curValNameList () {
94
98
  return this.curValObjList.map(item => item[this.nameKey] || item.name || item._name);
@@ -140,7 +144,7 @@ export default {
140
144
 
141
145
  /* ------- 方法 ------- */
142
146
  // 获取某项的对象数据
143
- getItemObj (val) {
147
+ getItemObj (val, selfStyle = {}) {
144
148
  const obj = this.listData.find(item => item[this.saveKey] === val) || {
145
149
  [this.saveKey]: val,
146
150
  [this.nameKey]: `提示:选项${val}已不存在`
@@ -148,13 +152,13 @@ export default {
148
152
 
149
153
  return !this.$isEmptyData(val)
150
154
  ? {
151
- name: obj[this.nameKey],
155
+ name: obj[this.nameKey], // 查看状态时tag用
152
156
  ...obj,
153
- // 查看状态时tag用
154
157
  style: {
155
158
  ...this.tagStyle,
156
- ...this.getItemColorStyle(obj)
157
- },
159
+ ...this.getItemColorStyle(obj),
160
+ ...selfStyle
161
+ }, // 查看状态时tag用
158
162
  color: undefined
159
163
  }
160
164
  : undefined;
@@ -22,7 +22,7 @@
22
22
  <template v-else>
23
23
  <!-- 配置端 设置默认值用-->
24
24
  <dsh-btn-modal v-if="propsObj._key === '_default'">
25
- <bri-flat-table
25
+ <dsh-flat-table
26
26
  :canEdit="finalCanEdit"
27
27
  :columns="columns"
28
28
  :data="curVal.list"
@@ -30,7 +30,7 @@
30
30
  :parentObj="value"
31
31
  :propsObj="propsObj"
32
32
  @change="change"
33
- ></bri-flat-table>
33
+ ></dsh-flat-table>
34
34
  </dsh-btn-modal>
35
35
 
36
36
  <!-- 正常使用 -->
@@ -43,7 +43,7 @@
43
43
  @click="$dispatchEvent($event)"
44
44
  ></dsh-buttons>
45
45
 
46
- <bri-flat-table
46
+ <dsh-flat-table
47
47
  ref="dshFatTable"
48
48
  :canEdit="finalCanEdit"
49
49
  :columns="columns"
@@ -53,7 +53,7 @@
53
53
  :parentObj="value"
54
54
  :propsObj="propsObj"
55
55
  @change="change"
56
- ></bri-flat-table>
56
+ ></dsh-flat-table>
57
57
 
58
58
  <!-- 全屏查看 -->
59
59
  <dsh-modal
@@ -61,7 +61,7 @@
61
61
  mode="custom"
62
62
  :propsObj="modalPropsObj"
63
63
  >
64
- <bri-flat-table
64
+ <dsh-flat-table
65
65
  :canEdit="finalCanEdit"
66
66
  :columns="columns"
67
67
  :data="curVal.list"
@@ -70,7 +70,7 @@
70
70
  :parentObj="value"
71
71
  :propsObj="propsObj"
72
72
  @change="change"
73
- ></bri-flat-table>
73
+ ></dsh-flat-table>
74
74
  </dsh-modal>
75
75
  </template>
76
76
  </template>
@@ -88,9 +88,9 @@
88
88
  </template>
89
89
 
90
90
  <script>
91
- import controlMixin from "../mixins/controlMixin.js";
92
- import DshBtnModal from "../../small/DshBtnModal.vue";
93
- import BriFlatTable from "../../list/BriFlatTable.vue";
91
+ import controlMixin from "../../mixins/controlMixin.js";
92
+ import DshBtnModal from "../../../small/DshBtnModal.vue";
93
+ import DshFlatTable from "../../../list/DshFlatTable.vue";
94
94
  import flatTableImportModal from "./flatTableImportModal.vue";
95
95
 
96
96
  export default {
@@ -100,7 +100,7 @@
100
100
  ],
101
101
  components: {
102
102
  DshBtnModal,
103
- BriFlatTable,
103
+ DshFlatTable,
104
104
  flatTableImportModal
105
105
  },
106
106
  props: {},
@@ -180,13 +180,18 @@ export default {
180
180
  );
181
181
  const parameterTypeName = (this.parameterPropsObj._data.find(parameterTypeItem => parameterTypeItem._key === parameterType) || { name: `${parameterType}不存在` }).name;
182
182
 
183
- const operators = fieldData[!dynamicList.length && ["set"].includes(this.mode) ? "operatorsSet" : "operators"] || fieldData.operators || [];
183
+ const operators = ["_id"].includes(curFormItem._key)
184
+ ? []
185
+ : (fieldData[!dynamicList.length && ["set"].includes(this.mode) ? "operatorsSet" : "operators"] ||
186
+ fieldData.operators || []);
184
187
  const fieldOperator = ["_id"].includes(curFormItem._key)
185
188
  ? "eq"
186
- : initContion.fieldOperator || (
187
- ["reference"].includes(fieldType) && this.isSimpleSearch
188
- ? "eq"
189
- : (operators[0] || {})._key
189
+ : (
190
+ initContion.fieldOperator || (
191
+ ["reference"].includes(fieldType) && this.isSimpleSearch
192
+ ? "eq"
193
+ : (operators[0] || {})._key
194
+ )
190
195
  );
191
196
  const fieldOperatorName = (operators.find(operatorItem => operatorItem._key === fieldOperator) || { name: `${fieldOperator}不存在` }).name;
192
197
 
@@ -348,7 +348,7 @@
348
348
  computed: {
349
349
  selfPropsObj () {
350
350
  return {
351
- isShare: false, // 是否是分享页在用
351
+ // isShare: false, // 是否是分享页在用
352
352
 
353
353
  _showRequired: true, // 表头显示校验符号*
354
354
  _showDescription: true, // 表头显示提示
@@ -360,9 +360,9 @@
360
360
  _contentHeight: this.propsObj._contentHeight || 400 // 表格最大高度
361
361
  };
362
362
  },
363
- isShare () {
364
- return this.selfPropsObj.isShare;
365
- },
363
+ // isShare () {
364
+ // return this.selfPropsObj.isShare;
365
+ // },
366
366
  contentHeight () {
367
367
  return this.selfPropsObj._contentHeight;
368
368
  },
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <div class="BriFlatTable">
2
+ <div class="DshFlatTable">
3
3
  <bri-table
4
- class="BriFlatTable-main"
4
+ class="DshFlatTable-main"
5
5
  :columns="showColumns"
6
6
  :data="listData"
7
7
  :footer-data="footerData"
@@ -12,7 +12,7 @@
12
12
 
13
13
  <!-- 添加行 -->
14
14
  <dsh-buttons
15
- class="BriFlatTable-create"
15
+ class="DshFlatTable-create"
16
16
  :list="$getOperationList(['canCreate'])"
17
17
  @click="$dispatchEvent($event, null, null, listData)"
18
18
  ></dsh-buttons>
@@ -20,96 +20,41 @@
20
20
  </template>
21
21
 
22
22
  <script>
23
+ import DshFlatTableMixin from "./mixins/DshFlatTableMixin.js";
23
24
  import DshListUnit from "../unit/DshListUnit.vue";
24
25
 
25
26
  export default {
26
- name: "BriFlatTable",
27
+ name: "DshFlatTable",
28
+ mixins: [
29
+ DshFlatTableMixin
30
+ ],
27
31
  components: {
28
32
  DshListUnit
29
33
  },
30
- props: {
31
- canEdit: {
32
- type: Boolean,
33
- default: true
34
- },
35
- columns: {
36
- type: Array,
37
- default () {
38
- return [];
39
- }
40
- },
41
- data: {
42
- type: Array,
43
- default () {
44
- return [];
45
- }
46
- },
47
- oldData: {
48
- type: Array,
49
- default () {
50
- return [];
51
- }
52
- },
53
- rowDefault: {
54
- type: Object,
55
- default () {
56
- return {};
57
- }
58
- },
59
-
60
- parentObj: {
61
- type: Object,
62
- default () {
63
- return {};
64
- }
65
- },
66
- propsObj: {
67
- type: Object,
68
- default () {
69
- return {};
70
- }
71
- }
72
- },
73
- model: {
74
- prop: "data",
75
- event: "change"
76
- },
34
+ props: {},
77
35
  data () {
78
- return {
79
- showRuleMessage: false, // 显示校验文字
80
- ruleRecordMap: {}
81
- };
36
+ return {};
82
37
  },
83
38
  computed: {
84
- listData () {
85
- this.data.forEach(item => {
86
- !item._id && this.$set(item, "_id", this.$ObjectID().str);
87
- });
88
- return this.data;
89
- },
90
39
  footerData () {
91
40
  if (this.useSummary && this.listData.length) {
92
- const row = this.filterColumns.reduce((row, col) => {
93
- if (col._type === "number") {
94
- row[col._key] = this.$calNumList(this.listData.map(item => item[col._key]), col._summaryType, { ...col, _defaultDigit: 2 });
95
- }
96
- return row;
97
- }, {
98
- _id: this.$ObjectID().str,
99
- custome: "汇总"
100
- });
101
-
102
- return [row];
41
+ return [
42
+ this.filterColumns.reduce((obj, col) => {
43
+ return {
44
+ ...obj,
45
+ [col._key]: col._type === "number"
46
+ ? this.$calNumList(this.listData.map(item => item[col._key]), col._summaryType, { ...col, _defaultDigit: 2 })
47
+ : obj[col._key]
48
+ };
49
+ }, {
50
+ _id: this.$ObjectID().str,
51
+ custome: "汇总"
52
+ })
53
+ ];
103
54
  } else {
104
55
  return [];
105
56
  }
106
57
  },
107
- oldListData () {
108
- this.oldData.forEach(item => {
109
- !item._id && this.$set(item, "_id", this.$ObjectID().str);
110
- });
111
- return this.oldData;
112
- },
113
58
 
114
59
  tablePropsObj () {
115
60
  return {
@@ -123,29 +68,9 @@
123
68
  },
124
69
  selfPropsObj () {
125
70
  return {
126
- isShare: false, // 是否是分享页在用
127
-
128
- _showRequired: true, // 表头显示校验符号*
129
- _showDescription: true, // 表头显示提示
130
- _headHeightAuto: false, // 表头高度自适应
131
- _heightAuto: false, // 单元格高度自适应
132
- _useSelection: false, // 使用选择列
133
- _useIndex: true, // 使用序号列
134
- _useSummary: false, // 使用汇总行
135
- _disabledBtns: false, // 禁用增删按钮
136
- _disabledCreateBtn: false, // 置灰新增按钮,目前只内部使用,comp_web数据表配置页那块
137
- _disabledOldDataRow: false, // 置灰老数据行包含删除
138
- ...this.propsObj,
139
-
140
- _contentHeight: this.propsObj._contentHeight || 500 // 表格最大高度
71
+ ...this.commonPropsObj
141
72
  };
142
73
  },
143
- isShare () {
144
- return this.selfPropsObj.isShare;
145
- },
146
- contentHeight () {
147
- return this.selfPropsObj._contentHeight;
148
- },
149
74
  showRequired () {
150
75
  return this.selfPropsObj._showRequired;
151
76
  },
@@ -158,38 +83,11 @@
158
83
  heightAuto () {
159
84
  return this.selfPropsObj._heightAuto;
160
85
  },
161
- useSelection () {
162
- return this.selfPropsObj._useSelection;
163
- },
164
- useIndex () {
165
- return this.selfPropsObj._useIndex;
166
- },
167
- useSummary () {
168
- return this.selfPropsObj._useSummary;
169
- },
170
- disabledBtns () {
171
- return this.selfPropsObj._disabledBtns;
172
- },
173
- disabledCreateBtn () {
174
- return this.selfPropsObj._disabledCreateBtn;
175
- },
176
- disabledOldDataRow () {
177
- return this.selfPropsObj._disabledOldDataRow;
178
- },
179
86
 
180
- useCampare () {
181
- return !!this.oldListData.length;
182
- },
183
- filterColumns () {
184
- return this.columns.filter(column => {
185
- return column._isRelyParent
186
- ? this.$isFormItemShow(column, this.parentObj, true)
187
- : !["hide"].includes(column._displayType);
188
- });
189
- },
190
87
  showColumns () {
191
- const operationList = this.$getOperationList(["delete"]);
192
- const showColumns = [
88
+ const operationList = this.$getOperationList(["canDelete"]);
89
+
90
+ return [
193
91
  ...(
194
92
  this.useSelection === true
195
93
  ? [
@@ -226,7 +124,7 @@
226
124
  filter: undefined,
227
125
  sortBy: undefined,
228
126
  renderBodyCell: ({ row, column, rowIndex }, h) => {
229
- column = this.$transformFieldProperty(column, row);
127
+ column = this.$transformFieldProperty(column, column._isRuleByParent ? this.parentObj : row);
230
128
 
231
129
  return [
232
130
  this.isShowCompare(column, row, this.oldListData[rowIndex])
@@ -249,8 +147,8 @@
249
147
  formData: row,
250
148
  formItem: this.resetCol(column, row),
251
149
  rowIndex: rowIndex,
252
- parentData: this.listData,
253
- allFormList: this.columns
150
+ allFormList: this.columns,
151
+ parentListData: this.listData
254
152
  },
255
153
  on: {
256
154
  blur: () => this.controlBlur(null, column, row, arguments),
@@ -265,8 +163,8 @@
265
163
  formData: row,
266
164
  formItem: this.resetCol(column, row),
267
165
  rowIndex: rowIndex,
268
- parentData: this.listData,
269
- allFormList: this.columns
166
+ allFormList: this.columns,
167
+ parentListData: this.listData
270
168
  },
271
169
  on: {
272
170
  blur: () => this.controlBlur(null, column, row, arguments),
@@ -281,13 +179,17 @@
281
179
  : undefined
282
180
  ];
283
181
  },
182
+ renderHeaderCell: ({ column }, h) => {
183
+ column = this.$transformFieldProperty(column, column._isRuleByParent ? this.parentObj : {});
184
+
185
+ return this.$getHeadRender(h, column, {
186
+ showRequired: this.showRequired,
187
+ showDescription: this.showDescription,
188
+ headHeightAuto: this.headHeightAuto
189
+ });
190
+ },
284
191
  ...colItem
285
- })),
286
- {
287
- showRequired: this.showRequired,
288
- showDescription: this.showDescription,
289
- headHeightAuto: this.headHeightAuto
290
- }
192
+ }))
291
193
  ),
292
194
 
293
195
  ...(
@@ -303,7 +205,10 @@
303
205
  renderBodyCell: (params, h) => {
304
206
  return h("dsh-buttons", {
305
207
  props: {
306
- list: operationList.map(btnItem => ({ ...btnItem, disabled: this.disabledOldDataRow && !params.row.__isCreate__ }))
208
+ list: operationList.map(btnItem => ({
209
+ ...btnItem,
210
+ disabled: this.disabledOldDataRow && !params.row.__isCreate__
211
+ }))
307
212
  },
308
213
  on: {
309
214
  click: (operationItem) => {
@@ -317,13 +222,10 @@
317
222
  : []
318
223
  )
319
224
  ];
320
- return showColumns;
321
225
  },
322
- selfRowDefault () {
323
- return this.$filterObj(this.columns, this.rowDefault);
324
- },
325
- operationMap () {
326
- const allOperationMap = {
226
+
227
+ allOperationMap () {
228
+ return {
327
229
  canCreate: {
328
230
  name: "添加一行",
329
231
  type: "canCreate",
@@ -333,9 +235,9 @@
333
235
  event: "clickCreate",
334
236
  btnType: "default"
335
237
  },
336
- delete: {
238
+ canDelete: {
337
239
  name: "删除",
338
- type: "delete",
240
+ type: "canDelete",
339
241
  btnType: "errorText",
340
242
  icon: "ios-trash-outline",
341
243
  size: "small",
@@ -353,29 +255,10 @@
353
255
  event: "changeVal"
354
256
  }
355
257
  };
356
-
357
- return this.canEdit
358
- ? this.$categoryMapToMap(
359
- allOperationMap,
360
- null,
361
- this.disabledBtns ? ["canCreate", "delete"] : []
362
- )
363
- : {};
364
258
  }
365
259
  },
366
260
  created () {},
367
261
  methods: {
368
- // 共外部使用
369
- validate () {
370
- this.showRuleMessage = true;
371
-
372
- return this.listData.every(row =>
373
- this.filterColumns.every(column => {
374
- column = this.$transformFieldProperty(column, row);
375
- return this.getRuleResult(column, row).bool;
376
- })
377
- );
378
- },
379
262
  // 点击 -添加行
380
263
  clickCreate (operationItem, row, index, list) {
381
264
  const newRow = {
@@ -389,18 +272,6 @@
389
272
 
390
273
  this.change("createRow", null, newRow, newRowIndex);
391
274
  },
392
- // 点击 -删除行
393
- clickDelete (operationItem, row, rowIndex, list) {
394
- this.$Modal.confirm({
395
- title: "警告",
396
- content: "确定删除吗?",
397
- onOk: () => {
398
- list.splice(rowIndex, 1);
399
-
400
- this.change("deleteRow", null, row, rowIndex);
401
- }
402
- });
403
- },
404
275
  changeSelect (list) {
405
276
  this.$emit("changeSelect", list);
406
277
  },
@@ -412,57 +283,13 @@
412
283
  // 表单控件失去焦点
413
284
  controlBlur (operationItem, col, row, params) {
414
285
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
415
- },
416
- change (...params) {
417
- this.$emit("change", { list: this.listData, rowDefault: this.rowDefault }, ...params);
418
- },
419
-
420
- /* --------------- 工具方法 ------------- */
421
- resetCol (col, row) {
422
- let resetMap = {
423
- select: {
424
- _optionKind: "dropdown"
425
- },
426
- checkbox: {
427
- _optionKind: "dropdown"
428
- }
429
- };
430
- return {
431
- ...col,
432
- ...(resetMap[col._type] || {}),
433
- isShare: this.isShare,
434
- _heightAuto: this.heightAuto
435
- // canEdit: this.$isAdvRelyShow(col, row, true)
436
- };
437
- },
438
- getUnitCanEdit (col, row) {
439
- return this.canEdit && // 是否是编辑状态
440
- // (!this.disabledOldDataRow || !!this.createRowMap[row._id]) && // 是否让老数据行置灰
441
- (!this.disabledOldDataRow || !!row.__isCreate__) && // 是否让老数据行置灰
442
- (!col.dependRowCanEdit || row.canEdit !== false) &&
443
- this.$isAdvRelyShow(col, row, true); // 在老数据行里某些列不可编辑; // 在老数据行里某些列不可编辑
444
- },
445
- isShowCompare (col, row, oldRow = {}) {
446
- return this.useCampare && ["number"].includes(col._type) &&
447
- !(this.$isEmptyData(row[col._key]) && this.$isEmptyData(oldRow[col._key])) &&
448
- row[col._key] !== oldRow[col._key];
449
- },
450
- // 是否显示 单元格校验提示文字
451
- getRuleResult (col, row) {
452
- if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || this.showRuleMessage) {
453
- return this.$getFieldRuleResult(col, row);
454
- } else {
455
- return {
456
- bool: true
457
- };
458
- }
459
286
  }
460
287
  }
461
288
  };
462
289
  </script>
463
290
 
464
291
  <style lang="less" scoped>
465
- .BriFlatTable {
292
+ .DshFlatTable {
466
293
  &-main {
467
294
  width: 100%;
468
295
  height: auto;
@@ -0,0 +1,213 @@
1
+ export default {
2
+ mixins: [],
3
+ components: {},
4
+ props: {
5
+ canEdit: {
6
+ type: Boolean,
7
+ default: true
8
+ },
9
+ columns: {
10
+ type: Array,
11
+ default () {
12
+ return [];
13
+ }
14
+ },
15
+ data: {
16
+ type: Array,
17
+ default () {
18
+ return [];
19
+ }
20
+ },
21
+ oldData: {
22
+ type: Array,
23
+ default () {
24
+ return [];
25
+ }
26
+ },
27
+ rowDefault: {
28
+ type: Object,
29
+ default () {
30
+ return {};
31
+ }
32
+ },
33
+ parentObj: {
34
+ type: Object,
35
+ default () {
36
+ return {};
37
+ }
38
+ },
39
+ propsObj: {
40
+ type: Object,
41
+ default () {
42
+ return {};
43
+ }
44
+ }
45
+ },
46
+ model: {
47
+ prop: "data",
48
+ event: "change"
49
+ },
50
+ data () {
51
+ return {
52
+ showRuleMessage: false, // 显示校验文字
53
+ ruleRecordMap: {}
54
+ };
55
+ },
56
+ computed: {
57
+ listData () {
58
+ this.data.forEach(item => {
59
+ !item._id && this.$set(item, "_id", this.$ObjectID().str);
60
+ });
61
+ return this.data;
62
+ },
63
+ oldListData () {
64
+ this.oldData.forEach(item => {
65
+ !item._id && this.$set(item, "_id", this.$ObjectID().str);
66
+ });
67
+ return this.oldData;
68
+ },
69
+ useCampare () {
70
+ return !!this.oldListData.length;
71
+ },
72
+
73
+ commonPropsObj () {
74
+ return {
75
+ // isShare: false, // 是否是分享页在用
76
+
77
+ _showRequired: true, // 表头显示校验符号*
78
+ _showDescription: true, // 表头显示提示
79
+ _headHeightAuto: false, // 表头高度自适应
80
+ _heightAuto: false, // 单元格高度自适应
81
+ _useSelection: false, // 使用选择列
82
+ _useIndex: true, // 使用序号列
83
+ _useSummary: false, // 使用汇总行
84
+ _disabledBtns: false, // 禁用增删按钮
85
+ _disabledCreateBtn: false, // 置灰新增按钮,目前只内部使用,comp_web数据表配置页那块
86
+ _disabledOldDataRow: false, // 置灰老数据行包含删除
87
+ ...this.propsObj,
88
+
89
+ _contentHeight: this.propsObj._contentHeight || 500 // 表格最大高度
90
+ };
91
+ },
92
+ // isShare () {
93
+ // return this.selfPropsObj.isShare;
94
+ // },
95
+ contentHeight () {
96
+ return this.selfPropsObj._contentHeight;
97
+ },
98
+ useSelection () {
99
+ return this.selfPropsObj._useSelection;
100
+ },
101
+ useIndex () {
102
+ return this.selfPropsObj._useIndex;
103
+ },
104
+ useSummary () {
105
+ return this.selfPropsObj._useSummary;
106
+ },
107
+ disabledBtns () {
108
+ return this.selfPropsObj._disabledBtns;
109
+ },
110
+ disabledCreateBtn () {
111
+ return this.selfPropsObj._disabledCreateBtn;
112
+ },
113
+ disabledOldDataRow () {
114
+ return this.selfPropsObj._disabledOldDataRow;
115
+ },
116
+
117
+ filterColumns () {
118
+ return this.columns.filter(column =>
119
+ column._isRelyByParent
120
+ ? this.$isAdvRelyShow(column, this.parentObj, true, true, this.listData)
121
+ : !["hide"].includes(column._displayType)
122
+ );
123
+ },
124
+ selfRowDefault () {
125
+ return this.$filterObj(this.filterColumns, this.rowDefault);
126
+ },
127
+
128
+ operationMap () {
129
+ return this.canEdit
130
+ ? this.$categoryMapToMap(
131
+ this.allOperationMap,
132
+ null,
133
+ this.disabledBtns ? ["canCreate", "canDelete"] : []
134
+ )
135
+ : {};
136
+ }
137
+ },
138
+ created () { },
139
+ methods: {
140
+ // 共外部使用
141
+ validate () {
142
+ this.showRuleMessage = true;
143
+
144
+ return this.listData.every(row =>
145
+ this.filterColumns.every(column => {
146
+ column = this.$transformFieldProperty(column, column._isRuleByParent ? this.parentObj : row);
147
+ return this.getRuleResult(column, row).bool;
148
+ })
149
+ );
150
+ },
151
+ // 是否显示 单元格校验提示文字
152
+ getRuleResult (col, row) {
153
+ if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || this.showRuleMessage) {
154
+ return this.$getFieldRuleResult(col, row);
155
+ } else {
156
+ return {
157
+ bool: true
158
+ };
159
+ }
160
+ },
161
+
162
+ // 点击 -删除行
163
+ clickDelete (operationItem, row, rowIndex, list) {
164
+ this.$Modal.confirm({
165
+ title: "警告",
166
+ content: "确定删除吗?",
167
+ onOk: () => {
168
+ list.splice(rowIndex, 1);
169
+
170
+ this.change("deleteRow", null, row, rowIndex);
171
+ }
172
+ });
173
+ },
174
+ change (...params) {
175
+ this.$emit("change", { list: this.listData, rowDefault: this.rowDefault }, ...params);
176
+ },
177
+
178
+ /* --------------- 工具方法 ------------- */
179
+ resetCol (col, row) {
180
+ let resetMap = {
181
+ select: {
182
+ _optionKind: "dropdown"
183
+ },
184
+ checkbox: {
185
+ _optionKind: "dropdown"
186
+ }
187
+ };
188
+ return {
189
+ ...col,
190
+ ...(resetMap[col._type] || {}),
191
+ // isShare: this.isShare,
192
+ _heightAuto: this.heightAuto
193
+ };
194
+ },
195
+ getUnitCanEdit (col, row) {
196
+ return this.getRowCanEdit(row) && this.getColCanEdit(col, row);
197
+ },
198
+ getRowCanEdit (row) {
199
+ return this.canEdit && // 是否是编辑状态
200
+ // (!this.disabledOldDataRow || !!this.createRowMap[row._id]) && // 是否让老数据行置灰
201
+ (!this.disabledOldDataRow || !!row.__isCreate__); // 是否让老数据行置灰
202
+ },
203
+ getColCanEdit (col, row) {
204
+ return (!col.dependRowCanEdit || row.canEdit !== false) &&
205
+ (col._isRelyByParent ? true : this.$isAdvRelyShow(col, row, true)); // 在老数据行里某些列不可编辑; // 在老数据行里某些列不可编辑
206
+ },
207
+ isShowCompare (col, row, oldRow = {}) {
208
+ return this.useCampare && ["number"].includes(col._type) &&
209
+ !(this.$isEmptyData(row[col._key]) && this.$isEmptyData(oldRow[col._key])) &&
210
+ row[col._key] !== oldRow[col._key];
211
+ }
212
+ }
213
+ };
@@ -23,9 +23,9 @@
23
23
  size: 'default',
24
24
  inTable: true
25
25
  }"
26
- :allFormList="allFormList"
27
26
  :rowIndex="rowIndex"
28
- :parentData="parentData"
27
+ :allFormList="allFormList"
28
+ :parentListData="parentListData"
29
29
  @blur="blur"
30
30
  @change="change"
31
31
  ></component>
@@ -49,7 +49,7 @@
49
49
 
50
50
  indexStr: String,
51
51
  rowIndex: Number,
52
- parentData: {
52
+ parentListData: {
53
53
  type: Array,
54
54
  default () {
55
55
  return [];
package/src/index.js CHANGED
@@ -9,7 +9,7 @@ import CN from "vue-easytable/libs/locale/lang/zh-CN.js";
9
9
 
10
10
  // list
11
11
  import BriTable from "./components/list/BriTable.vue";
12
- import BriFlatTable from "./components/list/BriFlatTable.vue";
12
+ import DshFlatTable from "./components/list/DshFlatTable.vue";
13
13
  import DshBox from "./components/list/DshBox/DshBox.vue";
14
14
  import DshList from "./components/list/DshBox/DshList.vue";
15
15
  import DshTable from "./components/list/DshBox/DshTable.vue";
@@ -228,7 +228,7 @@ export {
228
228
  Error403,
229
229
  Error404,
230
230
 
231
- BriFlatTable,
231
+ DshFlatTable,
232
232
  // DshCascaderTable,
233
233
 
234
234
  BriCard,