This commit is contained in:
weiwei committed 2025-05-13 14:54:57 +08:00
1 parent 5bd138c276
commit 150b493080
3 files changed
+165 -323

No files matched your search

+158 -184
View File
@@ -1,42 +1,51 @@
<template>
<div v-loading="loading" class="w-full h-full">
<div class="layout-padding-auto layout-padding-view" style="overflow: scroll">
<el-form ref="baseDataFormRef" :model="baseDataForm" :rules="dataRules" label-width="100px">
<el-form ref="baseFormRef" :model="baseForm" :rules="dataRules" label-width="100px">
<div class="flex flex-wrap">
<el-form-item label="单据编号" prop="inventoryCode">
<el-input v-model.trim="baseDataForm.inventoryCode" readonly style="width: 200px" :disabled="disabled" />
<el-input v-model.trim="baseForm.inventoryCode" readonly style="width: 200px" />
</el-form-item>
<el-form-item label="单据日期" prop="inventoryDate">
<el-input v-model.trim="baseDataForm.inventoryDate" readonly style="width: 200px" :disabled="disabled" />
<el-input v-model.trim="baseForm.inventoryDate" readonly style="width: 200px" />
</el-form-item>
<el-form-item label="经办人" prop="handlerUserId">
<SelectHandlerUser
v-model.trim="baseDataForm.handlerUserId"
placeholder="请选择经办人"
style="width: 200px"
:disabled="disabled"
/>
<SelectHandlerUser v-model.trim="baseForm.handlerUserId" placeholder="请选择经办人" style="width: 200px" />
</el-form-item>
<el-form-item label="商户" prop="merchantId">
<select-mch v-model="baseDataForm.merchantId" :apiParams="{ types: '1' }" style="width: 200px" :disabled="disabled" />
<select-mch v-model="baseForm.merchantId" :apiParams="{ types: '1' }" style="width: 200px" />
</el-form-item>
<el-form-item label="货商" prop="supplierId">
<SelectCanteenSupplier v-model="baseDataForm.supplierId" style="width: 200px" :disabled="disabled" />
<SelectCanteenSupplier v-model="baseForm.supplierId" style="width: 200px" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model.trim="baseDataForm.remark" placeholder="请输入备注" style="width: 200px" :disabled="disabled" />
<el-input v-model.trim="baseForm.remark" placeholder="请输入备注" style="width: 200px" />
</el-form-item>
</div>
</el-form>
<el-row class="my-3">
<el-button type="primary" plain @click="handleClickSpuSelect">商品选择</el-button>
<el-button @click="removeSelectRowEvent" :disabled="state.selectedRowsErpMaterialIds.length <= 0">删除选中</el-button>
<el-button type="primary" plain @click="clickSelectDialog" v-auth="'canteen_canteenInventoryRecordsItem_add'">商品选择</el-button>
<el-button
@click="removeSelectedRows"
:disabled="state.selectedRowIds.length <= 0"
v-auth="'canteen_canteenInventoryRecordsItem_del'"
>
删除选中
</el-button>
<el-button type="danger" plain @click="clearData">清空数据</el-button>
</el-row>
<!-- 对话框选择 -->
<select-dialog
ref="selectDialogRef"
v-model="state.selectDialogVisible"
:selectedRows="state.itemTableForm"
@getSelectedRows="getSelectedRows"
/>
<vxe-table
ref="editableTableRef"
ref="itemTableFormRef"
border
:loading="loading"
show-overflow
@@ -49,14 +58,13 @@
// if (column.property === '') {
// return false
// }
if(disabled) return false
return true
},
}"
:column-config="{ resizable: true }"
:row-config="{ isHover: true }"
:resizable-config="{ dragMode: 'fixed' }"
:data="state.editableTableData"
:data="state.itemTableForm"
:edit-rules="validRules"
@checkbox-all="selectChangeEvent"
@checkbox-change="selectChangeEvent"
@@ -65,11 +73,9 @@
>
<vxe-column type="checkbox" width="40" fixed="left" />
<vxe-column type="seq" width="50" fixed="left" />
<vxe-column field="name" title="库存商品">
<template #default="{ row }">
<span>{{ row.name }}</span>
</template>
</vxe-column>
<vxe-column field="name" title="库存商品" />
<vxe-column field="stock" title="库存" />
<vxe-column field="unit" title="单位" />
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
<template #edit="{ row }">
<el-input v-model="row.quantity" />
@@ -102,26 +108,18 @@
<el-row class="my-3">
<el-tooltip effect="dark" content="返回列表页面" placement="top">
<el-button type="primary" plain @click="emit('close')">{{ disabled ? "返回" : "取消" }}</el-button>
<el-button type="primary" plain @click="emit('close')">返回</el-button>
</el-tooltip>
<el-tooltip v-if="!baseDataForm.id" effect="dark" content="保存并清空数据" placement="top">
<el-tooltip v-if="!baseForm.id" effect="dark" content="保存并清空数据" placement="top">
<el-button type="primary" plain @click="onContinueAdd">继续添加</el-button>
</el-tooltip>
<el-tooltip v-if="!disabled" effect="dark" content="保存并返回列表页面" placement="top">
<el-tooltip effect="dark" content="保存并返回列表页面" placement="top">
<el-button type="primary" plain @click="onSave">保存</el-button>
</el-tooltip>
<el-tooltip v-if="disabled" effect="dark" content="打印清单" placement="top">
<el-button type="success" plain @click="printEvent">打印</el-button>
<el-tooltip effect="dark" content="打印清单" placement="top">
<el-button type="success" plain @click="">打印</el-button>
</el-tooltip>
</el-row>
<!-- 商品选择对话框 -->
<select-dialog
ref="erpSpuSelectDialogRef"
v-model="state.erpSpuSelectDialogVisible"
:selectedSpuRows="state.editableTableData"
@getSelectedSpuRows="getSelectedSpuRows"
/>
</div>
</div>
</template>
@@ -133,56 +131,40 @@ import { getCanteenSequence } from "/@/api/canteen/common"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
import { formatDate } from "/@/utils/formatTime"
import { displayPrice, storePrice } from "/@/utils/formatMoney"
import { tablePrint } from "../../supermarketerp/supermarketUtils"
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
import { useMessage } from "/@/hooks/message"
const SelectDialog = defineAsyncComponent(() => import("/@/views/canteen/components/selectDialog.vue"))
const SelectDialog = defineAsyncComponent(() => import("./select-dialog.vue"))
const props = withDefaults(
defineProps<{
formId?: string | undefined
disabled?: boolean
}>(),
{
formId: undefined,
disabled: false,
},
)
const emit = defineEmits(["close"])
const loading = ref(false) // 采购计划加载
const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
const baseDataFormRef = ref() // 基本数据表单ref
const editableTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
// 基本信息表单数据
const baseDataForm = reactive<any>({
const loading = ref(false)
const baseFormRef = ref() // 基本表单ref
const selectDialogRef = ref() // 对话框选择ref
const itemTableFormRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
const baseForm = reactive<any>({
id: "",
inventoryCode: "",
inventoryDate: formatDate(new Date(), "YYYY-mm-dd"),
handlerUserId: "",
supplierId: "",
merchantId: "",
supplierId: "",
remark: "",
inventoryType: "3",
inventoryType: "1",
orderType: "1",
})
const state = reactive<{
editableTableData: any[]
erpSpuItemsMemo: any[]
selectedRowsErpMaterialIds: string[]
erpSpuSimpleAll: any
linkCodeVisible: boolean
erpSpuSelectDialogVisible: boolean
linkCgPlanDialogVisible: boolean
}>({
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpMaterialIds: [], // 可编辑表格已选行的erpMaterialId
erpSpuSimpleAll: [], // 简要商品列表
linkCodeVisible: false, // 关联采购申请单对话框开关
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
const state = reactive<any>({
selectDialogVisible: false, // 对话框选择开关
itemTableForm: [], // 可编辑表格数据
selectedRowIds: [], // 可编辑表格已选行的id
})
// 基本信息表单校验规则
@@ -202,25 +184,24 @@ const validRules = ref<VxeTablePropTypes.EditRules<any>>({
// 初始化数据
const getInitData = async () => {
baseDataForm.id = undefined
baseForm.id = undefined
const id = props.formId
if (id) {
loading.value = true
// 获取清单数据
const [cgPlanData] = await Promise.allSettled([getObj(id)])
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
.finally(() => (loading.value = false))
if (cgPlanData && cgPlanData.code === 0) {
Object.assign(baseDataForm, cgPlanData.data)
}
// loading.value = true
// // 获取清单数据
// const [cgPlanData] = await Promise.allSettled([getObj(id)])
// .then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
// .finally(() => (loading.value = false))
// if (cgPlanData && cgPlanData.code === 0) {
// Object.assign(baseForm, cgPlanData.data)
// }
} else {
loading.value = true
// 获取采购入库编号
const [planCode] = await Promise.allSettled([getCanteenSequence({ type: 1 })])
const [sequenceCode] = await Promise.allSettled([getCanteenSequence({ type: 1 })])
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
.finally(() => (loading.value = false))
planCode && planCode.code === 0 && (baseDataForm.inventoryCode = planCode.data)
sequenceCode && sequenceCode.code === 0 && (baseForm.inventoryCode = sequenceCode.data)
}
// loading.value = true
@@ -231,143 +212,136 @@ const getInitData = async () => {
// erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
}
// 点击关联采购申请编号
// const handleClickLinkCode = () => linkCgPlanDialogRef.value.openLinkCodeDialog(2)
// 点击商品选择
const clickSelectDialog = () => selectDialogRef.value.openDialog()
// 获取选择的采购申请
// const getSelectedLinkCode = (selectionRows: any) => {
// console.log("被选择的关联数据", selectionRows)
// 获取被选择的商品行
const getSelectedRows = (selectionRows: any) => {
console.log("被选择的商品行", selectionRows)
// baseDataForm.linkCode = selectionRows.code
// state.editableTableData = selectionRows.items.map((item: any) => ({
// ...item,
// unitObj: {},
// realPrice: displayPrice(item.purchasePrice, ""),
// }))
// state.erpSpuItemsMemo = selectionRows.items.map((item: any) => ({
// ...item,
// unitObj: {},
// realPrice: displayPrice(item.purchasePrice, ""),
// }))
// state.linkCgPlanDialogVisible = false
// }
// 筛选新勾选的项并处理
const addedItems = selectionRows
.filter((selectionRowsItem: any) => !state.itemTableForm.some((item: any) => item.erpMaterialId === selectionRowsItem.erpMaterialId))
.map((addItem: any) => ({ ...addItem, price: displayPrice(addItem.price, ""), isNew: true }))
state.itemTableForm = [...state.itemTableForm, ...addedItems]
state.selectDialogVisible = false
console.log("state.itemTableForm", state.itemTableForm)
}
// 可编辑表格行勾选
const selectChangeEvent: VxeTableEvents.CheckboxChange<any> = ({ checked }) => {
const $table = itemTableFormRef.value
if ($table) {
const records = $table.getCheckboxRecords()
state.selectedRowIds = records.map((item) => item.erpMaterialId)
}
}
// 删除选中的行
const removeSelectRowEvent = () => {
const $table = editableTableRef.value
const removeSelectedRows = () => {
const $table = itemTableFormRef.value
if ($table) {
const selectRecords = $table.getCheckboxRecords()
if (selectRecords.length > 0) {
state.editableTableData = state.editableTableData.filter(
(item) => !selectRecords.some((row) => row.erpMaterialId === item.erpMaterialId),
state.itemTableForm = state.itemTableForm.filter(
(item: any) => !selectRecords.some((row) => row.erpMaterialId === item.erpMaterialId),
)
}
}
}
// 可编辑表格行勾选
const selectChangeEvent: VxeTableEvents.CheckboxChange<any> = ({ checked }) => {
const $table = editableTableRef.value
if ($table) {
const records = $table.getCheckboxRecords()
console.log(checked ? "勾选事件" : "取消事件", records)
state.selectedRowsErpMaterialIds = records.map((item) => item.erpMaterialId)
}
}
// 点击商品选择
const handleClickSpuSelect = () => erpSpuSelectDialogRef.value.openDialog()
// 获取被选择的商品行
const getSelectedSpuRows = (selectionRows: any) => {
console.log("被选择的商品行", selectionRows)
// 筛选新勾选的项
const addedItems = selectionRows
.filter(
(item: any) => !state.editableTableData.some((editableTableItem: any) => editableTableItem.erpMaterialId === item.erpMaterialId),
)
.map((addItem: any) => {
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpMaterialId === addItem.erpMaterialId)
if (index !== -1) return state.erpSpuItemsMemo[index]
return { ...addItem, price: displayPrice(addItem.price, ""), isNew: true }
})
// 仅添加新勾选的项
state.editableTableData = [...state.editableTableData, ...addedItems]
// 筛选取消勾选的项
const removedItems = state.editableTableData.filter(
(item: any) => !selectionRows.some((selectedItem: any) => selectedItem.erpMaterialId === item.erpMaterialId),
)
// 仅移除取消勾选的项
state.editableTableData = state.editableTableData.filter(
(item: any) => !removedItems.some((removeItem: any) => removeItem.erpMaterialId === item.erpMaterialId),
)
// state.editableTableData.push(item)
// nextTick(() => {
// const $table = editableTableRef.value
// if ($table) {
// $table.setRow(item)
// }
// })
state.erpSpuSelectDialogVisible = false
console.log("state.editableTableData", state.editableTableData)
}
// 整理数据
const cgPlanSpuItems = computed(() => {
return state.editableTableData.map((item: any) => {
return {
id: item.isNew ? undefined : item.id,
erpMaterialId: item.erpMaterialId,
quantity: item.quantity,
unitPrice: item.price,
realPrice: item.realPrice ? storePrice(item.realPrice) : 0,
totalAmount: item?.realPrice && item.quantity ? storePrice(Number(item.realPrice) * Number(item.quantity)) : 0,
stock: item.stock,
remark: item.remark,
}
})
const tableFormItems = state.itemTableForm.map((item: any) => {
return {
// id: item.isNew ? undefined : item.id,
erpMaterialId: item.erpMaterialId,
quantity: item.quantity,
unitPrice: item.price,
realPrice: item.realPrice ? storePrice(item.realPrice) : 0,
totalAmount: (Number(item.quantity || 0) * Number(item.realPrice || 0)).toFixed(2),
stock: item.stock,
remark: item.remark,
}
})
const { formValidate, submitData } = useSmProcessFormAction()
// 点击继续添加
const onContinueAdd = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData()
;(await baseFormValidate()) && (await itemTableFormValidate()) && (await submitData()) && clearData()
}
// 点击保存
const onSave = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData() &&
emit("close")
;(await baseFormValidate()) && (await itemTableFormValidate()) && (await submitData()) && clearData() && emit("close")
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
const baseFormValidate = async () => {
const valid = await baseFormRef.value.validate().catch(() => {})
return valid
}
// 校验可编辑表格 成功返回 true 失败返回 false
const itemTableFormValidate = async () => {
if (state.itemTableForm.length <= 0) {
useMessage().warning("请选择商品")
return false
}
// 全量校验
const $table = itemTableFormRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
} else {
console.log("全量校验成功!")
return true
}
}
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async () => {
try {
loading.value = true
const _pa = {
...baseForm,
items: tableFormItems(),
}
console.log("提交的数据:", _pa)
const res = baseForm.id ? await putObj(_pa) : await addObj(_pa)
if (res.code == 0) {
useMessage().success(baseForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
return false
} finally {
loading.value = false
}
}
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
for (const key in baseForm) {
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
baseDataForm[key] = ""
baseForm[key] = ""
}
state.editableTableData = []
state.erpSpuItemsMemo = []
state.selectedRowsErpMaterialIds = []
state.itemTableForm = []
state.selectedRowIds = []
return true
}
// 点击打印
const printEvent = () => {
// tablePrint(editableTableRef.value, baseDataInfoRef.value, state.editableTableData, 23, "采购入库")
}
onMounted(() => {
getInitData()
})
@@ -44,20 +44,18 @@
<script setup lang="ts">
import { ref } from "vue"
import { fetchErpMaterialPageList } from "/@/api/canteen/canteenErpMaterial"
import { useDict } from "/@/hooks/dict"
const dialogVisible = defineModel()
const emit = defineEmits(["getSelectedSpuRows"])
const emit = defineEmits(["getSelectedRows"])
const props = withDefaults(
defineProps<{
selectedSpuRows: any[]
selectedRows: any[]
}>(),
{
selectedSpuRows: () => [],
selectedRows: () => [],
},
)
const { status } = useDict("status")
const queryRef = ref()
const spuMultipleTableRef = ref() // 对话框多选表格ref
const loading = ref(false) // 对话框多选表格loading
@@ -66,10 +64,9 @@ const queryForm = reactive<any>({
})
const total = ref<number>(0)
const spuDataList = ref<any[]>([]) // 对话框多选表格数据
const foodCategory = ref<any>([]) // 菜品分类
// 打开弹窗
const openDialog = async () => {
const openDialog = () => {
dialogVisible.value = true
getDataListAndSelect()
}
@@ -90,7 +87,7 @@ const getDataListAndSelect = async () => {
// 合并当前页面数据中的已选行和之前保存的已选行
const rowsToSelect = [
// ...currentSelectedRows,
...props.selectedSpuRows.filter((row) => spuDataList.value.some((item) => item.erpMaterialId === row.erpMaterialId)),
...props.selectedRows.filter((row) => spuDataList.value.some((item) => item.erpMaterialId === row.erpMaterialId)),
]
// 去重
const uniqueRowsToSelect = Array.from(new Map(rowsToSelect.map((row) => [row.erpMaterialId, row])).values())
@@ -138,12 +135,12 @@ const dialogConfirm = () => {
// 合并当前选中的行和之前已选的行(排除当前页面的行)
const allSelectedRows = [
...currentSelectedRows,
...props.selectedSpuRows.filter((row) => !spuDataList.value.some((item) => item.erpMaterialId === row.erpMaterialId)),
...props.selectedRows.filter((row) => !spuDataList.value.some((item) => item.erpMaterialId === row.erpMaterialId)),
]
// 去重
const uniqueSelectedRows = Array.from(new Map(allSelectedRows.map((row) => [row.erpMaterialId, row])).values())
emit("getSelectedSpuRows", uniqueSelectedRows)
emit("getSelectedRows", uniqueSelectedRows)
}
}
@@ -1,129 +0,0 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-row>
<div class="mb8" style="width: 100%">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
v-auth="'canteen_canteenInventoryRecordsItem_add'">
新 增
</el-button>
<el-button plain :disabled="multiple" icon="Delete" type="primary"
v-auth="'canteen_canteenInventoryRecordsItem_del'" @click="handleDelete(selectObjs)">
删除
</el-button>
<right-toolbar v-model:showSearch="showSearch" :export="'canteen_canteenInventoryRecordsItem_export'"
@exportExcel="exportExcel" class="ml10 mr20" style="float: right;"
@queryTable="getDataList"></right-toolbar>
</div>
</el-row>
<el-table :data="state.dataList" v-loading="state.loading" border
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle">
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="inventoryType" label="单据类型(字典inventory_type)" show-overflow-tooltip/>
<el-table-column prop="erpMaterialId" label="原料id" show-overflow-tooltip/>
<el-table-column prop="merchantId" label="商户编号" show-overflow-tooltip/>
<el-table-column prop="deptId" label="部门id" show-overflow-tooltip/>
<el-table-column prop="quantity" label="出入库数量" show-overflow-tooltip/>
<el-table-column prop="unitPrice" label="单价" show-overflow-tooltip/>
<el-table-column prop="totalAmount" label="总金额" show-overflow-tooltip/>
<el-table-column prop="taxRate" label="税率%" show-overflow-tooltip/>
<el-table-column prop="taxAmount" label="税前金额" show-overflow-tooltip/>
<el-table-column prop="supplierId" label="货商" show-overflow-tooltip/>
<el-table-column prop="remark" label="备注" show-overflow-tooltip/>
<el-table-column prop="orderType" label="订单类型(1入库 2出库)" show-overflow-tooltip/>
<el-table-column prop="inventoryId" label="出入库关联id" show-overflow-tooltip/>
<el-table-column prop="totalNumber" label="总数" show-overflow-tooltip/>
<el-table-column prop="accountNumber" label="账面数量" show-overflow-tooltip/>
<el-table-column prop="realNumber" label="实际数量" show-overflow-tooltip/>
<el-table-column prop="realPrice" label="实际单价" show-overflow-tooltip/>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenInventoryRecordsItem_edit'"
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenInventoryRecordsItem_del'" @click="handleDelete([scope.row.id])">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</div>
<!-- 编辑、新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
</div>
</template>
<script setup lang="ts" name="systemCanteenInventoryRecordsItem">
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList, delObjs } from "/@/api/canteen/canteenInventoryRecordsItem";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { useDict } from '/@/hooks/dict';
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
// 定义查询字典
// 定义变量内容
const formDialogRef = ref()
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: fetchList
})
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
sortChangeHandle,
downBlobFile,
tableStyle
} = useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile('/canteen/canteenInventoryRecordsItem/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenInventoryRecordsItem.xlsx')
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id);
multiple.value = !objs.length;
};
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm('此操作将永久删除');
} catch {
return;
}
try {
await delObjs(ids);
getDataList();
useMessage().success('删除成功');
} catch (err: any) {
useMessage().error(err.msg);
}
};
</script>