You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.0 KiB
JavaScript
106 lines
3.0 KiB
JavaScript
import { useEffect, useState } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
/**
|
|
* 产品管理 相关的预设数据
|
|
* 项目类型
|
|
酒店预定 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 = () => {
|
|
const [types, setTypes] = useState([]);
|
|
const { t, i18n } = useTranslation();
|
|
|
|
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: 'J', key: 'J' },
|
|
{ label: t('products:type.Guide'), value: 'Q', key: 'Q' },
|
|
{ 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);
|
|
}, [i18n.language]);
|
|
|
|
return types;
|
|
};
|
|
|
|
export const useProductsAuditStates = () => {
|
|
const [types, setTypes] = useState([]);
|
|
const { t, i18n } = useTranslation();
|
|
|
|
useEffect(() => {
|
|
const newData = [
|
|
{ key: '-1', value: '-1', label: t('products:auditState.New'), color: 'gray-500' },
|
|
{ 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: 'red-500' },
|
|
{ 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, role) => {
|
|
const infoDefault = ['code', 'title'];
|
|
const infoAdmin = ['remarks', 'dept', 'display_to_c'];
|
|
const infoTypesMap = {
|
|
'6': [],
|
|
'B': ['city_id', 'km'],
|
|
'J': ['description', 'city_id', 'recommends_rate', 'duration', 'display_to_c'],
|
|
'Q': ['description', 'city_id', 'duration', ],
|
|
'D': ['description', 'city_id', 'recommends_rate','duration',],
|
|
'7': ['description', 'city_id', 'recommends_rate', 'duration', 'display_to_c', 'open_weekdays'], // todo: 怎么是2个图
|
|
'C': ['description', 'city_id',],
|
|
'8': [], // todo: ?
|
|
};
|
|
};
|