|
|
@ -1,5 +1,5 @@
|
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
import { App, Form, Modal, DatePicker, Divider } from 'antd';
|
|
|
|
import { App, Form, Modal, DatePicker, Divider, Switch } from 'antd';
|
|
|
|
import { isEmpty, objectMapper } from '@/utils/commons';
|
|
|
|
import { isEmpty, objectMapper } from '@/utils/commons';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
|
|
|
@ -29,7 +29,7 @@ export const CopyProductsForm = ({ action, initialValues, onFormInstanceReady, s
|
|
|
|
|
|
|
|
|
|
|
|
const onValuesChange = (changeValues, allValues) => {};
|
|
|
|
const onValuesChange = (changeValues, allValues) => {};
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Form layout='horizontal' form={form} name='form_in_modal' initialValues={initialValues} onValuesChange={onValuesChange}>
|
|
|
|
<Form layout='horizontal' form={form} name='form_in_modal' initialValues={initialValues} onValuesChange={onValuesChange} >
|
|
|
|
{action === '#' && <Form.Item name='agency' label={`${t('products:CopyFormMsg.target')}${t('products:Vendor')}`} rules={[{ required: true, message: t('products:CopyFormMsg.requiredVendor') }]}>
|
|
|
|
{action === '#' && <Form.Item name='agency' label={`${t('products:CopyFormMsg.target')}${t('products:Vendor')}`} rules={[{ required: true, message: t('products:CopyFormMsg.requiredVendor') }]}>
|
|
|
|
<SearchInput
|
|
|
|
<SearchInput
|
|
|
|
placeholder={t('products:Vendor')}
|
|
|
|
placeholder={t('products:Vendor')}
|
|
|
@ -39,7 +39,7 @@ export const CopyProductsForm = ({ action, initialValues, onFormInstanceReady, s
|
|
|
|
map={{ travel_agency_name: 'label', travel_agency_id: 'value' }}
|
|
|
|
map={{ travel_agency_name: 'label', travel_agency_id: 'value' }}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Form.Item>}
|
|
|
|
</Form.Item>}
|
|
|
|
<Form.Item name={`products_types`} label={t('products:ProductType')}>
|
|
|
|
<Form.Item name={`products_types`} label={t('products:ProductType')} >
|
|
|
|
<ProductsTypesSelector maxTagCount={1} mode={'multiple'} placeholder={t('All')} />
|
|
|
|
<ProductsTypesSelector maxTagCount={1} mode={'multiple'} placeholder={t('All')} />
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
{action === '#' && <RequireAuth subject={PERM_PRODUCTS_MANAGEMENT}>
|
|
|
|
{action === '#' && <RequireAuth subject={PERM_PRODUCTS_MANAGEMENT}>
|
|
|
@ -47,11 +47,15 @@ export const CopyProductsForm = ({ action, initialValues, onFormInstanceReady, s
|
|
|
|
<DeptSelector isLeaf={true} />
|
|
|
|
<DeptSelector isLeaf={true} />
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
</RequireAuth>}
|
|
|
|
</RequireAuth>}
|
|
|
|
<Form.Item name={'source_use_year'} label={`${t('products:CopyFormMsg.Source')}${t('products:UseYear')}`} initialValue={dayjs([source.sourceYear, 1, 1])}>
|
|
|
|
<Form.Item name={'source_use_year'} label={`${t('products:CopyFormMsg.Source')}${t('products:UseYear')}`} initialValue={dayjs([source.sourceYear, 1, 1])} rules={[{ required: true,}]}>
|
|
|
|
<DatePicker picker='year' allowClear />
|
|
|
|
<DatePicker picker='year' allowClear />
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item name={'target_use_year'} label={`${t('products:CopyFormMsg.target')}${t('products:UseYear')}`}>
|
|
|
|
<Form.Item name={'target_use_year'} label={`${t('products:CopyFormMsg.target')}${t('products:UseYear')}`} rules={[{ required: true,}]}>
|
|
|
|
<DatePicker picker='year' allowClear disabledDate={(current) => current <= dayjs([source.sourceYear, 12, 31])} />
|
|
|
|
<DatePicker picker='year' allowClear />
|
|
|
|
|
|
|
|
{/* disabledDate={(current) => current <= dayjs([source.sourceYear, 12, 31])} */}
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
<Form.Item name={'with_quote'} label={`${t('products:CopyFormMsg.withQuote')}`}>
|
|
|
|
|
|
|
|
<Switch checkedChildren={t('Yes')} unCheckedChildren={t('No')} />
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -69,7 +73,7 @@ const formValuesMapper = (values) => {
|
|
|
|
'products_types': {
|
|
|
|
'products_types': {
|
|
|
|
key: 'products_types',
|
|
|
|
key: 'products_types',
|
|
|
|
transform: (value) => {
|
|
|
|
transform: (value) => {
|
|
|
|
return Array.isArray(value) ? value.map((ele) => ele.key).join(',') : value ? value.value : '';
|
|
|
|
return Array.isArray(value) ? value.map((ele) => ele.key).join(',') : value ? value.value : '-1';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'dept': {
|
|
|
|
'dept': {
|
|
|
@ -78,6 +82,7 @@ const formValuesMapper = (values) => {
|
|
|
|
return Array.isArray(value) ? value.map((ele) => ele.key).join(',') : value ? value.value : '';
|
|
|
|
return Array.isArray(value) ? value.map((ele) => ele.key).join(',') : value ? value.value : '';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'with_quote': { key: 'with_quote', transform: (value) => (value ? 1 : 0) },
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let dest = {};
|
|
|
|
let dest = {};
|
|
|
|
const { agency, year, ...omittedValue } = values;
|
|
|
|
const { agency, year, ...omittedValue } = values;
|
|
|
|