From ca0edbd63ab9cb96b683d61f3bb5de632c680e93 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 17 Jun 2024 09:46:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BB=8Ehooks/usingStorage=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=99=BB=E5=BD=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/airticket/Index.jsx | 5 ++--- src/views/feedback/CustomerDetail.jsx | 4 ++-- src/views/feedback/Detail.jsx | 4 ++-- src/views/feedback/Index.jsx | 4 ++-- src/views/invoice/Detail.jsx | 9 +++------ src/views/invoice/Index.jsx | 4 ++-- src/views/invoice/Paid.jsx | 4 ++-- src/views/invoice/PaidDetail.jsx | 4 ++-- src/views/notice/Detail.jsx | 4 ++-- src/views/notice/Index.jsx | 5 +++-- src/views/report/Index.jsx | 4 ++-- 11 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/views/airticket/Index.jsx b/src/views/airticket/Index.jsx index 479975c..06cbb02 100644 --- a/src/views/airticket/Index.jsx +++ b/src/views/airticket/Index.jsx @@ -7,7 +7,7 @@ import dayjs from "dayjs"; import SearchForm from "@/components/SearchForm"; import airTicketStore from "@/stores/Airticket"; -import useAuthStore from "@/stores/Auth"; +import { usingStorage } from "@/hooks/usingStorage"; const planListColumns = [ { @@ -66,9 +66,8 @@ const Airticket = props => { const href = useHref(); const navigate = useNavigate(); const { phonenumber } = useParams(); - const travelAgencyId = useAuthStore(state => state.loginUser.travelAgencyId); + const {travelAgencyId, } = usingStorage(); const [getPlanList, planList, loading] = airTicketStore(state => [state.getPlanList, state.planList, state.loading]); - const [loginUser] = useAuthStore(state => [state.loginUser]); const [phone_number, setPhone_number] = useState(phonenumber); const showTotal = total => `合计 ${total} `; diff --git a/src/views/feedback/CustomerDetail.jsx b/src/views/feedback/CustomerDetail.jsx index d9f77ce..3172617 100644 --- a/src/views/feedback/CustomerDetail.jsx +++ b/src/views/feedback/CustomerDetail.jsx @@ -3,16 +3,16 @@ import { useEffect, useState } from 'react'; import { Row, Col, Space, Button, Divider, Form, Typography, Rate, Radio, Upload, Input, App, Card } from 'antd'; import { PlusOutlined } from '@ant-design/icons'; import * as config from '@/config'; -import useAuthStore from '@/stores/Auth'; import { getFeedbackDetail, getCustomerFeedbackDetail, getFeedbackImages, getFeedbackInfo, removeFeedbackImages, postFeedbackInfo } from '@/stores/Feedback'; import BackBtn from '@/components/BackBtn'; +import { usingStorage } from '@/hooks/usingStorage'; const { Title, Text, Paragraph } = Typography; function Detail() { const navigate = useNavigate(); const { GRI_SN, RefNo, CII_SN } = useParams(); - const [travelAgencyId, token] = useAuthStore((state) => [state.loginUser.travelAgencyId, state.loginUser.token]); + const {travelAgencyId, token} = usingStorage(); const desc = ['none', 'Unacceptable', 'Poor', 'Fair', 'Very Good', 'Excellent']; const { notification } = App.useApp(); const [form] = Form.useForm(); diff --git a/src/views/feedback/Detail.jsx b/src/views/feedback/Detail.jsx index 9683fbe..b7e36a6 100644 --- a/src/views/feedback/Detail.jsx +++ b/src/views/feedback/Detail.jsx @@ -3,15 +3,15 @@ import { useEffect, useState } from "react"; import { Row, Col, Space, Button, Divider, Form, Typography, Rate, Radio, Upload, Input, App, Card } from "antd"; import { PlusOutlined } from "@ant-design/icons"; import * as config from "@/config"; -import useAuthStore from '@/stores/Auth'; import { getFeedbackDetail, getFeedbackImages, getFeedbackInfo, removeFeedbackImages, postFeedbackInfo } from '@/stores/Feedback'; import BackBtn from "@/components/BackBtn"; +import { usingStorage } from "@/hooks/usingStorage"; const { Title, Text, Paragraph } = Typography; function Detail() { const navigate = useNavigate(); const { GRI_SN,RefNo } = useParams(); - const [travelAgencyId, token] = useAuthStore((state) => [state.loginUser.travelAgencyId, state.loginUser.token]); + const {travelAgencyId, token} = usingStorage(); const desc = ["none", "Unacceptable", "Poor", "Fair", "Very Good", "Excellent"]; const { notification } = App.useApp(); const [form] = Form.useForm(); diff --git a/src/views/feedback/Index.jsx b/src/views/feedback/Index.jsx index e788887..c9e4473 100644 --- a/src/views/feedback/Index.jsx +++ b/src/views/feedback/Index.jsx @@ -3,9 +3,9 @@ import { useEffect } from 'react'; import { Row, Col, Space, Table, App } from 'antd'; import { useTranslation } from 'react-i18next'; import SearchForm from '@/components/SearchForm'; -import useAuthStore from '@/stores/Auth'; import useFeedbackStore from '@/stores/Feedback'; import dayjs from 'dayjs'; +import { usingStorage } from '@/hooks/usingStorage'; const feedbackListColumns = [ { @@ -48,7 +48,7 @@ function Index() { const { t } = useTranslation(); const { notification } = App.useApp(); - const travelAgencyId = useAuthStore((state) => state.loginUser.travelAgencyId) + const {travelAgencyId} = usingStorage(); const [loading, feedbackList, fetchFeedbackList] = useFeedbackStore((state) => [state.loading, state.feedbackList, state.fetchFeedbackList]); const showTotal = (total) => `Total ${total} items`; diff --git a/src/views/invoice/Detail.jsx b/src/views/invoice/Detail.jsx index 54eb628..f0605eb 100644 --- a/src/views/invoice/Detail.jsx +++ b/src/views/invoice/Detail.jsx @@ -5,20 +5,17 @@ import { PlusOutlined } from "@ant-design/icons"; import { isNotEmpty } from "@/utils/commons"; import * as config from "@/config"; import dayjs from "dayjs"; -import useAuthStore from '@/stores/Auth'; -import useInvoiceStore, { fetchInvoiceDetail, postEditInvoiceDetail, postAddInvoice } from '@/stores/Invoice'; +import { fetchInvoiceDetail, postEditInvoiceDetail, postAddInvoice } from '@/stores/Invoice'; import { removeFeedbackImages } from '@/stores/Feedback'; import BackBtn from '@/components/BackBtn'; +import { usingStorage } from "@/hooks/usingStorage"; const { Title,Text } = Typography; -const { TextArea } = Input; function Detail() { const navigate = useNavigate(); const { GMDSN, GSN } = useParams(); - const [userId, travelAgencyId, token] = useAuthStore((state) => [state.loginUser.userId, state.loginUser.travelAgencyId, state.loginUser.token]); - // const { invoiceStore, authStore } = useStore(); - // const { invoiceGroupInfo, invoiceProductList, invoiceCurrencyList, invoiceZDDetail } = invoiceStore; + const {userId, travelAgencyId, token} = usingStorage(); const [form] = Form.useForm(); const [dataLoading, setDataLoading] = useState(false); const [edited, setEdited] = useState(true); //表单是否允许编辑 diff --git a/src/views/invoice/Index.jsx b/src/views/invoice/Index.jsx index 28d5aff..02033ed 100644 --- a/src/views/invoice/Index.jsx +++ b/src/views/invoice/Index.jsx @@ -6,12 +6,12 @@ import { formatDate, isNotEmpty } from "@/utils/commons"; import { AuditOutlined, SmileOutlined, SolutionOutlined, EditOutlined } from "@ant-design/icons"; import SearchForm from '@/components/SearchForm'; import dayjs from 'dayjs'; -import useAuthStore from '@/stores/Auth'; import useInvoiceStore from '@/stores/Invoice'; +import { usingStorage } from "@/hooks/usingStorage"; function Index() { - const [travelAgencyId, ] = useAuthStore((state) => [state.loginUser.travelAgencyId]); + const {travelAgencyId, } = usingStorage(); const [invoiceList, fetchInvoiceList] = useInvoiceStore((state) => [state.invoiceList, state.fetchInvoiceList]); const navigate = useNavigate(); const { notification } = App.useApp(); diff --git a/src/views/invoice/Paid.jsx b/src/views/invoice/Paid.jsx index e09780b..27305b7 100644 --- a/src/views/invoice/Paid.jsx +++ b/src/views/invoice/Paid.jsx @@ -3,13 +3,13 @@ import { useEffect } from 'react'; import { Row, Col, Space, Table, Image } from 'antd'; import { formatDate, isNotEmpty } from '@/utils/commons'; import SearchForm from '@/components/SearchForm'; -import useAuthStore from '@/stores/Auth'; import dayjs from 'dayjs'; import BackBtn from '@/components/BackBtn'; import useInvoiceStore from '@/stores/Invoice'; +import { usingStorage } from '@/hooks/usingStorage'; function Paid() { - const [travelAgencyId] = useAuthStore((state) => [state.loginUser.travelAgencyId]); + const {travelAgencyId, } = usingStorage(); const [invoicePaid, fetchInvoicePaid] = useInvoiceStore((state) => [state.invoicePaid, state.fetchInvoicePaid]); const navigate = useNavigate(); const showTotal = (total) => `Total ${total} items`; diff --git a/src/views/invoice/PaidDetail.jsx b/src/views/invoice/PaidDetail.jsx index e9760df..60b3020 100644 --- a/src/views/invoice/PaidDetail.jsx +++ b/src/views/invoice/PaidDetail.jsx @@ -2,15 +2,15 @@ import { useNavigate, useParams } from 'react-router-dom'; import { useEffect, useState } from 'react'; import { Row, Col, Space, Table, Typography } from 'antd'; import { formatDate, isNotEmpty } from '@/utils/commons'; -import useAuthStore from '@/stores/Auth'; import BackBtn from '@/components/BackBtn'; import { fetchInvoicePaidDetail } from '@/stores/Invoice'; +import { usingStorage } from '@/hooks/usingStorage'; const { Title } = Typography; function PaidDetail() { const navigate = useNavigate(); - const [travelAgencyId] = useAuthStore((state) => [state.loginUser.travelAgencyId]); + const {travelAgencyId, } = usingStorage(); const { flid } = useParams(); const [invoicePaidDetail, setInvoicePaidDetail] = useState([]); diff --git a/src/views/notice/Detail.jsx b/src/views/notice/Detail.jsx index e4af7f4..8fc5aab 100644 --- a/src/views/notice/Detail.jsx +++ b/src/views/notice/Detail.jsx @@ -4,15 +4,15 @@ import { Row, Col, Space, Typography, Divider } from 'antd'; import * as comm from '@/utils/commons'; import { useTranslation } from 'react-i18next'; import { fetchNoticeDetail } from '@/stores/Notice'; -import useAuthStore from '@/stores/Auth'; import BackBtn from '@/components/BackBtn'; +import { usingStorage } from '@/hooks/usingStorage'; const { Title, Paragraph } = Typography; function Detail() { const { t } = useTranslation(); const { CCP_BLID } = useParams(); - const [userId, ] = useAuthStore((state) => [state.loginUser.userId]); + const {userId} = usingStorage(); const [noticeInfo, setNoticeInfo] = useState({}); useEffect(() => { diff --git a/src/views/notice/Index.jsx b/src/views/notice/Index.jsx index 68a2c19..c1f3cbc 100644 --- a/src/views/notice/Index.jsx +++ b/src/views/notice/Index.jsx @@ -2,10 +2,11 @@ import { NavLink } from "react-router-dom"; import { useEffect, useState } from "react"; import { Row, Col, Space, Typography, Badge, List } from "antd"; import useNoticeStore, { fetchBulletinList } from '@/stores/Notice'; -import useAuthStore from '@/stores/Auth'; +import { usingStorage } from "@/hooks/usingStorage"; + function Index() { - const [userId, ] = useAuthStore((state) => [state.loginUser.userId]); + const { userId, } = usingStorage(); const getBulletinUnReadCount = useNoticeStore((state) => state.getBulletinUnReadCount); const [noticeList, setNoticeList] = useState([]); diff --git a/src/views/report/Index.jsx b/src/views/report/Index.jsx index b369805..0d09c2b 100644 --- a/src/views/report/Index.jsx +++ b/src/views/report/Index.jsx @@ -3,14 +3,14 @@ import * as comm from '@/utils/commons'; import { usePDF } from 'react-to-pdf'; import dayjs from 'dayjs'; import SearchForm from '@/components/SearchForm'; -import useAuthStore from '@/stores/Auth'; import useReportStore from '@/stores/Report'; import { useTranslation } from 'react-i18next' +import { usingStorage } from '@/hooks/usingStorage'; function Index() { const { t } = useTranslation(); - const [travelAgencyId, ] = useAuthStore((state) => [state.loginUser.travelAgencyId]); + const {travelAgencyId, } = usingStorage(); const [loading, vendorScoresData, getHWVendorScores] = useReportStore((state) => [state.loading, state.vendorScoresData, state.getHWVendorScores]); const [productScoresData, getHWProductScores] = useReportStore((state) => [state.productScoresData, state.getHWProductScores]); const [commendScoresData, getHWCommendScores] = useReportStore((state) => [state.commendScoresData, state.getHWCommendScores]);