feat: 出入库模块完善
This commit is contained in:
parent
989cbfc69a
commit
8bcae5be3f
|
@ -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;
|
||||
/** 产品信息 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<TableListItem>;
|
||||
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: '经办人',
|
||||
|
|
|
@ -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<API.MaterialsInOutEntity>[] = [
|
||||
export const formSchemas = (isEdit?: boolean): FormSchema<API.MaterialsInOutEntity>[] => [
|
||||
{
|
||||
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<API.MaterialsInOutEntity>[] = [
|
|||
componentProps: ({ formInstance, schema, formModel }) => ({
|
||||
showSearch: true,
|
||||
filterOption: false,
|
||||
disabled: isEdit,
|
||||
fieldNames: {
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
|
@ -56,24 +134,6 @@ export const formSchemas: FormSchema<API.MaterialsInOutEntity>[] = [
|
|||
}, 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<API.MaterialsInOutEntity>[] = [
|
|||
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<LabelValueOptions> => {
|
||||
|
@ -244,12 +208,16 @@ const getProductOptions = async (keyword?: string): Promise<LabelValueOptions> =
|
|||
);
|
||||
};
|
||||
|
||||
const getCompanyOptions = async ({ keyword, id }): Promise<LabelValueOptions> => {
|
||||
const { items: result } = await Api.company.companyList({ pageSize: 100, name: keyword });
|
||||
const getInventoryNumberOptions = async (inventoryNumber?: string): Promise<LabelValueOptions> => {
|
||||
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,
|
||||
})) || []
|
||||
);
|
||||
};
|
||||
|
|
|
@ -18,6 +18,13 @@
|
|||
>
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
:disabled="!$auth('materials_inventory:history_in_out:export')"
|
||||
@click="exportMI()"
|
||||
>
|
||||
导出原材料盘点表
|
||||
</a-button>
|
||||
</template>
|
||||
</DynamicTable>
|
||||
</div>
|
||||
|
@ -25,11 +32,16 @@
|
|||
|
||||
<script setup lang="tsx">
|
||||
import { useTable } from '@/components/core/dynamic-table';
|
||||
import { baseColumns, type TableColumnItem, type TableListItem } from './columns';
|
||||
import {
|
||||
baseColumns,
|
||||
type TableColumnItem,
|
||||
type TableListItem,
|
||||
type TableQueryItem,
|
||||
} from './columns';
|
||||
import Api from '@/api/';
|
||||
import { onMounted, ref, type FunctionalComponent } from 'vue';
|
||||
import { onMounted, ref, type FunctionalComponent, unref } from 'vue';
|
||||
import { useFormModal, useModal } from '@/hooks/useModal';
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { Button, message } 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';
|
||||
|
@ -47,8 +59,8 @@
|
|||
...baseColumns,
|
||||
{
|
||||
title: '附件',
|
||||
width: 50,
|
||||
maxWidth: 50,
|
||||
width: 40,
|
||||
maxWidth: 40,
|
||||
hideInSearch: true,
|
||||
fixed: 'right',
|
||||
dataIndex: 'files',
|
||||
|
@ -91,7 +103,15 @@
|
|||
},
|
||||
];
|
||||
});
|
||||
|
||||
const exportMI = async () => {
|
||||
const { time } = unref<TableQueryItem>(
|
||||
dynamicTableInstance?.queryFormRef?.formModel as TableQueryItem,
|
||||
);
|
||||
if (!time) {
|
||||
message.warn('请先在查询区选择导出月份时间');
|
||||
}
|
||||
console.log('exportMI');
|
||||
};
|
||||
const openAttachmentUploadModal = async (record: TableListItem) => {
|
||||
isUploadPopupVisiable.value = true;
|
||||
fnModal.show({
|
||||
|
@ -133,6 +153,7 @@
|
|||
const openEditModal = async (record: Partial<TableListItem>) => {
|
||||
const [formRef] = await showModal({
|
||||
modalProps: {
|
||||
|
||||
title: `${record.id ? '编辑' : '新增'}出入库记录`,
|
||||
width: '50%',
|
||||
onFinish: async (values) => {
|
||||
|
@ -154,7 +175,7 @@
|
|||
},
|
||||
formProps: {
|
||||
labelWidth: 100,
|
||||
schemas: formSchemas,
|
||||
schemas: formSchemas(!!record.id),
|
||||
},
|
||||
});
|
||||
// 如果是编辑的话,需要获取详情
|
||||
|
|
Loading…
Reference in New Issue