<template>
|
<div>
|
<BasicTable @register="registerTable">
|
<template #toolbar>
|
<a-button preIcon="OutR|svg" ghost color="success" @click="aoaToExcel"> 导出 </a-button>
|
</template>
|
<!-- <template #action="{ record }">
|
<TableAction
|
:actions="[
|
{
|
icon: 'clarity:note-edit-line',
|
onClick: handleEdit.bind(null, record),
|
},
|
{
|
icon: 'ant-design:delete-outlined',
|
color: 'error',
|
popConfirm: {
|
title: '是否确认删除?',
|
placement: 'left',
|
confirm: handleDelete.bind(null, record),
|
},
|
},
|
]"
|
/>
|
</template> -->
|
<Loading :loading="compState.loading" :tip="compState.tip" />
|
</BasicTable>
|
<!-- <WmsItemDrawer @register="registerDrawer" @success="handleSuccess" /> -->
|
</div>
|
</template>
|
<script lang="ts" setup>
|
import { aoaToSheetXlsx } from '/@/components/Excel';
|
import { reactive, ref } from 'vue';
|
import { Loading } from '/@/components/Loading';
|
import { BasicTable, useTable } from '/@/components/Table';
|
|
import { columns, searchFormSchema } from './inventorySearch.data';
|
import { getWmsItemListByPage } from '/@/api/tigerapi/wms/inventorySearch';
|
import { useRoute } from 'vue-router';
|
import { useTabs } from '/@/hooks/web/useTabs';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
const { t } = useI18n();
|
const { createMessage } = useMessage();
|
const compState = reactive({
|
absolute: false,
|
loading: false,
|
tip: '加载中...',
|
});
|
const route = useRoute();
|
const ItemCode = ref(route.params?.ItemCode);
|
const ITEM_CODE = ItemCode.value == '' ? '' : ItemCode;
|
const [registerTable, { reload, getForm, getPaginationRef }] = useTable({
|
title: '库位库存查询列表',
|
api: getWmsItemListByPage,
|
columns,
|
formConfig: {
|
labelWidth: 120,
|
schemas: searchFormSchema,
|
model: { ITEM_CODE: ITEM_CODE },
|
},
|
useSearchForm: true,
|
// showTableSetting: true,
|
canColDrag: false,
|
// ellipsis:true,
|
canResize: true,
|
|
bordered: true,
|
showIndexColumn: false,
|
// actionColumn: {
|
// width: 80,
|
// title: '操作',
|
// dataIndex: 'action',
|
// slots: { customRender: 'action' },
|
// fixed: undefined,
|
// },
|
searchInfo: { ITEM_CODE },
|
});
|
const { setTitle } = useTabs();
|
//setTitle('实时库存' + (ItemCode.value==''?'':',料号:('+ItemCode.value+')'));
|
|
console.log(ITEM_CODE);
|
function handleSuccess() {
|
reload();
|
}
|
function handleCreate() {
|
reload();
|
}
|
let arr: any[] = [];
|
function aoaToExcel() {
|
const totals = getPaginationRef().total;
|
if (totals < 30000) {
|
arr = [];
|
compState.loading = true;
|
const col = getForm().getFieldsValue();
|
getWmsItemListByPage(col).then((res) => {
|
res.items.forEach((element) => {
|
arr.push({
|
仓库: element.WH_CODE,
|
据点: element.AUTH_ORG,
|
储位: element.LOCATION_CODE,
|
物料代码: element.ITEM_CODE,
|
数量: element.QTY,
|
物料名称: element.ITEM_NAME,
|
});
|
});
|
const arrHeader = columns.map((column) => column.title);
|
const arrData = arr.map((item) => {
|
return Object.keys(item).map((key) => item[key]);
|
});
|
// 保证data顺序与header一致
|
if (arr.length < 30000000) {
|
aoaToSheetXlsx({
|
data: arrData,
|
header: arrHeader,
|
filename: '库位库存查询报表.xlsx',
|
});
|
} else {
|
createMessage.error(t('导出数据不能超过三万条,如需要更多的请联系管理员'));
|
}
|
compState.loading = false;
|
});
|
} else {
|
createMessage.error(t('导出数据不能超过三万条,如需要更多的请联系管理员'));
|
}
|
}
|
</script>
|