|
|
|
@ -11,7 +11,7 @@ import ProductInfoLgc from './ProductInfoLgc';
|
|
|
|
|
import ProductInfoQuotation from './ProductInfoQuotation';
|
|
|
|
|
import { useHTLanguageSetsMapVal } from '@/hooks/useHTLanguageSets';
|
|
|
|
|
|
|
|
|
|
const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, showSubmit, confirmText, formName, ...props }) => {
|
|
|
|
|
const InfoForm = ({ onSubmit, onReset, onValuesChange, editablePerm, infoEditable, priceEditable, showSubmit, confirmText, formName, ...props }) => {
|
|
|
|
|
const { notification } = App.useApp();
|
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
|
const HTLanguageSetsMapVal = useHTLanguageSetsMapVal();
|
|
|
|
@ -29,7 +29,9 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show
|
|
|
|
|
const filedsets = useProductsTypesFieldsets(editingProduct?.info?.product_type_id);
|
|
|
|
|
const shows = filedsets[0];
|
|
|
|
|
|
|
|
|
|
const [editable, setEditable] = useState(true);
|
|
|
|
|
// const [editable, setEditable] = useState(true);
|
|
|
|
|
const [formEditable, setFormEditable] = useState(true);
|
|
|
|
|
const [showSave, setShowSave] = useState(true);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
form.resetFields();
|
|
|
|
|
form.setFieldValue('city', editingProduct?.info?.city_id ? { value: editingProduct?.info?.city_id, label: editingProduct?.info?.city_name } : undefined);
|
|
|
|
@ -38,10 +40,13 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show
|
|
|
|
|
form.setFieldValue('lgc_details_mapped', lgc_details_mapped);
|
|
|
|
|
form.setFieldValue('quotation', editingProduct?.quotation);
|
|
|
|
|
|
|
|
|
|
const editable0 = isEmpty(editingProduct) ? false : _editable; // 空对象未操作
|
|
|
|
|
setEditable(editable0);
|
|
|
|
|
setFormEditable(infoEditable || priceEditable);
|
|
|
|
|
|
|
|
|
|
const editable0 = isEmpty(editingProduct) ? false : editablePerm; // 空对象未操作
|
|
|
|
|
setShowSave(infoEditable || priceEditable);
|
|
|
|
|
// setEditable(editable0);
|
|
|
|
|
return () => {};
|
|
|
|
|
}, [editingProduct?.info?.id, _editable]);
|
|
|
|
|
}, [editingProduct?.info?.id, editablePerm, infoEditable, priceEditable]);
|
|
|
|
|
|
|
|
|
|
const onFinish = (values) => {
|
|
|
|
|
console.log('Received values of form, origin form value: \n', values);
|
|
|
|
@ -84,7 +89,7 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show
|
|
|
|
|
<>
|
|
|
|
|
<Form
|
|
|
|
|
form={form}
|
|
|
|
|
disabled={!editable}
|
|
|
|
|
disabled={!formEditable}
|
|
|
|
|
name={formName || 'product_info'}
|
|
|
|
|
// preserve={false}
|
|
|
|
|
onFinish={onFinish}
|
|
|
|
@ -93,7 +98,7 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show
|
|
|
|
|
initialValues={editingProduct?.info}
|
|
|
|
|
onFinishFailed={onFinishFailed} scrollToFirstError >
|
|
|
|
|
<Row>
|
|
|
|
|
{getFields({ sort, initialValue: editingProduct?.info, hides, shows, fieldProps, fieldComProps, form, t, dataSets: { weekdays }, editable })}
|
|
|
|
|
{getFields({ sort, initialValue: editingProduct?.info, hides, shows, fieldProps, fieldComProps, form, t, dataSets: { weekdays }, editable: infoEditable })}
|
|
|
|
|
{/* {showSubmit && (
|
|
|
|
|
<Col flex='1 0 90px' className='flex justify-end items-start'>
|
|
|
|
|
<Space align='center'>
|
|
|
|
@ -125,11 +130,11 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
]}>
|
|
|
|
|
<ProductInfoLgc editable={editable} formInstance={form} />
|
|
|
|
|
<ProductInfoLgc editable={infoEditable} formInstance={form} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item name='quotation'>
|
|
|
|
|
<ProductInfoQuotation editable={editable} />
|
|
|
|
|
<ProductInfoQuotation editable={priceEditable} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item hidden name={'id'} label={'ID'}>
|
|
|
|
@ -138,7 +143,7 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show
|
|
|
|
|
{/* <Form.Item hidden name={'title'} label={'title'}>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item> */}
|
|
|
|
|
{editable && (
|
|
|
|
|
{showSave && (
|
|
|
|
|
<Form.Item>
|
|
|
|
|
<div className='flex justify-around'>
|
|
|
|
|
<Button type='primary' htmlType='submit' loading={loading}>
|
|
|
|
|