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.

147 lines
3.6 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<el-dialog
class="addLineDialog"
:title="lineDialogTitle"
:visible.sync="isShow"
:close-on-click-modal="false"
width="420px"
>
<el-form
label-position="left"
label-width="92px"
ref="formLineInfo"
:rules="rules"
:model="formdata"
>
<el-form-item label="单位:" prop="bsManufacturer">
<el-input
v-model="formdata.bsManufacturer"
autocomplete="off"
></el-input>
</el-form-item>
<el-form-item label="DY等级" prop="dyLevelid">
<el-select v-model="formdata.dyLevelid" placeholder="请选择电压等级">
<el-option
v-for="items in dyOptions"
:key="items.id"
:label="items.name"
:value="items.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="线路名称:" prop="name">
<el-input v-model="formdata.name" autocomplete="off"></el-input>
</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 {
addLineJoggle,
updateLineJoggle,
getdyListJoggle,
} from "@/utils/api/index";
export default {
props: {
lineDialogTitle: String,
},
data() {
return {
isShow: false,
formdata: {},
dyOptions: "",
rules: {
bsManufacturer: [
{ required: true, message: "请输入公司名称", trigger: "blur" },
],
dyLevelid: [
{ required: true, message: "请选择DY等级", trigger: "change" },
],
name: [
{
required: true,
message: "请输入线路名称",
trigger: "blur",
},
],
},
};
},
methods: {
//判断
getdataform(val) {
console.log(val);
if (val == null) {
return (this.formdata = {});
}
this.formdata = val;
//this.$set(this.formdata);
},
// 保存确定操作
submitForm() {
this.$refs.formLineInfo.validate((valid) => {
if (valid) {
// 走保存请求
if (this.lineDialogTitle == "新增") {
let formArr = [];
formArr.push(this.formdata);
console.log(formArr);
addLineJoggle({ list: formArr })
.then((res) => {
this.isShow = false;
this.$message.success("添加成功");
this.$parent.lineList();
})
.catch((err) => {
console.log(err); //代码错误、请求失败捕获
this.$message.error("添加失败");
});
} else {
updateLineJoggle(this.formdata)
.then((res) => {
this.isShow = false;
this.$message.success("修改成功");
this.$parent.lineList();
})
.catch((err) => {
this.$message.error("修改失败");
});
}
} else {
console.log("error submit!!");
return false;
}
});
},
display() {
this.isShow = true;
},
hide() {
this.isShow = false;
},
},
created() {
getdyListJoggle().then((res) => {
console.log(res);
this.dyOptions = res.data.list;
console.log(this.dyOptions);
});
},
};
</script>
<style lang="less">
.addLineDialog {
.el-select {
width: 100%;
}
}
</style>