2020-11-04 10:18:29 +08:00
|
|
|
<template>
|
2020-11-04 14:48:36 +08:00
|
|
|
<div v-if="dialogVisible" v-quickMenuDrag class="reminder-drag">
|
|
|
|
<div style="width: 100%;text-align: center;font-size: 18px;padding-top: 8px;">条件管理</div>
|
2020-11-05 15:31:28 +08:00
|
|
|
<i style="position: relative;top: -25px;right: -370px;font-size: 20px;" class="el-icon-close" @click="handleClose" />
|
2020-11-04 14:48:36 +08:00
|
|
|
<el-tabs v-model="activeName">
|
|
|
|
<el-tab-pane label="列车触发" name="first">
|
|
|
|
<div>
|
|
|
|
<el-table
|
|
|
|
:data="tableData"
|
|
|
|
style="width: 100%"
|
|
|
|
height="200px"
|
|
|
|
>
|
|
|
|
<el-table-column prop="code" label="触发列车" />
|
|
|
|
<el-table-column prop="physicalCode" label="到达区段">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ getSectionName(scope.row.physicalCode) }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column prop="stop" label="是否停车">
|
|
|
|
<template slot-scope="scope">
|
2020-11-04 16:41:01 +08:00
|
|
|
<span>{{ handleStopValue(scope.row.stop) }}</span>
|
2020-11-04 14:48:36 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column width="150">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-button
|
|
|
|
size="mini"
|
|
|
|
@click="handleEdit(scope.$index, scope.row)"
|
|
|
|
>编辑</el-button>
|
|
|
|
<el-button
|
|
|
|
size="mini"
|
|
|
|
type="danger"
|
|
|
|
@click="handleDelete(scope.$index, scope.row)"
|
|
|
|
>删除</el-button>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
<el-form ref="form" label-width="80px" style="margin-top: 8px;padding: 10px;" :model="formModel" :rules="rules">
|
|
|
|
<el-form-item label="触发列车" prop="code">
|
|
|
|
<el-select v-model="formModel.code" size="small" filterable placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="item in trainList"
|
|
|
|
:key="item.code"
|
|
|
|
:label="item.code"
|
|
|
|
:value="item.code"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
<el-button :type="field === 'triggerTrain'? 'danger': 'primary'" size="small" @click="hover('triggerTrain')">{{ $t('map.activate') }}</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="到达区段" prop="physicalCode">
|
|
|
|
<el-select v-model="formModel.physicalCode" size="small" filterable placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="item in sectionList"
|
|
|
|
:key="item.code"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.code"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
<el-button :type="field === 'triggerSection'? 'danger': 'primary'" size="small" @click="hover('triggerSection')">{{ $t('map.activate') }}</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="是否停车">
|
|
|
|
<el-select v-model="formModel.stop" clearable size="small" placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="item in stopList"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item style="text-align: center;" label-width="0">
|
|
|
|
<el-button v-if="!update" size="small" type="primary" @click="onCommit">添加</el-button>
|
|
|
|
<el-button v-if="update" size="small" type="primary" @click="onUpdate">修改</el-button>
|
|
|
|
<el-button v-if="update" size="small" @click="initData">取消</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
|
|
|
</el-tab-pane>
|
|
|
|
<el-tab-pane label="延时触发" name="second">
|
|
|
|
<div style="text-align: center;">
|
|
|
|
<div style="display: inline-block;margin-right: 10px;font-size: 14px;">延时条件</div>
|
|
|
|
<el-input-number v-model="delay" size="small" controls-position="right" :min="0" />
|
|
|
|
<div style="margin-top: 10px;">
|
|
|
|
<el-button type="primary" size="mini" @click="onUpdateDelay">修改</el-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</el-tab-pane>
|
|
|
|
</el-tabs>
|
|
|
|
</div>
|
2020-11-04 10:18:29 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-11-04 16:41:01 +08:00
|
|
|
import { updateActionCondition, getActionCondition } from '@/api/script';
|
2020-11-04 14:48:36 +08:00
|
|
|
import { mapGetters } from 'vuex';
|
2020-11-04 10:18:29 +08:00
|
|
|
export default {
|
|
|
|
name: 'ConditionManage',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dialogVisible: false,
|
|
|
|
tableData: [],
|
2020-11-04 14:48:36 +08:00
|
|
|
stopList: [
|
|
|
|
{label: '是', value: 1},
|
|
|
|
{label: '否', value: 0}
|
|
|
|
],
|
2020-11-04 10:18:29 +08:00
|
|
|
formModel: {
|
2020-11-04 14:48:36 +08:00
|
|
|
code: '',
|
2020-11-04 10:18:29 +08:00
|
|
|
physicalCode: '',
|
2020-11-04 16:41:01 +08:00
|
|
|
stop: ''
|
2020-11-04 14:48:36 +08:00
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
code: [
|
|
|
|
{ required: true, message: '请选择触发列车', trigger: 'change' }
|
|
|
|
],
|
|
|
|
physicalCode: [
|
|
|
|
{ required: true, message: '请选择到达区段', trigger: 'change' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
actionId: '',
|
|
|
|
update: false,
|
|
|
|
updateIndex: '',
|
|
|
|
field: '',
|
|
|
|
delay: 0,
|
|
|
|
activeName: 'first'
|
2020-11-04 10:18:29 +08:00
|
|
|
};
|
|
|
|
},
|
2020-11-04 14:48:36 +08:00
|
|
|
computed: {
|
|
|
|
...mapGetters('map', [
|
|
|
|
'trainList',
|
|
|
|
'sectionList'
|
|
|
|
])
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$store.state.menuOperation.selectedCount':function(em) {
|
|
|
|
const device = this.$store.state.menuOperation.selected;
|
|
|
|
if (device.code) {
|
|
|
|
this.deviceSelect(device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-11-04 10:18:29 +08:00
|
|
|
methods:{
|
2020-11-05 15:31:28 +08:00
|
|
|
doShow(actionId) {
|
|
|
|
if (this.actionId === actionId && this.dialogVisible) {
|
|
|
|
this.handleClose();
|
|
|
|
} else {
|
|
|
|
this.tableData = [];
|
|
|
|
this.delay = 0;
|
|
|
|
this.actionId = actionId;
|
|
|
|
getActionCondition(this.$route.query.group, this.actionId).then(resp => {
|
|
|
|
if (resp.data) {
|
|
|
|
this.tableData = resp.data.trainStatuses;
|
|
|
|
this.delay = (resp.data.delay || 0) / 1000;
|
|
|
|
}
|
|
|
|
}).catch(()=> {
|
|
|
|
this.$message.error('获取条件失败');
|
|
|
|
});
|
|
|
|
this.dialogVisible = true;
|
|
|
|
}
|
2020-11-04 10:18:29 +08:00
|
|
|
},
|
|
|
|
handleClose() {
|
|
|
|
this.dialogVisible = false;
|
2020-11-04 14:48:36 +08:00
|
|
|
this.initData();
|
|
|
|
},
|
|
|
|
getSectionName(code) {
|
|
|
|
const section = this.$store.getters['map/getDeviceByCode'](code);
|
|
|
|
return section.name;
|
|
|
|
},
|
2020-11-04 16:41:01 +08:00
|
|
|
handleStopValue(stop) {
|
|
|
|
if (stop === 0) {
|
|
|
|
return '否';
|
|
|
|
} else if (stop === 1) {
|
|
|
|
return '是';
|
|
|
|
} else {
|
|
|
|
return '/';
|
|
|
|
}
|
|
|
|
},
|
2020-11-04 14:48:36 +08:00
|
|
|
handleEdit(index, row) {
|
|
|
|
this.updateIndex = index;
|
|
|
|
this.update = true;
|
|
|
|
this.formModel.code = row.code;
|
|
|
|
this.formModel.physicalCode = row.physicalCode;
|
|
|
|
this.formModel.stop = row.stop;
|
|
|
|
},
|
|
|
|
handleDelete(index, row) {
|
|
|
|
const data = [...this.tableData];
|
|
|
|
data.splice(index, 1);
|
2020-11-05 09:32:44 +08:00
|
|
|
const param = { trainStatuses: data };
|
|
|
|
if (this.delay) {
|
|
|
|
param.delay = this.delay * 1000;
|
|
|
|
}
|
|
|
|
updateActionCondition(this.$route.query.group, this.actionId, param).then(resp => {
|
2020-11-04 14:48:36 +08:00
|
|
|
this.tableData = data;
|
2020-11-04 16:41:01 +08:00
|
|
|
this.initData();
|
|
|
|
this.$message.success('删除条件成功');
|
2020-11-04 14:48:36 +08:00
|
|
|
}).catch(()=>{
|
|
|
|
this.$message.error('删除条件失败');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onUpdate() {
|
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
const data = [...this.tableData];
|
2020-11-04 16:41:01 +08:00
|
|
|
data[this.updateIndex] = {code: this.formModel.code, physicalCode: this.formModel.physicalCode, stop: this.formModel.stop};
|
2020-11-05 09:32:44 +08:00
|
|
|
const param = { trainStatuses: data };
|
|
|
|
if (this.delay) {
|
|
|
|
param.delay = this.delay * 1000;
|
|
|
|
}
|
|
|
|
updateActionCondition(this.$route.query.group, this.actionId, param).then(resp => {
|
2020-11-04 14:48:36 +08:00
|
|
|
this.tableData = data;
|
2020-11-04 16:41:01 +08:00
|
|
|
this.initData();
|
|
|
|
this.$message.success('修改条件成功');
|
2020-11-04 14:48:36 +08:00
|
|
|
}).catch(()=>{
|
|
|
|
this.$message.error('修改条件失败');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onUpdateDelay() {
|
2020-11-05 09:32:44 +08:00
|
|
|
const param = { trainStatuses: this.tableData };
|
|
|
|
if (this.delay) {
|
|
|
|
param.delay = this.delay * 1000;
|
|
|
|
}
|
|
|
|
updateActionCondition(this.$route.query.group, this.actionId, param).then(resp => {
|
2020-11-04 16:41:01 +08:00
|
|
|
this.initData();
|
|
|
|
this.$message.success('修改条件成功');
|
2020-11-04 14:48:36 +08:00
|
|
|
}).catch(()=>{
|
|
|
|
this.$message.error('修改条件失败');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
initData() {
|
|
|
|
this.update = false;
|
|
|
|
this.updateIndex = '';
|
2020-11-04 16:41:01 +08:00
|
|
|
this.$refs.form && this.$refs.form.resetFields();
|
2020-11-04 14:48:36 +08:00
|
|
|
},
|
|
|
|
onCommit() {
|
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
const data = [...this.tableData];
|
2020-11-04 16:41:01 +08:00
|
|
|
data.push({code: this.formModel.code, physicalCode: this.formModel.physicalCode, stop: this.formModel.stop});
|
2020-11-05 09:32:44 +08:00
|
|
|
const param = { trainStatuses: data };
|
|
|
|
if (this.delay) {
|
|
|
|
param.delay = this.delay * 1000;
|
|
|
|
}
|
|
|
|
updateActionCondition(this.$route.query.group, this.actionId, param).then(resp => {
|
2020-11-04 14:48:36 +08:00
|
|
|
this.tableData = data;
|
2020-11-04 16:41:01 +08:00
|
|
|
this.initData();
|
|
|
|
this.$message.success('添加条件成功');
|
2020-11-04 14:48:36 +08:00
|
|
|
}).catch(()=>{
|
|
|
|
this.$message.error('添加条件失败');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
hover(field) {
|
|
|
|
if (this.field === field) {
|
|
|
|
this.field = '';
|
|
|
|
} else {
|
|
|
|
this.field = field;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
deviceSelect(em) {
|
|
|
|
if (this.field.toUpperCase() === 'triggerSection'.toUpperCase() && em._type.toUpperCase() === 'Section'.toUpperCase()) {
|
|
|
|
this.formModel.physicalCode = em.code;
|
|
|
|
} else if (this.field.toUpperCase() === 'triggerTrain'.toUpperCase() && em._type.toUpperCase() === 'Train'.toUpperCase()) {
|
|
|
|
this.formModel.code = em.code;
|
|
|
|
}
|
2020-11-04 10:18:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2020-11-04 14:48:36 +08:00
|
|
|
.reminder-drag{
|
|
|
|
position: absolute;
|
|
|
|
bottom: 10px;
|
|
|
|
left: 15px;
|
|
|
|
z-index: 200;
|
|
|
|
padding: 5px;
|
|
|
|
background: #FFF;
|
|
|
|
width: 400px;
|
|
|
|
height: 600px;
|
2020-11-05 15:31:28 +08:00
|
|
|
border-radius: 5px;
|
2020-11-04 14:48:36 +08:00
|
|
|
}
|
2020-11-04 10:18:29 +08:00
|
|
|
</style>
|