¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <a-modal |
| | | :title="title" |
| | | :width="1000" |
| | | :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 style="width: 100%"> |
| | | |
| | | </a-row> |
| | | <a-row style="width: 100%"> |
| | | <a-col :span="24 / 2 "> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="å¤ä»¶ç¼ç " |
| | | > |
| | | <a-input |
| | | placeholder="å°ç±ç³»ç»çæ" |
| | | v-decorator="['num', validatorRules.num]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | <a-col :span="24 / 2 "> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="å¤ä»¶åç§°" |
| | | > |
| | | <a-input |
| | | placeholder="请è¾å
¥å¤ä»¶åç§°" |
| | | v-decorator="['name', validatorRules.name]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | <a-row style="width: 100%"> |
| | | <a-col :span="24 / 2"> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="åå·ç¼ç " |
| | | > |
| | | <a-input |
| | | placeholder="请è¾å
¥åå·ç¼ç " |
| | | v-decorator="['model', validatorRules.model]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | |
| | | <a-col :span="24 / 2 "> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="è§æ ¼" |
| | | > |
| | | <a-input |
| | | placeholder="请è¾å
¥è§æ ¼" |
| | | v-decorator="['specification', validatorRules.specification]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | <a-row style="width: 100%"> |
| | | <a-col :span="24 / 2"> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="å¶é å" |
| | | > |
| | | <j-dict-select-tag |
| | | allow-clear |
| | | :disabled="disableSubmit" |
| | | :placeholder="disableSubmit?'':'è¯·éæ©å¶é å'" |
| | | :triggerChange="true" |
| | | dictCode="mom_base_constructor,name,id,status!='0' and del_flag!='1'" |
| | | v-decorator="['constructorId', validatorRules.constructorId]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | <a-col :span="24 / 2"> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="åä½" |
| | | > |
| | | <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="['mainUnitId', validatorRules.mainUnitId]" |
| | | @change="(e)=>handle2Change(e)" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | <a-row style="width: 100%"> |
| | | <!-- <a-col :span="24 / 2"> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="è¾
åä½" |
| | | > |
| | | <a-select |
| | | :placeholder="disableSubmit?'':'è¯·éæ©è¾
åä½'" |
| | | :options="this.auxiliaryUnits" |
| | | style="width: 100%" |
| | | :disabled="disableSubmit" |
| | | v-decorator="['auxiliaryUnitId', validatorRules.auxiliaryUnitId]" |
| | | @change="(e)=>handle3Change(e)" |
| | | /> |
| | | </a-form-item> |
| | | </a-col>--> |
| | | <a-col :span="24 / 2 "> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="æææ" |
| | | > |
| | | <a-input-number |
| | | style="width: 100%" |
| | | placeholder="请è¾å
¥æææ" |
| | | v-decorator="['validityPeriod', validatorRules.validityPeriod]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | <!-- <a-row style="width: 100%"> |
| | | <!– hidden –> |
| | | <a-col :span="24 / 2 "> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="æ¢ç®æ¯ä¾" |
| | | > |
| | | <a-input |
| | | style="width: 100%" |
| | | placeholder="请è¾å
¥æ¢ç®æ¯ä¾" |
| | | v-decorator="['conversionRatio', validatorRules.conversionRatio]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row>--> |
| | | <a-row style="width: 100%"> |
| | | <a-col :span="24 / 2"> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="æææåä½" |
| | | > |
| | | <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="['validityPeriodUnitId', validatorRules.validityPeriodUnitId]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | <a-col :span="24 / 2"> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="åºåä¸éå¼" |
| | | > |
| | | <a-input-number |
| | | style="width: 100%" |
| | | placeholder="请è¾å
¥æææ" |
| | | v-decorator="['inventoryUpperLimit', validatorRules.inventoryUpperLimit]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | <a-row style="width: 100%"> |
| | | <a-col :span="24 / 2 "> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="åºåä¸éå¼" |
| | | > |
| | | <a-input-number |
| | | style="width: 100%" |
| | | placeholder="请è¾å
¥åºåä¸éå¼" |
| | | v-decorator="['inventoryLowerLimit', validatorRules.inventoryLowerLimit]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | <a-col :span="24 / 2"> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="åºåé¢è¦ä¸é" |
| | | > |
| | | <a-input-number |
| | | style="width: 100%" |
| | | placeholder="请è¾å
¥åºåé¢è¦ä¸é" |
| | | v-decorator="['inventoryWarnLimit', validatorRules.inventoryWarnLimit]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | <a-row style="width: 100%"> |
| | | <a-col :span="24 / 2"> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="ç»æµè®¢è´§é" |
| | | > |
| | | <a-input-number |
| | | style="width: 100%" |
| | | placeholder="请è¾å
¥ç»æµè®¢è´§é" |
| | | v-decorator="['economicOrderQuantity', validatorRules.economicOrderQuantity]" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | |
| | | <a-col :span="24 / 2 "> |
| | | <a-form-item |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | label="éè´æåæ" |
| | | > |
| | | <a-input-number |
| | | style="width: 100%" |
| | | placeholder="请è¾å
¥éè´æåæ" |
| | | v-decorator="['purchaseLeadTime', validatorRules.purchaseLeadTime]" |
| | | /> |
| | | </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 |
| | | :disabled="disableSubmit || confirmLoading" |
| | | :loading="confirmLoading" |
| | | @click="handleOk" |
| | | type="primary" |
| | | >ç¡®å®</a-button> |
| | | </template> |
| | | </a-modal> |
| | | </template> |
| | | |
| | | <script> |
| | | import pick from 'lodash.pick' |
| | | import { postAction, requestPut, getAction } from '@/api/manage' |
| | | import { duplicateCheck } from '@/api/api' |
| | | import moment from 'moment' |
| | | import JImageUpload from '@/components/jeecg/JImage2Upload' |
| | | import Vue from 'vue' |
| | | |
| | | export default { |
| | | name: 'SparePartModel', |
| | | components: { |
| | | JImageUpload |
| | | }, |
| | | data() { |
| | | return { |
| | | title: "æä½", |
| | | visible: false, |
| | | codeDisable: true, |
| | | disableSubmit: false, |
| | | sparePartCategoryId: '', |
| | | auxiliaryUnits: [], |
| | | 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' }, |
| | | ] |
| | | }, |
| | | remark: { |
| | | rules: [ |
| | | { min: 0, max: 100, message: 'é¿åº¦ä¸è¶
è¿ 100 个å符', trigger: 'blur' }, |
| | | ] |
| | | } |
| | | }, |
| | | url: { |
| | | add: "/spare/sparePart/add", |
| | | edit: "/spare/sparePart/edit", |
| | | getAuxiliaryUnits: "/spare/sparePart/getAuxiliaryUnits", |
| | | getConversionRatio: "/spare/sparePart/getConversionRatio", |
| | | getNum: '/eam/sysIdentity/getNumNew', |
| | | }, |
| | | //æ°å¢ãç¼è¾ãå é¤ãæ¹éå 餿使¹åæ°æ®åå·æ°å
³èçç»ä»¶ççå¬å±æ§ |
| | | alterFlag: "", |
| | | } |
| | | }, |
| | | created() { |
| | | // this.getSysDeparts() |
| | | }, |
| | | methods: { |
| | | moment, |
| | | |
| | | add() { |
| | | this.edit({}); |
| | | }, |
| | | |
| | | edit(record) { |
| | | this.form.resetFields(); |
| | | this.model = Object.assign({}, record); |
| | | this.visible = true; |
| | | this.disableSubmit = false; |
| | | this.auxiliaryUnits = record.auxiliaryUnits |
| | | this.$nextTick(() => { |
| | | this.form.setFieldsValue(pick(this.model, |
| | | 'num', |
| | | 'name', |
| | | 'specification', |
| | | 'model', |
| | | 'constructorId', |
| | | 'mainUnitId', |
| | | 'auxiliaryUnitId', |
| | | 'conversionRatio', |
| | | 'validityPeriod', |
| | | 'validityPeriodUnitId', |
| | | 'inventoryUpperLimit', |
| | | 'inventoryLowerLimit', |
| | | 'economicOrderQuantity', |
| | | 'purchaseLeadTime', |
| | | 'inventoryWarnLimit', |
| | | 'remark')); |
| | | }); |
| | | if (record.id) { |
| | | this.codeDisable = true; |
| | | } else { |
| | | this.codeDisable = false; |
| | | // this.$nextTick(() => { |
| | | // getAction(this.url.getNum, { type: 'SparePart', length: '4' }).then((res) => { |
| | | // if (res.success) { |
| | | // this.form.setFieldsValue({ num: res.message }); |
| | | // } |
| | | // }) |
| | | // }); |
| | | } |
| | | }, |
| | | |
| | | close() { |
| | | this.$emit('close'); |
| | | this.visible = false; |
| | | }, |
| | | |
| | | handleOk() { |
| | | const that = this; |
| | | // 触å表åéªè¯ |
| | | this.form.validateFields(async (err, values) => { |
| | | if (!err) { |
| | | that.confirmLoading = true; |
| | | let formData = Object.assign(this.model, values); |
| | | let obj; |
| | | if (!this.model.id) { |
| | | if(!formData.num){ |
| | | await getAction(this.url.getNum, { type: 'SparePart', length: '4' }).then((res) => { |
| | | if (res.success) { |
| | | formData.num = res.message; |
| | | } |
| | | }); |
| | | } |
| | | formData.sparePartCategoryId = this.sparePartCategoryId |
| | | 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(); |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | handle2Change(val) { |
| | | this.auxiliaryUnits = []; |
| | | this.form.setFieldsValue({ "auxiliaryUnitId": null, "conversionRatio": null }) |
| | | this.getAuxiliaryUnits(val); |
| | | }, |
| | | |
| | | getAuxiliaryUnits(mainUnitId) { |
| | | getAction(this.url.getAuxiliaryUnits, { mainUnitId: mainUnitId }).then((res) => { |
| | | if (res.success) { |
| | | this.auxiliaryUnits = res.result |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | handle3Change(val) { |
| | | let data = this.form.getFieldsValue(['mainUnitId']); |
| | | if (data.mainUnitId === "" || data.mainUnitId === null || data.mainUnitId === undefined) { |
| | | this.$message.warning("è¯·éæ©ä¸»åä½ï¼"); |
| | | return |
| | | } |
| | | this.form.setFieldsValue({ "conversionRatio": null }) |
| | | getAction(this.url.getConversionRatio, { mainUnitId: data.mainUnitId, auxiliaryUnitId: val }).then((res) => { |
| | | if (res.success) { |
| | | this.form.setFieldsValue({ "conversionRatio": res.result }) |
| | | } |
| | | }) |
| | | |
| | | }, |
| | | |
| | | handleCancel() { |
| | | this.close() |
| | | }, |
| | | |
| | | //éªè¯ ç¼å· |
| | | validateNum(rule, value, callback) { |
| | | var params = { |
| | | tableName: 'mom_eam_equipment', |
| | | 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_equipment', |
| | | 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> |