diff --git a/src/api/backend/api/typings.d.ts b/src/api/backend/api/typings.d.ts index 2353f73..e521a20 100644 --- a/src/api/backend/api/typings.d.ts +++ b/src/api/backend/api/typings.d.ts @@ -1389,6 +1389,8 @@ declare namespace API { }; type MaterialsInventoryEntity = { + /** 库存编号 */ + inventoryNumber: string; /** 项目 */ project: ProjectEntity; /** 产品 */ @@ -1621,7 +1623,7 @@ declare namespace API { type ProductParams = { page?: number; pageSize?: number; - keyword?:string; + keyword?: string; company?: string; name?: string; field?: string; @@ -1769,14 +1771,14 @@ declare namespace API { type MaterialsInOutInfoParams = { id?: number; - inventoryNumber?: string; + inventoryInOutNumber?: string; }; type MaterialsInOutListParams = { page?: number; pageSize?: number; time?: string; - inventoryNumber?: string; + inventoryInOutNumber?: string; isCreateOut?: boolean; project?: string; field?: string; @@ -1787,8 +1789,8 @@ declare namespace API { type MaterialsInOutEntity = { /** 入库后的库存Id */ inventoryId: number; - /** 库存编号 */ - inventoryNumber: string; + /** 出入库编号 */ + inventoryInOutNumber: string; /** 公司信息 */ company: CompanyEntity; /** 产品Id */ diff --git a/src/components/basic/excel/src/ExportExcelModal.tsx b/src/components/basic/excel/src/ExportExcelModal.tsx index 25768e4..b453a23 100644 --- a/src/components/basic/excel/src/ExportExcelModal.tsx +++ b/src/components/basic/excel/src/ExportExcelModal.tsx @@ -6,6 +6,7 @@ import { useFormModal } from '@/hooks/useModal/'; export type OpenModalOptions = { onOk: (val: ExportModalResult) => any; + formSchemas?: FormSchema[]; }; const getSchemas = (t): FormSchema[] => [ @@ -15,44 +16,44 @@ const getSchemas = (t): FormSchema[] => [ label: t('component.excel.fileName'), rules: [{ required: true }], }, - { - field: 'bookType', - component: 'Select', - label: t('component.excel.fileType'), - defaultValue: 'xlsx', - rules: [{ required: true }], - componentProps: { - options: [ - { - label: 'xlsx', - value: 'xlsx', - key: 'xlsx', - }, - { - label: 'html', - value: 'html', - key: 'html', - }, - { - label: 'csv', - value: 'csv', - key: 'csv', - }, - { - label: 'txt', - value: 'txt', - key: 'txt', - }, - ], - }, - }, + // { + // field: 'bookType', + // component: 'Select', + // label: t('component.excel.fileType'), + // defaultValue: 'xlsx', + // rules: [{ required: true }], + // componentProps: { + // options: [ + // { + // label: 'xlsx', + // value: 'xlsx', + // key: 'xlsx', + // }, + // { + // label: 'html', + // value: 'html', + // key: 'html', + // }, + // { + // label: 'csv', + // value: 'csv', + // key: 'csv', + // }, + // { + // label: 'txt', + // value: 'txt', + // key: 'txt', + // }, + // ], + // }, + // }, ]; export const useExportExcelModal = () => { const { t } = useI18n(); const [showModal] = useFormModal(); - const openModal = ({ onOk }: OpenModalOptions) => { + const openModal = ({ onOk, formSchemas = [] }: OpenModalOptions) => { showModal({ modalProps: { title: t('component.excel.exportModalTitle'), @@ -67,7 +68,7 @@ export const useExportExcelModal = () => { }, formProps: { labelWidth: 100, - schemas: getSchemas(t), + schemas: [...formSchemas, ...getSchemas(t)], }, }); }; diff --git a/src/components/basic/excel/src/typing.ts b/src/components/basic/excel/src/typing.ts index e55e549..03616ab 100644 --- a/src/components/basic/excel/src/typing.ts +++ b/src/components/basic/excel/src/typing.ts @@ -24,4 +24,5 @@ export interface AoAToSheet { export interface ExportModalResult { filename: string; bookType: BookType; + time?: Date[]; } diff --git a/src/views/materials-inventory/in-out/columns.tsx b/src/views/materials-inventory/in-out/columns.tsx index de19091..1181199 100644 --- a/src/views/materials-inventory/in-out/columns.tsx +++ b/src/views/materials-inventory/in-out/columns.tsx @@ -9,13 +9,22 @@ export type TableListItem = API.MaterialsInOutEntity; export type TableQueryItem = API.MaterialsInOutListParams; export type TableColumnItem = TableColumn; export const baseColumns: TableColumnItem[] = [ + { + title: '时间范围', + hideInTable: true, + dataIndex: 'time', + formItemProps: { + component: 'RangePicker', + componentProps: ({ formInstance, schema, formModel }) => ({}), + }, + }, { title: '出入库单号', width: 100, fixed: 'left', - dataIndex: 'inventoryNumber', + dataIndex: 'inventoryInOutNumber', customRender: ({ record }) => { - return record.inventoryNumber || ''; + return record.inventoryInOutNumber || ''; }, formItemProps: { labelWidth: 120, @@ -73,6 +82,7 @@ export const baseColumns: TableColumnItem[] = [ title: '所属公司', width: 100, dataIndex: 'company', + hideInSearch: true, customRender: ({ record }) => { return record.product?.company?.name || ''; }, @@ -118,6 +128,7 @@ export const baseColumns: TableColumnItem[] = [ width: 60, align: 'center', dataIndex: 'time', + hideInSearch: true, formItemProps: { component: 'MonthPicker', }, diff --git a/src/views/materials-inventory/in-out/formSchemas.ts b/src/views/materials-inventory/in-out/formSchemas.ts index 402cfd8..c63eb46 100644 --- a/src/views/materials-inventory/in-out/formSchemas.ts +++ b/src/views/materials-inventory/in-out/formSchemas.ts @@ -226,9 +226,9 @@ export const formSchemas = (isEdit?: boolean): FormSchema ({ + disabled: isEdit, onBlur(e) { const { quantity, unitPrice, amount, inOrOut } = toRaw(formModel); // 出库只关心数量,单价已经有了,直接算出出库金额 @@ -267,6 +267,7 @@ export const formSchemas = (isEdit?: boolean): FormSchema ({ + disabled: isEdit, onBlur(e) { const { quantity, unitPrice } = toRaw(formModel); if (quantity) { @@ -291,6 +292,7 @@ export const formSchemas = (isEdit?: boolean): FormSchema ({ + disabled: isEdit, onBlur(e) { const { quantity, amount } = toRaw(formModel); if (quantity) { @@ -346,16 +348,18 @@ const getProductOptions = async (keyword?: string): Promise = ); }; -const getInventoryNumberOptions = async (inventoryNumber?: string): Promise => { +const getInventoryNumberOptions = async ( + inventoryInOutNumber?: string, +): Promise => { const { items: result } = await Api.materialsInOut.materialsInOutList({ - inventoryNumber, + inventoryInOutNumber, isCreateOut: true, pageSize: 100, }); return ( result?.map((item) => ({ - label: `${item.inventoryNumber} (${item.project?.name || '-'}) (${item.product?.company?.name || '-'}) (${item.product?.name || '-'})`, - value: item.inventoryNumber, + label: `${item.inventoryInOutNumber} (${item.project?.name || '-'}) (${item.product?.company?.name || '-'}) (${item.product?.name || '-'})`, + value: item.inventoryInOutNumber, })) || [] ); }; diff --git a/src/views/materials-inventory/in-out/index.vue b/src/views/materials-inventory/in-out/index.vue index 586c79d..51e919b 100644 --- a/src/views/materials-inventory/in-out/index.vue +++ b/src/views/materials-inventory/in-out/index.vue @@ -34,15 +34,15 @@ 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'; + import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum'; + import { formatToDate } from '@/utils/dateUtil'; defineOptions({ name: 'MaterialsInOut', }); + const [DynamicTable, dynamicTableInstance] = useTable({ formProps: { autoSubmitOnEnter: true } }); const [showModal] = useFormModal(); const exportExcelModal = useExportExcelModal(); @@ -102,34 +102,42 @@ import { formatToDate } from '@/utils/dateUtil'; const openExportModal = () => { exportExcelModal.openModal({ + formSchemas: [ + { + field: 'time', + component: 'RangePicker', + label:'时间范围', + rules: [{ required: true }], + }, + ], onOk: ({ filename, bookType }) => { const tableData: TableListItem[] = dynamicTableInstance.tableData; let exportData: any[] = [] for (let item of tableData) { exportData.push({ - projectName:item.project?.name, + projectName: item.project?.name, inOrOut: item.inOrOut === MaterialsInOutEnum.In ? '入库' : '出库', - inventoryNumber:item.inventoryNumber, - 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 + 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: '出/入库', - inventoryNumber: '出入库单号', + inventoryInOutNumber: '出入库单号', time: '时间', - projectName:'项目', + projectName: '项目', company: '公司', productName: '产品名', productSpecification: "产品规格", @@ -148,7 +156,7 @@ import { formatToDate } from '@/utils/dateUtil'; json2sheetOpts: { // 指定顺序 header: [ - 'inOrOut', 'inventoryNumber', 'time','projectName', 'company', 'productName', 'productSpecification', 'unit', 'quantity', + 'inOrOut', 'inventoryInOutNumber', 'time', 'projectName', 'company', 'productName', 'productSpecification', 'unit', 'quantity', 'unitPrice', 'amount', 'agent', 'issuanceNumber', 'remark'], }, }); diff --git a/src/views/materials-inventory/inventory-check/columns.tsx b/src/views/materials-inventory/inventory-check/columns.tsx index d409e0c..562ae74 100644 --- a/src/views/materials-inventory/inventory-check/columns.tsx +++ b/src/views/materials-inventory/inventory-check/columns.tsx @@ -9,6 +9,15 @@ export type TableListItem = API.MaterialsInventoryEntity; export type TableColumnItem = TableColumn; const dictStore = useDictStore(); export const baseColumns: TableColumnItem[] = [ + { + title: '库存编号', + width: 120, + dataIndex: 'inventoryNumber', + fixed: 'left', + customRender: ({ record }) => { + return record?.inventoryNumber || ''; + }, + }, { title: '所属项目', width: 180, @@ -66,12 +75,7 @@ export const baseColumns: TableColumnItem[] = [ return record?.product?.unit?.label || ''; }, }, - { - title: '库存数量', - hideInSearch: true, - width: 80, - dataIndex: 'quantity', - }, + { title: '入库库存单价', hideInSearch: true, @@ -81,6 +85,13 @@ export const baseColumns: TableColumnItem[] = [ return parseFloat(record.unitPrice) || 0; }, }, + { + title: '库存数量', + hideInSearch: true, + fixed:'right', + width: 80, + dataIndex: 'quantity', + }, ]; export function formatStatus(status: ContractStatusEnum): { diff --git a/src/views/materials-inventory/inventory-check/index.vue b/src/views/materials-inventory/inventory-check/index.vue index ffc3e68..7f86136 100644 --- a/src/views/materials-inventory/inventory-check/index.vue +++ b/src/views/materials-inventory/inventory-check/index.vue @@ -1,28 +1,25 @@ - - + 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