|
|
@ -14,7 +14,7 @@ import { HT_HOST } from '@/config';
|
|
|
|
// import SearchInput from './SearchInput';
|
|
|
|
// import SearchInput from './SearchInput';
|
|
|
|
// import AuditStateSelector from './AuditStateSelector';
|
|
|
|
// import AuditStateSelector from './AuditStateSelector';
|
|
|
|
import { useProductsTypesMapVal, useProductsTypesFieldsets } from '@/hooks/useProductsSets';
|
|
|
|
import { useProductsTypesMapVal, useProductsTypesFieldsets } from '@/hooks/useProductsSets';
|
|
|
|
import useProductsStore from '@/stores/Products/Index';
|
|
|
|
import useProductsStore, { postProductsSaveAction } from '@/stores/Products/Index';
|
|
|
|
import ProductInfoLgc from './ProductInfoLgc';
|
|
|
|
import ProductInfoLgc from './ProductInfoLgc';
|
|
|
|
import ProductInfoQuotation from './ProductInfoQuotation';
|
|
|
|
import ProductInfoQuotation from './ProductInfoQuotation';
|
|
|
|
import useAuthStore from '@/stores/Auth';
|
|
|
|
import useAuthStore from '@/stores/Auth';
|
|
|
@ -22,10 +22,10 @@ import { PERM_PRODUCTS_MANAGEMENT, PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFE
|
|
|
|
|
|
|
|
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
|
|
|
|
|
|
|
|
const InfoForm = ({ onSubmit, onReset, onValuesChange, editable, showSubmit, confirmText, formName, loading, ...props }) => {
|
|
|
|
const InfoForm = ({ onSubmit, onReset, onValuesChange, editable, showSubmit, confirmText, formName, ...props }) => {
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
const isPermitted = useAuthStore((state) => state.isPermitted);
|
|
|
|
const isPermitted = useAuthStore((state) => state.isPermitted);
|
|
|
|
const [agencyProducts, editingProduct, setEditingProduct] = useProductsStore((state) => [state.agencyProducts, state.editingProduct, state.setEditingProduct]);
|
|
|
|
const [loading, setLoading, agencyProducts, editingProduct, setEditingProduct] = useProductsStore((state) => [state.loading, state.setLoading, state.agencyProducts, state.editingProduct, state.setEditingProduct]);
|
|
|
|
const weekdays = useWeekdays();
|
|
|
|
const weekdays = useWeekdays();
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
const { sort, hides, fieldProps, fieldComProps } = {
|
|
|
|
const { sort, hides, fieldProps, fieldComProps } = {
|
|
|
@ -50,16 +50,15 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable, showSubmit, con
|
|
|
|
}, [editingProduct?.info?.id]);
|
|
|
|
}, [editingProduct?.info?.id]);
|
|
|
|
|
|
|
|
|
|
|
|
const topPerm = isPermitted(PERM_PRODUCTS_OFFER_AUDIT);
|
|
|
|
const topPerm = isPermitted(PERM_PRODUCTS_OFFER_AUDIT);
|
|
|
|
const isNew = isEmpty(editingProduct?.info?.id);
|
|
|
|
const isNew = isEmpty(editingProduct?.info?.id) || editable;
|
|
|
|
const ignoreEditable = topPerm || isNew;
|
|
|
|
const ignoreEditable = topPerm || isNew;
|
|
|
|
|
|
|
|
|
|
|
|
const onFinish = (values) => {
|
|
|
|
const onFinish = (values) => {
|
|
|
|
console.log('Received values of form, origin form value: \n', values);
|
|
|
|
console.log('Received values of form, origin form value: \n', values);
|
|
|
|
const dest = formValuesMapper(values);
|
|
|
|
const dest = formValuesMapper(values);
|
|
|
|
console.log('form value send to onSubmit:\n', dest);
|
|
|
|
console.log('form value send to onSubmit:\n', dest);
|
|
|
|
const str = new URLSearchParams(dest).toString();
|
|
|
|
|
|
|
|
if (typeof onSubmit === 'function') {
|
|
|
|
if (typeof onSubmit === 'function') {
|
|
|
|
onSubmit(null, dest, values, str);
|
|
|
|
onSubmit(null, dest, values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -120,7 +119,8 @@ function getFields(props) {
|
|
|
|
// console.log('getFields', props.initialValue);
|
|
|
|
// console.log('getFields', props.initialValue);
|
|
|
|
const styleProps = {};
|
|
|
|
const styleProps = {};
|
|
|
|
const editableProps = (name) => {
|
|
|
|
const editableProps = (name) => {
|
|
|
|
const disabled = props.ignoreEditable ? false : (isEmpty(props.initialValue?.[name]) && props.editable ? false : true)
|
|
|
|
// const disabled = props.ignoreEditable ? false : (isEmpty(props.initialValue?.[name]) && props.editable ? false : true)
|
|
|
|
|
|
|
|
const disabled = !props.editable;
|
|
|
|
return { disabled, className: disabled ? '!text-slate-500' : '' };
|
|
|
|
return { disabled, className: disabled ? '!text-slate-500' : '' };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const bigCol = 4 * 2;
|
|
|
|
const bigCol = 4 * 2;
|
|
|
@ -194,7 +194,7 @@ function getFields(props) {
|
|
|
|
{/* <Input placeholder={t('RecommendsRate')} allowClear /> */}
|
|
|
|
{/* <Input placeholder={t('RecommendsRate')} allowClear /> */}
|
|
|
|
<Select {...styleProps} {...editableProps('recommends_rate')}
|
|
|
|
<Select {...styleProps} {...editableProps('recommends_rate')}
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
labelInValue
|
|
|
|
labelInValue={false}
|
|
|
|
options={[
|
|
|
|
options={[
|
|
|
|
{ value: '1', label: 'Top 1' },
|
|
|
|
{ value: '1', label: 'Top 1' },
|
|
|
|
{ value: '2', label: '2' },
|
|
|
|
{ value: '2', label: '2' },
|
|
|
|