123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <script setup lang="ts">
- import { reactive, ref } from "vue";
- import { useRouter } from "vue-router";
- import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
- import NotOrderImportModal from "./components/NotOrderImportModal/index.vue"
- import OrderImportModal from "./components/OrderImportModal/index.vue"
- import { notOrderTemplate } from "./components/NotOrderImportModal/columns-config"
- import { orderTemplate } from "./components/OrderImportModal/columns-config"
- import { useRenderIcon } from "/@/components/ReIcon/src/hooks"
- import contentConfig from "./config/content.config";
- import searchConfig from "./config/search.config";
- import { utils, writeFile } from "xlsx";
- import { useUserInfo } from "/@/hooks/core/useUser";
- import { httpDelete } from "/@/api/invoiceInOut/inOutManager";
- import { useTask } from "/@/hooks/core";
- import { ElMessage } from "element-plus";
- const PageName = "inOutManager";
- const router = useRouter();
- const state = reactive({ orderImportVisible: false, notOrderImportVisible: false })
- const hooks: PageHooks = { pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig) };
- const pageContentRef = ref(null)
- const deleteTask = useTask({
- success() {
- ElMessage.success('取消成功')
- pageContentRef?.value.onSearch()
- }
- })
- const { isSuperUser } = useUserInfo()
- const events: PageEvents = {
- content: {
- create: () => router.push('/invoiceInOut/outManagerDetail'),
- preview: ({ id }) => router.push("/invoiceInOut/outManagerDetail?id=" + id)
- }
- };
- function onDownload(type = 'notOrder'){
- const data = type === 'notOrder' ? notOrderTemplate : orderTemplate
- const title = type === 'notOrder' ? '非订单商品模板.xlsx' : '订单商品模板.xlsx'
- const workBook = utils.book_new();
- const workSheet = utils.json_to_sheet(data);
- utils.book_append_sheet(workBook, workSheet, "sheet");
- writeFile(workBook, title, { bookType: "xlsx" });
- }
- function handleRefresh(row) {
- deleteTask.run(httpDelete({ id: row.id }))
- }
- </script>
- <template>
- <PageAuth :pageName="PageName">
- <PageContainer :hooks="hooks" :events="events" :searchConfig="searchConfig" :contentConfig="contentConfig"
- :get-content-ref="ref => pageContentRef = ref">
- <template #content_header>
- <ElDropdown v-if="!isSuperUser">
- <ElButton size="small" type="primary" style="margin-right: 10px;margin-top:1px"
- :icon="useRenderIcon('arrow-up-line')">商品导入
- </ElButton>
- <template #dropdown>
- <ElDropdownMenu>
- <ElDropdownItem @click="state.orderImportVisible = true">订单商品</ElDropdownItem>
- <ElDropdownItem @click="state.notOrderImportVisible = true">非订单商品</ElDropdownItem>
- </ElDropdownMenu>
- </template>
- </ElDropdown>
- <ElDropdown>
- <ElButton size="small" style="margin-right: 10px;margin-top:1px" :icon="useRenderIcon('arrow-down-line')">
- 商品导入模板下载</ElButton>
- <template #dropdown>
- <ElDropdownMenu>
- <ElDropdownItem @click="onDownload('order')">订单商品</ElDropdownItem>
- <ElDropdownItem @click="onDownload('notOrder')">非订单商品</ElDropdownItem>
- </ElDropdownMenu>
- </template>
- </ElDropdown>
- </template>
- <template #content_action="row">
- <ElTooltip content="取消操作" placement="top" v-if="row.status == '1'">
- <ElButton :icon="useRenderIcon('refresh')" @click="handleRefresh(row)" type="danger" link />
- </ElTooltip>
- </template>
- </PageContainer>
- <OrderImportModal v-model:visible="state.orderImportVisible" @refresh="pageContentRef?.onSearch()" />
- <NotOrderImportModal v-model:visible="state.notOrderImportVisible" @refresh="pageContentRef?.onSearch()" />
- </PageAuth>
- </template>
|