You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

303 lines
8.2 KiB
Vue

<template>
<el-dialog
class="addPhotoDialog"
:title="photoDialogTitle"
2 years ago
:visible.sync="isShow"
:close-on-click-modal="false"
width="576px"
@close="handleclose"
>
<el-form
label-position="left"
2 years ago
label-width="98px"
2 years ago
ref="formgrapInfo"
:rules="rules"
:model="formInfo"
>
2 years ago
<el-form-item label="线路" prop="lineid">
2 years ago
<el-select
2 years ago
v-model="formInfo.lineid"
2 years ago
placeholder="请选择"
2 years ago
@change="getTowerchange"
2 years ago
>
2 years ago
<el-option
2 years ago
v-for="item in lineOptions"
2 years ago
:key="item.id"
2 years ago
:label="item.name"
2 years ago
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
2 years ago
<el-form-item label="杆塔:" prop="towerid">
<el-select v-model="formInfo.towerid" placeholder="请选择">
2 years ago
<el-option
2 years ago
v-for="item in toweridOptions"
2 years ago
:key="item.id"
2 years ago
:label="item.name"
2 years ago
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="装置ID" prop="cmdid">
2 years ago
<el-input v-model="formInfo.cmdid" auto-complete="on"></el-input>
2 years ago
</el-form-item>
2 years ago
<!-- <el-form-item label="显示名:" prop="displayName" required>
<el-input v-model="formInfo.displayName" auto-complete="on"></el-input>
</el-form-item> -->
<el-form-item label="装置名称:" prop="equipName">
2 years ago
<el-input v-model="formInfo.equipName" auto-complete="on"></el-input>
</el-form-item>
2 years ago
<el-form-item label="SIM卡" prop="sim">
<el-input v-model="formInfo.sim" auto-complete="on"></el-input>
2 years ago
</el-form-item>
2 years ago
<el-form-item label="通道(可多选)" prop="channelVal">
<el-checkbox-group
class="channelBox"
2 years ago
v-model="formInfo.channelVal"
v-if="channelOptions.length > 0"
>
<el-checkbox
border
v-for="item in channelOptions"
:key="item.id"
:label="item.id"
:value="item.channelname"
>{{ item.channelname }}</el-checkbox
>
</el-checkbox-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
2 years ago
<el-button @click="isShow = false"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</template>
<script>
2 years ago
import {
addTerminalJoggle,
updateTerminalJoggle,
2 years ago
getAllChannelListJoggle,
2 years ago
getSearchInfo,
2 years ago
} from "@/utils/api/index";
export default {
props: {
photoDialog: {
type: Boolean,
},
photoDialogTitle: {
type: String,
default: "新增",
},
},
data() {
2 years ago
let validCmid = (rule, value, callback) => {
2 years ago
let reg = /^[0-9A-Za-z]{17}$/;
2 years ago
if (!reg.test(value)) {
2 years ago
callback(new Error("装置id为17位编码"));
2 years ago
} else {
callback();
}
};
return {
2 years ago
isShow: false,
formInfo: {
2 years ago
// lineid: "",
// towerid: "",
2 years ago
// equipName: "",
// cmdid: "",
2 years ago
// sim: "",
2 years ago
// displayName: "",
channelVal: [],
},
channelOptions: [], //所有通道列表
lineOptions: [], //线路
toweridOptions: [], //杆塔
rules: {
2 years ago
cmdid: [
{ required: true, message: "请输入装置ID", trigger: "blur" },
{ validator: validCmid, trigger: "blur" },
],
},
photoDialogtype: 0, //1 线路change时修改杆塔数据
};
},
mounted() {},
created() {},
watch: {},
methods: {
2 years ago
//判断
getdataform(val) {
console.log(val);
this.getLine();
this.getChannel();
2 years ago
if (val == null) {
return (this.formInfo = {
channelVal: [],
});
}
this.formInfo = val;
2 years ago
let channelnr = [];
val.list.forEach((item) => {
channelnr.push(item.id);
});
2 years ago
this.$set(this.formInfo, "channelVal", channelnr);
2 years ago
},
// 保存确定操作
submitForm() {
2 years ago
this.$refs.formgrapInfo.validate((valid) => {
if (valid) {
if (this.photoDialogTitle == "新增") {
2 years ago
this.formInfo = {
channelid: this.formInfo.channelVal,
cmdid: this.formInfo.cmdid,
2 years ago
lineid: this.formInfo.lineid,
2 years ago
equipName: this.formInfo.equipName,
2 years ago
sim: this.formInfo.sim,
2 years ago
displayName: this.formInfo.cmdid,
2 years ago
towerid: this.formInfo.towerid,
2 years ago
};
addTerminalJoggle(this.formInfo)
.then((res) => {
2 years ago
this.isShow = false;
2 years ago
this.$message({
showClose: true,
message: "添加成功",
type: "success",
});
2 years ago
this.$parent.terminalList(); //刷新
})
.catch((err) => {
2 years ago
this.$message({
showClose: true,
message: "添加失败",
type: "error",
});
});
2 years ago
} else {
this.formInfo = {
channelid: this.formInfo.channelVal,
cmdid: this.formInfo.cmdid,
2 years ago
lineid: this.formInfo.lineid,
equipName: this.formInfo.equipName,
2 years ago
sim: this.formInfo.sim,
2 years ago
displayName: this.formInfo.cmdid,
2 years ago
towerid: this.formInfo.towerid,
2 years ago
id: this.formInfo.id,
};
2 years ago
updateTerminalJoggle(this.formInfo)
.then((res) => {
2 years ago
this.isShow = false;
this.$message.success("修改成功");
this.$parent.terminalList();
})
.catch((err) => {
this.$message.error("修改失败");
});
}
} else {
return false;
}
});
},
2 years ago
//获取所有线路
getLine() {
getSearchInfo({ type: 2 }).then((res) => {
this.lineOptions = res.data.list;
if (res.data.list.length == 0) {
this.lineOptions = [];
2 years ago
this.formInfo.lineid = "";
2 years ago
} else {
this.lineOptions = res.data.list;
2 years ago
if (this.photoDialogTitle == "新增") {
// this.formInfo.lineid = res.data.list[0].id;
this.$set(this.formInfo, "lineid", res.data.list[0].id);
}
2 years ago
}
// this.dyOptions = res.data.list;
// this.formdata.dyid = res.data.list == [] ? "" : res.data.list[0].id;
this.getTower();
});
},
//获取所有杆塔
getTower() {
2 years ago
getSearchInfo({ type: 3, id: this.formInfo.lineid })
2 years ago
.then((res) => {
if (res.data.list.length == 0) {
this.toweridOptions = [];
2 years ago
this.formInfo.towerid = "";
2 years ago
} else {
this.toweridOptions = res.data.list;
if (this.photoDialogTitle == "新增" || this.photoDialogtype == 1) {
2 years ago
// this.formInfo.towerid = res.data.list[0].id;
this.$set(this.formInfo, "towerid", res.data.list[0].id);
this.photoDialogtype = 0;
2 years ago
}
2 years ago
}
})
.catch((err) => {});
},
getTowerchange() {
2 years ago
if (this.photoDialogTitle == "修改") {
this.photoDialogtype = 1;
2 years ago
}
this.getTower();
2 years ago
},
2 years ago
//获取所有通道
getChannel() {
2 years ago
getAllChannelListJoggle()
2 years ago
.then((res) => {
this.channelOptions = res.data.list;
})
2 years ago
.catch((err) => {});
2 years ago
},
2 years ago
display() {
this.isShow = true;
2 years ago
},
2 years ago
hide() {
this.isShow = false;
2 years ago
},
2 years ago
handleclose() {
this.$parent.terminalList();
2 years ago
},
},
};
</script>
<style lang="less">
.addPhotoDialog {
.el-dialog {
.el-form {
2 years ago
//display: flex;
// flex-wrap: wrap;
2 years ago
.el-form-item {
2 years ago
// width: 260px;
// margin-right: 16px;
.el-select {
width: 100%;
}
.el-checkbox-group {
.el-checkbox {
margin-right: 12px;
}
}
2 years ago
.el-form-item__label {
padding-right: 0px;
}
}
.channelBox {
.el-checkbox {
margin-right: 12px;
margin-left: 0px;
margin-bottom: 8px;
}
}
}
}
}
</style>