From e2b989cd7ac2e5ddf2a2e459b54aa33ab3a14217 Mon Sep 17 00:00:00 2001
From: Cloud Zhang <941187371@qq.com>
Date: 星期一, 13 五月 2024 17:22:20 +0800
Subject: [PATCH] 工具信息and上料操作

---
 src/views/tigerprojects/mes/smt/tool/smt_tool/index.vue |  171 ++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 140 insertions(+), 31 deletions(-)

diff --git a/src/views/tigerprojects/mes/smt/tool/smt_tool/index.vue b/src/views/tigerprojects/mes/smt/tool/smt_tool/index.vue
index ed9fb3b..777ff0b 100644
--- a/src/views/tigerprojects/mes/smt/tool/smt_tool/index.vue
+++ b/src/views/tigerprojects/mes/smt/tool/smt_tool/index.vue
@@ -2,29 +2,46 @@
   <div>
     <BasicTable @register="registerTable">
       <template #toolbar>
-        <a-button preIcon="OutR|svg" ghost color="success" @click="aoaToExcel"> 瀵煎嚭 </a-button>
+        <a-button color="primary" @click="addTool"> 娣诲姞 </a-button>
+        <a-button ghost color="primary" @click="aoaToExcel"> 瀵煎嚭 </a-button>
       </template>
       <template #action="{ record }">
         <TableAction :actions="[
-          {
-            icon: 'clarity:info-standard-line',
-            tooltip: '鏌ョ湅鍗曟嵁璇︽儏',
-            onClick: handleEdit.bind(null, record),
-          },
-        ]" />
+      {
+        icon: 'clarity:note-edit-line',
+        tooltip: '淇敼',
+        onClick: handleEdit.bind(null, record),
+      },
+      {
+        icon: 'clarity:info-standard-line',
+        tooltip: '鎶ュ簾',
+        onClick: handleBao.bind(null, record),
+      },
+      {
+        icon: 'ant-design:delete-outlined',
+        tooltip: '鍒犻櫎',
+        popConfirm: {
+          title: '鏄惁纭鍒犻櫎?',
+          placement: 'left',
+          confirm: handleDelete.bind(null, record),
+        },
+      },
+    ]" />
       </template>
     </BasicTable>
     <Loading :loading="compState.loading" :tip="compState.tip" />
     <!-- <WmsItemDrawer @register="registerDrawer" @success="handleSuccess" /> -->
+    <ToolDrawer @register="registerDrawer" @success="handleSuccess" />
   </div>
 </template>
 <script lang="ts" setup>
-import { reactive } from 'vue';
+import { reactive, unref } from 'vue';
 import { aoaToSheetXlsx } from '/@/components/Excel';
 import { BasicTable, useTable, TableAction } from '/@/components/Table';
-
-import { columns, searchFormSchema } from './wms_item_sum.data';
-import { getWmsItemSumByPage } from '/@/api/tigerapi/wms/wms_item';
+import ToolDrawer from './ToolDrawer.vue';
+import { useDrawer } from '/@/components/Drawer';
+import { columns, searchFormSchema } from './smt_tool.data';
+import { getToolListByPage, SaveTool, DeleteTool } from '/@/api/tigerapi/mes/smt/tool';
 import { useGo } from '/@/hooks/web/usePage';
 import { Loading } from '/@/components/Loading';
 import { useMessage } from '/@/hooks/web/useMessage';
@@ -32,48 +49,104 @@
 
 const { t } = useI18n();
 const { createMessage } = useMessage();
+const [registerDrawer, { openDrawer }] = useDrawer();
 const go = useGo();
 const compState = reactive({
   absolute: false,
   loading: false,
   tip: '鍔犺浇涓�...',
 });
-const [registerTable,{getForm,getPaginationRef}] = useTable({
-  title: '搴撳瓨姹囨��',
-  api: getWmsItemSumByPage,
+const [registerTable, { getForm, getPaginationRef, reload }] = useTable({
+  title: '宸ュ叿淇℃伅',
+  api: getToolListByPage,
   columns,
   formConfig: {
     labelWidth: 120,
     schemas: searchFormSchema,
   },
   actionColumn: {
-    width: 80,
+    width: 120,
     title: '鎿嶄綔',
     dataIndex: 'action',
     slots: { customRender: 'action' },
     fixed: 'right', //undefined,
   },
-  ellipsis:true,
+  ellipsis: true,
   useSearchForm: true,
   showTableSetting: false,
   bordered: true,
   showIndexColumn: false,
 });
 let arr: any[] = [];
+//瀵煎嚭
 function aoaToExcel() {
   const totals = getPaginationRef().total
   if (totals < 30000) {
     arr = [];
     compState.loading = true;
     const col = getForm().getFieldsValue()
-    getWmsItemSumByPage(col).then((res) => {
+    getToolListByPage(col).then((res) => {
       res.items.forEach(element => {
+        var TYPE = ''
+        var ALARM_TYPE = ''
+        var STATUS = ''
+        switch (element.TYPE) {
+          case 0:
+            TYPE = '閽㈢綉';
+            break;
+          case 1:
+            TYPE = '鍒垁';
+            break;
+          default:
+            break;
+        }
+        switch (element.ALARM_TYPE) {
+          case '0':
+            ALARM_TYPE = '姝e父';
+            break;
+          case '1':
+            ALARM_TYPE = '淇濆吇棰勮';
+            break;
+          case '2':
+            ALARM_TYPE = '鎶ュ簾棰勮';
+            break;
+          default:
+            break;
+        }
+        switch (element.STATUS) {
+          case 0:
+            STATUS = '宸插叆搴�';
+            break;
+          case 1:
+            STATUS = '宸查鐢�';
+            break;
+          case 2:
+            STATUS = '宸蹭笂绾�';
+            break;
+          case 3:
+            STATUS = '宸蹭笅绾�';
+            break;
+          case 4:
+            STATUS = '淇濆吇涓�';
+            break;
+          case 5:
+            STATUS = '宸叉姤搴�';
+            break;
+          default:
+            break;
+        }
         arr.push({
-          '浠撳簱': element.WH_CODE,
-          '鐗╂枡浠g爜': element.ITEM_CODE,
-          '鐗╂枡鍚嶇О': element.ITEM_NAME,
-          '鏁伴噺': element.ZK_QTY,
-          '鍗曚綅': element.UNIT
+          '鏉$爜': element.TOOL_CODE,
+          '鍨嬪彿': element.TOOL_MODEL,
+          '鎻忚堪': element.TOOL_SPEC,
+          '绫诲瀷': TYPE,
+          '棰勮鍒楄〃': ALARM_TYPE,
+          '鍒堕�犲晢': element.MANUFACTURER,
+          '褰撳墠浣跨敤娆℃暟': element.USE_COUNT,
+          '绱娆℃暟': element.TOTAL,
+          '鐘舵��': STATUS,
+          '鍒涘缓浜�': element.CREATE_USER,
+          '鍒涘缓鏃堕棿': element.CREATE_TIME,
         });
       });
       const arrHeader = columns.map((column) => column.title);
@@ -81,16 +154,16 @@
         return Object.keys(item).map((key) => item[key]);
       });
       // 淇濊瘉data椤哄簭涓巋eader涓�鑷�
-      if(arr.length<30000){
+      if (arr.length < 30000) {
         aoaToSheetXlsx({
-        data: arrData,
-        header: arrHeader,
-        filename: '姹囨�绘姤琛�.xlsx',
-      });
-      }else{
+          data: arrData,
+          header: arrHeader,
+          filename: '宸ュ叿淇℃伅.xlsx',
+        });
+      } else {
         createMessage.error(t('瀵煎嚭鏁版嵁涓嶈兘瓒呰繃涓変竾鏉★紝濡傞渶瑕佹洿澶氱殑璇疯仈绯荤鐞嗗憳'));
       }
-      
+
       compState.loading = false;
 
     })
@@ -101,8 +174,44 @@
 
 
 }
-//璺宠浆鍒板疄鏃跺簱瀛�
+//娣诲姞
+function addTool() {
+  openDrawer(true, {
+    isUpdate: false,
+  });
+}
+//缂栬緫
 function handleEdit(record: any) {
-  go('/WmsItem/' + record.ITEM_CODE);
+  openDrawer(true, {
+    isUpdate: true,
+    record
+  });
+}
+function handleSuccess() {
+  reload();
+}
+//鎶ュ簾
+function handleBao(record: any) {
+  const apiAction = SaveTool(record, unref(true), true);
+  apiAction.then((action) => {
+    if (action.IsSuccessed) {
+      createMessage.success(t('宸叉姤搴�'));
+      reload();
+    } else {
+      createMessage.success(t('鎶ュ簾鎿嶄綔澶辫触'));
+    }
+  });
+}
+//鍒犻櫎
+function handleDelete(record: any) {
+  const apiAction = DeleteTool(record.ID);
+  apiAction.then((action) => {
+    if (action.IsSuccessed) {
+      createMessage.success(t('宸插垹闄�'));
+      reload();
+    } else {
+      createMessage.success(t('鍒犻櫎鎿嶄綔澶辫触'));
+    }
+  });
 }
 </script>

--
Gitblit v1.9.3