From 7b0a48360bdfffbe412846e51718a646471bc3d5 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 29 Jul 2024 09:13:09 +0800 Subject: [PATCH 1/5] 2.0.0-alpha.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From 655114ab44d1726fcb2c63c463129319fa83bdbc Mon Sep 17 00:00:00 2001 From: YCC Date: Mon, 29 Jul 2024 16:10:02 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=9C=BA=E7=A5=A8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.jsx | 2 +- src/stores/Airticket.js | 42 +++++- src/stores/Auth.js | 2 +- src/views/airticket/Index.jsx | 16 +- src/views/airticket/Plan.jsx | 272 ++++++++++++++++++++++++---------- 5 files changed, 239 insertions(+), 95 deletions(-) diff --git a/src/main.jsx b/src/main.jsx index ec6f14b..b2062c1 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -68,7 +68,7 @@ const initRouter = async () => { { path: 'invoice/paid',element:}, { path: 'invoice/paid/detail/:flid', element: }, { path: 'airticket',element: }, - { path: 'airticket/plan/:coli_sn',element:}, + { path: 'airticket/plan/:coli_sn/:gri_sn',element:}, { path: "products",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/Airticket.js b/src/stores/Airticket.js index e73711a..9ec94a8 100644 --- a/src/stores/Airticket.js +++ b/src/stores/Airticket.js @@ -1,5 +1,5 @@ import { create } from "zustand"; -import { fetchJSON } from "@/utils/request"; +import { fetchJSON, postForm } from "@/utils/request"; import { prepareUrl, isNotEmpty } from "@/utils/commons"; import { HT_HOST, DATE_FORMAT } from "@/config"; import dayjs from "dayjs"; @@ -15,7 +15,7 @@ const airTicketStore = create((set, get) => ({ const { setLoading, setPlanList } = get(); setLoading(true); const searchParams = { - vei_sn: 4272, //vei_sn, + vei_sn: vei_sn, FlightDate1: TimeStart, FlightDate2: TimeEnd, GRI_Name: GRI_Name, @@ -30,23 +30,53 @@ const airTicketStore = create((set, get) => ({ async getPlanDetail(vei_sn, gri_sn) { const { setPlanDetail } = get(); const searchParams = { - vei_sn: 4272, //vei_sn, - gri_sn: 372928, //gri_sn + vei_sn: vei_sn, + gri_sn: gri_sn, }; const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/GetFlightPlanDetail`, searchParams); const _result = errcode !== 0 ? [] : result; setPlanDetail(_result); }, + + async postFlightDetail(CLF_SN, GRI_SN, VEI_SN, original_values, info_object) { + const formData = new FormData(); + formData.append("CLF_SN", CLF_SN ? CLF_SN : ""); + formData.append("GRI_SN", GRI_SN); + formData.append("VEI_SN", VEI_SN); + for (const [key, value] of Object.entries(original_values)) { + formData.append(key, value); //先用原始数据填充一遍,确保复制了全部数据到新表 + } + for (const [key, value] of Object.entries(info_object)) { + formData.set(key, value); //再用新值覆盖 + } + const postUrl = HT_HOST + "/Service_BaseInfoWeb/edit_or_new_flight_info"; + return postForm(postUrl, formData).then(json => { + if (json.errcode == 0) { + return json; + } else { + throw new Error(json.errmsg + ": " + json.errcode); + } + }); + }, + async getGuestList(coli_sn) { const { setGuestList } = get(); const searchParams = { - COLI_SN: 1097829, //coli_sn, + COLI_SN: coli_sn, }; const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/GetFlightGuestInfo`, searchParams); const _result = errcode !== 0 ? [] : result; setGuestList(_result); }, - + // async getFlightCostList(CLF_SN) { + // const searchParams = { + // CLF_SN: CLF_SN, + // }; + // const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/Get_flight_cost`, searchParams); + // const _result = errcode !== 0 ? [] : result; + // console.log(_result); + // return _result; + // }, })); export default airTicketStore; diff --git a/src/stores/Auth.js b/src/stores/Auth.js index d880476..3f3808b 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -43,7 +43,7 @@ async function fetchLastRequet() { const initialState = { tokenInterval: null, - tokenTimeout: true, + tokenTimeout: false,// 开发时候用false,正式环境true, loginStatus: 0, defaltRoute: '', currentUser: { diff --git a/src/views/airticket/Index.jsx b/src/views/airticket/Index.jsx index 32a84a5..09b0d87 100644 --- a/src/views/airticket/Index.jsx +++ b/src/views/airticket/Index.jsx @@ -46,33 +46,33 @@ const planListColumns = [ dataIndex: "ToCity", }, { - title: "航空", + title: "航班", key: "FlightNo", dataIndex: "FlightNo", }, { title: "起飞时间", - key: "FlightTimeStart", - dataIndex: "FlightTimeStart", + key: "FlightStart", + dataIndex: "FlightStart", render: text => formatColonTime(text), }, { title: "落地时间", - key: "FlightTimeEnd", - dataIndex: "FlightTimeEnd", + key: "FlightEnd", + dataIndex: "FlightEnd", render: text => formatColonTime(text), }, { title: "是否出票", - key: "COLD_PlanVEI_SN", - dataIndex: "COLD_PlanVEI_SN", + key: "CLF_SN", + dataIndex: "CLF_SN", render: (text, record) => "否", }, { title: "操作", key: "FlightInfo", dataIndex: "FlightInfo", - render: (text, record) => {"编辑"}, + render: (text, record) => {"编辑"}, }, ]; diff --git a/src/views/airticket/Plan.jsx b/src/views/airticket/Plan.jsx index ea193fa..3799ab0 100644 --- a/src/views/airticket/Plan.jsx +++ b/src/views/airticket/Plan.jsx @@ -1,6 +1,6 @@ import { useState, useEffect } from "react"; -import { Grid, Divider, Layout, Modal, Form, Input, Col, Row, Space, Collapse, Table, Button, Select, InputNumber, Typography } from "antd"; -import { PhoneOutlined, CustomerServiceOutlined, AudioOutlined, ArrowUpOutlined, ArrowDownOutlined } from "@ant-design/icons"; +import { Grid, Divider, Layout, Modal, Form, Input, Col, Row, Space, Collapse, Table, Button, Select, App, Typography } from "antd"; +import { PhoneOutlined, FrownTwoTone, LikeTwoTone, ArrowUpOutlined, ArrowDownOutlined } from "@ant-design/icons"; import { useParams, useHref, useNavigate, NavLink } from "react-router-dom"; import { isEmpty, formatColonTime } from "@/utils/commons"; import { OFFICEWEBVIEWERURL } from "@/config"; @@ -9,13 +9,22 @@ import airTicketStore from "@/stores/Airticket"; import { usingStorage } from "@/hooks/usingStorage"; const AirticketPlan = props => { - const { coli_sn } = useParams(); + const { coli_sn, gri_sn } = useParams(); const { travelAgencyId, loginToken } = usingStorage(); - const [getPlanDetail, planDetail, getGuestList, guestList, loading] = airTicketStore(state => [state.getPlanDetail, state.planDetail, state.getGuestList, state.guestList, state.loading]); + const [getPlanDetail, planDetail, getGuestList, guestList, loading, postFlightDetail, getFlightCostList] = airTicketStore(state => [ + state.getPlanDetail, + state.planDetail, + state.getGuestList, + state.guestList, + state.loading, + state.postFlightDetail, + state.getFlightCostList, + ]); const reservationUrl = `https://p9axztuwd7x8a7.mycht.cn/Service_BaseInfoWeb/FlightPlanDocx?GRI_SN=${coli_sn}&VEI_SN=${travelAgencyId}`; const reservationPreviewUrl = OFFICEWEBVIEWERURL + encodeURIComponent(reservationUrl); - - // console.log(reservationPreviewUrl); + const [form] = Form.useForm(); + const { notification } = App.useApp(); + //console.log(reservationPreviewUrl); //乘客列表 const guestListColumns = [ @@ -98,79 +107,185 @@ const AirticketPlan = props => { }, ]; + //费用列表 + const costListColumns = [ + { + title: "费用类型", + key: "CostType", + dataIndex: "CostType", + }, + { + title: "金额", + key: "Cost", + dataIndex: "Cost", + }, + { + title: "PNR", + key: "PNR", + dataIndex: "PNR", + }, + { + title: "FlightCost", + key: "FlightCost", + dataIndex: "FlightCost", + }, + { + title: "Discount", + key: "Discount", + dataIndex: "Discount", + }, + { + title: "ServiceFee", + key: "ServiceFee", + dataIndex: "ServiceFee", + }, + { + title: "DateTime", + key: "DateTime", + dataIndex: "DateTime", + }, + { + title: "FlightType", + key: "FlightType", + dataIndex: "FlightType", + }, + { + title: "Memo", + key: "Memo", + dataIndex: "Memo", + }, + { + title: "编辑", + key: "CLF_SN", + dataIndex: "CLF_SN", //GRI_SN VEI_SN + }, + ]; + const Airticket_form = props => { - const aitInfo = props.airInfo; + const airInfo = props.airInfo; return ( <> -
- - - } value={aitInfo.FromCity} /> - } value={aitInfo.ToCity} /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + { + postFlightDetail(airInfo.CLF_SN, airInfo.GRI_SN, airInfo.VEI_SN, airInfo, values) + .then(() => { + notification.success({ + message: `成功`, + description: "机票信息保存成功!", + placement: "top", + duration: 4, + icon: , + }); + }) + .catch(() => { + notification.error({ + message: `错误`, + description: "保存失败", + placement: "top", + duration: 4, + icon: , + }); + }); + }} + autoComplete="off"> + + + + } /> + + + } /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - 费用列表 - - + + + + + + + + + + + + + 费用列表 +
+ + ); }; @@ -180,7 +295,7 @@ const AirticketPlan = props => { ? planDetail.map(item => { return { key: item.id, - label: `${item.StartDate} 计划: ${item.FlightInfo}`, + label: `${item.StartDate}`, children: , }; }) @@ -222,7 +337,7 @@ const AirticketPlan = props => { const TicketModal = () => { return ( <> - +
{ // 机票信息编辑表单 end useEffect(() => { - getPlanDetail(travelAgencyId, coli_sn); + getPlanDetail(travelAgencyId, gri_sn); getGuestList(travelAgencyId, coli_sn); - console.log(detail_items()); }, []); return ( From f68370fa729f6f59c92f5bed271c134f86fd2bd2 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 29 Jul 2024 17:02:39 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=8F=AF=E4=BB=A5=E5=90=8C=E6=97=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=BA=BA=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prerelease.bat | 1 + src/views/account/Management.jsx | 1 - src/views/products/Detail.jsx | 3 +- .../products/Detail/BatchImportPrice.jsx | 307 +++++++++++++++--- 4 files changed, 257 insertions(+), 55 deletions(-) create mode 100644 prerelease.bat diff --git a/prerelease.bat b/prerelease.bat new file mode 100644 index 0000000..f418442 --- /dev/null +++ b/prerelease.bat @@ -0,0 +1 @@ +npm version prerelease \ No newline at end of file diff --git a/src/views/account/Management.jsx b/src/views/account/Management.jsx index f495de5..4740326 100644 --- a/src/views/account/Management.jsx +++ b/src/views/account/Management.jsx @@ -356,7 +356,6 @@ function Management() { showSizeChanger: true, showTotal: (total) => { return t('Total') + `:${total}` } }} - onChange={(pagination) => { onSearchClick(pagination.current) }} columns={accountListColumns} dataSource={accountList} /> diff --git a/src/views/products/Detail.jsx b/src/views/products/Detail.jsx index af0ee47..5939a51 100644 --- a/src/views/products/Detail.jsx +++ b/src/views/products/Detail.jsx @@ -380,7 +380,7 @@ function Detail() { }; fetchData(); }, [productsTypes, travel_agency_id, use_year, audit_state, agencyProducts]); - + const flattenTreeData = (tree) => { let flatList = []; const flatten = (nodes) => { @@ -1169,7 +1169,6 @@ function Detail() { } { - !isCanEditable && } diff --git a/src/views/products/Detail/BatchImportPrice.jsx b/src/views/products/Detail/BatchImportPrice.jsx index 0b35796..723d481 100644 --- a/src/views/products/Detail/BatchImportPrice.jsx +++ b/src/views/products/Detail/BatchImportPrice.jsx @@ -1,13 +1,14 @@ -import React, { useState } from 'react'; -import { Button, Card, Checkbox, Col, DatePicker, Form, Input, Row, Select, Space, Tag, Table, InputNumber } from 'antd'; +import { useEffect, useState } from 'react'; +import { Button, Card, Checkbox, Col, DatePicker, Typography, Form, Input, Row, Select, Space, Tag, Table, InputNumber } from 'antd'; import { CloseOutlined } from '@ant-design/icons'; -import dayjs from 'dayjs'; import { useDatePresets } from '@/hooks/useDatePresets'; const { Option } = Select; const { RangePicker } = DatePicker; const BatchImportPrice = ({ onBatchImportData }) => { const [form] = Form.useForm(); + const [peopleForm] = Form.useForm(); + const [tags, setTags] = useState([]); const [minPeople, setMinPeople] = useState(''); const [maxPeople, setMaxPeople] = useState(''); @@ -16,6 +17,35 @@ const BatchImportPrice = ({ onBatchImportData }) => { const [sendData, setSendData] = useState(null); const presets = useDatePresets(); + useEffect(() => { + peopleForm.setFieldValue({ + "items": [ + { + "weekend": [ + "5", + "6", + "7" + ], + "peopleList": [ + { + "peoplePrice": "22", + "numberStart": "1", + "numberEnd": "2", + "audultPrice": "23", + "childrenPrice": "44" + }, + { + "numberStart": "3", + "numberEnd": "5", + "audultPrice": "24", + "childrenPrice": "12" + } + ] + } + ] + }) + }) + const handleTagClose = (removedTag) => { setTags(tags.filter(tag => tag !== removedTag)); }; @@ -237,63 +267,228 @@ const BatchImportPrice = ({ onBatchImportData }) => { ...generatePeopleColumns(), ]; + const PriceInput = (props) => { + const { id, value = {}, onChange } = props + const [numberStart, setNumberStart] = useState(0) + const [numberEnd, setNumberEnd] = useState(0) + const [audultPrice, setAudultPrice] = useState(0) + const [childrenPrice, setChildrenPrice] = useState(0) + const triggerChange = (changedValue) => { + onChange?.({ + numberStart, + numberEnd, + audultPrice, + childrenPrice, + ...value, + ...changedValue, + }) + } + const onNumberStartChange = (e) => { + const newNumber = parseInt(e.target.value || '0', 10) + if (Number.isNaN(numberStart)) { + return + } + if (!('numberStart' in value)) { + setNumberStart(newNumber); + } + triggerChange({ + numberStart: newNumber, + }) + } + const onNumberEndChange = (e) => { + const newNumber = parseInt(e.target.value || '0', 10) + if (Number.isNaN(numberEnd)) { + return + } + if (!('numberEnd' in value)) { + setNumberEnd(newNumber) + } + triggerChange({ + numberEnd: newNumber, + }); + }; + const onAudultPriceChange = (e) => { + const newNumber = parseInt(e.target.value || '0', 10) + if (Number.isNaN(audultPrice)) { + return + } + if (!('audultPrice' in value)) { + setAudultPrice(newNumber) + } + triggerChange({ + audultPrice: newNumber, + }) + } + const onChildrenPriceChange = (e) => { + const newNumber = parseInt(e.target.value || '0', 10) + if (Number.isNaN(childrenPrice)) { + return + } + if (!('childrenPrice' in value)) { + setChildrenPrice(newNumber) + } + triggerChange({ + childrenPrice: newNumber, + }) + }; + return ( + + + + + + + ) + } + return ( -
- +
+ - - - - setMinPeople(e.target.value)} - /> - - setMaxPeople(e.target.value)} - /> - - - - - - - -
- {tags.map((tag) => ( - handleTagClose(tag)}> - {tag} - - ))} -
+ + {(fields, { add, remove }) => ( +
+ {fields.map((field, index) => ( + + + + + + + + + + {(priceFields, priceOpt) => ( + <> + {priceFields.map((priceField) => ( + + + + - - + priceOpt.remove(priceField.name)} /> + + ))} + + + )} + + + + + ))} +
+ )} +
+ + {() => ( + +
{JSON.stringify(peopleForm.getFieldsValue(), null, 2)}
+
+ )} +
+ + + + @@ -348,6 +543,13 @@ const BatchImportPrice = ({ onBatchImportData }) => { )} + + {() => ( + +
{JSON.stringify(form.getFieldsValue(), null, 2)}
+
+ )} +
- - - {(fields, { add, remove }) => ( -
- {fields.map((field, index) => ( - - - - - - - - - - {(priceFields, priceOpt) => ( - <> - {priceFields.map((priceField) => ( - - - + + + + + + + ) + } + + const priceInitialValues = { + "items": [ + // 旺季 + { + "useDate": [ + dayjs().add(1, 'year').startOf("y"), dayjs().add(1, 'year').endOf("y") + ], + "unitName": "每人", + "currency": "CNY", + "weekend": [ + "5", + "6" + ], + "prieceList": [ + { + "priceInput": { + "numberStart": 1, + "numberEnd": 2, + "audultPrice": 0, + "childrenPrice": 0 + } + }, + { + "priceInput": { + "numberStart": 3, + "numberEnd": 4, + "audultPrice": 0, + "childrenPrice": 0 + } + }, + { + "priceInput": { + "numberStart": 5, + "numberEnd": 6, + "audultPrice": 0, + "childrenPrice": 0 + } + }, + { + "priceInput": { + "numberStart": 7, + "numberEnd": 9, + "audultPrice": 0, + "childrenPrice": 0 + } + } + ] + }, + // 淡季 + { + "useDate": [ + dayjs().add(1, 'year').subtract(2, "M").startOf("M"), dayjs().add(1, 'year').endOf("M") + ], + "unitName": "每人", + "currency": "CNY", + + "weekend": [ + "5", + "6" + ], + + "prieceList": [ + { + "priceInput": { + "numberStart": 1, + "numberEnd": 2, + "audultPrice": 0, + "childrenPrice": 0 + } + }, + { + "priceInput": { + "numberStart": 3, + "numberEnd": 4, + "audultPrice": 0, + "childrenPrice": 0 + } + }, + { + "priceInput": { + "numberStart": 5, + "numberEnd": 6, + "audultPrice": 0, + "childrenPrice": 0 + } + }, + { + "priceInput": { + "numberStart": 7, + "numberEnd": 9, + "audultPrice": 0, + "childrenPrice": 0 + } + } + ] + } + ] + } + + return ( + +
+ + + {(fields, { add, remove }) => ( + + {fields.map((field, index) => ( + { + remove(field.name) + }} />} + > + + - priceOpt.remove(priceField.name)} /> - - ))} - - - )} - - - - - - ))} - - )} - - - {() => ( - -
{JSON.stringify(peopleForm.getFieldsValue(), null, 2)}
-
- )} -
- - - - - - - {(fields, { add, remove }) => ( -
- {fields.map((field, index) => ( - remove(field.name)} />} - > - - - - - - - - - - - {(periodFields, periodOpt) => ( -
- {periodFields.map((periodField, idx) => ( - - - - - periodOpt.remove(periodField.name)} /> - - ))} - -
- )} -
-
-
+ + + + + + + + + + + + {(prieceFieldList, priceOptList) => ( + + {prieceFieldList.map((priceField) => ( + + + + + priceOptList.remove(priceField.name)} /> + ))} - -
- )} -
- - {() => ( - -
{JSON.stringify(form.getFieldsValue(), null, 2)}
-
- )} -
- - - - - {tableData.length > 0 && ( -
-
- + + )} + + + + ))} + + + )} + + + {() => ( + +
{JSON.stringify(priceForm.getFieldsValue(), null, 2)}
+
)} - - - ); +
+ + + + ); }; export default BatchImportPrice; From 2b9a365c45ee89bdf6af68736f8af419beee80ef Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 30 Jul 2024 15:29:04 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E7=94=9F=E6=88=90=E5=92=8C=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/products/Detail.jsx | 2 +- .../products/Detail/BatchImportPrice.jsx | 95 ++++++++++++++++--- 2 files changed, 81 insertions(+), 16 deletions(-) diff --git a/src/views/products/Detail.jsx b/src/views/products/Detail.jsx index 997348a..64f072e 100644 --- a/src/views/products/Detail.jsx +++ b/src/views/products/Detail.jsx @@ -1217,7 +1217,7 @@ function Detail() { open={batchImportPriceVisible} onOk={handleBatchImportOK} onCancel={() => setBatchImportPriceVisible(false)} - width={620} + width={'90%'} > diff --git a/src/views/products/Detail/BatchImportPrice.jsx b/src/views/products/Detail/BatchImportPrice.jsx index 5f3dbcc..ab56f58 100644 --- a/src/views/products/Detail/BatchImportPrice.jsx +++ b/src/views/products/Detail/BatchImportPrice.jsx @@ -1,14 +1,70 @@ import { useState } from 'react'; -import { Button, Card, Checkbox, Col, Flex, DatePicker, Typography, Form, Input, Row, Select, Space } from 'antd'; +import { Button, Card, Checkbox, Table, Col, Flex, DatePicker, Typography, Form, Input, Row, Select, Space } from 'antd'; import dayjs from "dayjs"; -import { CloseOutlined } from '@ant-design/icons'; +import { useTranslation } from 'react-i18next'; +import { CloseOutlined, StarOutlined } from '@ant-design/icons'; import { useDatePresets } from '@/hooks/useDatePresets'; const { Option } = Select; const { RangePicker } = DatePicker; const BatchImportPrice = ({ onBatchImportData }) => { - const [priceForm] = Form.useForm(); - const presets = useDatePresets(); + const { t } = useTranslation() + + const previewTableColumns = [ + { title: t('products:adultPrice'), dataIndex: 'adult_cost', width: '10%' }, + { title: t('products:childrenPrice'), dataIndex: 'child_cost', width: '10%' }, + { title: t('products:currency'), dataIndex: 'currency', width: '10%' }, + { + title: t('products:Types'), + dataIndex: 'unit', + width: '10%', + editable: true, + render: (text) => (text === '0' ? '每人' : text === '1' ? '每团' : text), + }, + { + title: t('products:number'), + dataIndex: 'group_size', + width: '10%', + editable: true, + render: (_, record) => `${record.group_size_min}-${record.group_size_max}` + }, + { + title: t('products:validityPeriod'), + dataIndex: 'validityPeriod', + width: '20%', + editable: true, + render: (_, record) => dayjs(record.use_dates_start).format('YYYY-MM-DD') + '~' + dayjs(record.use_dates_end).format('YYYY-MM-DD') + }, + { title: t('products:Weekdays'), dataIndex: 'weekdays', width: '10%' }, + ] + + const [priceForm] = Form.useForm() + const [previewData, setPreviewData] = useState([]) + const presets = useDatePresets() + + const previewSetupPrice = () => { + let previewList = [] + const defList = priceForm.getFieldsValue().defList + + defList.forEach(definition => { + const previewPrice = definition?.priceList.map(price => { + return { + adult_cost: price.priceInput.audultPrice, + child_cost: price.priceInput.childrenPrice, + group_size_min: price.priceInput.numberStart, + group_size_max: price.priceInput.numberEnd, + + currency: definition.currency, + unit: definition.unitName, + use_dates_start: definition.useDate[0], + use_dates_end: definition.useDate[1], + weekdays: definition.weekend.join(','), + } + }) + previewList.push(...previewPrice) + }) + setPreviewData(previewList) + } const PriceInput = (props) => { const { id, value = {}, onChange } = props @@ -116,7 +172,7 @@ const BatchImportPrice = ({ onBatchImportData }) => { } const priceInitialValues = { - "items": [ + "defList": [ // 旺季 { "useDate": [ @@ -128,7 +184,7 @@ const BatchImportPrice = ({ onBatchImportData }) => { "5", "6" ], - "prieceList": [ + "priceList": [ { "priceInput": { "numberStart": 1, @@ -170,13 +226,11 @@ const BatchImportPrice = ({ onBatchImportData }) => { ], "unitName": "每人", "currency": "CNY", - "weekend": [ "5", "6" ], - - "prieceList": [ + "priceList": [ { "priceInput": { "numberStart": 1, @@ -216,7 +270,7 @@ const BatchImportPrice = ({ onBatchImportData }) => { return ( - + { autoComplete="off" initialValues={priceInitialValues} > - + {(fields, { add, remove }) => ( {fields.map((field, index) => ( @@ -259,15 +313,15 @@ const BatchImportPrice = ({ onBatchImportData }) => { /> - - {(prieceFieldList, priceOptList) => ( + + {(priceFieldList, priceOptList) => ( - {prieceFieldList.map((priceField) => ( + {priceFieldList.map((priceField, index) => ( - priceOptList.remove(priceField.name)} /> + {index==0?: priceOptList.remove(priceField.name)} />} ))} + +
+ ); };