Skip to content

Commit e51214b

Browse files
author
283591387@qq.com
committed
增加vue3版本保存明细表时处理多选下拉框的值
1 parent ce1f9f8 commit e51214b

File tree

2 files changed

+50
-8
lines changed
  • Vol.Vue3版本/src/components/basic/ViewGrid
  • 开发版dev/Vue.NetCore/Vol.Vue3版本/src/components/basic/ViewGrid

2 files changed

+50
-8
lines changed

Vol.Vue3版本/src/components/basic/ViewGrid/methods.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,27 @@ let methods = {
631631
//获取明细数据(前台数据明细未做校验,待完.后台已经校验)
632632
if (this.hasDetail) {
633633
formData.detailData = this.$refs.detail.rowData;
634+
let _fields = this.detail.columns
635+
.filter((c) => {
636+
return (
637+
c.type == 'selectList' || (c.edit && c.edit.type == 'selectList')
638+
);
639+
})
640+
.map((c) => {
641+
return c.field;
642+
});
643+
//2022.06.20增加保存时对明细表下拉框多选的判断
644+
if (_fields.length) {
645+
formData.detailData = JSON.parse(JSON.stringify(formData.detailData));
646+
formData.detailData.forEach((row) => {
647+
for (let index = 0; index < _fields.length; index++) {
648+
const _field = _fields[index];
649+
if (Array.isArray(row[_field])) {
650+
row[_field] = row[_field].join(',');
651+
}
652+
}
653+
});
654+
}
634655
}
635656
if (this.detailOptions.delKeys.length > 0) {
636657
formData.delKeys = this.detailOptions.delKeys;
@@ -922,7 +943,7 @@ let methods = {
922943
);
923944
let elink = this.$refs.export;
924945
xmlResquest.responseType = 'blob';
925-
xmlResquest.onload = function (oEvent) {
946+
xmlResquest.onload = function(oEvent) {
926947
if (xmlResquest.status != 200) {
927948
this.$error('下载文件出错了..');
928949
return;
@@ -1446,7 +1467,7 @@ let methods = {
14461467
}
14471468
if (refreshBtn) {
14481469
refreshBtn.name = '重 置';
1449-
refreshBtn.onClick = function () {
1470+
refreshBtn.onClick = function() {
14501471
this.resetSearch();
14511472
};
14521473
}
@@ -1501,7 +1522,7 @@ let methods = {
15011522
this.importAfter(data);
15021523
}
15031524
};
1504-
import customColumns from './ViewGridCustomColumn.js'
1525+
import customColumns from './ViewGridCustomColumn.js';
15051526
//合并扩展方法
1506-
methods = Object.assign(methods, detailMethods, serviceFilter,customColumns);
1527+
methods = Object.assign(methods, detailMethods, serviceFilter, customColumns);
15071528
export default methods;

开发版dev/Vue.NetCore/Vol.Vue3版本/src/components/basic/ViewGrid/methods.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,27 @@ let methods = {
631631
//获取明细数据(前台数据明细未做校验,待完.后台已经校验)
632632
if (this.hasDetail) {
633633
formData.detailData = this.$refs.detail.rowData;
634+
let _fields = this.detail.columns
635+
.filter((c) => {
636+
return (
637+
c.type == 'selectList' || (c.edit && c.edit.type == 'selectList')
638+
);
639+
})
640+
.map((c) => {
641+
return c.field;
642+
});
643+
//2022.06.20增加保存时对明细表下拉框多选的判断
644+
if (_fields.length) {
645+
formData.detailData = JSON.parse(JSON.stringify(formData.detailData));
646+
formData.detailData.forEach((row) => {
647+
for (let index = 0; index < _fields.length; index++) {
648+
const _field = _fields[index];
649+
if (Array.isArray(row[_field])) {
650+
row[_field] = row[_field].join(',');
651+
}
652+
}
653+
});
654+
}
634655
}
635656
if (this.detailOptions.delKeys.length > 0) {
636657
formData.delKeys = this.detailOptions.delKeys;
@@ -922,7 +943,7 @@ let methods = {
922943
);
923944
let elink = this.$refs.export;
924945
xmlResquest.responseType = 'blob';
925-
xmlResquest.onload = function (oEvent) {
946+
xmlResquest.onload = function(oEvent) {
926947
if (xmlResquest.status != 200) {
927948
this.$error('下载文件出错了..');
928949
return;
@@ -1446,7 +1467,7 @@ let methods = {
14461467
}
14471468
if (refreshBtn) {
14481469
refreshBtn.name = '重 置';
1449-
refreshBtn.onClick = function () {
1470+
refreshBtn.onClick = function() {
14501471
this.resetSearch();
14511472
};
14521473
}
@@ -1501,7 +1522,7 @@ let methods = {
15011522
this.importAfter(data);
15021523
}
15031524
};
1504-
import customColumns from './ViewGridCustomColumn.js'
1525+
import customColumns from './ViewGridCustomColumn.js';
15051526
//合并扩展方法
1506-
methods = Object.assign(methods, detailMethods, serviceFilter,customColumns);
1527+
methods = Object.assign(methods, detailMethods, serviceFilter, customColumns);
15071528
export default methods;

0 commit comments

Comments
 (0)