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.

407 lines
11 KiB
Vue

<template>
<el-dialog
class="addPhotoDialog"
:title="photoDialogTitle"
2 years ago
:visible.sync="isShow"
:close-on-click-modal="false"
2 years ago
width="800px"
@close="handleclose"
>
<el-form
label-position="left"
2 years ago
label-width="74px"
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">
2 years ago
<el-select v-model="formInfo.towerId" placeholder="请选择" filterable>
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>
2 years ago
<el-form-item label="装置ID" prop="cmdId">
<el-input v-model="formInfo.cmdId" autocomplete="on"></el-input>
2 years ago
</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-divider></el-divider>
<h4>添加通道</h4>
<div class="addchannel" ref="channelBoxref">
<div
class="channelBoxadd"
v-for="(val, index) in formInfo.list"
2 years ago
:key="index"
2 years ago
>
2 years ago
<el-form-item label="通道号:">
<el-select
2 years ago
v-model="val.id"
2 years ago
placeholder="请选择通道号"
@change="changeHandle"
2 years ago
>
<el-option
v-for="item in filterOption"
2 years ago
:key="item.id"
:label="item.channelname"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="通道名称:">
<el-input
2 years ago
v-model="val.alias"
2 years ago
placeholder="请输入通道名称"
></el-input>
</el-form-item>
<div class="btngrop">
<el-button
v-if="index !== 0"
type="danger"
icon="el-icon-minus"
2 years ago
@click="deleteModule(val, index)"
2 years ago
></el-button>
<el-button
icon="el-icon-plus"
type="primary"
@click="addModule()"
v-if="index + 1 == formInfo.list.length"
2 years ago
></el-button>
</div>
</div>
2 years ago
<!-- <el-form-item label="通道(可多选)" prop="id">
2 years ago
<el-checkbox-group
class="channelBox"
2 years ago
v-model="formInfo.id"
2 years ago
v-if="channelOptions.length > 0"
2 years ago
>
2 years ago
<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> -->
</div>
</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
getLineAndGtInfo,
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) => {
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,
2 years ago
formInfo: {},
2 years ago
channelOptions: [], //所有通道列表
2 years ago
filterOption: [], //筛选后的通道列表
2 years ago
lineOptions: [], //线路
toweridOptions: [], //杆塔
rules: {
2 years ago
cmdId: [
2 years ago
{ required: true, message: "请输入装置ID", trigger: "blur" },
{ validator: validCmid, trigger: "blur" },
],
},
photoDialogtype: 0, //1 线路change时修改杆塔数据
};
},
mounted() {},
created() {},
watch: {},
methods: {
2 years ago
//判断
getdataform(val) {
this.getLine();
this.getChannel();
2 years ago
if (val == null) {
return (this.formInfo = {
2 years ago
lineId: "",
towerId: "",
cmdId: "",
equipName: "",
sim: "",
list: [
2 years ago
{
2 years ago
id: "",
alias: "",
2 years ago
},
],
2 years ago
});
}
this.formInfo = val;
},
//通道号值改变
2 years ago
changeHandle() {
this.filterOption = this.channelOptions.filter(
(val) => !this.formInfo.list.some((item) => item.id === val.id)
);
2 years ago
},
2 years ago
//新增一行
addModule() {
//新增一行
this.formInfo.list.push({
2 years ago
id: "",
2 years ago
alias: "",
2 years ago
});
2 years ago
this.filterOption = this.channelOptions.filter(
(val) => !this.formInfo.list.some((item) => item.id === val.id)
);
2 years ago
this.$nextTick(() => {
console.log(this.$refs.channelBoxref);
if (this.$refs.channelBoxref) {
console.log(this.$refs.channelBoxref.scrollHeight);
2 years ago
this.$refs.channelBoxref.scrollTop =
this.$refs.channelBoxref.scrollHeight;
2 years ago
}
});
},
//删除一行
deleteModule(item, index) {
console.log(item, index);
const itemList = this.formInfo.list.indexOf(item);
2 years ago
if (itemList !== -1) {
this.formInfo.list.splice(index, 1);
2 years ago
}
2 years ago
this.filterOption = this.channelOptions.filter(
(val) => !this.formInfo.list.some((item) => item.id === val.id)
);
2 years ago
},
// 保存确定操作
submitForm() {
2 years ago
const newListLength = new Set(this.formInfo.list.map((item) => item.id))
.size;
const listLength = this.formInfo.list.length;
2 years ago
if (listLength > newListLength) {
return this.$message.error("通道不能重复");
}
2 years ago
this.$refs.formgrapInfo.validate((valid) => {
if (valid) {
if (this.photoDialogTitle == "新增") {
2 years ago
// this.formInfo = {
// lineId: this.formInfo.lineId,
// towerId: this.formInfo.towerId,
// cmdId: this.formInfo.cmdId,
// equipName: this.formInfo.equipName,
// sim: this.formInfo.sim,
// list: this.formInfo.list,
2 years ago
// displayName: this.formInfo.cmdId,
// };
2 years ago
this.$set(this.formInfo, "displayName", this.formInfo.cmdId);
2 years ago
addTerminalJoggle(this.formInfo)
.then((res) => {
2 years ago
this.isShow = false;
2 years ago
this.$message({
duration: 1500,
2 years ago
showClose: true,
message: "添加成功",
type: "success",
});
2 years ago
this.$parent.terminalList(); //刷新
})
.catch((err) => {
2 years ago
this.$message({
duration: 1500,
2 years ago
showClose: true,
message: "添加失败",
type: "error",
});
});
2 years ago
} else {
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() {
2 years ago
getLineAndGtInfo({ type: 1 }).then((res) => {
2 years ago
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 == "新增") {
2 years ago
// this.formInfo.lineId = res.data.list[0].id;
this.$set(this.formInfo, "lineId", res.data.list[0].id);
2 years ago
}
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
getLineAndGtInfo({ type: 2, 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;
this.filterOption = res.data.list;
this.formInfo.list[0].id = this.filterOption[0].id;
2 years ago
})
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: 364px;
margin-right: 16px;
2 years ago
.el-select {
width: 100%;
}
.el-checkbox-group {
.el-checkbox {
margin-right: 12px;
}
}
2 years ago
.el-form-item__label {
padding-right: 0px;
}
}
2 years ago
.el-divider--horizontal {
margin: 12px;
}
h4 {
font-size: 16px;
font-weight: normal;
margin-bottom: 6px;
line-height: 24px;
}
.addchannel {
max-height: 200px;
overflow: auto;
.channelBoxadd {
display: flex;
//justify-content: space-between;
padding-right: 6px;
.el-form-item {
width: 310px;
}
.btngrop {
margin-bottom: 16px;
margin-left: 16px;
height: 32px;
.el-button--small {
padding: 9px 8px;
width: 30px;
}
}
}
}
.channelBox {
.el-checkbox {
margin-right: 12px;
margin-left: 0px;
margin-bottom: 8px;
}
}
}
}
}
</style>