feat: temp barcode templates
This commit is contained in:
@@ -9,6 +9,7 @@ export type { OpenAPIConfig } from './core/OpenAPI';
|
|||||||
|
|
||||||
export type { AuthLoginRequest } from './models/AuthLoginRequest';
|
export type { AuthLoginRequest } from './models/AuthLoginRequest';
|
||||||
export type { AuthLoginResponse } from './models/AuthLoginResponse';
|
export type { AuthLoginResponse } from './models/AuthLoginResponse';
|
||||||
|
export type { BarcodeTemplateAdditionalAttributeSchema } from './models/BarcodeTemplateAdditionalAttributeSchema';
|
||||||
export type { BarcodeTemplateAttributeSchema } from './models/BarcodeTemplateAttributeSchema';
|
export type { BarcodeTemplateAttributeSchema } from './models/BarcodeTemplateAttributeSchema';
|
||||||
export type { BarcodeTemplateCreateRequest } from './models/BarcodeTemplateCreateRequest';
|
export type { BarcodeTemplateCreateRequest } from './models/BarcodeTemplateCreateRequest';
|
||||||
export type { BarcodeTemplateCreateResponse } from './models/BarcodeTemplateCreateResponse';
|
export type { BarcodeTemplateCreateResponse } from './models/BarcodeTemplateCreateResponse';
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/* generated using openapi-typescript-codegen -- do no edit */
|
||||||
|
/* istanbul ignore file */
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
export type BarcodeTemplateAdditionalAttributeSchema = {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
@@ -2,11 +2,13 @@
|
|||||||
/* istanbul ignore file */
|
/* istanbul ignore file */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
import type { BarcodeTemplateAdditionalAttributeSchema } from './BarcodeTemplateAdditionalAttributeSchema';
|
||||||
export type BarcodeTemplateCreateRequest = {
|
export type BarcodeTemplateCreateRequest = {
|
||||||
name: string;
|
name: string;
|
||||||
isDefault: boolean;
|
isDefault: boolean;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
|
additionalAttributes: Array<BarcodeTemplateAdditionalAttributeSchema>;
|
||||||
attributeIds: Array<number>;
|
attributeIds: Array<number>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
/* istanbul ignore file */
|
/* istanbul ignore file */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
import type { BarcodeTemplateAdditionalAttributeSchema } from './BarcodeTemplateAdditionalAttributeSchema';
|
||||||
import type { BarcodeTemplateAttributeSchema } from './BarcodeTemplateAttributeSchema';
|
import type { BarcodeTemplateAttributeSchema } from './BarcodeTemplateAttributeSchema';
|
||||||
export type BarcodeTemplateSchema = {
|
export type BarcodeTemplateSchema = {
|
||||||
name: string;
|
name: string;
|
||||||
isDefault: boolean;
|
isDefault: boolean;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
|
additionalAttributes: Array<BarcodeTemplateAdditionalAttributeSchema>;
|
||||||
id: number;
|
id: number;
|
||||||
attributes: Array<BarcodeTemplateAttributeSchema>;
|
attributes: Array<BarcodeTemplateAttributeSchema>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
/* istanbul ignore file */
|
/* istanbul ignore file */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
import type { BarcodeTemplateAdditionalAttributeSchema } from './BarcodeTemplateAdditionalAttributeSchema';
|
||||||
export type BarcodeTemplateUpdateRequest = {
|
export type BarcodeTemplateUpdateRequest = {
|
||||||
name: string;
|
name: string;
|
||||||
isDefault: boolean;
|
isDefault: boolean;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
|
additionalAttributes: Array<BarcodeTemplateAdditionalAttributeSchema>;
|
||||||
id: number;
|
id: number;
|
||||||
attributeIds: Array<number>;
|
attributeIds: Array<number>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
/* istanbul ignore file */
|
/* istanbul ignore file */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
import type { BarcodeTemplateSchema } from './BarcodeTemplateSchema';
|
||||||
export type ProductCreateRequest = {
|
export type ProductCreateRequest = {
|
||||||
name: string;
|
name: string;
|
||||||
article: string;
|
article: string;
|
||||||
clientId: number;
|
clientId: number;
|
||||||
barcodes: Array<string>;
|
barcodes: Array<string>;
|
||||||
|
barcodeTemplate?: (BarcodeTemplateSchema | null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
/* istanbul ignore file */
|
/* istanbul ignore file */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
import type { BarcodeTemplateSchema } from './BarcodeTemplateSchema';
|
||||||
export type ProductSchema = {
|
export type ProductSchema = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
article: string;
|
article: string;
|
||||||
clientId: number;
|
clientId: number;
|
||||||
barcodes: Array<string>;
|
barcodes: Array<string>;
|
||||||
|
barcodeTemplate?: (BarcodeTemplateSchema | null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,75 @@
|
|||||||
import {GetInputProps} from "@mantine/form/lib/types";
|
import {FC, useEffect, useState} from "react";
|
||||||
import {FC} from "react";
|
import {ActionIcon, Button, Flex, rem, TextInput} from "@mantine/core";
|
||||||
|
import {BarcodeTemplateAdditionalAttributeSchema} from "../../../../client";
|
||||||
type Props = GetInputProps<Array<{ name:string,value:string }>>
|
import {IconX} from "@tabler/icons-react";
|
||||||
const BarcodeTemplateAdditionalFieldTable:FC<Props> = (props:Props) => {
|
import {isEqual} from "lodash";
|
||||||
|
|
||||||
|
type FieldType = BarcodeTemplateAdditionalAttributeSchema;
|
||||||
|
type Props = {
|
||||||
|
onChange: (value: FieldType[]) => void;
|
||||||
|
value?: FieldType[];
|
||||||
|
error?: string | null;
|
||||||
}
|
}
|
||||||
|
const BarcodeTemplateAdditionalFieldTable: FC<Props> = (props: Props) => {
|
||||||
|
const {value, onChange} = props;
|
||||||
|
const [innerValue, setInnerValue] = useState<FieldType[]>(props.value || []);
|
||||||
|
console.log(innerValue);
|
||||||
|
const onNameChange = (field: FieldType, newName: string) => {
|
||||||
|
const newField = {...field, name: newName};
|
||||||
|
const newFields = innerValue.map(f => f === field ? newField : f);
|
||||||
|
setInnerValue(newFields);
|
||||||
|
onChange(newFields);
|
||||||
|
}
|
||||||
|
const onValueChange = (field: FieldType, newValue: string) => {
|
||||||
|
const newField = {...field, value: newValue};
|
||||||
|
const newFields = innerValue.map(f => f === field ? newField : f);
|
||||||
|
setInnerValue(newFields);
|
||||||
|
onChange(newFields);
|
||||||
|
}
|
||||||
|
const onCreateField = () => {
|
||||||
|
const newField = {name: "", value: ""};
|
||||||
|
setInnerValue([...innerValue, newField]);
|
||||||
|
onChange([...innerValue, newField]);
|
||||||
|
}
|
||||||
|
const onDeleteField = (field: FieldType) => {
|
||||||
|
const newFields = innerValue.filter(f => f !== field);
|
||||||
|
setInnerValue(newFields);
|
||||||
|
onChange(newFields);
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
if (isEqual(value, innerValue)) return;
|
||||||
|
setInnerValue(value || []);
|
||||||
|
}, [value]);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Flex
|
||||||
|
direction={"column"}
|
||||||
|
gap={rem(10)}
|
||||||
|
>
|
||||||
|
{/*{innerValue.length === 0 && <Text>Дополнительных полей нет</Text>}*/}
|
||||||
|
{innerValue.map((field, idx) => (
|
||||||
|
<Flex align={"center"} gap={rem(10)} key={idx}>
|
||||||
|
<ActionIcon onClick={() => onDeleteField(field)} variant={"default"}>
|
||||||
|
<IconX/>
|
||||||
|
</ActionIcon>
|
||||||
|
<TextInput
|
||||||
|
placeholder={"Название атрибута"}
|
||||||
|
value={field.name}
|
||||||
|
onChange={event => event &&
|
||||||
|
onNameChange(field, event.target.value)}/>
|
||||||
|
<TextInput
|
||||||
|
placeholder={"Значение атрибута"}
|
||||||
|
value={field.value}
|
||||||
|
onChange={event => event &&
|
||||||
|
onValueChange(field, event.target.value)}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
<Button variant={"default"} onClick={onCreateField}>Создать дополительный атрибут</Button>
|
||||||
|
</Flex>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BarcodeTemplateAdditionalFieldTable;
|
||||||
@@ -1,11 +1,17 @@
|
|||||||
import BaseFormModal, {CreateEditFormProps} from "../../../ClientsPage/modals/BaseFormModal/BaseFormModal.tsx";
|
import BaseFormModal, {CreateEditFormProps} from "../../../ClientsPage/modals/BaseFormModal/BaseFormModal.tsx";
|
||||||
import {BarcodeTemplateAttributeSchema, BarcodeTemplateSchema} from "../../../../client";
|
import {
|
||||||
|
BarcodeTemplateAdditionalAttributeSchema,
|
||||||
|
BarcodeTemplateAttributeSchema,
|
||||||
|
BarcodeTemplateSchema
|
||||||
|
} from "../../../../client";
|
||||||
import {ContextModalProps} from "@mantine/modals";
|
import {ContextModalProps} from "@mantine/modals";
|
||||||
import {useForm} from "@mantine/form";
|
import {useForm} from "@mantine/form";
|
||||||
import {Checkbox, Fieldset, Flex, NumberInput, rem, TextInput} from "@mantine/core";
|
import {Checkbox, Fieldset, Flex, NumberInput, rem, TextInput} from "@mantine/core";
|
||||||
import {IconX} from "@tabler/icons-react";
|
import {IconX} from "@tabler/icons-react";
|
||||||
import BarcodeTemplateAttributeMultiselect
|
import BarcodeTemplateAttributeMultiselect
|
||||||
from "../../components/BarcodeTemplateAttributeMultiselect/BarcodeTemplateAttributeMultiselect.tsx";
|
from "../../components/BarcodeTemplateAttributeMultiselect/BarcodeTemplateAttributeMultiselect.tsx";
|
||||||
|
import BarcodeTemplateAdditionalFieldTable
|
||||||
|
from "../../components/BarcodeTemplateAdditionalFieldTable/BarcodeTemplateAdditionalFieldTable.tsx";
|
||||||
|
|
||||||
type Props = CreateEditFormProps<BarcodeTemplateSchema>
|
type Props = CreateEditFormProps<BarcodeTemplateSchema>
|
||||||
const BarcodeTemplateFormModal = ({
|
const BarcodeTemplateFormModal = ({
|
||||||
@@ -19,7 +25,8 @@ const BarcodeTemplateFormModal = ({
|
|||||||
width: undefined,
|
width: undefined,
|
||||||
height: undefined,
|
height: undefined,
|
||||||
isDefault: false,
|
isDefault: false,
|
||||||
attributes: [] as Array<BarcodeTemplateAttributeSchema>
|
attributes: [] as Array<BarcodeTemplateAttributeSchema>,
|
||||||
|
additionalAttributes: [] as Array<BarcodeTemplateAdditionalAttributeSchema>
|
||||||
} as Partial<BarcodeTemplateSchema>;
|
} as Partial<BarcodeTemplateSchema>;
|
||||||
const form = useForm<Partial<BarcodeTemplateSchema>>({
|
const form = useForm<Partial<BarcodeTemplateSchema>>({
|
||||||
initialValues: initialValues,
|
initialValues: initialValues,
|
||||||
@@ -30,7 +37,7 @@ const BarcodeTemplateFormModal = ({
|
|||||||
name: (name: string | undefined) => name && name.trim() !== '' ? null : "Необходимо ввести название шаблона",
|
name: (name: string | undefined) => name && name.trim() !== '' ? null : "Необходимо ввести название шаблона",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
console.log(form.values.additionalAttributes);
|
||||||
return (
|
return (
|
||||||
<BaseFormModal
|
<BaseFormModal
|
||||||
{...innerProps}
|
{...innerProps}
|
||||||
@@ -64,10 +71,13 @@ const BarcodeTemplateFormModal = ({
|
|||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
<BarcodeTemplateAttributeMultiselect
|
<BarcodeTemplateAttributeMultiselect
|
||||||
label={"Атрибуты"}
|
label={"Стандартные атрибуты"}
|
||||||
placeholder={!form.values.attributes?.length ? "Выберите атрибуты" : undefined}
|
placeholder={!form.values.attributes?.length ? "Выберите атрибуты" : undefined}
|
||||||
{...form.getInputProps('attributes')}
|
{...form.getInputProps('attributes')}
|
||||||
/>
|
/>
|
||||||
|
<BarcodeTemplateAdditionalFieldTable
|
||||||
|
{...form.getInputProps('additionalAttributes')}
|
||||||
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label={"Использовать как стандартный шаблон"}
|
label={"Использовать как стандартный шаблон"}
|
||||||
checked={form.getInputProps('isDefault').value as boolean}
|
checked={form.getInputProps('isDefault').value as boolean}
|
||||||
|
|||||||
@@ -34,7 +34,13 @@ export const useProductsTableColumns = () => {
|
|||||||
|
|
||||||
</List>
|
</List>
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
|
enableSorting: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "barcodeTemplate.name",
|
||||||
|
header: "Шаблон штрихкода",
|
||||||
|
enableSorting: false,
|
||||||
}
|
}
|
||||||
], []);
|
], []);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {Button, Flex, rem, TagsInput, TextInput} from "@mantine/core";
|
|||||||
import {useForm} from "@mantine/form";
|
import {useForm} from "@mantine/form";
|
||||||
import {BaseProduct, CreateProductRequest} from "../../types.ts";
|
import {BaseProduct, CreateProductRequest} from "../../types.ts";
|
||||||
import {ProductSchema} from "../../../../client";
|
import {ProductSchema} from "../../../../client";
|
||||||
|
import BarcodeTemplateSelect from "../../../../components/Selects/BarcodeTemplateSelect/BarcodeTemplateSelect.tsx";
|
||||||
|
|
||||||
type CreateProps = {
|
type CreateProps = {
|
||||||
clientId: number;
|
clientId: number;
|
||||||
@@ -26,7 +27,8 @@ const CreateProductModal = ({
|
|||||||
const initialValues = isEditProps ? {
|
const initialValues = isEditProps ? {
|
||||||
name: innerProps.product.name,
|
name: innerProps.product.name,
|
||||||
article: innerProps.product.article,
|
article: innerProps.product.article,
|
||||||
barcodes: innerProps.product.barcodes
|
barcodes: innerProps.product.barcodes,
|
||||||
|
barcodeTemplate: innerProps.product.barcodeTemplate
|
||||||
} : {
|
} : {
|
||||||
name: '',
|
name: '',
|
||||||
article: '',
|
article: '',
|
||||||
@@ -69,6 +71,11 @@ const CreateProductModal = ({
|
|||||||
label={"Штрихкоды"}
|
label={"Штрихкоды"}
|
||||||
{...form.getInputProps('barcodes')}
|
{...form.getInputProps('barcodes')}
|
||||||
/>
|
/>
|
||||||
|
<BarcodeTemplateSelect
|
||||||
|
placeholder={"Выберите шаблон штрихкода"}
|
||||||
|
label={"Шаблон штрихкода"}
|
||||||
|
{...form.getInputProps('barcodeTemplate')}
|
||||||
|
/>
|
||||||
<Flex justify={"flex-end"} mt={rem(5)} gap={rem(10)}>
|
<Flex justify={"flex-end"} mt={rem(5)} gap={rem(10)}>
|
||||||
<Button onClick={() => onCancelClick()} variant={"subtle"}>Отменить</Button>
|
<Button onClick={() => onCancelClick()} variant={"subtle"}>Отменить</Button>
|
||||||
{isEditProps ?
|
{isEditProps ?
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import {createLazyFileRoute} from "@tanstack/react-router";
|
import {createLazyFileRoute} from "@tanstack/react-router";
|
||||||
import {Fieldset, Flex, NumberInput} from "@mantine/core";
|
|
||||||
import {IconCross, IconX} from "@tabler/icons-react";
|
|
||||||
import {useEffect} from "react";
|
import {useEffect} from "react";
|
||||||
import {openContextModal} from "@mantine/modals";
|
import {openContextModal} from "@mantine/modals";
|
||||||
|
|
||||||
@@ -22,22 +20,6 @@ function TestPage() {
|
|||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Fieldset legend={"Размеры"}>
|
|
||||||
|
|
||||||
<Flex gap={10} align={"center"}>
|
|
||||||
|
|
||||||
<NumberInput
|
|
||||||
hideControls
|
|
||||||
placeholder={"Ширина"}
|
|
||||||
/>
|
|
||||||
<IconX/>
|
|
||||||
<NumberInput
|
|
||||||
hideControls
|
|
||||||
placeholder={"Высота"}
|
|
||||||
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
</Fieldset>
|
|
||||||
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user