From 330375a684720f1801424028d4f592477b6d73d9 Mon Sep 17 00:00:00 2001 From: qushaowei <qushaowei@163.com> Date: 星期二, 07 十一月 2023 10:11:33 +0800 Subject: [PATCH] 提交 workshop --- src/views/eam/depart/modules/DepartForm.vue | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 156 insertions(+), 0 deletions(-) diff --git a/src/views/eam/depart/modules/DepartForm.vue b/src/views/eam/depart/modules/DepartForm.vue new file mode 100644 index 0000000..c5dedd0 --- /dev/null +++ b/src/views/eam/depart/modules/DepartForm.vue @@ -0,0 +1,156 @@ +<template> + <a-spin :spinning="confirmLoading"> + <j-form-container :disabled="formDisabled"> + <a-form-model + ref="form" + :model="model" + :rules="validatorRules" + slot="detail" + > + <a-row :gutter="24"> + <a-col :span="24"> + <a-form-item + :labelCol="labelCol" + :wrapperCol="wrapperCol" + label="鐖剁骇閮ㄩ棬" + prop="parentId" + > + <j-dict-select-tag + allow-clear + placeholder="璇烽�夋嫨鐖剁骇閮ㄩ棬" + :triggerChange="true" + dictCode="sys_depart,depart_name,id,del_flag = '0'" + v-model="model.parentId" + :disabled="true" + /> + </a-form-item> + </a-col> + </a-row> + <a-row> + <a-col :span="24"> + <a-form-model-item + label="缂栫爜" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + prop="orgCode" + > + <a-input + v-model="model.orgCode" + placeholder="璇疯緭鍏ョ紪鐮�" + ></a-input> + </a-form-model-item> + </a-col> + <a-col :span="24"> + <a-form-model-item + label="鍚嶇О" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + prop="departName" + > + <a-input + v-model="model.departName" + placeholder="璇疯緭鍏ュ悕绉�" + ></a-input> + </a-form-model-item> + </a-col> + </a-row> + </a-form-model> + </j-form-container> + </a-spin> +</template> + +<script> + +import { httpAction, getAction } from '@/api/manage' +import { validateDuplicateValue } from '@/utils/util' + +export default { + name: 'RepairPlanTypeForm', + components: { + }, + props: { + //琛ㄥ崟绂佺敤 + disabled: { + type: Boolean, + default: false, + required: false + } + }, + data() { + return { + model: { + }, + labelCol: { + xs: { span: 24 }, + sm: { span: 5 }, + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 }, + }, + confirmLoading: false, + validatorRules: { + orgCode: [ + { required: true, message: '璇疯緭鍏ョ紪鐮�!' }, + { validator: (rule, value, callback) => validateDuplicateValue('sys_depart', 'org_code', value, this.model.id, callback) }, + ], + departName: [ + { required: true, message: '璇疯緭鍏ュ悕绉�!' }, + { validator: (rule, value, callback) => validateDuplicateValue('sys_depart', 'depart_name', value, this.model.id, callback) }, + ], + }, + url: { + add: "/sys/sysDepart/add", + edit: "/sys/sysDepart/edit", + } + } + }, + computed: { + formDisabled() { + return this.disabled + }, + }, + created() { + //澶囦唤model鍘熷鍊� + this.modelDefault = JSON.parse(JSON.stringify(this.model)); + }, + methods: { + add(record) { + this.edit(record); + }, + edit(record) { + this.model = Object.assign({}, record); + this.visible = true; + }, + submitForm() { + const that = this; + // 瑙﹀彂琛ㄥ崟楠岃瘉 + this.$refs.form.validate(valid => { + if (valid) { + that.confirmLoading = true; + let httpurl = ''; + let method = ''; + if (!this.model.id) { + httpurl += this.url.add; + method = 'post'; + } else { + httpurl += this.url.edit; + method = 'put'; + } + httpAction(httpurl, this.model, method).then((res) => { + if (res.success) { + that.$message.success(res.message); + that.$emit('ok'); + } else { + that.$message.warning(res.message); + } + }).finally(() => { + that.confirmLoading = false; + }) + } + + }) + }, + } +} +</script> \ No newline at end of file -- Gitblit v1.9.3