rt-sim-training-client/src/views/system/commandDictionary/copyParam.vue

115 lines
3.6 KiB
Vue
Raw Normal View History

2020-07-20 10:47:27 +08:00
<template>
<el-dialog v-dialogDrag title="复制线路操作" :visible.sync="dialogVisible" width="400px" :before-close="handleClose" center :close-on-click-modal="false">
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
2020-10-28 13:51:26 +08:00
import { postCopyCmd } from '@/api/management/dictionary';
2020-07-20 10:47:27 +08:00
export default {
name: 'EditCondition',
props: {
taskStatusList: {
type: Array,
2020-10-28 13:51:26 +08:00
default() {
return [];
}
2020-07-20 10:47:27 +08:00
}
},
data() {
return {
dialogVisible: false,
formModel: {
2020-10-28 13:51:26 +08:00
fromCode: '',
fromName: '',
2020-07-20 10:47:27 +08:00
targetIds: '',
deviceType: []
2020-07-20 13:29:32 +08:00
},
deviceTypeList: [],
targetList: [],
lineCode: ''
2020-07-20 10:47:27 +08:00
};
2020-07-20 13:29:32 +08:00
},
2020-07-20 10:47:27 +08:00
computed: {
form() {
const form = {
labelWidth: '100px',
items: [
{ prop: 'fromName', label: '源线路', type: 'text', disabled: true },
{ prop: 'targetIds', label:'拷贝线路', type: 'select', options: this.targetList, multiple: true },
{ prop: 'deviceType', label: '操作对象', type: 'select', options: this.deviceTypeList, multiple: true }
]
};
return form;
},
rules() {
return {
fromName: [
{ required: true, message: '请选择拷贝源线路', trigger: 'blur' }
],
targetIds: [
{ required: true, message: '请选择需要拷贝线路', trigger: 'blur' }
]
};
}
2020-07-20 13:29:32 +08:00
},
watch: {
taskStatusList(list) {
this.targetList = [];
list.forEach(item => {
if (item.value != this.lineCode) {
this.targetList.push(item);
}
});
}
},
created() {
this.deviceTypeList = [];
this.$ConstSelect.deviceTypeList.forEach(item => {
this.deviceTypeList.push(item);
});
},
2020-07-20 10:47:27 +08:00
methods: {
doShow(lineCode) {
this.dialogVisible = true;
if (lineCode) {
2020-07-20 13:29:32 +08:00
this.lineCode = lineCode;
this.targetList = [];
2020-07-20 10:47:27 +08:00
this.taskStatusList.forEach(item => {
2020-10-28 13:51:26 +08:00
item.value = item.code;
item.label = item.name;
if (item.code != lineCode) {
this.targetList.push(item);
} else {
this.formModel.fromCode = item.code;
this.formModel.fromName = item.name;
}
});
2020-07-20 10:47:27 +08:00
}
},
doSave() {
this.$refs.dataform.validateForm(() => {
2020-10-28 13:51:26 +08:00
const param = {
fromLineCode: this.formModel.fromCode,
targetLineCodes: this.formModel.targetIds,
operateObjects: this.formModel.deviceType
};
postCopyCmd(param).then(res => {
this.handleClose();
this.$message.success('复制指令成功!');
});
2020-07-20 10:47:27 +08:00
});
},
handleClose() {
this.$refs.dataform.resetForm();
this.dialogVisible = false;
}
}
};
</script>