From 27b6063a1eda89640a3975ce648e974c0b6f3697 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 28 Jul 2025 10:50:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E6=A0=91:=20?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=A4=9A=E5=9F=8E=E5=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/products/Detail/ProductsTree.jsx | 51 ++++++++++++---------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/views/products/Detail/ProductsTree.jsx b/src/views/products/Detail/ProductsTree.jsx index 4378482..a289837 100644 --- a/src/views/products/Detail/ProductsTree.jsx +++ b/src/views/products/Detail/ProductsTree.jsx @@ -53,6 +53,7 @@ const ProductsTree = ({ onNodeSelect, ...props }) => { const [rawTreeData, setRawTreeData] = useState([]); const [flattenTreeData, setFlattenTreeData] = useState([]); const [expandedKeys, setExpandedKeys] = useState([]); + const [selectedKeys, setSelectedKeys] = useState([]); const [autoExpandParent, setAutoExpandParent] = useState(true); useEffect(() => { @@ -74,28 +75,30 @@ const ProductsTree = ({ onNodeSelect, ...props }) => { const _show = productsTypes .filter((kk) => hasDataTypes.includes(kk.value)) .map((ele) => ({ - ...ele, - title: ele.label, - key: ele.value, - children: (agencyProducts[ele.value] || []).map((product) => { - const lgc_map = product.lgc_details.reduce((rlgc, clgc) => ({...rlgc, [clgc.lgc]: clgc}), {}); - return { - // title: product.info.title || lgc_map?.['2']?.title || lgc_map?.['1']?.title || '', - title: `【${product.info.city_name}】` + (product.info.title || lgc_map?.['2']?.title || lgc_map?.['1']?.title || product.info.product_title || ''), - // key: `${ele.value}-${product.info.id}`, - key: product.info.id, - _raw: product, - isLeaf: true, - }}), - // 增加`城市`层级 - // _children: Object.keys(copyAgencyProducts[ele.value] || []).map(city => { - // return { - // title: city, - // key: `${ele.value}-${city}`, - // children: copyAgencyProducts[ele.value][city], - // }; - // }), - })); + ...ele, + title: ele.label, + key: ele.value, + children: (agencyProducts[ele.value] || []).reduce((arr, product) => { + const lgc_map = product.lgc_details.reduce((rlgc, clgc) => ({ ...rlgc, [clgc.lgc]: clgc }), {}); + const combindCityList = product.info.city_list.indexOf(city => city.id === product.info.city_id) !== -1 ? product.info.city_list : [...product.info.city_list, { id: product.info.city_id, name: product.info.city_name }]; + const flatCityP = combindCityList.map(city => ({ + title: `【${city.name}】` + (product.info.title || lgc_map?.['2']?.title || lgc_map?.['1']?.title || product.info.product_title || ''), + // key: `${ele.value}-${product.info.id}`, + key: `${product.info.id}-${city.id}`, + _raw: product, + isLeaf: true, + })); + return arr.concat(flatCityP); + }, []), + // 增加`城市`层级 + // _children: Object.keys(copyAgencyProducts[ele.value] || []).map(city => { + // return { + // title: city, + // key: `${ele.value}-${city}`, + // children: copyAgencyProducts[ele.value][city], + // }; + // }), + })); setTreeData(_show); setRawTreeData(_show); setFlattenTreeData(flattenTreeFun(_show)); @@ -130,6 +133,8 @@ const ProductsTree = ({ onNodeSelect, ...props }) => { const handleNodeSelect = (selectedKeys, { node }) => { if (node._raw) { setEditingProduct(node._raw); + const allKeysWithCity = [...node._raw.info.city_list, { id: node._raw.info.city_id, name: node._raw.info.city_name }].map((city) => `${node._raw.info.id}-${city.id}`); + setSelectedKeys(allKeysWithCity); } else { // 单击: 折叠/展开 // const isExpand = expandedKeys.includes(selectedKeys[0]); @@ -174,7 +179,7 @@ const ProductsTree = ({ onNodeSelect, ...props }) => { } onSelect={handleNodeSelect} treeData={treeData} From e6832cfd7f1c448791b1bd01ad388b2ea2005677 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Mon, 28 Jul 2025 15:03:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E5=9C=B0=E6=8E=A5=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=87=87=E8=B4=AD=E5=B9=B4=E4=BB=BD=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.jsx | 3 +++ src/views/products/PickYear.jsx | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/views/products/PickYear.jsx diff --git a/src/main.jsx b/src/main.jsx index 7a3310c..51170af 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -45,6 +45,8 @@ import { isNotEmpty } from '@/utils/commons' import ProductsManage from '@/views/products/Manage'; import ProductsDetail from '@/views/products/Detail'; import ProductsAudit from '@/views/products/Audit'; +import PickYear from './views/products/PickYear' + import { PERM_ACCOUNT_MANAGEMENT, PERM_ROLE_NEW, PERM_OVERSEA,PERM_TRAIN_TICKET, PERM_AIR_TICKET, PERM_PRODUCTS_MANAGEMENT, PERM_PRODUCTS_OFFER_PUT } from '@/config' import './i18n' @@ -94,6 +96,7 @@ const initRouter = async () => { { path: "products/:travel_agency_id/:use_year/:audit_state/edit",element:}, { path: "products/audit",element:}, { path: "products/edit",element:}, + { path: "products/pick-year",element: }, // ] }, diff --git a/src/views/products/PickYear.jsx b/src/views/products/PickYear.jsx new file mode 100644 index 0000000..6329175 --- /dev/null +++ b/src/views/products/PickYear.jsx @@ -0,0 +1,40 @@ +import { useNavigate } from "react-router-dom"; +import { Row, DatePicker, Flex, Col, Typography } from "antd"; +import dayjs from "dayjs"; +import { usingStorage } from "@/hooks/usingStorage"; + +function PickYear() { + const navigate = useNavigate(); + const { travelAgencyId } = usingStorage(); + + return ( + <> + + + + + 请选择采购年份 + + { + const useYear = date.year(); + navigate(`/products/${travelAgencyId}/${useYear}/all/edit`); + }} + /> + + + + + ); +} +export default PickYear;