From 7859c063db5effe91f2418056e70b848177a3628 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期四, 14 八月 2025 10:51:29 +0800 Subject: [PATCH] 1、保养规范审批流程根据规范分类区分展示保养项明细 2、调整二保批量新增功能 --- src/views/eam/maintenance/modules/EamSecondMaintenanceBatchOrderModal.vue | 316 ++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 228 insertions(+), 88 deletions(-) diff --git a/src/views/eam/maintenance/modules/EamSecondMaintenanceBatchOrderModal.vue b/src/views/eam/maintenance/modules/EamSecondMaintenanceBatchOrderModal.vue index 7f78e9f..a340fc9 100644 --- a/src/views/eam/maintenance/modules/EamSecondMaintenanceBatchOrderModal.vue +++ b/src/views/eam/maintenance/modules/EamSecondMaintenanceBatchOrderModal.vue @@ -1,145 +1,279 @@ <template> - <j-modal :title="title" :width="1200" :visible="visible" :confirmLoading="confirmLoading" switchFullscreen centered + <j-modal :title="title" :visible="visible" :confirmLoading="confirmLoading" fullscreen :mask-closable="false" @ok="handleOk" @cancel="handleCancel" cancelText="鍏抽棴"> <a-spin :spinning="spinning"> - <j-vxe-table ref="editableDetailTable" rowNumber rowSelection bordered alwaysEdit toolbar @added="addNewRow" - :toolbarConfig="detail.toolbarConfig" keep-source :height="500" - :dataSource="detail.dataSource" :columns="detail.columns"/> + <a-row :gutter="48"> + <a-col :span="6"> + <a-tabs default-active-key="1"> + <a-tab-pane tab="璁惧缁撴瀯鏍�" key="1"> + <a-tree showLine ref="tree" :expandedKeys.sync="expandedKeys" + :treeData="treeDataSource" checkable @check="onCheck" v-model="checkedKeys" + @expand="onExpand" @select="handleTreeNodeSelect"> + </a-tree> + </a-tab-pane> + </a-tabs> + </a-col> + + <a-col :span="18"> + <a-tabs default-active-key="1"> + <a-tab-pane tab="璁惧鏄庣粏" key="1"> + <j-vxe-table ref="editableDetailTable" rowNumber rowSelection bordered alwaysEdit keep-source + :height="500" :dataSource="detail.dataSource" :columns="detail.columns" + @selectRowChange="handleTableSelectRowChange"> + <!-- 淇濆吇鏃ユ湡--> + <template v-slot:maintenanceDate="props"> + <a-date-picker v-model="props.row.maintenanceDate" value-format="YYYY-MM-DD" :allow-clear="false"/> + </template> + + <!-- 鎿嶄綔--> + <template v-slot:action="props"> + <a :disabled="!props.row.equipmentId" @click="handlePreviewDetail(props.row.standardId)">棰勮鏄庣粏</a> + </template> + </j-vxe-table> + </a-tab-pane> + + <a-date-picker slot="tabBarExtraContent" type="primary" value-format="YYYY-MM-DD" :allowClear="false" + @change="handleBatchSetDate"/> + </a-tabs> + </a-col> + </a-row> + </a-spin> + + <eam-second-maintenance-batch-order-detail-modal ref="detailModal"/> </j-modal> </template> <script> - import { getAction, httpAction } from '@/api/manage' - import MaintenanceEquipmentSelect from '@views/eam/equipment/modules/MaintenanceEquipmentSelect.vue' + import { getAction, postAction } from '@/api/manage' import { JVXETypes } from '@comp/jeecg/JVxeTable' + import EamSecondMaintenanceBatchOrderDetailModal from './EamSecondMaintenanceBatchOrderDetailModal' export default { name: 'EamSecondMaintenanceBatchOrderModal', - components: { MaintenanceEquipmentSelect }, + components: { EamSecondMaintenanceBatchOrderDetailModal }, data() { return { title: '鎿嶄綔', visible: false, confirmLoading: false, spinning: false, + treeDataSource: [], + checkedKeys: [], + expandedKeys: [], + selectedKeys: [], url: { - batchAdd: '/eam/secondMaintenanceOrder/batchAdd' + batchAdd: '/eam/secondMaintenanceOrder/batchAdd', + getDeviceTree: '/eam/secondMaintenanceOrder/BatchTreeStructure' }, detail: { dataSource: [], columns: [ { - title: 'ID', - key: 'id', - type: JVXETypes.hidden - }, - { - title: '宸ュ崟鍙�', - dataIndex: 'orderNum', - align: 'center', - type: JVXETypes.inputNumber, - disabled: true, - placeholder: '宸ュ崟鍙风郴缁熻嚜鍔ㄧ敓鎴�' - }, - { title: '缁熶竴缂栫爜', - dataIndex: 'equipmentId', + key: 'equipmentCode', align: 'center', - type: JVXETypes.slot, - slotName: 'equipmentId' + type: JVXETypes.normal, + width: 150 }, { title: '瑙勮寖鍚嶇О', - dataIndex: 'standardName', + key: 'standardName', align: 'center', - type: JVXETypes.input, - disabled: true, - placeholder: '閫夋嫨璁惧鍚庤嚜鍔ㄥ甫鍑�' + type: JVXETypes.normal, + width: 300 }, { title: '淇濆吇鏃ユ湡', - dataIndex: 'maintenanceDate', + key: 'maintenanceDate', align: 'center', - type: JVXETypes.date + type: JVXETypes.slot, + width: 200, + slotName: 'maintenanceDate', + validateRules: [{ required: true, message: '璇烽�夋嫨${title}' }] }, { title: '淇濆吇鍛ㄦ湡', - dataIndex: 'maintenancePeriod', + key: 'maintenancePeriod', align: 'center', - type: JVXETypes.inputNumber, - defaultValue: '6' + type: JVXETypes.normal, + width: 150 + }, + { + title: '澶囨敞', + key: 'remark', + align: 'center', + type: JVXETypes.textarea, + placeholder: '璇疯緭鍏ュ娉�' + }, + { + title: '鎿嶄綔', + align: 'center', + type: JVXETypes.slot, + width: 150, + slotName: 'action' } - ], - toolbarConfig: { - // prefix 鍓嶇紑锛泂uffix 鍚庣紑 - slot: ['prefix', 'suffix'], - // add 鏂板鎸夐挳锛況emove 鍒犻櫎鎸夐挳锛沜learSelection 娓呯┖閫夋嫨鎸夐挳 - btn: ['add', 'remove', 'clearSelection'] - } + ] } } }, methods: { add() { - //鍒濆鍖栭粯璁ゅ�� - this.model = { maintenancePeriod: 6 } this.visible = true - this.editable = true - this.detail.operatorMaintenanceList = this.detail.repairerMaintenanceList = [] + this.checkedKeys = this.detail.dataSource = [] + this.queryTreeData() }, - addNewRow({ row }) { - console.log('row', row) - row.maintenancePeriod = 6 - this.$refs.editableDetailTable.updateData() + // 鑾峰彇璁惧缁撴瀯鏍� + queryTreeData() { + this.spinning = true + this.treeDataSource = [] + getAction(this.url.getDeviceTree) + .then(res => { + if (res.success) { + this.allTreeKeys = [] + this.treeDataSource = res.result + this.generateList(this.treeDataSource) + this.expandedKeys = this.allTreeKeys + } else { + this.$notification.warning({ + message: '娑堟伅', + description: res.message + }) + } + }) + .finally(() => { + this.spinning = false + }) }, - autocompleteForm(selectObj) { - this.$set(this.model, 'standardName', selectObj.standardName) - this.$set(this.model, 'standardId', selectObj.id) - this.$set(this.model, 'equipmentId', selectObj.equipmentId) - if (!this.model.id) this.loadStandardDetail(selectObj.id) + /** + * 棰勮璁惧瑙勮寖鏄庣粏 + * @param standardId + */ + handlePreviewDetail(standardId) { + this.$refs.detailModal.visible = true + this.$refs.detailModal.loadStandardDetail(standardId) + }, + + onExpand(expandedKeys) { + this.expandedKeys = expandedKeys + this.autoExpandParent = false + }, + + async onCheck(value, obj) { + this.$refs.editableDetailTable.clearValidate() + this.checkedKeys = value + const childNodesList = obj.checkedNodes.filter(item => item.data.props.equipmentId).map(item => { + return { + ...item.data.props.dataRef, + id: item.data.props.dataRef.key, + equipmentId: item.data.props.dataRef.key, + equipmentCode: item.data.props.dataRef.equipmentId, + standardId: item.data.props.dataRef.maintenanceStandardId, + standardName: item.data.props.dataRef.maintenanceStandardName, + maintenancePeriod: 6 + } + }) + + if (childNodesList.length === 0) { + this.detail.dataSource = [] + return + } + console.log('childNodesList', childNodesList) + + if (childNodesList.length > this.detail.dataSource.length) { + childNodesList.forEach(childNode => { + if (!(this.detail.dataSource.map(item => item.id).includes(childNode.id))) this.detail.dataSource.push(childNode) + }) + console.log('detail+++++++++++', this.detail.dataSource) + } else { + const deleteList = [] + this.detail.dataSource.map(item => item.id).forEach(item => { + if (!(childNodesList.map(childNode => childNode.id).includes(item))) deleteList.push(item) + }) + + deleteList.forEach(deleteItem => { + this.detail.dataSource.splice(this.detail.dataSource.findIndex(item => item.id === deleteItem), 1) + }) + + console.log('deleteList', deleteList) + console.log('detail----------', this.detail.dataSource) + } + }, + + /** + * 鐐瑰嚮鏍戣妭鐐规椂瑙﹀彂 + * @param selectedKeys + * @param event + */ + handleTreeNodeSelect(selectedKeys, event) { + event.node.$el.childNodes[1].click() + }, + + /** + * 閫掑綊鏍戞暟鎹睍寮�鎵�鏈夎妭鐐� + * @param data + */ + generateList(data) { + for (let i = 0; i < data.length; i++) { + const node = data[i] + const key = node.key + this.allTreeKeys.push(key) + if (node.children) { + this.generateList(node.children) + } + } + }, + + handleBatchSetDate(value) { + this.detail.dataSource.forEach((item, index, self) => { + if (this.selectedKeys.includes(item.id)) this.$set(item, 'maintenanceDate', value) + }) + }, + + /** + * 琛ㄦ牸澶氶�夋鍙戠敓鏀瑰彉鏃惰Е鍙� + * @param {selectedRowIds} 琛ㄦ牸涓凡閫夋嫨鐨処D鍒楄〃 + */ + handleTableSelectRowChange({ selectedRowIds }) { + this.selectedKeys = selectedRowIds + console.log('selectedKeys', this.selectedKeys) }, async handleOk() { - const that = this - // 瑙﹀彂琛ㄥ崟楠岃瘉 - this.$refs.form.validate(valid => { - if (valid) { - that.confirmLoading = that.spinning = true - let httpUrl = '' - let method = '' - if (!this.model.id) { - httpUrl += this.url.add - method = 'post' + const requests = this.$refs.editableDetailTable.getTableData() + if (requests.length == 0) { + this.$notification.warning({ + message: '娑堟伅', + description: '璇疯嚦灏戞柊澧炰竴鏉¤褰�' + }) + return + } + + const errMap = await this.$refs.editableDetailTable.validateTable() + if (errMap) return + + this.confirmLoading = this.spinning = true + postAction(this.url.batchAdd, requests) + .then((res) => { + if (res.success) { + this.$notification.success({ + message: '娑堟伅', + description: res.message + }) + this.$emit('ok') + this.close() } else { - httpUrl += this.url.edit - method = 'put' + this.$notification.warning({ + message: '娑堟伅', + description: res.message + }) } - httpAction(httpUrl, this.model, method) - .then((res) => { - if (res.success) { - that.$notification.success({ - message: '娑堟伅', - description: res.message - }) - that.$emit('ok') - that.close() - } else { - that.$notification.warning({ - message: '娑堟伅', - description: res.message - }) - } - }) - .finally(() => { - that.confirmLoading = that.spinning = false - }) - } else { - return false - } - }) + }) + .finally(() => { + this.confirmLoading = this.spinning = false + }) }, handleCancel() { @@ -154,3 +288,9 @@ } } </script> + +<style scoped lang="less"> + /deep/ .ant-select-dropdown-menu { + text-align: left; + } +</style> -- Gitblit v1.9.3