zs
2025-05-12 7baa0d978e41f395891753b208d805bc02edee38
HIAWms/hiawms_web/src/widgets/WmsTask/Controllers/WmsTask.ts
@@ -9,6 +9,11 @@
  row: any 
  index: number 
interface WmsTaskItem {
  id: string
  taskNo: string
  // 其他字段...
}
export const useWmsTask = (props: any, ctx?: any) => { 
  const wmsTask = injectModel<WmsTask>('wmsTask') 
  const { exportFile } = useFile() 
@@ -19,7 +24,7 @@
  /** 
   * 动态列配置 
   */ 
  const wmsTaskColumns = ref<Record<string, any>>([])
  const wmsTaskColumns = ref<Record<string, any>>({})
  /** 
   * 搜索值 
   */ 
@@ -32,7 +37,7 @@
  /** 
   * 选择项 
   */ 
  const selection = ref([])
  const selection = ref<WmsTaskItem[]>([])
  /** 
   * 当前选中的行 
   */ 
@@ -56,7 +61,6 @@
    title: '', 
    isAdd: false, 
  }) 
 
  const dialogSettingConfig = reactive({ 
    visible: false, 
@@ -103,32 +107,53 @@
    //   divided: true, 
    //   icon: 'up', 
    // }, 
    // {
    //   label: '向下添加',
    //   fn: (c: CurrentType, pageNum: number) => {
    //     current.value = null
    //     sort.value = c.index + 2 + (pageNum - 1) * 50
    //     dialogConfig.visible = true
    //     dialogConfig.title = '添加'
    //     dialogConfig.isAdd = false
    //   },
    //   divided: true,
    //   icon: 'down',
    // },
    // {
    //   label: '创建副本',
    //   fn: async ({ row }: CurrentType) => {
    //     await wmsTask.cloneData([row.id])
    //     ElMessage.success('创建副本成功')
    //     tableRef.value?.getList()
    //   },
    //   divided: true,
    //   icon: 'copy',
    // },
    {
      label: '强制完成',
      fn: async (c: CurrentType) => {
        // 获取要操作的任务(多选或当前行)
        const tasks = selection.value.length > 0 ? selection.value : [c.row]
        const data = {
          taskNo: tasks[0].taskNo,
        }
        ConfirmBox(`是否强制完成 ${tasks.map((t) => t.taskNo).join(',')}`)
          .then(async () => {
            await wmsTask.finishTask(data) // 传递单个对象或数组
            ElMessage.success('强制完成成功')
            tableRef.value.getList()
          })
          .catch(() => {})
      },
      divided: true,
      icon: 'down',
    },
    {
      label: '取消',
      fn: async (c: CurrentType) => {
        // 获取要操作的任务(多选或当前行)
        const tasks = selection.value.length > 0 ? selection.value : [c.row]
        const data = {
          taskNo: tasks[0].taskNo,
        }
        ConfirmBox(`是否取消 ${tasks.map((t) => t.taskNo).join(',')}`)
          .then(async () => {
            await wmsTask.cancelTask(data) // 传递单个对象或数组
            ElMessage.success('取消成功')
            tableRef.value.getList()
          })
          .catch(() => {})
      },
      divided: true,
      icon: 'copy',
    },
    { 
      label: '删除', 
      fn: async (c: CurrentType) => { 
        const names = selection.value.map((item: { taskNo: string }) => item.taskNo)
        const names = selection.value.map(
          (item: { taskNo: string }) => item.taskNo
        )
        ConfirmBox( 
          `是否删除${names.length ? names.join(',') : c.row.taskNo}` 
        ).then(async () => { 
@@ -270,6 +295,6 @@
    onConfirmWmsTask, 
    onCheck, 
    onAddWmsTask, 
    onAdvancedQuery
    onAdvancedQuery,
  }