emis-frontend/src/views/emis/emisPrintTplRel/emisPrintTplRelForm.vue
2024-05-13 05:27:19 +08:00

175 lines
4.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div >
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row :gutter="0" style="display: flex;flex-wrap: wrap;">
<el-col :span="24">
<el-form-item label="模版代码" prop="tplCode">
<el-input v-model="form.tplCode" placeholder="请输入模版代码" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="模板名称" prop="tplName">
<el-input v-model="form.tplName" placeholder="请输入模板名称" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="删除标志(0代表存在" prop="delFlag">
<el-input v-model="form.delFlag" placeholder="请输入删除标志(0代表存在" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-col>
<!--
<el-form-item label="上级字典">
<treeselect
ref="tree"
v-model="form.parentId"
:options="emisPrintTplRelOptions"
:normalizer="normalizer"
:default-expand-level="1"
:show-count="true"
placeholder="选择上级"
/>
</el-form-item>
-->
</el-row>
</el-form>
<div style="text-align: center;margin-bottom: 10px;">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</div>
</template>
<script>
import { listEmisPrintTplRel, getEmisPrintTplRel, delEmisPrintTplRel, addEmisPrintTplRel, updateEmisPrintTplRel } from "@/api/emis/emisPrintTplRel";
export default {
name: "emisPrintTplRelForm",
props:{
id:{
type:Number
}
},
components: { },
dicts: [
],
data() {
return {
emisPrintTplRelOptions: [],
// 遮罩层
loading: true,
// 表单参数
form: {},
// 表单校验
rules: {
id: [
{ required: true, message: "id不能为空", trigger: "blur" }
],
}
};
},
watch: {
"id": {
handler (newValue, oldValue) {
this.id = newValue;
this.initData();
},
deep: true
}
},
created() {
this.initData();
},
methods: {
initData() {
if(this.id !=null) {
this.loading = true;
getEmisPrintTplRel(this.id).then(response => {
this.form = response.data;
this.loading = false;
});
}else{
this.reset();
}
// this.getTreeselect();
},
// 取消按钮
cancel() {
this.reset();
this.$emit("on-cancel");
},
// 表单重置
reset() {
this.form = {
id: null,
merchId: null,
tplId: null,
tplCode: null,
tplName: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
createSite: null,
updateSite: null
};
this.resetForm("form");
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateEmisPrintTplRel(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.$emit("on-changed");
});
} else {
addEmisPrintTplRel(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.$emit("on-changed");
});
}
}
});
},
// /** 转换菜单数据结构 */
// normalizer(node) {
// if (node.children && !node.children.length) {
// delete node.children;
// }
// return {
// id: node.id,
// label: node.idName,
// children: node.children
// };
// },
// /** 查询菜单下拉树结构 */
// getTreeselect() {
// const queryParams = {}
// listEmisPrintTplRel(queryParams).then(response => {
// this.emisPrintTplRelOptions = [];
// const rootItem = { idId: 0, emisPrintTplRelName: '-', children: [] };
// rootItem.children = this.handleTree(response.data, "id");
// this.emisPrintTplRelOptions.push(rootItem);
// if(this.parentId != undefined) {
// this.form.parentId = this.parentId;
// }
// });
// },
}
};
</script>