提交 b107cd6c 编写于 作者: kadycui's avatar kadycui 💻

ADD: 封装批量删除

上级 cc21c13b
......@@ -78,6 +78,31 @@ export function useInitTable(opt = {}) {
})
}
// 多选选中ID
const multiSelectionIds = ref([])
const handleSelectionChange = (e) => {
multiSelectionIds.value = e.map(o => o.id)
}
// 批量删除
const multipleTableRef = ref(null)
const handleMultiDelete = () => {
loading.value = true
opt.delete(multiSelectionIds.value)
.then(res => {
toast("删除成功!")
// 清空选中
if (multipleTableRef.value) {
multipleTableRef.value.clearSelection()
}
getData()
})
.finally(() => {
loading.value = false
})
}
return {
searchForm,
resetSearchForm,
......@@ -88,7 +113,10 @@ export function useInitTable(opt = {}) {
limit,
getData,
handleDelete,
handleStatusChange
handleStatusChange,
handleSelectionChange,
multipleTableRef,
handleMultiDelete
}
......
......@@ -58,9 +58,6 @@
<script setup>
import { ref } from "vue"
import { toast } from "@/composables/util"
import {
getSkusList,
createSkus,
......@@ -86,7 +83,10 @@ const {
limit,
getData,
handleDelete,
handleStatusChange
handleStatusChange,
handleSelectionChange,
multipleTableRef,
handleMultiDelete
} = useInitTable({
getList: getSkusList,
......@@ -134,31 +134,6 @@ const {
})
// 多选选中ID
const multiSelectionIds = ref([])
const handleSelectionChange = (e) => {
multiSelectionIds.value = e.map(o => o.id)
}
// 批量删除
const multipleTableRef = ref(null)
const handleMultiDelete = () => {
loading.value = true
deleteSkus(multiSelectionIds.value)
.then(res => {
toast("删除成功!")
// 清空选中
if(multipleTableRef.value){
multipleTableRef.value.clearSelection()
}
getData()
})
.finally(() => {
loading.value = false
})
}
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册