| | |
| | | <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'; |
| | |
| | | |
| | | 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 = '正常'; |
| | | 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, |
| | | '物料代码': 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); |
| | |
| | | return Object.keys(item).map((key) => item[key]); |
| | | }); |
| | | // 保证data顺序与header一致 |
| | | 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; |
| | | |
| | | }) |
| | |
| | | |
| | | |
| | | } |
| | | //跳转到实时库存 |
| | | //添加 |
| | | 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> |