¶Ô±ÈÐÂÎļþ |
| | |
| | | <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="è§£éåä¼èªå¨éæ¾åºåï¼ç¡®è®¤è§£éå?" |
| | | @confirm="() => handleUnLock(record)" |
| | | > |
| | | <a |
| | | v-has="'specialtyMaintenanceOrder:actualMaterialLock'" |
| | | v-if="record.isLock=='yes'&&orderStatus=='4'" |
| | | >è§£é</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("åºåè§£éæåï¼") |
| | | } 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> |