From 1534ce6979668541dc269a967341793597c1515d Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 26 Jun 2024 17:02:18 +0800 Subject: [PATCH] =?UTF-8?q?debug:=20=E6=90=9C=E7=B4=A2=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=9A=84=E9=99=84=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?;=20=E4=BB=B7=E6=A0=BCvalue=E6=94=B9=E4=B8=BAadult=5Fcost;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/en/products.json | 1 + public/locales/zh/products.json | 3 ++- src/hooks/useProductsSets.js | 33 ++++++++++++++++++---------- src/views/products/Audit.jsx | 4 ++-- src/views/products/Detail/Extras.jsx | 15 ++++++------- 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/public/locales/en/products.json b/public/locales/en/products.json index 6a62774..2a07ae5 100644 --- a/public/locales/en/products.json +++ b/public/locales/en/products.json @@ -1,4 +1,5 @@ { + "ProductType": "ProductType", "type": { "Experience": "Experience", "Car": "Transport Services", diff --git a/public/locales/zh/products.json b/public/locales/zh/products.json index 65cb019..1e1083b 100644 --- a/public/locales/zh/products.json +++ b/public/locales/zh/products.json @@ -1,4 +1,5 @@ { + "ProductType": "项目类型", "type": { "Experience": "综费", "Car": "车费", @@ -78,7 +79,7 @@ "GroupSize": "人等", "UseDates": "使用日期", - "Weekdays": "有效日/周X", + "Weekdays": "周末", "OnWeekdays": "周: ", "Unlimited": "不限", diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index 0dd63f7..5ee66d3 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -1,5 +1,7 @@ import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; +import useAuthStore from '@/stores/Auth'; +import { PERM_OVERSEA, PERM_AIR_TICKET, PERM_PRODUCTS_MANAGEMENT } from '@/config'; /** * 产品管理 相关的预设数据 @@ -89,17 +91,26 @@ export const useProductsAuditStatesMapVal = (value) => { /** * @ignore */ -export const useProductsTypesFieldsets = (type, role) => { - const infoDefault = ['code', 'title']; +export const useProductsTypesFieldsets = (type) => { + const [isPermitted] = useAuthStore((state) => [state.isPermitted]); + const infoDefault = [['code'], ['title']]; const infoAdmin = ['remarks', 'dept', 'display_to_c']; const infoTypesMap = { - '6': [], - 'B': ['city_id', 'km'], - 'J': ['description', 'city_id', 'recommends_rate', 'duration', 'display_to_c'], - 'Q': ['description', 'city_id', 'duration', ], - 'D': ['description', 'city_id', 'recommends_rate','duration',], - '7': ['description', 'city_id', 'recommends_rate', 'duration', 'display_to_c', 'open_weekdays'], // todo: 怎么是2个图 - 'C': ['description', 'city_id',], - '8': [], // todo: ? + '6': [[],[]], + 'B': [['city_id', 'km'], []], + 'J': [['city_id', 'recommends_rate', 'duration', 'display_to_c'], ['description',]], + 'Q': [['city_id', 'duration', ], ['description',]], + 'D': [['city_id', 'recommends_rate','duration',], ['description',]], + '7': [['city_id', 'recommends_rate', 'duration', 'display_to_c', 'open_weekdays'], ['description',]], // todo: 怎么是2个图 + 'C': [['city_id',], ['description',]], + '8': [[],[]], // todo: ? }; -}; + const thisTypeFieldset = (_type) => { + const adminSet = isPermitted(PERM_PRODUCTS_MANAGEMENT) ? infoAdmin : []; + return [ + [...infoDefault[0], ...infoTypesMap[_type][0], ...adminSet], + [...infoDefault[1], ...infoTypesMap[_type][1]] + ]; + }; + return thisTypeFieldset(type); +} diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index 2cbb8b1..ca38cfd 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -86,8 +86,8 @@ const PriceTable = ({ dataSource, refresh }) => { const columns = [ { key: 'title', dataIndex: ['info', 'title'], width: '16rem', title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }), render: (text, r) => text || r.lgc_details?.['2']?.title || '' }, - { key: 'adult', title: t('AgeType.Adult'), render: (_, { value, currency, unit_name }) => `${value} ${currency} / ${unit_name}` }, - { key: 'child', title: t('AgeType.Child'), render: (_, { value, currency, unit_name }) => `${value} ${currency} / ${unit_name}` }, + { key: 'adult', title: t('AgeType.Adult'), render: (_, { adult_cost, currency, unit_name }) => `${adult_cost} ${currency} / ${unit_name}` }, + { key: 'child', title: t('AgeType.Child'), render: (_, { child_cost, currency, unit_name }) => `${child_cost} ${currency} / ${unit_name}` }, // {key: 'price', title: t('Currency'), }, // {key: 'currency', title: t('Currency'), }, // {key: 'unit', title: t('Unit'), }, diff --git a/src/views/products/Detail/Extras.jsx b/src/views/products/Detail/Extras.jsx index 4caf981..c22a2fb 100644 --- a/src/views/products/Detail/Extras.jsx +++ b/src/views/products/Detail/Extras.jsx @@ -24,27 +24,26 @@ const NewAddonModal = ({ onPick, ...props }) => { const { starttime, endtime, ...param } = copyObject; setSearchLoading(true); setSearchResult([]); - const result = await getAgencyProductsAction({ ...param, audit_state: '1', travel_agency_id, use_year }); + // debug: audit_state: '1', + const result = await getAgencyProductsAction({ ...param, audit_state: '0', travel_agency_id, use_year }); setSearchResult(result?.products || []); setSearchLoading(false); }; const handleAddExtras = async (item) => { - // const success = await fetchBindOrder({ coli_sn, conversationid: currentConversationID }); - // success ? message.success('绑定成功') : message.error('绑定失败'); - // setOpen(false); if (typeof onPick === 'function') { onPick(item); } }; - // todo: + // todo: 如何显示价格表 const searchResultColumns = [ + { key: 'ptype', dataIndex: ['info', 'product_type_name'], width: '6rem', title: t('products:ProductType') }, { key: 'title', dataIndex: ['info', 'title'], width: '16rem', title: t('products:Title') }, { title: t('products:price'), - dataIndex: ['quotation', '0', 'value'], + dataIndex: ['quotation', '0', 'adult_cost'], width: '10rem', - render: (_, { quotation }) => `${quotation[0].value} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo: 成人 儿童 + render: (_, { quotation }) => `${quotation[0].adult_cost} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo: 成人 儿童 }, { key: 'action', @@ -143,7 +142,7 @@ const Extras = ({ productId, onChange, ...props }) => { dataIndex: ['quotation', '0', 'value'], width: '10rem', - render: (_, { quotation }) => `${quotation[0].value} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo: 成人 儿童 + render: (_, { quotation }) => `${quotation[0].adult_cost} ${quotation[0].currency} / ${quotation[0].unit_name}`, // todo: 成人 儿童 }, // { title: t('products:Types'), dataIndex: 'age_type', width: '40%', }, {