From 1cb54dbb75d49866caa3a894a7a1b0ca292ebb0d Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 2 Aug 2024 15:33:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E5=90=84=E6=93=8D=E4=BD=9C=E6=9D=83=E9=99=90:=20=E6=9C=89=20`h?= =?UTF-8?q?tid`=20=E5=88=99=E4=B8=8D=E5=85=81=E8=AE=B8=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BF=A1=E6=81=AF;=20=E6=8F=90=E4=BA=A4=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useProductsSets.js | 3 +- src/stores/Products/Index.js | 24 ++- src/views/products/Audit.jsx | 5 +- src/views/products/Detail.jsx | 172 +----------------- src/views/products/Detail/Header.jsx | 38 +++- src/views/products/Detail/ProductInfo.jsx | 68 ++++--- src/views/products/Detail/ProductInfoForm.jsx | 85 +++++---- src/views/products/Detail/ProductInfoLgc.jsx | 11 +- 8 files changed, 154 insertions(+), 252 deletions(-) diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index 09dd303..8c588bf 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -131,6 +131,7 @@ export const useNewProductRecord = () => { return { info: { 'id': '', + 'htid': 0, 'title': '', 'code': '', 'product_type_id': '', @@ -138,7 +139,7 @@ export const useNewProductRecord = () => { 'remarks': '', 'duration': 0, 'duration_unit': 'h', - 'open_weekdays': '', + 'open_weekdays': ['1', '2', '3', '4', '5', '6', '7'], 'recommends_rate': 0, 'dept': '', 'dept_id': 0, diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index ccc4876..aa1e3ce 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -64,6 +64,9 @@ export const getAgencyProductExtrasAction = async (param) => { return errcode !== 0 ? [] : result; }; +/** + * 审核一条价格 + */ export const postProductsQuoteAuditAction = async (auditState, quoteRow) => { const postbody = { audit_state: auditState, @@ -79,22 +82,27 @@ export const postProductsQuoteAuditAction = async (auditState, quoteRow) => { // return errcode !== 0 ? {} : result; }; -export const postProductsAuditAction = async (auditState, infoRow) => { +/** + * 供应商提交审核 + */ +export const postAgencyAuditAction = async (travel_agency_id, use_year) => { const postbody = { - audit_state: auditState, - id: infoRow.id, - travel_agency_id: infoRow.travel_agency_id, + use_year, + travel_agency_id, }; const formData = new FormData(); Object.keys(postbody).forEach((key) => { formData.append(key, postbody[key]); }); - const json = await postForm(`${HT_HOST}/Service_BaseInfoWeb/travel-agency-products-audit`, formData); - return json; + const { errcode, result } = await postForm(`${HT_HOST}/Service_BaseInfoWeb/agency_submit`, formData); + return { errcode, result, success: errcode === 0 }; // const { errcode, result } = json; // return errcode !== 0 ? {} : result; }; +/** + * 保存一个产品 + */ export const postProductsSaveAction = async (products) => { const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_save`, products); return { errcode, result, success: errcode === 0 }; @@ -131,9 +139,9 @@ export const useProductsStore = create( setEditing: (editing) => set({ editing }), setSwitchParams: (switchParams) => set({ switchParams }), - newProduct: (productItem) => { + appendNewProduct: (productItem) => { const { setActiveAgency, agencyProducts, setAgencyProducts } = get(); - const typeGroup = agencyProducts[productItem.info.product_type_id]; + const typeGroup = agencyProducts[productItem.info.product_type_id] || []; const newIndex = typeGroup.findIndex((item) => item.info.id === productItem.info.id); if (newIndex !== -1) { typeGroup.splice(newIndex, 1, productItem); diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index a65d836..4498cb3 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -8,7 +8,7 @@ import useProductsStore, { postProductsQuoteAuditAction, } from '@/stores/Produc import { cloneDeep, isEmpty, isNotEmpty } from '@/utils/commons'; import useAuthStore from '@/stores/Auth'; import RequireAuth from '@/components/RequireAuth'; -import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; +import { PERM_PRODUCTS_MANAGEMENT, PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; import Header from './Detail/Header'; import dayjs from 'dayjs'; import { usingStorage } from '@/hooks/usingStorage'; @@ -163,6 +163,7 @@ const TypesPanels = (props) => { }; const Audit = ({ ...props }) => { + const isPermitted = useAuthStore(state => state.isPermitted); const { travel_agency_id, use_year, audit_state } = useParams(); const [loading, activeAgency, getAgencyProducts] = useProductsStore((state) => [state.loading, state.activeAgency, state.getAgencyProducts]); const { travelAgencyId } = usingStorage(); @@ -176,7 +177,7 @@ const Audit = ({ ...props }) => { return ( <> - }> + } > {/* */} diff --git a/src/views/products/Detail.jsx b/src/views/products/Detail.jsx index abc97a9..cdba40f 100644 --- a/src/views/products/Detail.jsx +++ b/src/views/products/Detail.jsx @@ -1,16 +1,13 @@ import { useState, useEffect } from 'react'; -import { message, Divider, Empty, Flex } from 'antd'; +import { Divider, Empty, Flex } from 'antd'; import { useNavigate } from 'react-router-dom'; -import Extras from './Detail/Extras'; import { isEmpty } from '@/utils/commons'; import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; import Header from './Detail/Header'; import { useParams } from 'react-router-dom'; import useProductsStore from '@/stores/Products/Index'; import dayjs from 'dayjs'; -import { HT_HOST } from '@/config'; -import { postForm } from '@/utils/request'; -import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; +import { PERM_PRODUCTS_MANAGEMENT } from '@/config'; import { usingStorage } from '@/hooks/usingStorage'; import ProductsTree from './Detail/ProductsTree'; import ProductInfo from './Detail/ProductInfo'; @@ -18,11 +15,9 @@ import useAuthStore from '@/stores/Auth'; import NewProductModal from './Detail/NewProductModal'; function Detail() { - // const { t } = useTranslation(); const navigate = useNavigate(); const { travel_agency_id, audit_state, use_year } = useParams(); const [addProductVisible, setAddProductVisible] = useState(false); - const [editingProduct, ] = useProductsStore((state) => [state.editingProduct]); const [agencyProducts, loading] = useProductsStore((state) => [state.agencyProducts, state.loading]); const [getAgencyProducts, activeAgency] = useProductsStore((state) => [state.getAgencyProducts, state.activeAgency]); const [setSwitchParams] = useProductsStore((state) => [state.setSwitchParams]); @@ -42,165 +37,16 @@ function Detail() { setSwitchParams(param); // setEditingProduct({}); getAgencyProducts(param); - // console.log("AgencyProducts",agencyProducts); - // navigate(`/products/${agency}/${year}/${audit_state}/edit`); }; - // useEffect(() => { - // editingProductQuotation(); - // }, [treeData, editingProduct]); - - // const editingProductQuotation = () => { - // console.log('editingProduct', editingProduct); - // const editingProductID = editingProduct.id; - // console.log('editingProductID', editingProductID); - // let stopProgram = false; - // for (const element of treeData) { - // if (stopProgram) { - // return; - // } - // const childList = element.children; - // for (const product of childList) { - // const childrenID = product.key.split('-')[1]; - // if (editingProductID == childrenID) { - // const fatherKey = product.key.split('-')[0]; - // setSelectedCategory(productProject[fatherKey]); - // stopProgram = true; - // const tempInfo = product._raw.info; - // const tempLgc_details = product._raw.lgc_details.find((record) => record.lgc === 2); - // console.log('tempLgc_details', tempLgc_details); - // const tempQuotation = product._raw.quotation; - // console.log({ - // info: tempInfo, - // lgc_details: { - // title: tempLgc_details.title, - // description: tempLgc_details.descriptions, - // }, - // }); - // setQuotation(tempQuotation); - // setTags([languageLabel]); - // setRemainderLanguage(HTLanguageSets.filter((item) => item.key !== language.toString())); - - // form.setFieldsValue({ - // info: tempInfo, - // lgc_details: { - // title: tempLgc_details.title, - // description: tempLgc_details.descriptions, - // }, - // }); - // break; - // } - // } - // } - // }; - const isPermitted = useAuthStore((state) => state.isPermitted); - const [editable, setEditable] = useState(true); + const topPerm = isPermitted(PERM_PRODUCTS_MANAGEMENT); // 高级权限 + const [newActionable, setNewActionable] = useState(false); useEffect(() => { const notAudit = activeAgency.audit_state_id < 0 || activeAgency.audit_state_id === 3; - const hasAuditPer = isPermitted(PERM_PRODUCTS_OFFER_AUDIT); - const hasEditPer = isPermitted(PERM_PRODUCTS_OFFER_PUT); - setEditable(hasAuditPer ? true : notAudit && hasEditPer); - // setEditable(true); // debug: 0 - // console.log('editable', hasAuditPer, (notAudit && hasEditPer)); + setNewActionable(topPerm || notAudit); return () => {}; - }, [activeAgency, editingProduct]); - - //保存产品 - // const onSave = async (values) => { - // let tempInfo; - // if (info.id === '') { - // tempInfo = { - // ...info, - // ...values.info, - // city_name: values.info.city_name.label, - // audit_state: '-1', - // }; - // delete tempInfo.product_type_name; - // delete tempInfo.dept_name; - - // let tempQuotation = quotation.map((element) => { - // const updateData = { - // ...element, - // audit_state: '-1', - // }; - // delete updateData.tempKey; - // return updateData; - // }); - // let tempLgc_details = [{ ...lgc_details }]; - // const tempData = { - // travel_agency_id, - // info: tempInfo, - // quotation: tempQuotation, - // lgc_details: Object.values(lgc_details), - // }; - // console.log('tempData', tempData); - - // const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_save`, tempData); - // console.log('result', result); - // if (errcode === 0) { - // message.success('保存成功'); - // } else { - // message.error(`保存失败: ${result}`); - // } - // return; - // } - - // tempInfo = { - // ...info, - // ...values.info, - // audit_state: '-1', - // }; - - // console.log('tempInfo', tempInfo); - - // let tempQuotation = quotation.map((element) => { - // const updateData = { - // ...element, - // audit_state: '-1', - // }; - // return updateData; - // }); - - // const tempData = { - // travel_agency_id, - // info: tempInfo, - // quotation: tempQuotation, - // lgc_details: Object.values(lgc_details), - // }; - - // console.log('tempData', tempData); - // // const { errcode, result } = await postProductsSave(tempData); - // const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_save`, tempData); - // if (errcode === 0) { - // message.success('保存成功'); - // } else { - // message.error(`保存失败: ${result}`); - // } - - // return; - // }; - - //提交审核方法 - const submitReview = async () => { - const formData = new FormData(); - formData.append('use_year', use_year); - formData.append('travel_agency_id', travel_agency_id); - try { - const { errcode, result } = await postForm(`${HT_HOST}/Service_BaseInfoWeb/agency_submit`, formData); - console.log('errcode', errcode); - if (errcode === 0) { - message.success('提交审核成功'); - navigate(`/products/${travel_agency_id}/${use_year}/${audit_state}/audit`); - } else { - message.error('提交审核失败'); - } - console.log('result', result); - } catch (error) { - console.error('提交审核请求失败', error); - message.error('提交审核请求失败'); - } - }; + }, [activeAgency]); return ( setAddProductVisible(true)} - handleSubmitForAudit={submitReview} - editable={editable} + newActionable={newActionable} /> }> {isEmpty(agencyProducts) ? ( @@ -224,8 +69,7 @@ function Detail() {
- - {!isEmpty(editingProduct) && } +
diff --git a/src/views/products/Detail/Header.jsx b/src/views/products/Detail/Header.jsx index 588af1d..9a2ba12 100644 --- a/src/views/products/Detail/Header.jsx +++ b/src/views/products/Detail/Header.jsx @@ -3,7 +3,7 @@ import { useParams, Link, useNavigate, useLocation } from 'react-router-dom'; import { App, Button, Divider, Select } from 'antd'; import { useProductsAuditStatesMapVal } from '@/hooks/useProductsSets'; import { useTranslation } from 'react-i18next'; -import useProductsStore, { postProductsQuoteAuditAction } from '@/stores/Products/Index'; +import useProductsStore, { postProductsQuoteAuditAction, postAgencyAuditAction } from '@/stores/Products/Index'; import { isEmpty } from '@/utils/commons'; import useAuthStore from '@/stores/Auth'; import RequireAuth from '@/components/RequireAuth'; @@ -12,15 +12,16 @@ import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; import dayjs from 'dayjs'; import VendorSelector from '@/components/VendorSelector'; import AuditStateSelector from '@/components/AuditStateSelector'; -const Header = ({ refresh, editable, ...props }) => { + +const Header = ({ refresh, newActionable, ...props }) => { const location = useLocation(); - console.log(location); const showEditA = !location.pathname.includes('edit'); const showAuditA = !location.pathname.includes('audit'); const { travel_agency_id, use_year, audit_state } = useParams(); const { t } = useTranslation(); const isPermitted = useAuthStore((state) => state.isPermitted); const [activeAgency, setActiveAgency] = useProductsStore((state) => [state.activeAgency, state.setActiveAgency]); + const [switchParams] = useProductsStore((state) => [state.switchParams]); const stateMapVal = useProductsAuditStatesMapVal(); const { message, notification } = App.useApp(); const navigate = useNavigate(); @@ -86,6 +87,33 @@ const Header = ({ refresh, editable, ...props }) => { }); }); }; + + const handleSubmitForAudit = () => { + postAgencyAuditAction(activeAgency.travel_agency_id, switchParams.use_year) + .then((json) => { + if (json.errcode === 0) { + message.success(t('Success')); + if (typeof refresh === 'function') { + refresh(param); + const auditPagePath = isPermitted(PERM_PRODUCTS_OFFER_AUDIT) + ? `/products/${activeAgency.travel_agency_id}/${switchParams.use_year}/all/audit` + : isPermitted(PERM_PRODUCTS_OFFER_PUT) + ? `/products/audit` + : ''; + navigate(auditPagePath); + } + } + }) + .catch((ex) => { + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + duration: 4, + }); + }); + }; + return (
@@ -141,7 +169,7 @@ const Header = ({ refresh, editable, ...props }) => { {/* 编辑 */} - {editable && ( + {newActionable && ( <> - diff --git a/src/views/products/Detail/ProductInfo.jsx b/src/views/products/Detail/ProductInfo.jsx index 26f85c6..f35b5c3 100644 --- a/src/views/products/Detail/ProductInfo.jsx +++ b/src/views/products/Detail/ProductInfo.jsx @@ -1,53 +1,68 @@ -import { createContext, useEffect, useState } from 'react'; -import { App, Breadcrumb, Form, Divider, Button, Input, Select, Row, Col } from 'antd'; +import { useEffect, useState } from 'react'; +import { App, Breadcrumb, Divider } from 'antd'; import { useTranslation } from 'react-i18next'; import { useProductsTypesMapVal, useNewProductRecord } from '@/hooks/useProductsSets'; import useProductsStore, { postProductsSaveAction } from '@/stores/Products/Index'; import useAuthStore from '@/stores/Auth'; -import RequireAuth from '@/components/RequireAuth'; -import { PERM_PRODUCTS_MANAGEMENT, PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT, } from '@/config'; -import DeptSelector from '@/components/DeptSelector'; -import CitySelector from '@/components/CitySelector'; -import { at, isEmpty, pick } from '@/utils/commons'; +import { PERM_PRODUCTS_MANAGEMENT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; +import { isEmpty, pick } from '@/utils/commons'; import ProductInfoForm from './ProductInfoForm'; -import dayjs from 'dayjs'; -import { usingStorage } from '@/hooks/usingStorage' +import { usingStorage } from '@/hooks/usingStorage'; +import Extras from './Extras'; -const ProductInfo = ({ editable, ...props }) => { +const ProductInfo = ({ ...props }) => { const { t } = useTranslation(); const { notification, message } = App.useApp(); - const { userId } = usingStorage() + const { userId } = usingStorage(); const isPermitted = useAuthStore((state) => state.isPermitted); const productsTypesMapVal = useProductsTypesMapVal(); const newProductRecord = useNewProductRecord(); - const [loading, setLoading, newProduct] = useProductsStore((state) => [state.loading, state.setLoading, state.newProduct]); - const [activeAgency, agencyProducts, editingProduct, setEditingProduct] = useProductsStore((state) => [state.activeAgency, state.agencyProducts, state.editingProduct, state.setEditingProduct]); + const [loading, setLoading, appendNewProduct] = useProductsStore((state) => [state.loading, state.setLoading, state.appendNewProduct]); + const [activeAgency, editingProduct, setEditingProduct] = useProductsStore((state) => [state.activeAgency, state.editingProduct, state.setEditingProduct]); + + const [extrasVisible, setExtrasVisible] = useState(false); + const [editable, setEditable] = useState(false); + const topPerm = isPermitted(PERM_PRODUCTS_MANAGEMENT); // 高级权限 + useEffect(() => { + const hasHT = (editingProduct?.info?.htid || 0) > 0; + // const hasAuditPer = isPermitted(PERM_PRODUCTS_OFFER_AUDIT); + const hasEditPer = isPermitted(PERM_PRODUCTS_OFFER_PUT); + setEditable(topPerm || (!hasHT && hasEditPer)); + // setEditable(topPerm || (hasAuditPer ? true : (!hasHT && hasEditPer))); + // setEditable(true); // debug: 0 + // console.log('editable', hasAuditPer, (notAudit && hasEditPer)); + + const showExtras = topPerm && !isEmpty(editingProduct) && hasHT; + setExtrasVisible(showExtras); + return () => {}; + }, [activeAgency, editingProduct]); const onSave = async (err, values, forms) => { values.travel_agency_id = activeAgency.travel_agency_id; - const copyNewProduct = structuredClone(newProductRecord); - const poster = { - "audit_state": "-1", + const copyNewProduct = structuredClone(newProductRecord); + const poster = { + 'audit_state': '-1', // "create_date": dayjs().format('YYYY-MM-DD HH:mm:ss'), // "created_by": userId, - "travel_agency_id": activeAgency.travel_agency_id, + 'travel_agency_id': activeAgency.travel_agency_id, // "travel_agency_name": "", // "lastedit_changed": "", }; /** lgc_details */ - const copyFields = pick(editingProduct.info, ['title', 'product_type_id', ]); - const readyToSubInfo = {...copyNewProduct.info, ...values.info, ...copyFields, type: copyFields.product_type_id, ...poster }; + const copyFields = pick(editingProduct.info, ['title', 'product_type_id']); + const readyToSubInfo = { ...copyNewProduct.info, ...values.info, ...copyFields, type: copyFields.product_type_id, ...poster }; // console.log('onSave', editingProduct.info, readyToSubInfo); - const prevLgcDetailsMapped = editingProduct.lgc_details.reduce((r, c) => ({...r, [c.lgc]: {...c, description: c.descriptions}}), {}); // todo: description字段不一致 + const prevLgcDetailsMapped = editingProduct.lgc_details.reduce((r, c) => ({ ...r, [c.lgc]: { ...c, description: c.descriptions } }), {}); // todo: description字段不一致 const mergedLgc = { ...prevLgcDetailsMapped, ...values.lgc_details_mapped }; /** quotation */ // todo: 报价不能为空 - const prevQuotationMapped = editingProduct.quotation.reduce((r, c) => ({...r, [c.id]: {...c, unit: c.unit_id, audit_state: c.audit_state_id }}), {}); + const prevQuotationMapped = editingProduct.quotation.reduce((r, c) => ({ ...r, [c.id]: { ...c, unit: c.unit_id, audit_state: c.audit_state_id } }), {}); const mergedQ = { ...prevQuotationMapped, ...(values.quotation || []) }; - // console.log(values); - // return false; + console.log(values); + // return false; // debug: 0 + /** 提交保存 */ setLoading(true); const { success, result } = await postProductsSaveAction({ travel_agency_id: activeAgency.travel_agency_id, @@ -58,7 +73,7 @@ const ProductInfo = ({ editable, ...props }) => { setLoading(false); success ? message.success(t('Success')) : message.error(t('Failed')); // 保存后更新数据 - newProduct(result); + appendNewProduct(result); setEditingProduct(result); }; return ( @@ -66,13 +81,14 @@ const ProductInfo = ({ editable, ...props }) => {

{t('products:EditComponents.info')}

- + + {extrasVisible && } ); }; diff --git a/src/views/products/Detail/ProductInfoForm.jsx b/src/views/products/Detail/ProductInfoForm.jsx index 81cfd3b..ffa79be 100644 --- a/src/views/products/Detail/ProductInfoForm.jsx +++ b/src/views/products/Detail/ProductInfoForm.jsx @@ -9,15 +9,11 @@ import { useProductsTypesFieldsets } from '@/hooks/useProductsSets'; import useProductsStore from '@/stores/Products/Index'; import ProductInfoLgc from './ProductInfoLgc'; import ProductInfoQuotation from './ProductInfoQuotation'; -import useAuthStore from '@/stores/Auth'; -import { PERM_PRODUCTS_OFFER_AUDIT } from '@/config'; import { useHTLanguageSetsMapVal } from '@/hooks/useHTLanguageSets'; - const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, showSubmit, confirmText, formName, ...props }) => { const { t } = useTranslation('products'); const HTLanguageSetsMapVal = useHTLanguageSetsMapVal(); - const isPermitted = useAuthStore((state) => state.isPermitted); const [loading, editingProduct] = useProductsStore((state) => [state.loading, state.editingProduct]); const weekdays = useWeekdays(); const [form] = Form.useForm(); @@ -32,20 +28,15 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show const filedsets = useProductsTypesFieldsets(editingProduct?.info?.product_type_id); const shows = filedsets[0]; - const topPerm = isPermitted(PERM_PRODUCTS_OFFER_AUDIT); // 高级权限 - const [ignoreEditable, setIgnoreEditable] = useState(false); const [editable, setEditable] = useState(true); useEffect(() => { form.resetFields(); form.setFieldValue('city', { value: editingProduct?.info?.city_id, label: editingProduct?.info?.city_name }); form.setFieldValue('dept', { value: editingProduct?.info?.dept_id, label: editingProduct?.info?.dept_name }); - form.setFieldValue('lgc_details', editingProduct?.lgc_details || []); + const lgc_details_mapped = (editingProduct?.lgc_details || []).reduce((r, c) => ({ ...r, [c.lgc]: c }), {}); + form.setFieldValue('lgc_details_mapped', lgc_details_mapped); - const isNew = isEmpty(editingProduct?.info?.id) || _editable; // 新增产品; 状态=新增 - const ignoreEditable0 = topPerm || isNew; // 允许编辑 const editable0 = isEmpty(editingProduct) ? false : _editable; // 空对象未操作 - setIgnoreEditable(ignoreEditable0); - // console.log('+++++++++++++++++++', '\ntopPerm', topPerm, '\nisNew', isNew, '\nignoreEditable0', ignoreEditable0, '\neditable0', editable0, '\n_editable', _editable); setEditable(editable0); return () => {}; }, [editingProduct?.info?.id, _editable]); @@ -85,7 +76,7 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show <>
- {getFields({ sort, initialValue: editingProduct?.info, hides, shows, fieldProps, fieldComProps, form, t, dataSets: { weekdays }, editable, ignoreEditable })} + {getFields({ sort, initialValue: editingProduct?.info, hides, shows, fieldProps, fieldComProps, form, t, dataSets: { weekdays }, editable })} {/* {showSubmit && ( @@ -106,25 +97,26 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show )} */} {/* */} - ({ - transform(value) { - return Object.values(value).filter(_v => !isEmpty(_v)); - }, - validator: async (_, valueArr) => { - const invalidLgcName = valueArr - .filter((l) => isEmpty(l.title)) - .map((x) => HTLanguageSetsMapVal[x.lgc].label) - .join(', '); - if (isNotEmpty(invalidLgcName)) { - return Promise.reject(new Error(`请完善多语种信息: ${invalidLgcName}`)); - } - return Promise.resolve(); - }, - }), - ]}> - + ({ + transform(value) { + return Object.values(value).filter((_v) => !isEmpty(_v)); + }, + validator: async (_, valueArr) => { + const invalidLgcName = valueArr + .filter((l) => isEmpty(l.title)) + .map((x) => HTLanguageSetsMapVal[x.lgc].label) + .join(', '); + if (isNotEmpty(invalidLgcName)) { + return Promise.reject(new Error(`请完善多语种信息: ${invalidLgcName}`)); + } + return Promise.resolve(); + }, + }), + ]}> +