From f323f0b511e858f253afec08ab85973e62a16f59 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 18 Jun 2024 13:57:55 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/en/common.json | 3 +++ public/locales/en/products.json | 18 +++++++++++++++++- public/locales/zh/common.json | 3 +++ public/locales/zh/products.json | 20 ++++++++++++++++++-- src/components/AuditStateSelector.jsx | 12 ++++++++++++ src/components/SearchForm.jsx | 20 ++++++-------------- src/components/SecondHeaderWrapper.jsx | 2 +- src/hooks/useProductsSets.js | 12 ++++++------ src/views/products/Index.jsx | 10 ++++++---- 9 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 src/components/AuditStateSelector.jsx diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 0810454..09471cf 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -21,6 +21,9 @@ "preview": "Preview", "Total": "Total", "Action": "Action", + "Import": "Import", + "Export": "Export", + "Copy": "Copy", "Login": "Login", "Username": "Username", diff --git a/public/locales/en/products.json b/public/locales/en/products.json index 2076875..637b8f8 100644 --- a/public/locales/en/products.json +++ b/public/locales/en/products.json @@ -16,11 +16,27 @@ "Rejected": "Rejected", "Published": "Published" }, + "Status": "Status", + "Title": "Title", "Vendor": "Vendor", "AuState": "Audit State", "CreatedBy": "Created By", "CreateDate": "Create Date", "AuditedBy": "Audited By", - "AuditDate": "Audit Date" + "AuditDate": "Audit Date", + + "Quotation": "Quotation", + "Unit": "Unit", + "GroupSize": "Group Size", + "UseDates": "Use Dates", + "Weekdays": "Weekdays", + + "AgeType": { + "Type": "Age Type", + "Adult": "Adult", + "Child": "Child" + }, + + "#": "#" } diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index 4ef0694..2c54705 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -21,6 +21,9 @@ "preview": "预览", "Total": "总数", "Action": "操作", + "Import": "导入", + "Export": "导出", + "Copy": "复制", "Login": "登录", "Username": "账号", diff --git a/public/locales/zh/products.json b/public/locales/zh/products.json index 326bd78..8d5c4e9 100644 --- a/public/locales/zh/products.json +++ b/public/locales/zh/products.json @@ -16,11 +16,27 @@ "Rejected": "已拒绝", "Published": "已发布" }, + "Status": "状态", + "Title": "名称", "Vendor": "供应商", "AuState": "审核状态", "CreatedBy": "提交人员", "CreateDate": "提交时间", - "Auditors": "审核人员", - "AuditDate": "审核时间" + "AuditedBy": "审核人员", + "AuditDate": "审核时间", + + "Quotation": "报价", + "Unit": "单位", + "GroupSize": "人等", + "UseDates": "使用日期", + "Weekdays": "有效日", + + "AgeType": { + "Type": "人群", + "Adult": "成人", + "Child": "儿童" + }, + + "#": "#" } diff --git a/src/components/AuditStateSelector.jsx b/src/components/AuditStateSelector.jsx new file mode 100644 index 0000000..db4c77d --- /dev/null +++ b/src/components/AuditStateSelector.jsx @@ -0,0 +1,12 @@ +import { Select } from 'antd'; +import { useProductsAuditStates } from '@/hooks/useProductsSets'; + +const AuditStateSelector = ({ ...props }) => { + const states = useProductsAuditStates(); + return ( + <> + + + , fieldProps?.auditState?.col || 3 ), diff --git a/src/components/SecondHeaderWrapper.jsx b/src/components/SecondHeaderWrapper.jsx index 2b2ffca..097b0d4 100644 --- a/src/components/SecondHeaderWrapper.jsx +++ b/src/components/SecondHeaderWrapper.jsx @@ -14,7 +14,7 @@ const HeaderWrapper = ({ children, header, ...props }) => {
{/* {header} */} -
{header}
+
{header}
diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index 4545d91..ee33d47 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -27,17 +27,17 @@ export const useProductsTypes = () => { }; -export const useProductsAuditStatus = () => { +export const useProductsAuditStates = () => { const [types, setTypes] = useState([]); const { t, i18n } = useTranslation(); useEffect(() => { const newData = [ - { value: '0', label: 'New' }, - { value: '1', label: 'Pending' }, - { value: '2', label: 'Approve' }, - { value: '3', label: 'Rejected' }, - { value: '4', label: 'Published' }, + { value: '0', label: t('products:auditState.New') }, + { value: '1', label: t('products:auditState.Pending') }, + { value: '2', label: t('products:auditState.Approve') }, + { value: '3', label: t('products:auditState.Rejected') }, + { value: '4', label: t('products:auditState.Published') }, ]; setTypes(newData); }, [i18n.language]); diff --git a/src/views/products/Index.jsx b/src/views/products/Index.jsx index b793b2f..df1b189 100644 --- a/src/views/products/Index.jsx +++ b/src/views/products/Index.jsx @@ -17,6 +17,7 @@ function Index() { useEffect(() => {}, []); const showTotal = (total) => `Total ${total} items`; + const columns = [ { title: t('products:Vendor'), key: 'vendor', dataIndex: 'travel_agency_name' }, { title: t('products:CreatedBy'), key: 'created_by', dataIndex: 'created_by' }, @@ -38,9 +39,6 @@ function Index() { return ( { }} /> - +
From 232a8f85c875a1d1b0f0fd8b4f86b58dbcce668d Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 19 Jun 2024 10:19:43 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2:=20=E8=A1=A8=E6=A0=BC,=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/zh/products.json | 2 +- src/hooks/useProductsSets.js | 10 +- src/stores/Products/Index.js | 246 +++++++++++++++++++++++++++++++- src/views/App.jsx | 1 - src/views/products/Audit.jsx | 106 ++++++++++++-- src/views/products/Index.jsx | 6 +- 6 files changed, 351 insertions(+), 20 deletions(-) diff --git a/public/locales/zh/products.json b/public/locales/zh/products.json index 8d5c4e9..932fc24 100644 --- a/public/locales/zh/products.json +++ b/public/locales/zh/products.json @@ -30,7 +30,7 @@ "Unit": "单位", "GroupSize": "人等", "UseDates": "使用日期", - "Weekdays": "有效日", + "Weekdays": "有效日/周X", "AgeType": { "Type": "人群", diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index ee33d47..888368d 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -33,11 +33,11 @@ export const useProductsAuditStates = () => { useEffect(() => { const newData = [ - { value: '0', label: t('products:auditState.New') }, - { value: '1', label: t('products:auditState.Pending') }, - { value: '2', label: t('products:auditState.Approve') }, - { value: '3', label: t('products:auditState.Rejected') }, - { value: '4', label: t('products:auditState.Published') }, + { key: '0', value: '0', label: t('products:auditState.New') }, + { key: '1', value: '1', label: t('products:auditState.Pending') }, + { key: '2', value: '2', label: t('products:auditState.Approve') }, + { key: '3', value: '3', label: t('products:auditState.Rejected') }, + { key: '4', value: '4', label: t('products:auditState.Published') }, ]; setTypes(newData); }, [i18n.language]); diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 872bec9..1747757 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -3,10 +3,19 @@ import { devtools } from 'zustand/middleware'; import { fetchJSON } from '@/utils/request'; import { HT_HOST } from '@/config'; +import { groupBy } from '@/utils/commons'; + +const searchAgency = async (param) => { + const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); + +}; +const getAgencyProducts = async (param) => { + const { errcode, Result, Result1 } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); +}; const initialState = { loading: false, - productsList: [ + agencyList: [ { 'audit_date': '2001-03-03', 'travel_agency_name': '新油低外', @@ -18,6 +27,237 @@ const initialState = { 'audit_state': '1', }, ], + activeAgency: {}, + agencyProducts: groupBy([ + { + "info": { + "id": "640000198509289851", + "title": "如拉下完公", + "code": "grlkt", + "type": "Guide", + "audit_state": "1", + "create_date": "2022-01-13", + "created_by": "郝涛", + "travel_agency_id": "710000200712195349", + "travel_agency_name": "国得气验", + "lastedit_memo": "划百引程级门会需代领主属快。", + "remarks": "及决对金利低集小理电和按常如门。", + "duration": 2, + "duration_unit": "m", + "open_weekdays": "6", + "recommends_rate": 3, + "dept": 1, + "display_to_c": "2", + "km": 27, + "city_id": 77, + "city_name": "称命" + }, + "quotation": [ + { + "id": "21000020030611324X", + "value": 70, + "currency": "CNY", + "unit": "团", + "age_type": "儿童", + "group_size_min": 4, + "group_size_max": 4, + "use_dates_start": "2004-01-19", + "use_dates_end": "1990-03-10", + "weekdays": "4", + "audit_state": "ea pariatur", + "lastedit_memo": "sunt" + }, + { + "id": "610000197306240177", + "value": 86, + "currency": "CNY", + "unit": "人", + "age_type": "儿童", + "group_size_min": 6, + "group_size_max": 8, + "use_dates_start": "1996-12-16", + "use_dates_end": "1974-11-19", + "weekdays": "4", + "audit_state": "aliqua aute quis ipsum", + "lastedit_memo": "commodo adipisicing ea ipsum" + } + ], + "lgc_details": [ + { + "lgc": "mollit", + "title": "林运但", + "description": "学克信图走法因心委周说步将且文手越。", + "id": "35" + }, + { + "lgc": "et laborum", + "title": "备上引深量知量", + "description": "到听少文话包由北层中争二调原务越明在。", + "id": "74" + }, + { + "lgc": "minim velit", + "title": "安都始新", + "description": "取影压前手府要青白支大而。", + "id": "23" + } + ] + }, + { + "info": { + "id": "41000019901227754X", + "title": "据划京少国取", + "code": "ore", + "type": "Guide", + "audit_state": "2", + "create_date": "1979-01-31", + "created_by": "陆芳", + "travel_agency_id": "110000198612200137", + "travel_agency_name": "少平酸型", + "lastedit_memo": "八想军也装运知长示各院步济水。", + "remarks": "千改原统实专回列参目党却是样与后收。", + "duration": 3, + "duration_unit": "d", + "open_weekdays": "5", + "recommends_rate": 5, + "dept": 1, + "display_to_c": "2", + "km": 30, + "city_id": 62, + "city_name": "业入" + }, + "quotation": [ + { + "id": "37000019760525515X", + "value": 93, + "currency": "CNY", + "unit": "团", + "age_type": "成人", + "group_size_min": 7, + "group_size_max": 11, + "use_dates_start": "1992-11-22", + "use_dates_end": "1997-07-16", + "weekdays": "7", + "audit_state": "id nulla irure cupidatat", + "lastedit_memo": "quis aute reprehenderit consectetur" + }, + { + "id": "150000199506023175", + "value": 90, + "currency": "CNY", + "unit": "人", + "age_type": "儿童", + "group_size_min": 9, + "group_size_max": 10, + "use_dates_start": "2007-09-11", + "use_dates_end": "2013-07-27", + "weekdays": "5", + "audit_state": "commodo ad ut", + "lastedit_memo": "id anim incididunt" + } + ], + "lgc_details": [ + { + "lgc": "adipisicing elit Excepteur in", + "title": "很很结龙认", + "description": "事起复京长立然将采共层列工。", + "id": "43" + }, + { + "lgc": "dolore fugiat", + "title": "专中小", + "description": "示史想当集认点离反而原化精满并计前。", + "id": "28" + }, + { + "lgc": "sunt consectetur ea cillum", + "title": "他率带没", + "description": "节经厂面际是统表王活基书色活至是干验。", + "id": "83" + }, + { + "lgc": "incididunt labore fugiat", + "title": "精话西改", + "description": "须事金性别民学少拉个且须专需断连。", + "id": "97" + }, + { + "lgc": "dolore id", + "title": "文技话", + "description": "上任成条到则查支外很素给务府三。", + "id": "99" + } + ] + }, + { + "info": { + "id": "44000019990112280X", + "title": "节到和", + "code": "ixlmndtmz", + "type": "Meals", + "audit_state": "1", + "create_date": "2006-12-30", + "created_by": "易敏", + "travel_agency_id": "640000197111288408", + "travel_agency_name": "术备带走", + "lastedit_memo": "认队什教调问传改万消然声地全。", + "remarks": "属须厂几问总识看部群该克员方。", + "duration": 2, + "duration_unit": "m", + "open_weekdays": "6", + "recommends_rate": 3, + "dept": 2, + "display_to_c": "1", + "km": 13, + "city_id": 55, + "city_name": "铁以" + }, + "quotation": [ + { + "id": "13000019860219219X", + "value": 88, + "currency": "CNY", + "unit": "团", + "age_type": "儿童", + "group_size_min": 2, + "group_size_max": 4, + "use_dates_start": "1991-03-19", + "use_dates_end": "1974-03-13", + "weekdays": "3", + "audit_state": "officia voluptate ad adipisicing dolore", + "lastedit_memo": "Duis amet veniam enim" + }, + { + "id": "420000201706118123", + "value": 61, + "currency": "CNY", + "unit": "人", + "age_type": "儿童", + "group_size_min": 4, + "group_size_max": 10, + "use_dates_start": "1992-04-23", + "use_dates_end": "1970-07-19", + "weekdays": "5", + "audit_state": "commodo labore", + "lastedit_memo": "ullamco anim culpa do in" + } + ], + "lgc_details": [ + { + "lgc": "ut minim", + "title": "回等这意", + "description": "农满界个整千书得被写况空派会想头无。", + "id": "40" + }, + { + "lgc": "laborum id elit irure commodo", + "title": "增正数白养土子", + "description": "么划才共别程以元于族完难变。", + "id": "84" + } + ] + } +], row => row.info.type), }; export const useProductsStore = create( devtools((set, get) => ({ @@ -25,7 +265,9 @@ export const useProductsStore = create( ...initialState, // state actions - setProductsList: (productsList) => set({ productsList }), + setAgencyList: (agencyList) => set({ agencyList }), + setActiveAgency: activeAgency => set({ activeAgency }), + setAgencyProducts: agencyProducts => set({ agencyProducts }), reset: () => set(initialState), diff --git a/src/views/App.jsx b/src/views/App.jsx index cbb2949..0edd221 100644 --- a/src/views/App.jsx +++ b/src/views/App.jsx @@ -152,7 +152,6 @@ function App() { { label: {t('account:management.tile')}, key: '3' }, { type: 'divider' }, { label: {t('Logout')}, key: '4' }, - { label: {t('ChangeVendor')}, key: 'change-vendor' }, ], { type: 'divider' }, { label: <>v{BUILD_VERSION}, key: 'BUILD_VERSION' }, diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index f4187a2..cc5b79f 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -1,14 +1,22 @@ import { createContext, useContext, useEffect, useState } from 'react'; -import { Button, Table, Tabs } from 'antd'; +import { Link, useLocation, } from 'react-router-dom'; +import { Button, Collapse, Table, Tabs, Typography, Space, } from 'antd'; import { useProductsTypes } from '@/hooks/useProductsSets'; import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; +import { useTranslation } from 'react-i18next'; +import useProductsStore from '@/stores/Products/Index'; +import { isEmpty } from '@/utils/commons'; -const Header = () => { +const Header = ({title, ...props}) => { + const { t } = useTranslation(); return ( -
-
- - +
+
+

{title}

+
+ {/* */} + {/* */} +
); }; @@ -20,11 +28,93 @@ const TypesTabs = () => { ) } +const subjectComponents = { + // 'sum_profit': ProfitTable, + // 'in_order_count': Count, + // 'confirm_order_count': Count, + // 'depart_order_count': Count, + // 'confirm_rates': Rates, + // 'praise_rates': Rates, + // 'sum_person_num': Count, +}; + +const PriceTable = ({dataSource}) => { + const { t } = useTranslation('products'); + // console.log(dataSource, ); + const columns = [ + { key: 'title', dataIndex: ['info', 'title'], title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) }, + { key: 'value', title: t('Quotation'), render: (_, { value, currency, unit }) => `${value} ${currency} / ${unit}` }, + // {key: 'price', title: t('Currency'), }, + // {key: 'currency', title: t('Currency'), }, + // {key: 'unit', title: t('Unit'), }, + { key: 'ageType', dataIndex: ['age_type'], title: t('AgeType.Type') }, + { + key: 'groupSize', + dataIndex: ['group_size_min'], + title: t('GroupSize'), + render: (_, { group_size_min, group_size_max} ) => `${group_size_min} - ${group_size_max}`, + }, + { + key: 'useDates', + dataIndex: ['use_dates_start'], + title: t('UseDates'), + render: (_, { use_dates_start, use_dates_end} ) => `${use_dates_start} ~ ${use_dates_end}`, + }, + { key: 'weekdays', dataIndex: ['weekdays'], title: t('Weekdays'), }, + {key: 'status', title: t('Status'), render: () => '已通过'}, + { + title: '', + key: 'action', + render: () => ( + + + + + ), + }, + ]; + return
r.id} />; +} + +/** + * + */ +const TypesPanels = () => { + const [loading, agencyProducts] = useProductsStore((state) => [state.loading, state.agencyProducts]); + // console.log(agencyProducts); + const productsTypes = useProductsTypes(); + const [activeKey, setActiveKey] = useState([]); + const [showTypes, setShowTypes] = useState([]); + useEffect(() => { + // 只显示有产品的类型 + const hasDataTypes = Object.keys(agencyProducts); + const _show = productsTypes + .filter((kk) => hasDataTypes.includes(kk.value)) + .map((ele) => ({ ...ele, children: r.concat(c.quotation.map((q, i) => ({ ...q, info: c.info, rowSpan: i=== 0 ? c.quotation.length : 0 }))), [])} /> })); + setShowTypes(_show); + + setActiveKey(isEmpty(_show) ? [] : [_show[0].key]); + + return () => {}; + }, [productsTypes, agencyProducts]); + + const onCollapseChange = (_activeKey) => { + setActiveKey(_activeKey) + } + return ( + + ) +} + const Audit = ({ ...props }) => { + // const [loading, agencyProducts] = useProductsStore((state) => [state.loading, state.agencyProducts]); + return ( <> - }> - + }> +
+ + {/* */}
); diff --git a/src/views/products/Index.jsx b/src/views/products/Index.jsx index df1b189..0562519 100644 --- a/src/views/products/Index.jsx +++ b/src/views/products/Index.jsx @@ -1,17 +1,17 @@ import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { Row, Col, Space, Typography, Table, Button } from 'antd'; -import useProductsStore from '@/stores/Products/Index'; import { usingStorage } from '@/hooks/usingStorage'; import SearchForm from '@/components/SearchForm'; import dayjs from 'dayjs'; import { useTranslation } from 'react-i18next'; +import useProductsStore from '@/stores/Products/Index'; import { useProductsTypes } from '@/hooks/useProductsSets'; function Index() { const { t } = useTranslation(); const { userId } = usingStorage(); - const [loading, productsList] = useProductsStore((state) => [state.loading, state.productsList]); + const [loading, agencyList, ] = useProductsStore((state) => [state.loading, state.agencyList, ]); const [noticeList, setNoticeList] = useState([]); useEffect(() => {}, []); @@ -56,7 +56,7 @@ function Index() { />
-
+
From a579ee4ee5f3686e287408296da17c8d59c39725 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 19 Jun 2024 10:20:21 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8F=82=E6=95=B0:=20lgc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/LanguageSwitcher.jsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/i18n/LanguageSwitcher.jsx b/src/i18n/LanguageSwitcher.jsx index ac1f009..af87005 100644 --- a/src/i18n/LanguageSwitcher.jsx +++ b/src/i18n/LanguageSwitcher.jsx @@ -1,6 +1,12 @@ -import React, { useState } from 'react'; -import { Dropdown, Menu } from 'antd'; +import { useState, useEffect } from 'react'; +import { Dropdown } from 'antd'; import { useTranslation } from 'react-i18next'; +import { appendRequestParams } from '@/utils/request'; + +const i18n_to_htcode = { + 'zh': 2, + 'en': 1, +}; /** * 语言选择组件 @@ -8,6 +14,13 @@ import { useTranslation } from 'react-i18next'; const Language = () => { const { t, i18n } = useTranslation(); const [selectedKeys, setSelectedKeys] = useState([i18n.language]); + + useEffect(() => { + appendRequestParams('lgc', i18n_to_htcode[i18n.language]); + + return () => {}; + }, [i18n.language]); + // 切换语言事件 const handleChangeLanguage = ({ key }) => { setSelectedKeys([key]); From d24c34d4acf93dacae1fa35e427a37ade7cda7d3 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 19 Jun 2024 13:45:11 +0800 Subject: [PATCH 4/9] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86:=20=E5=AE=A2=E6=9C=8D=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/en/common.json | 4 +++ public/locales/en/products.json | 5 +++- public/locales/zh/common.json | 4 +++ public/locales/zh/products.json | 4 ++- src/components/SearchForm.jsx | 8 +++--- src/hooks/useProductsSets.js | 16 ++++++++---- src/stores/Products/Index.js | 12 +++++++-- src/views/products/Audit.jsx | 44 +++++++++++++-------------------- src/views/products/Index.jsx | 35 +++++++++++++++++--------- 9 files changed, 80 insertions(+), 52 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 09471cf..b113807 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -25,6 +25,10 @@ "Export": "Export", "Copy": "Copy", + "Table": { + "Total": "Total {{total}} items" + }, + "Login": "Login", "Username": "Username", "Password": "Password", diff --git a/public/locales/en/products.json b/public/locales/en/products.json index 637b8f8..35c6d67 100644 --- a/public/locales/en/products.json +++ b/public/locales/en/products.json @@ -12,11 +12,12 @@ "auditState": { "New": "New", "Pending": "Pending", - "Approve": "Approve", + "Approved": "Approved", "Rejected": "Rejected", "Published": "Published" }, "Status": "Status", + "State": "State", "Title": "Title", "Vendor": "Vendor", @@ -27,6 +28,8 @@ "AuditDate": "Audit Date", "Quotation": "Quotation", + "Offer": "Offer", + "Unit": "Unit", "GroupSize": "Group Size", "UseDates": "Use Dates", diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index 2c54705..e3239a1 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -25,6 +25,10 @@ "Export": "导出", "Copy": "复制", + "Table": { + "Total": "共 {{total}} 条" + }, + "Login": "登录", "Username": "账号", "Password": "密码", diff --git a/public/locales/zh/products.json b/public/locales/zh/products.json index 932fc24..d4d640d 100644 --- a/public/locales/zh/products.json +++ b/public/locales/zh/products.json @@ -12,11 +12,12 @@ "auditState": { "New": "新增", "Pending": "待审核", - "Approve": "已通过", + "Approved": "已通过", "Rejected": "已拒绝", "Published": "已发布" }, "Status": "状态", + "State": "状态", "Title": "名称", "Vendor": "供应商", @@ -27,6 +28,7 @@ "AuditDate": "审核时间", "Quotation": "报价", + "Offer": "报价", "Unit": "单位", "GroupSize": "人等", "UseDates": "使用日期", diff --git a/src/components/SearchForm.jsx b/src/components/SearchForm.jsx index ab5626b..9f55352 100644 --- a/src/components/SearchForm.jsx +++ b/src/components/SearchForm.jsx @@ -50,7 +50,7 @@ const SearchForm = ({ initialValue, onSubmit, onReset, ...props }) => { { key: 'endtime', transform: (arrVal) => (arrVal ? arrVal[1].format(SMALL_DATETIME_FORMAT) : '') }, ], 'invoiceStatus': { key: 'invoiceStatus', transform: (value) => value?.value || value?.key || '', default: '' }, - 'auditState': { key: 'auditState', transform: (value) => value?.value || value?.key || '', default: '' }, + 'audit_state': { key: 'audit_state', transform: (value) => value?.value || value?.key || '', default: '' }, 'agency': { key: 'agency', transform: (value) => { @@ -217,12 +217,12 @@ function getFields(props) { fieldProps?.agency?.col || 6 ), item( - 'auditState', + 'audit_state', 99, - + , - fieldProps?.auditState?.col || 3 + fieldProps?.audit_state?.col || 3 ), ]; diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index 888368d..f002991 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -33,14 +33,20 @@ export const useProductsAuditStates = () => { useEffect(() => { const newData = [ - { key: '0', value: '0', label: t('products:auditState.New') }, - { key: '1', value: '1', label: t('products:auditState.Pending') }, - { key: '2', value: '2', label: t('products:auditState.Approve') }, - { key: '3', value: '3', label: t('products:auditState.Rejected') }, - { key: '4', value: '4', label: t('products:auditState.Published') }, + { key: '-1', value: '-1', label: t('products:auditState.New') }, + { key: '0', value: '0', label: t('products:auditState.Pending') }, + { key: '2', value: '2', label: t('products:auditState.Approved') }, + // { key: '3', value: '3', label: t('products:auditState.Rejected') }, + { key: '1', value: '1', label: t('products:auditState.Published') }, ]; setTypes(newData); }, [i18n.language]); return types; }; + +export const useProductsAuditStatesMapVal = (value) => { + const stateSets = useProductsAuditStates(); + const stateMapVal = stateSets.reduce((r, c) => ({ ...r, [`${c.value}`]: c }), {}); + return stateMapVal; +}; diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 1747757..ecd1fe1 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -5,9 +5,9 @@ import { fetchJSON } from '@/utils/request'; import { HT_HOST } from '@/config'; import { groupBy } from '@/utils/commons'; -const searchAgency = async (param) => { +const searchAgencyAction = async (param) => { const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); - + return errcode !== 0 ? [] : result; }; const getAgencyProducts = async (param) => { const { errcode, Result, Result1 } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); @@ -265,6 +265,7 @@ export const useProductsStore = create( ...initialState, // state actions + setLoading: loading => set({ loading }), setAgencyList: (agencyList) => set({ agencyList }), setActiveAgency: activeAgency => set({ activeAgency }), setAgencyProducts: agencyProducts => set({ agencyProducts }), @@ -272,6 +273,13 @@ export const useProductsStore = create( reset: () => set(initialState), // side effects + searchAgency: async (param) => { + const { setLoading, setAgencyList } = get(); + setLoading(true); + const res = await searchAgencyAction(param); + setAgencyList(res); + setLoading(false); + }, })) ); export default useProductsStore; diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index cc5b79f..cbc8fdb 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -1,7 +1,7 @@ import { createContext, useContext, useEffect, useState } from 'react'; import { Link, useLocation, } from 'react-router-dom'; import { Button, Collapse, Table, Tabs, Typography, Space, } from 'antd'; -import { useProductsTypes } from '@/hooks/useProductsSets'; +import { useProductsTypes, useProductsAuditStatesMapVal, useProductsAuditStates } from '@/hooks/useProductsSets'; import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; import { useTranslation } from 'react-i18next'; import useProductsStore from '@/stores/Products/Index'; @@ -21,26 +21,10 @@ const Header = ({title, ...props}) => { ); }; -const TypesTabs = () => { - const productsTypes = useProductsTypes(); - return ( - - ) -} - -const subjectComponents = { - // 'sum_profit': ProfitTable, - // 'in_order_count': Count, - // 'confirm_order_count': Count, - // 'depart_order_count': Count, - // 'confirm_rates': Rates, - // 'praise_rates': Rates, - // 'sum_person_num': Count, -}; - -const PriceTable = ({dataSource}) => { +const PriceTable = ({dataSource, loading}) => { const { t } = useTranslation('products'); - // console.log(dataSource, ); + const stateMapVal = useProductsAuditStatesMapVal(); + const columns = [ { key: 'title', dataIndex: ['info', 'title'], title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) }, { key: 'value', title: t('Quotation'), render: (_, { value, currency, unit }) => `${value} ${currency} / ${unit}` }, @@ -52,23 +36,29 @@ const PriceTable = ({dataSource}) => { key: 'groupSize', dataIndex: ['group_size_min'], title: t('GroupSize'), - render: (_, { group_size_min, group_size_max} ) => `${group_size_min} - ${group_size_max}`, + render: (_, { group_size_min, group_size_max }) => `${group_size_min} - ${group_size_max}`, }, { key: 'useDates', dataIndex: ['use_dates_start'], title: t('UseDates'), - render: (_, { use_dates_start, use_dates_end} ) => `${use_dates_start} ~ ${use_dates_end}`, + render: (_, { use_dates_start, use_dates_end }) => `${use_dates_start} ~ ${use_dates_end}`, + }, + { key: 'weekdays', dataIndex: ['weekdays'], title: t('Weekdays') }, + { + key: 'state', + title: t('State'), + render: (_, r) => { + return stateMapVal[`${r.info.audit_state}`]?.label; + }, }, - { key: 'weekdays', dataIndex: ['weekdays'], title: t('Weekdays'), }, - {key: 'status', title: t('Status'), render: () => '已通过'}, { title: '', key: 'action', render: () => ( - - + + ), }, @@ -90,7 +80,7 @@ const TypesPanels = () => { const hasDataTypes = Object.keys(agencyProducts); const _show = productsTypes .filter((kk) => hasDataTypes.includes(kk.value)) - .map((ele) => ({ ...ele, children: r.concat(c.quotation.map((q, i) => ({ ...q, info: c.info, rowSpan: i=== 0 ? c.quotation.length : 0 }))), [])} /> })); + .map((ele) => ({ ...ele, children: r.concat(c.quotation.map((q, i) => ({ ...q, info: c.info, rowSpan: i=== 0 ? c.quotation.length : 0 }))), [])} /> })); setShowTypes(_show); setActiveKey(isEmpty(_show) ? [] : [_show[0].key]); diff --git a/src/views/products/Index.jsx b/src/views/products/Index.jsx index 0562519..02d57ec 100644 --- a/src/views/products/Index.jsx +++ b/src/views/products/Index.jsx @@ -1,22 +1,29 @@ -import { useEffect, useState } from 'react'; +import { useEffect } from 'react'; import { Link } from 'react-router-dom'; -import { Row, Col, Space, Typography, Table, Button } from 'antd'; -import { usingStorage } from '@/hooks/usingStorage'; +import { Row, Col, Space, Table } from 'antd'; import SearchForm from '@/components/SearchForm'; import dayjs from 'dayjs'; import { useTranslation } from 'react-i18next'; import useProductsStore from '@/stores/Products/Index'; -import { useProductsTypes } from '@/hooks/useProductsSets'; +import useFormStore from '@/stores/Form'; +import { objectMapper } from '@/utils/commons'; function Index() { const { t } = useTranslation(); - const { userId } = usingStorage(); - const [loading, agencyList, ] = useProductsStore((state) => [state.loading, state.agencyList, ]); + const [loading, agencyList, searchAgency] = useProductsStore((state) => [state.loading, state.agencyList, state.searchAgency]); + const formValuesToSub = useFormStore(state => state.formValuesToSub); - const [noticeList, setNoticeList] = useState([]); - useEffect(() => {}, []); + const handleSearchAgency = (formVal = undefined) => { + const { starttime, endtime, ...param } = formVal || formValuesToSub; + const searchParam = objectMapper(param, { agency: 'travel_agency_id', startdate: 'edit_date1', enddate: 'edit_date2' }); + searchAgency(searchParam); + } - const showTotal = (total) => `Total ${total} items`; + useEffect(() => { + handleSearchAgency(); + }, []); + + const showTotal = (total) => t('Table.Total', { total }); const columns = [ { title: t('products:Vendor'), key: 'vendor', dataIndex: 'travel_agency_name' }, @@ -40,18 +47,22 @@ function Index() { { + handleSearchAgency(formVal); }} /> From f8ffaf899d77dd7d106a31a8328da09e3dcf82e3 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 19 Jun 2024 15:55:06 +0800 Subject: [PATCH 5/9] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86:=20=E5=AE=A2=E6=9C=8D=E5=AE=A1=E6=A0=B8=E4=BA=A7?= =?UTF-8?q?=E5=93=81,=20=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/en/products.json | 7 +++ public/locales/zh/products.json | 7 +++ src/stores/Products/Index.js | 64 ++++++++++++++++++------ src/views/products/Audit.jsx | 87 +++++++++++++++++++++++++++------ 4 files changed, 134 insertions(+), 31 deletions(-) diff --git a/public/locales/en/products.json b/public/locales/en/products.json index 35c6d67..6033e89 100644 --- a/public/locales/en/products.json +++ b/public/locales/en/products.json @@ -16,6 +16,13 @@ "Rejected": "Rejected", "Published": "Published" }, + "auditStateAction": { + "New": "New", + "Pending": "Pending", + "Approved": "Approve", + "Rejected": "Rejecte", + "Published": "Publish" + }, "Status": "Status", "State": "State", diff --git a/public/locales/zh/products.json b/public/locales/zh/products.json index d4d640d..01f7836 100644 --- a/public/locales/zh/products.json +++ b/public/locales/zh/products.json @@ -16,6 +16,13 @@ "Rejected": "已拒绝", "Published": "已发布" }, + "auditStateAction": { + "New": "新增", + "Pending": "待审核", + "Approved": "审核通过", + "Rejected": "审核拒绝", + "Published": "发布上线" + }, "Status": "状态", "State": "状态", diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index ecd1fe1..544c478 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -1,32 +1,53 @@ import { create } from 'zustand'; import { devtools } from 'zustand/middleware'; -import { fetchJSON } from '@/utils/request'; +import { fetchJSON, postForm } from '@/utils/request'; import { HT_HOST } from '@/config'; import { groupBy } from '@/utils/commons'; -const searchAgencyAction = async (param) => { +export const searchAgencyAction = async (param) => { const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); return errcode !== 0 ? [] : result; }; -const getAgencyProducts = async (param) => { - const { errcode, Result, Result1 } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); +export const getAgencyProductsAction = async (param) => { + const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel-agency-products`, param); + return errcode !== 0 ? [] : result; +}; + +export const postProductsQuoteAudit = async (auditState, quoteRow) => { + const postbody = { + audit_state: auditState, + id: quoteRow.id, + travel_agency_id: quoteRow.info.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-quote-audit`, formData); + return json; + // return errcode !== 0 ? {} : result; +}; + +export const postProductsAudit = async (auditState, infoRow) => { + const postbody = { + audit_state: auditState, + id: infoRow.id, + travel_agency_id: infoRow.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 } = json; + // return errcode !== 0 ? {} : result; }; const initialState = { loading: false, - agencyList: [ - { - 'audit_date': '2001-03-03', - 'travel_agency_name': '新油低外', - 'travel_agency_id': '650000200301029585', - 'created_by': '冯丽', - 'create_date': '1989-06-20', - 'lastedit_memo': 'nostrud ad eu', - 'audited_by': '黎静', - 'audit_state': '1', - }, - ], + agencyList: [], activeAgency: {}, agencyProducts: groupBy([ { @@ -280,6 +301,17 @@ export const useProductsStore = create( setAgencyList(res); setLoading(false); }, + + getAgencyProducts: async (param) => { + const { setLoading, setActiveAgency, setAgencyProducts } = get(); + setLoading(true); + const res = await getAgencyProductsAction(param); + const productsData = groupBy(res, row => row.info.type); + setAgencyProducts(productsData); + setActiveAgency(res[0].info); + setLoading(false); + }, + })) ); export default useProductsStore; diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index cbc8fdb..3a4f3e6 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -1,14 +1,31 @@ -import { createContext, useContext, useEffect, useState } from 'react'; -import { Link, useLocation, } from 'react-router-dom'; -import { Button, Collapse, Table, Tabs, Typography, Space, } from 'antd'; -import { useProductsTypes, useProductsAuditStatesMapVal, useProductsAuditStates } from '@/hooks/useProductsSets'; +import { useEffect, useState } from 'react'; +import { useParams, } from 'react-router-dom'; +import { App, Button, Collapse, Table, Space, } from 'antd'; +import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProductsSets'; import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; import { useTranslation } from 'react-i18next'; -import useProductsStore from '@/stores/Products/Index'; +import useProductsStore, { postProductsQuoteAudit } from '@/stores/Products/Index'; import { isEmpty } from '@/utils/commons'; -const Header = ({title, ...props}) => { +const Header = ({ title, agency, ...props}) => { const { t } = useTranslation(); + const { message, notification } = App.useApp(); + const handleAuditItem = (state, row) => { + postProductsQuoteAudit(state, row) + .then((json) => { + if (json.errcode === 0) { + message.success('✔'); + } + }) + .catch((ex) => { + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + duration: 4, + }); + }); + }; return (
@@ -16,15 +33,37 @@ const Header = ({title, ...props}) => {
{/* */} {/* */} - + + {/* todo: export */} +
); }; const PriceTable = ({dataSource, loading}) => { const { t } = useTranslation('products'); + const { message, notification } = App.useApp(); const stateMapVal = useProductsAuditStatesMapVal(); + const handleAuditPriceItem = (state, row) => { + postProductsQuoteAudit(state, row) + .then((json) => { + if (json.errcode === 0) { + message.success('✔'); + } + }) + .catch((ex) => { + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + duration: 4, + }); + }); + }; + const columns = [ { key: 'title', dataIndex: ['info', 'title'], title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) }, { key: 'value', title: t('Quotation'), render: (_, { value, currency, unit }) => `${value} ${currency} / ${unit}` }, @@ -55,10 +94,10 @@ const PriceTable = ({dataSource, loading}) => { { title: '', key: 'action', - render: () => ( + render: (_, r) => ( - - + + ), }, @@ -76,11 +115,19 @@ const TypesPanels = () => { const [activeKey, setActiveKey] = useState([]); const [showTypes, setShowTypes] = useState([]); useEffect(() => { - // 只显示有产品的类型 + // 只显示有产品的类型; 展开产品的价格表, 合并名称列 const hasDataTypes = Object.keys(agencyProducts); const _show = productsTypes .filter((kk) => hasDataTypes.includes(kk.value)) - .map((ele) => ({ ...ele, children: r.concat(c.quotation.map((q, i) => ({ ...q, info: c.info, rowSpan: i=== 0 ? c.quotation.length : 0 }))), [])} /> })); + .map((ele) => ({ + ...ele, + children: ( + r.concat(c.quotation.map((q, i) => ({ ...q, info: c.info, rowSpan: i === 0 ? c.quotation.length : 0 }))), [])} + /> + ), + })); setShowTypes(_show); setActiveKey(isEmpty(_show) ? [] : [_show[0].key]); @@ -97,14 +144,24 @@ const TypesPanels = () => { } const Audit = ({ ...props }) => { - // const [loading, agencyProducts] = useProductsStore((state) => [state.loading, state.agencyProducts]); + const { agencyId: travel_agency_id } = useParams(); + const [activeAgency, getAgencyProducts] = useProductsStore((state) => [state.activeAgency, state.getAgencyProducts]); + + const handleGetAgencyProducts = () => { + getAgencyProducts({ travel_agency_id }); + } + + useEffect(() => { + handleGetAgencyProducts(); + + return () => {}; + }, [travel_agency_id]) return ( <> - }> + }>
- {/* */}
); From a7c87170a0154d68314944ec7f35965214f54c09 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 20 Jun 2024 14:04:22 +0800 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86:=20=E5=AE=A2=E6=9C=8D=E9=A6=96=E9=A1=B5,=20=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E4=BA=A7=E5=93=81:=20=E6=A0=B8=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SearchForm.jsx | 6 +++--- src/hooks/useProductsSets.js | 25 ++++++++++++++++++++----- src/stores/Products/Index.js | 12 ++++++------ src/views/products/Audit.jsx | 12 +++++++----- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/components/SearchForm.jsx b/src/components/SearchForm.jsx index 9f55352..6a53cac 100644 --- a/src/components/SearchForm.jsx +++ b/src/components/SearchForm.jsx @@ -15,8 +15,8 @@ import AuditStateSelector from './AuditStateSelector'; //供应商列表 export const fetchVendorList = async () => { - const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-cusservice/PTGetHWVendorList`) - return errcode !== 0 ? [] : Result + const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/VendorList`) + return errcode !== 0 ? [] : result } const { RangePicker } = DatePicker; @@ -212,7 +212,7 @@ function getFields(props) { 'agency', 99, - + , fieldProps?.agency?.col || 6 ), diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index f002991..93feaac 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -3,6 +3,21 @@ import { useTranslation } from 'react-i18next'; /** * 产品管理 相关的预设数据 + * 项目类型 +1 酒店预定 +2 火车 +3 飞机票务 +4 游船 +5 快巴 +6 旅行社(综费) +7 景点 +8 特殊项目 +9 其他 +A 酒店 +B 超公里 +C 餐费 +D 包价包 +X 站 */ export const useProductsTypes = () => { @@ -11,13 +26,13 @@ export const useProductsTypes = () => { useEffect(() => { const newData = [ - { label: t('products:type.Experience'), value: 'Experience', key: 'Experience' }, + { label: t('products:type.Experience'), value: '6', key: '6' }, { label: t('products:type.Car'), value: 'Car', key: 'Car' }, { label: t('products:type.Guide'), value: 'Guide', key: 'Guide' }, - { label: t('products:type.Package'), value: 'Package', key: 'Package' }, - { label: t('products:type.Attractions'), value: 'Attractions', key: 'Attractions' }, - { label: t('products:type.Meals'), value: 'Meals', key: 'Meals' }, - { label: t('products:type.Extras'), value: 'Extras', key: 'Extras' }, + { label: t('products:type.Package'), value: 'D', key: 'D' }, + { label: t('products:type.Attractions'), value: '7', key: '7' }, + { label: t('products:type.Meals'), value: 'C', key: 'C' }, + { label: t('products:type.Extras'), value: '8', key: '8' }, { label: t('products:type.Special'), value: 'Special', key: 'Special' }, ]; setTypes(newData); diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 544c478..51d3010 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -10,21 +10,21 @@ export const searchAgencyAction = async (param) => { return errcode !== 0 ? [] : result; }; export const getAgencyProductsAction = async (param) => { - const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel-agency-products`, param); - return errcode !== 0 ? [] : result; + const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel_agency_products`, param); + return errcode !== 0 ? { agency: {}, products: [] } : result; }; export const postProductsQuoteAudit = async (auditState, quoteRow) => { const postbody = { audit_state: auditState, id: quoteRow.id, - travel_agency_id: quoteRow.info.travel_agency_id, + travel_agency_id: quoteRow.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-quote-audit`, formData); + const json = await postForm(`${HT_HOST}/Service_BaseInfoWeb/quotation_audit`, formData); return json; // return errcode !== 0 ? {} : result; }; @@ -306,9 +306,9 @@ export const useProductsStore = create( const { setLoading, setActiveAgency, setAgencyProducts } = get(); setLoading(true); const res = await getAgencyProductsAction(param); - const productsData = groupBy(res, row => row.info.type); + const productsData = groupBy(res.products, row => row.info.product_type_id); setAgencyProducts(productsData); - setActiveAgency(res[0].info); + setActiveAgency(res.agency); setLoading(false); }, diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index 3a4f3e6..16cefc9 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -9,9 +9,10 @@ import { isEmpty } from '@/utils/commons'; const Header = ({ title, agency, ...props}) => { const { t } = useTranslation(); + const [activeAgency, ] = useProductsStore((state) => [state.activeAgency]); const { message, notification } = App.useApp(); const handleAuditItem = (state, row) => { - postProductsQuoteAudit(state, row) + postProductsQuoteAudit(state, {id: row.id, travel_agency_id: activeAgency.travel_agency_id}) .then((json) => { if (json.errcode === 0) { message.success('✔'); @@ -44,11 +45,12 @@ const Header = ({ title, agency, ...props}) => { const PriceTable = ({dataSource, loading}) => { const { t } = useTranslation('products'); + const [activeAgency, ] = useProductsStore((state) => [state.activeAgency]); const { message, notification } = App.useApp(); const stateMapVal = useProductsAuditStatesMapVal(); const handleAuditPriceItem = (state, row) => { - postProductsQuoteAudit(state, row) + postProductsQuoteAudit(state, {id: row.id, travel_agency_id: activeAgency.travel_agency_id}) .then((json) => { if (json.errcode === 0) { message.success('✔'); @@ -66,7 +68,7 @@ const PriceTable = ({dataSource, loading}) => { const columns = [ { key: 'title', dataIndex: ['info', 'title'], title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) }, - { key: 'value', title: t('Quotation'), render: (_, { value, currency, unit }) => `${value} ${currency} / ${unit}` }, + { key: 'value', title: t('Quotation'), render: (_, { value, currency, unit_name }) => `${value} ${currency} / ${unit_name}` }, // {key: 'price', title: t('Currency'), }, // {key: 'currency', title: t('Currency'), }, // {key: 'unit', title: t('Unit'), }, @@ -88,7 +90,7 @@ const PriceTable = ({dataSource, loading}) => { key: 'state', title: t('State'), render: (_, r) => { - return stateMapVal[`${r.info.audit_state}`]?.label; + return stateMapVal[`${r.audit_state_id}`]?.label; }, }, { @@ -144,7 +146,7 @@ const TypesPanels = () => { } const Audit = ({ ...props }) => { - const { agencyId: travel_agency_id } = useParams(); + const { travel_agency_id } = useParams(); const [activeAgency, getAgencyProducts] = useProductsStore((state) => [state.activeAgency, state.getAgencyProducts]); const handleGetAgencyProducts = () => { From a61ef8882baabc51b483b1b0555644a0bbb39daa Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 21 Jun 2024 09:38:35 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8F=82=E6=95=B0:=20wu=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useProductsSets.js | 14 +++++++------- src/stores/Auth.js | 1 + src/views/App.jsx | 3 ++- src/views/products/Audit.jsx | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index 93feaac..0994b3f 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -9,13 +9,13 @@ import { useTranslation } from 'react-i18next'; 3 飞机票务 4 游船 5 快巴 -6 旅行社(综费) -7 景点 -8 特殊项目 +6 旅行社(综费) - +7 景点 - +8 特殊项目 - 9 其他 A 酒店 -B 超公里 -C 餐费 +B 超公里 - +C 餐费 - D 包价包 X 站 */ @@ -33,7 +33,7 @@ export const useProductsTypes = () => { { label: t('products:type.Attractions'), value: '7', key: '7' }, { label: t('products:type.Meals'), value: 'C', key: 'C' }, { label: t('products:type.Extras'), value: '8', key: '8' }, - { label: t('products:type.Special'), value: 'Special', key: 'Special' }, + // { label: t('products:type.Special'), value: 'Special', key: 'Special' }, ]; setTypes(newData); }, [i18n.language]); @@ -51,7 +51,7 @@ export const useProductsAuditStates = () => { { key: '-1', value: '-1', label: t('products:auditState.New') }, { key: '0', value: '0', label: t('products:auditState.Pending') }, { key: '2', value: '2', label: t('products:auditState.Approved') }, - // { key: '3', value: '3', label: t('products:auditState.Rejected') }, + { key: '3', value: '3', label: t('products:auditState.Rejected') }, { key: '1', value: '1', label: t('products:auditState.Published') }, ]; setTypes(newData); diff --git a/src/stores/Auth.js b/src/stores/Auth.js index f7f31f3..5511e6b 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -88,6 +88,7 @@ const useAuthStore = create((set, get) => ({ setStorage(KEY_TRAVEL_AGENCY_ID, userDetail.LMI_VEI_SN) setStorage(KEY_USER_DETAIL, {username: userDetail.LoginName, travelAgencyName: userDetail.VName}) appendRequestParams('token', loginToken) + appendRequestParams('wu_id', userDetail.LMI_SN) // loadPageSpy(`${json.Result.VName}-${json.Result.LoginName}`) startTokenInterval() }, diff --git a/src/views/App.jsx b/src/views/App.jsx index 0edd221..b61c1ce 100644 --- a/src/views/App.jsx +++ b/src/views/App.jsx @@ -28,7 +28,7 @@ function App() { const [validateUserPassword, tokenTimeout] = useAuthStore( (state) => [state.validateUserPassword, state.tokenTimeout]) - const { loginToken, userDetail } = usingStorage() + const { loginToken, userDetail, userId } = usingStorage() const noticeUnRead = useNoticeStore((state) => state.noticeUnRead) const href = useHref() @@ -40,6 +40,7 @@ function App() { if (!needToLogin) { appendRequestParams('token', loginToken) + appendRequestParams('wu_id', userId) } useEffect(() => { diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index 16cefc9..c548de2 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -96,12 +96,12 @@ const PriceTable = ({dataSource, loading}) => { { title: '', key: 'action', - render: (_, r) => ( + render: (_, r) => r.audit_state_id <= 0 ?( - ), + ) : null, }, ]; return
r.id} />; From e9b7aec5219c997bc6acce03d232c99d83237ecb Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 21 Jun 2024 14:20:06 +0800 Subject: [PATCH 8/9] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86:=20=E6=90=9C=E7=B4=A2+=E5=B9=B4=E4=BB=BD,=E7=8A=B6?= =?UTF-8?q?=E6=80=81;=20=E4=BA=A7=E5=93=81=E7=B1=BB=E5=9E=8B=E6=8E=92?= =?UTF-8?q?=E5=BA=8F;=20=E5=AE=A1=E6=A0=B8=E9=A1=B5:=20=E6=88=90=E4=BA=BA,?= =?UTF-8?q?=E5=84=BF=E7=AB=A5=E4=BB=B7;=20=E8=AF=AD=E7=A7=8D=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= 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 | 7 +- src/components/SearchForm.jsx | 35 ++- src/components/SearchInput.jsx | 1 + .../{usePresets.js => useDatePresets.js} | 4 +- src/hooks/useLanguageSets.js | 14 ++ src/hooks/useProductsSets.js | 1 + src/main.jsx | 4 +- src/stores/Products/Index.js | 236 +----------------- src/views/products/Audit.jsx | 51 ++-- src/views/products/Index.jsx | 27 +- 11 files changed, 111 insertions(+), 274 deletions(-) rename src/hooks/{usePresets.js => useDatePresets.js} (91%) create mode 100644 src/hooks/useLanguageSets.js diff --git a/public/locales/en/products.json b/public/locales/en/products.json index 6033e89..b5e7694 100644 --- a/public/locales/en/products.json +++ b/public/locales/en/products.json @@ -7,6 +7,7 @@ "Attractions": "Attractions", "Meals": "Meals", "Extras": "Extras", + "Overtravel": "超公里", "Special": "Special" }, "auditState": { @@ -20,7 +21,7 @@ "New": "New", "Pending": "Pending", "Approved": "Approve", - "Rejected": "Rejecte", + "Rejected": "Reject", "Published": "Publish" }, "Status": "Status", @@ -42,6 +43,8 @@ "UseDates": "Use Dates", "Weekdays": "Weekdays", + "UseYear": "Use Year", + "AgeType": { "Type": "Age Type", "Adult": "Adult", diff --git a/public/locales/zh/products.json b/public/locales/zh/products.json index 01f7836..9f1f8b6 100644 --- a/public/locales/zh/products.json +++ b/public/locales/zh/products.json @@ -6,7 +6,8 @@ "Package": "包价线路", "Attractions": "景点", "Meals": "餐费", - "Extras": "附加", + "Extras": "附加项目", + "Overtravel": "超公里", "Special": "特殊项目" }, "auditState": { @@ -21,7 +22,7 @@ "Pending": "待审核", "Approved": "审核通过", "Rejected": "审核拒绝", - "Published": "发布上线" + "Published": "审核发布" }, "Status": "状态", "State": "状态", @@ -41,6 +42,8 @@ "UseDates": "使用日期", "Weekdays": "有效日/周X", + "UseYear": "年份", + "AgeType": { "Type": "人群", "Adult": "成人", diff --git a/src/components/SearchForm.jsx b/src/components/SearchForm.jsx index 6a53cac..a669294 100644 --- a/src/components/SearchForm.jsx +++ b/src/components/SearchForm.jsx @@ -3,7 +3,7 @@ import { Form, Input, Row, Col, Select, DatePicker, Space, Button } from 'antd'; import { objectMapper, at } from '@/utils/commons'; import { DATE_FORMAT, SMALL_DATETIME_FORMAT } from '@/config'; import useFormStore from '@/stores/Form'; -import usePresets from '@/hooks/usePresets'; +import useDatePresets from '@/hooks/useDatePresets'; import { useTranslation } from 'react-i18next'; import { fetchJSON } from '@/utils/request'; @@ -14,8 +14,8 @@ import AuditStateSelector from './AuditStateSelector'; //供应商列表 -export const fetchVendorList = async () => { - const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/VendorList`) +export const fetchVendorList = async (q) => { + const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/VendorList`, { q }) return errcode !== 0 ? [] : result } @@ -23,7 +23,7 @@ const { RangePicker } = DatePicker; const SearchForm = ({ initialValue, onSubmit, onReset, ...props }) => { const { t } = useTranslation(); - const presets = usePresets(); + const presets = useDatePresets(); const [formValues, setFormValues] = useFormStore((state) => [state.formValues, state.setFormValues]); const [formValuesToSub, setFormValuesToSub] = useFormStore((state) => [state.formValuesToSub, state.setFormValuesToSub]); const [form] = Form.useForm(); @@ -57,6 +57,9 @@ const SearchForm = ({ initialValue, onSubmit, onReset, ...props }) => { return Array.isArray(value) ? value.map((ele) => ele.key).join(',') : value ? value.value : ''; }, }, + 'year': [ + { key: 'year', transform: (arrVal) => (arrVal ? arrVal.format('YYYY') : '') }, + ], }; let dest = {}; const { dates, ...omittedValue } = values; @@ -165,15 +168,15 @@ function getFields(props) { 'referenceNo', 99, - + , fieldProps?.referenceNo?.col || 6 ), item( 'PNR', 99, - - + + , fieldProps?.PNR?.col || 4 ), @@ -208,11 +211,26 @@ function getFields(props) { /** * */ + item( + 'year', + 99, + + + , + fieldProps?.year?.col || 3 + ), item( 'agency', 99, - + , fieldProps?.agency?.col || 6 ), @@ -224,7 +242,6 @@ function getFields(props) { , fieldProps?.audit_state?.col || 3 ), - ]; baseChildren = baseChildren .map((x) => { diff --git a/src/components/SearchInput.jsx b/src/components/SearchInput.jsx index d816647..dcf2657 100644 --- a/src/components/SearchInput.jsx +++ b/src/components/SearchInput.jsx @@ -31,6 +31,7 @@ function DebounceSelect({ fetchOptions, debounceTimeout = 800, ...props }) { showSearch allowClear maxTagCount={1} + dropdownStyle={{width: '16rem'}} {...props} onSearch={debounceFetcher} notFoundContent={fetching ? : null} diff --git a/src/hooks/usePresets.js b/src/hooks/useDatePresets.js similarity index 91% rename from src/hooks/usePresets.js rename to src/hooks/useDatePresets.js index aa046e6..87397b9 100644 --- a/src/hooks/usePresets.js +++ b/src/hooks/useDatePresets.js @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; import dayjs from "dayjs"; import { useTranslation } from 'react-i18next'; -const usePresets = () => { +const useDatePresets = () => { const [presets, setPresets] = useState([]); const { t, i18n } = useTranslation(); @@ -39,4 +39,4 @@ const usePresets = () => { return presets; } -export default usePresets; +export default useDatePresets; diff --git a/src/hooks/useLanguageSets.js b/src/hooks/useLanguageSets.js new file mode 100644 index 0000000..1dab4b1 --- /dev/null +++ b/src/hooks/useLanguageSets.js @@ -0,0 +1,14 @@ +export const useLanguageSets = () => { + const newData = [ + { key: '1', value: '1', label: 'English' }, + { key: '2', value: '2', label: 'Chinese (中文)' }, + { key: '3', value: '3', label: 'Japanese (日本語)' }, + { key: '4', value: '4', label: 'German (Deutsch)' }, + { key: '5', value: '5', label: 'French (Français)' }, + { key: '6', value: '6', label: 'Spanish (Español)' }, + { key: '7', value: '7', label: 'Russian (Русский)' }, + { key: '8', value: '8', label: 'Italian (Italiano)' }, + ]; + + return newData; +}; diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index 0994b3f..5f3a85b 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -27,6 +27,7 @@ export const useProductsTypes = () => { useEffect(() => { const newData = [ { label: t('products:type.Experience'), value: '6', key: '6' }, + { label: t('products:type.Overtravel'), value: 'B', key: 'B' }, { label: t('products:type.Car'), value: 'Car', key: 'Car' }, { label: t('products:type.Guide'), value: 'Guide', key: 'Guide' }, { label: t('products:type.Package'), value: 'D', key: 'D' }, diff --git a/src/main.jsx b/src/main.jsx index 3733462..a4556b5 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -69,8 +69,8 @@ const router = createBrowserRouter([ { path: "invoice/paid/detail/:flid",element:}, { path: "airticket",element:}, { path: "products",element:}, - { path: "products/:travel_agency_id/audit",element:}, - { path: "products/:travel_agency_id",element:}, + { path: "products/:travel_agency_id/:use_year/:audit_state/audit",element:}, + { path: "products/:travel_agency_id/:use_year/:audit_state/edit",element:}, ] }, { diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 51d3010..a18f098 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -10,7 +10,8 @@ export const searchAgencyAction = async (param) => { return errcode !== 0 ? [] : result; }; export const getAgencyProductsAction = async (param) => { - const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel_agency_products`, param); + const _param = { ...param, use_year: (param.use_year || '').replace('all', ''), audit_state: (param.audit_state || '').replace('all', '') }; + const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel_agency_products`, _param); return errcode !== 0 ? { agency: {}, products: [] } : result; }; @@ -47,238 +48,10 @@ export const postProductsAudit = async (auditState, infoRow) => { const initialState = { loading: false, + searchValues: {}, agencyList: [], activeAgency: {}, - agencyProducts: groupBy([ - { - "info": { - "id": "640000198509289851", - "title": "如拉下完公", - "code": "grlkt", - "type": "Guide", - "audit_state": "1", - "create_date": "2022-01-13", - "created_by": "郝涛", - "travel_agency_id": "710000200712195349", - "travel_agency_name": "国得气验", - "lastedit_memo": "划百引程级门会需代领主属快。", - "remarks": "及决对金利低集小理电和按常如门。", - "duration": 2, - "duration_unit": "m", - "open_weekdays": "6", - "recommends_rate": 3, - "dept": 1, - "display_to_c": "2", - "km": 27, - "city_id": 77, - "city_name": "称命" - }, - "quotation": [ - { - "id": "21000020030611324X", - "value": 70, - "currency": "CNY", - "unit": "团", - "age_type": "儿童", - "group_size_min": 4, - "group_size_max": 4, - "use_dates_start": "2004-01-19", - "use_dates_end": "1990-03-10", - "weekdays": "4", - "audit_state": "ea pariatur", - "lastedit_memo": "sunt" - }, - { - "id": "610000197306240177", - "value": 86, - "currency": "CNY", - "unit": "人", - "age_type": "儿童", - "group_size_min": 6, - "group_size_max": 8, - "use_dates_start": "1996-12-16", - "use_dates_end": "1974-11-19", - "weekdays": "4", - "audit_state": "aliqua aute quis ipsum", - "lastedit_memo": "commodo adipisicing ea ipsum" - } - ], - "lgc_details": [ - { - "lgc": "mollit", - "title": "林运但", - "description": "学克信图走法因心委周说步将且文手越。", - "id": "35" - }, - { - "lgc": "et laborum", - "title": "备上引深量知量", - "description": "到听少文话包由北层中争二调原务越明在。", - "id": "74" - }, - { - "lgc": "minim velit", - "title": "安都始新", - "description": "取影压前手府要青白支大而。", - "id": "23" - } - ] - }, - { - "info": { - "id": "41000019901227754X", - "title": "据划京少国取", - "code": "ore", - "type": "Guide", - "audit_state": "2", - "create_date": "1979-01-31", - "created_by": "陆芳", - "travel_agency_id": "110000198612200137", - "travel_agency_name": "少平酸型", - "lastedit_memo": "八想军也装运知长示各院步济水。", - "remarks": "千改原统实专回列参目党却是样与后收。", - "duration": 3, - "duration_unit": "d", - "open_weekdays": "5", - "recommends_rate": 5, - "dept": 1, - "display_to_c": "2", - "km": 30, - "city_id": 62, - "city_name": "业入" - }, - "quotation": [ - { - "id": "37000019760525515X", - "value": 93, - "currency": "CNY", - "unit": "团", - "age_type": "成人", - "group_size_min": 7, - "group_size_max": 11, - "use_dates_start": "1992-11-22", - "use_dates_end": "1997-07-16", - "weekdays": "7", - "audit_state": "id nulla irure cupidatat", - "lastedit_memo": "quis aute reprehenderit consectetur" - }, - { - "id": "150000199506023175", - "value": 90, - "currency": "CNY", - "unit": "人", - "age_type": "儿童", - "group_size_min": 9, - "group_size_max": 10, - "use_dates_start": "2007-09-11", - "use_dates_end": "2013-07-27", - "weekdays": "5", - "audit_state": "commodo ad ut", - "lastedit_memo": "id anim incididunt" - } - ], - "lgc_details": [ - { - "lgc": "adipisicing elit Excepteur in", - "title": "很很结龙认", - "description": "事起复京长立然将采共层列工。", - "id": "43" - }, - { - "lgc": "dolore fugiat", - "title": "专中小", - "description": "示史想当集认点离反而原化精满并计前。", - "id": "28" - }, - { - "lgc": "sunt consectetur ea cillum", - "title": "他率带没", - "description": "节经厂面际是统表王活基书色活至是干验。", - "id": "83" - }, - { - "lgc": "incididunt labore fugiat", - "title": "精话西改", - "description": "须事金性别民学少拉个且须专需断连。", - "id": "97" - }, - { - "lgc": "dolore id", - "title": "文技话", - "description": "上任成条到则查支外很素给务府三。", - "id": "99" - } - ] - }, - { - "info": { - "id": "44000019990112280X", - "title": "节到和", - "code": "ixlmndtmz", - "type": "Meals", - "audit_state": "1", - "create_date": "2006-12-30", - "created_by": "易敏", - "travel_agency_id": "640000197111288408", - "travel_agency_name": "术备带走", - "lastedit_memo": "认队什教调问传改万消然声地全。", - "remarks": "属须厂几问总识看部群该克员方。", - "duration": 2, - "duration_unit": "m", - "open_weekdays": "6", - "recommends_rate": 3, - "dept": 2, - "display_to_c": "1", - "km": 13, - "city_id": 55, - "city_name": "铁以" - }, - "quotation": [ - { - "id": "13000019860219219X", - "value": 88, - "currency": "CNY", - "unit": "团", - "age_type": "儿童", - "group_size_min": 2, - "group_size_max": 4, - "use_dates_start": "1991-03-19", - "use_dates_end": "1974-03-13", - "weekdays": "3", - "audit_state": "officia voluptate ad adipisicing dolore", - "lastedit_memo": "Duis amet veniam enim" - }, - { - "id": "420000201706118123", - "value": 61, - "currency": "CNY", - "unit": "人", - "age_type": "儿童", - "group_size_min": 4, - "group_size_max": 10, - "use_dates_start": "1992-04-23", - "use_dates_end": "1970-07-19", - "weekdays": "5", - "audit_state": "commodo labore", - "lastedit_memo": "ullamco anim culpa do in" - } - ], - "lgc_details": [ - { - "lgc": "ut minim", - "title": "回等这意", - "description": "农满界个整千书得被写况空派会想头无。", - "id": "40" - }, - { - "lgc": "laborum id elit irure commodo", - "title": "增正数白养土子", - "description": "么划才共别程以元于族完难变。", - "id": "84" - } - ] - } -], row => row.info.type), + agencyProducts: {}, }; export const useProductsStore = create( devtools((set, get) => ({ @@ -287,6 +60,7 @@ export const useProductsStore = create( // state actions setLoading: loading => set({ loading }), + setSearchValues: searchValues => set({ searchValues }), setAgencyList: (agencyList) => set({ agencyList }), setActiveAgency: activeAgency => set({ activeAgency }), setAgencyProducts: agencyProducts => set({ agencyProducts }), diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index c548de2..e055cc3 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -7,15 +7,18 @@ import { useTranslation } from 'react-i18next'; import useProductsStore, { postProductsQuoteAudit } from '@/stores/Products/Index'; import { isEmpty } from '@/utils/commons'; -const Header = ({ title, agency, ...props}) => { +const Header = ({ title, agency, refresh, ...props}) => { const { t } = useTranslation(); - const [activeAgency, ] = useProductsStore((state) => [state.activeAgency]); + const [activeAgency, ] = useProductsStore((state) => [state.activeAgency, ]); const { message, notification } = App.useApp(); const handleAuditItem = (state, row) => { postProductsQuoteAudit(state, {id: row.id, travel_agency_id: activeAgency.travel_agency_id}) .then((json) => { if (json.errcode === 0) { - message.success('✔'); + message.success(json.errmsg); + if (typeof refresh === 'function') { + refresh(); + } } }) .catch((ex) => { @@ -34,8 +37,14 @@ const Header = ({ title, agency, ...props}) => { {/* */} {/* */} - + {/* */} + {/* todo: export */} @@ -43,9 +52,9 @@ const Header = ({ title, agency, ...props}) => { ); }; -const PriceTable = ({dataSource, loading}) => { +const PriceTable = ({dataSource,refresh}) => { const { t } = useTranslation('products'); - const [activeAgency, ] = useProductsStore((state) => [state.activeAgency]); + const [loading, activeAgency, ] = useProductsStore((state) => [state.loading, state.activeAgency, ]); const { message, notification } = App.useApp(); const stateMapVal = useProductsAuditStatesMapVal(); @@ -53,7 +62,10 @@ const PriceTable = ({dataSource, loading}) => { postProductsQuoteAudit(state, {id: row.id, travel_agency_id: activeAgency.travel_agency_id}) .then((json) => { if (json.errcode === 0) { - message.success('✔'); + message.success(json.errmsg); + if (typeof refresh === 'function') { + refresh(); + } } }) .catch((ex) => { @@ -68,11 +80,11 @@ const PriceTable = ({dataSource, loading}) => { const columns = [ { key: 'title', dataIndex: ['info', 'title'], title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) }, - { key: 'value', title: t('Quotation'), render: (_, { value, currency, unit_name }) => `${value} ${currency} / ${unit_name}` }, + { 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: 'price', title: t('Currency'), }, // {key: 'currency', title: t('Currency'), }, // {key: 'unit', title: t('Unit'), }, - { key: 'ageType', dataIndex: ['age_type'], title: t('AgeType.Type') }, { key: 'groupSize', dataIndex: ['group_size_min'], @@ -94,24 +106,24 @@ const PriceTable = ({dataSource, loading}) => { }, }, { - title: '', + title: '价格审核', key: 'action', render: (_, r) => r.audit_state_id <= 0 ?( - + ) : null, }, ]; - return
r.id} />; + return
r.id} />; } /** * */ -const TypesPanels = () => { - const [loading, agencyProducts] = useProductsStore((state) => [state.loading, state.agencyProducts]); +const TypesPanels = (props) => { + const [loading, agencyProducts, ] = useProductsStore((state) => [state.loading, state.agencyProducts]); // console.log(agencyProducts); const productsTypes = useProductsTypes(); const [activeKey, setActiveKey] = useState([]); @@ -125,8 +137,9 @@ const TypesPanels = () => { ...ele, children: ( r.concat(c.quotation.map((q, i) => ({ ...q, info: c.info, rowSpan: i === 0 ? c.quotation.length : 0 }))), [])} + refresh={props.refresh} /> ), })); @@ -146,11 +159,11 @@ const TypesPanels = () => { } const Audit = ({ ...props }) => { - const { travel_agency_id } = useParams(); + const { travel_agency_id, use_year, audit_state } = useParams(); const [activeAgency, getAgencyProducts] = useProductsStore((state) => [state.activeAgency, state.getAgencyProducts]); const handleGetAgencyProducts = () => { - getAgencyProducts({ travel_agency_id }); + getAgencyProducts({ travel_agency_id, use_year, audit_state }); } useEffect(() => { @@ -161,9 +174,9 @@ const Audit = ({ ...props }) => { return ( <> - }> + }>
- +
); diff --git a/src/views/products/Index.jsx b/src/views/products/Index.jsx index 02d57ec..5a6385c 100644 --- a/src/views/products/Index.jsx +++ b/src/views/products/Index.jsx @@ -11,16 +11,18 @@ import { objectMapper } from '@/utils/commons'; function Index() { const { t } = useTranslation(); const [loading, agencyList, searchAgency] = useProductsStore((state) => [state.loading, state.agencyList, state.searchAgency]); + const [searchValues, setSearchValues] = useProductsStore((state) => [state.searchValues, state.setSearchValues]); const formValuesToSub = useFormStore(state => state.formValuesToSub); const handleSearchAgency = (formVal = undefined) => { const { starttime, endtime, ...param } = formVal || formValuesToSub; const searchParam = objectMapper(param, { agency: 'travel_agency_id', startdate: 'edit_date1', enddate: 'edit_date2' }); + setSearchValues(searchParam); searchAgency(searchParam); } useEffect(() => { - handleSearchAgency(); + // handleSearchAgency(); }, []); const showTotal = (total) => t('Table.Total', { total }); @@ -37,8 +39,8 @@ function Index() { key: 'action', render: (_, r) => ( - {t('Edit')} - {t('Audit')} + {t('Edit')} + {t('Audit')} ), }, @@ -47,19 +49,21 @@ function Index() { { handleSearchAgency(formVal); @@ -67,7 +71,14 @@ function Index() { />
-
+
From cacc4832c5ce355b0bf179cfd6675b5a6c867544 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 21 Jun 2024 15:58:33 +0800 Subject: [PATCH 9/9] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86:=20=E6=90=9C=E7=B4=A2:=20=E5=A4=9A=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/products/Index.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/views/products/Index.jsx b/src/views/products/Index.jsx index 5a6385c..d1b1495 100644 --- a/src/views/products/Index.jsx +++ b/src/views/products/Index.jsx @@ -16,7 +16,7 @@ function Index() { const handleSearchAgency = (formVal = undefined) => { const { starttime, endtime, ...param } = formVal || formValuesToSub; - const searchParam = objectMapper(param, { agency: 'travel_agency_id', startdate: 'edit_date1', enddate: 'edit_date2' }); + const searchParam = objectMapper(param, { agency: 'travel_agency_ids', startdate: 'edit_date1', enddate: 'edit_date2' }); setSearchValues(searchParam); searchAgency(searchParam); } @@ -49,14 +49,14 @@ function Index() {