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.

272 lines
7.4 KiB
Vue

<template>
<el-dialog
class="addPhotoDialog"
:title="photoDialogTitle"
2 years ago
:visible.sync="isShow"
:close-on-click-modal="false"
width="660px"
@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="lineVal">
<el-select v-model="formInfo.lineVal" placeholder="请选择">
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="towerVal">
<el-select v-model="formInfo.towerVal" 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="simCard">
<el-input v-model="formInfo.simCard" auto-complete="on"></el-input>
2 years ago
</el-form-item>
2 years ago
<el-form-item label="通道(可多选)" prop="channelVal">
<el-checkbox-group
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: {
// lineVal: "",
// towerVal: "",
// equipName: "",
// cmdid: "",
// simCard: "",
// displayName: "",
channelVal: [],
},
channelOptions: [], //所有通道列表
lineOptions: [], //线路
toweridOptions: [], //杆塔
rules: {
2 years ago
cmdid: [
{ required: true, message: "请输入装置ID", trigger: "blur" },
{ validator: validCmid, trigger: "blur" },
],
},
};
},
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;
},
// 保存确定操作
submitForm() {
2 years ago
this.$refs.formgrapInfo.validate((valid) => {
if (valid) {
2 years ago
console.log(valid);
if (this.photoDialogTitle == "新增") {
2 years ago
console.log(this.formInfo);
this.formInfo = {
channelid: this.formInfo.channelVal,
cmdid: this.formInfo.cmdid,
lineid: this.formInfo.lineVal,
equipName: this.formInfo.equipName,
sim: this.formInfo.simCard,
displayName: this.formInfo.cmdid,
towerid: this.formInfo.towerVal,
};
addTerminalJoggle(this.formInfo)
.then((res) => {
2 years ago
this.isShow = false;
this.$message.success("添加成功");
2 years ago
this.$parent.terminalList(); //刷新
})
.catch((err) => {
console.log(err); //代码错误、请求失败捕获
this.$message.error("添加失败");
});
2 years ago
} else {
this.formInfo = {
channelid: this.formInfo.channelVal,
cmdid: this.formInfo.cmdid,
2 years ago
lineid: this.formInfo.lineVal,
equipName: this.formInfo.equipName,
2 years ago
sim: this.formInfo.simCard,
displayName: this.formInfo.cmdid,
towerid: this.formInfo.towerVal,
};
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 {
console.log("error submit!!");
return false;
}
});
},
2 years ago
//获取所有线路
getLine() {
getSearchInfo({ type: 2 }).then((res) => {
console.log(res);
this.lineOptions = res.data.list;
if (res.data.list.length == 0) {
this.lineOptions = [];
this.formInfo.lineVal = "";
} else {
this.lineOptions = res.data.list;
this.formInfo.lineVal = res.data.list[0].id;
}
// this.dyOptions = res.data.list;
// this.formdata.dyid = res.data.list == [] ? "" : res.data.list[0].id;
this.getTower();
});
},
//获取所有杆塔
getTower() {
getSearchInfo({ type: 3, id: this.formInfo.lineVal })
.then((res) => {
console.log(res);
if (res.data.list.length == 0) {
this.toweridOptions = [];
this.formInfo.towerVal = "";
} else {
this.toweridOptions = res.data.list;
this.formInfo.towerVal = res.data.list[0].id;
}
})
.catch((err) => {});
},
2 years ago
//获取所有通道
getChannel() {
2 years ago
getAllChannelListJoggle()
2 years ago
.then((res) => {
this.channelOptions = res.data.list;
console.log(this.channelOptions);
})
.catch((err) => {
console.log(err);
});
},
2 years ago
display() {
this.isShow = true;
2 years ago
},
2 years ago
hide() {
this.isShow = false;
2 years ago
},
handleclose(){
this.$parent.terminalList();
}
}
};
</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;
}
}
}
}
}
</style>