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/spare/modules/sparePartOutbound/SparePartOutboundModal.vue | 518 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 518 insertions(+), 0 deletions(-) diff --git a/src/views/spare/modules/sparePartOutbound/SparePartOutboundModal.vue b/src/views/spare/modules/sparePartOutbound/SparePartOutboundModal.vue new file mode 100644 index 0000000..9542396 --- /dev/null +++ b/src/views/spare/modules/sparePartOutbound/SparePartOutboundModal.vue @@ -0,0 +1,518 @@ +<template> + <a-modal + :title="title" + :width="1450" + :visible="visible" + :maskClosable="false" + @ok="handleOk" + cancelText="鍏抽棴" + @cancel="handleCancel" + :confirmLoading="confirmLoading" + > + <a-spin :spinning="confirmLoading"> + <a-form :form="form"> + <a-row :gutter="24"> + <a-col :span="24/2"> + <a-form-item + label="鐢宠鍗曠紪鐮�" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + placeholder="璇疯緭鐢宠鍗曠紪鐮�" + :disabled="true" + v-decorator="['num', validatorRules.num]" + /> + </a-form-item> + </a-col> + <a-col :span="24/2"> + <a-form-item + label="棰嗙敤閮ㄩ棬" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-tree-select + style="width: 100%" + :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" + :tree-data="treeData" + placeholder="璇烽�夋嫨棰嗙敤閮ㄩ棬" + tree-default-expand-all + v-decorator="['departId', validatorRules.departId]" + /> + </a-form-item> + </a-col> + </a-row> + <a-row :gutter="24"> + <a-col :span="24/2"> + <a-form-item + label="鍑哄簱浜哄憳" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <j-dict-select-tag + allow-clear + :disabled="disableSubmit" + :placeholder="'璇烽�夋嫨鍑哄簱浜哄憳'" + v-decorator="['outboundPersonId', validatorRules.outboundPersonId]" + dictCode="sys_user,realname,id,del_flag!='1'" + /> + </a-form-item> + </a-col> + <a-col :span="24/2"> + <a-form-item + label="浠撳簱" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <j-dict-select-tag + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇烽�夋嫨浠撳簱'" + :triggerChange="true" + dictCode="mom_base_warehouse,name,id , del_flag!='1'" + v-decorator="['warehouseId', validatorRules.warehouseId]" + @change="(e)=>handle2Change(e)" + /> + </a-form-item> + </a-col> + </a-row> + </a-form> + </a-spin> + <a-button + type="primary" + :disabled="disableSubmit" + :style="{ marginRight: '8px',marginBottom:'8px' }" + :loading="confirmLoading" + @click="selectSparePartInventory()" + >澧炲姞澶囦欢搴撳瓨淇℃伅</a-button> + <a-table + ref="table" + bordered + size="middle" + rowKey='id' + :columns="columns" + :dataSource="dataSource" + :scroll="{ x: 'calc(1200px + 50%)', y: 900 }" + > + <template + v-for="col in columns" + :slot="col.dataIndex" + slot-scope='text, record, index' + > + <div :key="col.dataIndex"> + <a-input-number + :value="text" + + v-if="col.dataIndex == 'outboundMainQuantity'" + :min="0" + :disabled="disableSubmit" + :max="record.mainQuantity" + @change="(e)=>handleChange(e, record.key, col, index)" + /> + </div> + </template> + + <span + slot="action" + slot-scope="text, record, index" + + > + <a-popconfirm + + title="纭畾鍒犻櫎鍚�?" + :disabled="disableSubmit" + @confirm="() => handleDelete(text,record, index)" + > + <a>鍒犻櫎</a> + </a-popconfirm> + </span> + </a-table> + <template slot="footer"> + <a-button + :style="{marginRight: '8px'}" + @click="handleCancel()" + > + 鍏抽棴 + </a-button> + + <a-button + @click="handleOk()" + :disabled="disableSubmit" + type="primary" + :loading="confirmLoading" + >纭畾</a-button> + </template> + <j-select-spare-part-inventory-modal ref="sparePartInventoryModalForm"></j-select-spare-part-inventory-modal> + </a-modal> + +</template> + +<script> +import { getAction, postAction, requestPut } from '@/api/manage' +import pick from 'lodash.pick' +import JMultiSelectTag from '@/components/dict/JMultiSelectTag' +import { duplicateCheck } from '@/api/api' +import Tooltip from 'ant-design-vue/es/tooltip' +import JSelectSparePartInventoryModal from './JSelectSparePartInventoryModal' + +export default { + name: "SparePartOutboundModal", + components: { + JMultiSelectTag, + Tooltip, + JSelectSparePartInventoryModal + }, + data() { + return { + disabled:false, + treeData:[], + departs: [], + columns: [ + { + title: '#', + dataIndex: '', + key: 'rowIndex', + align: 'center', + customRender: function (t, r, index) { + return parseInt(index) + 1 + }, + width: 50, + }, + { + title: '鎵规鍙�', + align: 'center', + dataIndex: 'batchNum' + }, + { + title: '澶囦欢缂栫爜', + align: 'center', + dataIndex: 'num' + }, + { + title: '澶囦欢鍚嶇О', + align: 'center', + dataIndex: 'name' + }, + { + title: '鍨嬪彿', + align: 'center', + dataIndex: 'model' + }, + { + title: '瑙勬牸', + align: 'center', + dataIndex: 'specification' + }, + { + title: '鍒堕�犲晢', + align: 'center', + dataIndex: 'constructorName', + }, + { + title: '鍑哄巶鏃ユ湡', + align: 'center', + dataIndex: 'manufactureDate', + }, + { + title: '浠撳簱', + align: 'center', + dataIndex: 'warehouseName', + }, + { + title: '搴撳尯', + align: 'center', + dataIndex: 'warehouseAreaName' + }, + { + title: '搴撲綅', + align: 'center', + dataIndex: 'warehouseLocationNum' + }, + { + title: '鍗曚綅', + align: 'center', + dataIndex: 'mainUnitName' + }, + { + title: '鏁伴噺', + align: 'center', + dataIndex: 'mainQuantity', + }, + /* { + title: '杈呭崟浣�', + align: 'center', + dataIndex: 'auxiliaryUnitName' + }, + { + title: '杈呮暟閲�', + align: 'center', + dataIndex: 'auxiliaryQuantity' + }, */ + { + title: '鍑哄簱鏁伴噺', + align: 'center', + dataIndex: 'outboundMainQuantity', + scopedSlots: { customRender: 'outboundMainQuantity' } + }, + // { + // title: '鍑哄簱杈呮暟閲�', + // align: 'center', + // dataIndex: 'outboundAuxiliaryQuantity', + // }, + { + title: '鎿嶄綔', + align: 'center', + dataIndex: 'action', + fixed: 'right', + width: 100, + scopedSlots: { + customRender: 'action' + }, + } + ], + title: "鎿嶄綔", + visible: false, + disableSubmit: false, + codeDisable: true, + model: {}, + warehouseId: "", + labelCol: { + xs: { span: 24 }, + sm: { span: 5 }, + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 }, + }, + confirmLoading: false, + form: this.$form.createForm(this), + validatorRules: { + num: { + rules: [ + { required: true, message: '璇疯緭鍏ュ叆搴撳崟缂栧彿!' }, + ] + }, + departId: { + rules: [ + { required: true, message: '璇烽�夋嫨閮ㄩ棬!' }, + ] + }, + outboundPersonId: { + rules: [ + { required: true, message: '璇烽�夋嫨鍑哄簱浜哄憳!' }, + // { validator: this.validateEquipmentId }, + ] + }, + warehouseId: { + rules: [ + { required: true, message: '璇烽�夋嫨浠撳簱!' }, + ] + }, + }, + url: { + add: "/spare/sparePartOutbound/add", + loadOptions: '/sys/sysDepart/loadDepartTreeOptions', + getSysDeparts: "/eam/equipment/getSysDeparts", + getNum: '/eam/sysIdentity/getNumNew', + edit: "/spare/sparePartOutbound/edit", + }, + + dataSource: [], + } + }, + + + mounted() { + this.$bus.$on('selectionRows', (data) => { + for (let i = 0; i < data.length; i++) { + this.dataSource.push({ + id: data[i].id, + sparesPartInventoryId: data[i].id, + sparePartId: data[i].sparePartId, + batchNum: data[i].batchNum, + num: data[i].num, + name: data[i].name, + specification: data[i].specification, + model: data[i].model, + mainQuantity: data[i].mainQuantity, + mainUnitId: data[i].mainUnitId, + mainUnitName: data[i].mainUnitName, + /* auxiliaryQuantity: data[i].auxiliaryQuantity, */ + /* auxiliaryUnitId: data[i].auxiliaryUnitId, + auxiliaryUnitName: data[i].auxiliaryUnitName, */ + /* conversionRatio: data[i].conversionRatio, */ + constructorId: data[i].constructorId, + constructorName: data[i].constructorName, + supplierId: data[i].supplierId, + manufactureDate: data[i].manufactureDate, + warehouseName: data[i].warehouseName, + warehouseAreaName: data[i].warehouseAreaName, + warehouseLocationNum: data[i].warehouseLocationNum, + }) + } + }) + }, + +created() { +}, + methods: { + getSysDeparts() { + getAction(this.url.getSysDeparts).then((res) => { + if (res.success) { + this.departs = res.result + } + }) + }, + //閫夋嫨澶囦欢搴撳瓨淇℃伅 + selectSparePartInventory: function () { + if (this.warehouseId == "" || this.warehouseId == null) { + this.$message.warning("璇烽�夋嫨浠撳簱锛�"); + return + } + let ids = []; + for (let i = 0; i < this.dataSource.length; i++) { + ids.push(this.dataSource[i].sparesPartInventoryId); + } + this.$refs.sparePartInventoryModalForm.showModals(ids, this.warehouseId); + this.$refs.sparePartInventoryModalForm.title = '閫夋嫨澶囦欢搴撳瓨淇℃伅'; + this.$refs.sparePartInventoryModalForm.disableSubmit = false; + }, + + add() { + this.edit({ sparePartOutboundDetailList: [] }) + + }, + + edit(record) { + let that = this; + that.dataSource = []; + that.form.resetFields(); + that.model = Object.assign({}, record); + that.visible = true; + that.initOptions() + that.warehouseId = record.warehouseId + if (record.sparePartOutboundDetailList != undefined) { + const temp = [...record.sparePartOutboundDetailList]; + that.dataSource = temp; + } + that.$nextTick(() => { + that.form.setFieldsValue(pick(that.model, 'num', 'departId', 'outboundPersonId', 'warehouseId')); + }); + 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 }); + } + }) + }); + } + }, + initOptions() { + getAction(this.url.loadOptions).then(res => { + if (res.success) { + this.treeData = res.result + } else { + this.$message.warning(res.message) + } + }) + }, + close() { + this.$emit('close'); + this.visible = false; + this.warehouseId = ""; + }, + + handleCancel() { + this.close(); + }, + + handleOk() { + const that = this; + this.form.validateFields((err, values) => { + if (!err) { + that.confirmLoading = true; + let formData = Object.assign(this.model, values); + formData.sparePartOutboundDetails = that.dataSource; + if (that.dataSource.length ===0){ + that.confirmLoading = false + that.$message.warning("璇锋坊鍔犳槑缁�") + return + } + let obj; + if (!this.model.id) { + 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'); + } else { + that.$message.warning(res.message); + } + }).finally(() => { + that.confirmLoading = false; + that.close(); + }) + } + }) + }, + + handleDelete(text, record, index) { + this.dataSource.splice(index, 1); + }, + + + handleChange(value, key, column, index) { + let that = this; + const temp = [...that.dataSource]; + const target = temp.filter(item => key === item.key)[index]; + if (target) { + if (column.dataIndex == 'outboundMainQuantity') { + target[column.dataIndex] = value; + /* target["outboundAuxiliaryQuantity"] = value * target.conversionRatio */ + } + //鏄剧ず甯﹁繃鏉ョ殑鏁版嵁 + that.dataSource = temp; + } + }, + + handle2Change(val) { + this.warehouseId = val + this.dataSource = [] + } + }, +} +</script> + +<style lang="less" scoped> +/deep/ .frozenRowClass { + color: #c9c9c9; +} +.fontweight { + font-weight: bold; +} +.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