自适应

master
十七 4 years ago
parent 23ce13a318
commit dd0237013f

@ -1,98 +1,98 @@
<template> <template>
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" :before-close="handleClose"> <el-dialog :title="title+'职务'" :visible.sync="dialogFormVisible" width="500px" :before-close="handleClose">
<el-form ref="form" :model="form" :rules="rules" label-width="100px"> <el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="编码:" prop='postNum'> <el-form-item label="编码:" prop='postNum'>
<el-input ref="postNum" v-focus v-model="form.postNum" autocomplete="on" style="width:200px"></el-input> <el-input ref="postNum" v-focus v-model="form.postNum" autocomplete="on" style="width:200px"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="名称:" prop='postName'> <el-form-item label="名称:" prop='postName'>
<el-input v-model="form.postName" autocomplete="on" style="width:200px"></el-input> <el-input v-model="form.postName" autocomplete="on" style="width:200px"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="handleClose" size="mini"> </el-button> <el-button @click="handleClose" size="mini"> </el-button>
<el-button type="primary" size="mini" @click="save"> </el-button> <el-button type="primary" size="mini" @click="save"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { addBasePost, editBasePost } from "@/api/storeManage.js"; import { addBasePost, editBasePost } from "@/api/storeManage.js";
export default { export default {
data() { data() {
return { return {
form: {}, // form: {}, //
rules: { rules: {
postNum: [ postNum: [
{ {
required: true, required: true,
message: "请输入职务编码", message: "请输入职务编码",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
], ],
postName: [ postName: [
{ {
required: true, required: true,
message: "请输入职务名称", message: "请输入职务名称",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
], ],
}, },
title: "", // title: "", //
dialogFormVisible: false, // dialogFormVisible: false, //
}; };
}, },
methods: { methods: {
// //
handleClose() { handleClose() {
this.form = {}; this.form = {};
this.dialogFormVisible = false; this.dialogFormVisible = false;
this.$refs.form.clearValidate(); this.$refs.form.clearValidate();
}, },
// //
show(row) { show(row) {
this.form = Object.assign({}); this.form = Object.assign({});
if (row == "添加") { if (row == "添加") {
this.title = row; this.title = row;
} else { } else {
this.title = "修改"; this.title = "修改";
this.form = Object.assign({}, row); this.form = Object.assign({}, row);
} }
this.dialogFormVisible = true; this.dialogFormVisible = true;
setTimeout(() => { setTimeout(() => {
this.$refs.postNum.focus(); this.$refs.postNum.focus();
this.$refs.postNum.select(); this.$refs.postNum.select();
}, 300); }, 300);
}, },
// //
save() { save() {
this.$refs["form"].validate(async (valid) => { this.$refs["form"].validate(async (valid) => {
if (valid) { if (valid) {
if (this.title == "添加") { if (this.title == "添加") {
await addBasePost(this.form).then((res) => this.callbackFun(res)); await addBasePost(this.form).then((res) => this.callbackFun(res));
} else { } else {
await editBasePost(this.form).then((res) => this.callbackFun(res)); await editBasePost(this.form).then((res) => this.callbackFun(res));
} }
} else { } else {
return false; return false;
} }
}); });
}, },
// //
callbackFun(res) { callbackFun(res) {
if (res.code == "000000") { if (res.code == "000000") {
this.dialogFormVisible = false this.dialogFormVisible = false;
this.$message.success({ message: this.title + "成功" }); this.$message.success({ message: this.title + "成功" });
this.$emit("editData"); this.$emit("editData");
this.close(); this.close();
} else { } else {
this.$alert(res.message, "提示", { this.$alert(res.message, "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
confirmButtonClass: "confirmbtnFalses", confirmButtonClass: "confirmbtnFalses",
type: "warning", type: "warning",
center: true, center: true,
callback: (action) => {}, callback: (action) => {},
}); });
} }
}, },
}, },
}; };
</script> </script>

Loading…
Cancel
Save