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/predictiveWorkOrder/ActualMaterialEditTable.vue | 465 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 465 insertions(+), 0 deletions(-) diff --git a/src/views/eam/modules/predictiveWorkOrder/ActualMaterialEditTable.vue b/src/views/eam/modules/predictiveWorkOrder/ActualMaterialEditTable.vue new file mode 100644 index 0000000..22a19f5 --- /dev/null +++ b/src/views/eam/modules/predictiveWorkOrder/ActualMaterialEditTable.vue @@ -0,0 +1,465 @@ +<template> + <a-card + :bordered="false" + :class="'cust-erp-sub-tab'" + > + <a-table + ref="table" + bordered + rowKey="id" + :columns="columns" + :dataSource="dataSource" + :pagination="ipagination" + @change="handleTableChange" + > + + <template + v-for="col in columns" + :slot="col.dataIndex" + slot-scope='text, record, index' + > + <div :key="col.dataIndex"> + <a-input-search + v-if="col.dataIndex == 'materialName'" + enter-button + @search="onSearchMaterial(index)" + :value="text" + :read-only="true" + @change="(e) => handleChange(e, record.key, col, index)" + /> + <a-input-number + :value="text" + v-if="col.dataIndex == 'quantity'" + :min="1" + :max="99999" + @change="(e)=>handleChange(e, record.key, col, index)" + :disabled="record.isLock == 'yes'||orderStatus!='4'" + /> + + </div> + </template> + <span + slot='action' + slot-scope='text, record' + > + <a-popconfirm + title="纭閿佹枡鍚�?" + @confirm="() => handleLock(record)" + > + <a + v-has="'specialtyMaintenanceOrder:actualMaterialLock'" + v-if="record.isLock=='no'&&orderStatus=='4'" + >閿佹枡</a> + </a-popconfirm> + <a-divider + v-if="record.isLock=='no'" + type="vertical" + /> + <a-popconfirm + title="瑙i攣鍚庝細鑷姩閲婃斁搴撳瓨锛岀‘璁よВ閿佸悧?" + @confirm="() => handleUnLock(record)" + > + <a + v-has="'specialtyMaintenanceOrder:actualMaterialLock'" + v-if="record.isLock=='yes'&&orderStatus=='4'" + >瑙i攣</a> + </a-popconfirm> + <a-popconfirm + title="纭畾鍒犻櫎鍚�?" + @confirm="() => handleDelete(record.id)" + > + <a + v-has="'specialtyMaintenanceOrder:actualMaterialDelete'" + v-if="record.isLock=='no'&&orderStatus=='4'" + >鍒犻櫎</a> + </a-popconfirm> + </span> + </a-table> + <a-button + style="width: 100%; margin-top: 16px; margin-bottom: 8px" + type="dashed" + icon="plus" + @click="addMaterial" + :disabled="orderStatus!='4'" + v-has="'specialtyMaintenanceOrder:actualMaterialAdd'" + >娣诲姞瀹為檯鐢ㄦ枡</a-button> + <div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}"> + <a-row :style="{textAlign:'right'}"> + <!-- <a-button + :style="{marginRight: '8px'}" + @click="handleCancel" + > + 鍙栨秷 + </a-button> --> + <!-- <a-button + @click="handleOk(1)" + type="primary" + :style="{marginRight: '8px'}" + :disabled="orderStatus!='4'" + >鏆傚瓨</a-button> + <a-button + @click="handleOk(0)" + type="primary" + :disabled="orderStatus!='4'" + >淇濆瓨</a-button> --> + </a-row> + <!-- :disabled="false" --> + </div> + <actual-material-select + @getSelectRows="getSelectRows" + ref='JSelectSparePartModal'> + <!-- @sendMaterialRecord="sendMaterialRecord" --> + </actual-material-select> + </a-card> +</template> +<script> +import { postAction, getAction } from '@/api/manage' +import { JeecgListMixin } from '@/mixins/JeecgListMixin' +import pick from 'lodash.pick' +import JEllipsis from '@/components/jeecg/JEllipsis' +import ActualMaterialSelect from './select/ActualMaterialSelect.vue' +export default { + name: 'ActualMaterialEditTable', + mixins: [JeecgListMixin], + components: { + JEllipsis, + ActualMaterialSelect, + }, + props: { + orderId: { + type: String, + required: false, + default: '' + }, + orderStatus: { + type: String, + required: false, + default: '' + }, + equipmentId: { + type: String, + required: false, + default: '' + }, + }, + data() { + return { + disableMixiCreated:true, + title: "瀹為檯鐢ㄦ枡", + visible: false, + model: {}, + maskClosable: true, + confirmLoading: false, + // specialyMaintenanceOrderStatus: '', + form: this.$form.createForm(this), + /* 鍒嗛〉鍙傛暟 */ + ipagination: { + current: 1, + pageSize: 99, + pageSizeOptions: ['99', '199'], + showTotal: (total, range) => { + return range[0] + "-" + range[1] + " 鍏�" + total + "鏉�" + }, + showQuickJumper: true, + showSizeChanger: true, + total: 0 + }, + validatorRules: { + materialId: { + rules: [ + { required: true, message: '璇烽�夋嫨鐗╂枡!' }, + ] + }, + quantity: { + rules: [ + { required: false, message: '璇峰~鍐欐暟閲�!' }, + ] + }, + }, + labelCol: { + xs: { span: 24 }, + sm: { span: 7 }, + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 }, + }, + drawerWidth: "100%", + visible: false, + disableSubmit: false, + disableSelect: false, + loading: false, + dataSource: [], + columns: [ + { + title: '棰嗘枡鍑哄簱鍗�', + dataIndex: 'num', + align: "center", + width: 150, + }, + { + title: '澶囦欢缂栫爜', + dataIndex: 'sparePartNum', + align: "center", + + }, + { + title: '澶囦欢鍚嶇О', + dataIndex: 'sparePartName', + align: "center", + + }, + { + title: '瑙勬牸', + dataIndex: 'specification', + align: "center", + }, + { + title: '鍨嬪彿', + dataIndex: 'model', + align: "center", + }, + { + title: '鍒堕�犲晢', + dataIndex: 'constructorName', + align: "center", + }, + { + title: '涓诲崟浣�', + dataIndex: 'mainUnitName', + align: "center", + + }, + { + title: '涓绘暟閲�', + align: 'center', + dataIndex: 'mainQuantity' + }, + { + title: '鍙敤鏁伴噺', + align: 'center', + dataIndex: 'availableQuantity' + }, + { + title: '浣跨敤鏁伴噺', + dataIndex: 'quantity', + align: "center", + scopedSlots: { customRender: 'quantity' }, + className: 'red', + + }, + { + title: '鎿嶄綔', + dataIndex: 'action', + align: 'center', + width: 250, + scopedSlots: { customRender: 'action' } + } + ], + url: { + list: "/eam/maintenanceOrderActualMaterial/getMaintenanceOrderActualMaterialList", + confirmMaterial: "/eam/maintenanceOrderActualMaterial/add", + delete: "/eam/maintenanceOrderActualMaterial/delete", + addInit: "/eam/maintenanceOrderActualMaterial/addInit", + lock: "/eam/maintenanceOrderActualMaterial/lock", + unLock: "/eam/maintenanceOrderActualMaterial/unLock" + }, + changeIndex: 0 + } + }, + watch: { + orderId: { + immediate: true, + handler(val) { + if(this.orderId){ + alert + this.queryParam['maintenanceOrderId'] = val + this.queryParam['equipmentId'] = this.equipmentId + this.queryParam['delFlag'] = 0 + this.loadData(1); + }else{ + this.clearList(); + } + } + }, + }, + methods: { + addMaterial() { + let ids = []; + for (let i = 0; i < this.dataSource.length; i++) { + ids.push(this.dataSource[i].outboundOrderDetailId); + } + this.$refs.JSelectSparePartModal.showModals(ids); + this.$refs.JSelectSparePartModal.title = '閫夋嫨澶囦欢淇℃伅' + this.$refs.JSelectSparePartModal.disableSubmit = false + }, + handleCancel() { + this.$bus.$emit('closeDrawer'); + }, + close() { + this.$emit('close'); + this.dataSource = []; + this.disableSubmit = false; + this.visible = false; + }, + handleDeleteFake(index) { + this.dataSource.pop(index); + }, + handleOk(saveStatus) { + const that = this + if (saveStatus == 0) { + let materialDataSource = that.dataSource; + let indexIdList = []; + for (let i = 0; i < materialDataSource.length; i++) { + if (materialDataSource[i].materialId == undefined || materialDataSource[i].materialId == null || materialDataSource[i].materialId == '') { + that.$message.warning("璇烽�夋嫨绗�" + (i + 1) + "琛岀墿鏂欙紒"); + return false; + } + if (materialDataSource[i].quantity == undefined || materialDataSource[i].quantity == null || materialDataSource[i].quantity == '') { + that.$message.warning("璇峰~鍐欑" + (i + 1) + "琛岀敤鏂欐暟锛�"); + return false; + } + } + } + if (that.dataSource.length === 0) { + that.$message.warning("璇锋坊鍔犵墿鏂欙紒") + return + } + this.form.validateFields((err, values) => { + if (!err) { + that.confirmLoading = true + let formData = {} + formData.maintenanceOrderId = that.specialyMaintenanceOrderId; + formData.maintenanceOrderActualMaterials = that.dataSource; + formData.equipmentId = that.equipmentId; + let obj = obj = postAction(this.url.confirmMaterial, formData) + 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() + that.loadData(1); + }) + } + }) + }, + handleChange(value, key, column, index) { + console.log(column) + const temp = [...this.dataSource] + const target = temp[index] + let availableQuantity = target['availableQuantity'] + if (target) { + if (value != undefined && value != null && value != '' && availableQuantity < value) { + this.$message.error('浣跨敤鏁伴噺涓嶈兘澶т簬鍙敤鏁伴噺!') + } else { + } + target[column.dataIndex] = value + this.dataSource = temp + } + }, + onSearchMaterial(index) { + this.recordIndex = index + this.$refs.actualMaterialSelect.list() + this.$refs.actualMaterialSelect.title = '鐗╂枡閫夋嫨' + }, + clearList() { + this.dataSource = []; + this.ipagination.current = 1 + }, + // getUuiD(randomLength) { + // return Number( + // Math.random() + // .toString() + // .substr(2, randomLength) + Date.now() + // ).toString(36) + // }, + handleLock(record) { + let that = this; + if (record.quantity == null || record.quantity == undefined || record.quantity == '') { + this.$message.error('璇峰厛濉啓鏁伴噺!'); + return false + } + if (record.availableQuantity < record.quantity) { + this.$message.error('浣跨敤鏁伴噺涓嶈兘澶т簬鍙敤鏁伴噺!'); + return false; + } + this.confirmLoading = true; + postAction(this.url.lock, record).then(res => { + if (res.success) { + this.$message.success("搴撳瓨閿佸畾鎴愬姛锛�") + } else { + this.$message.error(res.message) + } + }).finally(res => { + that.confirmLoading = false + that.loadData(); + }) + + }, + handleUnLock(record) { + let that = this; + this.confirmLoading = true; + postAction(this.url.unLock, record).then(res => { + if (res.success) { + this.$message.success("搴撳瓨瑙i攣鎴愬姛锛�") + } else { + this.$message.error(res.message) + } + }).finally(res => { + that.confirmLoading = false + that.loadData(); + }) + }, + getSelectRows(data){ + let newActualMaterials = []; + for (let i = 0; i < data.length; i++) { + newActualMaterials.push({ + // id: this.getUuiD(16), + // num: data[i].num, + outboundOrderDetailId: data[i].id, + sparePartId: data[i].sparePartId, + // sparePartNum: data[i].spareNum, + // sparePartName: data[i].spareName, + // specification: data[i].specification, + // model: data[i].model, + // constructorName: data[i].constructorName, + // constructorId: data[i].constructorId, + // mainUnitName: data[i].mainUnitName, + // mainUnitId: data[i].mainUnitId, + mainQuantity: data[i].mainQuantity, + useQuantity: data[i].useQuantity, + availableQuantity: data[i].availableQuantity, + maintenanceOrderId: this.orderId, + equipmentId: this.equipmentId, + isLock: 'no' + }) + } + let that = this + postAction(this.url.addInit, newActualMaterials).then((res) => { + if (res.success) { + that.$message.success(res.message) + that.$emit('ok') + } else { + that.$message.warning(res.message) + } + }).finally(res => { + newActualMaterials = [] + that.loadData(); + + }) + + } + }, +} +</script> + +<style scoped> +/deep/ .red { + color: red; +} +</style> \ No newline at end of file -- Gitblit v1.9.3