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

129 lines
3.0 KiB
TypeScript
Raw Normal View History

2024-03-04 09:59:48 +08:00
import type { TableColumn } from '@/components/core/dynamic-table';
import { ContractStatusEnum } from '@/enums/contractEnum';
2024-03-04 14:17:40 +08:00
import { DictEnum } from '@/enums/dictEnum';
import { useDictStore } from '@/store/modules/dict';
2024-03-04 09:59:48 +08:00
import { formatToDate } from '@/utils/dateUtil';
2024-03-04 14:17:40 +08:00
import { Tag } from 'ant-design-vue';
2024-03-04 09:59:48 +08:00
2024-03-04 14:17:40 +08:00
export type TableListItem = API.MaterialsInventoryEntity;
2024-03-04 09:59:48 +08:00
export type TableColumnItem = TableColumn<TableListItem>;
2024-03-04 14:17:40 +08:00
const dictStore = useDictStore();
export const baseColumns: TableColumnItem[] = [
2024-03-27 14:10:56 +08:00
{
title: '库存编号',
width: 120,
dataIndex: 'inventoryNumber',
fixed: 'left',
customRender: ({ record }) => {
return record?.inventoryNumber || '';
},
},
{
title: '所属项目',
width: 180,
dataIndex: 'project',
customRender: ({ record }) => {
return record?.project?.name || '';
},
},
{
title: '所属公司',
width: 180,
dataIndex: 'product',
customRender: ({ record }) => {
return record?.product?.company?.name || '';
},
},
2024-03-04 14:17:40 +08:00
{
title: '产品名称',
width: 180,
dataIndex: 'product',
customRender: ({ record }) => {
return record?.product?.name || '';
},
2024-03-04 14:17:40 +08:00
},
2024-03-22 16:47:44 +08:00
{
title: '产品规格',
width: 180,
dataIndex: 'productSpecification',
customRender: ({ record }) => {
return record?.product?.productSpecification || '';
},
},
{
title: '产品编号',
width: 180,
dataIndex: 'productNumber',
customRender: ({ record }) => {
return record?.product?.productNumber || '';
},
},
2024-03-04 14:17:40 +08:00
{
title: '单位',
width: 60,
hideInSearch: true,
dataIndex: 'unit',
formItemProps: {
component: 'Select',
componentProps: {
2024-03-04 14:17:40 +08:00
options: dictStore
.getDictItemsByCode(DictEnum.Unit)
.map(({ label, id }) => ({ value: id, label })),
},
2024-03-04 09:59:48 +08:00
},
2024-03-04 14:17:40 +08:00
customRender: ({ record }) => {
return record?.product?.unit?.label || '';
2024-03-04 09:59:48 +08:00
},
2024-03-04 14:17:40 +08:00
},
2024-03-27 14:10:56 +08:00
2024-03-04 14:17:40 +08:00
{
2024-03-22 16:47:44 +08:00
title: '入库库存单价',
2024-03-04 14:17:40 +08:00
hideInSearch: true,
width: 80,
2024-03-08 17:23:06 +08:00
dataIndex: 'unitPrice',
customRender: ({ record }) => {
return parseFloat(record.unitPrice) || 0;
},
2024-03-04 14:17:40 +08:00
},
2024-03-27 14:10:56 +08:00
{
title: '库存数量',
hideInSearch: true,
fixed:'right',
width: 80,
dataIndex: 'quantity',
},
2024-03-04 14:17:40 +08:00
];
2024-03-04 09:59:48 +08:00
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,
};
}
}