diff --git a/src/api/backend/api/typings.d.ts b/src/api/backend/api/typings.d.ts index 5801299..2eb1013 100644 --- a/src/api/backend/api/typings.d.ts +++ b/src/api/backend/api/typings.d.ts @@ -1621,14 +1621,19 @@ declare namespace API { type MaterialsInOutListParams = { page?: number; pageSize?: number; + time?: string; + inventoryNumber?: string; + isCreateOut?: boolean; field?: string; order?: 'ASC' | 'DESC'; _t?: number; }; type MaterialsInOutEntity = { - /** 公司名称 */ - companyName: string; + /** 库存编号 */ + inventoryNumber: string; + /** 公司信息 */ + company: CompanyEntity; /** 产品Id */ productId: number; /** 产品信息 */ diff --git a/src/permission/permCode.ts b/src/permission/permCode.ts index 665d28b..7aa94cc 100644 --- a/src/permission/permCode.ts +++ b/src/permission/permCode.ts @@ -90,8 +90,9 @@ const permissions = [ 'app:product:create', 'app:product:update', 'app:product:delete', + 'materials_inventory:history_in_out:export' ] as const; -export type PermissionType = (typeof permissions)[number]; +export type PermissionType = string; // console.log('permissions', permissions); diff --git a/src/views/materials-inventory/in-out/columns.tsx b/src/views/materials-inventory/in-out/columns.tsx index 7d3717e..8aa2c37 100644 --- a/src/views/materials-inventory/in-out/columns.tsx +++ b/src/views/materials-inventory/in-out/columns.tsx @@ -1,28 +1,48 @@ import type { TableColumn } from '@/components/core/dynamic-table'; -import { DictEnum } from '@/enums/dictEnum'; import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum'; -import { useDictStore } from '@/store/modules/dict'; import { formatToDate } from '@/utils/dateUtil'; import { Tag } from 'ant-design-vue'; export type TableListItem = API.MaterialsInOutEntity; +export type TableQueryItem = API.MaterialsInOutListParams; export type TableColumnItem = TableColumn; export const baseColumns: TableColumnItem[] = [ + { + title: '原材料库存编号', + width: 100, + fixed: 'left', + dataIndex: 'inventoryNumber', + customRender: ({ record }) => { + return record.inventoryNumber || ''; + }, + formItemProps: { + labelWidth: 120, + }, + }, + { + title: '所属公司', + width: 100, + dataIndex: 'company', + customRender: ({ record }) => { + return record.product?.company?.name || ''; + }, + }, { title: '产品名称', - width: 180, + width: 100, dataIndex: 'product', customRender: ({ record }) => { return record.product?.name || ''; }, }, + { title: '单位', width: 40, hideInSearch: true, dataIndex: 'unit', customRender: ({ record }) => { - return record.unit?.label || ''; + return record?.product?.unit?.label || ''; }, }, @@ -60,12 +80,18 @@ export const baseColumns: TableColumnItem[] = [ hideInSearch: true, width: 60, dataIndex: 'quantity', + customRender: ({ record }) => { + return parseFloat(record.quantity) || 0; + }, }, { title: '单价', hideInSearch: true, width: 80, dataIndex: 'unitPrice', + customRender: ({ record }) => { + return parseFloat(record.unitPrice) || 0; + }, }, { title: '金额', @@ -73,6 +99,9 @@ export const baseColumns: TableColumnItem[] = [ align: 'center', dataIndex: 'amount', hideInSearch: true, + customRender: ({ record }) => { + return parseFloat(record.amount) || 0; + }, }, { title: '经办人', diff --git a/src/views/materials-inventory/in-out/formSchemas.ts b/src/views/materials-inventory/in-out/formSchemas.ts index 0e20658..a67b220 100644 --- a/src/views/materials-inventory/in-out/formSchemas.ts +++ b/src/views/materials-inventory/in-out/formSchemas.ts @@ -3,14 +3,91 @@ import type { FormSchema } from '@/components/core/schema-form/'; import Api from '@/api'; import { debounce } from 'lodash-es'; import { MaterialsInOutEnum } from '@/enums/materialsInventoryEnum'; -import { DictEnum } from '@/enums/dictEnum'; -import { useDictStore } from '@/store/modules/dict'; -import { toRaw } from 'vue'; -const { getDictItemsByCode } = useDictStore(); -export const formSchemas: FormSchema[] = [ +export const formSchemas = (isEdit?: boolean): FormSchema[] => [ + { + field: 'inOrOut', + component: 'Select', + label: '出入库', + rules: [{ required: true, type: 'number' }], + defaultValue: MaterialsInOutEnum.In, + colProps: { + span: 8, + }, + componentProps: { + allowClear: false, + disabled:isEdit, + options: [ + { label: '出库', value: MaterialsInOutEnum.Out }, + { label: '入库', value: MaterialsInOutEnum.In }, + ], + }, + }, + { + field: 'inventoryNumber', + component: 'Select', + label: '库存编号', + vIf: ({ formModel }) => formModel.inOrOut === MaterialsInOutEnum.Out, + colProps: { + span: 16, + }, + helpMessage: '出库必须选择入库时的编号', + componentProps: ({ formInstance, schema, formModel }) => ({ + showSearch: true, + filterOption: false, + disabled: isEdit, + fieldNames: { + label: 'label', + value: 'value', + }, + options: [], + getPopupContainer: () => document.body, + defaultActiveFirstOption: true, + onClear: async () => { + const newSchema = { + field: schema.field, + componentProps: { + options: [] as LabelValueOptions, + }, + }; + const options = await getInventoryNumberOptions().finally(() => (schema.loading = false)); + newSchema.componentProps.options = options; + formInstance?.updateSchema([newSchema]); + }, + request: { + watchFields: ['inOrOut'], + options: { + immediate: true, + }, + callback: async ({ formModel }) => { + if (formModel.inOrOut === MaterialsInOutEnum.Out) { + return getInventoryNumberOptions(); + } else { + return Promise.resolve([] as LabelValueOptions); + } + }, + }, + onSearch: debounce(async (keyword) => { + schema.loading = true; + const newSchema = { + field: schema.field, + componentProps: { + options: [] as LabelValueOptions, + }, + }; + formInstance?.updateSchema([newSchema]); + const options = await getInventoryNumberOptions(keyword).finally( + () => (schema.loading = false), + ); + newSchema.componentProps.options = options; + formInstance?.updateSchema([newSchema]); + }, 500), + }), + }, + { field: 'productId', component: 'Select', + vIf: ({ formModel }) => formModel.inOrOut === MaterialsInOutEnum.In || isEdit, label: '产品', colProps: { span: 16, @@ -20,6 +97,7 @@ export const formSchemas: FormSchema[] = [ componentProps: ({ formInstance, schema, formModel }) => ({ showSearch: true, filterOption: false, + disabled: isEdit, fieldNames: { label: 'label', value: 'value', @@ -56,24 +134,6 @@ export const formSchemas: FormSchema[] = [ }, 500), }), }, - - { - field: 'inOrOut', - component: 'Select', - label: '出入库', - rules: [{ required: true, type: 'number' }], - defaultValue: MaterialsInOutEnum.In, - colProps: { - span: 8, - }, - componentProps: { - allowClear: false, - options: [ - { label: '出库', value: MaterialsInOutEnum.Out }, - { label: '入库', value: MaterialsInOutEnum.In }, - ], - }, - }, { label: '时间', field: 'time', @@ -136,102 +196,6 @@ export const formSchemas: FormSchema[] = [ field: 'remark', component: 'InputTextArea', }, - // { - // field: 'label', - // component: 'Input', - // label: '合同标题', - // rules: [{ required: true, type: 'string' }], - // colProps: { - // span: 12, - // }, - // }, - // { - // field: 'partyA', - // component: 'Input', - // label: '甲方', - // rules: [{ required: true, type: 'string' }], - // colProps: { - // span: 12, - // }, - // }, - // { - // field: 'partyB', - // component: 'Input', - // label: '乙方', - // rules: [{ required: true, type: 'string' }], - // colProps: { - // span: 12, - // }, - // }, - // { - // field: 'signingDate', - // label: '签订时间', - // component: 'DatePicker', - // // defaultValue: new Date(), - // colProps: { span: 12 }, - // componentProps: {}, - // }, - // { - // field: 'deliveryDeadline', - // label: '交付期限', - // component: 'DatePicker', - // // defaultValue: new Date(), - // colProps: { span: 12 }, - // }, - // { - // field: 'type', - // label: '合同类型', - // component: 'Select', - // required: true, - // colProps: { - // span: 12, - // }, - // componentProps: { - // options: contractTypes.map(({ label, id }) => ({ value: id, label })), - // }, - // }, - // { - // field: 'status', - // label: '审核结果', - // component: 'Select', - // required:true, - // defaultValue: 0, - // colProps: { - // span: 12, - // }, - // componentProps: { - // allowClear: false, - // options: Object.values(ContractStatusEnum) - // .filter((value) => typeof value === 'number') - // .map((item) => formatStatus(item as ContractStatusEnum)), - // }, - // }, - // { - // field: 'remark', - // component: 'InputTextArea', - // label: '备注', - // }, - // { - // field: 'menuIds', - // component: 'Tree', - // label: '菜单权限', - // componentProps: { - // checkable: true, - // vModelKey: 'checkedKeys', - // fieldNames: { - // label: 'name', - // key: 'id', - // }, - // style: { - // height: '350px', - // paddingTop: '5px', - // overflow: 'auto', - // borderRadius: '6px', - // border: '1px solid #dcdfe6', - // resize: 'vertical', - // }, - // }, - // }, ]; const getProductOptions = async (keyword?: string): Promise => { @@ -244,12 +208,16 @@ const getProductOptions = async (keyword?: string): Promise = ); }; -const getCompanyOptions = async ({ keyword, id }): Promise => { - const { items: result } = await Api.company.companyList({ pageSize: 100, name: keyword }); +const getInventoryNumberOptions = async (inventoryNumber?: string): Promise => { + const { items: result } = await Api.materialsInOut.materialsInOutList({ + inventoryNumber, + isCreateOut: true, + pageSize: 100, + }); return ( result?.map((item) => ({ - label: item.name, - value: item.id, + label: item.inventoryNumber, + value: item.inventoryNumber, })) || [] ); }; diff --git a/src/views/materials-inventory/in-out/index.vue b/src/views/materials-inventory/in-out/index.vue index 9d0f6a6..93d3172 100644 --- a/src/views/materials-inventory/in-out/index.vue +++ b/src/views/materials-inventory/in-out/index.vue @@ -18,6 +18,13 @@ > 新增 + + 导出原材料盘点表 + @@ -25,11 +32,16 @@