oa_front/src/views/materials-inventory/inventory-check/columns.tsx

198 lines
4.1 KiB
TypeScript

import type { TableColumn } from '@/components/core/dynamic-table';
import { ContractStatusEnum } from '@/enums/contractEnum';
import { DictEnum } from '@/enums/dictEnum';
import { useDictStore } from '@/store/modules/dict';
import { formatToDate } from '@/utils/dateUtil';
import { Tag } from 'ant-design-vue';
export type TableListItem = API.MaterialsInventoryEntity;
export type TableColumnItem = TableColumn<TableListItem>;
const dictStore = useDictStore();
export const baseColumns: TableColumnItem[] = [
{
title: '公司名称',
width: 120,
dataIndex: 'companyName',
},
{
title: '产品名称',
width: 180,
dataIndex: 'product',
},
{
title: '单位',
width: 60,
hideInSearch: true,
dataIndex: 'unit',
formItemProps: {
component: 'Select',
componentProps: {
options: dictStore
.getDictItemsByCode(DictEnum.Unit)
.map(({ label, id }) => ({ value: id, label })),
},
},
customRender: ({ record }) => {
return dictStore.getDictItemsByCode(DictEnum.Unit)?.length
? dictStore.getDictItemsByCode(DictEnum.Unit).find((item) => item.id === record.unit)
?.label || ''
: '';
},
},
{
title: '库存数量',
hideInSearch: true,
width: 80,
dataIndex: 'previousInventoryQuantity',
},
{
title: '单价',
hideInSearch: true,
width: 80,
dataIndex: 'previousUnitPrice',
},
{
title: '金额',
hideInSearch: true,
width: 80,
dataIndex: 'previousAmount',
},
{
title: '入库',
children: [
{
title: '入库时间',
width: 120,
align: 'center',
dataIndex: 'inventoryTime',
customRender: ({ record }) => {
return formatToDate(record.inventoryTime);
},
},
{
title: '数量',
width: 80,
align: 'center',
dataIndex: 'inventoryQuantity',
},
{
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 }) => {
return formatToDate(record.outime);
},
},
{
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): {
color: string;
label: string;
value: number;
} {
switch (status) {
case ContractStatusEnum.Pending:
return {
color: '#ccc',
label: '待审核',
value: ContractStatusEnum.Pending,
};
case ContractStatusEnum.Approved:
return {
color: 'green',
label: '已通过',
value: ContractStatusEnum.Approved,
};
case ContractStatusEnum.Rejected:
return {
color: 'red',
label: '已拒绝',
value: ContractStatusEnum.Rejected,
};
default:
return {
color: '#ccc',
label: '待审核',
value: ContractStatusEnum.Pending,
};
}
}