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

ADD: 封装批量删除

上级 cc21c13b
...@@ -78,6 +78,31 @@ export function useInitTable(opt = {}) { ...@@ -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 { return {
searchForm, searchForm,
resetSearchForm, resetSearchForm,
...@@ -88,7 +113,10 @@ export function useInitTable(opt = {}) { ...@@ -88,7 +113,10 @@ export function useInitTable(opt = {}) {
limit, limit,
getData, getData,
handleDelete, handleDelete,
handleStatusChange handleStatusChange,
handleSelectionChange,
multipleTableRef,
handleMultiDelete
} }
......
...@@ -58,9 +58,6 @@ ...@@ -58,9 +58,6 @@
<script setup> <script setup>
import { ref } from "vue"
import { toast } from "@/composables/util"
import { import {
getSkusList, getSkusList,
createSkus, createSkus,
...@@ -86,7 +83,10 @@ const { ...@@ -86,7 +83,10 @@ const {
limit, limit,
getData, getData,
handleDelete, handleDelete,
handleStatusChange handleStatusChange,
handleSelectionChange,
multipleTableRef,
handleMultiDelete
} = useInitTable({ } = useInitTable({
getList: getSkusList, getList: getSkusList,
...@@ -134,31 +134,6 @@ const { ...@@ -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> </script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册