diff --git a/src/views/products/Detail/ProductInfo.jsx b/src/views/products/Detail/ProductInfo.jsx index 87f148e..4065ef5 100644 --- a/src/views/products/Detail/ProductInfo.jsx +++ b/src/views/products/Detail/ProductInfo.jsx @@ -42,7 +42,7 @@ const ProductInfo = ({ ...props }) => { values.travel_agency_id = activeAgency.travel_agency_id; const copyNewProduct = structuredClone(newProductRecord); const poster = { - 'audit_state': '-1', + ...(topPerm ? {} : {'audit_state': '-1',}), // 高级权限: 不变更状态值 // "create_date": dayjs().format('YYYY-MM-DD HH:mm:ss'), // "created_by": userId, 'travel_agency_id': activeAgency.travel_agency_id, diff --git a/src/views/products/Detail/ProductInfoForm.jsx b/src/views/products/Detail/ProductInfoForm.jsx index c0fefe6..a35c483 100644 --- a/src/views/products/Detail/ProductInfoForm.jsx +++ b/src/views/products/Detail/ProductInfoForm.jsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { Form, Input, Row, Col, Select, Button, InputNumber, Checkbox } from 'antd'; +import { App, Form, Input, Row, Col, Select, Button, InputNumber, Checkbox } from 'antd'; import { objectMapper, isEmpty, isNotEmpty } from '@/utils/commons'; import { useTranslation } from 'react-i18next'; import { useWeekdays } from '@/hooks/useDatePresets'; @@ -12,6 +12,7 @@ import ProductInfoQuotation from './ProductInfoQuotation'; import { useHTLanguageSetsMapVal } from '@/hooks/useHTLanguageSets'; const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, showSubmit, confirmText, formName, ...props }) => { + const { notification } = App.useApp(); const { t } = useTranslation('products'); const HTLanguageSetsMapVal = useHTLanguageSetsMapVal(); const [loading, editingProduct] = useProductsStore((state) => [state.loading, state.editingProduct]); @@ -31,7 +32,7 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show const [editable, setEditable] = useState(true); useEffect(() => { form.resetFields(); - form.setFieldValue('city', { value: editingProduct?.info?.city_id, label: editingProduct?.info?.city_name }); + form.setFieldValue('city', editingProduct?.info?.city_id ? { value: editingProduct?.info?.city_id, label: editingProduct?.info?.city_name } : undefined); form.setFieldValue('dept', { value: editingProduct?.info?.dept_id, label: editingProduct?.info?.dept_name }); const lgc_details_mapped = (editingProduct?.lgc_details || []).reduce((r, c) => ({ ...r, [c.lgc]: c }), {}); form.setFieldValue('lgc_details_mapped', lgc_details_mapped); @@ -53,6 +54,12 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show const onFinishFailed = ({ values, errorFields }) => { console.log('form validate failed', '\nform values:', values, '\nerrorFields', errorFields); + notification.warning({ + message: '数据未填写完整', + // description: '数据未填写完整', + placement: 'top', + duration: 4, + }) }; const handleReset = () => { @@ -84,7 +91,7 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show onValuesChange={onIValuesChange} // onFieldsChange={onFieldsChange} initialValues={editingProduct?.info} - onFinishFailed={onFinishFailed}> + onFinishFailed={onFinishFailed} scrollToFirstError > {getFields({ sort, initialValue: editingProduct?.info, hides, shows, fieldProps, fieldComProps, form, t, dataSets: { weekdays }, editable })} {/* {showSubmit && ( @@ -196,8 +203,8 @@ function getFields(props) { item( 'city', 99, - - + + , fieldProps?.city?.col || midCol ), @@ -212,7 +219,7 @@ function getFields(props) { item( 'duration', 99, - + {/* */} , @@ -221,8 +228,8 @@ function getFields(props) { item( 'km', 99, - - + + , fieldProps?.km?.col || midCol ), @@ -297,7 +304,7 @@ function getFields(props) { 'remarks', 99, - + , fieldProps?.remarks?.col || 24 ),