修复:删除种类时检查是否有商品

This commit is contained in:
Agent
2026-03-27 02:10:25 +00:00
parent 12da38d65d
commit 3f9420d026

View File

@@ -121,6 +121,15 @@ export default {
}
},
deleteCategory(cat) {
// 先检查该分类下是否有商品
uni.showLoading({ title: '检查中...' })
productApi.getProducts({ categoryId: cat.categoryId, page: 1, pageSize: 1 }).then(res => {
uni.hideLoading()
if (res.records && res.records.length > 0) {
uni.showToast({ title: '该分类下有商品,无法删除', icon: 'none' })
return
}
uni.showModal({
title: '确认删除',
content: `确定要删除 "${cat.name}" 吗?`,
@@ -136,6 +145,10 @@ export default {
}
}
})
}).catch(() => {
uni.hideLoading()
uni.showToast({ title: '检查失败', icon: 'none' })
})
}
}
}