feat: 原材料盘点表

This commit is contained in:
louis 2024-03-04 14:17:40 +08:00
parent 6a68e724df
commit 2af6a94072
6 changed files with 272 additions and 210 deletions

View File

@ -1412,6 +1412,8 @@ declare namespace API {
agent: string; agent: string;
/** 领料单号 */ /** 领料单号 */
issuanceNumber?: number; issuanceNumber?: number;
/** 项目 */
project: string;
/** 备注 */ /** 备注 */
remark: string; remark: string;
/** 附件 */ /** 附件 */

View File

@ -1,3 +1,4 @@
export enum DictEnum { export enum DictEnum {
ContractType = 'contract_type', ContractType = 'contract_type', // 合同类型
Unit = 'unit', // 单位
} }

View File

@ -4,7 +4,8 @@ import Api from '@/api';
import { store } from '@/store'; import { store } from '@/store';
import { DictEnum } from '@/enums/dictEnum'; import { DictEnum } from '@/enums/dictEnum';
const needCachedKey = [ const needCachedKey = [
DictEnum.ContractType, // 合同类型 DictEnum.ContractType,
DictEnum.Unit
]; ];
export const useDictStore = defineStore('dict', () => { export const useDictStore = defineStore('dict', () => {

View File

@ -96,7 +96,7 @@ import { ref, onMounted, type FunctionalComponent } from 'vue';
]; ];
}); });
const openAttachmentUploadModal = async (record: API.ContractEntity) => { const openAttachmentUploadModal = async (record: TableListItem) => {
isUploadPopupVisiable.value = true; isUploadPopupVisiable.value = true;
fnModal.show({ fnModal.show({
width: 800, width: 800,
@ -169,7 +169,7 @@ import { ref, onMounted, type FunctionalComponent } from 'vue';
dynamicTableInstance?.reload(); dynamicTableInstance?.reload();
}; };
const FilesRender: FunctionalComponent<TableListItem> = (contract: API.ContractEntity) => { const FilesRender: FunctionalComponent<TableListItem> = (contract: TableListItem) => {
const [fnModal] = useModal(); const [fnModal] = useModal();
return ( return (
<Button <Button
@ -183,7 +183,7 @@ import { ref, onMounted, type FunctionalComponent } from 'vue';
); );
}; };
const openFilesManageModal = (fnModal, contract: API.ContractEntity) => { const openFilesManageModal = (fnModal, contract: TableListItem) => {
const fileIds = contract.files?.map((item) => item.id) || []; const fileIds = contract.files?.map((item) => item.id) || [];
fnModal.show({ fnModal.show({
width: 1200, width: 1200,

View File

@ -1,97 +1,167 @@
import type { TableColumn } from '@/components/core/dynamic-table'; import type { TableColumn } from '@/components/core/dynamic-table';
import { ContractStatusEnum } from '@/enums/contractEnum'; import { ContractStatusEnum } from '@/enums/contractEnum';
import { DictEnum } from '@/enums/dictEnum';
import { useDictStore } from '@/store/modules/dict';
import { formatToDate } from '@/utils/dateUtil'; import { formatToDate } from '@/utils/dateUtil';
import { Tag, Button } from 'ant-design-vue'; import { Tag } from 'ant-design-vue';
export type TableListItem = API.ContractEntity; export type TableListItem = API.MaterialsInventoryEntity;
export type TableColumnItem = TableColumn<TableListItem>; export type TableColumnItem = TableColumn<TableListItem>;
const dictStore = useDictStore();
export const baseColumns = (ctx: { export const baseColumns: TableColumnItem[] = [
contractTypes: API.DictItemEntity[];
dynamicTableInstance;
}): TableColumnItem[] => {
const { contractTypes } = ctx;
return [
{ {
title: '编号', title: '公司名称',
width: 100, width: 120,
maxWidth: 100, dataIndex: 'companyName',
fixed: 'left',
dataIndex: 'contractNumber',
}, },
{ {
title: '标题', title: '产品名称',
width: 180, width: 180,
dataIndex: 'title', dataIndex: 'product',
}, },
{ {
title: '类型', title: '单位',
width: 80, width: 60,
hideInSearch: true,
dataIndex: 'unit',
formItemProps: { formItemProps: {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: contractTypes.map(({ label, id }) => ({ value: id, label })), options: dictStore
.getDictItemsByCode(DictEnum.Unit)
.map(({ label, id }) => ({ value: id, label })),
}, },
}, },
dataIndex: 'type',
customRender: ({ record }) => { customRender: ({ record }) => {
return contractTypes?.length return dictStore.getDictItemsByCode(DictEnum.Unit)?.length
? contractTypes.find((item) => item.id === record.type)?.label || '' ? dictStore.getDictItemsByCode(DictEnum.Unit).find((item) => item.id === record.unit)
?.label || ''
: ''; : '';
}, },
}, },
{ {
title: '甲方', title: '库存数量',
width: 120,
dataIndex: 'partyA',
},
{
title: '乙方',
width: 120,
dataIndex: 'partyB',
},
{
title: '签订时间',
width: 60,
maxWidth: 60,
hideInSearch: true, hideInSearch: true,
dataIndex: 'signingDate', width: 80,
customRender: ({ record }) => { dataIndex: 'previousInventoryQuantity',
return formatToDate(record.signingDate);
},
}, },
{ {
title: '交付期限', title: '单价',
width: 60,
maxWidth: 60,
hideInSearch: true, hideInSearch: true,
dataIndex: 'deliveryDeadline', width: 80,
dataIndex: 'previousUnitPrice',
},
{
title: '金额',
hideInSearch: true,
width: 80,
dataIndex: 'previousAmount',
},
{
title: '入库',
children: [
{
title: '入库时间',
width: 120,
align: 'center',
dataIndex: 'inventoryTime',
customRender: ({ record }) => { customRender: ({ record }) => {
return formatToDate(record.deliveryDeadline); return formatToDate(record.inventoryTime);
}, },
}, },
{ {
title: '审核结果', title: '数量',
dataIndex: 'status', width: 80,
maxWidth: 60, align: 'center',
width: 60, dataIndex: 'inventoryQuantity',
fixed:'right',
formItemProps: {
component: 'Select',
componentProps: {
options: Object.values(ContractStatusEnum)
.filter((value) => typeof value === 'number')
.map((item) => formatStatus(item as ContractStatusEnum)),
}, },
{
title: '单价',
width: 80,
align: 'center',
dataIndex: 'inventoryUnitPrice',
}, },
{
title: '金额',
width: 80,
align: 'center',
dataIndex: 'inventoryAmount',
},
],
},
{
title: '出库',
children: [
{
title: '出库时间',
width: 120,
dataIndex: 'outime',
align: 'center',
customRender: ({ record }) => { customRender: ({ record }) => {
const { color, label } = formatStatus(record.status); return formatToDate(record.outime);
return <Tag color={color}>{label}</Tag>;
}, },
}, },
{
title: '出库数量',
width: 80,
dataIndex: 'outQuantity',
align: 'center',
},
{
title: '出库单价',
width: 80,
align: 'center',
dataIndex: 'outUnitPrice',
},
{
title: '出库金额',
width: 80,
align: 'center',
dataIndex: 'outAmount',
},
],
},
{
title: '结存数量',
hideInSearch: true,
width: 80,
dataIndex: 'currentInventoryQuantity',
},
{
title: '单价',
hideInSearch: true,
width: 80,
dataIndex: 'currentUnitPrice',
},
{
title: '金额',
hideInSearch: true,
width: 80,
dataIndex: 'currentAmount',
},
{
title: '经办人',
width: 80,
dataIndex: 'agent',
},
{
title: '领料单号',
width: 80,
dataIndex: 'issuanceNumber',
},
{
title: '项目',
width: 80,
dataIndex: 'project',
},
{
title: '备注',
width: 80,
dataIndex: 'remark',
},
]; ];
};
export function formatStatus(status: ContractStatusEnum): { export function formatStatus(status: ContractStatusEnum): {
color: string; color: string;

View File

@ -1,5 +1,4 @@
<template> <template>
test
<div v-if="columns?.length"> <div v-if="columns?.length">
<DynamicTable <DynamicTable
row-key="id" row-key="id"
@ -43,23 +42,13 @@
const [DynamicTable, dynamicTableInstance] = useTable(); const [DynamicTable, dynamicTableInstance] = useTable();
const [showModal] = useFormModal(); const [showModal] = useFormModal();
const [fnModal] = useModal(); const [fnModal] = useModal();
const { getDictItemsByCode } = useDictStore();
const contractTypes = ref<API.DictItemEntity[]>([]);
const getContractTypes = async () => {
contractTypes.value = await getDictItemsByCode(DictEnum.ContractType);
};
const isUploadPopupVisiable = ref(false); const isUploadPopupVisiable = ref(false);
// contractList; // contractList;
let columns = ref<TableColumnItem[]>(); let columns = ref<TableColumnItem[]>();
onMounted(() => { onMounted(() => {
getContractTypes().then((res) => {
columns.value = [ columns.value = [
...baseColumns({ ...baseColumns,
dynamicTableInstance,
contractTypes: contractTypes.value,
}),
{ {
title: '附件', title: '附件',
width: 50, width: 50,
@ -90,7 +79,7 @@
{ {
icon: 'ant-design:delete-outlined', icon: 'ant-design:delete-outlined',
color: 'red', color: 'red',
tooltip: '删除此合同', tooltip: '删除此记录',
auth: 'app:contract:delete', auth: 'app:contract:delete',
popConfirm: { popConfirm: {
title: '你确定要删除吗?', title: '你确定要删除吗?',
@ -107,27 +96,26 @@
}, },
]; ];
}); });
});
const openAttachmentUploadModal = async (record: API.ContractEntity) => { const openAttachmentUploadModal = async (record: TableListItem) => {
isUploadPopupVisiable.value = true; // isUploadPopupVisiable.value = true;
fnModal.show({ // fnModal.show({
width: 800, // width: 800,
title: `合同编号: ${record.contractNumber}`, // title: `: ${record.contractNumber}`,
content: () => { // content: () => {
return ( // return (
<AttachmentUpload // <AttachmentUpload
onClose={handleUploadClose} // onClose={handleUploadClose}
afterUploadCallback={(files) => { // afterUploadCallback={(files) => {
afterUploadCallback(files, record.id); // afterUploadCallback(files, record.id);
}} // }}
></AttachmentUpload> // ></AttachmentUpload>
); // );
}, // },
destroyOnClose: true, // destroyOnClose: true,
open: isUploadPopupVisiable.value, // open: isUploadPopupVisiable.value,
footer: null, // footer: null,
}); // });
}; };
const handleUploadClose = (hasSuccess: boolean) => { const handleUploadClose = (hasSuccess: boolean) => {
fnModal.hide(); fnModal.hide();
@ -145,44 +133,44 @@
* @description 打开新增/编辑弹窗 * @description 打开新增/编辑弹窗
*/ */
const openEditModal = async (record: Partial<TableListItem>) => { const openEditModal = async (record: Partial<TableListItem>) => {
const [formRef] = await showModal({ // const [formRef] = await showModal({
modalProps: { // modalProps: {
title: `${record.id ? '编辑' : '新增'}合同`, // title: `${record.id ? '' : ''}`,
width: '50%', // width: '50%',
onFinish: async (values) => { // onFinish: async (values) => {
const params = { // const params = {
...values, // ...values,
signingDate: formatToDate(values.signingDate), // signingDate: formatToDate(values.signingDate),
deliveryDeadline: formatToDate(values.deliveryDeadline), // deliveryDeadline: formatToDate(values.deliveryDeadline),
}; // };
if (record.id) { // if (record.id) {
await Api.contract.contractUpdate({ id: record.id }, params); // await Api.contract.contractUpdate({ id: record.id }, params);
} else { // } else {
await Api.contract.contractCreate(params); // await Api.contract.contractCreate(params);
} // }
dynamicTableInstance?.reload(); // dynamicTableInstance?.reload();
}, // },
}, // },
formProps: { // formProps: {
labelWidth: 100, // labelWidth: 100,
schemas: contractSchemas(contractTypes.value), // schemas: contractSchemas(contractTypes.value),
}, // },
}); // });
// // //
if (record.id) { // if (record.id) {
const info = await Api.contract.contractInfo({ id: record.id }); // const info = await Api.contract.contractInfo({ id: record.id });
formRef?.setFieldsValue({ // formRef?.setFieldsValue({
...info, // ...info,
}); // });
} // }
}; };
const delRowConfirm = async (record) => { const delRowConfirm = async (record) => {
await Api.contract.contractDelete({ id: record }); await Api.contract.contractDelete({ id: record });
dynamicTableInstance?.reload(); dynamicTableInstance?.reload();
}; };
const FilesRender: FunctionalComponent<TableListItem> = (contract: API.ContractEntity) => { const FilesRender: FunctionalComponent<TableListItem> = (contract: TableListItem) => {
const [fnModal] = useModal(); const [fnModal] = useModal();
return ( return (
<Button <Button
@ -196,22 +184,22 @@
); );
}; };
const openFilesManageModal = (fnModal, contract: API.ContractEntity) => { const openFilesManageModal = (fnModal, contract: TableListItem) => {
const fileIds = contract.files?.map((item) => item.id) || []; // const fileIds = contract.files?.map((item) => item.id) || [];
fnModal.show({ // fnModal.show({
width: 1200, // width: 1200,
title: `附件管理`, // title: ``,
content: () => { // content: () => {
return ( // return (
<AttachmentManage // <AttachmentManage
fileIds={fileIds} // fileIds={fileIds}
onDelete={(unlinkIds) => unlinkAttachments(contract.id, unlinkIds)} // onDelete={(unlinkIds) => unlinkAttachments(contract.id, unlinkIds)}
></AttachmentManage> // ></AttachmentManage>
); // );
}, // },
destroyOnClose: true, // destroyOnClose: true,
footer: null, // footer: null,
}); // });
}; };
const unlinkAttachments = async (id: number, unlinkIds: number[]) => { const unlinkAttachments = async (id: number, unlinkIds: number[]) => {
await Api.contract.unlinkAttachments({ id }, { fileIds: unlinkIds }); await Api.contract.unlinkAttachments({ id }, { fileIds: unlinkIds });