bri-components 1.0.3 → 1.1.0
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/lib/0.bri-components.min.js +1 -1
- package/lib/1.bri-components.min.js +1 -1
- package/lib/2.bri-components.min.js +1 -1
- package/lib/3.bri-components.min.js +1 -1
- package/lib/4.bri-components.min.js +1 -1
- package/lib/5.bri-components.min.js +1 -1
- package/lib/6.bri-components.min.js +1 -1
- package/lib/7.bri-components.min.js +1 -0
- package/lib/8.bri-components.min.js +1 -0
- package/lib/9.bri-components.min.js +1 -0
- package/lib/bri-components.min.js +16 -6
- package/lib/styles/bundle.css +0 -2
- package/package.json +121 -120
- package/src/components/controls/base/BriLabels.vue +117 -0
- package/src/components/controls/base/DshCascader.vue +23 -38
- package/src/components/controls/base/DshCascaderMultiple.vue +1 -1
- package/src/components/controls/base/DshCheckbox.vue +14 -4
- package/src/components/controls/base/DshCoordinates.vue +5 -9
- package/src/components/controls/base/DshDate.vue +10 -34
- package/src/components/controls/base/DshDivider.vue +1 -1
- package/src/components/controls/base/DshEditor.vue +52 -44
- package/src/components/controls/base/DshInput.vue +18 -45
- package/src/components/controls/base/DshLabels.vue +8 -4
- package/src/components/controls/base/DshNumber/DshNumber.vue +6 -20
- package/src/components/controls/base/DshNumberange.vue +1 -1
- package/src/components/controls/base/DshPackage.vue +7 -1
- package/src/components/controls/base/DshSelect.vue +15 -5
- package/src/components/controls/base/DshSwitch.vue +2 -6
- package/src/components/controls/base/YSerialNumber.vue +0 -1
- package/src/components/controls/base/ZUpload/index.vue +16 -10
- package/src/components/controls/base/ZUpload/upload-list.vue +17 -12
- package/src/components/controls/base/ZUpload/uploadMixin.js +1 -5
- package/src/components/controls/base/controlShow.vue +52 -0
- package/src/components/controls/base/textMultiple/DshTextMultiple.vue +1 -1
- package/src/components/controls/controlMap.js +4 -0
- package/src/components/controls/controlMixin.js +21 -20
- package/src/components/controls/senior/cascaderTable.vue +188 -0
- package/src/components/controls/senior/flatTable.vue +131 -0
- package/src/components/form/DshForm.vue +0 -5
- package/src/components/list/BriFlatTable.vue +430 -0
- package/src/components/list/BriTable.vue +184 -0
- package/src/components/list/DshBox/DshPanel.vue +63 -79
- package/src/components/list/DshBox/DshTable.vue +29 -39
- package/src/components/list/DshCascaderTable.vue +6 -11
- package/src/components/list/DshFlatTable.vue +9 -17
- package/src/components/other/BriTransfer.vue +71 -0
- package/src/components/small/BriButton.vue +65 -0
- package/src/components/small/BriTree.vue +42 -0
- package/src/components/small/Ctooltip.vue +1 -1
- package/src/components/small/DshButtons.vue +12 -42
- package/src/components/unit/DshFormItem.vue +11 -6
- package/src/components/unit/DshUnit.vue +1 -3
- package/src/components/unit/unitMixin.js +4 -1
- package/src/index.js +24 -4
- package/src/styles/bundle.css +0 -2
- package/src/styles/common/common.less +2 -2
- package/src/styles/common/control.less +53 -0
- package/src/styles/common/index.less +1 -0
- package/src/styles/components/controls/BriLabels.less +23 -0
- package/src/styles/components/controls/DshCascader.less +3 -3
- package/src/styles/components/controls/DshCheckbox.less +1 -1
- package/src/styles/components/controls/DshCoordinates.less +3 -3
- package/src/styles/components/controls/DshDate.less +54 -0
- package/src/styles/components/controls/DshDaterange.less +1 -1
- package/src/styles/components/controls/DshEditor.less +27 -9
- package/src/styles/components/controls/DshInput.less +5 -5
- package/src/styles/components/controls/DshLabels.less +1 -1
- package/src/styles/components/controls/DshSelect.less +46 -30
- package/src/styles/components/controls/ZUpload.less +82 -91
- package/src/styles/components/controls/cascaderTable.less +33 -0
- package/src/styles/components/controls/controlShow.less +12 -0
- package/src/styles/components/controls/flatTable.less +33 -0
- package/src/styles/components/form/DshAdvSearchForm.less +6 -6
- package/src/styles/components/index.less +10 -0
- package/src/styles/components/list/BriFlatTable.less +8 -0
- package/src/styles/components/list/BriTable.less +155 -0
- package/src/styles/components/list/DshFlatTable.less +3 -8
- package/src/styles/components/list/evTable.less +1 -1
- package/src/styles/components/other/BriTransfer.less +65 -0
- package/src/styles/components/other/DshEditPanel.less +2 -2
- package/src/styles/components/other/DshMenuNav.less +5 -5
- package/src/styles/components/other/ZGantt.less +5 -5
- package/src/styles/components/small/BriButton.less +259 -0
- package/src/styles/components/small/BriTree.less +57 -0
- package/src/styles/components/small/Ctooltip.less +14 -0
- package/src/styles/components/small/DshButtons.less +1 -1
- package/src/styles/components/small/DshControlDefine.less +2 -2
- package/src/styles/components/small/DshDropdown.less +1 -1
- package/src/styles/components/small/DshPage.less +1 -1
- package/src/styles/components/small/DshTabs.less +2 -2
- package/src/styles/components/unit/DshFormItem.less +5 -6
- package/src/styles/index.less +1 -5
- package/src/styles/plugin/easytable.less +22 -0
- package/src/styles/plugin/index.less +2 -0
- package/src/styles/plugin/iview.less +33 -0
- package/src/styles/variables.less +71 -88
- package/src/utils/table.js +72 -978
- package/src/styles/define.less +0 -374
- package/src/styles/view_reset.less +0 -452
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="BriFlatTable">
|
|
3
|
+
<bri-table
|
|
4
|
+
class="BriFlatTable-main"
|
|
5
|
+
:propsObj="tablePropsObj"
|
|
6
|
+
:columns="showColumns"
|
|
7
|
+
:data="listData"
|
|
8
|
+
:footer-data="footerData"
|
|
9
|
+
@selectChange="changeSelect"
|
|
10
|
+
@selectAll="changeSelect"
|
|
11
|
+
></bri-table>
|
|
12
|
+
|
|
13
|
+
<!-- 添加行 -->
|
|
14
|
+
<dsh-buttons
|
|
15
|
+
class="BriFlatTable-create"
|
|
16
|
+
:list="$getOperationList(['create'])"
|
|
17
|
+
@click="$dispatchEvent($event, null, null, listData)"
|
|
18
|
+
></dsh-buttons>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
export default {
|
|
24
|
+
name: "BriFlatTable",
|
|
25
|
+
props: {
|
|
26
|
+
canEdit: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: true
|
|
29
|
+
},
|
|
30
|
+
columns: {
|
|
31
|
+
type: Array,
|
|
32
|
+
default () {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
data: {
|
|
37
|
+
type: Array,
|
|
38
|
+
default () {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
oldData: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default () {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
rowDefault: {
|
|
49
|
+
type: Object,
|
|
50
|
+
default () {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
outObj: {
|
|
56
|
+
type: Object,
|
|
57
|
+
default () {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
propsObj: {
|
|
62
|
+
type: Object,
|
|
63
|
+
default () {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
isShare: Boolean
|
|
68
|
+
},
|
|
69
|
+
model: {
|
|
70
|
+
prop: "data",
|
|
71
|
+
event: "change"
|
|
72
|
+
},
|
|
73
|
+
data () {
|
|
74
|
+
return {
|
|
75
|
+
showRuleMessage: false, // 显示校验文字
|
|
76
|
+
ruleRecordMap: {}
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
computed: {
|
|
80
|
+
tablePropsObj () {
|
|
81
|
+
return {
|
|
82
|
+
maxHeight: this.contentHeight
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
listData () {
|
|
86
|
+
this.data.forEach(item => {
|
|
87
|
+
!item._id && this.$set(item, "_id", this.$ObjectID().str);
|
|
88
|
+
});
|
|
89
|
+
return this.data;
|
|
90
|
+
},
|
|
91
|
+
footerData () {
|
|
92
|
+
let row = { _id: this.$ObjectID().str, custome: "汇总" };
|
|
93
|
+
this.filterColumns.map(col => {
|
|
94
|
+
if (col._type === "number") {
|
|
95
|
+
row[col._key] = this.$calNumList(this.listData.map(item => item[col._key]), col._summaryType, { ...col, _defaultDigit: 2 });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return this.useSummary && this.listData.length ? [row] : [];
|
|
99
|
+
},
|
|
100
|
+
oldListData () {
|
|
101
|
+
this.oldData.forEach(item => {
|
|
102
|
+
!item._id && this.$set(item, "_id", this.$ObjectID().str);
|
|
103
|
+
});
|
|
104
|
+
return this.oldData;
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
selfPropsObj () {
|
|
108
|
+
return {
|
|
109
|
+
_contentHeight: 500,
|
|
110
|
+
_useSelection: false, // 使用选择列
|
|
111
|
+
_useIndex: true, // 使用序号列
|
|
112
|
+
_useSummary: false, // 使用汇总行
|
|
113
|
+
_disabledBtns: false, // 禁用增删按钮
|
|
114
|
+
_disabledCreateBtn: false, // 置灰新增按钮,目前只内部使用,comp_web数据表配置页那块
|
|
115
|
+
_disabledOldDataRow: false, // 置灰老数据行包含删除
|
|
116
|
+
|
|
117
|
+
...this.propsObj
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
contentHeight () {
|
|
121
|
+
return this.selfPropsObj._contentHeight;
|
|
122
|
+
},
|
|
123
|
+
useSelection () {
|
|
124
|
+
return this.selfPropsObj._useSelection;
|
|
125
|
+
},
|
|
126
|
+
useIndex () {
|
|
127
|
+
return this.selfPropsObj._useIndex;
|
|
128
|
+
},
|
|
129
|
+
useSummary () {
|
|
130
|
+
return this.selfPropsObj._useSummary;
|
|
131
|
+
},
|
|
132
|
+
disabledBtns () {
|
|
133
|
+
return this.selfPropsObj._disabledBtns;
|
|
134
|
+
},
|
|
135
|
+
disabledCreateBtn () {
|
|
136
|
+
return this.selfPropsObj._disabledCreateBtn;
|
|
137
|
+
},
|
|
138
|
+
disabledOldDataRow () {
|
|
139
|
+
return this.selfPropsObj._disabledOldDataRow;
|
|
140
|
+
},
|
|
141
|
+
useCampare () {
|
|
142
|
+
return !!this.oldListData.length;
|
|
143
|
+
},
|
|
144
|
+
filterColumns () {
|
|
145
|
+
return this.columns.filter(colItem => colItem._displayType !== "hide" && this.$isAdvRelyShow(colItem, this.outObj));
|
|
146
|
+
},
|
|
147
|
+
showColumns () {
|
|
148
|
+
const operationList = this.$getOperationList(["delete"]);
|
|
149
|
+
const showColumns = [
|
|
150
|
+
...(
|
|
151
|
+
this.useSelection === true
|
|
152
|
+
? [
|
|
153
|
+
{
|
|
154
|
+
field: "selection",
|
|
155
|
+
key: "selection",
|
|
156
|
+
type: "checkbox",
|
|
157
|
+
width: 66,
|
|
158
|
+
align: "center",
|
|
159
|
+
fixed: "left"
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
: []
|
|
163
|
+
),
|
|
164
|
+
|
|
165
|
+
...(
|
|
166
|
+
this.useIndex === true
|
|
167
|
+
? [
|
|
168
|
+
{
|
|
169
|
+
title: "序号",
|
|
170
|
+
field: "custome",
|
|
171
|
+
key: "customes",
|
|
172
|
+
width: 76,
|
|
173
|
+
align: "center",
|
|
174
|
+
fixed: "left",
|
|
175
|
+
renderBodyCell: ({ rowIndex }) => ++rowIndex
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
: []
|
|
179
|
+
),
|
|
180
|
+
|
|
181
|
+
...this.$transformToColumns(this.filterColumns.map(item => ({
|
|
182
|
+
filter: undefined,
|
|
183
|
+
sortBy: undefined,
|
|
184
|
+
renderBodyCell: ({ row, column, rowIndex }, h) => {
|
|
185
|
+
return [
|
|
186
|
+
this.isShowCompare(column, row, this.oldListData[rowIndex])
|
|
187
|
+
? h("Tooltip", {
|
|
188
|
+
class: "td-inner-compare",
|
|
189
|
+
props: {
|
|
190
|
+
content: this.$isEmptyData(this.oldListData[rowIndex][column._key]) ? "" : this.oldListData[rowIndex][column._key],
|
|
191
|
+
transfer: true,
|
|
192
|
+
maxWidth: 200,
|
|
193
|
+
placement: "top"
|
|
194
|
+
},
|
|
195
|
+
scopedSlots: {
|
|
196
|
+
default: props => h("dsh-unit", {
|
|
197
|
+
props: {
|
|
198
|
+
canEdit: this.getUnitCanEdit(column, row),
|
|
199
|
+
parentData: this.listData,
|
|
200
|
+
formData: row,
|
|
201
|
+
formItem: this.resetCol(item),
|
|
202
|
+
isShare: this.isShare,
|
|
203
|
+
rowIndex: rowIndex,
|
|
204
|
+
isUnit: !this.finalCanEdit
|
|
205
|
+
},
|
|
206
|
+
on: {
|
|
207
|
+
blur: () => this.controlBlur(null, column, row, arguments),
|
|
208
|
+
change: () => this.$dispatchEvent(this.operationMap.changeVal, column, row, rowIndex, arguments)
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
: h("dsh-unit", {
|
|
214
|
+
props: {
|
|
215
|
+
canEdit: this.getUnitCanEdit(column, row),
|
|
216
|
+
parentData: this.listData,
|
|
217
|
+
formData: row,
|
|
218
|
+
formItem: this.resetCol(item),
|
|
219
|
+
isShare: this.isShare,
|
|
220
|
+
rowIndex: rowIndex,
|
|
221
|
+
isUnit: !this.finalCanEdit
|
|
222
|
+
},
|
|
223
|
+
on: {
|
|
224
|
+
blur: () => this.controlBlur(null, column, row, arguments),
|
|
225
|
+
change: () => this.$dispatchEvent(this.operationMap.changeVal, column, row, rowIndex, arguments)
|
|
226
|
+
}
|
|
227
|
+
}),
|
|
228
|
+
!this.getRuleResult(column, row).bool &&
|
|
229
|
+
h("span", { class: "table-row-td-tip" }, this.getRuleResult(column, row).message)
|
|
230
|
+
];
|
|
231
|
+
},
|
|
232
|
+
renderHeaderCell: ({ column }, h) => {
|
|
233
|
+
return h("span", [
|
|
234
|
+
column._required && h("i", { style: { color: "#ed4014" } }, "*"),
|
|
235
|
+
h("span", column.title),
|
|
236
|
+
column._description &&
|
|
237
|
+
h("Tooltip", {
|
|
238
|
+
style: { display: "inline-block" },
|
|
239
|
+
props: {
|
|
240
|
+
content: column._description,
|
|
241
|
+
transfer: true,
|
|
242
|
+
maxWidth: 200
|
|
243
|
+
},
|
|
244
|
+
scopedSlots: {
|
|
245
|
+
default: props => h("i", { class: "table-head-description ivu-icon bico-font bico-explain" })
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
]);
|
|
249
|
+
},
|
|
250
|
+
...item
|
|
251
|
+
}))),
|
|
252
|
+
|
|
253
|
+
...(
|
|
254
|
+
this.canEdit && operationList.length
|
|
255
|
+
? [
|
|
256
|
+
{
|
|
257
|
+
title: "操作",
|
|
258
|
+
field: "operation",
|
|
259
|
+
key: "operation",
|
|
260
|
+
align: "center",
|
|
261
|
+
fixed: "right",
|
|
262
|
+
width: 100,
|
|
263
|
+
renderBodyCell: (params, h) => {
|
|
264
|
+
return h("dsh-buttons", {
|
|
265
|
+
props: {
|
|
266
|
+
list: operationList.map(btnItem => ({ ...btnItem, disabled: this.disabledOldDataRow && !params.row.__isCreate__ }))
|
|
267
|
+
},
|
|
268
|
+
on: {
|
|
269
|
+
click: (operationItem) => {
|
|
270
|
+
this.$dispatchEvent(operationItem, params.row, params.index, this.listData);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
: []
|
|
278
|
+
)
|
|
279
|
+
];
|
|
280
|
+
return showColumns;
|
|
281
|
+
},
|
|
282
|
+
selfRowDefault () {
|
|
283
|
+
return this.$filterObj(this.columns, this.rowDefault);
|
|
284
|
+
},
|
|
285
|
+
operationMap () {
|
|
286
|
+
const allOperationMap = {
|
|
287
|
+
create: {
|
|
288
|
+
name: "添加一行",
|
|
289
|
+
type: "create",
|
|
290
|
+
size: "default",
|
|
291
|
+
long: true,
|
|
292
|
+
disabled: !!this.disabledCreateBtn,
|
|
293
|
+
event: "clickCreate",
|
|
294
|
+
btnType: "default"
|
|
295
|
+
},
|
|
296
|
+
delete: {
|
|
297
|
+
name: "删除",
|
|
298
|
+
type: "delete",
|
|
299
|
+
btnType: "errorText",
|
|
300
|
+
icon: "ios-trash-outline",
|
|
301
|
+
size: "small",
|
|
302
|
+
disabled: false,
|
|
303
|
+
event: "clickDelete"
|
|
304
|
+
},
|
|
305
|
+
// expand: {
|
|
306
|
+
// name: "展开",
|
|
307
|
+
// type: "expand",
|
|
308
|
+
// event: "clickExpand"
|
|
309
|
+
// },
|
|
310
|
+
changeVal: {
|
|
311
|
+
name: "改变输入框值",
|
|
312
|
+
type: "changeVal",
|
|
313
|
+
event: "changeVal"
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
return this.canEdit
|
|
318
|
+
? this.$categoryMapToMap(
|
|
319
|
+
allOperationMap,
|
|
320
|
+
null,
|
|
321
|
+
this.disabledBtns ? ["create", "delete"] : []
|
|
322
|
+
)
|
|
323
|
+
: {};
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
created () {
|
|
327
|
+
},
|
|
328
|
+
methods: {
|
|
329
|
+
// 共外部使用
|
|
330
|
+
validate () {
|
|
331
|
+
this.showRuleMessage = true;
|
|
332
|
+
|
|
333
|
+
return this.listData.every(dataItem =>
|
|
334
|
+
this.filterColumns.every(col => this.getRuleResult(col, dataItem, true).bool)
|
|
335
|
+
);
|
|
336
|
+
},
|
|
337
|
+
// 点击 -添加行
|
|
338
|
+
clickCreate (operationItem, row, index, list) {
|
|
339
|
+
const newRow = {
|
|
340
|
+
...this.$deepCopy(this.selfRowDefault),
|
|
341
|
+
__isCreate__: true,
|
|
342
|
+
_id: this.$ObjectID().str
|
|
343
|
+
};
|
|
344
|
+
const newRowIndex = index == null ? list.length : index + 1;
|
|
345
|
+
list.splice(newRowIndex, 0, newRow);
|
|
346
|
+
|
|
347
|
+
this.$forceUpdate(); // 自定义页中点击添加一行没有更新页面
|
|
348
|
+
|
|
349
|
+
this.change("createRow", null, newRow, newRowIndex);
|
|
350
|
+
},
|
|
351
|
+
// 点击 -删除行
|
|
352
|
+
clickDelete (operationItem, row, rowIndex, list) {
|
|
353
|
+
this.$Modal.confirm({
|
|
354
|
+
title: "警告",
|
|
355
|
+
content: "确定删除吗?",
|
|
356
|
+
onOk: () => {
|
|
357
|
+
list.splice(rowIndex, 1);
|
|
358
|
+
|
|
359
|
+
this.change("deleteRow", null, row, rowIndex);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
changeSelect (list) {
|
|
364
|
+
this.$emit("selectChange", list);
|
|
365
|
+
},
|
|
366
|
+
// 表单控件值改变
|
|
367
|
+
changeVal (operationItem, col, row, rowIndex, params) {
|
|
368
|
+
this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
|
|
369
|
+
|
|
370
|
+
this.change("changeVal", col, row, rowIndex, ...params);
|
|
371
|
+
},
|
|
372
|
+
// 表单控件失去焦点
|
|
373
|
+
controlBlur (operationItem, col, row, params) {
|
|
374
|
+
this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
|
|
375
|
+
},
|
|
376
|
+
change (...params) {
|
|
377
|
+
this.$emit("change", { list: this.listData, rowDefault: this.rowDefault }, ...params);
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
/* --------------- 工具方法 ------------- */
|
|
381
|
+
resetCol (col) {
|
|
382
|
+
let obj = {
|
|
383
|
+
select: {
|
|
384
|
+
_optionKind: "dropdown"
|
|
385
|
+
},
|
|
386
|
+
checkbox: {
|
|
387
|
+
_optionKind: "dropdown"
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
return { ...col, ...(obj[col._type] || {}) };
|
|
391
|
+
},
|
|
392
|
+
getUnitCanEdit (col, row) {
|
|
393
|
+
return this.canEdit && // 是否是编辑状态
|
|
394
|
+
// (!this.disabledOldDataRow || !!this.createRowMap[row._id]) && // 是否让老数据行置灰
|
|
395
|
+
(!this.disabledOldDataRow || !!row.__isCreate__) && // 是否让老数据行置灰
|
|
396
|
+
(!col.dependRowCanEdit || row.canEdit !== false); // 在老数据行里某些列不可编辑
|
|
397
|
+
},
|
|
398
|
+
isShowCompare (col, row, oldRow = {}) {
|
|
399
|
+
return this.useCampare && ["number"].includes(col._type) &&
|
|
400
|
+
!(this.$isEmptyData(row[col._key]) && this.$isEmptyData(oldRow[col._key])) &&
|
|
401
|
+
row[col._key] !== oldRow[col._key];
|
|
402
|
+
},
|
|
403
|
+
// 是否显示 单元格校验提示文字
|
|
404
|
+
getRuleResult (col, row, showRuleMessage = this.showRuleMessage) {
|
|
405
|
+
if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || showRuleMessage) {
|
|
406
|
+
const val = row[col._key];
|
|
407
|
+
const ruleConfig = this.$getFormTypeRuleConfig(col);
|
|
408
|
+
// 为空 校验必填;不为空 格式校验 (不是必填也要校验格式)
|
|
409
|
+
return this.$isEmptyData(val)
|
|
410
|
+
? {
|
|
411
|
+
bool: !col._required,
|
|
412
|
+
message: `${col._name}为必填项`
|
|
413
|
+
}
|
|
414
|
+
: ruleConfig.regs && ruleConfig.regs.length
|
|
415
|
+
? {
|
|
416
|
+
bool: ruleConfig.regs.every(regItem => regItem.test(val)),
|
|
417
|
+
message: col.regMessage || `${col._name}格式不正确`
|
|
418
|
+
}
|
|
419
|
+
: {
|
|
420
|
+
bool: true
|
|
421
|
+
};
|
|
422
|
+
} else {
|
|
423
|
+
return {
|
|
424
|
+
bool: true
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
</script>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="bri-table">
|
|
3
|
+
<ve-table
|
|
4
|
+
class="bri-table-content"
|
|
5
|
+
:class="[selfClassName, selfPropsObj.className]"
|
|
6
|
+
:table-data="data"
|
|
7
|
+
:footer-data="footerData"
|
|
8
|
+
:columns="columnsList"
|
|
9
|
+
:show-header="selfPropsObj.showHeader"
|
|
10
|
+
:fixed-header="selfPropsObj.fixedHeader"
|
|
11
|
+
:fixed-footer="selfPropsObj.fixedFooter"
|
|
12
|
+
:scroll-width="selfPropsObj.scrollWidth"
|
|
13
|
+
:max-height="selfPropsObj.maxHeight"
|
|
14
|
+
:row-key-field-name="selfPropsObj.rowKeyFieldName"
|
|
15
|
+
:border-around="selfPropsObj.borderAround"
|
|
16
|
+
:border-x="selfPropsObj.borderX"
|
|
17
|
+
:border-y="selfPropsObj.borderY"
|
|
18
|
+
:cellSpanOption="selfPropsObj.cellSpanOption"
|
|
19
|
+
:columnHiddenOption="selfPropsObj.columnHiddenOption"
|
|
20
|
+
:cellStyleOption="cellStyleOption"
|
|
21
|
+
:rowStyleOption="rowStyleOption"
|
|
22
|
+
:expandOption="selfPropsObj.expandOption"
|
|
23
|
+
:checkbox-option="checkboxOption"
|
|
24
|
+
:radioOption="selfPropsObj.radioOption"
|
|
25
|
+
:sortOption="sortOption"
|
|
26
|
+
:cellSelectionOption="selfPropsObj.cellSelectionOption"
|
|
27
|
+
:editOption="selfPropsObj.editOption"
|
|
28
|
+
:contextmenuHeaderOption="selfPropsObj.contextmenuHeaderOption"
|
|
29
|
+
:contextmenuBodyOption="selfPropsObj.contextmenuBodyOption"
|
|
30
|
+
:event-custom-option="eventCustomOption"
|
|
31
|
+
:cellAutofillOption="selfPropsObj.cellAutofillOption"
|
|
32
|
+
:clipboardOption="selfPropsObj.clipboardOption"
|
|
33
|
+
:columnWidthResizeOption="columnWidthResizeOption"
|
|
34
|
+
></ve-table>
|
|
35
|
+
<!-- loading -->
|
|
36
|
+
<div v-if="isLoading" class="bri-table-empty bri-table-loading">
|
|
37
|
+
<slot name="loading">正在加载中,请稍后...</slot>
|
|
38
|
+
</div>
|
|
39
|
+
<!-- empty -->
|
|
40
|
+
<div v-else-if="!data.length" class="bri-table-empty">
|
|
41
|
+
<slot name="empty">{{ noDataText }}</slot>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
export default {
|
|
48
|
+
name: "BriTable",
|
|
49
|
+
props: {
|
|
50
|
+
propsObj: {
|
|
51
|
+
type: Object,
|
|
52
|
+
default () {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
isLoading: Boolean,
|
|
57
|
+
noDataText: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: "暂无数据"
|
|
60
|
+
},
|
|
61
|
+
columns: Array,
|
|
62
|
+
data: Array,
|
|
63
|
+
footerData: Array
|
|
64
|
+
},
|
|
65
|
+
data () {
|
|
66
|
+
// 中文文档https://happy-coding-clans.github.io/vue-easytable/#/zh/doc/table/api
|
|
67
|
+
return {
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
computed: {
|
|
71
|
+
selfPropsObj () {
|
|
72
|
+
return {
|
|
73
|
+
rowKeyFieldName: "_id",
|
|
74
|
+
scrollWidth: "0",
|
|
75
|
+
borderY: true,
|
|
76
|
+
cellSelectionOption: {
|
|
77
|
+
enable: false
|
|
78
|
+
},
|
|
79
|
+
...this.propsObj
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
columnsList () {
|
|
83
|
+
return this.columns;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
// 当前表格状态
|
|
87
|
+
currentState () {
|
|
88
|
+
return this.propsObj.state || this.state;
|
|
89
|
+
},
|
|
90
|
+
selfClassName () {
|
|
91
|
+
if (this.loading || !this.data.length) {
|
|
92
|
+
return "bri-table-onlyhead";
|
|
93
|
+
} else {
|
|
94
|
+
return "";
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
rowStyleOption () {
|
|
99
|
+
return {
|
|
100
|
+
clickHighlight: false,
|
|
101
|
+
...(this.propsObj.rowStyleOption || {})
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
cellStyleOption () {
|
|
106
|
+
return {
|
|
107
|
+
headerCellClass: () => {
|
|
108
|
+
return "bri-table-th";
|
|
109
|
+
},
|
|
110
|
+
bodyCellClass: ({rowIndex}) => {
|
|
111
|
+
return "bri-table-td";
|
|
112
|
+
},
|
|
113
|
+
...(this.propsObj.cellStyleOption || {})
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
// 自定义表格事件,也可配置鼠标事件
|
|
117
|
+
eventCustomOption () {
|
|
118
|
+
return {
|
|
119
|
+
bodyRowEvents: ({ row, rowIndex }) => {
|
|
120
|
+
return {
|
|
121
|
+
click: (event) => {
|
|
122
|
+
this.$emit("click-row", row, rowIndex, event);
|
|
123
|
+
},
|
|
124
|
+
dblclick: (event) => {
|
|
125
|
+
this.$emit("db-click-row", row, rowIndex, event);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
...(this.propsObj.eventCustomOption || {})
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
// 全选配置项
|
|
133
|
+
checkboxOption () {
|
|
134
|
+
return {
|
|
135
|
+
// 行选择改变事件
|
|
136
|
+
selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
|
|
137
|
+
this.$emit(
|
|
138
|
+
"selectChange",
|
|
139
|
+
this.data.filter(dataItem => selectedRowKeys.includes(dataItem[this.selfPropsObj.rowKeyFieldName])),
|
|
140
|
+
{ row, isSelected, selectedRowKeys }
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
// 全选改变事件
|
|
144
|
+
selectedAllChange: ({ isSelected, selectedRowKeys }) => {
|
|
145
|
+
this.$emit(
|
|
146
|
+
"selectAll",
|
|
147
|
+
this.data.filter(dataItem => selectedRowKeys.includes(dataItem[this.selfPropsObj.rowKeyFieldName])),
|
|
148
|
+
{ isSelected, selectedRowKeys }
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
...(this.propsObj.checkboxOption || {})
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
// 列宽改变设置项
|
|
155
|
+
columnWidthResizeOption () {
|
|
156
|
+
return {
|
|
157
|
+
enable: true,
|
|
158
|
+
minWidth: 80,
|
|
159
|
+
sizeChange: ({ column, differWidth, columnWidth }) => {
|
|
160
|
+
this.$emit("size-change", column, differWidth, columnWidth);
|
|
161
|
+
},
|
|
162
|
+
...(this.propsObj.columnWidthResizeOption || {})
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
sortOption () {
|
|
166
|
+
return {
|
|
167
|
+
sortChange: (params) => {
|
|
168
|
+
let sortObj =
|
|
169
|
+
Object.keys(params)
|
|
170
|
+
.filter(attr => !!params[attr])
|
|
171
|
+
.reduce((obj, attr) => {
|
|
172
|
+
return { sortType: params[attr], field: attr };
|
|
173
|
+
}, {});
|
|
174
|
+
this.$emit("sort-change", sortObj);
|
|
175
|
+
},
|
|
176
|
+
...(this.propsObj.sortOption || {})
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
mounted () {
|
|
181
|
+
},
|
|
182
|
+
methods: {}
|
|
183
|
+
};
|
|
184
|
+
</script>
|