From 67bc71ab83ede070dc226dc2b2d034694bd3d7ed Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Thu, 27 Nov 2025 15:09:32 +0800 Subject: [PATCH] 2025-11-27 --- src/api/qc/qc.js | 1 + src/views/modules/qc/qcPartAttribute.vue | 38 +++++++++++++++++++-- src/views/modules/qc/qcTemplate.vue | 42 +++++++++++++++++------- 3 files changed, 68 insertions(+), 13 deletions(-) diff --git a/src/api/qc/qc.js b/src/api/qc/qc.js index f4686f1..c89b967 100644 --- a/src/api/qc/qc.js +++ b/src/api/qc/qc.js @@ -21,6 +21,7 @@ export const templateSearch = data => createAPI(`/pms/qc/templateSearch`,'post', export const templateSave = data => createAPI(`/pms/qc/templateSave`,'post',data) export const templateUpdate = data => createAPI(`/pms/qc/templateUpdate`,'post',data) export const templateDelete = data => createAPI(`/pms/qc/templateDelete`,'post',data) +export const checkTemplateReference = data => createAPI(`/pms/qc/checkTemplateReference`,'post',data) // 检查模板是否被物料引用 export const inspectionTypeSearch = data => createAPI(`/pms/qc/inspectionTypeSearch`,'post',data) export const objectSearch = data => createAPI(`/pms/qc/objectSearch`,'post',data) export const templateDetailsSearch = data => createAPI(`/pms/qc/templateDetailsSearch`,'post',data) diff --git a/src/views/modules/qc/qcPartAttribute.vue b/src/views/modules/qc/qcPartAttribute.vue index 7dcebd9..cbe8826 100644 --- a/src/views/modules/qc/qcPartAttribute.vue +++ b/src/views/modules/qc/qcPartAttribute.vue @@ -352,8 +352,8 @@ @@ -498,6 +498,17 @@ + + + @@ -1363,6 +1374,8 @@ selectedTemplates: [], // 选中的质量检验模板 dataListLoading: false, templateDeleteLoading: false, // 批量删除loading + templatePageIndex: 1, // 质量检验模板当前页 + templatePageSize: 20, // 质量检验模板每页条数 // 展示列集 columnList: [ { @@ -2028,6 +2041,15 @@ } }, + computed: { + // 质量检验模板分页数据 + detailListPaged () { + const start = (this.templatePageIndex - 1) * this.templatePageSize + const end = start + this.templatePageSize + return this.detailList.slice(start, end) + } + }, + methods: { // 获取用户的bu getSiteAndBuByUserName () { @@ -2268,6 +2290,7 @@ this.detailData.partDesc = this.partCurrentRow.partDesc searchPartAttributeDetails(this.detailData).then(({data}) => { this.detailList = data.rows + this.templatePageIndex = 1 // 重置到第一页 }) }, @@ -2521,6 +2544,17 @@ }) }, + // 质量检验模板每页数 + templateSizeChangeHandle (val) { + this.templatePageSize = val + this.templatePageIndex = 1 + }, + + // 质量检验模板当前页 + templateCurrentChangeHandle (val) { + this.templatePageIndex = val + }, + // ==================== 物料缺陷跟踪 ==================== // 查询物料缺陷跟踪 diff --git a/src/views/modules/qc/qcTemplate.vue b/src/views/modules/qc/qcTemplate.vue index 3412120..cb7d81e 100644 --- a/src/views/modules/qc/qcTemplate.vue +++ b/src/views/modules/qc/qcTemplate.vue @@ -461,6 +461,7 @@ templateSave, // 新增模板 templateUpdate, // 修改模板 templateDelete, // 删除模板 + checkTemplateReference, // 检查模板是否被物料引用 inspectionTypeSearch, // 搜索所有检验类型 objectSearch, // 搜索所有设备 templateDetailsSearch, // 查询明细列表 @@ -1293,19 +1294,38 @@ // 删除 deleteModel (row) { - this.$confirm(`是否删除这个检验模板?`, '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }).then(() => { - templateDelete(row).then(({data}) => { - if (data && data.code === 0) { - this.getDataList() - this.$message.success('操作成功') + // 先检查模板是否被物料引用 + checkTemplateReference({ + site: row.site, + buNo: row.buNo, + templateId: row.templateId + }).then(({data}) => { + if (data && data.code === 0) { + if (data.isReferenced) { + // 模板被引用,提示不能删除 + this.$message.warning(`该模板已被 ${data.referenceCount} 个物料引用,无法删除!`) } else { - this.$message.error(data.msg) + // 模板未被引用,可以删除 + this.$confirm(`是否删除这个检验模板?`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + templateDelete(row).then(({data}) => { + if (data && data.code === 0) { + this.getDataList() + this.$message.success('操作成功') + } else { + this.$message.error(data.msg) + } + }) + }) } - }) + } else { + this.$message.error(data.msg || '检查模板引用失败') + } + }).catch(() => { + this.$message.error('检查模板引用失败') }) },