diff --git a/web/src/assets/global.css b/web/src/assets/global.css index cc5d96f..5be59b4 100644 --- a/web/src/assets/global.css +++ b/web/src/assets/global.css @@ -1,6 +1,3 @@ @import 'tailwindcss/base'; @import 'tailwindcss/components'; -@import 'tailwindcss/utilities'; -.ant-table-wrapper.border-collapse table { - border-collapse: collapse; -} +@import 'tailwindcss/utilities'; \ No newline at end of file diff --git a/web/src/hooks/useDatePresets.js b/web/src/hooks/useDatePresets.js deleted file mode 100644 index 779c244..0000000 --- a/web/src/hooks/useDatePresets.js +++ /dev/null @@ -1,60 +0,0 @@ -import { useEffect, useState } from 'react'; -import dayjs from "dayjs"; -import { useTranslation } from 'react-i18next'; -import i18n from '@/i18n'; - -export const useDatePresets = () => { - const [presets, setPresets] = useState([]); - const { t, i18n } = useTranslation(); - - useEffect(() => { - const newPresets = [ - { - label: t("datetime.thisWeek"), - value: [dayjs().startOf("w"), dayjs().endOf("w")], - }, - { - label: t("datetime.lastWeek"), - value: [dayjs().startOf("w").subtract(7, "days"), dayjs().endOf("w").subtract(7, "days")], - }, - { - label: t("datetime.thisMonth"), - value: [dayjs().startOf("M"), dayjs().endOf("M")], - }, - { - label: t("datetime.lastMonth"), - value: [dayjs().subtract(1, "M").startOf("M"), dayjs().subtract(1, "M").endOf("M")], - }, - { - label: t("datetime.lastThreeMonth"), - value: [dayjs().subtract(2, "M").startOf("M"), dayjs().endOf("M")], - }, - { - label: t("datetime.thisYear"), - value: [dayjs().startOf("y"), dayjs().endOf("y")], - }, - ]; - setPresets(newPresets); - }, [i18n.language]); - - return presets; -} - -export const useWeekdays = () => { - const [data, setData] = useState([]); - const { t, i18n } = useTranslation(); - useEffect(() => { - const newData = [ - { value: '1', label: t('weekdays.1') }, - { value: '2', label: t('weekdays.2') }, - { value: '3', label: t('weekdays.3') }, - { value: '4', label: t('weekdays.4') }, - { value: '5', label: t('weekdays.5') }, - { value: '6', label: t('weekdays.6') }, - { value: '7', label: t('weekdays.7') }, - ]; - setData(newData); - return () => {}; - }, [i18n.language]); - return data; -}; diff --git a/web/src/hooks/useHTLanguageSets.js b/web/src/hooks/useHTLanguageSets.js deleted file mode 100644 index f01e46c..0000000 --- a/web/src/hooks/useHTLanguageSets.js +++ /dev/null @@ -1,20 +0,0 @@ -export const useHTLanguageSets = () => { - 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; -}; - -export const useHTLanguageSetsMapVal = () => { - const stateSets = useHTLanguageSets(); - const stateMapVal = stateSets.reduce((r, c) => ({ ...r, [`${c.value}`]: c }), {}); - return stateMapVal; -}; diff --git a/web/src/hooks/useProductsSets.js b/web/src/hooks/useProductsSets.js deleted file mode 100644 index 8ec4355..0000000 --- a/web/src/hooks/useProductsSets.js +++ /dev/null @@ -1,182 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import useAuthStore from '@/stores/Auth'; -import { PERM_OVERSEA, PERM_AIR_TICKET, PERM_PRODUCTS_MANAGEMENT } from '@/config'; -import { isEmpty } from '@/utils/commons'; - -/** - * 产品管理 相关的预设数据 - * 项目类型 - * * 酒店预定 1 - * * 火车 2 - * * 飞机票务 3 - * * 游船 4 - * * 快巴 5 - * * 旅行社(综费) 6 - * * 景点 7 - * * 特殊项目 8 - * * 其他 9 - * * 酒店 A - * * 超公里 B - * * 餐费 C - * * 小包价 D // 包价线路 - * * 站 X - * * 购物 S - * * 餐 R (餐厅) - * * 娱乐 E - * * 精华线路 T - * * 客人testimonial F - * * 线路订单 O - * * 省 P - * * 信息 I - * * 国家 G - * * 城市 K - * * 图片 H - * * 地图 M - * * 包价线路 L (已废弃) - * * 节日节庆 V - * * 火车站 N - * * 手机租赁 Z - * * ---- webht 类型, 20240624 新增HT类型 ---- - * * 导游 Q - * * 车费 J - */ - -export const useProductsTypes = (showAll = false) => { - const [types, setTypes] = useState([]); - const { t, i18n } = useTranslation(); - - useEffect(() => { - const allItem = [{ label: t('All'), value: '', key: '' }]; - const newData = [ - { label: t('products:type.Experience'), value: '6', key: '6' }, - { label: t('products:type.UltraService'), value: 'B', key: 'B' }, - { label: t('products:type.Car'), value: 'J', key: 'J' }, - { label: t('products:type.Guide'), value: 'Q', key: 'Q' }, - { label: t('products:type.Attractions'), value: '7', key: '7' }, // landscape - { label: t('products:type.Meals'), value: 'R', key: 'R' }, - { label: t('products:type.Extras'), value: '8', key: '8' }, - { label: t('products:type.Package'), value: 'D', key: 'D' }, - ]; - const res = showAll ? [...allItem, ...newData] : newData; - setTypes(res); - }, [i18n.language]); - - return types; -}; -export const useProductsTypesMapVal = (value) => { - const stateSets = useProductsTypes(); - const stateMapVal = stateSets.reduce((r, c) => ({ ...r, [`${c.value}`]: c }), {}); - return stateMapVal; -}; - -export const useProductsAuditStates = () => { - const [types, setTypes] = useState([]); - const { t, i18n } = useTranslation(); - - useEffect(() => { - const newData = [ - { key: '-1', value: '-1', label: t('products:auditState.New'), color: 'muted' }, - { key: '0', value: '0', label: t('products:auditState.Pending'), color: '' }, - { key: '2', value: '2', label: t('products:auditState.Approved'), color: 'primary' }, - { key: '3', value: '3', label: t('products:auditState.Rejected'), color: 'danger' }, - { key: '1', value: '1', label: t('products:auditState.Published'), color: 'primary' }, - // ELSE 未知 - ]; - 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; -}; - -/** - * @ignore - */ -export const useProductsTypesFieldsets = (type) => { - const [isPermitted] = useAuthStore((state) => [state.isPermitted]); - const infoDefault = [['city'], ['title']]; - const infoAdmin = ['title', 'product_title', 'code', 'remarks', 'dept']; // 'display_to_c' - const infoDisplay = isPermitted(PERM_PRODUCTS_MANAGEMENT) ? ['display_to_c'] : []; - const infoRecDisplay = isPermitted(PERM_PRODUCTS_MANAGEMENT) ? ['recommends_rate'] : []; - const infoTypesMap = { - '6': [[], []], - 'B': [['km'], []], - 'J': [[...infoRecDisplay, 'duration', ], ['description']], - 'Q': [[...infoRecDisplay, 'duration', ], ['description']], - 'D': [[...infoRecDisplay, 'duration', ...infoDisplay], ['description']], - '7': [[...infoRecDisplay, 'duration', 'open_weekdays'], ['description']], - 'R': [[], ['description']], - '8': [[], []], - }; - const thisTypeFieldset = (_type) => { - if (isEmpty(_type)) { - return infoDefault; - } - const adminSet = isPermitted(PERM_PRODUCTS_MANAGEMENT) ? infoAdmin : []; - return [ - [...infoDefault[0], ...infoTypesMap[_type][0], ...adminSet], - [...infoDefault[1], ...infoTypesMap[_type][1]], - ]; - }; - return thisTypeFieldset(type); -}; - -export const useNewProductRecord = () => { - return { - info: { - 'id': '', - 'htid': 0, - 'title': '', - 'code': '', - 'product_type_id': '', - 'product_type_name': '', - 'remarks': '', - 'duration': 0, - 'duration_unit': 'h', - 'open_weekdays': ['1', '2', '3', '4', '5', '6', '7'], - 'recommends_rate': 0, - 'dept_id': 0, - 'dept_name': '', - 'display_to_c': 0, - 'km': 0, - 'city_id': 0, - 'city_name': '', - 'open_hours': '', - 'lastedit_changed': '', - 'create_date': '', - 'created_by': '', - }, - lgc_details: [ - { - 'title': '', - 'descriptions': '', - 'lgc': 1, - 'id': '', - }, - ], - quotation: [ - { - 'id': '', - 'adult_cost': 0, - 'child_cost': 0, - 'currency': 'RMB', - 'unit_id': '1', - 'unit_name': '每团', - 'group_size_min': 1, - 'group_size_max': 2, - 'use_dates_start': '', - 'use_dates_end': '', - 'weekdays': '', - 'audit_state_id': -1, - 'audit_state_name': '', - 'lastedit_changed': '', - }, - ], - }; -}; diff --git a/web/src/hooks/usingStorage.js b/web/src/hooks/usingStorage.js deleted file mode 100644 index 1292d1a..0000000 --- a/web/src/hooks/usingStorage.js +++ /dev/null @@ -1,86 +0,0 @@ -const persistObject = {} - -/** - * G-INT:USER_ID -> userId = 456 - * G-STR:LOGIN_TOKEN -> loginToken = 'E6779386E7D64DF0ADD0F97767E00D8B' - * G-JSON:LOGIN_USER -> loginUser = { username: 'test-username' } - */ -export function usingStorage() { - - const getStorage = () => { - if (import.meta.env.DEV && window.localStorage) { - return window.localStorage - } else if (window.sessionStorage) { - return window.sessionStorage - } else { - console.error('browser not support localStorage and sessionStorage.') - } - } - - const setProperty = (key, value) => { - const webStorage = getStorage() - const typeAndKey = key.split(':') - if (typeAndKey.length === 2) { - const propName = camelCasedWords(typeAndKey[1]) - persistObject[propName] = value - if (typeAndKey[0] === 'G-JSON') { - webStorage.setItem(key, JSON.stringify(value)) - } else { - webStorage.setItem(key, value) - } - } - } - - // USER_ID -> userId - const camelCasedWords = (string) => { - if (typeof string !== 'string' || string.length === 0) { - return string; - } - return string.split('_').map((word, index) => { - if (index === 0) { - return word.toLowerCase() - } else { - return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() - } - }).join('') - } - - if (Object.keys(persistObject).length == 0) { - - const webStorage = getStorage() - - for (let i = 0; i < webStorage.length; i++) { - const key = webStorage.key(i) - const typeAndKey = key.split(':') - - if (typeAndKey.length === 2) { - const value = webStorage.getItem(key) - const propName = camelCasedWords(typeAndKey[1]) - if (typeAndKey[0] === 'G-INT') { - persistObject[propName] = parseInt(value, 10) - } else if (typeAndKey[0] === 'G-JSON') { - try { - persistObject[propName] = JSON.parse(value) - } catch (e) { - // 如果解析失败,保留原始字符串值 - persistObject[propName] = value - console.error('解析 JSON 失败。') - } - } else { - persistObject[propName] = value - } - } - } - } - - return { - ...persistObject, - setStorage: (key, value) => { - setProperty(key, value) - }, - clearStorage: () => { - getStorage().clear() - Object.assign(persistObject, {}) - } - } -} diff --git a/web/src/stores/Hotel.js b/web/src/stores/Hotel.js index a54fc3c..576d4ef 100644 --- a/web/src/stores/Hotel.js +++ b/web/src/stores/Hotel.js @@ -1,7 +1,6 @@ import { create } from 'zustand' import { devtools } from 'zustand/middleware' -import { fetchJSON, postForm } from '@/utils/request' -import { usingStorage } from '@/hooks/usingStorage' +import { fetchJSON } from '@/utils/request' export const fetchHotelList = async (hotelName, checkinDateString, checkoutDateString) => { const { errcode, data } = await fetchJSON( @@ -20,7 +19,7 @@ export const fetchAvailability = async (hotelId, checkinDateString, checkoutDate } -const useHotelStore = create(devtools((set, get) => ({ +const useHotelStore = create(devtools((set) => ({ selectedHotel: null, hotelList: [],