feat: develop export and domain
This commit is contained in:
parent
783f92bf18
commit
89d1aeedf0
|
@ -0,0 +1,26 @@
|
|||
import { request, type RequestOptions } from '@/utils/request';
|
||||
|
||||
/** 获取公司列表 GET /api/domain */
|
||||
export async function domainList(params: API.DomainParams, options?: RequestOptions) {
|
||||
return request<{
|
||||
items?: API.DomainEntity[];
|
||||
meta?: {
|
||||
itemCount?: number;
|
||||
totalItems?: number;
|
||||
itemsPerPage?: number;
|
||||
totalPages?: number;
|
||||
currentPage?: number;
|
||||
};
|
||||
}>('/api/domain', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
// page has a default value: 1
|
||||
page: '1',
|
||||
// pageSize has a default value: 10
|
||||
pageSize: '10',
|
||||
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
|
@ -36,9 +36,10 @@ import * as saleQuotationGroup from './saleQuotationGroup';
|
|||
import * as saleQuotationComponent from './saleQuotationComponent';
|
||||
import * as saleQuotationTemplate from './saleQuotationTemplate';
|
||||
import * as saleQuotation from './saleQuotation';
|
||||
|
||||
import * as domain from './domain';
|
||||
export default {
|
||||
auth,
|
||||
domain,
|
||||
account,
|
||||
captcha,
|
||||
authEmail,
|
||||
|
@ -71,5 +72,5 @@ export default {
|
|||
saleQuotationGroup,
|
||||
saleQuotationComponent,
|
||||
saleQuotationTemplate,
|
||||
saleQuotation
|
||||
saleQuotation,
|
||||
};
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
import { request, type RequestOptions } from '@/utils/request';
|
||||
|
||||
/** 导出出入库记录 GET /api/materials-inventory/export*/
|
||||
export async function materialsInoutExport(
|
||||
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||
params: API.MaterialsInoutExportParams,
|
||||
options?: RequestOptions,
|
||||
) {
|
||||
const { ...queryParams } = params;
|
||||
return request(`/api/materials-in-out/export`, {
|
||||
method: 'GET',
|
||||
params: { ...queryParams },
|
||||
...(options || { responseType: 'blob', isReturnResult: false }),
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取原材料出入库记录列表 GET /api/materials-in-out */
|
||||
export async function materialsInOutList(
|
||||
params: API.MaterialsInOutListParams,
|
||||
|
@ -60,7 +74,7 @@ export async function materialsInOutInfo(
|
|||
/** 解除原材料出入库记录和附件关联 PUT /api/materials-in-out/unlink-attachments/${param0} */
|
||||
export async function unlinkAttachments(
|
||||
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||
params: API.MaterialsInOutUpdateParams,
|
||||
params: API.MaterialsInOutUpdateParams,
|
||||
body: API.MaterialsInOutUpdateDto,
|
||||
options?: RequestOptions,
|
||||
) {
|
||||
|
|
|
@ -21,6 +21,8 @@ declare namespace API {
|
|||
remark: string;
|
||||
/** 头像 */
|
||||
avatar: string;
|
||||
/** 所属域 */
|
||||
domain: DomainType;
|
||||
};
|
||||
|
||||
type AccountMenus = {
|
||||
|
@ -1213,12 +1215,13 @@ declare namespace API {
|
|||
status: number;
|
||||
roles: RoleEntity[];
|
||||
dept: DeptEntity;
|
||||
domain: DomainType;
|
||||
accessTokens: AccessTokenEntity[];
|
||||
id: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
type DomainType = number;
|
||||
type UserListParams = {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
|
@ -1379,8 +1382,9 @@ declare namespace API {
|
|||
};
|
||||
|
||||
type MaterialsInventoryExportParams = {
|
||||
time: string;
|
||||
projectId: number;
|
||||
time: string[];
|
||||
filename:string;
|
||||
projectId?: number;
|
||||
};
|
||||
|
||||
type MaterialsInventoryInfoParams = {
|
||||
|
@ -1808,6 +1812,11 @@ declare namespace API {
|
|||
};
|
||||
|
||||
// Materials In out history
|
||||
type MaterialsInoutExportParams = {
|
||||
time: string[];
|
||||
filename:string;
|
||||
};
|
||||
|
||||
type MaterialsInOutUpdateParams = {
|
||||
id: number;
|
||||
fileIds?: number[];
|
||||
|
@ -2015,4 +2024,18 @@ declare namespace API {
|
|||
type SaleQuotationTemplateDeleteParams = {
|
||||
id: number;
|
||||
};
|
||||
|
||||
type DomainEntity = {
|
||||
title: string;
|
||||
id: number;
|
||||
};
|
||||
|
||||
type DomainParams = {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
title?: string;
|
||||
field?: string;
|
||||
order?: 'ASC' | 'DESC';
|
||||
_t?: number;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -58,11 +58,11 @@ export const useExportExcelModal = () => {
|
|||
modalProps: {
|
||||
title: t('component.excel.exportModalTitle'),
|
||||
onFinish: async (values) => {
|
||||
const { filename, bookType } = values;
|
||||
|
||||
const { filename, bookType, time } = values;
|
||||
onOk({
|
||||
filename: `${filename.split('.').shift()}.${bookType}`,
|
||||
filename: bookType ? `${filename.split('.').shift()}.${bookType}` : filename,
|
||||
bookType,
|
||||
time,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
|
@ -12,7 +12,12 @@ export const USER_INFO_KEY = 'USER__INFO__';
|
|||
|
||||
// role info key
|
||||
export const ROLES_KEY = 'ROLES__KEY__';
|
||||
|
||||
/** 是否锁屏 */
|
||||
export const IS_LOCKSCREEN = 'IS_LOCKSCREEN';
|
||||
|
||||
/** 标签页 */
|
||||
export const TABS_ROUTES = 'TABS_ROUTES';
|
||||
|
||||
/** 域 */
|
||||
export const DOMAIN_KEY = 'DOMAIN__';
|
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<div>
|
||||
公司: <a-select ref="select"
|
||||
v-if="options.length"
|
||||
:disabled="!$auth('system:domain:change')"
|
||||
v-model:value="userStore.domain"
|
||||
style="min-width: 100px;"
|
||||
placeholder="请选择"
|
||||
@change="onChange"
|
||||
:dropdownStyle="{ 'textOverflow': 'ellipsis', 'min-width': 'fit-content' }">
|
||||
<a-select-option :value="item.value"
|
||||
v-for="(item, index) in options"
|
||||
:key="index">{{ item.label }}</a-select-option>
|
||||
</a-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import Api from '@/api';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import type { SelectValue } from 'ant-design-vue/es/select';
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'DomianPicker'
|
||||
})
|
||||
|
||||
const userStore = useUserStore();
|
||||
const options = ref<{ label: string, value: number }[]>([]);
|
||||
let domains = ref<API.DomainEntity[]>([]);
|
||||
const onChange = (value: SelectValue) => {
|
||||
userStore.changeDomain(value)
|
||||
};
|
||||
onMounted(() => {
|
||||
Api.domain.domainList({}).then((res) => {
|
||||
if (res) {
|
||||
domains.value = res.items ?? [];
|
||||
options.value = domains.value.map((item) => {
|
||||
return {
|
||||
label: item.title,
|
||||
value: item.id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped></style>
|
|
@ -1,3 +1,4 @@
|
|||
export { default as Search } from './search/index.vue';
|
||||
export { default as FullScreen } from './fullscreen/index.vue';
|
||||
export { default as ProjectSetting } from './setting/index.vue';
|
||||
export { default as DomianPicker } from './domianPicker/index.vue';
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
<template>
|
||||
<Layout.Header :style="headerStyle" class="layout-header">
|
||||
<Layout.Header :style="headerStyle"
|
||||
class="layout-header">
|
||||
<Space :size="20">
|
||||
<slot>
|
||||
<Space :size="20">
|
||||
<span class="menu-fold" @click="() => emit('update:collapsed', !collapsed)">
|
||||
<span class="menu-fold"
|
||||
@click="() => emit('update:collapsed', !collapsed)">
|
||||
<component :is="collapsed ? MenuUnfoldOutlined : MenuFoldOutlined" />
|
||||
</span>
|
||||
<Breadcrumb>
|
||||
<template v-for="(routeItem, rotueIndex) in menus" :key="routeItem?.name">
|
||||
<template v-for="(routeItem, rotueIndex) in menus"
|
||||
:key="routeItem?.name">
|
||||
<Breadcrumb.Item>
|
||||
<TitleI18n :title="routeItem?.meta?.title" />
|
||||
<template v-if="routeItem?.children?.length" #overlay>
|
||||
<template v-if="routeItem?.children?.length"
|
||||
#overlay>
|
||||
<Menu :selected-keys="getSelectKeys(rotueIndex)">
|
||||
<template v-for="childItem in routeItem?.children" :key="childItem.name">
|
||||
<Menu.Item
|
||||
v-if="!childItem.meta?.hideInMenu && !childItem.meta?.hideInBreadcrumb"
|
||||
<template v-for="childItem in routeItem?.children"
|
||||
:key="childItem.name">
|
||||
<Menu.Item v-if="!childItem.meta?.hideInMenu && !childItem.meta?.hideInBreadcrumb"
|
||||
:key="childItem.name"
|
||||
@click="clickMenuItem(childItem)"
|
||||
>
|
||||
@click="clickMenuItem(childItem)">
|
||||
<TitleI18n :title="childItem.meta?.title" />
|
||||
</Menu.Item>
|
||||
</template>
|
||||
|
@ -30,14 +33,17 @@
|
|||
</slot>
|
||||
</Space>
|
||||
<Space :size="20">
|
||||
<DomianPicker />
|
||||
<Search />
|
||||
<Tooltip :title="$t('layout.header.tooltipLock')" placement="bottom">
|
||||
<Tooltip :title="$t('layout.header.tooltipLock')"
|
||||
placement="bottom">
|
||||
<LockOutlined @click="lockscreenStore.setLock(true)" />
|
||||
</Tooltip>
|
||||
<FullScreen />
|
||||
<!-- <LocalePicker /> -->
|
||||
<Dropdown placement="bottomRight">
|
||||
<Avatar :src="userInfo.avatar" :alt="userInfo.username">{{ userInfo.username }}</Avatar>
|
||||
<Avatar :src="userInfo.avatar"
|
||||
:alt="userInfo.username">{{ userInfo.username }}</Avatar>
|
||||
<template #overlay>
|
||||
<Menu>
|
||||
<Menu.Item @click="$router.push({ name: 'account-about' })">
|
||||
|
@ -61,151 +67,151 @@
|
|||
</template>
|
||||
|
||||
<script lang="tsx" setup>
|
||||
import { computed, type CSSProperties } from 'vue';
|
||||
import { useRouter, useRoute, type RouteRecordRaw } from 'vue-router';
|
||||
import {
|
||||
QuestionCircleOutlined,
|
||||
MenuFoldOutlined,
|
||||
MenuUnfoldOutlined,
|
||||
PoweroffOutlined,
|
||||
LockOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import {
|
||||
Layout,
|
||||
Modal,
|
||||
Dropdown,
|
||||
Menu,
|
||||
Space,
|
||||
Breadcrumb,
|
||||
Avatar,
|
||||
Tooltip,
|
||||
type MenuTheme,
|
||||
} from 'ant-design-vue';
|
||||
import { Search, FullScreen, ProjectSetting } from './components/';
|
||||
import { LocalePicker } from '@/components/basic/locale-picker';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { useLockscreenStore } from '@/store/modules/lockscreen';
|
||||
import { TitleI18n } from '@/components/basic/title-i18n';
|
||||
import { useLayoutSettingStore } from '@/store/modules/layoutSetting';
|
||||
import { computed, type CSSProperties } from 'vue';
|
||||
import { useRouter, useRoute, type RouteRecordRaw } from 'vue-router';
|
||||
import {
|
||||
QuestionCircleOutlined,
|
||||
MenuFoldOutlined,
|
||||
MenuUnfoldOutlined,
|
||||
PoweroffOutlined,
|
||||
LockOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import {
|
||||
Layout,
|
||||
Modal,
|
||||
Dropdown,
|
||||
Menu,
|
||||
Space,
|
||||
Breadcrumb,
|
||||
Avatar,
|
||||
Tooltip,
|
||||
type MenuTheme,
|
||||
} from 'ant-design-vue';
|
||||
import { Search, FullScreen, ProjectSetting, DomianPicker } from './components/';
|
||||
import { LocalePicker } from '@/components/basic/locale-picker';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { useLockscreenStore } from '@/store/modules/lockscreen';
|
||||
import { TitleI18n } from '@/components/basic/title-i18n';
|
||||
import { useLayoutSettingStore } from '@/store/modules/layoutSetting';
|
||||
|
||||
defineProps({
|
||||
collapsed: {
|
||||
type: Boolean,
|
||||
},
|
||||
theme: {
|
||||
type: String as PropType<MenuTheme>,
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(['update:collapsed']);
|
||||
const userStore = useUserStore();
|
||||
const layoutSettingStore = useLayoutSettingStore();
|
||||
const lockscreenStore = useLockscreenStore();
|
||||
defineProps({
|
||||
collapsed: {
|
||||
type: Boolean,
|
||||
},
|
||||
theme: {
|
||||
type: String as PropType<MenuTheme>,
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(['update:collapsed']);
|
||||
const userStore = useUserStore();
|
||||
const layoutSettingStore = useLayoutSettingStore();
|
||||
const lockscreenStore = useLockscreenStore();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const userInfo = computed(() => userStore.userInfo);
|
||||
const headerStyle = computed<CSSProperties>(() => {
|
||||
const { navTheme, layout } = layoutSettingStore.layoutSetting;
|
||||
const isDark = navTheme === 'dark' && layout === 'topmenu';
|
||||
return {
|
||||
backgroundColor: navTheme === 'realDark' || isDark ? '' : 'rgba(255, 255, 255, 0.85)',
|
||||
color: isDark ? 'rgba(255, 255, 255, 0.85)' : '',
|
||||
};
|
||||
});
|
||||
|
||||
const menus = computed(() => {
|
||||
if (route.meta?.namePath) {
|
||||
let children = userStore.menus;
|
||||
const paths = route.meta?.namePath?.map((item) => {
|
||||
const a = children.find((n) => n.name === item);
|
||||
children = a?.children || [];
|
||||
return a;
|
||||
});
|
||||
return [
|
||||
{
|
||||
name: '__index',
|
||||
meta: {
|
||||
title: '首页',
|
||||
},
|
||||
children: userStore.menus,
|
||||
},
|
||||
...paths,
|
||||
];
|
||||
}
|
||||
return route.matched;
|
||||
});
|
||||
|
||||
const getSelectKeys = (rotueIndex: number) => {
|
||||
return [menus.value[rotueIndex + 1]?.name] as string[];
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const userInfo = computed(() => userStore.userInfo);
|
||||
const headerStyle = computed<CSSProperties>(() => {
|
||||
const { navTheme, layout } = layoutSettingStore.layoutSetting;
|
||||
const isDark = navTheme === 'dark' && layout === 'topmenu';
|
||||
return {
|
||||
backgroundColor: navTheme === 'realDark' || isDark ? '' : 'rgba(255, 255, 255, 0.85)',
|
||||
color: isDark ? 'rgba(255, 255, 255, 0.85)' : '',
|
||||
};
|
||||
});
|
||||
|
||||
const findLastChild = (route?: RouteRecordRaw) => {
|
||||
if (typeof route?.redirect === 'object') {
|
||||
const redirectValues = Object.values(route.redirect);
|
||||
if (route?.children?.length) {
|
||||
const target = route.children.find((n) =>
|
||||
redirectValues.some((m) => [n.name, n.path, n.meta?.fullPath].some((v) => v === m)),
|
||||
);
|
||||
return findLastChild(target);
|
||||
}
|
||||
return redirectValues.find((n) => typeof n === 'string');
|
||||
} else if (typeof route?.redirect === 'string') {
|
||||
if (route?.children?.length) {
|
||||
const target = route.children.find((n) =>
|
||||
[n.name, n.path, n.meta?.fullPath].some((m) => m === route?.redirect),
|
||||
);
|
||||
return findLastChild(target);
|
||||
}
|
||||
return route?.redirect;
|
||||
}
|
||||
return route;
|
||||
};
|
||||
const getRouteByName = (name: string) => router.getRoutes().find((n) => n.name === name);
|
||||
|
||||
// 点击菜单
|
||||
const clickMenuItem = (menuItem: RouteRecordRaw) => {
|
||||
const lastChild = findLastChild(menuItem);
|
||||
console.log('lastChild', menuItem, lastChild);
|
||||
|
||||
const targetRoute = getRouteByName(lastChild?.name);
|
||||
const { isExt, extOpenMode } = targetRoute?.meta || {};
|
||||
if (isExt && extOpenMode === 1) {
|
||||
window.open(lastChild?.path);
|
||||
} else {
|
||||
router.push({ name: lastChild?.name });
|
||||
}
|
||||
};
|
||||
|
||||
// 退出登录
|
||||
const doLogout = () => {
|
||||
Modal.confirm({
|
||||
title: '您确定要退出登录吗?',
|
||||
icon: <QuestionCircleOutlined />,
|
||||
centered: true,
|
||||
onOk: async () => {
|
||||
// 如果不是rootadmin,则退出登录
|
||||
if (userStore.userInfo.phone !== '13553550634') {
|
||||
// logout({})
|
||||
await userStore.logout();
|
||||
}
|
||||
},
|
||||
const menus = computed(() => {
|
||||
if (route.meta?.namePath) {
|
||||
let children = userStore.menus;
|
||||
const paths = route.meta?.namePath?.map((item) => {
|
||||
const a = children.find((n) => n.name === item);
|
||||
children = a?.children || [];
|
||||
return a;
|
||||
});
|
||||
};
|
||||
return [
|
||||
{
|
||||
name: '__index',
|
||||
meta: {
|
||||
title: '首页',
|
||||
},
|
||||
children: userStore.menus,
|
||||
},
|
||||
...paths,
|
||||
];
|
||||
}
|
||||
return route.matched;
|
||||
});
|
||||
|
||||
const getSelectKeys = (rotueIndex: number) => {
|
||||
return [menus.value[rotueIndex + 1]?.name] as string[];
|
||||
};
|
||||
|
||||
const findLastChild = (route?: RouteRecordRaw) => {
|
||||
if (typeof route?.redirect === 'object') {
|
||||
const redirectValues = Object.values(route.redirect);
|
||||
if (route?.children?.length) {
|
||||
const target = route.children.find((n) =>
|
||||
redirectValues.some((m) => [n.name, n.path, n.meta?.fullPath].some((v) => v === m)),
|
||||
);
|
||||
return findLastChild(target);
|
||||
}
|
||||
return redirectValues.find((n) => typeof n === 'string');
|
||||
} else if (typeof route?.redirect === 'string') {
|
||||
if (route?.children?.length) {
|
||||
const target = route.children.find((n) =>
|
||||
[n.name, n.path, n.meta?.fullPath].some((m) => m === route?.redirect),
|
||||
);
|
||||
return findLastChild(target);
|
||||
}
|
||||
return route?.redirect;
|
||||
}
|
||||
return route;
|
||||
};
|
||||
const getRouteByName = (name: string) => router.getRoutes().find((n) => n.name === name);
|
||||
|
||||
// 点击菜单
|
||||
const clickMenuItem = (menuItem: RouteRecordRaw) => {
|
||||
const lastChild = findLastChild(menuItem);
|
||||
console.log('lastChild', menuItem, lastChild);
|
||||
|
||||
const targetRoute = getRouteByName(lastChild?.name);
|
||||
const { isExt, extOpenMode } = targetRoute?.meta || {};
|
||||
if (isExt && extOpenMode === 1) {
|
||||
window.open(lastChild?.path);
|
||||
} else {
|
||||
router.push({ name: lastChild?.name });
|
||||
}
|
||||
};
|
||||
|
||||
// 退出登录
|
||||
const doLogout = () => {
|
||||
Modal.confirm({
|
||||
title: '您确定要退出登录吗?',
|
||||
icon: <QuestionCircleOutlined />,
|
||||
centered: true,
|
||||
onOk: async () => {
|
||||
// 如果不是rootadmin,则退出登录
|
||||
if (userStore.userInfo.phone !== '13553550634') {
|
||||
// logout({})
|
||||
await userStore.logout();
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.layout-header {
|
||||
display: flex;
|
||||
position: sticky;
|
||||
z-index: 10;
|
||||
top: 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: @header-height;
|
||||
padding: 0 20px;
|
||||
.layout-header {
|
||||
display: flex;
|
||||
position: sticky;
|
||||
z-index: 10;
|
||||
top: 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: @header-height;
|
||||
padding: 0 20px;
|
||||
|
||||
* {
|
||||
cursor: pointer;
|
||||
}
|
||||
* {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useDictStore } from './dict';
|
|||
import { useRouter, type RouteRecordRaw, useRoute } from 'vue-router';
|
||||
import { store } from '@/store';
|
||||
import Api from '@/api/';
|
||||
import { ACCESS_TOKEN_KEY } from '@/enums/cacheEnum';
|
||||
import { ACCESS_TOKEN_KEY, DOMAIN_KEY } from '@/enums/cacheEnum';
|
||||
import { Storage } from '@/utils/Storage';
|
||||
import { resetRouter } from '@/router';
|
||||
import { generateDynamicRoutes } from '@/router/helper/routeHelper';
|
||||
|
@ -21,12 +21,12 @@ export type MessageEvent = {
|
|||
export const useUserStore = defineStore('user', () => {
|
||||
let eventSource: EventSource | null = null;
|
||||
const token = ref(Storage.get(ACCESS_TOKEN_KEY, null));
|
||||
const name = ref('amdin');
|
||||
const name = ref('admin');
|
||||
const perms = ref<string[]>([]);
|
||||
const menus = ref<RouteRecordRaw[]>([]);
|
||||
const userInfo = ref<Partial<API.UserEntity>>({});
|
||||
const serverConnected = ref(true);
|
||||
|
||||
const domain = ref<API.DomainType>(Storage.get(DOMAIN_KEY, null));
|
||||
watch(serverConnected, (val) => {
|
||||
if (val) {
|
||||
initServerMsgListener();
|
||||
|
@ -87,6 +87,7 @@ export const useUserStore = defineStore('user', () => {
|
|||
// const ex = 7 * 24 * 60 * 60 * 1000;
|
||||
Storage.set(ACCESS_TOKEN_KEY, token.value);
|
||||
};
|
||||
|
||||
/** 登录 */
|
||||
const login = async (params: API.LoginDto) => {
|
||||
try {
|
||||
|
@ -97,6 +98,7 @@ export const useUserStore = defineStore('user', () => {
|
|||
return Promise.reject(error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 解锁屏幕 */
|
||||
const unlock = async (params: API.LoginDto) => {
|
||||
try {
|
||||
|
@ -106,6 +108,17 @@ export const useUserStore = defineStore('user', () => {
|
|||
return Promise.reject(error);
|
||||
}
|
||||
};
|
||||
|
||||
/** 切换domain */
|
||||
const changeDomain = (value) => {
|
||||
domain.value = value;
|
||||
Storage.set(DOMAIN_KEY, value);
|
||||
setTimeout(() => {
|
||||
// 刷新页面
|
||||
window.location.reload();
|
||||
}, 200);
|
||||
};
|
||||
|
||||
/** 登录成功之后, 获取用户信息以及生成权限路由 */
|
||||
const afterLogin = async () => {
|
||||
try {
|
||||
|
@ -113,9 +126,12 @@ export const useUserStore = defineStore('user', () => {
|
|||
useDictStore();
|
||||
// const wsStore = useWsStore();
|
||||
const userInfoData = await accountProfile();
|
||||
|
||||
userInfo.value = userInfoData;
|
||||
|
||||
if (!Storage.get(DOMAIN_KEY)) {
|
||||
domain.value = userInfoData.domain;
|
||||
Storage.set(DOMAIN_KEY, domain.value);
|
||||
}
|
||||
await fetchPermsAndMenus();
|
||||
initServerMsgListener();
|
||||
} catch (error) {
|
||||
|
@ -158,6 +174,8 @@ export const useUserStore = defineStore('user', () => {
|
|||
perms,
|
||||
menus,
|
||||
userInfo,
|
||||
domain,
|
||||
changeDomain,
|
||||
login,
|
||||
unlock,
|
||||
afterLogin,
|
||||
|
|
|
@ -123,6 +123,8 @@ export function request<T = any>(config: RequestOptions): Promise<BaseResponse<T
|
|||
export async function request(_url: string | RequestOptions, _config: RequestOptions = {}) {
|
||||
const url = isString(_url) ? _url : _url.url;
|
||||
const config = isString(_url) ? _config : _url;
|
||||
const userStore = useUserStore();
|
||||
|
||||
try {
|
||||
// 兼容 from data 文件上传的情况
|
||||
const { requestType, isReturnResult = true, ...rest } = config;
|
||||
|
@ -137,6 +139,7 @@ export async function request(_url: string | RequestOptions, _config: RequestOpt
|
|||
headers: {
|
||||
...rest.headers,
|
||||
...(requestType === 'form' ? { 'Content-Type': 'multipart/form-data' } : {}),
|
||||
'sk-domain':userStore.domain
|
||||
},
|
||||
})) as AxiosResponse<BaseResponse>;
|
||||
|
||||
|
|
|
@ -21,264 +21,277 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<script setup
|
||||
lang="tsx">
|
||||
import { useTable } from '@/components/core/dynamic-table';
|
||||
import {
|
||||
baseColumns,
|
||||
type TableColumnItem,
|
||||
type TableListItem,
|
||||
} from './columns';
|
||||
import Api from '@/api/';
|
||||
import { onMounted, ref, type FunctionalComponent } from 'vue';
|
||||
import { useFormModal, useModal } from '@/hooks/useModal';
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { formSchemas } from './formSchemas';
|
||||
import AttachmentManage from '@/components/business/attachment-manage/index.vue';
|
||||
import AttachmentUpload from '@/components/business/attachment-upload/index.vue';
|
||||
import { useExportExcelModal, jsonToSheetXlsx } from '@/components/basic/excel';
|
||||
import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum';
|
||||
import { formatToDate } from '@/utils/dateUtil';
|
||||
defineOptions({
|
||||
name: 'MaterialsInOut',
|
||||
});
|
||||
<script setup lang="tsx">
|
||||
import { useTable } from '@/components/core/dynamic-table';
|
||||
import {
|
||||
baseColumns,
|
||||
type TableColumnItem,
|
||||
type TableListItem,
|
||||
} from './columns';
|
||||
import Api from '@/api/';
|
||||
import { onMounted, ref, type FunctionalComponent } from 'vue';
|
||||
import { useFormModal, useModal } from '@/hooks/useModal';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import { formSchemas } from './formSchemas';
|
||||
import AttachmentManage from '@/components/business/attachment-manage/index.vue';
|
||||
import AttachmentUpload from '@/components/business/attachment-upload/index.vue';
|
||||
import { useExportExcelModal, jsonToSheetXlsx } from '@/components/basic/excel';
|
||||
import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum';
|
||||
import { formatToDate } from '@/utils/dateUtil';
|
||||
import dayjs from 'dayjs';
|
||||
import fileDownload from 'js-file-download';
|
||||
defineOptions({
|
||||
name: 'MaterialsInOut',
|
||||
});
|
||||
|
||||
const [DynamicTable, dynamicTableInstance] = useTable({ formProps: { autoSubmitOnEnter: true } });
|
||||
const [showModal] = useFormModal();
|
||||
const exportExcelModal = useExportExcelModal();
|
||||
const [fnModal] = useModal();
|
||||
const isUploadPopupVisiable = ref(false);
|
||||
const [DynamicTable, dynamicTableInstance] = useTable({ formProps: { autoSubmitOnEnter: true } });
|
||||
const [showModal] = useFormModal();
|
||||
const exportExcelModal = useExportExcelModal();
|
||||
const [fnModal] = useModal();
|
||||
const isUploadPopupVisiable = ref(false);
|
||||
|
||||
let columns = ref<TableColumnItem[]>();
|
||||
onMounted(() => {
|
||||
columns.value = [
|
||||
...baseColumns,
|
||||
{
|
||||
title: '附件',
|
||||
width: 40,
|
||||
maxWidth: 40,
|
||||
hideInSearch: true,
|
||||
fixed: 'right',
|
||||
dataIndex: 'files',
|
||||
customRender: ({ record }) => <FilesRender {...record} />,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
maxWidth: 80,
|
||||
width: 80,
|
||||
dataIndex: 'ACTION',
|
||||
hideInSearch: true,
|
||||
fixed: 'right',
|
||||
actions: ({ record }) => [
|
||||
{
|
||||
icon: 'ant-design:edit-outlined',
|
||||
tooltip: '编辑',
|
||||
auth: {
|
||||
perm: 'materials_inventory:history_in_out:update',
|
||||
effect: 'disable',
|
||||
},
|
||||
onClick: () => openEditModal(record),
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:delete-outlined',
|
||||
color: 'red',
|
||||
tooltip: '删除此记录',
|
||||
auth: 'materials_inventory:history_in_out:delete',
|
||||
popConfirm: {
|
||||
title: '你确定要删除吗?',
|
||||
placement: 'left',
|
||||
onConfirm: () => delRowConfirm(record.id),
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:cloud-upload-outlined',
|
||||
tooltip: '上传附件',
|
||||
onClick: () => openAttachmentUploadModal(record),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
const openExportModal = () => {
|
||||
exportExcelModal.openModal({
|
||||
formSchemas: [
|
||||
let columns = ref<TableColumnItem[]>();
|
||||
onMounted(() => {
|
||||
columns.value = [
|
||||
...baseColumns,
|
||||
{
|
||||
title: '附件',
|
||||
width: 40,
|
||||
maxWidth: 40,
|
||||
hideInSearch: true,
|
||||
fixed: 'right',
|
||||
dataIndex: 'files',
|
||||
customRender: ({ record }) => <FilesRender {...record} />,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
maxWidth: 80,
|
||||
width: 80,
|
||||
dataIndex: 'ACTION',
|
||||
hideInSearch: true,
|
||||
fixed: 'right',
|
||||
actions: ({ record }) => [
|
||||
{
|
||||
field: 'time',
|
||||
component: 'RangePicker',
|
||||
label:'时间范围',
|
||||
rules: [{ required: true }],
|
||||
icon: 'ant-design:edit-outlined',
|
||||
tooltip: '编辑',
|
||||
auth: {
|
||||
perm: 'materials_inventory:history_in_out:update',
|
||||
effect: 'disable',
|
||||
},
|
||||
onClick: () => openEditModal(record),
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:delete-outlined',
|
||||
color: 'red',
|
||||
tooltip: '删除此记录',
|
||||
auth: 'materials_inventory:history_in_out:delete',
|
||||
popConfirm: {
|
||||
title: '你确定要删除吗?',
|
||||
placement: 'left',
|
||||
onConfirm: () => delRowConfirm(record.id),
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: 'ant-design:cloud-upload-outlined',
|
||||
tooltip: '上传附件',
|
||||
onClick: () => openAttachmentUploadModal(record),
|
||||
},
|
||||
],
|
||||
onOk: ({ filename, bookType }) => {
|
||||
const tableData: TableListItem[] = dynamicTableInstance.tableData;
|
||||
let exportData: any[] = []
|
||||
for (let item of tableData) {
|
||||
exportData.push({
|
||||
projectName: item.project?.name,
|
||||
inOrOut: item.inOrOut === MaterialsInOutEnum.In ? '入库' : '出库',
|
||||
inventoryInOutNumber: item.inventoryInOutNumber,
|
||||
time: formatToDate(item.time),
|
||||
company: item.product?.company?.name,
|
||||
productName: item.product?.name,
|
||||
productSpecification: item.product?.productSpecification,
|
||||
unit: item.product?.unit?.label,
|
||||
quantity: item.quantity,
|
||||
unitPrice: parseFloat(item.unitPrice),
|
||||
amount: parseFloat(item.amount),
|
||||
agent: item.agent,
|
||||
issuanceNumber: item.issuanceNumber,
|
||||
remark: item.remark
|
||||
})
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
const openExportModal = async () => {
|
||||
const queryModel = dynamicTableInstance.queryFormRef?.formModel;
|
||||
if(!queryModel?.time){
|
||||
message.warning('请选择时间范围')
|
||||
return;
|
||||
}
|
||||
const timeRange = (queryModel?.time ?? []).map(item => dayjs(item).format('YYYY-MM-DD'));
|
||||
const response = await Api.materialsInOut.materialsInoutExport({
|
||||
time: timeRange ?? [], filename: `${timeRange[0]}-${timeRange[1]}`
|
||||
});
|
||||
fileDownload(response, `${timeRange[0]}-${timeRange[1]}.xls`);
|
||||
// exportExcelModal.openModal({
|
||||
// formSchemas: [
|
||||
// {
|
||||
// field: 'time',
|
||||
// component: 'RangePicker',
|
||||
// label: '时间范围',
|
||||
// rules: [{ required: true }],
|
||||
// },
|
||||
// ],
|
||||
// onOk: async ({ filename, bookType, time }) => {
|
||||
// const response = await Api.materialsInOut.materialsInoutExport({
|
||||
// time: (time ?? []).map(item => dayjs(item).format('YYYY-MM-DD')), filename
|
||||
// });
|
||||
// fileDownload(response, `${filename}.xls`);
|
||||
// const tableData: TableListItem[] = dynamicTableInstance.tableData;
|
||||
// let exportData: any[] = []
|
||||
// for (let item of tableData) {
|
||||
// exportData.push({
|
||||
// projectName: item.project?.name,
|
||||
// inOrOut: item.inOrOut === MaterialsInOutEnum.In ? '入库' : '出库',
|
||||
// inventoryInOutNumber: item.inventoryInOutNumber,
|
||||
// time: formatToDate(item.time),
|
||||
// company: item.product?.company?.name,
|
||||
// productName: item.product?.name,
|
||||
// productSpecification: item.product?.productSpecification,
|
||||
// unit: item.product?.unit?.label,
|
||||
// quantity: item.quantity,
|
||||
// unitPrice: parseFloat(item.unitPrice),
|
||||
// amount: parseFloat(item.amount),
|
||||
// agent: item.agent,
|
||||
// issuanceNumber: item.issuanceNumber,
|
||||
// remark: item.remark
|
||||
// })
|
||||
// }
|
||||
// jsonToSheetXlsx({
|
||||
// data: exportData,
|
||||
// header: {
|
||||
// inOrOut: '出/入库',
|
||||
// inventoryInOutNumber: '出入库单号',
|
||||
// time: '时间',
|
||||
// projectName: '项目',
|
||||
// company: '公司',
|
||||
// productName: '产品名',
|
||||
// productSpecification: "产品规格",
|
||||
// unit: '单位',
|
||||
// quantity: '数量',
|
||||
// unitPrice: '单价',
|
||||
// amount: '金额',
|
||||
// agent: '经办人',
|
||||
// issuanceNumber: '领料单号',
|
||||
// remark: '备注'
|
||||
// },
|
||||
// filename,
|
||||
// write2excelOpts:
|
||||
// { bookType: 'xls' },
|
||||
// json2sheetOpts: {
|
||||
// // 指定顺序
|
||||
// header: [
|
||||
// 'inOrOut', 'inventoryInOutNumber', 'time', 'projectName', 'company', 'productName', 'productSpecification', 'unit', 'quantity',
|
||||
// 'unitPrice', 'amount', 'agent', 'issuanceNumber', 'remark'],
|
||||
// },
|
||||
// });
|
||||
// },
|
||||
// });
|
||||
};
|
||||
const openAttachmentUploadModal = async (record: TableListItem) => {
|
||||
isUploadPopupVisiable.value = true;
|
||||
fnModal.show({
|
||||
width: 800,
|
||||
title: `上传附件: ${record.id}`,
|
||||
content: () => {
|
||||
return (
|
||||
<AttachmentUpload
|
||||
onClose={handleUploadClose}
|
||||
bussinessModule="materialsInOut"
|
||||
bussinessRecordId={record.id}
|
||||
afterUploadCallback={(files) => {
|
||||
afterUploadCallback(files, record.id);
|
||||
}}
|
||||
></AttachmentUpload>
|
||||
);
|
||||
},
|
||||
destroyOnClose: true,
|
||||
open: isUploadPopupVisiable.value,
|
||||
footer: null,
|
||||
});
|
||||
};
|
||||
const handleUploadClose = (hasSuccess: boolean) => {
|
||||
fnModal.hide();
|
||||
isUploadPopupVisiable.value = false;
|
||||
};
|
||||
const afterUploadCallback = async (
|
||||
files: { filename: { path: string; id: number } }[],
|
||||
id: number,
|
||||
) => {
|
||||
await Api.materialsInOut.materialsInOutUpdate(
|
||||
{ id },
|
||||
{ fileIds: files.map((item) => item.filename.id) },
|
||||
);
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 打开新增/编辑弹窗
|
||||
*/
|
||||
const openEditModal = async (record: Partial<TableListItem>) => {
|
||||
const [formRef] = await showModal({
|
||||
modalProps: {
|
||||
title: `${record.id ? '编辑' : '新增'}出入库记录`,
|
||||
width: '50%',
|
||||
onFinish: async (values) => {
|
||||
const params = {
|
||||
...values,
|
||||
// signingDate: formatToDate(values.signingDate),
|
||||
// deliveryDeadline: formatToDate(values.deliveryDeadline),
|
||||
};
|
||||
if (record.id) {
|
||||
await Api.materialsInOut.materialsInOutUpdate(
|
||||
{ id: record.id },
|
||||
params as API.MaterialsInOutUpdateDto,
|
||||
);
|
||||
} else {
|
||||
await Api.materialsInOut.materialsInOutCreate(params as API.MaterialsInOutDto);
|
||||
}
|
||||
jsonToSheetXlsx({
|
||||
data: exportData,
|
||||
header: {
|
||||
inOrOut: '出/入库',
|
||||
inventoryInOutNumber: '出入库单号',
|
||||
time: '时间',
|
||||
projectName: '项目',
|
||||
company: '公司',
|
||||
productName: '产品名',
|
||||
productSpecification: "产品规格",
|
||||
unit: '单位',
|
||||
quantity: '数量',
|
||||
unitPrice: '单价',
|
||||
amount: '金额',
|
||||
agent: '经办人',
|
||||
issuanceNumber: '领料单号',
|
||||
remark: '备注'
|
||||
},
|
||||
filename,
|
||||
write2excelOpts: {
|
||||
bookType,
|
||||
},
|
||||
json2sheetOpts: {
|
||||
// 指定顺序
|
||||
header: [
|
||||
'inOrOut', 'inventoryInOutNumber', 'time', 'projectName', 'company', 'productName', 'productSpecification', 'unit', 'quantity',
|
||||
'unitPrice', 'amount', 'agent', 'issuanceNumber', 'remark'],
|
||||
},
|
||||
});
|
||||
dynamicTableInstance?.reload();
|
||||
},
|
||||
},
|
||||
formProps: {
|
||||
labelWidth: 100,
|
||||
schemas: formSchemas(!!record.id),
|
||||
},
|
||||
});
|
||||
// 如果是编辑的话,需要获取详情
|
||||
if (record.id) {
|
||||
const info = await Api.materialsInOut.materialsInOutInfo({ id: record.id });
|
||||
formRef?.setFieldsValue({
|
||||
...info,
|
||||
});
|
||||
};
|
||||
const openAttachmentUploadModal = async (record: TableListItem) => {
|
||||
isUploadPopupVisiable.value = true;
|
||||
fnModal.show({
|
||||
width: 800,
|
||||
title: `上传附件: ${record.id}`,
|
||||
content: () => {
|
||||
return (
|
||||
<AttachmentUpload
|
||||
onClose={handleUploadClose}
|
||||
bussinessModule="materialsInOut"
|
||||
bussinessRecordId={record.id}
|
||||
afterUploadCallback={(files) => {
|
||||
afterUploadCallback(files, record.id);
|
||||
}}
|
||||
></AttachmentUpload>
|
||||
);
|
||||
},
|
||||
destroyOnClose: true,
|
||||
open: isUploadPopupVisiable.value,
|
||||
footer: null,
|
||||
});
|
||||
};
|
||||
const handleUploadClose = (hasSuccess: boolean) => {
|
||||
fnModal.hide();
|
||||
isUploadPopupVisiable.value = false;
|
||||
};
|
||||
const afterUploadCallback = async (
|
||||
files: { filename: { path: string; id: number } }[],
|
||||
id: number,
|
||||
) => {
|
||||
await Api.materialsInOut.materialsInOutUpdate(
|
||||
{ id },
|
||||
{ fileIds: files.map((item) => item.filename.id) },
|
||||
);
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
}
|
||||
};
|
||||
const delRowConfirm = async (record) => {
|
||||
await Api.materialsInOut.materialsInOutDelete({ id: record });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 打开新增/编辑弹窗
|
||||
*/
|
||||
const openEditModal = async (record: Partial<TableListItem>) => {
|
||||
const [formRef] = await showModal({
|
||||
modalProps: {
|
||||
title: `${record.id ? '编辑' : '新增'}出入库记录`,
|
||||
width: '50%',
|
||||
onFinish: async (values) => {
|
||||
const params = {
|
||||
...values,
|
||||
// signingDate: formatToDate(values.signingDate),
|
||||
// deliveryDeadline: formatToDate(values.deliveryDeadline),
|
||||
};
|
||||
if (record.id) {
|
||||
await Api.materialsInOut.materialsInOutUpdate(
|
||||
{ id: record.id },
|
||||
params as API.MaterialsInOutUpdateDto,
|
||||
);
|
||||
} else {
|
||||
await Api.materialsInOut.materialsInOutCreate(params as API.MaterialsInOutDto);
|
||||
}
|
||||
dynamicTableInstance?.reload();
|
||||
},
|
||||
},
|
||||
formProps: {
|
||||
labelWidth: 100,
|
||||
schemas: formSchemas(!!record.id),
|
||||
},
|
||||
});
|
||||
// 如果是编辑的话,需要获取详情
|
||||
if (record.id) {
|
||||
const info = await Api.materialsInOut.materialsInOutInfo({ id: record.id });
|
||||
formRef?.setFieldsValue({
|
||||
...info,
|
||||
});
|
||||
}
|
||||
};
|
||||
const delRowConfirm = async (record) => {
|
||||
await Api.materialsInOut.materialsInOutDelete({ id: record });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
const FilesRender: FunctionalComponent<TableListItem> = (materialsInOut: TableListItem) => {
|
||||
const [fnModal] = useModal();
|
||||
return (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
openFilesManageModal(fnModal, materialsInOut);
|
||||
}}
|
||||
>
|
||||
{materialsInOut.files?.length || 0}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
const FilesRender: FunctionalComponent<TableListItem> = (materialsInOut: TableListItem) => {
|
||||
const [fnModal] = useModal();
|
||||
return (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
openFilesManageModal(fnModal, materialsInOut);
|
||||
}}
|
||||
>
|
||||
{materialsInOut.files?.length || 0}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
const openFilesManageModal = (fnModal, tableData: TableListItem) => {
|
||||
const fileIds = tableData.files?.map((item) => item.id) || [];
|
||||
fnModal.show({
|
||||
width: 1200,
|
||||
title: `附件管理`,
|
||||
content: () => {
|
||||
return (
|
||||
<AttachmentManage
|
||||
fileIds={fileIds}
|
||||
onDelete={(unlinkIds) => unlinkAttachments(tableData.id, unlinkIds)}
|
||||
></AttachmentManage>
|
||||
);
|
||||
},
|
||||
destroyOnClose: true,
|
||||
footer: null,
|
||||
});
|
||||
};
|
||||
const unlinkAttachments = async (id: number, unlinkIds: number[]) => {
|
||||
await Api.materialsInOut.unlinkAttachments({ id }, { fileIds: unlinkIds });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
const openFilesManageModal = (fnModal, tableData: TableListItem) => {
|
||||
const fileIds = tableData.files?.map((item) => item.id) || [];
|
||||
fnModal.show({
|
||||
width: 1200,
|
||||
title: `附件管理`,
|
||||
content: () => {
|
||||
return (
|
||||
<AttachmentManage
|
||||
fileIds={fileIds}
|
||||
onDelete={(unlinkIds) => unlinkAttachments(tableData.id, unlinkIds)}
|
||||
></AttachmentManage>
|
||||
);
|
||||
},
|
||||
destroyOnClose: true,
|
||||
footer: null,
|
||||
});
|
||||
};
|
||||
const unlinkAttachments = async (id: number, unlinkIds: number[]) => {
|
||||
await Api.materialsInOut.unlinkAttachments({ id }, { fileIds: unlinkIds });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less"
|
||||
scoped></style>
|
||||
<style lang="less" scoped></style>
|
||||
|
|
|
@ -18,139 +18,154 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<script setup
|
||||
lang="tsx">
|
||||
import { useTable } from '@/components/core/dynamic-table';
|
||||
import { baseColumns, type TableColumnItem, type TableListItem } from './columns';
|
||||
import Api from '@/api/';
|
||||
import { onMounted, ref, unref } from 'vue';
|
||||
import { useFormModal } from '@/hooks/useModal';
|
||||
import { exportSchemas } from './exportSchema';
|
||||
import dayjs from 'dayjs';
|
||||
import fileDownload from 'js-file-download';
|
||||
import { message } from 'ant-design-vue';
|
||||
<script setup lang="tsx">
|
||||
import { useTable } from '@/components/core/dynamic-table';
|
||||
import { baseColumns, type TableColumnItem, type TableListItem } from './columns';
|
||||
import Api from '@/api/';
|
||||
import { onMounted, ref, unref } from 'vue';
|
||||
import { useFormModal } from '@/hooks/useModal';
|
||||
import { exportSchemas } from './exportSchema';
|
||||
import dayjs from 'dayjs';
|
||||
import fileDownload from 'js-file-download';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { useExportExcelModal } from '@/components/basic/excel';
|
||||
|
||||
defineOptions({
|
||||
name: 'MaterialsInventory',
|
||||
});
|
||||
const [DynamicTable, dynamicTableInstance] = useTable();
|
||||
const [showExportModal] = useFormModal();
|
||||
let columns = ref<TableColumnItem[]>();
|
||||
onMounted(() => {
|
||||
columns.value = [
|
||||
...baseColumns,
|
||||
defineOptions({
|
||||
name: 'MaterialsInventory',
|
||||
});
|
||||
const [DynamicTable, dynamicTableInstance] = useTable();
|
||||
const [showExportModal] = useFormModal();
|
||||
const exportExcelModal = useExportExcelModal();
|
||||
let columns = ref<TableColumnItem[]>();
|
||||
onMounted(() => {
|
||||
columns.value = [
|
||||
...baseColumns,
|
||||
|
||||
// {
|
||||
// title: '操作',
|
||||
// maxWidth: 60,
|
||||
// width: 60,
|
||||
// minWidth: 60,
|
||||
// dataIndex: 'ACTION',
|
||||
// hideInSearch: true,
|
||||
// actions: ({ record }) => [
|
||||
// {
|
||||
// icon: 'ant-design:edit-outlined',
|
||||
// tooltip: '编辑',
|
||||
// auth: {
|
||||
// perm: 'app:materials_inventory:update',
|
||||
// effect: 'disable',
|
||||
// },
|
||||
// onClick: () => openEditModal(record),
|
||||
// },
|
||||
// // {
|
||||
// // icon: 'ant-design:delete-outlined',
|
||||
// // color: 'red',
|
||||
// // tooltip: '删除此记录',
|
||||
// // auth: 'app:materials_inventory:delete',
|
||||
// // popConfirm: {
|
||||
// // title: '你确定要删除吗?',
|
||||
// // placement: 'left',
|
||||
// // onConfirm: () => delRowConfirm(record.id),
|
||||
// // },
|
||||
// // },
|
||||
// ],
|
||||
// },
|
||||
];
|
||||
});
|
||||
const exportMI = async () => {
|
||||
const { time } = unref<{ time: string; projectId: number }>(
|
||||
dynamicTableInstance?.queryFormRef?.formModel as { time: string; projectId: number },
|
||||
);
|
||||
|
||||
const [formRef] = await showExportModal({
|
||||
modalProps: {
|
||||
title: `导出条件选择`,
|
||||
width: '50%',
|
||||
okText: '导出',
|
||||
onFinish: async (values) => {
|
||||
const response = await Api.materialsInventory.materialsInventoryExport(values);
|
||||
const { time } = values;
|
||||
fileDownload(response, `${dayjs(time).format('YYYY.MM.盘点表')}.xls`);
|
||||
},
|
||||
},
|
||||
formProps: {
|
||||
labelWidth: 100,
|
||||
schemas: exportSchemas,
|
||||
},
|
||||
});
|
||||
|
||||
// auto fill export time fields
|
||||
if (time) {
|
||||
formRef?.setFieldsValue({
|
||||
time,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 打开新增/编辑弹窗
|
||||
*/
|
||||
const openEditModal = async (record: Partial<TableListItem>) => {
|
||||
message.warning(
|
||||
<div>
|
||||
暂不支持编辑功能,等待后期需求确认
|
||||
<div>库存数量是由出入库记录自动计算得出的,库存单价为入库的单价</div>
|
||||
</div>
|
||||
);
|
||||
// const [formRef] = await showModal({
|
||||
// modalProps: {
|
||||
// title: `${record.id ? '编辑' : '新增'}盘点记录`,
|
||||
// width: '50%',
|
||||
// onFinish: async (values) => {
|
||||
// const params = {
|
||||
// ...values,
|
||||
// signingDate: formatToDate(values.signingDate),
|
||||
// deliveryDeadline: formatToDate(values.deliveryDeadline),
|
||||
// };
|
||||
// if (record.id) {
|
||||
// await Api.contract.contractUpdate({ id: record.id }, params);
|
||||
// } else {
|
||||
// await Api.contract.contractCreate(params);
|
||||
// }
|
||||
// dynamicTableInstance?.reload();
|
||||
// {
|
||||
// title: '操作',
|
||||
// maxWidth: 60,
|
||||
// width: 60,
|
||||
// minWidth: 60,
|
||||
// dataIndex: 'ACTION',
|
||||
// hideInSearch: true,
|
||||
// actions: ({ record }) => [
|
||||
// {
|
||||
// icon: 'ant-design:edit-outlined',
|
||||
// tooltip: '编辑',
|
||||
// auth: {
|
||||
// perm: 'app:materials_inventory:update',
|
||||
// effect: 'disable',
|
||||
// },
|
||||
// onClick: () => openEditModal(record),
|
||||
// },
|
||||
// },
|
||||
// formProps: {
|
||||
// labelWidth: 100,
|
||||
// schemas: contractSchemas(contractTypes.value),
|
||||
// },
|
||||
// });
|
||||
// // 如果是编辑的话,需要获取角色详情
|
||||
// if (record.id) {
|
||||
// const info = await Api.contract.contractInfo({ id: record.id });
|
||||
// formRef?.setFieldsValue({
|
||||
// ...info,
|
||||
// });
|
||||
// }
|
||||
};
|
||||
const delRowConfirm = async (record) => {
|
||||
await Api.contract.contractDelete({ id: record });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
// // {
|
||||
// // icon: 'ant-design:delete-outlined',
|
||||
// // color: 'red',
|
||||
// // tooltip: '删除此记录',
|
||||
// // auth: 'app:materials_inventory:delete',
|
||||
// // popConfirm: {
|
||||
// // title: '你确定要删除吗?',
|
||||
// // placement: 'left',
|
||||
// // onConfirm: () => delRowConfirm(record.id),
|
||||
// // },
|
||||
// // },
|
||||
// ],
|
||||
// },
|
||||
];
|
||||
});
|
||||
const exportMI = async () => {
|
||||
const { time } = unref<{ time: string; projectId: number }>(
|
||||
dynamicTableInstance?.queryFormRef?.formModel as { time: string; projectId: number },
|
||||
);
|
||||
exportExcelModal.openModal({
|
||||
formSchemas: [
|
||||
{
|
||||
field: 'time',
|
||||
component: 'RangePicker',
|
||||
label: '时间范围',
|
||||
rules: [{ required: true }],
|
||||
},
|
||||
],
|
||||
onOk: async ({ filename, bookType, time }) => {
|
||||
const response = await Api.materialsInventory.materialsInventoryExport({
|
||||
time: (time ?? []).map(item => dayjs(item).format('YYYY-MM-DD')), filename
|
||||
});
|
||||
fileDownload(response, `${filename}.xls`);
|
||||
}
|
||||
});
|
||||
// const [formRef] = await showExportModal({
|
||||
// modalProps: {
|
||||
// title: `导出条件选择`,
|
||||
// width: '50%',
|
||||
// okText: '导出',
|
||||
// onFinish: async (values) => {
|
||||
// const response = await Api.materialsInventory.materialsInventoryExport(values);
|
||||
// const { time } = values;
|
||||
// fileDownload(response, `${dayjs(time).format('YYYY.MM.盘点表')}.xls`);
|
||||
// },
|
||||
// },
|
||||
// formProps: {
|
||||
// labelWidth: 100,
|
||||
// schemas: exportSchemas,
|
||||
// },
|
||||
// });
|
||||
|
||||
// auto fill export time fields
|
||||
// if (time) {
|
||||
// formRef?.setFieldsValue({
|
||||
// time,
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 打开新增/编辑弹窗
|
||||
*/
|
||||
const openEditModal = async (record: Partial<TableListItem>) => {
|
||||
message.warning(
|
||||
<div>
|
||||
暂不支持编辑功能,等待后期需求确认
|
||||
<div>库存数量是由出入库记录自动计算得出的,库存单价为入库的单价</div>
|
||||
</div>
|
||||
);
|
||||
// const [formRef] = await showModal({
|
||||
// modalProps: {
|
||||
// title: `${record.id ? '编辑' : '新增'}盘点记录`,
|
||||
// width: '50%',
|
||||
// onFinish: async (values) => {
|
||||
// const params = {
|
||||
// ...values,
|
||||
// signingDate: formatToDate(values.signingDate),
|
||||
// deliveryDeadline: formatToDate(values.deliveryDeadline),
|
||||
// };
|
||||
// if (record.id) {
|
||||
// await Api.contract.contractUpdate({ id: record.id }, params);
|
||||
// } else {
|
||||
// await Api.contract.contractCreate(params);
|
||||
// }
|
||||
// dynamicTableInstance?.reload();
|
||||
// },
|
||||
// },
|
||||
// formProps: {
|
||||
// labelWidth: 100,
|
||||
// schemas: contractSchemas(contractTypes.value),
|
||||
// },
|
||||
// });
|
||||
// // 如果是编辑的话,需要获取角色详情
|
||||
// if (record.id) {
|
||||
// const info = await Api.contract.contractInfo({ id: record.id });
|
||||
// formRef?.setFieldsValue({
|
||||
// ...info,
|
||||
// });
|
||||
// }
|
||||
};
|
||||
const delRowConfirm = async (record) => {
|
||||
await Api.contract.contractDelete({ id: record });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less"
|
||||
scoped></style>
|
||||
<style lang="less" scoped></style>
|
||||
import dayjs from 'dayjs'; import fileDownload from 'js-file-download'; import type { TableQueryItem
|
||||
} from '../in-out/columns'; import { exportSchemas } from '../in-out/exportSchema'; import dayjs
|
||||
from 'dayjs'; import fileDownload from 'js-file-download'; import type { TableQueryItem } from
|
||||
|
|
Loading…
Reference in New Issue