cnhis-design-vue 2.1.17 → 2.1.18
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/CHANGELOG.md +2219 -2219
- package/es/affix/index.js +8 -8
- package/es/age/index.js +10 -10
- package/es/alert/index.js +8 -8
- package/es/anchor/index.js +8 -8
- package/es/auto-complete/index.js +8 -8
- package/es/avatar/index.js +8 -8
- package/es/back-top/index.js +8 -8
- package/es/badge/index.js +8 -8
- package/es/base/index.js +8 -8
- package/es/big-table/index.js +164 -164
- package/es/breadcrumb/index.js +8 -8
- package/es/button/index.js +32 -32
- package/es/calendar/index.js +8 -8
- package/es/captcha/index.js +3 -3
- package/es/card/index.js +8 -8
- package/es/carousel/index.js +8 -8
- package/es/cascader/index.js +8 -8
- package/es/checkbox/index.js +9 -9
- package/es/col/index.js +8 -8
- package/es/collapse/index.js +8 -8
- package/es/color-picker/index.js +1 -1
- package/es/comment/index.js +8 -8
- package/es/config-provider/index.js +8 -8
- package/es/date-picker/index.js +8 -8
- package/es/descriptions/index.js +8 -8
- package/es/divider/index.js +8 -8
- package/es/drag-layout/index.js +3 -3
- package/es/drawer/index.js +8 -8
- package/es/dropdown/index.js +8 -8
- package/es/editor/index.js +1 -1
- package/es/empty/index.js +8 -8
- package/es/fabric-chart/index.js +34 -34
- package/es/form/index.js +8 -8
- package/es/form-model/index.js +8 -8
- package/es/form-table/index.js +62 -62
- package/es/index/index.js +672 -657
- package/es/index/style.css +1 -1
- package/es/input/index.js +9 -9
- package/es/input-number/index.js +8 -8
- package/es/layout/index.js +8 -8
- package/es/list/index.js +8 -8
- package/es/locale-provider/index.js +8 -8
- package/es/map/index.js +9 -9
- package/es/mentions/index.js +8 -8
- package/es/menu/index.js +8 -8
- package/es/message/index.js +8 -8
- package/es/multi-chat/index.js +92 -92
- package/es/multi-chat-client/index.js +86 -86
- package/es/multi-chat-history/index.js +4 -4
- package/es/multi-chat-record/index.js +14 -14
- package/es/multi-chat-setting/index.js +81 -66
- package/es/multi-chat-setting/style.css +1 -1
- package/es/multi-chat-sip/index.js +1 -1
- package/es/notification/index.js +8 -8
- package/es/page-header/index.js +8 -8
- package/es/pagination/index.js +8 -8
- package/es/popconfirm/index.js +8 -8
- package/es/popover/index.js +8 -8
- package/es/progress/index.js +8 -8
- package/es/radio/index.js +9 -9
- package/es/rate/index.js +8 -8
- package/es/result/index.js +8 -8
- package/es/row/index.js +8 -8
- package/es/scale-view/index.js +33 -33
- package/es/select/index.js +11 -11
- package/es/select-label/index.js +11 -11
- package/es/select-person/index.js +20 -20
- package/es/skeleton/index.js +8 -8
- package/es/slider/index.js +8 -8
- package/es/space/index.js +8 -8
- package/es/spin/index.js +8 -8
- package/es/statistic/index.js +8 -8
- package/es/steps/index.js +8 -8
- package/es/switch/index.js +8 -8
- package/es/table-filter/index.js +118 -118
- package/es/tabs/index.js +8 -8
- package/es/tag/index.js +9 -9
- package/es/time-picker/index.js +8 -8
- package/es/timeline/index.js +8 -8
- package/es/tooltip/index.js +8 -8
- package/es/transfer/index.js +8 -8
- package/es/tree/index.js +8 -8
- package/es/tree-select/index.js +8 -8
- package/es/upload/index.js +8 -8
- package/es/verification-code/index.js +2 -2
- package/lib/cui.common.js +620 -605
- package/lib/cui.umd.js +620 -605
- package/lib/cui.umd.min.js +71 -71
- package/package.json +106 -106
- package/packages/big-table/src/BigTable.vue +3038 -3038
- package/packages/big-table/src/assets/style/table-base.less +370 -370
- package/packages/big-table/src/components/AutoLayoutButton.vue +270 -270
- package/packages/big-table/src/utils/batchEditing.js +610 -610
- package/packages/big-table/src/utils/bigTableProps.js +95 -95
- package/packages/button/src/ButtonPrint/components/IdentityVerification.vue +181 -181
- package/packages/button/src/ButtonPrint/index.vue +728 -728
- package/packages/button/src/ButtonPrint/js/print.es.min.js +1 -1
- package/packages/fabric-chart/src/components/TimeScaleValue.vue +117 -117
- package/packages/fabric-chart/src/const/defaultVaule.js +59 -59
- package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +960 -960
- package/packages/fabric-chart/src/fabric-chart/FabricScaleValue.vue +135 -135
- package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +558 -558
- package/packages/fabric-chart/src/fabric-chart2/FabricTop.vue +172 -172
- package/packages/multi-chat/chat/chatFooter.vue +1598 -1598
- package/packages/multi-chat/chat/chatMain.vue +1442 -1442
- package/packages/multi-chat/chat/quickReply.vue +439 -439
- package/packages/multi-chat/chat/scrollList.vue +1232 -1232
- package/packages/multi-chat/setting/baseInfo/index.vue +1316 -1302
- package/packages/multi-chat/store/actions.js +448 -448
- package/packages/multi-chat/store/state.js +112 -112
- package/packages/scale-view/formitem/r-choice.vue +714 -714
- package/packages/scale-view/scaleView.vue +2010 -2010
- package/packages/select-person/select-person.vue +1658 -1658
- package/packages/table-filter/src/base-search-com/BaseSearch.vue +2462 -2462
- package/packages/table-filter/src/components/c-tree-select/tree-select.vue +336 -336
- package/packages/table-filter/src/components/multi-select/multi-select.vue +219 -219
- package/packages/table-filter/src/components/out-quick-search/out-quick-search.vue +340 -340
- package/packages/table-filter/src/const/dataOptions.js +43 -43
- package/packages/table-filter/src/mixins/mixins.js +695 -695
- package/packages/table-filter/src/quick-search/QuickSearch.vue +2083 -2083
- package/src/directive/preventReClick.js +12 -12
|
@@ -1,610 +1,610 @@
|
|
|
1
|
-
// import { mapMutations, mapActions } from "vuex";
|
|
2
|
-
import utils from '@/utils/utils-map';
|
|
3
|
-
export default {
|
|
4
|
-
props: {
|
|
5
|
-
// 曾经的getters
|
|
6
|
-
isBatchEditing: Boolean,
|
|
7
|
-
isEditAllRow: Boolean,
|
|
8
|
-
isBatchSave: Boolean,
|
|
9
|
-
isBatchCancel: Boolean,
|
|
10
|
-
batchDynamicPropsCache: { type: Object, default: () => ({}) },
|
|
11
|
-
batchEditDoneNumber: { type: Object, default: () => ({}) },
|
|
12
|
-
batchError: Boolean,
|
|
13
|
-
batchFormData: { type: Object, default: () => ({}) },
|
|
14
|
-
|
|
15
|
-
// 曾经的mapActions
|
|
16
|
-
resetInlineBatchEdit: Function,
|
|
17
|
-
resetBatchEditRowStatus: Function
|
|
18
|
-
},
|
|
19
|
-
data() {
|
|
20
|
-
return {
|
|
21
|
-
cacheUniqueKey: {},
|
|
22
|
-
theUniqueKeyListObj: {},
|
|
23
|
-
batchFieldList: [],
|
|
24
|
-
editColumnMap: {},
|
|
25
|
-
fieldLength: 0,
|
|
26
|
-
originFormatList: [],
|
|
27
|
-
isSaveForm: false,
|
|
28
|
-
isLoadData: false,
|
|
29
|
-
isLoadColumn: false,
|
|
30
|
-
addInlineEditPrimaryKey: ''
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
computed: {
|
|
34
|
-
configuration() {
|
|
35
|
-
return {
|
|
36
|
-
userInfo: this.userInfo || {},
|
|
37
|
-
sysImageSize: this.sysImageSize || {},
|
|
38
|
-
switchConfig: this.switchConfig || {},
|
|
39
|
-
hospitalConfigData: this.iconObj || {}
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
tableLoad() {
|
|
43
|
-
return {
|
|
44
|
-
isLoadData: this.isLoadData,
|
|
45
|
-
isLoadColumn: this.isLoadColumn
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
isTableEdit() {
|
|
49
|
-
return this.isInlineOperating || this.isInlineAdding;
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
watch: {
|
|
53
|
-
tableLoad(obj) {
|
|
54
|
-
if (!obj) return;
|
|
55
|
-
let { isLoadData, isLoadColumn } = obj;
|
|
56
|
-
if (!(isLoadData && isLoadColumn)) return;
|
|
57
|
-
if (this.isBatchEditing) return;
|
|
58
|
-
this.$emit('tableLoad', true);
|
|
59
|
-
},
|
|
60
|
-
/**
|
|
61
|
-
* 编辑
|
|
62
|
-
*/
|
|
63
|
-
async isBatchEditing(val) {
|
|
64
|
-
if (!val || this.isNestTable) return false;
|
|
65
|
-
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
66
|
-
if (!this.checkOperateCurrentTable()) {
|
|
67
|
-
this.resetBatchOperationRowStatus();
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
// 非行内按钮触发
|
|
71
|
-
if (!this.isRowEditing) {
|
|
72
|
-
await this.toggleColumn();
|
|
73
|
-
}
|
|
74
|
-
this.hideSelectCloumns();
|
|
75
|
-
this.handleClickBatchEditBtnByInline();
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* 保存
|
|
79
|
-
*/
|
|
80
|
-
isBatchSave(val) {
|
|
81
|
-
if (!val || this.isNestTable) return false;
|
|
82
|
-
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
83
|
-
if (!this.checkOperateCurrentTable()) return false;
|
|
84
|
-
this.handleClickBatchSaveBtnByInline();
|
|
85
|
-
},
|
|
86
|
-
/**
|
|
87
|
-
* 取消
|
|
88
|
-
*/
|
|
89
|
-
async isBatchCancel(val) {
|
|
90
|
-
if (!val || this.isNestTable) return false;
|
|
91
|
-
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
92
|
-
if (!this.checkOperateCurrentTable()) return false;
|
|
93
|
-
await this.toggleColumn('showColumn');
|
|
94
|
-
this.handleClickBatchCancelBtnByInline();
|
|
95
|
-
},
|
|
96
|
-
/**
|
|
97
|
-
* 校验提交
|
|
98
|
-
*/
|
|
99
|
-
batchEditDoneNumber(obj) {
|
|
100
|
-
if (!obj || !Object.keys(obj).length || this.isNestTable) return;
|
|
101
|
-
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
102
|
-
if (!this.checkOperateCurrentTable()) return false;
|
|
103
|
-
this.submitBatchInlineForm(obj);
|
|
104
|
-
},
|
|
105
|
-
async isInlineAdding(val) {
|
|
106
|
-
if (!val || this.isNestTable) return false;
|
|
107
|
-
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
108
|
-
if (!this.checkOperateCurrentTable()) {
|
|
109
|
-
this.resetBatchOperationRowStatus();
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
await this.toggleColumn();
|
|
113
|
-
this.hideSelectCloumns();
|
|
114
|
-
this.handleClickAddRow();
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
methods: {
|
|
118
|
-
toggleColumn(key) {
|
|
119
|
-
let method = key || 'hideColumn';
|
|
120
|
-
const xGrid = this.$refs.xGrid;
|
|
121
|
-
if (!xGrid) return Promise.resolve();
|
|
122
|
-
let operate = xGrid.getColumnByField('operatorColumn');
|
|
123
|
-
if (method === 'showColumn' && operate.visible) {
|
|
124
|
-
return Promise.resolve();
|
|
125
|
-
}
|
|
126
|
-
return xGrid[method](operate);
|
|
127
|
-
},
|
|
128
|
-
/**
|
|
129
|
-
* 获取配置的 api 方法
|
|
130
|
-
* @param {*} params 调用参数
|
|
131
|
-
* @param {String} key 方法名
|
|
132
|
-
* @param {Object} config 其他配置
|
|
133
|
-
*/
|
|
134
|
-
async handleGetConfigApi(params, key, config = {}) {
|
|
135
|
-
try {
|
|
136
|
-
// TODO: 判断 fn 是异步函数还是同步
|
|
137
|
-
const editFormApiConfig = this?.editFormApiConfig || {};
|
|
138
|
-
const fn = editFormApiConfig[key] || null;
|
|
139
|
-
if (typeof fn === 'function') {
|
|
140
|
-
let res = await fn(params, config);
|
|
141
|
-
return Promise.resolve(res);
|
|
142
|
-
} else {
|
|
143
|
-
return Promise.reject(new Error(`${key} Is not a function`));
|
|
144
|
-
}
|
|
145
|
-
} catch (error) {
|
|
146
|
-
return Promise.reject(error);
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
/**
|
|
150
|
-
* 设置row 为编辑样式
|
|
151
|
-
*/
|
|
152
|
-
getBatchOpreateRows(arr) {
|
|
153
|
-
let vxeTable = this.$refs.xGrid;
|
|
154
|
-
let { tableData } = vxeTable.getTableData();
|
|
155
|
-
if (!arr.length) return;
|
|
156
|
-
// 重置状态时使用
|
|
157
|
-
|
|
158
|
-
arr.forEach((item, i) => {
|
|
159
|
-
let rowIndex = i;
|
|
160
|
-
if (!this.isEditAllRow) {
|
|
161
|
-
let matchIndex = tableData.findIndex(v => v[this.primaryKey] == item[this.primaryKey]);
|
|
162
|
-
if (matchIndex > -1) {
|
|
163
|
-
rowIndex = matchIndex;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
this.setRowStatus(vxeTable.$el, rowIndex, 66);
|
|
167
|
-
this.$set(item, '__isInlineEditing', true);
|
|
168
|
-
});
|
|
169
|
-
},
|
|
170
|
-
/**
|
|
171
|
-
* 重置样式
|
|
172
|
-
* @param {*} isCancel 保存之后
|
|
173
|
-
* @returns
|
|
174
|
-
*/
|
|
175
|
-
resetBatchOperationRowStatus(isResetColumn) {
|
|
176
|
-
if (this.isTree != 0) return false;
|
|
177
|
-
|
|
178
|
-
const vxeTable = this.$refs.xGrid;
|
|
179
|
-
let { tableData } = vxeTable.getTableData();
|
|
180
|
-
vxeTable.clearActived();
|
|
181
|
-
vxeTable.resetColumn();
|
|
182
|
-
tableData.forEach((row, index) => {
|
|
183
|
-
this.setRowStatus(vxeTable.$el, index, null);
|
|
184
|
-
this.$set(row, '__isInlineEditing', false);
|
|
185
|
-
this.$set(row, '__isDisableInlineEdit', false);
|
|
186
|
-
});
|
|
187
|
-
this.checkedRows = [];
|
|
188
|
-
},
|
|
189
|
-
async handleClickAddRow() {
|
|
190
|
-
if (!this.checkListFormUnionSettingParamsList()) {
|
|
191
|
-
this.handleClickCancelBtnByInline();
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
this.addInlineEditPrimaryKey = Date.now();
|
|
195
|
-
let formData = {
|
|
196
|
-
[this.handleRowId]: this.addInlineEditPrimaryKey,
|
|
197
|
-
__isInsertRow: true
|
|
198
|
-
};
|
|
199
|
-
let vxeTable = this.$refs.xGrid;
|
|
200
|
-
await vxeTable.insert(formData);
|
|
201
|
-
await vxeTable.loadData([formData]);
|
|
202
|
-
await this.resetInlineBatchEdit();
|
|
203
|
-
|
|
204
|
-
this.setAllRowInlineStatus(true);
|
|
205
|
-
this.setRowStatus(vxeTable.$el, 0, 66);
|
|
206
|
-
},
|
|
207
|
-
/**
|
|
208
|
-
* 批量编辑
|
|
209
|
-
*/
|
|
210
|
-
async handleClickBatchEditBtnByInline() {
|
|
211
|
-
if (!this.checkListFormUnionSettingParamsList()) {
|
|
212
|
-
this.handleClickCancelBtnByInline();
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
let vxeTable = this.$refs.xGrid;
|
|
216
|
-
let arr = this.checkedRows;
|
|
217
|
-
let { tableData } = vxeTable.getTableData();
|
|
218
|
-
// 全部行编辑
|
|
219
|
-
if (this.isEditAllRow) {
|
|
220
|
-
arr = tableData;
|
|
221
|
-
}
|
|
222
|
-
await vxeTable.loadData(arr);
|
|
223
|
-
await this.resetInlineBatchEdit();
|
|
224
|
-
|
|
225
|
-
this.setAllRowInlineStatus(true);
|
|
226
|
-
this.getBatchOpreateRows(arr);
|
|
227
|
-
},
|
|
228
|
-
/**
|
|
229
|
-
* 批量保存
|
|
230
|
-
*/
|
|
231
|
-
handleClickBatchSaveBtnByInline() {
|
|
232
|
-
if (this.spinning) return false;
|
|
233
|
-
this.$emit('resetBatchEditDoneStatus');
|
|
234
|
-
|
|
235
|
-
let formDom = document.querySelectorAll('.js-inlineEditForm');
|
|
236
|
-
let filterFormDom = [];
|
|
237
|
-
[...formDom].map(item => {
|
|
238
|
-
let pNode = item.parentNode?.parentNode;
|
|
239
|
-
if (pNode) {
|
|
240
|
-
if (pNode.classList.contains('vxe-body--column') && !pNode.classList.contains('fixed--hidden')) {
|
|
241
|
-
filterFormDom.push(item);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
if (!filterFormDom.length) return false;
|
|
246
|
-
// // HACK: vxeTable行内编辑时复制的DOM节点,无需触发提交
|
|
247
|
-
filterFormDom.forEach(item => {
|
|
248
|
-
item.__vue__.handleSubmitForm();
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
/**
|
|
252
|
-
* 处理需要submit的form个数
|
|
253
|
-
*/
|
|
254
|
-
handleEditFormLength() {
|
|
255
|
-
let fieldLength = this.batchFieldList.length;
|
|
256
|
-
if (!fieldLength) return;
|
|
257
|
-
// 新增
|
|
258
|
-
if (this.isInlineAdding) {
|
|
259
|
-
return fieldLength;
|
|
260
|
-
}
|
|
261
|
-
let vxeTable = this.$refs.xGrid;
|
|
262
|
-
let rowLen = this.allSelectedLength;
|
|
263
|
-
let { tableData } = vxeTable.getTableData();
|
|
264
|
-
// 全部行
|
|
265
|
-
if (this.isEditAllRow) {
|
|
266
|
-
rowLen = tableData.length;
|
|
267
|
-
}
|
|
268
|
-
if (!rowLen) return;
|
|
269
|
-
return fieldLength * rowLen;
|
|
270
|
-
},
|
|
271
|
-
async handleClickBatchCancelBtnByInline() {
|
|
272
|
-
let vxeTable = this.$refs.xGrid;
|
|
273
|
-
this.isSaveForm = false;
|
|
274
|
-
this.$emit('resetInlineEditAll', false);
|
|
275
|
-
await vxeTable.reloadData(this.originFormatList);
|
|
276
|
-
this.resetBatchOperationRowStatus(true);
|
|
277
|
-
},
|
|
278
|
-
/**
|
|
279
|
-
* 避免每次点击都查询
|
|
280
|
-
* 初始化查一次 行编辑 表单search用
|
|
281
|
-
*/
|
|
282
|
-
// 避免每次点击都查询
|
|
283
|
-
async handleFormTheUniqueKey() {
|
|
284
|
-
let hasEditRow = this.btnList?.find(item => {
|
|
285
|
-
let trigger_type = item.settingObj && item.settingObj[0]?.trigger_type;
|
|
286
|
-
if (item.isShow == 1 && trigger_type == 'EDIT_ROW') return true;
|
|
287
|
-
return false;
|
|
288
|
-
});
|
|
289
|
-
if (!hasEditRow) return;
|
|
290
|
-
await this.handleFieldTheUniqueKey();
|
|
291
|
-
},
|
|
292
|
-
/**
|
|
293
|
-
* 获取编辑的field
|
|
294
|
-
*/
|
|
295
|
-
handleFieldTheUniqueKey() {
|
|
296
|
-
return new Promise((resolve, reject) => {
|
|
297
|
-
let { paramsList = [] } = this.listFormUnionSetting || {};
|
|
298
|
-
let { fieldList = [] } = this.inlineEditFormConfig || {};
|
|
299
|
-
fieldList = JSON.parse(JSON.stringify(fieldList));
|
|
300
|
-
this.batchFieldList = [];
|
|
301
|
-
let batchFieldList = [];
|
|
302
|
-
batchFieldList = fieldList
|
|
303
|
-
.map(item => {
|
|
304
|
-
let matchItem = paramsList.find(v => item.val_key === v.tableField);
|
|
305
|
-
if (matchItem) {
|
|
306
|
-
let NOWORDBOOK = item.wordbook && (item?.wordbook?.type || '') != 'WORDBOOK';
|
|
307
|
-
let id = item.wordbook?.id;
|
|
308
|
-
if (NOWORDBOOK && id && !this.theUniqueKeyListObj[id]) {
|
|
309
|
-
this.theUniqueKeyListObj[id] = id;
|
|
310
|
-
}
|
|
311
|
-
return item;
|
|
312
|
-
}
|
|
313
|
-
return null;
|
|
314
|
-
})
|
|
315
|
-
.filter(Boolean);
|
|
316
|
-
if (!batchFieldList || !batchFieldList.length) return resolve();
|
|
317
|
-
// 缓存行编辑需要的column配置
|
|
318
|
-
this.editColumnMap = this.handleColumnMap(batchFieldList, paramsList);
|
|
319
|
-
this.batchFieldList = batchFieldList;
|
|
320
|
-
this.fieldLength = this.handleFieldLength();
|
|
321
|
-
let keyList = Object.keys(this.theUniqueKeyListObj || {});
|
|
322
|
-
if (!keyList.length) return resolve();
|
|
323
|
-
keyList.forEach(async item => {
|
|
324
|
-
await this.handleRequestedUniqueKey(item);
|
|
325
|
-
});
|
|
326
|
-
resolve();
|
|
327
|
-
});
|
|
328
|
-
},
|
|
329
|
-
handleColumnMap(batchFieldList, paramsList) {
|
|
330
|
-
let { fieldList = [] } = this.columnConfig;
|
|
331
|
-
let editColumnMap = {};
|
|
332
|
-
fieldList.forEach(item => {
|
|
333
|
-
if (item.isShow != 1 || item.isEdit != 1) return;
|
|
334
|
-
let matchItem = paramsList.find(v => v.tableField === item.columnName);
|
|
335
|
-
if (!matchItem) return;
|
|
336
|
-
let fieldItem = batchFieldList?.find(field => {
|
|
337
|
-
return field.val_key === matchItem.tableField;
|
|
338
|
-
});
|
|
339
|
-
if (!fieldItem) return;
|
|
340
|
-
fieldItem = this.formatFieldItem(fieldItem);
|
|
341
|
-
let obj = {
|
|
342
|
-
columnName: item.columnName,
|
|
343
|
-
matchItem,
|
|
344
|
-
fieldItem
|
|
345
|
-
};
|
|
346
|
-
editColumnMap[item.columnName] = obj;
|
|
347
|
-
});
|
|
348
|
-
return editColumnMap;
|
|
349
|
-
},
|
|
350
|
-
async handleRequestedUniqueKey(id) {
|
|
351
|
-
let handleEditFormRequestedUniqueKey = this.editFormApiConfig?.handleEditFormRequestedUniqueKey;
|
|
352
|
-
if (!handleEditFormRequestedUniqueKey || typeof handleEditFormRequestedUniqueKey !== 'function') {
|
|
353
|
-
handleEditFormRequestedUniqueKey = this.getPrimaryKeyRequest;
|
|
354
|
-
}
|
|
355
|
-
return handleEditFormRequestedUniqueKey({ tableId: id }).then(val => {
|
|
356
|
-
val && (this.cacheUniqueKey[id] = { value: val, status: true });
|
|
357
|
-
});
|
|
358
|
-
},
|
|
359
|
-
getPrimaryKeyRequest(params) {
|
|
360
|
-
return new Promise((resolve, reject) => {
|
|
361
|
-
this.axios
|
|
362
|
-
.get('tableList/getPrimaryKey', { params })
|
|
363
|
-
.then(({ data }) => {
|
|
364
|
-
let result;
|
|
365
|
-
if (data.result == 'SUCCESS') {
|
|
366
|
-
const { map = {} } = data;
|
|
367
|
-
result = map.primaryKey || undefined;
|
|
368
|
-
} else {
|
|
369
|
-
result = undefined;
|
|
370
|
-
}
|
|
371
|
-
resolve(result);
|
|
372
|
-
})
|
|
373
|
-
.catch(err => {
|
|
374
|
-
reject(err);
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
},
|
|
378
|
-
/**
|
|
379
|
-
* 判断是否渲染EditForm
|
|
380
|
-
* @param {*} row
|
|
381
|
-
* @param {*} column
|
|
382
|
-
* @returns
|
|
383
|
-
*/
|
|
384
|
-
showEditForm(row, column, $rowIndex) {
|
|
385
|
-
if (!this.isMatchComponent || this.isNestTable || this.isScanMultiTable) return false;
|
|
386
|
-
if (this.isBatchEditing || this.isInlineAdding) {
|
|
387
|
-
let matchObj = this.editColumnMap[column.property];
|
|
388
|
-
if (!matchObj || !matchObj.matchItem || !matchObj.fieldItem) return false;
|
|
389
|
-
// 批量编辑 未选择全部行编辑
|
|
390
|
-
if (this.isBatchEditing && !this.isEditAllRow) {
|
|
391
|
-
let matchIndex = this.checkedRows.findIndex(v => v[this.primaryKey] == row[this.primaryKey]);
|
|
392
|
-
if (matchIndex < 0) return false;
|
|
393
|
-
}
|
|
394
|
-
// 新增
|
|
395
|
-
if (this.isInlineAdding) {
|
|
396
|
-
if ($rowIndex !== 0) return false;
|
|
397
|
-
}
|
|
398
|
-
return matchObj.matchItem;
|
|
399
|
-
}
|
|
400
|
-
return false;
|
|
401
|
-
},
|
|
402
|
-
/**
|
|
403
|
-
* 初始化props
|
|
404
|
-
* @param {*} unionItem
|
|
405
|
-
* @param {*} row
|
|
406
|
-
* @param {*} column
|
|
407
|
-
* @param {*} $rowIndex
|
|
408
|
-
* @returns
|
|
409
|
-
*/
|
|
410
|
-
initBatchDynamicProps(unionItem, row, column, $rowIndex) {
|
|
411
|
-
let id = row[this.primaryKey];
|
|
412
|
-
let dynamicPropsCache = this.batchDynamicPropsCache[id];
|
|
413
|
-
if (dynamicPropsCache && dynamicPropsCache[unionItem.tableField]) {
|
|
414
|
-
return dynamicPropsCache[unionItem.tableField];
|
|
415
|
-
}
|
|
416
|
-
let matchObj = this.editColumnMap[column.property];
|
|
417
|
-
let { fieldItem = {} } = matchObj || {};
|
|
418
|
-
let defaultCombinationForm = {};
|
|
419
|
-
if (!this.isInlineAdding) {
|
|
420
|
-
let originalRow = this.pageIndexOldtableData.find(item => {
|
|
421
|
-
let oldItemVal = utils.handleCurValue(item[this.primaryKey]);
|
|
422
|
-
let rowVal = utils.handleCurValue(row[this.primaryKey]);
|
|
423
|
-
return oldItemVal == rowVal;
|
|
424
|
-
});
|
|
425
|
-
defaultCombinationForm = this.setDefaultFormData(column.property, fieldItem, originalRow);
|
|
426
|
-
}
|
|
427
|
-
let tempFieldItem = JSON.parse(JSON.stringify(fieldItem));
|
|
428
|
-
let defaultForm = {
|
|
429
|
-
fieldList: [tempFieldItem],
|
|
430
|
-
defaultCombinationForm
|
|
431
|
-
};
|
|
432
|
-
let dynamicProps = {
|
|
433
|
-
props: {
|
|
434
|
-
formPrimaryKey: id,
|
|
435
|
-
defaultForm,
|
|
436
|
-
banRequest: true,
|
|
437
|
-
propsFormBtn: true,
|
|
438
|
-
propsDelSetting: true,
|
|
439
|
-
parentConfig: {
|
|
440
|
-
is_edit: '1'
|
|
441
|
-
},
|
|
442
|
-
configuration: this.configuration,
|
|
443
|
-
isPure: true,
|
|
444
|
-
isOpenShortcut: false,
|
|
445
|
-
cacheUniqueKey: this.cacheUniqueKey,
|
|
446
|
-
styleSetting: {},
|
|
447
|
-
editFormApiConfig: this.editFormApiConfig,
|
|
448
|
-
btnList: this.btnList
|
|
449
|
-
},
|
|
450
|
-
on: {
|
|
451
|
-
handleSubmit: this.handleSubmitEditForm,
|
|
452
|
-
banSubmit: this.banSubmit
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
this.$emit('setBatchDynamicPropsCache', {
|
|
456
|
-
primaryKey: row[this.primaryKey],
|
|
457
|
-
tableField: unionItem.tableField,
|
|
458
|
-
dynamicProps
|
|
459
|
-
});
|
|
460
|
-
return dynamicProps;
|
|
461
|
-
},
|
|
462
|
-
/**
|
|
463
|
-
* 单个form提交成功数据
|
|
464
|
-
* @param {*} obj formData
|
|
465
|
-
*/
|
|
466
|
-
handleSubmitEditForm(obj = {}) {
|
|
467
|
-
this.$emit('submitEditFormSuccessBatch', obj);
|
|
468
|
-
},
|
|
469
|
-
/**
|
|
470
|
-
* 单个form提交失败
|
|
471
|
-
* @param {*} obj
|
|
472
|
-
*/
|
|
473
|
-
banSubmit(obj) {
|
|
474
|
-
this.$emit('submitEditFormErrorBatch', obj);
|
|
475
|
-
},
|
|
476
|
-
formatFieldItem(fieldItem) {
|
|
477
|
-
return Object.assign({}, fieldItem, {
|
|
478
|
-
elem_width: '12',
|
|
479
|
-
is_show: '1'
|
|
480
|
-
});
|
|
481
|
-
},
|
|
482
|
-
formatField(value) {
|
|
483
|
-
if (value && typeof value == 'string' && value.startsWith('###')) {
|
|
484
|
-
value = value.slice(3);
|
|
485
|
-
value = JSON.parse(value);
|
|
486
|
-
value = value.tooltip || value.value;
|
|
487
|
-
}
|
|
488
|
-
return value;
|
|
489
|
-
},
|
|
490
|
-
setDefaultFormData(property, fieldItem, originalRow = {}) {
|
|
491
|
-
let defaultValue = originalRow[property];
|
|
492
|
-
|
|
493
|
-
return {
|
|
494
|
-
[fieldItem.name]: this.formatField(defaultValue)
|
|
495
|
-
};
|
|
496
|
-
},
|
|
497
|
-
/**
|
|
498
|
-
* 批量提交form
|
|
499
|
-
* @param {*} obj
|
|
500
|
-
* @returns
|
|
501
|
-
*/
|
|
502
|
-
submitBatchInlineForm(obj) {
|
|
503
|
-
if (this.batchError) {
|
|
504
|
-
this.resetBatchEditRowStatus();
|
|
505
|
-
this.$emit('triggerSpinning', false);
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
let isBatchDoneAll = this.handleIsBatchDoneAll(obj);
|
|
509
|
-
if (!isBatchDoneAll) {
|
|
510
|
-
this.resetBatchEditRowStatus();
|
|
511
|
-
this.$emit('triggerSpinning', false);
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
let { listFormUnionSetting } = this;
|
|
515
|
-
let { formId } = listFormUnionSetting;
|
|
516
|
-
let params = this.handleSubmitParams(this.batchFormData);
|
|
517
|
-
if (!formId || !params) {
|
|
518
|
-
this.resetBatchEditRowStatus();
|
|
519
|
-
this.$emit('triggerSpinning', false);
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
if (this.isSaveForm) return false;
|
|
523
|
-
this.isSaveForm = true;
|
|
524
|
-
this.savaForm(formId, params)
|
|
525
|
-
.then(async ({ data }) => {
|
|
526
|
-
this.$emit('triggerSpinning', false);
|
|
527
|
-
if (data.result !== 'SUCCESS') {
|
|
528
|
-
this.isSaveForm = false;
|
|
529
|
-
this.$message.error(data.resultMsg || '保存失败');
|
|
530
|
-
this.resetBatchEditRowStatus();
|
|
531
|
-
return false;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
await this.resetInlineBatchEdit();
|
|
535
|
-
this.handleClickBatchCancelBtnByInline();
|
|
536
|
-
this.$emit('pubTableReload');
|
|
537
|
-
})
|
|
538
|
-
.finally(() => {
|
|
539
|
-
this.isSaveForm = false;
|
|
540
|
-
this.$emit('triggerSpinning', false);
|
|
541
|
-
this.resetBatchEditRowStatus();
|
|
542
|
-
});
|
|
543
|
-
},
|
|
544
|
-
/**
|
|
545
|
-
* 处理form
|
|
546
|
-
* @param {*} batchFormData
|
|
547
|
-
* @returns
|
|
548
|
-
*/
|
|
549
|
-
handleSubmitParams(batchFormData) {
|
|
550
|
-
let arr = [];
|
|
551
|
-
for (let key in batchFormData) {
|
|
552
|
-
// v[this.primaryKey] 可能为数字
|
|
553
|
-
// key 为字符串 用全等匹配不到 改为 ==
|
|
554
|
-
let matchItem = this.oldtableData.find(v => v[this.primaryKey] == key);
|
|
555
|
-
let obj = batchFormData[key];
|
|
556
|
-
if (matchItem) {
|
|
557
|
-
obj = Object.assign({}, obj, {
|
|
558
|
-
[this.primaryKey]: matchItem[this.primaryKey]
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
arr.push(obj);
|
|
562
|
-
}
|
|
563
|
-
return arr;
|
|
564
|
-
},
|
|
565
|
-
savaForm(formId, params) {
|
|
566
|
-
let handleEditFormSavaForm = this.editFormApiConfig?.handleEditFormSavaForm;
|
|
567
|
-
if (!handleEditFormSavaForm || typeof handleEditFormSavaForm !== 'function') {
|
|
568
|
-
handleEditFormSavaForm = this.savaFormRequest;
|
|
569
|
-
}
|
|
570
|
-
return handleEditFormSavaForm(params, { formId });
|
|
571
|
-
},
|
|
572
|
-
savaFormRequest(params, config) {
|
|
573
|
-
let url = `/form/editRows/update/${config.formId}`;
|
|
574
|
-
return this.axios({
|
|
575
|
-
method: 'post',
|
|
576
|
-
url,
|
|
577
|
-
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
|
578
|
-
data: params
|
|
579
|
-
});
|
|
580
|
-
},
|
|
581
|
-
handleFieldLength() {
|
|
582
|
-
let { fieldList = [] } = this.columnConfig;
|
|
583
|
-
let fieldLength = 0;
|
|
584
|
-
fieldList.forEach(item => {
|
|
585
|
-
// table中有column隐藏
|
|
586
|
-
if (item.isShow == 1 && item.isEdit == 1) {
|
|
587
|
-
let matchItem = this.batchFieldList.find(v => v.val_key === item.columnName);
|
|
588
|
-
if (matchItem) {
|
|
589
|
-
fieldLength++;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
return fieldLength;
|
|
594
|
-
},
|
|
595
|
-
/**
|
|
596
|
-
* 判断每个表单是否校验过
|
|
597
|
-
* @param {*} obj
|
|
598
|
-
* @returns
|
|
599
|
-
*/
|
|
600
|
-
handleIsBatchDoneAll(obj) {
|
|
601
|
-
// let fieldLength = this.batchFieldList?.length;
|
|
602
|
-
let fieldLength = this.fieldLength;
|
|
603
|
-
if (!fieldLength) return false;
|
|
604
|
-
for (let key in obj) {
|
|
605
|
-
if (obj[key] < fieldLength) return false;
|
|
606
|
-
}
|
|
607
|
-
return true;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
};
|
|
1
|
+
// import { mapMutations, mapActions } from "vuex";
|
|
2
|
+
import utils from '@/utils/utils-map';
|
|
3
|
+
export default {
|
|
4
|
+
props: {
|
|
5
|
+
// 曾经的getters
|
|
6
|
+
isBatchEditing: Boolean,
|
|
7
|
+
isEditAllRow: Boolean,
|
|
8
|
+
isBatchSave: Boolean,
|
|
9
|
+
isBatchCancel: Boolean,
|
|
10
|
+
batchDynamicPropsCache: { type: Object, default: () => ({}) },
|
|
11
|
+
batchEditDoneNumber: { type: Object, default: () => ({}) },
|
|
12
|
+
batchError: Boolean,
|
|
13
|
+
batchFormData: { type: Object, default: () => ({}) },
|
|
14
|
+
|
|
15
|
+
// 曾经的mapActions
|
|
16
|
+
resetInlineBatchEdit: Function,
|
|
17
|
+
resetBatchEditRowStatus: Function
|
|
18
|
+
},
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
cacheUniqueKey: {},
|
|
22
|
+
theUniqueKeyListObj: {},
|
|
23
|
+
batchFieldList: [],
|
|
24
|
+
editColumnMap: {},
|
|
25
|
+
fieldLength: 0,
|
|
26
|
+
originFormatList: [],
|
|
27
|
+
isSaveForm: false,
|
|
28
|
+
isLoadData: false,
|
|
29
|
+
isLoadColumn: false,
|
|
30
|
+
addInlineEditPrimaryKey: ''
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
computed: {
|
|
34
|
+
configuration() {
|
|
35
|
+
return {
|
|
36
|
+
userInfo: this.userInfo || {},
|
|
37
|
+
sysImageSize: this.sysImageSize || {},
|
|
38
|
+
switchConfig: this.switchConfig || {},
|
|
39
|
+
hospitalConfigData: this.iconObj || {}
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
tableLoad() {
|
|
43
|
+
return {
|
|
44
|
+
isLoadData: this.isLoadData,
|
|
45
|
+
isLoadColumn: this.isLoadColumn
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
isTableEdit() {
|
|
49
|
+
return this.isInlineOperating || this.isInlineAdding;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
watch: {
|
|
53
|
+
tableLoad(obj) {
|
|
54
|
+
if (!obj) return;
|
|
55
|
+
let { isLoadData, isLoadColumn } = obj;
|
|
56
|
+
if (!(isLoadData && isLoadColumn)) return;
|
|
57
|
+
if (this.isBatchEditing) return;
|
|
58
|
+
this.$emit('tableLoad', true);
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* 编辑
|
|
62
|
+
*/
|
|
63
|
+
async isBatchEditing(val) {
|
|
64
|
+
if (!val || this.isNestTable) return false;
|
|
65
|
+
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
66
|
+
if (!this.checkOperateCurrentTable()) {
|
|
67
|
+
this.resetBatchOperationRowStatus();
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
// 非行内按钮触发
|
|
71
|
+
if (!this.isRowEditing) {
|
|
72
|
+
await this.toggleColumn();
|
|
73
|
+
}
|
|
74
|
+
this.hideSelectCloumns();
|
|
75
|
+
this.handleClickBatchEditBtnByInline();
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* 保存
|
|
79
|
+
*/
|
|
80
|
+
isBatchSave(val) {
|
|
81
|
+
if (!val || this.isNestTable) return false;
|
|
82
|
+
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
83
|
+
if (!this.checkOperateCurrentTable()) return false;
|
|
84
|
+
this.handleClickBatchSaveBtnByInline();
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* 取消
|
|
88
|
+
*/
|
|
89
|
+
async isBatchCancel(val) {
|
|
90
|
+
if (!val || this.isNestTable) return false;
|
|
91
|
+
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
92
|
+
if (!this.checkOperateCurrentTable()) return false;
|
|
93
|
+
await this.toggleColumn('showColumn');
|
|
94
|
+
this.handleClickBatchCancelBtnByInline();
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* 校验提交
|
|
98
|
+
*/
|
|
99
|
+
batchEditDoneNumber(obj) {
|
|
100
|
+
if (!obj || !Object.keys(obj).length || this.isNestTable) return;
|
|
101
|
+
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
102
|
+
if (!this.checkOperateCurrentTable()) return false;
|
|
103
|
+
this.submitBatchInlineForm(obj);
|
|
104
|
+
},
|
|
105
|
+
async isInlineAdding(val) {
|
|
106
|
+
if (!val || this.isNestTable) return false;
|
|
107
|
+
if (this.isTree != 0 || !this.isMatchComponent) return false;
|
|
108
|
+
if (!this.checkOperateCurrentTable()) {
|
|
109
|
+
this.resetBatchOperationRowStatus();
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
await this.toggleColumn();
|
|
113
|
+
this.hideSelectCloumns();
|
|
114
|
+
this.handleClickAddRow();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
methods: {
|
|
118
|
+
toggleColumn(key) {
|
|
119
|
+
let method = key || 'hideColumn';
|
|
120
|
+
const xGrid = this.$refs.xGrid;
|
|
121
|
+
if (!xGrid) return Promise.resolve();
|
|
122
|
+
let operate = xGrid.getColumnByField('operatorColumn');
|
|
123
|
+
if (method === 'showColumn' && operate.visible) {
|
|
124
|
+
return Promise.resolve();
|
|
125
|
+
}
|
|
126
|
+
return xGrid[method](operate);
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* 获取配置的 api 方法
|
|
130
|
+
* @param {*} params 调用参数
|
|
131
|
+
* @param {String} key 方法名
|
|
132
|
+
* @param {Object} config 其他配置
|
|
133
|
+
*/
|
|
134
|
+
async handleGetConfigApi(params, key, config = {}) {
|
|
135
|
+
try {
|
|
136
|
+
// TODO: 判断 fn 是异步函数还是同步
|
|
137
|
+
const editFormApiConfig = this?.editFormApiConfig || {};
|
|
138
|
+
const fn = editFormApiConfig[key] || null;
|
|
139
|
+
if (typeof fn === 'function') {
|
|
140
|
+
let res = await fn(params, config);
|
|
141
|
+
return Promise.resolve(res);
|
|
142
|
+
} else {
|
|
143
|
+
return Promise.reject(new Error(`${key} Is not a function`));
|
|
144
|
+
}
|
|
145
|
+
} catch (error) {
|
|
146
|
+
return Promise.reject(error);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
/**
|
|
150
|
+
* 设置row 为编辑样式
|
|
151
|
+
*/
|
|
152
|
+
getBatchOpreateRows(arr) {
|
|
153
|
+
let vxeTable = this.$refs.xGrid;
|
|
154
|
+
let { tableData } = vxeTable.getTableData();
|
|
155
|
+
if (!arr.length) return;
|
|
156
|
+
// 重置状态时使用
|
|
157
|
+
|
|
158
|
+
arr.forEach((item, i) => {
|
|
159
|
+
let rowIndex = i;
|
|
160
|
+
if (!this.isEditAllRow) {
|
|
161
|
+
let matchIndex = tableData.findIndex(v => v[this.primaryKey] == item[this.primaryKey]);
|
|
162
|
+
if (matchIndex > -1) {
|
|
163
|
+
rowIndex = matchIndex;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
this.setRowStatus(vxeTable.$el, rowIndex, 66);
|
|
167
|
+
this.$set(item, '__isInlineEditing', true);
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* 重置样式
|
|
172
|
+
* @param {*} isCancel 保存之后
|
|
173
|
+
* @returns
|
|
174
|
+
*/
|
|
175
|
+
resetBatchOperationRowStatus(isResetColumn) {
|
|
176
|
+
if (this.isTree != 0) return false;
|
|
177
|
+
|
|
178
|
+
const vxeTable = this.$refs.xGrid;
|
|
179
|
+
let { tableData } = vxeTable.getTableData();
|
|
180
|
+
vxeTable.clearActived();
|
|
181
|
+
vxeTable.resetColumn();
|
|
182
|
+
tableData.forEach((row, index) => {
|
|
183
|
+
this.setRowStatus(vxeTable.$el, index, null);
|
|
184
|
+
this.$set(row, '__isInlineEditing', false);
|
|
185
|
+
this.$set(row, '__isDisableInlineEdit', false);
|
|
186
|
+
});
|
|
187
|
+
this.checkedRows = [];
|
|
188
|
+
},
|
|
189
|
+
async handleClickAddRow() {
|
|
190
|
+
if (!this.checkListFormUnionSettingParamsList()) {
|
|
191
|
+
this.handleClickCancelBtnByInline();
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
this.addInlineEditPrimaryKey = Date.now();
|
|
195
|
+
let formData = {
|
|
196
|
+
[this.handleRowId]: this.addInlineEditPrimaryKey,
|
|
197
|
+
__isInsertRow: true
|
|
198
|
+
};
|
|
199
|
+
let vxeTable = this.$refs.xGrid;
|
|
200
|
+
await vxeTable.insert(formData);
|
|
201
|
+
await vxeTable.loadData([formData]);
|
|
202
|
+
await this.resetInlineBatchEdit();
|
|
203
|
+
|
|
204
|
+
this.setAllRowInlineStatus(true);
|
|
205
|
+
this.setRowStatus(vxeTable.$el, 0, 66);
|
|
206
|
+
},
|
|
207
|
+
/**
|
|
208
|
+
* 批量编辑
|
|
209
|
+
*/
|
|
210
|
+
async handleClickBatchEditBtnByInline() {
|
|
211
|
+
if (!this.checkListFormUnionSettingParamsList()) {
|
|
212
|
+
this.handleClickCancelBtnByInline();
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
let vxeTable = this.$refs.xGrid;
|
|
216
|
+
let arr = this.checkedRows;
|
|
217
|
+
let { tableData } = vxeTable.getTableData();
|
|
218
|
+
// 全部行编辑
|
|
219
|
+
if (this.isEditAllRow) {
|
|
220
|
+
arr = tableData;
|
|
221
|
+
}
|
|
222
|
+
await vxeTable.loadData(arr);
|
|
223
|
+
await this.resetInlineBatchEdit();
|
|
224
|
+
|
|
225
|
+
this.setAllRowInlineStatus(true);
|
|
226
|
+
this.getBatchOpreateRows(arr);
|
|
227
|
+
},
|
|
228
|
+
/**
|
|
229
|
+
* 批量保存
|
|
230
|
+
*/
|
|
231
|
+
handleClickBatchSaveBtnByInline() {
|
|
232
|
+
if (this.spinning) return false;
|
|
233
|
+
this.$emit('resetBatchEditDoneStatus');
|
|
234
|
+
|
|
235
|
+
let formDom = document.querySelectorAll('.js-inlineEditForm');
|
|
236
|
+
let filterFormDom = [];
|
|
237
|
+
[...formDom].map(item => {
|
|
238
|
+
let pNode = item.parentNode?.parentNode;
|
|
239
|
+
if (pNode) {
|
|
240
|
+
if (pNode.classList.contains('vxe-body--column') && !pNode.classList.contains('fixed--hidden')) {
|
|
241
|
+
filterFormDom.push(item);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
if (!filterFormDom.length) return false;
|
|
246
|
+
// // HACK: vxeTable行内编辑时复制的DOM节点,无需触发提交
|
|
247
|
+
filterFormDom.forEach(item => {
|
|
248
|
+
item.__vue__.handleSubmitForm();
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
/**
|
|
252
|
+
* 处理需要submit的form个数
|
|
253
|
+
*/
|
|
254
|
+
handleEditFormLength() {
|
|
255
|
+
let fieldLength = this.batchFieldList.length;
|
|
256
|
+
if (!fieldLength) return;
|
|
257
|
+
// 新增
|
|
258
|
+
if (this.isInlineAdding) {
|
|
259
|
+
return fieldLength;
|
|
260
|
+
}
|
|
261
|
+
let vxeTable = this.$refs.xGrid;
|
|
262
|
+
let rowLen = this.allSelectedLength;
|
|
263
|
+
let { tableData } = vxeTable.getTableData();
|
|
264
|
+
// 全部行
|
|
265
|
+
if (this.isEditAllRow) {
|
|
266
|
+
rowLen = tableData.length;
|
|
267
|
+
}
|
|
268
|
+
if (!rowLen) return;
|
|
269
|
+
return fieldLength * rowLen;
|
|
270
|
+
},
|
|
271
|
+
async handleClickBatchCancelBtnByInline() {
|
|
272
|
+
let vxeTable = this.$refs.xGrid;
|
|
273
|
+
this.isSaveForm = false;
|
|
274
|
+
this.$emit('resetInlineEditAll', false);
|
|
275
|
+
await vxeTable.reloadData(this.originFormatList);
|
|
276
|
+
this.resetBatchOperationRowStatus(true);
|
|
277
|
+
},
|
|
278
|
+
/**
|
|
279
|
+
* 避免每次点击都查询
|
|
280
|
+
* 初始化查一次 行编辑 表单search用
|
|
281
|
+
*/
|
|
282
|
+
// 避免每次点击都查询
|
|
283
|
+
async handleFormTheUniqueKey() {
|
|
284
|
+
let hasEditRow = this.btnList?.find(item => {
|
|
285
|
+
let trigger_type = item.settingObj && item.settingObj[0]?.trigger_type;
|
|
286
|
+
if (item.isShow == 1 && trigger_type == 'EDIT_ROW') return true;
|
|
287
|
+
return false;
|
|
288
|
+
});
|
|
289
|
+
if (!hasEditRow) return;
|
|
290
|
+
await this.handleFieldTheUniqueKey();
|
|
291
|
+
},
|
|
292
|
+
/**
|
|
293
|
+
* 获取编辑的field
|
|
294
|
+
*/
|
|
295
|
+
handleFieldTheUniqueKey() {
|
|
296
|
+
return new Promise((resolve, reject) => {
|
|
297
|
+
let { paramsList = [] } = this.listFormUnionSetting || {};
|
|
298
|
+
let { fieldList = [] } = this.inlineEditFormConfig || {};
|
|
299
|
+
fieldList = JSON.parse(JSON.stringify(fieldList));
|
|
300
|
+
this.batchFieldList = [];
|
|
301
|
+
let batchFieldList = [];
|
|
302
|
+
batchFieldList = fieldList
|
|
303
|
+
.map(item => {
|
|
304
|
+
let matchItem = paramsList.find(v => item.val_key === v.tableField);
|
|
305
|
+
if (matchItem) {
|
|
306
|
+
let NOWORDBOOK = item.wordbook && (item?.wordbook?.type || '') != 'WORDBOOK';
|
|
307
|
+
let id = item.wordbook?.id;
|
|
308
|
+
if (NOWORDBOOK && id && !this.theUniqueKeyListObj[id]) {
|
|
309
|
+
this.theUniqueKeyListObj[id] = id;
|
|
310
|
+
}
|
|
311
|
+
return item;
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
})
|
|
315
|
+
.filter(Boolean);
|
|
316
|
+
if (!batchFieldList || !batchFieldList.length) return resolve();
|
|
317
|
+
// 缓存行编辑需要的column配置
|
|
318
|
+
this.editColumnMap = this.handleColumnMap(batchFieldList, paramsList);
|
|
319
|
+
this.batchFieldList = batchFieldList;
|
|
320
|
+
this.fieldLength = this.handleFieldLength();
|
|
321
|
+
let keyList = Object.keys(this.theUniqueKeyListObj || {});
|
|
322
|
+
if (!keyList.length) return resolve();
|
|
323
|
+
keyList.forEach(async item => {
|
|
324
|
+
await this.handleRequestedUniqueKey(item);
|
|
325
|
+
});
|
|
326
|
+
resolve();
|
|
327
|
+
});
|
|
328
|
+
},
|
|
329
|
+
handleColumnMap(batchFieldList, paramsList) {
|
|
330
|
+
let { fieldList = [] } = this.columnConfig;
|
|
331
|
+
let editColumnMap = {};
|
|
332
|
+
fieldList.forEach(item => {
|
|
333
|
+
if (item.isShow != 1 || item.isEdit != 1) return;
|
|
334
|
+
let matchItem = paramsList.find(v => v.tableField === item.columnName);
|
|
335
|
+
if (!matchItem) return;
|
|
336
|
+
let fieldItem = batchFieldList?.find(field => {
|
|
337
|
+
return field.val_key === matchItem.tableField;
|
|
338
|
+
});
|
|
339
|
+
if (!fieldItem) return;
|
|
340
|
+
fieldItem = this.formatFieldItem(fieldItem);
|
|
341
|
+
let obj = {
|
|
342
|
+
columnName: item.columnName,
|
|
343
|
+
matchItem,
|
|
344
|
+
fieldItem
|
|
345
|
+
};
|
|
346
|
+
editColumnMap[item.columnName] = obj;
|
|
347
|
+
});
|
|
348
|
+
return editColumnMap;
|
|
349
|
+
},
|
|
350
|
+
async handleRequestedUniqueKey(id) {
|
|
351
|
+
let handleEditFormRequestedUniqueKey = this.editFormApiConfig?.handleEditFormRequestedUniqueKey;
|
|
352
|
+
if (!handleEditFormRequestedUniqueKey || typeof handleEditFormRequestedUniqueKey !== 'function') {
|
|
353
|
+
handleEditFormRequestedUniqueKey = this.getPrimaryKeyRequest;
|
|
354
|
+
}
|
|
355
|
+
return handleEditFormRequestedUniqueKey({ tableId: id }).then(val => {
|
|
356
|
+
val && (this.cacheUniqueKey[id] = { value: val, status: true });
|
|
357
|
+
});
|
|
358
|
+
},
|
|
359
|
+
getPrimaryKeyRequest(params) {
|
|
360
|
+
return new Promise((resolve, reject) => {
|
|
361
|
+
this.axios
|
|
362
|
+
.get('tableList/getPrimaryKey', { params })
|
|
363
|
+
.then(({ data }) => {
|
|
364
|
+
let result;
|
|
365
|
+
if (data.result == 'SUCCESS') {
|
|
366
|
+
const { map = {} } = data;
|
|
367
|
+
result = map.primaryKey || undefined;
|
|
368
|
+
} else {
|
|
369
|
+
result = undefined;
|
|
370
|
+
}
|
|
371
|
+
resolve(result);
|
|
372
|
+
})
|
|
373
|
+
.catch(err => {
|
|
374
|
+
reject(err);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
/**
|
|
379
|
+
* 判断是否渲染EditForm
|
|
380
|
+
* @param {*} row
|
|
381
|
+
* @param {*} column
|
|
382
|
+
* @returns
|
|
383
|
+
*/
|
|
384
|
+
showEditForm(row, column, $rowIndex) {
|
|
385
|
+
if (!this.isMatchComponent || this.isNestTable || this.isScanMultiTable) return false;
|
|
386
|
+
if (this.isBatchEditing || this.isInlineAdding) {
|
|
387
|
+
let matchObj = this.editColumnMap[column.property];
|
|
388
|
+
if (!matchObj || !matchObj.matchItem || !matchObj.fieldItem) return false;
|
|
389
|
+
// 批量编辑 未选择全部行编辑
|
|
390
|
+
if (this.isBatchEditing && !this.isEditAllRow) {
|
|
391
|
+
let matchIndex = this.checkedRows.findIndex(v => v[this.primaryKey] == row[this.primaryKey]);
|
|
392
|
+
if (matchIndex < 0) return false;
|
|
393
|
+
}
|
|
394
|
+
// 新增
|
|
395
|
+
if (this.isInlineAdding) {
|
|
396
|
+
if ($rowIndex !== 0) return false;
|
|
397
|
+
}
|
|
398
|
+
return matchObj.matchItem;
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
401
|
+
},
|
|
402
|
+
/**
|
|
403
|
+
* 初始化props
|
|
404
|
+
* @param {*} unionItem
|
|
405
|
+
* @param {*} row
|
|
406
|
+
* @param {*} column
|
|
407
|
+
* @param {*} $rowIndex
|
|
408
|
+
* @returns
|
|
409
|
+
*/
|
|
410
|
+
initBatchDynamicProps(unionItem, row, column, $rowIndex) {
|
|
411
|
+
let id = row[this.primaryKey];
|
|
412
|
+
let dynamicPropsCache = this.batchDynamicPropsCache[id];
|
|
413
|
+
if (dynamicPropsCache && dynamicPropsCache[unionItem.tableField]) {
|
|
414
|
+
return dynamicPropsCache[unionItem.tableField];
|
|
415
|
+
}
|
|
416
|
+
let matchObj = this.editColumnMap[column.property];
|
|
417
|
+
let { fieldItem = {} } = matchObj || {};
|
|
418
|
+
let defaultCombinationForm = {};
|
|
419
|
+
if (!this.isInlineAdding) {
|
|
420
|
+
let originalRow = this.pageIndexOldtableData.find(item => {
|
|
421
|
+
let oldItemVal = utils.handleCurValue(item[this.primaryKey]);
|
|
422
|
+
let rowVal = utils.handleCurValue(row[this.primaryKey]);
|
|
423
|
+
return oldItemVal == rowVal;
|
|
424
|
+
});
|
|
425
|
+
defaultCombinationForm = this.setDefaultFormData(column.property, fieldItem, originalRow);
|
|
426
|
+
}
|
|
427
|
+
let tempFieldItem = JSON.parse(JSON.stringify(fieldItem));
|
|
428
|
+
let defaultForm = {
|
|
429
|
+
fieldList: [tempFieldItem],
|
|
430
|
+
defaultCombinationForm
|
|
431
|
+
};
|
|
432
|
+
let dynamicProps = {
|
|
433
|
+
props: {
|
|
434
|
+
formPrimaryKey: id,
|
|
435
|
+
defaultForm,
|
|
436
|
+
banRequest: true,
|
|
437
|
+
propsFormBtn: true,
|
|
438
|
+
propsDelSetting: true,
|
|
439
|
+
parentConfig: {
|
|
440
|
+
is_edit: '1'
|
|
441
|
+
},
|
|
442
|
+
configuration: this.configuration,
|
|
443
|
+
isPure: true,
|
|
444
|
+
isOpenShortcut: false,
|
|
445
|
+
cacheUniqueKey: this.cacheUniqueKey,
|
|
446
|
+
styleSetting: {},
|
|
447
|
+
editFormApiConfig: this.editFormApiConfig,
|
|
448
|
+
btnList: this.btnList
|
|
449
|
+
},
|
|
450
|
+
on: {
|
|
451
|
+
handleSubmit: this.handleSubmitEditForm,
|
|
452
|
+
banSubmit: this.banSubmit
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
this.$emit('setBatchDynamicPropsCache', {
|
|
456
|
+
primaryKey: row[this.primaryKey],
|
|
457
|
+
tableField: unionItem.tableField,
|
|
458
|
+
dynamicProps
|
|
459
|
+
});
|
|
460
|
+
return dynamicProps;
|
|
461
|
+
},
|
|
462
|
+
/**
|
|
463
|
+
* 单个form提交成功数据
|
|
464
|
+
* @param {*} obj formData
|
|
465
|
+
*/
|
|
466
|
+
handleSubmitEditForm(obj = {}) {
|
|
467
|
+
this.$emit('submitEditFormSuccessBatch', obj);
|
|
468
|
+
},
|
|
469
|
+
/**
|
|
470
|
+
* 单个form提交失败
|
|
471
|
+
* @param {*} obj
|
|
472
|
+
*/
|
|
473
|
+
banSubmit(obj) {
|
|
474
|
+
this.$emit('submitEditFormErrorBatch', obj);
|
|
475
|
+
},
|
|
476
|
+
formatFieldItem(fieldItem) {
|
|
477
|
+
return Object.assign({}, fieldItem, {
|
|
478
|
+
elem_width: '12',
|
|
479
|
+
is_show: '1'
|
|
480
|
+
});
|
|
481
|
+
},
|
|
482
|
+
formatField(value) {
|
|
483
|
+
if (value && typeof value == 'string' && value.startsWith('###')) {
|
|
484
|
+
value = value.slice(3);
|
|
485
|
+
value = JSON.parse(value);
|
|
486
|
+
value = value.tooltip || value.value;
|
|
487
|
+
}
|
|
488
|
+
return value;
|
|
489
|
+
},
|
|
490
|
+
setDefaultFormData(property, fieldItem, originalRow = {}) {
|
|
491
|
+
let defaultValue = originalRow[property];
|
|
492
|
+
|
|
493
|
+
return {
|
|
494
|
+
[fieldItem.name]: this.formatField(defaultValue)
|
|
495
|
+
};
|
|
496
|
+
},
|
|
497
|
+
/**
|
|
498
|
+
* 批量提交form
|
|
499
|
+
* @param {*} obj
|
|
500
|
+
* @returns
|
|
501
|
+
*/
|
|
502
|
+
submitBatchInlineForm(obj) {
|
|
503
|
+
if (this.batchError) {
|
|
504
|
+
this.resetBatchEditRowStatus();
|
|
505
|
+
this.$emit('triggerSpinning', false);
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
let isBatchDoneAll = this.handleIsBatchDoneAll(obj);
|
|
509
|
+
if (!isBatchDoneAll) {
|
|
510
|
+
this.resetBatchEditRowStatus();
|
|
511
|
+
this.$emit('triggerSpinning', false);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
let { listFormUnionSetting } = this;
|
|
515
|
+
let { formId } = listFormUnionSetting;
|
|
516
|
+
let params = this.handleSubmitParams(this.batchFormData);
|
|
517
|
+
if (!formId || !params) {
|
|
518
|
+
this.resetBatchEditRowStatus();
|
|
519
|
+
this.$emit('triggerSpinning', false);
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
if (this.isSaveForm) return false;
|
|
523
|
+
this.isSaveForm = true;
|
|
524
|
+
this.savaForm(formId, params)
|
|
525
|
+
.then(async ({ data }) => {
|
|
526
|
+
this.$emit('triggerSpinning', false);
|
|
527
|
+
if (data.result !== 'SUCCESS') {
|
|
528
|
+
this.isSaveForm = false;
|
|
529
|
+
this.$message.error(data.resultMsg || '保存失败');
|
|
530
|
+
this.resetBatchEditRowStatus();
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
await this.resetInlineBatchEdit();
|
|
535
|
+
this.handleClickBatchCancelBtnByInline();
|
|
536
|
+
this.$emit('pubTableReload');
|
|
537
|
+
})
|
|
538
|
+
.finally(() => {
|
|
539
|
+
this.isSaveForm = false;
|
|
540
|
+
this.$emit('triggerSpinning', false);
|
|
541
|
+
this.resetBatchEditRowStatus();
|
|
542
|
+
});
|
|
543
|
+
},
|
|
544
|
+
/**
|
|
545
|
+
* 处理form
|
|
546
|
+
* @param {*} batchFormData
|
|
547
|
+
* @returns
|
|
548
|
+
*/
|
|
549
|
+
handleSubmitParams(batchFormData) {
|
|
550
|
+
let arr = [];
|
|
551
|
+
for (let key in batchFormData) {
|
|
552
|
+
// v[this.primaryKey] 可能为数字
|
|
553
|
+
// key 为字符串 用全等匹配不到 改为 ==
|
|
554
|
+
let matchItem = this.oldtableData.find(v => v[this.primaryKey] == key);
|
|
555
|
+
let obj = batchFormData[key];
|
|
556
|
+
if (matchItem) {
|
|
557
|
+
obj = Object.assign({}, obj, {
|
|
558
|
+
[this.primaryKey]: matchItem[this.primaryKey]
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
arr.push(obj);
|
|
562
|
+
}
|
|
563
|
+
return arr;
|
|
564
|
+
},
|
|
565
|
+
savaForm(formId, params) {
|
|
566
|
+
let handleEditFormSavaForm = this.editFormApiConfig?.handleEditFormSavaForm;
|
|
567
|
+
if (!handleEditFormSavaForm || typeof handleEditFormSavaForm !== 'function') {
|
|
568
|
+
handleEditFormSavaForm = this.savaFormRequest;
|
|
569
|
+
}
|
|
570
|
+
return handleEditFormSavaForm(params, { formId });
|
|
571
|
+
},
|
|
572
|
+
savaFormRequest(params, config) {
|
|
573
|
+
let url = `/form/editRows/update/${config.formId}`;
|
|
574
|
+
return this.axios({
|
|
575
|
+
method: 'post',
|
|
576
|
+
url,
|
|
577
|
+
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
|
578
|
+
data: params
|
|
579
|
+
});
|
|
580
|
+
},
|
|
581
|
+
handleFieldLength() {
|
|
582
|
+
let { fieldList = [] } = this.columnConfig;
|
|
583
|
+
let fieldLength = 0;
|
|
584
|
+
fieldList.forEach(item => {
|
|
585
|
+
// table中有column隐藏
|
|
586
|
+
if (item.isShow == 1 && item.isEdit == 1) {
|
|
587
|
+
let matchItem = this.batchFieldList.find(v => v.val_key === item.columnName);
|
|
588
|
+
if (matchItem) {
|
|
589
|
+
fieldLength++;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
return fieldLength;
|
|
594
|
+
},
|
|
595
|
+
/**
|
|
596
|
+
* 判断每个表单是否校验过
|
|
597
|
+
* @param {*} obj
|
|
598
|
+
* @returns
|
|
599
|
+
*/
|
|
600
|
+
handleIsBatchDoneAll(obj) {
|
|
601
|
+
// let fieldLength = this.batchFieldList?.length;
|
|
602
|
+
let fieldLength = this.fieldLength;
|
|
603
|
+
if (!fieldLength) return false;
|
|
604
|
+
for (let key in obj) {
|
|
605
|
+
if (obj[key] < fieldLength) return false;
|
|
606
|
+
}
|
|
607
|
+
return true;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
};
|