|
|
@@ -1,6 +1,6 @@
|
|
|
// @ts-check
|
|
|
import { getList, add, update, getDetail } from '@/api/order/lead'
|
|
|
-import { getList as getDetailList, add as addDetail, update as updateDetail, remove as removeDetail, getDetail as getDetailDetail } from '@/api/order/lead-detail'
|
|
|
+import { getList as getDetailList, add as addDetail, update as updateDetail, deleteById, getDetail as getDetailDetail } from '@/api/order/lead-detail'
|
|
|
import { getCustomerList } from '@/api/common/index'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import {
|
|
|
@@ -1128,7 +1128,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 详细信息删除
|
|
|
+ * 详细信息删除 (单条删除)
|
|
|
* @param {LeadDetailRecord} row - 行数据
|
|
|
* @param {number} index - 行索引
|
|
|
* @returns {Promise<void>}
|
|
|
@@ -1136,16 +1136,25 @@ export default {
|
|
|
*/
|
|
|
async detailRowDel(row, index) {
|
|
|
try {
|
|
|
- const res = await removeDetail(row.id)
|
|
|
- if (res.data && res.data.success) {
|
|
|
- this.$message.success('删除成功')
|
|
|
+ await this.$confirm(`确定删除这条详细信息吗?`, '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+
|
|
|
+ // 使用deleteById方法进行单条删除
|
|
|
+ const res = await deleteById(row.id)
|
|
|
+ if (res.data && res.data.code === 200 && res.data.success) {
|
|
|
+ this.$message.success(res.data.msg || '删除成功')
|
|
|
this.detailOnLoad(this.detailPage)
|
|
|
} else {
|
|
|
this.$message.error(res.data ? res.data.msg : '删除失败')
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error('删除失败:', error)
|
|
|
- this.$message.error('删除失败,请稍后重试')
|
|
|
+ if (error !== 'cancel') {
|
|
|
+ console.error('删除失败:', error)
|
|
|
+ this.$message.error('删除失败,请稍后重试')
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -1198,26 +1207,57 @@ export default {
|
|
|
this.$message.warning('请选择要删除的数据')
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
- await this.$confirm('确定删除选中的详细信息吗?', '提示', {
|
|
|
+ await this.$confirm(`确定删除选中的 ${this.detailSelectionList.length} 条详细信息吗?`, '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
})
|
|
|
-
|
|
|
- const res = await removeDetail(this.detailIds)
|
|
|
- if (res.data && res.data.success) {
|
|
|
- this.$message.success('删除成功')
|
|
|
+
|
|
|
+ // 显示删除进度提示
|
|
|
+ const loadingMessage = this.$message({
|
|
|
+ message: `正在删除 ${this.detailSelectionList.length} 条记录...`,
|
|
|
+ type: 'info',
|
|
|
+ duration: 0
|
|
|
+ })
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 并发调用deleteById进行批量删除
|
|
|
+ const deletePromises = this.detailIds.map(id => deleteById(id))
|
|
|
+ const results = await Promise.all(deletePromises)
|
|
|
+
|
|
|
+ // 统计成功和失败的数量
|
|
|
+ const successCount = results.filter(res =>
|
|
|
+ res.data && res.data.code === 200 && res.data.success
|
|
|
+ ).length
|
|
|
+ const failedCount = this.detailIds.length - successCount
|
|
|
+
|
|
|
+ // 关闭进度提示
|
|
|
+ loadingMessage.close()
|
|
|
+
|
|
|
+ // 根据结果显示不同的提示
|
|
|
+ if (failedCount === 0) {
|
|
|
+ this.$message.success(`成功删除 ${successCount} 条记录`)
|
|
|
+ } else if (successCount === 0) {
|
|
|
+ this.$message.error(`删除失败,共 ${failedCount} 条记录`)
|
|
|
+ } else {
|
|
|
+ this.$message.warning(`部分删除成功:成功 ${successCount} 条,失败 ${failedCount} 条`)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 刷新数据并清空选择
|
|
|
this.detailOnLoad(this.detailPage)
|
|
|
this.$refs.detailCrud.toggleSelection()
|
|
|
- } else {
|
|
|
- this.$message.error(res.data ? res.data.msg : '删除失败')
|
|
|
+
|
|
|
+ } catch (deleteError) {
|
|
|
+ loadingMessage.close()
|
|
|
+ throw deleteError
|
|
|
}
|
|
|
+
|
|
|
} catch (error) {
|
|
|
if (error !== 'cancel') {
|
|
|
- console.error('删除失败:', error)
|
|
|
- this.$message.error('删除失败,请稍后重试')
|
|
|
+ console.error('批量删除失败:', error)
|
|
|
+ this.$message.error('批量删除失败,请稍后重试')
|
|
|
}
|
|
|
}
|
|
|
}
|