From 323e576c64129723df20fd18effb20d96d8d18b3 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 22 七月 2024 10:27:50 +0800 Subject: [PATCH] 工单更新 --- src/views/tigerprojects/mes/smt/tool/smt_mt_project/index.vue | 343 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 172 insertions(+), 171 deletions(-) diff --git a/src/views/tigerprojects/mes/smt/tool/smt_mt_project/index.vue b/src/views/tigerprojects/mes/smt/tool/smt_mt_project/index.vue index ae2ebd4..955a1ff 100644 --- a/src/views/tigerprojects/mes/smt/tool/smt_mt_project/index.vue +++ b/src/views/tigerprojects/mes/smt/tool/smt_mt_project/index.vue @@ -2,26 +2,31 @@ <div> <BasicTable @register="registerTable"> <template #toolbar> - <a-button color="primary" @click="handleAdd"> 娣诲姞 </a-button> - <a-button ghost color="primary" @click="aoaToExcel"> 瀵煎嚭 </a-button> + <a-button color="primary" @click="handleAdd" preIcon="add_02|svg"> 鏂板 </a-button> + <a-button ghost color="success" @click="aoaToExcel" preIcon="excel-export|svg"> + 瀵煎嚭 + </a-button> </template> <template #action="{ record }"> - <TableAction :actions="[ - { - icon: 'clarity:note-edit-line', - tooltip: '淇敼', - onClick: handleEdit.bind(null, record), - }, - { - icon: 'ant-design:delete-outlined', - tooltip: '鍒犻櫎', - popConfirm: { - title: '鏄惁纭鍒犻櫎?', - placement: 'left', - confirm: handleDelete.bind(null, record), - }, - }, - ]" /> + <TableAction + :actions="[ + { + icon: 'clarity:note-edit-line', + tooltip: '淇敼', + onClick: handleEdit.bind(null, record), + }, + { + icon: 'ant-design:delete-outlined', + tooltip: '鍒犻櫎', + color: 'error', + popConfirm: { + title: '鏄惁纭鍒犻櫎?', + placement: 'left', + confirm: handleDelete.bind(null, record), + }, + }, + ]" + /> </template> </BasicTable> <Loading :loading="compState.loading" :tip="compState.tip" /> @@ -30,161 +35,157 @@ </div> </template> <script lang="ts" setup> -import { reactive, unref } from 'vue'; -import { aoaToSheetXlsx } from '/@/components/Excel'; -import { BasicTable, useTable, TableAction } from '/@/components/Table'; -import ProjectDrawer from './ProjectDrawer.vue'; -import { useDrawer } from '/@/components/Drawer'; -import { columns, searchFormSchema } from './smt_mt_project.data'; -import { getListByPage, Save, Delete } from '/@/api/tigerapi/mes/smt/smtmtproject'; -import { useGo } from '/@/hooks/web/usePage'; -import { Loading } from '/@/components/Loading'; -import { useMessage } from '/@/hooks/web/useMessage'; -import { useI18n } from '/@/hooks/web/useI18n'; + import { reactive, unref } from 'vue'; + import { aoaToSheetXlsx } from '/@/components/Excel'; + import { BasicTable, useTable, TableAction } from '/@/components/Table'; + import ProjectDrawer from './ProjectDrawer.vue'; + import { useDrawer } from '/@/components/Drawer'; + import { columns, searchFormSchema } from './smt_mt_project.data'; + import { getListByPage, Save, Delete } from '/@/api/tigerapi/mes/smt/smtmtproject'; + import { useGo } from '/@/hooks/web/usePage'; + import { Loading } from '/@/components/Loading'; + import { useMessage } from '/@/hooks/web/useMessage'; + import { useI18n } from '/@/hooks/web/useI18n'; -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, reload }] = useTable({ - title: '宸ュ叿淇濆吇椤圭洰', - api: getListByPage, - columns, - formConfig: { - labelWidth: 120, - schemas: searchFormSchema, - }, - actionColumn: { - width: 120, - title: '鎿嶄綔', - dataIndex: 'action', - slots: { customRender: 'action' }, - fixed: 'right', //undefined, - }, - 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() - getListByPage(col).then((res) => { - res.items.forEach(element => { - var TYPE = '' - switch (element.TOOL_TYPE) { - case 0: - TYPE = '閽㈢綉'; - break; - case 1: - TYPE = '鍒垁'; - break; - default: - break; + 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, reload }] = useTable({ + title: '宸ュ叿淇濆吇椤圭洰', + api: getListByPage, + columns, + formConfig: { + labelWidth: 120, + schemas: searchFormSchema, + }, + actionColumn: { + width: 120, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', //undefined, + }, + ellipsis: true, + useSearchForm: true, + showTableSetting: true, + bordered: true, + showIndexColumn: false, + }); + let arr: any[] = []; + //瀵煎嚭 + function aoaToExcel() { + const totals = getPaginationRef().total; + if (totals < 30000) { + arr = []; + compState.loading = true; + const col = getForm().getFieldsValue(); + getListByPage(col).then((res) => { + res.items.forEach((element) => { + var TYPE = ''; + switch (element.TOOL_TYPE) { + case 0: + TYPE = '閽㈢綉'; + break; + case 1: + TYPE = '鍒垁'; + break; + default: + break; + } + arr.push({ + 淇濆吇椤圭洰缂栫爜: element.PROJ_CODE, + 淇濆吇椤圭洰鍚嶇О: element.PROJ_NAME, + 绫诲瀷: TYPE, + 淇濆吇椤�1: element.ITEM01, + 淇濆吇椤�2: element.ITEM02, + 淇濆吇椤�3: element.ITEM03, + 淇濆吇椤�4: element.ITEM04, + 淇濆吇椤�5: element.ITEM05, + 淇濆吇椤�6: element.ITEM06, + 淇濆吇椤�7: element.ITEM07, + 淇濆吇椤�8: element.ITEM08, + 淇濆吇椤�9: element.ITEM09, + 淇濆吇椤�10: element.ITEM10, + 淇濆吇椤�11: element.ITEM11, + 淇濆吇椤�12: element.ITEM12, + 淇濆吇椤�13: element.ITEM13, + 淇濆吇椤�14: element.ITEM14, + 淇濆吇椤�15: element.ITEM15, + 淇濆吇椤�16: element.ITEM16, + 淇濆吇椤�17: element.ITEM17, + 淇濆吇椤�18: element.ITEM18, + 淇濆吇椤�19: element.ITEM19, + 淇濆吇椤�20: element.ITEM20, + 澶囨敞: element.REMARK, + 鍒涘缓浜�: element.CREATE_USER, + 鍒涘缓鏃堕棿: element.CREATE_TIME, + }); + }); + const arrHeader = columns.map((column) => column.title); + const arrData = arr.map((item) => { + return Object.keys(item).map((key) => item[key]); + }); + // 淇濊瘉data椤哄簭涓巋eader涓�鑷� + if (arr.length < 30000) { + aoaToSheetXlsx({ + data: arrData, + header: arrHeader, + filename: '宸ュ叿淇濆吇椤圭洰.xlsx', + }); + } else { + createMessage.error(t('瀵煎嚭鏁版嵁涓嶈兘瓒呰繃涓変竾鏉★紝濡傞渶瑕佹洿澶氱殑璇疯仈绯荤鐞嗗憳')); } - arr.push({ - '淇濆吇椤圭洰缂栫爜': element.PROJ_CODE, - '淇濆吇椤圭洰鍚嶇О': element.PROJ_NAME, - '绫诲瀷': TYPE, - '淇濆吇椤�1': element.ITEM01, - '淇濆吇椤�2': element.ITEM02, - '淇濆吇椤�3': element.ITEM03, - '淇濆吇椤�4': element.ITEM04, - '淇濆吇椤�5': element.ITEM05, - '淇濆吇椤�6': element.ITEM06, - '淇濆吇椤�7': element.ITEM07, - '淇濆吇椤�8': element.ITEM08, - '淇濆吇椤�9': element.ITEM09, - '淇濆吇椤�10': element.ITEM10, - '淇濆吇椤�11': element.ITEM11, - '淇濆吇椤�12': element.ITEM12, - '淇濆吇椤�13': element.ITEM13, - '淇濆吇椤�14': element.ITEM14, - '淇濆吇椤�15': element.ITEM15, - '淇濆吇椤�16': element.ITEM16, - '淇濆吇椤�17': element.ITEM17, - '淇濆吇椤�18': element.ITEM18, - '淇濆吇椤�19': element.ITEM19, - '淇濆吇椤�20': element.ITEM20, - '澶囨敞': element.REMARK, - '鍒涘缓浜�': element.CREATE_USER, - '鍒涘缓鏃堕棿': element.CREATE_TIME, - }); + + compState.loading = false; }); - const arrHeader = columns.map((column) => column.title); - const arrData = arr.map((item) => { - return Object.keys(item).map((key) => item[key]); - }); - // 淇濊瘉data椤哄簭涓巋eader涓�鑷� - if (arr.length < 30000) { - aoaToSheetXlsx({ - data: arrData, - header: arrHeader, - filename: '宸ュ叿淇濆吇椤圭洰.xlsx', - }); - } else { - createMessage.error(t('瀵煎嚭鏁版嵁涓嶈兘瓒呰繃涓変竾鏉★紝濡傞渶瑕佹洿澶氱殑璇疯仈绯荤鐞嗗憳')); - } - - compState.loading = false; - - }) - - } else { - createMessage.error(t('瀵煎嚭鏁版嵁涓嶈兘瓒呰繃涓変竾鏉★紝濡傞渶瑕佹洿澶氱殑璇疯仈绯荤鐞嗗憳')); + } else { + createMessage.error(t('瀵煎嚭鏁版嵁涓嶈兘瓒呰繃涓変竾鏉★紝濡傞渶瑕佹洿澶氱殑璇疯仈绯荤鐞嗗憳')); + } } - - -} -//娣诲姞 -function handleAdd() { - openDrawer(true, { - isUpdate: false, - }); -} -//缂栬緫 -function handleEdit(record: any) { - openDrawer(true, { - isUpdate: true, - record - }); -} -function handleSuccess() { - reload(); -} -//鎶ュ簾 -function handleBao(record: any) { - const apiAction = Save(record, unref(true), true); - apiAction.then((action) => { - if (action.IsSuccessed) { - createMessage.success(t('宸叉姤搴�')); - reload(); - } else { - createMessage.success(t('鎶ュ簾鎿嶄綔澶辫触')); - } - }); -} -//鍒犻櫎 -function handleDelete(record: any) { - const apiAction = Delete(record.ID); - apiAction.then((action) => { - if (action.IsSuccessed) { - createMessage.success(t('宸插垹闄�')); - reload(); - } else { - createMessage.success(t('鍒犻櫎鎿嶄綔澶辫触')); - } - }); -} + //娣诲姞 + function handleAdd() { + openDrawer(true, { + isUpdate: false, + }); + } + //缂栬緫 + function handleEdit(record: any) { + openDrawer(true, { + isUpdate: true, + record, + }); + } + function handleSuccess() { + reload(); + } + //鎶ュ簾 + function handleBao(record: any) { + const apiAction = Save(record, unref(true), true); + apiAction.then((action) => { + if (action.IsSuccessed) { + createMessage.success(t('宸叉姤搴�')); + reload(); + } else { + createMessage.success(t('鎶ュ簾鎿嶄綔澶辫触')); + } + }); + } + //鍒犻櫎 + function handleDelete(record: any) { + const apiAction = Delete(record.ID); + apiAction.then((action) => { + if (action.IsSuccessed) { + createMessage.success(t('宸插垹闄�')); + reload(); + } else { + createMessage.success(t('鍒犻櫎鎿嶄綔澶辫触')); + } + }); + } </script> -- Gitblit v1.9.3