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.

113 lines
2.8 KiB
Vue

<template>
<div class="sblxAddBox">
<el-dialog
class="sblxAddDialogBox"
:title="title"
:visible.sync="sblxDialogshow"
width="520px"
>
<el-form
label-position="left"
ref="formInfo"
label-width="104px"
:rules="rules"
:model="formInfo"
>
<el-form-item label="名称:" prop="mc">
<el-input v-model="formInfo.mc"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="hide"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { sblxAddApi, sblxUpdateApi } from "@/utils/api/index";
export default {
props: ["title"],
data() {
return {
sblxDialogshow: false,
formInfo: {},
rules: {
mc: [{ required: true, message: "请输入名称", trigger: "blur" }],
},
bdzOptions: [],
};
},
created() {},
mounted() {},
watch: {},
methods: {
//判断
getdataform(val) {
console.log(val);
this.formInfo = JSON.parse(JSON.stringify(val));
},
submitForm() {
this.$refs.formInfo.validate((valid) => {
if (valid) {
if (this.title == "添加设备类型") {
console.log(this.formInfo);
sblxAddApi(this.formInfo)
.then((res) => {
if (res.success) {
this.$message({
duration: 1500,
showClose: true,
message: "添加成功",
type: "success",
});
this.hide();
this.$parent.getsblxAllList(); //刷新
}
})
.catch((err) => {});
} else {
sblxUpdateApi(this.formInfo)
.then((res) => {
if (res.success) {
this.$message({
duration: 1500,
showClose: true,
message: "修改成功",
type: "success",
});
this.hide();
this.$parent.getsblxAllList(); //刷新
}
})
.catch((err) => {});
}
} else {
console.log("error submit!!");
return false;
}
});
},
display() {
this.sblxDialogshow = true;
1 year ago
if (this.title == "添加设备类型") {
this.formInfo.mc = "";
}
},
hide() {
this.sblxDialogshow = false;
this.$refs.formInfo.resetFields(); // 重置表单字段值
},
},
};
</script>
<style lang="less">
.sblxAddBox {
.sblxAddDialogBox {
.el-select {
width: 376px;
}
}
}
</style>