|
@@ -1,17 +1,21 @@
|
|
|
<template>
|
|
|
<div class="rule-field-edit">
|
|
|
- <div class="field-part field-part-left">
|
|
|
+ <div class="field-part field-part-source">
|
|
|
<div class="field-title">
|
|
|
- <el-checkbox v-model="sourceAll">来源字段</el-checkbox>
|
|
|
+ <el-checkbox v-model="sourceAll" @change="sourceAllChange"
|
|
|
+ >来源字段</el-checkbox
|
|
|
+ >
|
|
|
</div>
|
|
|
<div class="field-body">
|
|
|
<div v-for="item in sourceList" :key="item.code" class="field-item">
|
|
|
- <el-checkbox v-model="item.checked">{{ item.name }}</el-checkbox>
|
|
|
+ <el-checkbox v-model="item.checked" @change="sourceItemChange">{{
|
|
|
+ item.name
|
|
|
+ }}</el-checkbox>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="field-part field-part-action">
|
|
|
- <div>
|
|
|
+ <div class="action-body">
|
|
|
<el-button
|
|
|
size="small"
|
|
|
icon="el-icon-arrow-left"
|
|
@@ -19,18 +23,22 @@
|
|
|
></el-button>
|
|
|
<el-button
|
|
|
size="small"
|
|
|
- icon="el-icon-arrow-left"
|
|
|
+ icon="el-icon-arrow-right"
|
|
|
@click="toRight"
|
|
|
></el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="field-part field-part-right">
|
|
|
+ <div class="field-part field-part-source">
|
|
|
<div class="field-title">
|
|
|
- <el-checkbox v-model="targetAll">目的字段</el-checkbox>
|
|
|
+ <el-checkbox v-model="targetAll" @change="targetAllChange"
|
|
|
+ >目的字段</el-checkbox
|
|
|
+ >
|
|
|
</div>
|
|
|
<div class="field-body">
|
|
|
<div v-for="item in targetList" :key="item.code" class="field-item">
|
|
|
- <el-checkbox v-model="item.checked">{{ item.name }}</el-checkbox>
|
|
|
+ <el-checkbox v-model="item.checked" @change="targetItemChange">{{
|
|
|
+ item.name
|
|
|
+ }}</el-checkbox>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -45,12 +53,14 @@ export default {
|
|
|
type: Array,
|
|
|
default() {
|
|
|
return [];
|
|
|
+ // [{code:'',name:''}]
|
|
|
}
|
|
|
},
|
|
|
data: {
|
|
|
type: Array,
|
|
|
default() {
|
|
|
return [];
|
|
|
+ // [{code:'',name:''}]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -62,6 +72,14 @@ export default {
|
|
|
targetList: []
|
|
|
};
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ value() {
|
|
|
+ this.initData();
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ this.initData();
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
initData() {
|
|
|
const fields = this.data.map(item => {
|
|
@@ -70,11 +88,30 @@ export default {
|
|
|
checked: false
|
|
|
};
|
|
|
});
|
|
|
- this.sourceList = fields.filter(item => !this.value.includes(item.code));
|
|
|
- this.targetList = fields.filter(item => this.value.includes(item.code));
|
|
|
+ const valCodes = this.value.map(item => item.code);
|
|
|
+ this.sourceList = fields.filter(item => !valCodes.includes(item.code));
|
|
|
+ this.targetList = this.value.map(item => {
|
|
|
+ return { ...item, checked: false };
|
|
|
+ });
|
|
|
+ },
|
|
|
+ sourceAllChange() {
|
|
|
+ this.sourceList.forEach(item => {
|
|
|
+ item.checked = this.sourceAll;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ targetAllChange() {
|
|
|
+ this.targetList.forEach(item => {
|
|
|
+ item.checked = this.targetAll;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ sourceItemChange() {
|
|
|
+ this.sourceAll = !this.sourceList.some(item => !item.checked);
|
|
|
+ },
|
|
|
+ targetItemChange() {
|
|
|
+ this.targetAll = !this.targetList.some(item => !item.checked);
|
|
|
},
|
|
|
toLeft() {
|
|
|
- const checkedFields = this.targetAll.filter(item => item.checked);
|
|
|
+ const checkedFields = this.targetList.filter(item => item.checked);
|
|
|
if (!checkedFields.length) {
|
|
|
this.$message.error("请选择目的字段!");
|
|
|
return;
|
|
@@ -88,6 +125,8 @@ export default {
|
|
|
};
|
|
|
})
|
|
|
);
|
|
|
+ this.targetList = this.targetList.filter(item => !item.checked);
|
|
|
+ this.targetAll = false;
|
|
|
this.emitChange();
|
|
|
},
|
|
|
toRight() {
|
|
@@ -105,6 +144,8 @@ export default {
|
|
|
};
|
|
|
})
|
|
|
);
|
|
|
+ this.sourceList = this.sourceList.filter(item => !item.checked);
|
|
|
+ this.sourceAll = false;
|
|
|
this.emitChange();
|
|
|
},
|
|
|
emitChange() {
|
|
@@ -114,10 +155,7 @@ export default {
|
|
|
code: item.code
|
|
|
};
|
|
|
});
|
|
|
- this.$emit(
|
|
|
- "input",
|
|
|
- this.targetList.map(item => item.code)
|
|
|
- );
|
|
|
+ this.$emit("input", targetFields);
|
|
|
this.$emit("change", targetFields);
|
|
|
}
|
|
|
}
|