Files
pj_admin_cloud/src/hooks/smProcessTableAction.ts
T
2025-04-07 20:48:13 +08:00

59 lines
1.7 KiB
TypeScript

import { Ref } from "vue"
import { useMessage } from "./message"
type tableRow = { id: string | undefined; checkStatus: number | string | undefined; processInstanceId: string | undefined | null }
type ICreate = () => void
type IEdit = (row: tableRow) => void
type IFormClose = () => void
type IDeal = (row: tableRow) => void
type ITaskSubmitEvent = () => void
// 采购流程(补货申请、采购订单、采购入库、采购退货、零售出库、零售退货) 表格操作列行为hook
export function useSmProcessTableAction(
processFormState: { formId: string | undefined; formDisabled: boolean; showForm: boolean },
processDrawerRef: Ref<any>,
fetchList: () => void,
): {
create: ICreate
edit: IEdit
formClose: IFormClose
deal: IDeal
taskSubmitEvent: ITaskSubmitEvent
} {
// 点击新增
const create: ICreate = () => {
processFormState.formDisabled = false
processFormState.showForm = true
}
// 点击编辑
const edit: IEdit = (row: tableRow) => {
row.id ? (processFormState.formId = row.id) : useMessage().warning("清单id不存在")
row.checkStatus == 2 ? (processFormState.formDisabled = true) : (processFormState.formDisabled = false)
processFormState.showForm = true
}
// 表单关闭
const formClose: IFormClose = () => {
processFormState.showForm = false
processFormState.formId = undefined
processFormState.formDisabled = true
fetchList()
}
// 点击开始处理
const deal = (row: tableRow) => {
if (!row.processInstanceId) return useMessage().warning("流程id不存在")
processDrawerRef.value.openProcessDrawer(row)
}
// 审批提交事件
const taskSubmitEvent = () => {
fetchList()
}
return {
create,
edit,
formClose,
deal,
taskSubmitEvent,
}
}