Skip to content

Commit

Permalink
[feature]{CrudTable}: 改写循环写法
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Mar 30, 2019
1 parent 73a81ef commit 101fd2f
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/components/CrudTable/CrudTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,15 @@ export default {
},
formValueToArray() {
// 如果select,radio,checkbox等组件为多选情况 后台返回逗号分隔字符串 => 数组
for (const row of this.jsonData.list) {
if (row.columns) {
for (const column of row.columns) {
const { list } = column;
if (Array.isArray(list)) {
list.forEach((citem) => {
if (citem.options.multiple) {
if (!Array.isArray(this.formValues[citem.model])
&& this.formValues[citem.model]) {
this.formValues[citem.model] = this.formValues[citem.model].split(',');
}
}
});
}
}
} else if (row.options.multiple) {
if (!Array.isArray(this.formValues[row.model])
&& this.formValues[row.model]) {
const genList = this.jsondata.list
for (let i = 0; i < genList.length; i += 1) {
if (genList[i].type === 'grid') {
genList[i].columns.forEach((item) => {
this.formValueToArray(item.list);
});
} else {
const row = genList[i]
if (!Array.isArray(this.formValues[row.model])) {
this.formValues[row.model] = this.formValues[row.model].split(',');
}
}
Expand Down

0 comments on commit 101fd2f

Please sign in to comment.