From e7a83df8a28c97cb6d0474c4650e293c79c2741c Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 1 Aug 2024 14:43:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=93=BE=E6=8E=A5=E6=8E=A7?= =?UTF-8?q?=E5=88=B6:=20=E6=9D=83=E9=99=90,=20=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/en/products.json | 5 +- public/locales/zh/products.json | 2 +- src/main.jsx | 4 + src/views/products/Audit.jsx | 13 +- src/views/products/Detail.jsx | 158 +++++++++--------- src/views/products/Detail/Header.jsx | 50 +++--- src/views/products/Detail/ProductInfoForm.jsx | 6 +- 7 files changed, 125 insertions(+), 113 deletions(-) diff --git a/public/locales/en/products.json b/public/locales/en/products.json index 79ca29e..74e08bb 100644 --- a/public/locales/en/products.json +++ b/public/locales/en/products.json @@ -30,8 +30,8 @@ "Published": "Publish" }, "PriceUnit": { - "0": "Person", - "1": "Group", + "0": "per Person", + "1": "per Group", "title": "Price Unit" }, "Status": "Status", @@ -44,6 +44,7 @@ "CreateDate": "Create Date", "AuditedBy": "Audited By", "AuditDate": "Audit Date", + "AuditRes": "Audit Result", "OpenHours": "Open Hours", "Duration": "Duration", "KM": "KM", diff --git a/public/locales/zh/products.json b/public/locales/zh/products.json index 2c5ae72..c7628f8 100644 --- a/public/locales/zh/products.json +++ b/public/locales/zh/products.json @@ -44,7 +44,7 @@ "CreateDate": "提交时间", "AuditedBy": "审核人员", "AuditDate": "审核时间", - + "AuditRes": "审核结果", "OpenHours": "游览时间", "Duration": "游览时长", "KM": "公里数", diff --git a/src/main.jsx b/src/main.jsx index b2062c1..b675476 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -71,7 +71,11 @@ const initRouter = async () => { { path: 'airticket/plan/:coli_sn/:gri_sn',element:}, { path: "products",element: }, { path: "products/:travel_agency_id/:use_year/:audit_state/audit",element:}, + { path: "products/:travel_agency_id/:use_year/:audit_state/edit",element:}, + + { path: "products/audit",element:}, + { path: "products/edit",element:}, ] }, diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index 1ab45c1..a65d836 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -5,11 +5,14 @@ import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProdu import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; import { useTranslation } from 'react-i18next'; import useProductsStore, { postProductsQuoteAuditAction, } from '@/stores/Products/Index'; -import { cloneDeep, isEmpty } from '@/utils/commons'; +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 Header from './Detail/Header'; +import dayjs from 'dayjs'; +import { usingStorage } from '@/hooks/usingStorage'; + const PriceTable = ({ productType, dataSource, refresh }) => { const { t } = useTranslation('products'); const { travel_agency_id, use_year, audit_state } = useParams(); @@ -58,7 +61,8 @@ const PriceTable = ({ productType, dataSource, refresh }) => { const columns = [ { key: 'title', dataIndex: ['info', 'title'], width: '16rem', title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan, }), className: 'bg-white', render: (text, r) => { const title = text || r.lgc_details?.['2']?.title || r.lgc_details?.['1']?.title || ''; - return isPermitted(PERM_PRODUCTS_OFFER_PUT) ? setEditingProduct({info: r.info})}>{title} : title; + const itemLink = isPermitted(PERM_PRODUCTS_OFFER_AUDIT) ? `/products/${travel_agency_id}/${use_year}/${audit_state}/edit` : isPermitted(PERM_PRODUCTS_OFFER_PUT) ? `/products/edit` : ''; + return isNotEmpty(itemLink) ? setEditingProduct({info: r.info})}>{title} : title; } }, // ...(productType === 'B' ? [{ key: 'km', dataIndex: ['info', 'km'], title: t('KM')}] : []), { key: 'adult', title: t('AgeType.Adult'), render: (_, { adult_cost, currency, unit_id, unit_name }) => `${adult_cost} ${currency} / ${t(`PriceUnit.${unit_id}`)}` }, @@ -161,10 +165,11 @@ const TypesPanels = (props) => { const Audit = ({ ...props }) => { const { travel_agency_id, use_year, audit_state } = useParams(); const [loading, activeAgency, getAgencyProducts] = useProductsStore((state) => [state.loading, state.activeAgency, state.getAgencyProducts]); + const { travelAgencyId } = usingStorage(); const handleGetAgencyProducts = ({pick_year, pick_agency, pick_state}={}) => { - const year = pick_year || use_year; - const agency = pick_agency || travel_agency_id; + const year = pick_year || use_year || dayjs().year(); + const agency = pick_agency || travel_agency_id || travelAgencyId; const state = pick_state ?? audit_state; getAgencyProducts({ travel_agency_id: agency, use_year: year, audit_state: state }); }; diff --git a/src/views/products/Detail.jsx b/src/views/products/Detail.jsx index 33a8938..abc97a9 100644 --- a/src/views/products/Detail.jsx +++ b/src/views/products/Detail.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import { useState, useEffect } from 'react'; import { message, Divider, Empty, Flex } from 'antd'; import { useNavigate } from 'react-router-dom'; import Extras from './Detail/Extras'; @@ -9,7 +9,7 @@ import { useParams } from 'react-router-dom'; import useProductsStore from '@/stores/Products/Index'; import dayjs from 'dayjs'; import { HT_HOST } from '@/config'; -import { postJSON, postForm } from '@/utils/request'; +import { postForm } from '@/utils/request'; import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; import { usingStorage } from '@/hooks/usingStorage'; import ProductsTree from './Detail/ProductsTree'; @@ -20,18 +20,12 @@ import NewProductModal from './Detail/NewProductModal'; function Detail() { // const { t } = useTranslation(); const navigate = useNavigate(); - const [quotation, setQuotation] = useState(null); - const [lgc_details, setLgc_details] = useState(null); - // const [languageLabel, setLanguageLabel] = useState(null); const { travel_agency_id, audit_state, use_year } = useParams(); - // const HTLanguageSets = useHTLanguageSets(); - // const { Search } = Input; const [addProductVisible, setAddProductVisible] = useState(false); - const [editingProduct, setEditingProduct] = useProductsStore((state) => [state.editingProduct, state.setEditingProduct]); - const [agencyProducts, setAgencyProducts, loading] = useProductsStore((state) => [state.agencyProducts, state.setAgencyProducts, state.loading]); + 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 [switchParams, setSwitchParams] = useProductsStore((state) => [state.switchParams, state.setSwitchParams]); - const [info, setInfo] = useState(); + const [setSwitchParams] = useProductsStore((state) => [state.setSwitchParams]); const yearOptions = []; const currentYear = dayjs().year(); const baseYear = Number(use_year === 'all' ? currentYear : use_year); @@ -113,79 +107,79 @@ function Detail() { }, [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; - } + // 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}`); - } + // 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; - }; + // return; + // }; //提交审核方法 const submitReview = async () => { diff --git a/src/views/products/Detail/Header.jsx b/src/views/products/Detail/Header.jsx index 9820cbe..588af1d 100644 --- a/src/views/products/Detail/Header.jsx +++ b/src/views/products/Detail/Header.jsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { useParams, Link, useNavigate } from 'react-router-dom'; +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'; @@ -13,6 +13,10 @@ import dayjs from 'dayjs'; import VendorSelector from '@/components/VendorSelector'; import AuditStateSelector from '@/components/AuditStateSelector'; const Header = ({ refresh, editable, ...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); @@ -107,15 +111,16 @@ const Header = ({ refresh, editable, ...props }) => { {(use_year || '').replace('all', '')} */} - {/* */} - {/* */} - {/* PERM_PRODUCTS_OFFER_PUT */} - - + {showEditA && ( + {t('Edit')} - - {/* todo: edit/audit 链接 */} + )} + {showAuditA && ( + + {t('products:AuditRes')} + + )} - - - - - - } + {editable && ( + <> + + + + + + + + )} ); }; diff --git a/src/views/products/Detail/ProductInfoForm.jsx b/src/views/products/Detail/ProductInfoForm.jsx index b815e2c..d5a42c5 100644 --- a/src/views/products/Detail/ProductInfoForm.jsx +++ b/src/views/products/Detail/ProductInfoForm.jsx @@ -163,7 +163,7 @@ function getFields(props) { fieldProps?.code?.col || midCol ), item( - 'city', // todo: + 'city', 99, @@ -171,7 +171,7 @@ function getFields(props) { fieldProps?.city?.col || midCol ), item( - 'dept', // todo: + 'dept', 99, @@ -196,7 +196,7 @@ function getFields(props) { fieldProps?.km?.col || midCol ), item( - 'recommends_rate', // todo: + 'recommends_rate', 99, {/* */}