From 92ff846fb659c62037a32b1d8c15eae9df9d9b54 Mon Sep 17 00:00:00 2001 From: zenglf <18502938215@163.com> Date: 星期一, 18 九月 2023 13:24:30 +0800 Subject: [PATCH] Merge branch 'develop' of http://117.34.109.166:18448/r/vue_mdc_430 --- src/views/base/modules/supplier/SupplierModel.vue | 391 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 391 insertions(+), 0 deletions(-) diff --git a/src/views/base/modules/supplier/SupplierModel.vue b/src/views/base/modules/supplier/SupplierModel.vue new file mode 100644 index 0000000..117b795 --- /dev/null +++ b/src/views/base/modules/supplier/SupplierModel.vue @@ -0,0 +1,391 @@ +<template> + <a-modal + :title="title" + :width="1050" + :visible="visible" + :maskClosable="false" + :confirmLoading="confirmLoading" + :okButtonProps="{ props: {disabled: disableSubmit} }" + @ok="handleOk" + @cancel="handleCancel" + cancelText="鍏抽棴" + > + + <a-spin :spinning="confirmLoading"> + <a-form :form="form"> + + <a-row :gutter="24"> + <a-col :span="12"> + <a-form-item + label="渚涘簲鍟嗗垎绫�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="true" + :placeholder="disableSubmit?'':'璇疯緭鍏ヤ笂绾т緵搴斿晢缂栧彿'" + v-decorator="['supplierCategoryNumName', validatorRules.supplierCategoryNumName ]" + /> + </a-form-item> + </a-col> + + <a-col :span="12"> + <a-form-item + label="渚涘簲鍟嗙畝绉�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ヤ緵搴斿晢绠�绉�'" + v-decorator="['abbreviation', validatorRules.abbreviation ]" + /> + </a-form-item> + </a-col> + </a-row> + + <a-row :gutter="24"> + <a-col :span="12"> + <a-form-item + label="渚涘簲鍟嗙紪鍙�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="codeDisable" + :placeholder="disableSubmit?'':'璇疯緭鍏ヤ緵搴斿晢缂栧彿'" + v-decorator="['num', validatorRules.num ]" + /> + </a-form-item> + </a-col> + <a-col :span="12"> + <a-form-item + label="渚涘簲鍟嗗悕绉�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ヤ緵搴斿晢鍚嶇О'" + v-decorator="['name', validatorRules.name ]" + + /> + </a-form-item> + </a-col> + </a-row> + <a-row :gutter="24"> + <a-col :span="12"> + <a-form-item + label="渚涘簲鍟嗙被鍨�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <j-dict-select-tag + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇烽�夋嫨渚涘簲鍟嗙被鍨�'" + dictCode="supplier_type" + :triggerChange="true" + v-decorator="['supplierType', validatorRules.supplierType]" + /> + <!-- dictCode="mom_eam_inspection_type,name,id,status!='0' and del_flag!='1'" --> + </a-form-item> + </a-col> + <a-col :span="12"> + <a-form-item + label="渚涘簲鍟嗘墍灞炶涓�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ヤ緵搴斿晢鎵�灞炶涓�'" + v-decorator="['affiliationIndustry', validatorRules.affiliationIndustry ]" + /> + + </a-form-item> + </a-col> + </a-row> + <a-row :gutter="24"> + <a-col :span="12"> + <a-form-item + label="鍦板潃" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ュ湴鍧�'" + v-decorator="['address', validatorRules.address ]" + /> + </a-form-item> + </a-col> + </a-row> + <a-row :gutter="24"> + <a-col :span="24"> + <a-form-item + :labelCol="{span:3}" + :wrapperCol="{span:21}" + label="澶囨敞" + > + <a-textarea + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ュ娉�'" + v-decorator="['remark', validatorRules.remark]" + /> + </a-form-item> + </a-col> + </a-row> + + </a-form> + </a-spin> + + <template slot="footer"> + <a-button + :style="{marginRight: '8px'}" + @click="handleCancel" + > + 鍏抽棴 + </a-button> +<!-- <a-button + v-if="!this.model.id" + :disabled="disableSubmit || confirmLoading" + :loading="confirmLoading" + @click="handleOkAndAdd" + type="primary" + >淇濆瓨骞剁户缁柊澧�</a-button>--> + <a-button + :disabled="disableSubmit || confirmLoading" + :loading="confirmLoading" + @click="handleOk" + type="primary" + >纭畾</a-button> + <!-- icon="save" --> + </template> + + </a-modal> +</template> + +<script> +import pick from 'lodash.pick' +import { postAction, requestPut } from '@/api/manage' +import { duplicateCheck } from '@/api/api' + +export default { + name: 'SupplierModel', + data() { + return { + title: "鎿嶄綔", + visible: false, + codeDisable: true, + disableSubmit: false, + supplierCategoryId: '', + model: {}, + labelCol: { + xs: { span: 24 }, + sm: { span: 6 }, + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 18 }, + }, + confirmLoading: false, + form: this.$form.createForm(this), + validatorRules: { + num: { + rules: [ + { required: true, message: '璇疯緭鍏ヤ緵搴斿晢缂栧彿!' }, + { min: 2, max: 30, message: '闀垮害鍦� 2 鍒� 30 涓瓧绗�', trigger: 'blur' }, + { validator: this.validateNum }, + ] + }, + name: { + rules: [ + { required: true, message: '璇疯緭鍏ヤ緵搴斿晢鍚嶇О!' }, + { min: 2, max: 30, message: '闀垮害鍦� 2 鍒� 30 涓瓧绗�', trigger: 'blur' }, + { validator: this.validateName }, + ] + }, + // }, + remark: { + rules: [ + { min: 0, max: 100, message: '闀垮害涓嶈秴杩� 100 涓瓧绗�', trigger: 'blur' }, + ] + } + }, + url: { + add: "/eam/supplier/add", + edit: "/eam/supplier/edit" + }, + //鏂板銆佺紪杈戙�佸垹闄ゃ�佹壒閲忓垹闄ゆ搷浣滄敼鍙樻暟鎹悗鍒锋柊鍏宠仈鐨勭粍浠剁殑鐩戝惉灞炴�� + alterFlag: "" + } + }, + created() { + }, + methods: { + + add(record) { + this.edit(record); + }, + + edit(record) { + this.form.resetFields(); + this.model = Object.assign({}, record); + this.visible = true; + this.disableSubmit = false; + this.$nextTick(() => { + this.form.setFieldsValue(pick(this.model, 'supplierCategoryNumName', 'abbreviation', 'supplierType', 'num', 'name', 'affiliationIndustry', 'address', 'remark')) + }); + if (record.id) { + this.codeDisable = true; + } else { + this.codeDisable = false; + } + }, + + close() { + this.$emit('close'); + this.visible = false; + }, + + //淇濆瓨骞舵柊澧炴寜閽Е鍙� + handleOkAndAdd() { + const that = this + + // 瑙﹀彂琛ㄥ崟楠岃瘉 + this.form.validateFields((err, values) => { + if (!err) { + that.confirmLoading = true; + let formData = Object.assign(this.model, values); + formData.supplierCategoryId = this.supplierCategoryId + console.log(this.supplierCategoryId) + postAction(this.url.add, formData).then((res) => { + if (res.success) { + that.$message.success(res.message); + that.$emit('ok'); + that.alterFlag = new Date(); + } else { + that.$message.warning(res.message); + } + }).finally(() => { + this.confirmLoading = false + this.form.setFieldsValue(pick(this.model, 'supplierCategoryNumName')) + this.form.setFieldsValue({ "abbreviation": null, "supplierType": null, "affiliationIndustry": null, "address": null, "num": null, "name": null, "remark": null }) + }) + } else { + return false + } + }) + }, + + handleOk() { + const that = this; + // 瑙﹀彂琛ㄥ崟楠岃瘉 + this.form.validateFields((err, values) => { + if (!err) { + that.confirmLoading = true; + let formData = Object.assign(this.model, values); + let obj; + if (!this.model.id) { + formData.supplierCategoryId = this.supplierCategoryId + + console.log("supplierCategoryId"+this.supplierCategoryId) + obj = postAction(this.url.add, formData); + } else { + obj = requestPut(this.url.edit, formData, { id: this.model.id }); + } + obj.then((res) => { + if (res.success) { + that.$message.success(res.message); + that.$emit('ok'); + that.alterFlag = new Date(); + } else { + that.$message.warning(res.message); + } + }).finally(() => { + that.confirmLoading = false; + that.close(); + }) + } + }) + }, + + handleCancel() { + this.close() + }, + + //楠岃瘉 缂栧彿 + validateNum(rule, value, callback) { + var params = { + tableName: 'mom_base_supplier', + fieldName: 'num', + fieldVal: value, + dataId: this.model.id, + //鏁版嵁搴撲腑瀛樺湪瀛楁del_flag骞朵娇鐢ㄨ瀛楁浣滀负鏈垹闄ょ瓥鐣ワ紝鐪熷垹闄わ細false 鍋囧垹闄わ細true + delFlag: '0', + }; + duplicateCheck(params).then((res) => { + if (res.success) { + callback(); + } else { + callback("缂栧彿宸插瓨鍦�!"); + } + }) + }, + + //楠岃瘉 鍚嶇О + validateName(rule, value, callback) { + var params = { + tableName: 'mom_base_supplier', + fieldName: 'name', + fieldVal: value, + dataId: this.model.id, + //鏁版嵁搴撲腑瀛樺湪瀛楁del_flag骞朵娇鐢ㄨ瀛楁浣滀负鏈垹闄ょ瓥鐣ワ紝鐪熷垹闄わ細false 鍋囧垹闄わ細true + delFlag: '0', + }; + duplicateCheck(params).then((res) => { + if (res.success) { + callback(); + } else { + callback("鍚嶇О宸插瓨鍦�!"); + } + }) + }, + + }, + watch: { + alterFlag() { + this.$bus.$emit('queryTreeData'); + }, + } +} +</script> + +<style scoped> +.ant-btn { + padding: 0 10px; + margin-left: 3px; +} + +.ant-form-item-control { + line-height: 0px; +} + +/** 涓昏〃鍗曡闂磋窛 */ +.ant-form .ant-form-item { + margin-bottom: 10px; +} + +/** Tab椤甸潰琛岄棿璺� */ +.ant-tabs-content .ant-form-item { + margin-bottom: 0px; +} +</style> \ No newline at end of file -- Gitblit v1.9.3