diff --git a/src/api/system/equipmentNew.js b/src/api/system/equipmentNew.js index c5f83d58..b4ed4c40 100644 --- a/src/api/system/equipmentNew.js +++ b/src/api/system/equipmentNew.js @@ -10,6 +10,30 @@ export function listUser(query) { }) } +export function getOwnEquipmentList(query) { + return request({ + url: '/material-mall/deptConfig/getOwnEquipmentList', + method: 'get', + params: query + }) +} + +export function getSharingEquipmentList(query) { + return request({ + url: '/material-mall/deptConfig/getSharingEquipmentList', + method: 'get', + params: query + }) +} + +export function getRentalEquipmentList(query) { + return request({ + url: '/material-mall/deptConfig/getRentalEquipmentList', + method: 'get', + params: query + }) +} + export function selectResourceList(query) { return request({ url: '/material-mall/deptConfig/selectResourceList', @@ -26,6 +50,41 @@ export function selectInventoryList(query) { }) } +export function saveInstanceSelection(data) { + return request({ + url: '/material-mall/deptConfig/saveInstanceSelection', + method: 'post', + data: data + }) +} + +export function getConfigurationTotal() { + return request({ + url: '/material-mall/deptConfig/getConfigurationTotal', + method: 'post' + }) +} + +export function getConfigurationDetails(data) { + return request({ + url: '/material-mall/deptConfig/getConfigurationDetails', + method: 'post', + data: data + }) +} + + +export function exportStatsData() { + return request({ + url: '/material-mall/deptConfig/exportStatsData', + method: 'get', + }) +} + + + + + export function insertResource(data) { return request({ url: '/material-mall/deptConfig/insertResource', diff --git a/src/views/rent-facility/index.vue b/src/views/rent-facility/index.vue index 6e5ef3d0..a6efca45 100644 --- a/src/views/rent-facility/index.vue +++ b/src/views/rent-facility/index.vue @@ -1,227 +1,389 @@ - + + + - diff --git a/src/views/system/equipment/index.vue b/src/views/system/equipment/index.vue index bb56b8c7..b7181e6d 100644 --- a/src/views/system/equipment/index.vue +++ b/src/views/system/equipment/index.vue @@ -362,6 +362,317 @@ + + + +
+ +
+ + + + + + + + + + + + + + + 查询 + 重置 + + +
+ + + + + + + + + + + + +
+ + +
+ + + +
+ +
+ + + + + + + + + + + + + + 查询 + 重置 + + +
+ + + + + + + + + + + + +
+ + +
+ + + +
+ +
+ + + + + + + + + + + + + + 查询 + 重置 + + +
+ + + + + + + + + + + + +
+ + +
@@ -371,8 +682,21 @@ import EquipmentTable from './table.vue' import CorrelationTable from './correlationTable.vue' // 接口统一引入 import { - listUser, addUser, getUser, delUser, updateEquipmentConfig, - deptTreeSelect, selectResourceList, insertResource, deleteResource, getCategoryList, selectInventoryList + listUser, + addUser, + getUser, + delUser, + updateEquipmentConfig, + deptTreeSelect, + selectResourceList, + insertResource, + deleteResource, + getCategoryList, + selectInventoryList, + getOwnEquipmentList, + getSharingEquipmentList, + getRentalEquipmentList, + saveInstanceSelection } from '@/api/system/equipmentNew' export default { @@ -381,26 +705,34 @@ export default { dicts: ['voltage_type', 'ma_machine_status'], data() { return { - // 主标签页配置:统一管理,便于扩展 + // 原有数据保持不变 mainTabList: [ { name: '0', key: 'line', label: '线路工程' }, { name: '1', key: 'power', label: '变电工程' }, { name: '2', key: 'cable', label: '电缆工程' } ], lineTypeOptions: [ - { label: '35kV', value: '35kV' }, // value可根据后端需求改为编码(如'35kV') + { label: '35kV', value: '35kV' }, { label: '110kV', value: '110kV' }, { label: '220kV', value: '220kV' }, { label: '500kV', value: '500kV' }, { label: '特高压', value: '特高压' } ], - jijuTypeOptions: [{ label: '通用装备', value: '通用装备' }, // value可根据后端需求改为编码(如'35kV') + jijuTypeOptions: [ + { label: '通用装备', value: '通用装备' }, { label: '专用设备', value: '专用设备' }, { label: '新型装备', value: '新型装备' } ], - activeTab: '0', // 激活的主标签页 + activeTab: '0', - // 所有表格列配置:聚合管理,按业务分类 + // 新增:装备类型选项(用于筛选) + equipmentTypeOptions: [ + { label: '通用装备', value: '通用装备' }, + { label: '专用设备', value: '专用设备' }, + { label: '新型装备', value: '新型装备' } + ], + + // 所有表格列配置:新增实例详情列配置 tableColumns: { main: [ { label: '项目名称', prop: 'typeName', minWidth: 120 }, @@ -423,7 +755,7 @@ export default { classification: [ { label: '名称', prop: 'name', minWidth: 400 }, { - label: '类型', prop: 'category', minWidth: 80,// 混合场景:先判断值,再返回文字 + label: '类型', prop: 'category', minWidth: 80, dictMap: { 0: '装备', 1: '工具' } }, { label: '数量', prop: 'quantity', minWidth: 80 }, @@ -442,15 +774,51 @@ export default { inventory: [ { label: '实列类型', prop: 'type', minWidth: 120, - dictMap: { 0: '自用', 1: '共享', 2: '外租' } + dictMap: { 0: '自有', 1: '共享', 2: '外租' } }, { label: '名称', prop: 'name', minWidth: 120 }, { label: '类型', prop: 'category', minWidth: 80, dictMap: { 0: '装备', 1: '工具' } }, + { label: '数量', prop: 'num', minWidth: 80 } + ], + // 新增:实例详情表格列(用于弹窗内的表格) + instanceDetail: [ + { label: '分类', prop: 'type', minWidth: 300 }, + { + label: '类型', prop: 'category', minWidth: 100, + dictMap: { 0: '装备', 1: '工具' } + }, + { label: '设备编码', prop: 'deviceCode', minWidth: 120 }, + { label: '装备名称', prop: 'name', minWidth: 150 }, + { label: '规格型号', prop: 'specificationModel', minWidth: 120 }, + { label: '原始编码', prop: 'originalEncoding', minWidth: 120 }, + { label: '数量', prop: 'num', minWidth: 80 } + ], + rentalDetail: [ + { label: '分类', prop: 'type', minWidth: 300 }, + { label: '装备名称', prop: 'name', minWidth: 150 }, + { label: '所属项目', prop: 'proName', minWidth: 150 }, + { label: '出租公司', prop: 'rentalCompany', minWidth: 150 }, + { label: '租赁时间', prop: 'startTime', minWidth: 120 }, + { label: '归还时间', prop: 'endTime', minWidth: 120 }, + { label: '数量', prop: 'num', minWidth: 80 } + ], + sharingDetail: [ + { label: '订单编号', prop: 'orderNumber', minWidth: 150 }, + { + label: '分类', prop: 'category', minWidth: 100, + dictMap: { 0: '装备', 1: '工具' } + }, + { label: '装备名称', prop: 'name', minWidth: 150 }, + { label: '规格型号', prop: 'specificationModel', minWidth: 120 }, + { label: '开始时间', prop: 'startTime', minWidth: 120 }, + { label: '结束时间', prop: 'endTime', minWidth: 120 }, + { label: '数量', prop: 'num', minWidth: 80 } ] + }, // 左侧部门树配置 @@ -462,7 +830,7 @@ export default { currentDeptId: null, configId: null, - // 所有表格状态:聚合管理 + // 所有表格状态:新增自有/共享/外租表格数据 tableData: { line: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, power: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, @@ -470,15 +838,24 @@ export default { fuzzy: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, classification: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, instance: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, - inventory: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 } + inventory: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, + // 新增 + own: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, + sharing: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 }, + rental: { list: [], loading: false, total: 0, pageNum: 1, pageSize: 10 } }, - // 弹窗状态:主弹窗+三个独立关联弹窗(完全独立) + // 弹窗状态:新增三个实例弹窗状态 dialogOpen: false, correlationOpen: false, - fuzzyOpen: false, // 模糊弹窗显隐 - classificationOpen: false,// 分类弹窗显隐 - instanceOpen: false, // 实例弹窗显隐 + fuzzyOpen: false, + classificationOpen: false, + instanceOpen: false, + // 新增 + ownOpen: false, // 自有装备弹窗 + sharingOpen: false, // 共享装备弹窗 + rentalOpen: false, // 外租装备弹窗 + dialogTitle: '', correlationTitle: '', fuzzyTitle: '新增模糊匹配', @@ -487,9 +864,8 @@ export default { isEdit: false, submitLoading: false, - // 表单数据:主表单+三个独立关联表单(字段按需配置,完全独立) + // 表单数据 formData: { - // 主表单 mainForm: { id: null, typeName: '', @@ -505,32 +881,52 @@ export default { deptId: '', configType: '' }, - // 1. 模糊匹配表单(仅matchingName) fuzzyForm: { matchingName: '', - matchingType: '0', // 固定0:模糊匹配 + matchingType: '0', configId: '' }, - // 2. 分类匹配表单(matchingName+category) classificationForm: { matchingName: '', name: '', category: '', - matchingType: '1', // 固定1:分类匹配 + matchingType: '1', configId: '' }, - // 3. 实例匹配表单(matchingName+category) instanceForm: { matchingName: '', category: '', - matchingType: '2', // 固定2:实例匹配 + matchingType: '2', configId: '' } }, - // 校验规则:主规则+三个独立关联规则(按需配置,完全独立) + // 新增:筛选表单数据 + searchForm: { + own: { + equipmentName: '', + equipmentType: '', + specModel: '' + }, + sharing: { + equipmentName: '', + equipmentType: '', + deptName: '' + }, + rental: { + equipmentName: '', + equipmentType: '', + companyName: '' + } + }, + + // 新增:选中的行数据 + selectedOwnRows: [], + selectedSharingRows: [], + selectedRentalRows: [], + + // 校验规则 formRules: { - // 主表单规则 mainRules: { typeName: [ { required: true, message: '请输入项目名称', trigger: 'blur' }, @@ -551,20 +947,17 @@ export default { configRate: [{ validator: this.validateConfigRate, trigger: 'change' }], isNew: [{ required: true, message: '请选择是否新型装备', trigger: 'change' }] }, - // 1. 模糊匹配规则(仅校验matchingName) fuzzyRules: { matchingName: [ { required: true, message: '请输入匹配名称', trigger: 'blur' }, { max: 100, message: '匹配名称长度不能超过100个字符', trigger: 'blur' } ] }, - // 2. 分类匹配规则(校验matchingName+category) classificationRules: { matchingName: [ { required: true, message: '请选择分类', trigger: 'change' } ] }, - // 3. 实例匹配规则(与分类一致,校验matchingName+category) instanceRules: { matchingName: [ { required: true, message: '请输入匹配名称', trigger: 'blur' }, @@ -602,10 +995,9 @@ export default { formRef() { return this.$refs.formRef } - // 移除所有关联表单的computed引用,直接在方法中通过$refs获取,避免缓存问题 }, methods: { - // 通用配置率校验 + // 原有方法保持不变 validateConfigRate(rule, value, callback) { if (this.formData.mainForm.configRateType === 'custom') { if (value === undefined || value === null) { @@ -624,12 +1016,10 @@ export default { if (res.code === 200) { this.categoryList = res.data.map(item => ({ ...item, - uniqueKey: `${item.typeId}-${item.type}` // 生成唯一key + uniqueKey: `${item.typeId}-${item.type}` })) } }, - - // 左侧部门树相关方法 async getDeptTree() { try { this.treeLoading = true @@ -655,8 +1045,6 @@ export default { if (!value) return true return data.deptName?.toLowerCase().includes(value.toLowerCase()) }, - - // 主标签页核心方法 handleTabClick(tab) { this.activeTab = tab.name const tabConfig = this.tableData[tab.key] @@ -699,8 +1087,6 @@ export default { const tab = this.mainTabList.find(item => item.key === tabKey) this.loadMainTabData(tab.name) }, - - // 关联弹窗核心方法 async handleTableRelate(row) { if (!row?.id) return this.configId = row.id @@ -753,10 +1139,7 @@ export default { this.tableData[key].pageNum = 1 }) this.loadMainTabData(this.activeTab) - }, - - // 主表格操作方法 handleTableAdd() { if (!this.currentDeptId) { this.$message.warning('请先在左侧选择所属公司') @@ -809,16 +1192,12 @@ export default { } }) }, - - // 关联表格删除方法(精准刷新对应表格) handleCorrelationDelete(row) { if (!row?.id) return this.$confirm('确定删除此条关联数据吗?', '温馨提示', { type: 'warning' }).then(async() => { try { - // 待实现:关联数据删除接口 await deleteResource(row.id) this.$message.success('删除成功') - // 根据matchingType精准刷新对应表格 let tabKey = '' if (row.matchingType === '0') { tabKey = 'fuzzy' @@ -832,7 +1211,6 @@ export default { } }) }, - async handleFormSubmit() { try { await this.formRef.validate() @@ -860,8 +1238,6 @@ export default { this.formRef?.clearValidate() this.submitLoading = false }, - - // ====================== 模糊匹配独立弹窗方法(修复后) ====================== handleFuzzyTableAdd() { this.initForm('fuzzy') this.fuzzyOpen = true @@ -936,8 +1312,6 @@ export default { this.$refs.fuzzyFormRef?.clearValidate() this.initForm('fuzzy') }, - - // ====================== 分类匹配独立弹窗方法(与模糊逻辑一致) ====================== handleClassificationTableAdd() { this.initForm('classification') this.classificationOpen = true @@ -946,34 +1320,29 @@ export default { this.$refs.classificationFormRef?.clearValidate() }) }, - // 分类选择-变化事件:获取选中项完整数据(搜索后依然生效) handleCategoryChange(selectedTypeId) { - // 判空:清空选择/搜索无结果时,重置自定义字段 if (!selectedTypeId) { this.formData.classificationForm.selectedCategory = null - this.formData.classificationForm.category = '' // 清空分类名称存储 + this.formData.classificationForm.category = '' return } - // 反向查找选中项的完整对象,获取所有自定义字段 const selectedItem = this.categoryList.find( item => item.typeId === selectedTypeId ) if (selectedItem) { - // 存储完整对象和分类名称,方便后续提交/展示 this.formData.classificationForm.matchingName = selectedItem.typeId this.formData.classificationForm.category = selectedItem.type this.formData.classificationForm.name = selectedItem.equipmentName } }, handleJijuTypeChange(selectedTypeId) { - // 判空:清空选择/搜索无结果时,重置自定义字段 if (!selectedTypeId) { this.formData.mainForm.jijuType = null - this.formData.mainForm.isNew = '0' // 清空分类名称存储 + this.formData.mainForm.isNew = '0' } else { if (selectedTypeId == '新型装备') { this.formData.mainForm.jijuType = selectedTypeId - this.formData.mainForm.isNew = '1' // 清空分类名称存储 + this.formData.mainForm.isNew = '1' } } }, @@ -1005,8 +1374,6 @@ export default { this.$refs.classificationFormRef?.clearValidate() this.initForm('classification') }, - - // ====================== 实例匹配独立弹窗方法(与分类逻辑一致) ====================== handleInstanceTableAdd() { this.initForm('instance') this.instanceOpen = true @@ -1014,48 +1381,318 @@ export default { this.$refs.instanceFormRef?.clearValidate() }) }, - handleInstanceTableOwn() { - this.initForm('instance') - this.instanceOpen = true - this.$nextTick(() => { - this.$refs.instanceFormRef?.clearValidate() - }) + + // ====================== 新增:实例匹配弹窗相关方法 ====================== + // 1. 自有装备弹窗方法 + async handleInstanceTableOwn() { + // 重置筛选条件和选中状态 + this.searchForm.own = { + equipmentName: '', + equipmentType: '', + specModel: '' + } + this.selectedOwnRows = [] + // 初始化分页 + this.tableData.own.pageNum = 1 + // 加载数据并打开弹窗 + await this.loadOwnEquipmentData() + this.ownOpen = true }, - handleInstanceSharingAdd() { - this.initForm('instance') - this.instanceOpen = true - this.$nextTick(() => { - this.$refs.instanceFormRef?.clearValidate() - }) + async loadOwnEquipmentData() { + const tabConfig = this.tableData.own + tabConfig.loading = true + try { + const queryParams = { + deptId: this.currentDeptId, + configId: this.configId, + ...this.searchForm.own, + pageNum: tabConfig.pageNum, + pageSize: tabConfig.pageSize + } + const res = await getOwnEquipmentList(queryParams) + tabConfig.list = res.rows || [] + tabConfig.total = res.total || 0 + } catch (err) { + console.error('加载自有装备数据失败:', err) + this.$message.error('加载自有装备数据失败,请稍后重试') + tabConfig.list = [] + tabConfig.total = 0 + } finally { + tabConfig.loading = false + } }, - handleInstanceRentalAdd() { - this.initForm('instance') - this.instanceOpen = true - this.$nextTick(() => { - this.$refs.instanceFormRef?.clearValidate() - }) + handleOwnSearch() { + this.tableData.own.pageNum = 1 + this.loadOwnEquipmentData() }, - async handleInstanceConfirm() { + resetOwnSearch() { + this.searchForm.own = { + equipmentName: '', + equipmentType: '', + specModel: '' + } + this.tableData.own.pageNum = 1 + this.loadOwnEquipmentData() + }, + handleOwnSizeChange(val) { + this.tableData.own.pageSize = val + this.loadOwnEquipmentData() + }, + handleOwnCurrentChange(val) { + this.tableData.own.pageNum = val + this.loadOwnEquipmentData() + }, + handleOwnSelectionChange(val) { + this.selectedOwnRows = val + }, + async handleOwnConfirm() { + try { + // 提交选中的自有装备数据 + const submitData = { + configId: this.configId, + matchingType: '2', + type: '0', // 0-自有 + equipmentList: this.selectedOwnRows.map(item => ({ + matchingName: item.id, + name: item.name, + category: item.category + })) + } + const res = await saveInstanceSelection(submitData) + if (res.code === 200) { + this.$message.success('自有装备选择成功') + this.ownOpen = false + // 刷新实例表格和清单表格 + await this.loadCorrelationData('instance') + await this.loadCorrelationData('inventory') + } else { + this.$message.error(res.message || '自有装备选择失败') + } + } catch (err) { + console.error('保存自有装备选择失败:', err) + this.$message.error('保存自有装备选择失败,请稍后重试') + } + }, + handleOwnClose() { + this.selectedOwnRows = [] + this.$refs.ownTableRef?.clearSelection() + }, + + // 2. 共享装备弹窗方法 + async handleInstanceSharingAdd() { + // 重置筛选条件和选中状态 + this.searchForm.sharing = { + equipmentName: '', + equipmentType: '', + deptName: '' + } + this.selectedSharingRows = [] + // 初始化分页 + this.tableData.sharing.pageNum = 1 + // 加载数据并打开弹窗 + await this.loadSharingEquipmentData() + this.sharingOpen = true + }, + async loadSharingEquipmentData() { + const tabConfig = this.tableData.sharing + tabConfig.loading = true + try { + const queryParams = { + deptId: this.currentDeptId, + configId: this.configId, + ...this.searchForm.sharing, + pageNum: tabConfig.pageNum, + pageSize: tabConfig.pageSize + } + const res = await getSharingEquipmentList(queryParams) + tabConfig.list = res.rows || [] + tabConfig.total = res.total || 0 + } catch (err) { + console.error('加载共享装备数据失败:', err) + this.$message.error('加载共享装备数据失败,请稍后重试') + tabConfig.list = [] + tabConfig.total = 0 + } finally { + tabConfig.loading = false + } + }, + handleSharingSearch() { + this.tableData.sharing.pageNum = 1 + this.loadSharingEquipmentData() + }, + resetSharingSearch() { + this.searchForm.sharing = { + equipmentName: '', + equipmentType: '', + deptName: '' + } + this.tableData.sharing.pageNum = 1 + this.loadSharingEquipmentData() + }, + handleSharingSizeChange(val) { + this.tableData.sharing.pageSize = val + this.loadSharingEquipmentData() + }, + handleSharingCurrentChange(val) { + this.tableData.sharing.pageNum = val + this.loadSharingEquipmentData() + }, + handleSharingSelectionChange(val) { + this.selectedSharingRows = val + }, + async handleSharingConfirm() { + try { + // 提交选中的共享装备数据 + const submitData = { + configId: this.configId, + matchingType: '2', + type: '1', // 共享 + equipmentList: this.selectedSharingRows.map(item => ({ + matchingName: item.id, + name: item.name, + category: item.category + })) + } + const res = await saveInstanceSelection(submitData) + if (res.code === 200) { + this.$message.success('共享装备选择成功') + this.sharingOpen = false + // 刷新实例表格和清单表格 + await this.loadCorrelationData('instance') + await this.loadCorrelationData('inventory') + } else { + this.$message.error(res.message || '共享装备选择失败') + } + } catch (err) { + console.error('保存共享装备选择失败:', err) + this.$message.error('保存共享装备选择失败,请稍后重试') + } + }, + handleSharingClose() { + this.selectedSharingRows = [] + this.$refs.sharingTableRef?.clearSelection() + }, + + // 3. 外租装备弹窗方法 + async handleInstanceRentalAdd() { + // 重置筛选条件和选中状态 + this.searchForm.rental = { + equipmentName: '', + equipmentType: '', + companyName: '' + } + this.selectedRentalRows = [] + // 初始化分页 + this.tableData.rental.pageNum = 1 + // 加载数据并打开弹窗 + await this.loadRentalEquipmentData() + this.rentalOpen = true + }, + async loadRentalEquipmentData() { + const tabConfig = this.tableData.rental + tabConfig.loading = true + try { + const queryParams = { + deptId: this.currentDeptId, + configId: this.configId, + ...this.searchForm.rental, + pageNum: tabConfig.pageNum, + pageSize: tabConfig.pageSize + } + const res = await getRentalEquipmentList(queryParams) + tabConfig.list = res.rows || [] + tabConfig.total = res.total || 0 + } catch (err) { + console.error('加载外租装备数据失败:', err) + this.$message.error('加载外租装备数据失败,请稍后重试') + tabConfig.list = [] + tabConfig.total = 0 + } finally { + tabConfig.loading = false + } + }, + handleRentalSearch() { + this.tableData.rental.pageNum = 1 + this.loadRentalEquipmentData() + }, + resetRentalSearch() { + this.searchForm.rental = { + equipmentName: '', + equipmentType: '', + companyName: '' + } + this.tableData.rental.pageNum = 1 + this.loadRentalEquipmentData() + }, + handleRentalSizeChange(val) { + this.tableData.rental.pageSize = val + this.loadRentalEquipmentData() + }, + handleRentalCurrentChange(val) { + this.tableData.rental.pageNum = val + this.loadRentalEquipmentData() + }, + handleRentalSelectionChange(val) { + this.selectedRentalRows = val + }, + async handleRentalConfirm() { + try { + // 提交选中的外租装备数据 + const submitData = { + configId: this.configId, + matchingType: '2', + type: '2', // 外租 + equipmentList: this.selectedRentalRows.map(item => ({ + matchingName: item.id, + name: item.name, + category: item.category + })) + } + const res = await saveInstanceSelection(submitData) + if (res.code === 200) { + this.$message.success('外租装备选择成功') + this.rentalOpen = false + // 刷新实例表格和清单表格 + await this.loadCorrelationData('instance') + await this.loadCorrelationData('inventory') + } else { + this.$message.error(res.message || '外租装备选择失败') + } + } catch (err) { + console.error('保存外租装备选择失败:', err) + this.$message.error('保存外租装备选择失败,请稍后重试') + } + }, + handleRentalClose() { + this.selectedRentalRows = [] + this.$refs.rentalTableRef?.clearSelection() + }, + + handleInstanceConfirm() { const instanceForm = this.$refs.instanceFormRef if (!instanceForm) { this.$message.warning('表单加载中,请稍候再试') return } try { - await instanceForm.validate() - this.submitLoading = true - const res = await insertResource(this.formData.instanceForm) - if (res.code === 200) { - this.$message.success('新增实例匹配成功') - this.instanceOpen = false - await this.loadCorrelationData('instance') - await this.loadCorrelationData('inventory') - } else { - this.$message.error(res.message || '新增实例匹配失败') - } + instanceForm.validate().then(async() => { + this.submitLoading = true + const res = await insertResource(this.formData.instanceForm) + if (res.code === 200) { + this.$message.success('新增实例匹配成功') + this.instanceOpen = false + await this.loadCorrelationData('instance') + await this.loadCorrelationData('inventory') + } else { + this.$message.error(res.message || '新增实例匹配失败') + } + }).catch(err => { + console.error('表单验证失败:', err) + }).finally(() => { + this.submitLoading = false + }) } catch (err) { console.error('新增实例匹配失败:', err) - } finally { this.submitLoading = false } }, @@ -1068,9 +1705,10 @@ export default {