2019-10-31 15:34:38 +08:00
|
|
|
<template>
|
2021-07-08 13:43:38 +08:00
|
|
|
<div>
|
|
|
|
<el-form ref="form" :rules="rules" :model="form" label-width="80px">
|
|
|
|
<el-form-item :label="this.$t('ibp.buttonCode')" prop="code">
|
|
|
|
<el-input v-model="form.code" :disabled="true">
|
|
|
|
<el-button slot="append" :disabled="isUpdate" type="primary" @click="generateCode">{{
|
|
|
|
$t("ibp.generateCode")
|
|
|
|
}}</el-button>
|
|
|
|
</el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.buttonColor')" prop="buttonColor">
|
|
|
|
<el-select v-model="form.buttonColor" :placeholder="this.$t('ibp.selectTheButtonColor')">
|
2021-07-12 10:37:14 +08:00
|
|
|
<el-option
|
|
|
|
v-for="item in colors"
|
|
|
|
:key="`btn${item}`"
|
|
|
|
:label="`${$t(`ibp.${item}`)}${$t('ibp.button')}`"
|
|
|
|
:value="item"
|
|
|
|
></el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.buttonLightColor')" prop="buttonLightColor">
|
|
|
|
<el-select v-model="form.buttonLightColor">
|
|
|
|
<el-option label="默认" value=""></el-option>
|
|
|
|
<el-option
|
|
|
|
v-for="item in colors"
|
|
|
|
:key="`light${item}`"
|
|
|
|
:label="`${$t(`ibp.${item}`)}`"
|
|
|
|
:value="item"
|
|
|
|
></el-option>
|
2021-07-08 13:43:38 +08:00
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.buttonWidth')" prop="buttonWidth">
|
|
|
|
<el-input-number v-model="form.buttonWidth" controls-position="right" :min="1" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.xCoordinate')">
|
|
|
|
<el-input-number v-model="form.x" controls-position="right" :min="1" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="this.$t('ibp.yCoordinate')">
|
|
|
|
<el-input-number v-model="form.y" controls-position="right" :min="1" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="操作">
|
|
|
|
<el-select v-model="form.mean" placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="item in operateMeanList"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item v-if="'AXLE_PRE_RESET' === form.mean" label="关联区段" prop="sectionCode">
|
|
|
|
<el-select v-model="form.sectionCode" filterable placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="item in sectionList"
|
|
|
|
:key="item.code"
|
|
|
|
:label="item.name + '(' + item.code + ')'"
|
|
|
|
:value="item.code"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item v-if="needDirectionItem" label="方向">
|
|
|
|
<el-select v-model="form.direction" placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="(item, i) in directions"
|
|
|
|
:key="i"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.value"
|
|
|
|
></el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button type="primary" @click="onSubmit('form')">{{ buttonText }}</el-button>
|
|
|
|
<el-button v-show="showDeleteButton" type="danger" @click="deleteDevice">{{
|
|
|
|
$t("global.delete")
|
|
|
|
}}</el-button>
|
|
|
|
<el-button v-show="showDeleteButton" @click="initPage">{{ $t("global.cancel") }}</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
2019-10-31 15:34:38 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-07-08 13:43:38 +08:00
|
|
|
import { getSectionListByCenStationCode, getSectionListByMapId } from "@/api/jmap/map";
|
2019-12-09 11:00:25 +08:00
|
|
|
export default {
|
2021-07-08 13:43:38 +08:00
|
|
|
name: "ButtonDraft",
|
|
|
|
components: {},
|
2019-12-09 11:00:25 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isUpdate: false,
|
2021-07-08 13:43:38 +08:00
|
|
|
buttonText: this.$t("ibp.createNow"),
|
2019-12-09 11:00:25 +08:00
|
|
|
showDeleteButton: false,
|
|
|
|
operateMeanList: [
|
2021-07-08 13:43:38 +08:00
|
|
|
{ label: "扣车", value: "KC" },
|
|
|
|
{ label: "终止扣车", value: "ZZKC" },
|
|
|
|
{ label: "紧急停车", value: "JJTC" },
|
|
|
|
{ label: "取消紧急停车", value: "QXJJTC" },
|
|
|
|
{ label: "报警切除", value: "BJQC" },
|
|
|
|
{ label: "屏蔽门开门", value: "KM" },
|
|
|
|
{ label: "屏蔽门关门", value: "GM" },
|
|
|
|
{ label: "计轴复位", value: "AXLE_RESET" },
|
2021-07-12 10:37:14 +08:00
|
|
|
{ label: "计轴区段复位", value: "AXLE_PRE_RESET" },
|
|
|
|
{ label: "计轴预复位", value: "PRERESET_Z" },
|
2021-07-08 13:43:38 +08:00
|
|
|
{ label: "试灯", value: "SD" }
|
2019-12-09 11:00:25 +08:00
|
|
|
],
|
2021-07-12 10:37:14 +08:00
|
|
|
colors: ["red", "yellow", "blue", "green", "gray"],
|
2021-07-08 13:43:38 +08:00
|
|
|
operateWithoutDirections: ["AXLE_RESET", "AXLE_PRE_RESET", "PRERESET_Z", "SD"],
|
2019-12-09 11:00:25 +08:00
|
|
|
form: {
|
2021-07-08 13:43:38 +08:00
|
|
|
code: "",
|
|
|
|
buttonColor: "red",
|
2021-07-12 10:37:14 +08:00
|
|
|
buttonLightColor: "",
|
2019-12-09 11:00:25 +08:00
|
|
|
buttonWidth: 25,
|
|
|
|
x: 10,
|
2021-02-23 13:04:29 +08:00
|
|
|
y: 10,
|
2021-07-08 13:43:38 +08:00
|
|
|
sectionCode: "",
|
|
|
|
mean: "",
|
|
|
|
direction: null
|
2019-12-09 11:00:25 +08:00
|
|
|
},
|
|
|
|
rules: {
|
2021-07-08 13:43:38 +08:00
|
|
|
code: [{ required: true, message: this.$t("ibp.enterTheButtonCode"), trigger: "blur" }],
|
|
|
|
buttonColor: [{ required: true, message: this.$t("ibp.selectTheButtonColor"), trigger: "change" }],
|
|
|
|
buttonWidth: [{ required: true, message: this.$t("ibp.enterTheButtonWidth"), trigger: "blur" }],
|
|
|
|
sectionCode: [{ required: true, message: "请选择关联区段", trigger: "blur" }]
|
2021-02-23 13:04:29 +08:00
|
|
|
},
|
2021-06-17 13:51:54 +08:00
|
|
|
sectionList: [],
|
2021-07-08 13:43:38 +08:00
|
|
|
directions: [{ name: "全部", value: null }, { name: "上行", value: true }, { name: "下行", value: false }]
|
2019-12-09 11:00:25 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2021-06-18 10:36:45 +08:00
|
|
|
needDirectionItem() {
|
|
|
|
return !this.operateWithoutDirections.includes(this.form.mean);
|
|
|
|
}
|
2019-12-09 11:00:25 +08:00
|
|
|
},
|
|
|
|
watch: {
|
2021-07-08 13:43:38 +08:00
|
|
|
"$store.state.ibp.rightClickCount": function(val) {
|
|
|
|
const model = this.$store.getters["ibp/updateDeviceData"];
|
|
|
|
if (model._type === "SquareButton") {
|
|
|
|
this.buttonText = this.$t("global.modify");
|
2019-12-09 11:00:25 +08:00
|
|
|
this.showDeleteButton = true;
|
|
|
|
this.isUpdate = true;
|
|
|
|
this.form.code = model.code;
|
|
|
|
this.form.buttonColor = model.color;
|
2021-07-12 10:37:14 +08:00
|
|
|
this.form.buttonLightColor = model.lightColor;
|
2019-12-09 11:00:25 +08:00
|
|
|
this.form.buttonWidth = model.width;
|
|
|
|
this.form.x = model.point.x;
|
|
|
|
this.form.y = model.point.y;
|
|
|
|
this.form.mean = model.mean;
|
2021-02-23 13:04:29 +08:00
|
|
|
this.form.sectionCode = model.sectionCode;
|
2021-06-17 13:51:54 +08:00
|
|
|
this.form.direction = model.direction;
|
2019-12-09 11:00:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-02-23 13:04:29 +08:00
|
|
|
if (this.$route.query.stationCode) {
|
2021-07-08 13:43:38 +08:00
|
|
|
getSectionListByCenStationCode(this.$route.query.mapId, this.$route.query.stationCode)
|
|
|
|
.then(resp => {
|
|
|
|
this.sectionList = resp.data;
|
|
|
|
// console.log(resp.data);
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message.error("获取区段列表失败!");
|
|
|
|
});
|
2021-02-23 13:04:29 +08:00
|
|
|
} else {
|
2021-07-08 13:43:38 +08:00
|
|
|
getSectionListByMapId(this.$route.query.mapId)
|
|
|
|
.then(resp => {
|
|
|
|
this.sectionList = resp.data;
|
|
|
|
console.log(resp.data);
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message.error("获取区段列表失败!");
|
|
|
|
});
|
2021-02-23 13:04:29 +08:00
|
|
|
}
|
2019-12-09 11:00:25 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onSubmit(form) {
|
2021-07-08 13:43:38 +08:00
|
|
|
this.$refs[form].validate(valid => {
|
2019-12-09 11:00:25 +08:00
|
|
|
if (valid) {
|
|
|
|
const buttonModel = {
|
|
|
|
point: {
|
|
|
|
x: this.form.x,
|
|
|
|
y: this.form.y
|
|
|
|
},
|
2021-07-08 13:43:38 +08:00
|
|
|
_type: "SquareButton",
|
2019-12-09 11:00:25 +08:00
|
|
|
code: this.form.code,
|
|
|
|
color: this.form.buttonColor,
|
2021-07-12 10:37:14 +08:00
|
|
|
lightColor: this.form.buttonLightColor,
|
2021-07-08 13:43:38 +08:00
|
|
|
status: "off",
|
2019-12-09 11:00:25 +08:00
|
|
|
width: this.form.buttonWidth,
|
2021-02-23 13:04:29 +08:00
|
|
|
mean: this.form.mean,
|
2021-06-17 13:51:54 +08:00
|
|
|
sectionCode: this.form.sectionCode,
|
2021-07-08 13:43:38 +08:00
|
|
|
direction: this.form.direction
|
2019-12-09 11:00:25 +08:00
|
|
|
};
|
2021-07-08 13:43:38 +08:00
|
|
|
this.$emit("createData", buttonModel);
|
2019-12-09 11:00:25 +08:00
|
|
|
this.initPage();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
2019-12-09 11:00:25 +08:00
|
|
|
deleteDevice() {
|
|
|
|
const buttonModel = {
|
|
|
|
point: {
|
|
|
|
x: this.form.x,
|
|
|
|
y: this.form.y
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
2021-07-08 13:43:38 +08:00
|
|
|
_type: "SquareButton",
|
2019-12-09 11:00:25 +08:00
|
|
|
code: this.form.code,
|
|
|
|
color: this.form.buttonColor,
|
2021-07-12 10:37:14 +08:00
|
|
|
lightColor: this.form.buttonLightColor,
|
2021-07-08 13:43:38 +08:00
|
|
|
status: "off",
|
2019-12-09 11:00:25 +08:00
|
|
|
width: this.form.buttonWidth,
|
2021-02-23 13:04:29 +08:00
|
|
|
mean: this.form.mean,
|
2021-06-17 13:51:54 +08:00
|
|
|
sectionCode: this.form.sectionCode,
|
2021-07-08 13:43:38 +08:00
|
|
|
direction: this.form.direction
|
2019-10-31 15:34:38 +08:00
|
|
|
};
|
2021-07-08 13:43:38 +08:00
|
|
|
this.$emit("deleteDataModel", buttonModel);
|
2019-12-09 11:00:25 +08:00
|
|
|
this.initPage();
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
2019-12-09 11:00:25 +08:00
|
|
|
initPage() {
|
|
|
|
this.isUpdate = false;
|
2021-07-08 13:43:38 +08:00
|
|
|
this.buttonText = this.$t("ibp.createNow");
|
2019-12-09 11:00:25 +08:00
|
|
|
this.showDeleteButton = false;
|
|
|
|
this.form = {
|
2021-07-08 13:43:38 +08:00
|
|
|
code: "",
|
|
|
|
buttonColor: "red",
|
2021-07-12 10:37:14 +08:00
|
|
|
buttonLightColor: "",
|
2019-12-09 11:00:25 +08:00
|
|
|
buttonWidth: 25,
|
|
|
|
x: 10,
|
|
|
|
y: 10,
|
2021-07-08 13:43:38 +08:00
|
|
|
mean: "",
|
|
|
|
sectionCode: "",
|
|
|
|
direction: null
|
2019-12-09 11:00:25 +08:00
|
|
|
};
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
2019-12-09 11:00:25 +08:00
|
|
|
generateCode() {
|
|
|
|
const mydate = new Date();
|
2021-07-08 13:43:38 +08:00
|
|
|
this.form.code =
|
|
|
|
"sButton_" +
|
|
|
|
mydate.getDay() +
|
|
|
|
mydate.getHours() +
|
|
|
|
mydate.getMinutes() +
|
|
|
|
mydate.getSeconds() +
|
|
|
|
mydate.getMilliseconds() +
|
|
|
|
Math.round(Math.random() * 10000);
|
2019-10-31 15:34:38 +08:00
|
|
|
}
|
2019-12-09 11:00:25 +08:00
|
|
|
}
|
|
|
|
};
|
2019-10-31 15:34:38 +08:00
|
|
|
</script>
|
2021-07-08 13:43:38 +08:00
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped></style>
|