From 7baa0d978e41f395891753b208d805bc02edee38 Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周一, 12 5月 2025 08:43:59 +0800
Subject: [PATCH] 叫料

---
 HIAWms/hiawms_web/src/widgets/WmsTask/Controllers/WmsTask.ts |  575 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 300 insertions(+), 275 deletions(-)

diff --git a/HIAWms/hiawms_web/src/widgets/WmsTask/Controllers/WmsTask.ts b/HIAWms/hiawms_web/src/widgets/WmsTask/Controllers/WmsTask.ts
index 731d5d2..5233f95 100644
--- a/HIAWms/hiawms_web/src/widgets/WmsTask/Controllers/WmsTask.ts
+++ b/HIAWms/hiawms_web/src/widgets/WmsTask/Controllers/WmsTask.ts
@@ -1,275 +1,300 @@
-import { ref, onMounted, reactive, Ref, nextTick, computed } from 'vue' 
-import { injectModel } from '@/libs/Provider/Provider' 
-import { WmsTask } from '../Models/WmsTask' 
-import { ElMessage } from 'element-plus' 
-import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox' 
-import { useFile } from './File' 
- 
-interface CurrentType { 
-  row: any 
-  index: number 
-} 
-export const useWmsTask = (props: any, ctx?: any) => { 
-  const wmsTask = injectModel<WmsTask>('wmsTask') 
-  const { exportFile } = useFile() 
-  /** 
-   * 澶撮儴閰嶇疆 
-   */ 
-  const headers = ref({}) 
-  /** 
-   * 鍔ㄦ�佸垪閰嶇疆 
-   */ 
-  const wmsTaskColumns = ref<Record<string, any>>([]) 
-  /** 
-   * 鎼滅储鍊� 
-   */ 
-  const search = ref('') 
- 
-  /** 
-   * 鎺掑簭 
-   */ 
-  const sort = ref(0) 
-  /** 
-   * 閫夋嫨椤� 
-   */ 
-  const selection = ref([]) 
-  /** 
-   * 褰撳墠閫変腑鐨勮 
-   */ 
-  const current = ref<any>(null) 
-  /** 
-   * 鏁版嵁婧� 
-   */ 
-  const dataSource: Ref<any[]> = ref([]) 
- 
-  /** 
-   * 琛ㄦ牸 
-   */ 
-  const tableRef = ref() 
-  const dialogConfig = reactive({ 
-    visible: false, 
-    title: '', 
-    isAdd: false, 
-  }) 
-  const dialogConfigForQuery = reactive({ 
-    visible: false, 
-    title: '', 
-    isAdd: false, 
-  }) 
- 
- 
-  const dialogSettingConfig = reactive({ 
-    visible: false, 
-    title: '', 
-  }) 
- 
-  /** 
-   * 鍒嗛〉鏁版嵁 
-   */ 
-  const paginationParams = ref({}) 
- 
-  /** 
-   * 鎵撳紑璇︽儏 
-   * @param row 
-   */ 
-  const openDetail = (row: any) => { 
-    current.value = row 
-    dialogConfig.visible = true 
-    dialogConfig.title = row.name 
-    dialogConfig.isAdd = false 
-    sort.value = row.sort 
-  } 
- 
-  const contextMenu = [ 
-    { 
-      label: '灞曞紑璇︽儏', 
-      fn: (c: CurrentType) => { 
-        current.value = null 
-        sort.value = c.row.sort 
-        nextTick(() => openDetail(c.row)) 
-      }, 
-      divided: true, 
-      icon: 'o', 
-    }, 
-    // { 
-    //   label: '鍚戜笂娣诲姞', 
-    //   fn: (c: CurrentType, pageNum: number) => { 
-    //     current.value = null 
-    //     sort.value = c.index + 1 + (pageNum - 1) * 50 
-    //     dialogConfig.visible = true 
-    //     dialogConfig.title = '娣诲姞' 
-    //     dialogConfig.isAdd = false 
-    //   }, 
-    //   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 names = selection.value.map((item: { taskNo: string }) => item.taskNo) 
-        ConfirmBox( 
-          `鏄惁鍒犻櫎${names.length ? names.join(',') : c.row.taskNo}` 
-        ).then(async () => { 
-          const ids = selection.value.map((item: { id: string }) => item.id) 
-          await wmsTask.deleteWmsTasks(ids.length ? ids : [c.row.id]) 
-          ElMessage.success('鍒犻櫎鎴愬姛') 
-          tableRef.value.getList() 
-        }) 
-      }, 
-      icon: 'close', 
-    }, 
-  ] 
- 
-  const onCheck = (records: any) => { 
-    selection.value = records 
-  } 
- 
-  const onAddWmsTask = () => { 
-    const params = tableRef.value?.getPaginationParams() 
-    current.value = null 
-    dialogConfig.visible = true 
-    dialogConfig.isAdd = true 
-    dialogConfig.title = '娣诲姞' 
-    sort.value = params.totalCount + 1 
-  } 
- 
-  //鐐瑰嚮鎸夐挳銆愰珮绾ф煡璇€�� 
-  const onAdvancedQuery = () => { 
-    const params = tableRef.value?.getPaginationParams() 
-    current.value = null 
-    dialogConfigForQuery.visible = true 
-    dialogConfigForQuery.isAdd = true 
-    dialogConfigForQuery.title = '楂樼骇鏌ヨ' 
-  } 
-  
-  const onConfirmWmsTask = async () => { 
-    dialogConfig.visible = false 
-    if (dialogConfig.isAdd) { 
-      tableRef.value?.scrollToRow({ 
-        skip: true, 
-      }) 
-    } else { 
-      await tableRef.value?.getList() 
-    } 
-  } 
-  /** 
-   * 琛岀偣鍑绘椂鏇存柊current 
-   */ 
-  const onRowClick = ({ row }: any) => { 
-    if (dialogConfig.visible && current.value) { 
-      current.value = row 
-    } 
-  } 
-  /** 
-   * 瀵煎嚭 
-   */ 
-  const onExport = (data={}) => { 
-    //const params = tableRef.value?.getParams() 
-    exportFile('/api/v1/HIAWms/wmsTask/export', data, 'HIAWms') 
-  } 
- 
-  /** 
-   * 鍏抽敭瀛楁悳绱� 
-   */ 
-  const onSearch = () => { 
-    tableRef.value?.getList({ 
-      Filter: search.value, 
-    }) 
-  } 
- 
-  /** 
-   * 閲嶇疆琛ㄦ牸鏁版嵁 
-   */ 
-  const reloadList = () => { 
-    tableRef.value?.getList() 
-  } 
-  /** 
-   * 涓婁紶鎴愬姛 
-   */ 
-  const onSuccess = () => { 
-    tableRef.value?.getList() 
-    ElMessage.success('瀵煎叆鎴愬姛') 
-  } 
-  /** 
-   * 澶辫触 
-   * @param err 
-   */ 
-  const onError = (err: any) => { 
-    try { 
-      const message = JSON.parse(err.message) 
-      ElMessage.error(message.msg) 
-    } catch (error) { 
-      ElMessage.error('瀵煎叆澶辫触') 
-    } 
-  } 
-  /** 
-   * 涓婁紶閽╁瓙 
-   */ 
-  const onBeforeUpload = (file: File) => { 
-    const format = ['xlsx', 'xls', 'csv'] 
-    if (!format.includes(file.name.split('.')[1])) { 
-      ElMessage.error('瀵煎叆鏂囦欢鏍煎紡涓嶆纭紝璇峰鍏�.xlsx/.xls涓�.csv鏍煎紡鐨勬枃浠�') 
-      return false 
-    } 
-    return true 
-  } 
- 
-  onMounted(() => { 
-    headers.value = { 
-      Authorization: `Bearer ${sessionStorage.getItem('Token')}`, 
-      'X-Project': sessionStorage.getItem('X-Project'), 
-    } 
-  }) 
- 
-  ctx.expose({ 
-    reloadList, 
-  }) 
- 
-  return { 
-    dataSource, 
-    contextMenu, 
-    dialogConfig, 
-    dialogConfigForQuery, 
-    dialogSettingConfig, 
-    tableRef, 
-    current, 
-    search, 
-    sort, 
-    wmsTaskColumns, 
-    paginationParams, 
-    headers, 
-    onBeforeUpload, 
-    onError, 
-    onSuccess, 
-    openDetail, 
-    onSearch, 
-    onExport, 
-    onRowClick, 
-    onConfirmWmsTask, 
-    onCheck, 
-    onAddWmsTask, 
-    onAdvancedQuery 
-  } 
-} 
+import { ref, onMounted, reactive, Ref, nextTick, computed } from 'vue'
+import { injectModel } from '@/libs/Provider/Provider'
+import { WmsTask } from '../Models/WmsTask'
+import { ElMessage } from 'element-plus'
+import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox'
+import { useFile } from './File'
+
+interface CurrentType {
+  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()
+  /**
+   * 澶撮儴閰嶇疆
+   */
+  const headers = ref({})
+  /**
+   * 鍔ㄦ�佸垪閰嶇疆
+   */
+  const wmsTaskColumns = ref<Record<string, any>>({})
+  /**
+   * 鎼滅储鍊�
+   */
+  const search = ref('')
+
+  /**
+   * 鎺掑簭
+   */
+  const sort = ref(0)
+  /**
+   * 閫夋嫨椤�
+   */
+  const selection = ref<WmsTaskItem[]>([])
+  /**
+   * 褰撳墠閫変腑鐨勮
+   */
+  const current = ref<any>(null)
+  /**
+   * 鏁版嵁婧�
+   */
+  const dataSource: Ref<any[]> = ref([])
+
+  /**
+   * 琛ㄦ牸
+   */
+  const tableRef = ref()
+  const dialogConfig = reactive({
+    visible: false,
+    title: '',
+    isAdd: false,
+  })
+  const dialogConfigForQuery = reactive({
+    visible: false,
+    title: '',
+    isAdd: false,
+  })
+
+  const dialogSettingConfig = reactive({
+    visible: false,
+    title: '',
+  })
+
+  /**
+   * 鍒嗛〉鏁版嵁
+   */
+  const paginationParams = ref({})
+
+  /**
+   * 鎵撳紑璇︽儏
+   * @param row
+   */
+  const openDetail = (row: any) => {
+    current.value = row
+    dialogConfig.visible = true
+    dialogConfig.title = row.name
+    dialogConfig.isAdd = false
+    sort.value = row.sort
+  }
+
+  const contextMenu = [
+    {
+      label: '灞曞紑璇︽儏',
+      fn: (c: CurrentType) => {
+        current.value = null
+        sort.value = c.row.sort
+        nextTick(() => openDetail(c.row))
+      },
+      divided: true,
+      icon: 'o',
+    },
+    // {
+    //   label: '鍚戜笂娣诲姞',
+    //   fn: (c: CurrentType, pageNum: number) => {
+    //     current.value = null
+    //     sort.value = c.index + 1 + (pageNum - 1) * 50
+    //     dialogConfig.visible = true
+    //     dialogConfig.title = '娣诲姞'
+    //     dialogConfig.isAdd = false
+    //   },
+    //   divided: true,
+    //   icon: 'up',
+    // },
+    {
+      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
+        )
+        ConfirmBox(
+          `鏄惁鍒犻櫎${names.length ? names.join(',') : c.row.taskNo}`
+        ).then(async () => {
+          const ids = selection.value.map((item: { id: string }) => item.id)
+          await wmsTask.deleteWmsTasks(ids.length ? ids : [c.row.id])
+          ElMessage.success('鍒犻櫎鎴愬姛')
+          tableRef.value.getList()
+        })
+      },
+      icon: 'close',
+    },
+  ]
+
+  const onCheck = (records: any) => {
+    selection.value = records
+  }
+
+  const onAddWmsTask = () => {
+    const params = tableRef.value?.getPaginationParams()
+    current.value = null
+    dialogConfig.visible = true
+    dialogConfig.isAdd = true
+    dialogConfig.title = '娣诲姞'
+    sort.value = params.totalCount + 1
+  }
+
+  //鐐瑰嚮鎸夐挳銆愰珮绾ф煡璇€��
+  const onAdvancedQuery = () => {
+    const params = tableRef.value?.getPaginationParams()
+    current.value = null
+    dialogConfigForQuery.visible = true
+    dialogConfigForQuery.isAdd = true
+    dialogConfigForQuery.title = '楂樼骇鏌ヨ'
+  }
+
+  const onConfirmWmsTask = async () => {
+    dialogConfig.visible = false
+    if (dialogConfig.isAdd) {
+      tableRef.value?.scrollToRow({
+        skip: true,
+      })
+    } else {
+      await tableRef.value?.getList()
+    }
+  }
+  /**
+   * 琛岀偣鍑绘椂鏇存柊current
+   */
+  const onRowClick = ({ row }: any) => {
+    if (dialogConfig.visible && current.value) {
+      current.value = row
+    }
+  }
+  /**
+   * 瀵煎嚭
+   */
+  const onExport = (data = {}) => {
+    //const params = tableRef.value?.getParams()
+    exportFile('/api/v1/HIAWms/wmsTask/export', data, 'HIAWms')
+  }
+
+  /**
+   * 鍏抽敭瀛楁悳绱�
+   */
+  const onSearch = () => {
+    tableRef.value?.getList({
+      Filter: search.value,
+    })
+  }
+
+  /**
+   * 閲嶇疆琛ㄦ牸鏁版嵁
+   */
+  const reloadList = () => {
+    tableRef.value?.getList()
+  }
+  /**
+   * 涓婁紶鎴愬姛
+   */
+  const onSuccess = () => {
+    tableRef.value?.getList()
+    ElMessage.success('瀵煎叆鎴愬姛')
+  }
+  /**
+   * 澶辫触
+   * @param err
+   */
+  const onError = (err: any) => {
+    try {
+      const message = JSON.parse(err.message)
+      ElMessage.error(message.msg)
+    } catch (error) {
+      ElMessage.error('瀵煎叆澶辫触')
+    }
+  }
+  /**
+   * 涓婁紶閽╁瓙
+   */
+  const onBeforeUpload = (file: File) => {
+    const format = ['xlsx', 'xls', 'csv']
+    if (!format.includes(file.name.split('.')[1])) {
+      ElMessage.error('瀵煎叆鏂囦欢鏍煎紡涓嶆纭紝璇峰鍏�.xlsx/.xls涓�.csv鏍煎紡鐨勬枃浠�')
+      return false
+    }
+    return true
+  }
+
+  onMounted(() => {
+    headers.value = {
+      Authorization: `Bearer ${sessionStorage.getItem('Token')}`,
+      'X-Project': sessionStorage.getItem('X-Project'),
+    }
+  })
+
+  ctx.expose({
+    reloadList,
+  })
+
+  return {
+    dataSource,
+    contextMenu,
+    dialogConfig,
+    dialogConfigForQuery,
+    dialogSettingConfig,
+    tableRef,
+    current,
+    search,
+    sort,
+    wmsTaskColumns,
+    paginationParams,
+    headers,
+    onBeforeUpload,
+    onError,
+    onSuccess,
+    openDetail,
+    onSearch,
+    onExport,
+    onRowClick,
+    onConfirmWmsTask,
+    onCheck,
+    onAddWmsTask,
+    onAdvancedQuery,
+  }
+}

--
Gitblit v1.9.3