From 9eaf758e97367dbc2eca2bdbdc92ab39e08be9d0 Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周四, 15 5月 2025 13:12:17 +0800
Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/HIA24016N_PipeLineDemo

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

diff --git a/HIAWms/hiawms_web/src/widgets/HIAWms/Controllers/WmsMaterialType.ts b/HIAWms/hiawms_web/src/widgets/HIAWms/Controllers/WmsMaterialType.ts
new file mode 100644
index 0000000..ede6c3f
--- /dev/null
+++ b/HIAWms/hiawms_web/src/widgets/HIAWms/Controllers/WmsMaterialType.ts
@@ -0,0 +1,275 @@
+import { ref, onMounted, reactive, Ref, nextTick, computed } from 'vue' 
+import { injectModel } from '@/libs/Provider/Provider' 
+import { WmsMaterialType } from '../Models/WmsMaterialType' 
+import { ElMessage } from 'element-plus' 
+import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox' 
+import { useFile } from './File' 
+ 
+interface CurrentType { 
+  row: any 
+  index: number 
+} 
+export const useWmsMaterialType = (props: any, ctx?: any) => { 
+  const wmsMaterialType = injectModel<WmsMaterialType>('wmsMaterialType') 
+  const { exportFile } = useFile() 
+  /** 
+   * 澶撮儴閰嶇疆 
+   */ 
+  const headers = ref({}) 
+  /** 
+   * 鍔ㄦ�佸垪閰嶇疆 
+   */ 
+  const wmsMaterialTypeColumns = 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 wmsMaterialType.cloneData([row.id]) 
+    //     ElMessage.success('鍒涘缓鍓湰鎴愬姛') 
+    //     tableRef.value?.getList() 
+    //   }, 
+    //   divided: true, 
+    //   icon: 'copy', 
+    // }, 
+    { 
+      label: '鍒犻櫎', 
+      fn: async (c: CurrentType) => { 
+        const names = selection.value.map((item: { materialTypeCode: string }) => item.materialTypeCode) 
+        ConfirmBox( 
+          `鏄惁鍒犻櫎${names.length ? names.join(',') : c.row.materialTypeCode}` 
+        ).then(async () => { 
+          const ids = selection.value.map((item: { id: string }) => item.id) 
+          await wmsMaterialType.deleteWmsMaterialTypes(ids.length ? ids : [c.row.id]) 
+          ElMessage.success('鍒犻櫎鎴愬姛') 
+          tableRef.value.getList() 
+        }) 
+      }, 
+      icon: 'close', 
+    }, 
+  ] 
+ 
+  const onCheck = (records: any) => { 
+    selection.value = records 
+  } 
+ 
+  const onAddWmsMaterialType = () => { 
+    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 onConfirmWmsMaterialType = 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/wmsMaterialType/export', data, '鐗╂枡绫诲瀷') 
+  } 
+ 
+  /** 
+   * 鍏抽敭瀛楁悳绱� 
+   */ 
+  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, 
+    wmsMaterialTypeColumns, 
+    paginationParams, 
+    headers, 
+    onBeforeUpload, 
+    onError, 
+    onSuccess, 
+    openDetail, 
+    onSearch, 
+    onExport, 
+    onRowClick, 
+    onConfirmWmsMaterialType, 
+    onCheck, 
+    onAddWmsMaterialType, 
+    onAdvancedQuery 
+  } 
+} 

--
Gitblit v1.9.3