lanan-system-vue/src/views/base/cont/form/ContTempForm.vue
2024-08-08 11:41:02 +08:00

130 lines
5.1 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 class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
<el-form-item label="模板编号" prop="tempCode">
<el-input v-model="formData.tempCode" placeholder="请输入模板编号" />
</el-form-item>
<el-form-item label="模板类型" prop="tempType">
<el-select v-model="formData.tempType" placeholder="请选择模板类型">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="模板用途" prop="tempUse">
<el-input v-model="formData.tempUse" placeholder="请输入模板用途" />
</el-form-item>
<el-form-item label="模板名称" prop="tempName">
<el-input v-model="formData.tempName" placeholder="请输入模板名称" />
</el-form-item>
<el-form-item label="是否有效0否1是" prop="isValid">
<el-input v-model="formData.isValid" placeholder="请输入是否有效0否1是" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="模板内容">
<Editor v-model="formData.tempContent" :min-height="192"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import * as ContTempApi from '@/api/base/cont';
import Editor from '@/components/Editor';
export default {
name: "ContTempForm",
components: {
Editor,
},
data() {
return {
// 弹出层标题
dialogTitle: "",
// 是否显示弹出层
dialogVisible: false,
// 表单的加载中1修改时的数据加载2提交的按钮禁用
formLoading: false,
// 表单参数
formData: {
id: undefined,
tempCode: undefined,
tempType: undefined,
tempUse: undefined,
tempName: undefined,
isValid: undefined,
status: undefined,
tempContent: undefined,
},
// 表单校验
formRules: {
},
};
},
methods: {
/** 打开弹窗 */
async open(id) {
this.dialogVisible = true;
this.reset();
// 修改时,设置数据
if (id) {
this.formLoading = true;
try {
const res = await ContTempApi.getContTemp(id);
this.formData = res.data;
this.title = "修改合同模板";
} finally {
this.formLoading = false;
}
}
this.title = "新增合同模板";
},
/** 提交按钮 */
async submitForm() {
// 校验主表
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
const data = this.formData;
// 修改的提交
if (data.id) {
await ContTempApi.updateContTemp(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit('success');
return;
}
// 添加的提交
await ContTempApi.createContTemp(data);
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit('success');
} finally {
this.formLoading = false;
}
},
/** 表单重置 */
reset() {
this.formData = {
id: undefined,
tempCode: undefined,
tempType: undefined,
tempUse: undefined,
tempName: undefined,
isValid: undefined,
status: undefined,
tempContent: undefined,
};
this.resetForm("formRef");
}
}
};
</script>