|
|
|
<template>
|
|
|
|
<el-dialog
|
|
|
|
class="addtowerDialog"
|
|
|
|
:title="title"
|
|
|
|
:visible.sync="isShow"
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
width="470px"
|
|
|
|
@close="handleClose"
|
|
|
|
>
|
|
|
|
<el-form
|
|
|
|
label-position="left"
|
|
|
|
ref="formInfo"
|
|
|
|
label-width="100px"
|
|
|
|
:rules="rules"
|
|
|
|
:model="formdata"
|
|
|
|
>
|
|
|
|
<el-form-item label="杆塔名称:" prop="name">
|
|
|
|
<el-input v-model="formdata.name" autocomplete="off"></el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="线路编号:" prop="lineId">
|
|
|
|
<el-select v-model="formdata.lineId" placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="item in lineOptions"
|
|
|
|
:key="item.id"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.id"
|
|
|
|
></el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button @click="isShow = false">取 消</el-button>
|
|
|
|
<el-button type="primary" @click="submitForm()">确 定</el-button>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { getLineListApi, addTowerApi, updateTowerApi } from "@/utils/api/index";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
title: String,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isShow: false,
|
|
|
|
lineOptions: [],
|
|
|
|
formdata: {},
|
|
|
|
rules: {
|
|
|
|
name: [{ required: true, message: "请输入杆塔名称", trigger: "blur" }],
|
|
|
|
lineId: [
|
|
|
|
{ required: true, message: "请选择线路编号", trigger: "blur" },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.getLineListdata();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getLineListdata() {
|
|
|
|
getLineListApi({ pageindex: 1, pagesize: 100 })
|
|
|
|
.then((res) => {
|
|
|
|
this.lineOptions = res.data.list;
|
|
|
|
})
|
|
|
|
.catch((err) => {});
|
|
|
|
},
|
|
|
|
//判断
|
|
|
|
getdataform(val) {
|
|
|
|
if (val == null) {
|
|
|
|
return (this.formdata = {});
|
|
|
|
}
|
|
|
|
this.formdata = val;
|
|
|
|
},
|
|
|
|
// 保存确定操作
|
|
|
|
submitForm() {
|
|
|
|
this.$refs.formInfo.validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
if (this.title == "新增") {
|
|
|
|
let formArr = [];
|
|
|
|
formArr.push(this.formdata);
|
|
|
|
addTowerApi({ list: formArr })
|
|
|
|
.then((res) => {
|
|
|
|
this.isShow = false;
|
|
|
|
this.$message.success("添加成功");
|
|
|
|
this.$parent.deviceList();
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.$message.error("添加失败");
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
updateTowerApi(this.formdata)
|
|
|
|
.then((res) => {
|
|
|
|
this.isShow = false;
|
|
|
|
this.$message.success("修改成功");
|
|
|
|
this.$parent.deviceList();
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.$message.error("修改失败");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log("error submit!!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
display() {
|
|
|
|
this.isShow = true;
|
|
|
|
},
|
|
|
|
hide() {
|
|
|
|
this.isShow = false;
|
|
|
|
},
|
|
|
|
handleClose() {
|
|
|
|
this.$parent.deviceList();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="less">
|
|
|
|
.addtowerDialog {
|
|
|
|
.el-select {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|