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/eam/modules/inspectionProject/InspectionProjectModel.vue | 550 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 550 insertions(+), 0 deletions(-) diff --git a/src/views/eam/modules/inspectionProject/InspectionProjectModel.vue b/src/views/eam/modules/inspectionProject/InspectionProjectModel.vue new file mode 100644 index 0000000..d8a3288 --- /dev/null +++ b/src/views/eam/modules/inspectionProject/InspectionProjectModel.vue @@ -0,0 +1,550 @@ +<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="['inspectionProjectCategoryNumName', validatorRules.inspectionProjectCategoryNumName ]" + /> + </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?'':'璇烽�夋嫨璁¢噺鍗曚綅'" + :triggerChange="true" + dictCode="mom_base_unit,name,id,status!='0' and del_flag!='1'" + v-decorator="['unitId', validatorRules.unitId]" + /> + </a-form-item> + </a-col> + <a-col :span="12"> + <a-form-item + label="妫�楠屽�肩被鍨�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <j-dict-select-tag + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇烽�夋嫨妫�楠屽�肩被鍨�'" + :triggerChange="true" + dictCode="test_value_type" + v-decorator="['testValueType', validatorRules.testValueType]" + @change="(e)=>handleChange(e)" + /> + </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?'':'璇烽�夋嫨鍒嗘瀽鏂规硶'" + :triggerChange="true" + dictCode="analysis_method" + @change="(e)=>handleChange(e)" + v-decorator="['analysisMethod', validatorRules.analysisMethod]" + /> + </a-form-item> + </a-col> --> + <a-col + v-if="testValueType == '2'" + :span="12" + > + <a-form-item + label="妫�娴嬫爣鍑�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ユ娴嬫爣鍑�'" + v-decorator="['detectionStandard', validatorRules.detectionStandard ]" + /> + </a-form-item> + </a-col> + <a-col + v-if="testValueType == '1'" + :span="12" + > + <a-form-item + label="鍚嶄箟鍊�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input-number + style="width: 100%" + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ュ悕涔夊��'" + v-decorator="['surfaceValue', validatorRules.surfaceValue ]" + /> + </a-form-item> + </a-col> + </a-row> + <a-row + v-if="testValueType == '1'" + :gutter="24" + > + <a-col :span="12"> + <a-form-item + label="涓婂亸宸�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input-number + style="width: 100%" + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ヤ笂鍋忓樊'" + v-decorator="['upValue', validatorRules.upValue ]" + /> + </a-form-item> + </a-col> + <a-col :span="12"> + <a-form-item + label="涓嬪亸宸�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input-number + style="width: 100%" + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ヤ笅鍋忓樊'" + v-decorator="['downValue', validatorRules.downValue ]" + /> + </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?'':'璇烽�夋嫨鐐规鏂规硶'" + :triggerChange="true" + dictCode="inspection_method" + v-decorator="['inspectionMethod', validatorRules.inspectionMethod]" + /> + </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="['inspectionTool', validatorRules.inspectionTool ]" + /> + </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: 'InspectionProjectModel', + data() { + return { + title: "鎿嶄綔", + visible: false, + codeDisable: true, + disableSubmit: false, + inspectionProjectCategoryId: '', + testValueType: null, + 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 }, + ] + }, + // analysisMethod: { + // rules: [ + // { required: true, message: '璇烽�夋嫨鍒嗘瀽鏂规硶!' }, + // ] + // }, + detectionStandard: { + rules: [ + { required: true, message: '璇疯緭鍏ユ娴嬫爣鍑�!' }, + // { validator: this.validateSurfaceValue }, + ] + }, + surfaceValue: { + rules: [ + { required: true, message: '璇疯緭鍏ュ悕涔夊��!' }, + // { validator: this.validateSurfaceValue }, + ] + }, + upValue: { + rules: [ + { required: true, message: '璇疯緭鍏ヤ笂鍋忓樊鍊�!' }, + ] + }, + downValue: { + rules: [ + { required: true, message: '璇疯緭鍏ヤ笅鍋忓樊鍊�!' }, + // { validator: this.validateDownValue }, + ] + }, + remark: { + rules: [ + { min: 0, max: 100, message: '闀垮害涓嶈秴杩� 100 涓瓧绗�', trigger: 'blur' }, + ] + } + }, + url: { + add: "/eam/inspectionProject/add", + edit: "/eam/inspectionProject/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.testValueType = record.testValueType + this.$nextTick(() => { + this.form.setFieldsValue(pick(this.model, 'inspectionProjectCategoryNumName', + 'num', 'name', 'unitId', 'detectionStandard', 'testValueType', 'inspectionMethod', 'inspectionTool', 'remark')) + }); + if (record.testValueType == '1') { + this.$nextTick(() => { + this.form.setFieldsValue(pick(this.model, 'surfaceValue', 'upValue', 'downValue')) + }); + } + 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.inspectionProjectCategoryId = this.inspectionProjectCategoryId + 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, 'inspectionProjectCategoryNumName')) + this.form.setFieldsValue({ "inspectionContent": null, "inspectionRequire": null, "inspectionMethod": null, "inspectionTool": 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.inspectionProjectCategoryId = this.inspectionProjectCategoryId + 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() + }, + + handleChange(val) { + this.testValueType = val + }, + + validateDownValue(rule, value, callback) { + let data = this.form.getFieldsValue(['surfaceValue']); + if (data.surfaceValue == null || data.surfaceValue == "") { + callback('鍚嶄箟鍊间笉鑳戒负绌猴紒') + } else { + if (value > data.surfaceValue) { + callback('涓嬪亸宸�间笉鑳藉ぇ浜庡悕涔夊�硷紒') + } else { + callback() + } + } + }, + + validateSurfaceValue(rule, value, callback) { + this.form.setFieldsValue({ "upValue": null, "downValue": null }) + // let data = this.form.getFieldsValue(['surfaceValue']); + // if (value > data.surfaceValue) { + // callback('涓嶅悎鏍兼暟閲忓簲灏忎簬妫�楠屾暟閲忥紒') + // } else { + // callback() + // } + }, + + validateAnalysisMethod(rule, value, callback) { + let data = this.form.getFieldsValue(['surfaceValue']); + if (value > data.surfaceValue) { + callback('涓嶅悎鏍兼暟閲忓簲灏忎簬妫�楠屾暟閲忥紒') + } else { + callback() + } + }, + + //楠岃瘉 缂栧彿 + validateNum(rule, value, callback) { + var params = { + tableName: 'mom_eam_inspection_project', + 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_eam_inspection_project', + 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