diff --git a/README.md b/README.md index 988d566..6266731 100644 --- a/README.md +++ b/README.md @@ -8,42 +8,43 @@ Global Highlights Hub 海外供应商平台 3. 打包代码:npm run build 或者 build.bat ## 版本设置 -npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git] +npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git] -npm version premajor --no-git-tag-version -1.0.0 -> 2.0.0-0 ---preid beta | alpha | rc -npm version prerelease --preid beta --no-git-tag-version -npm version prerelease -2.0.0-alpha-0 -> 2.0.0-alpha-1 -> 2.0.0-alpha-2 ..n -> 2.0.0-alpha-n -npm version patch --no-git-tag-version -2.0.0-n -> 2.0.0 +npm version premajor --no-git-tag-version +1.0.0 -> 2.0.0-0 +--preid beta | alpha | rc +npm version prerelease --preid beta --no-git-tag-version +npm version prerelease +2.0.0-alpha-0 -> 2.0.0-alpha-1 -> 2.0.0-alpha-2 ..n -> 2.0.0-alpha-n +npm version patch --no-git-tag-version +2.0.0-n -> 2.0.0 -"push:tag": "npm version patch && git.exe push --progress "origin" main:main" -"push:tag": "npm version patch && git push origin master" +"push:tag": "npm version patch && git.exe push --progress "origin" main:main" +"push:tag": "npm version patch && git push origin master" ## 相关文档 -需求文档 https://www.kdocs.cn/l/csZrIZlpuF2i -dayjs https://dayjs.gitee.io/docs/zh-CN/manipulate/start-of -antd https://ant-design.antgroup.com/components/upload-cn#uploadfile -反馈表案例 https://www.chinahighlights.com/customerservice/feedback/PostTourSurveyFormToWLGH.asp?LGC=1&COLI_SN=988185&MEI_SN=954295&Email=jennroth18@hotmail.com&ToC=0&ShowType=&page_class=4&dei_sn=28&country=30,490 -国内供应商平台 http://p.mycht.cn/index.aspx -文档预览 https://github.com/cyntler/react-doc-viewer -wps的文档预览 https://wwo.wps.cn/docs/front-end/introduction/quick-start -pdf生成 https://github.com/ivmarcos/react-to-pdf -react-pdf https://react-pdf.org +需求文档 https://www.kdocs.cn/l/csZrIZlpuF2i +dayjs https://dayjs.gitee.io/docs/zh-CN/manipulate/start-of +antd https://ant-design.antgroup.com/components/upload-cn#uploadfile +反馈表案例 https://www.chinahighlights.com/customerservice/feedback/PostTourSurveyFormToWLGH.asp?LGC=1&COLI_SN=988185&MEI_SN=954295&Email=jennroth18@hotmail.com&ToC=0&ShowType=&page_class=4&dei_sn=28&country=30,490 +国内供应商平台 http://p.mycht.cn/index.aspx +文档预览 https://github.com/cyntler/react-doc-viewer +wps的文档预览 https://wwo.wps.cn/docs/front-end/introduction/quick-start +pdf生成 https://github.com/ivmarcos/react-to-pdf +react-pdf https://react-pdf.org ## 阿里云OSS -Bucket 名称:global-highlights-hub -Endpoint:oss-cn-hongkong.aliyuncs.com -global-highlights-hub.oss-cn-hongkong.aliyuncs.com - -反馈表测试链接 -http://202.103.68.111:5173/feedback/330948 +Bucket 名称:global-highlights-hub +Endpoint:oss-cn-hongkong.aliyuncs.com +global-highlights-hub.oss-cn-hongkong.aliyuncs.com + +反馈表测试链接 +http://202.103.68.111:5173/feedback/330948 --- + ```mermaid --- title: GHHub 开发管理 - 机票和价格管理 @@ -51,6 +52,7 @@ title: GHHub 开发管理 - 机票和价格管理 gitGraph TB: commit commit + branch release branch feature/i18n checkout main commit id: "release" tag: "1.0.5.31" @@ -65,16 +67,19 @@ gitGraph TB: checkout main commit commit + commit id: "账户体系" checkout feature/price_manager commit - commit id: "完成价格" - checkout main - commit tag: "1.1.0" id: "完成机票" - branch pre-release - merge feature/price_manager id: "合并机票+价格" type:HIGHLIGHT + commit + commit checkout main - merge pre-release id: "合并发布" tag: "1.2.0" + merge feature/price_manager id: "合并价格" type:HIGHLIGHT + commit + commit + commit tag: "2.0.0" id: "完成机票" + commit + commit + commit id: "pre-release" tag: "pre-release" type:HIGHLIGHT commit ``` - diff --git a/package.json b/package.json index dd93ac5..1eaed3b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "global-highlights-hub", "private": true, - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/SearchForm.jsx b/src/components/SearchForm.jsx index 89b79b9..54174ff 100644 --- a/src/components/SearchForm.jsx +++ b/src/components/SearchForm.jsx @@ -15,7 +15,7 @@ import VendorSelector from '@/components/VendorSelector'; const { RangePicker } = DatePicker; -const SearchForm = ({ initialValue, onSubmit, onReset, confirmText, formName, formLayout, loading, ...props }) => { +const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, formName, formLayout, loading, ...props }) => { const { t } = useTranslation(); const presets = useDatePresets(); const [formValues, setFormValues] = useFormStore((state) => [state.formValues, state.setFormValues]); @@ -89,8 +89,14 @@ const SearchForm = ({ initialValue, onSubmit, onReset, confirmText, formName, fo }; useEffect(() => { - const dest = formValuesMapper(formValues); + setFormValues(readValues); + const dest = formValuesMapper(readValues); setFormValuesToSub(dest); + + if (typeof onMounted === 'function') { + onMounted(dest) + } + return () => {}; }, []); diff --git a/src/stores/Auth.js b/src/stores/Auth.js index 3f3808b..0c48ce6 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -64,6 +64,8 @@ const useAuthStore = create((set, get) => ({ const { startTokenInterval, loadUserPermission } = get() const { setStorage, loginToken } = usingStorage() + // Dev 模式使用 localStorage,会有 token 失效情况,需要手动删除 + // Prod 环境没有该问题 const userJson = await fetchUserDetail(loginToken) appendRequestParams('token', loginToken) @@ -142,9 +144,9 @@ const useAuthStore = create((set, get) => ({ async function checkTokenTimeout() { // TODO:Token 失效后要跳转到登录页面 const { LastReqDate } = await fetchLastRequet() - const lastReqDate = new Date(LastReqDate) + const lastReqDateTime = new Date(LastReqDate).getTime() const now = new Date() - const diffTime = now.getTime() - lastReqDate.getTime() + const diffTime = now.getTime() - lastReqDateTime const diffHours = diffTime/1000/60/60 if (diffHours > 1) { logout() diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 3d727be..1a79d56 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -30,7 +30,7 @@ export const copyAgencyDataAction = async (postbody) => { }; export const getAgencyProductsAction = async (param) => { - const _param = { ...param, use_year: String(param.use_year || '').replace('all', ''), audit_state: (param.audit_state || '').replace('all', '') }; + const _param = { ...param, use_year: String(param.use_year || '').replace('all', ''), audit_state: String(param.audit_state || '').replace('all', '') }; const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel_agency_products`, _param); return errcode !== 0 ? { agency: {}, products: [] } : result; }; @@ -95,13 +95,18 @@ export const postProductsAuditAction = async (auditState, infoRow) => { // return errcode !== 0 ? {} : result; }; +export const postProductsSave = async (products) => { + const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_save`, products); + return { errcode, result }; +} + const initialState = { loading: false, - searchValues: {}, - agencyList: [], - activeAgency: {}, - agencyProducts: {}, - editingProduct: {}, + searchValues: {}, // 客服首页: 搜索条件 + agencyList: [], // 客服首页: 搜索结果 + activeAgency: {}, // 审核/编辑 页: 当前的供应商 + agencyProducts: {}, // 审核/编辑 页: 供应商产品列表 + editingProduct: {}, // 编辑页: 当前编辑的产品 }; export const useProductsStore = create( devtools((set, get) => ({ @@ -130,7 +135,9 @@ export const useProductsStore = create( getAgencyProducts: async (param) => { const { setLoading, setActiveAgency, setAgencyProducts } = get(); setLoading(true); + setAgencyProducts({}); const res = await getAgencyProductsAction(param); + const productsData = groupBy(res.products, (row) => row.info.product_type_id); setAgencyProducts(productsData); setActiveAgency(res.agency); diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index dc35d85..8026a9c 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; -import { useParams, Link, Navigate, useNavigate } from 'react-router-dom'; -import { App, Empty, Button, Collapse, Table, Space, Divider, Select } from 'antd'; +import { useParams, Link } from 'react-router-dom'; +import { App, Empty, Button, Collapse, Table, Space } from 'antd'; import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProductsSets'; import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; import { useTranslation } from 'react-i18next'; @@ -8,112 +8,8 @@ import useProductsStore, { postProductsQuoteAuditAction, } from '@/stores/Produc import { cloneDeep, isEmpty } from '@/utils/commons'; import useAuthStore from '@/stores/Auth'; import RequireAuth from '@/components/RequireAuth'; -// import PrintContractPDF from './PrintContractPDF'; import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; -import dayjs from 'dayjs'; -import VendorSelector from '@/components/VendorSelector'; -const Header = ({ refresh, ...props }) => { - const { travel_agency_id, use_year, audit_state } = useParams(); - const { t } = useTranslation(); - const isPermitted = useAuthStore(state => state.isPermitted); - const [activeAgency, setActiveAgency] = useProductsStore((state) => [state.activeAgency, state.setActiveAgency]); - const { message, notification } = App.useApp(); - const navigate = useNavigate(); - - const yearOptions = []; - const currentYear = dayjs().year(); - const baseYear = Number(use_year === 'all' ? currentYear : use_year); - for (let i = baseYear - 3; i <= baseYear + 3; i++) { - yearOptions.push({ label: i, value: i, }); - } - - const [param, setParam] = useState({ pick_year: baseYear, pick_agency: travel_agency_id, }); - const [pickYear, setPickYear] = useState(baseYear); - useEffect(() => { - refresh(param); - navigate(`/products/${activeAgency.travel_agency_id}/${pickYear}/${audit_state}/audit`); - - return () => {}; - }, [param]); - - const handleYearChange = (value) => { - setPickYear(value); - setParam((pre) => ({ ...pre, ...{ pick_year: value } })); - }; - - const handleAgencyChange = ({ label, value }) => { - setActiveAgency({ travel_agency_id: value, travel_agency_name: label }); - setParam((pre) => ({ ...pre, ...{ pick_agency: value } })); - }; - - const handleAuditItem = (state, row) => { - postProductsQuoteAuditAction(state, { id: row.id, travel_agency_id: activeAgency.travel_agency_id }) - .then((json) => { - if (json.errcode === 0) { - message.success(json.errmsg); - if (typeof refresh === 'function') { - refresh(param); - } - } - }) - .catch((ex) => { - notification.error({ - message: 'Notification', - description: ex.message, - placement: 'top', - duration: 4, - }); - }); - }; - return ( -
-
-

- {isPermitted(PERM_PRODUCTS_OFFER_AUDIT) ? ( - - ) : ( - activeAgency.travel_agency_name - )} - - ; + return ; case "display_to_c": return ( - 在计划显示,不在报价信显示 计划和报价信都要显示 计划和报价信都不用显示 ); case "dept_name": - return ; + return ; case "city_name": - return ; + return ; default: - return ; + return ; } }; + //保存产品 const onSave = async (values) => { let tempInfo - console.log("values", values) - console.log("info", info) if (info.id === "") { tempInfo = { ...info, ...values.info, city_name: values.info.city_name.label, - audit_state:"-1" + audit_state: "-1" } delete tempInfo.product_type_name; delete tempInfo.dept_name; - - console.log("新增") let tempQuotation = quotation.map(element => { const updateData = { @@ -790,18 +961,17 @@ function Detail() { delete updateData.tempKey return updateData }) - let tempLgc_details = [{...lgc_details}] - console.log("tempLgc_details",tempLgc_details) + let tempLgc_details = [{ ...lgc_details }] const tempData = { travel_agency_id, info: tempInfo, quotation: tempQuotation, lgc_details: Object.values(lgc_details) }; - console.log("tempData",tempData); + console.log("tempData", tempData); const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_save`, tempData); - console.log("result",result) + console.log("result", result); if (errcode === 0) { message.success("保存成功"); setDataFetched(false); @@ -809,12 +979,12 @@ function Detail() { message.error(`保存失败: ${result}`); } return - } else { - tempInfo = { - ...info, - ...values.info, - audit_state: "-1" - } + } + + tempInfo = { + ...info, + ...values.info, + audit_state: "-1" } console.log("tempInfo", tempInfo) @@ -836,8 +1006,8 @@ function Detail() { }; 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("保存成功"); setDataFetched(false); @@ -849,14 +1019,47 @@ function Detail() { }; + //提交审核方法 + const submitReview = async () => { + const formData = new FormData(); + formData.append('use_year', use_year); + formData.append('travel_agency_id', travel_agency_id); + try { + const { errcode, result } = await postForm(`${HT_HOST}/Service_BaseInfoWeb/agency_submit`, formData); + console.log("errcode", errcode); + if (errcode === 0) { + message.success("提交审核成功"); + navigate(`/products/${travel_agency_id}/${use_year}/${audit_state}/audit`); + } else { + message.error("提交审核失败"); + } + console.log("result", result); + } catch (error) { + console.error("提交审核请求失败", error); + message.error("提交审核请求失败"); + } + }; + + const handleStateChange = (newState) => { + console.log("newState",newState) + if(newState === 'addProducts'){ + setAddProductVisible(true); + } + if(newState === 'submitReview'){ + submitReview(); + } + }; + return ( - -
+ + // + }> + {isEmpty(agencyProducts) ? :
- + - {/* {tags.map(tag => ( +
- {/* }> */} setAddProductType(value)} - > - {productsTypes.map((item) => ( - - {item.label} - - ))} - - -

新增产品名称

- setAddProductName(e.target.value)} - /> -
- ) - } + + } onClick={() => setAddProductVisible(true)} /> + + + } onClick={async () => { + const formData = new FormData(); + formData.append('use_year', use_year); + formData.append('travel_agency_id', travel_agency_id); + const { errcode, result } = await postForm(`${HT_HOST}/Service_BaseInfoWeb/agency_submit`, formData); + console.log("errcode", errcode); + if (errcode === 0) { + message.success("提交审核成功"); + navigate(`/products/${travel_agency_id}/${use_year}/${audit_state}/audit`); + } + console.log("result", result); + }} /> + + + + - { - ( - -

成人价

- setCurrentQuotationRecord({ ...currentQuotationRecord, adult_cost: e })} /> -

儿童价

- setCurrentQuotationRecord({ ...currentQuotationRecord, child_cost: e })} /> -

币种

- -

类型

- - -

人等

- - setCurrentQuotationRecord({ ...currentQuotationRecord, group_size_min: e })} - style={{ width: '50%', marginRight: '10px' }} - /> - - - setCurrentQuotationRecord({ ...currentQuotationRecord, group_size_max: e })} - style={{ width: '50%', marginLeft: '10px' }} - /> - -

有效期

- { - setCurrentQuotationRecord({ - ...currentQuotationRecord, - use_dates_start: dates[0], - use_dates_end: dates[1] - }); - }} - /> -

周末

- {days.map((day, index) => ( - - ))} + setBatchImportPriceVisible(false)} + width="80%" + > + + + + setAddProductVisible(false)} + > +

选择产品类别

+ + -
+

新增产品名称

+ setAddProductName(e.target.value)} + /> +
+ + +

成人价

+ setCurrentQuotationRecord({ ...currentQuotationRecord, adult_cost: e })} /> +

儿童价

+ setCurrentQuotationRecord({ ...currentQuotationRecord, child_cost: e })} /> +

币种

+ +

类型

+ - ) - } -
-
+

人等

+ + setCurrentQuotationRecord({ ...currentQuotationRecord, group_size_min: e })} + style={{ width: '50%', marginRight: '10px' }} + /> + - + setCurrentQuotationRecord({ ...currentQuotationRecord, group_size_max: e })} + style={{ width: '50%', marginLeft: '10px' }} + /> + +

有效期

+ { + setCurrentQuotationRecord({ + ...currentQuotationRecord, + use_dates_start: dates[0], + use_dates_end: dates[1] + }); + }} + /> +

周末

+ {days.map((day, index) => ( + + ))} + +

} + + // ); } export default Detail; diff --git a/src/views/products/Detail/CopyProducts.jsx b/src/views/products/Detail/CopyProducts.jsx index af2ed57..641937d 100644 --- a/src/views/products/Detail/CopyProducts.jsx +++ b/src/views/products/Detail/CopyProducts.jsx @@ -3,10 +3,9 @@ import { App, Form, Modal, DatePicker, Divider, Switch } from 'antd'; import { isEmpty, objectMapper } from '@/utils/commons'; import { useTranslation } from 'react-i18next'; -import SearchInput from '@/components/SearchInput'; import DeptSelector from '@/components/DeptSelector'; import ProductsTypesSelector from '@/components/ProductsTypesSelector'; -import { fetchVendorList } from '@/components/VendorSelector'; +import VendorSelector from '@/components/VendorSelector'; import dayjs from 'dayjs'; import arraySupport from 'dayjs/plugin/arraySupport'; import { copyAgencyDataAction } from '@/stores/Products/Index'; @@ -31,13 +30,7 @@ export const CopyProductsForm = ({ action, initialValues, onFormInstanceReady, s return (
{action === '#' && - + } diff --git a/src/views/products/Detail/Header.jsx b/src/views/products/Detail/Header.jsx new file mode 100644 index 0000000..1e30c52 --- /dev/null +++ b/src/views/products/Detail/Header.jsx @@ -0,0 +1,137 @@ +import { useEffect, useState } from 'react'; +import { useParams, Link, useNavigate } from 'react-router-dom'; +import { App, Button, Divider, Select } from 'antd'; +import { useProductsAuditStatesMapVal } from '@/hooks/useProductsSets'; +import { useTranslation } from 'react-i18next'; +import useProductsStore, { postProductsQuoteAuditAction, } from '@/stores/Products/Index'; +import { isEmpty } from '@/utils/commons'; +import useAuthStore from '@/stores/Auth'; +import RequireAuth from '@/components/RequireAuth'; +// import PrintContractPDF from './PrintContractPDF'; +import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; +import dayjs from 'dayjs'; +import VendorSelector from '@/components/VendorSelector'; +import AuditStateSelector from '@/components/AuditStateSelector'; +const Header = ({ refresh, ...props }) => { + const { travel_agency_id, use_year, audit_state } = useParams(); + const { t } = useTranslation(); + const isPermitted = useAuthStore(state => state.isPermitted); + const [activeAgency, setActiveAgency] = useProductsStore((state) => [state.activeAgency, state.setActiveAgency]); + const stateMapVal = useProductsAuditStatesMapVal(); + const { message, notification } = App.useApp(); + const navigate = useNavigate(); + + const yearOptions = []; + const currentYear = dayjs().year(); + const baseYear = Number(use_year === 'all' ? currentYear : use_year); + for (let i = baseYear - 3; i <= baseYear + 3; i++) { + yearOptions.push({ label: i, value: i, }); + } + + const [param, setParam] = useState({ pick_year: baseYear, pick_agency: travel_agency_id, }); + const [pickYear, setPickYear] = useState(baseYear); + const [pickAgency, setPickAgency] = useState({value: activeAgency.travel_agency_id, label: activeAgency.travel_agency_name }); + const [pickAuditState, setPickAuditState] = useState(); + useEffect(() => { + refresh(param); + + return () => {}; + }, [param]); + + const emptyPickState = { value: '', label: t('products:State') }; + useEffect(() => { + const baseState = audit_state === 'all' ? emptyPickState : stateMapVal[`${audit_state}`]; + if (isEmpty(pickAuditState)) { + setPickAuditState(baseState); + } + return () => {}; + }, [audit_state, stateMapVal]) + + + const handleYearChange = (value) => { + setPickYear(value); + setParam((pre) => ({ ...pre, ...{ pick_year: value } })); + }; + const handleAuditStateChange = (labelValue) => { + const { value } = labelValue || emptyPickState; + setPickAuditState(labelValue || emptyPickState); + setParam((pre) => ({ ...pre, ...{ pick_state: value } })); + }; + + const handleAgencyChange = ({ label, value }) => { + setPickAgency({ label, value }); + setActiveAgency({ travel_agency_id: value, travel_agency_name: label }); + setParam((pre) => ({ ...pre, ...{ pick_agency: value } })); + }; + + const handleAuditItem = (state, row) => { + postProductsQuoteAuditAction(state, { id: row.id, travel_agency_id: activeAgency.travel_agency_id }) + .then((json) => { + if (json.errcode === 0) { + message.success(json.errmsg); + if (typeof refresh === 'function') { + refresh(param); + } + } + }) + .catch((ex) => { + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + duration: 4, + }); + }); + }; + return ( +
+
+

+ {isPermitted(PERM_PRODUCTS_OFFER_AUDIT) ? ( + + ) : ( + activeAgency.travel_agency_name + )} + + + + +

+
+ + + +
+ ); +}; +export default YearSelector; diff --git a/src/views/products/Manage.jsx b/src/views/products/Manage.jsx index 4b2f2b6..a46dab8 100644 --- a/src/views/products/Manage.jsx +++ b/src/views/products/Manage.jsx @@ -82,11 +82,12 @@ function Index() { render: (_, r) => ( {t('Edit')} - {r.audit_state_id >= 0 ? ( + {t('Audit')} + {/* {r.audit_state_id >= 0 ? ( {t('Audit')} ) : ( {t('Audit')} - )} + )} */} diff --git a/src/views/reservation/Detail.jsx b/src/views/reservation/Detail.jsx index e2cd7c2..e482676 100644 --- a/src/views/reservation/Detail.jsx +++ b/src/views/reservation/Detail.jsx @@ -42,7 +42,7 @@ function Detail() { }, ]; - function detailTextRender(text, confirm) { + function detailTextRender(_, confirm) { const formattedText = confirm.PCI_ConfirmText;//.replace(/\;/g, '\n——————————————————————\n'); return (
@@ -51,19 +51,21 @@ function Detail() { ); } - function attachmentRender(text, confirm) { + function attachmentRender(_, confirm) { return ( <> {confirm.attachmentList.map(attch => { return ( - }>{attch.file_name} + }> + {attch.file_name} + )} )} ); } - function confirmRender(text, confirm) { + function confirmRender(_, confirm) { return ( ); @@ -128,7 +130,7 @@ function Detail() { .finally(() => { setDataLoading(false); }); - }, [reservationId]); + }, [reservationId, getReservationDetail, notification]); return ( <> diff --git a/src/views/reservation/Newest.jsx b/src/views/reservation/Newest.jsx index 9a02816..349d40e 100644 --- a/src/views/reservation/Newest.jsx +++ b/src/views/reservation/Newest.jsx @@ -1,4 +1,4 @@ -import { NavLink, useLocation } from 'react-router-dom' +import { NavLink } from 'react-router-dom' import { useState, useEffect } from 'react' import { Row, Col, Space, Button, Table, Typography, Modal, App, Select } from 'antd' import dayjs from 'dayjs' @@ -90,13 +90,11 @@ function Newest() { ) } - const location = useLocation() const [isModalOpen, setIsModalOpen] = useState(false) const [dataLoading, setDataLoading] = useState(false) const [guideSelectOptions, setGuideSelectOptions] = useState([]) const formValuesToSub = useFormStore((state) => state.formValuesToSub) - const [fetchAllGuideList, fetchReservationList, reservationList, reservationPage, cityList, selectReservation, getCityListByReservationId, setupCityGuide, updateReservationGuide] = useReservationStore((state) => [state.fetchAllGuideList, state.fetchReservationList, state.reservationList, state.reservationPage, state.cityList, state.selectReservation, state.getCityListByReservationId, state.setupCityGuide, state.updateReservationGuide]) @@ -104,13 +102,9 @@ function Newest() { const { notification } = App.useApp() useEffect (() => { - if (location.search !== '?back') { - // 第一页,未确认计划 - onSearchClick(1, 1) - } fetchAllGuideList() .then((guideList) => { - const selectOptions = guideList.map((data, index) => { + const selectOptions = guideList.map((data) => { return { value: data.guideId, label: data.guideName @@ -118,7 +112,7 @@ function Newest() { }) setGuideSelectOptions(selectOptions) }) - }, []) + }, [fetchAllGuideList]) const showCityGuideModal = (reservation) => { setDataLoading(true) @@ -137,6 +131,7 @@ function Newest() { setDataLoading(false); }) } + const handleOk = () => { updateReservationGuide() .finally(() => { @@ -144,15 +139,18 @@ function Newest() { setDataLoading(false); }) } + const handleCancel = () => { setIsModalOpen(false); setDataLoading(false); } // 默认重新搜索第一页,所有状态的计划 - const onSearchClick = (current=1, status=null) => { + const searchReservation = (submitValues, current=1) => { setDataLoading(true) - fetchReservationList(formValuesToSub, current) + console.info('onSearchClick') + console.info(submitValues) + fetchReservationList(submitValues, current) .catch(ex => { notification.error({ message: `Notification`, @@ -208,20 +206,11 @@ function Newest() { dates: { label: t('group:ArrivalDate') }, }, }} - onSubmit={(err, formVal, filedsVal) => { - setDataLoading(true) - fetchReservationList(formVal) - .catch(ex => { - notification.error({ - message: 'Notification', - description: ex.message, - placement: 'top', - duration: 4, - }) - }) - .finally(() => { - setDataLoading(false) - }) + onMounted={(initialValue) => { + searchReservation(initialValue) + }} + onSubmit={() => { + searchReservation(formValuesToSub) }} /> @@ -238,7 +227,9 @@ function Newest() { total: reservationPage.total, simple: true }} - onChange={(pagination) => {onSearchClick(pagination.current)}} + onChange={(pagination) => { + searchReservation(formValuesToSub, pagination.current) + }} columns={reservationListColumns} dataSource={reservationList} />