自适应
parent
23ce13a318
commit
dd0237013f
@ -1,98 +1,98 @@
|
||||
<template>
|
||||
<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-item label="编码:" prop='postNum'>
|
||||
<el-input ref="postNum" v-focus v-model="form.postNum" autocomplete="on" style="width:200px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="名称:" prop='postName'>
|
||||
<el-input v-model="form.postName" autocomplete="on" style="width:200px"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleClose" size="mini">取 消</el-button>
|
||||
<el-button type="primary" size="mini" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { addBasePost, editBasePost } from "@/api/storeManage.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form: {}, //主对象
|
||||
rules: {
|
||||
postNum: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入职务编码",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
postName: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入职务名称",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
},
|
||||
title: "", //弹窗标题
|
||||
dialogFormVisible: false, //弹窗开关
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//关闭弹窗前的回调方法
|
||||
handleClose() {
|
||||
this.form = {};
|
||||
this.dialogFormVisible = false;
|
||||
this.$refs.form.clearValidate();
|
||||
},
|
||||
//组件传值
|
||||
show(row) {
|
||||
this.form = Object.assign({});
|
||||
if (row == "添加") {
|
||||
this.title = row;
|
||||
} else {
|
||||
this.title = "修改";
|
||||
this.form = Object.assign({}, row);
|
||||
}
|
||||
this.dialogFormVisible = true;
|
||||
setTimeout(() => {
|
||||
this.$refs.postNum.focus();
|
||||
this.$refs.postNum.select();
|
||||
}, 300);
|
||||
},
|
||||
//保存确定方法
|
||||
save() {
|
||||
this.$refs["form"].validate(async (valid) => {
|
||||
if (valid) {
|
||||
if (this.title == "添加") {
|
||||
await addBasePost(this.form).then((res) => this.callbackFun(res));
|
||||
} else {
|
||||
await editBasePost(this.form).then((res) => this.callbackFun(res));
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
//返回方法
|
||||
callbackFun(res) {
|
||||
if (res.code == "000000") {
|
||||
this.dialogFormVisible = false
|
||||
this.$message.success({ message: this.title + "成功" });
|
||||
this.$emit("editData");
|
||||
this.close();
|
||||
} else {
|
||||
this.$alert(res.message, "提示", {
|
||||
confirmButtonText: "确定",
|
||||
confirmButtonClass: "confirmbtnFalses",
|
||||
type: "warning",
|
||||
center: true,
|
||||
callback: (action) => {},
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<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-item label="编码:" prop='postNum'>
|
||||
<el-input ref="postNum" v-focus v-model="form.postNum" autocomplete="on" style="width:200px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="名称:" prop='postName'>
|
||||
<el-input v-model="form.postName" autocomplete="on" style="width:200px"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleClose" size="mini">取 消</el-button>
|
||||
<el-button type="primary" size="mini" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { addBasePost, editBasePost } from "@/api/storeManage.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form: {}, //主对象
|
||||
rules: {
|
||||
postNum: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入职务编码",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
postName: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入职务名称",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
},
|
||||
title: "", //弹窗标题
|
||||
dialogFormVisible: false, //弹窗开关
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//关闭弹窗前的回调方法
|
||||
handleClose() {
|
||||
this.form = {};
|
||||
this.dialogFormVisible = false;
|
||||
this.$refs.form.clearValidate();
|
||||
},
|
||||
//组件传值
|
||||
show(row) {
|
||||
this.form = Object.assign({});
|
||||
if (row == "添加") {
|
||||
this.title = row;
|
||||
} else {
|
||||
this.title = "修改";
|
||||
this.form = Object.assign({}, row);
|
||||
}
|
||||
this.dialogFormVisible = true;
|
||||
setTimeout(() => {
|
||||
this.$refs.postNum.focus();
|
||||
this.$refs.postNum.select();
|
||||
}, 300);
|
||||
},
|
||||
//保存确定方法
|
||||
save() {
|
||||
this.$refs["form"].validate(async (valid) => {
|
||||
if (valid) {
|
||||
if (this.title == "添加") {
|
||||
await addBasePost(this.form).then((res) => this.callbackFun(res));
|
||||
} else {
|
||||
await editBasePost(this.form).then((res) => this.callbackFun(res));
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
//返回方法
|
||||
callbackFun(res) {
|
||||
if (res.code == "000000") {
|
||||
this.dialogFormVisible = false;
|
||||
this.$message.success({ message: this.title + "成功" });
|
||||
this.$emit("editData");
|
||||
this.close();
|
||||
} else {
|
||||
this.$alert(res.message, "提示", {
|
||||
confirmButtonText: "确定",
|
||||
confirmButtonClass: "confirmbtnFalses",
|
||||
type: "warning",
|
||||
center: true,
|
||||
callback: (action) => {},
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue