import { useState, useEffect } from "react"; import { Checkbox, Divider, DatePicker, Modal, Form, Input, Col, Row, Space, Collapse, Table, Button, Select, App, Popconfirm, Switch, Radio, List } from "antd"; import { PhoneOutlined, FrownTwoTone, LikeTwoTone, ArrowUpOutlined, ArrowDownOutlined, PlusOutlined } from "@ant-design/icons"; import { useParams, useHref, useNavigate, NavLink } from "react-router-dom"; import { isEmpty, formatColonTime } from "@/utils/commons"; import { OFFICEWEBVIEWERURL } from "@/config"; import dayjs from "dayjs"; import trainTicketStore from "@/stores/Trainticket"; import { usingStorage } from "@/hooks/usingStorage"; import BackBtn from "@/components/BackBtn"; import { station_names } from "@/views/trainticket/station_name"; import { Upload } from "antd"; import ImageUploader from "@/components/ImageUploader"; const TrainticketPlan = props => { const { coli_sn, gri_sn } = useParams(); const { travelAgencyId, loginToken, userId } = usingStorage(); const [ getPlanDetail, planDetail, getGuestList, guestList, loading, postFlightDetail, postFlightCost, deleteFlightCost, getVeiPlanChange, veiPlanChangeTxt, postVeiFlightPlanConfirm, ticketIssuedNotifications, delete_flight_info, seatTable, ] = trainTicketStore(state => [ state.getPlanDetail, state.planDetail, state.getGuestList, state.guestList, state.loading, state.postFlightDetail, state.postFlightCost, state.deleteFlightCost, state.getVeiPlanChange, state.veiPlanChangeTxt, state.postVeiFlightPlanConfirm, state.ticketIssuedNotifications, state.delete_flight_info, state.seatTable, ]); const reservationUrl = `https://p9axztuwd7x8a7.mycht.cn/Service_BaseInfoWeb/FlightPlanDocx?GRI_SN=${gri_sn}&VEI_SN=${travelAgencyId}&token=${loginToken}`; const reservationPreviewUrl = OFFICEWEBVIEWERURL + encodeURIComponent(reservationUrl); // const [form] = Form.useForm(); const { notification } = App.useApp(); //乘客下拉列表 const guestList_select = () => { return ( guestList && guestList.map(item => { return { label: `${item.MEI_Name} , ${item.MEI_PassportNo}`, value: `${item.MEI_Name} , ${item.MEI_PassportNo} , ${item.MEI_Country} , ${item.MEI_Gender} , ${item.MEI_age} , ${item.MEI_Birthday}` }; }) ); }; const station_name_select = rawStr => { const records = rawStr.split("@").filter(item => item); // 1. 按@分割记录(过滤空的首元素) return records.map(record => { // 按|分割字段(最多取前8个有效字段,忽略末尾空字段) const [ abbreviation, // 缩写(如bjb) name, // 站名(如北京北) code, // 代码(如VAP) pinyin, // 拼音(如beijingbei) shortPinyin, // 简拼(如bjb) sequence, // 序号(如0) areaCode, // 区域代码(如0357) city, // 城市(如北京) ] = record.split("|"); return { value: name + "(" + pinyin + ")", label: name, }; }); }; const guestList_OnChange = e => { ticket_form.setFieldsValue({ Memo: `${e.target.value}` }); }; //座位类型下拉列表 const seatTableList_select = () => { return ( seatTable && seatTable.map(item => { return { label: `${item.name}`, value: `${item.name}` }; }) ); }; //费用列表 const costListColumns = [ { title: "客人信息/备注", key: "Memo", dataIndex: "Memo", }, { title: "费用类型", key: "CostType", dataIndex: "CostType", }, { title: "车厢", key: "Cabin", dataIndex: "Cabin", render: (text, record) => (record.CostType == "出票" ? text : "-"), }, { title: "座位号", key: "SeatNo", dataIndex: "SeatNo", render: (text, record) => (record.CostType == "出票" ? text : "-"), }, { title: "座位类型", key: "SeatClass", dataIndex: "SeatClass", render: (text, record) => (record.CostType == "出票" ? text : "-"), }, { title: "车票价格", key: "Cost", dataIndex: "Cost", render: (text, record) => (record.CostType == "出票" ? text : "-"), }, { title: "服务费", key: "ServiceFee", dataIndex: "ServiceFee", }, { title: "编辑", key: "CLC_SN", dataIndex: "CLC_SN", render: (text, record) => record.CheckStatus <= 2 ? ( showModal(record)}>编辑 handleDelete(record.CLC_SN)} okText="是" cancelText="否"> ) : ( record.CheckStatusName ), }, ]; const Trainticket_form = trainInfo => { return ( <>
{ postFlightDetail(trainInfo.CLF_SN, trainInfo.GRI_SN, trainInfo.VEI_SN, trainInfo, values) .then(() => { notification.success({ message: `成功`, description: "车票信息保存成功!", placement: "top", duration: 4, icon: , }); }) .catch(() => { notification.error({ message: `错误`, description: "保存失败", placement: "top", duration: 4, icon: , }); }); }} autoComplete="off"> 火车信息 {/* */} - {/* */} 出票信息 { ticketIssuedNotifications(userId, trainInfo.CLF_SN, trainInfo.OPI_SN, values.FlightMemo_messages, values.ticketImages) .then(() => { notification.success({ message: `成功`, description: "提醒信息已发出!", placement: "top", duration: 4, icon: , }); //todo: 在这里情况输入框的内容,还未实现 values.FlightMemo_messages = ""; }) .catch(() => { notification.error({ message: `错误`, description: "提醒失败", placement: "top", duration: 4, icon: , }); }); }} autoComplete="off"> 车票图片 fileList}> 出票完成通知 ); }; const detail_items = () => { return planDetail ? planDetail.map(item => { return { key: item.id, label: `${item.StartDate} ${item.FlightNo}(${item.FromAirport}${item.FlightStart}-${item.ToAirport}${item.FlightEnd})(${item.FlightCabin})`, extra: ( { delete_flight_info(item.CLF_SN); //删除记录 getPlanDetail(travelAgencyId, gri_sn); //更新页面计划详情,含费用列表 }} okText="是" cancelText="否"> ), children: Trainticket_form(item), }; }) : []; }; // 车票信息编辑表单 begin const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen_confirmInfo, setisModalOpen_confirmInfo] = useState(false); const [isTicketType, setisTicketType] = useState(true); const [isAddNew, setisAddNew] = useState(true); //是否是在新增费用信息 const [ticket_form] = Form.useForm(); const [confirmInfo_form] = Form.useForm(); const showModal = ticket => { setIsModalOpen(true); ticket_form.resetFields(); if (isEmpty(ticket.CostType)) ticket.CostType = "出票"; ticket.CostType == "出票" ? setisTicketType(true) : setisTicketType(false); //如果是出票类型,显示票号、折扣等选项 const isNew = isEmpty(ticket.CLC_SN); // 判断是否为新增状态 setisAddNew(isNew); if (isNew) { ticket.ServiceFee = "60"; // // 新增时设置服务费默认值为60 } ticket_form.setFieldsValue(ticket); if (isEmpty(ticket.Memo)) ticket_form.setFieldsValue({ Memo: "" }); }; const handleOk = (close_modal = true) => { ticket_form .validateFields() .then(values => { // 在这里处理表单提交逻辑,例如发送数据到服务器 postFlightCost(values) .then(() => { notification.success({ message: `成功`, description: "保存成功!", placement: "top", duration: 4, icon: , }); getPlanDetail(travelAgencyId, gri_sn); }) .catch(() => { notification.error({ message: `错误`, description: "保存失败", placement: "top", duration: 4, icon: , }); }); if (close_modal) setIsModalOpen(false); }) .catch(info => { console.log("Validate Failed:", info); }); }; const handleCancel = () => { ticket_form.resetFields(); setIsModalOpen(false); }; const handleDelete = CLC_SN => { deleteFlightCost(CLC_SN) .then(() => { getPlanDetail(travelAgencyId, gri_sn); }) .catch(() => { notification.error({ message: `错误`, description: "删除失败", placement: "top", duration: 4, icon: , }); }); }; const onChangeType = value => { if (value == "出票") { setisTicketType(true); } else { setisTicketType(false); } }; //变更确认表单 const showModal_confirmInfo = ConfirmInfo => { setisModalOpen_confirmInfo(true); confirmInfo_form.setFieldsValue({ ConfirmInfo: ConfirmInfo }); }; const handleCancel_confirmInfo = () => { setisModalOpen_confirmInfo(false); confirmInfo_form.resetFields(); }; const handleOk_confirmInfo = () => { confirmInfo_form .validateFields() .then(values => { //console.log("Received values of form: ", values.ConfirmInfo); postVeiFlightPlanConfirm(travelAgencyId, gri_sn, userId, values.ConfirmInfo) .then(() => { notification.success({ message: `成功`, description: "保存成功!", placement: "top", duration: 4, icon: , }); getVeiPlanChange(travelAgencyId, gri_sn); }) .catch(() => { notification.error({ message: `错误`, description: "保存失败", placement: "top", duration: 4, icon: , }); }); confirmInfo_form.resetFields(); setisModalOpen_confirmInfo(false); }) .catch(info => { console.log("Validate Failed:", info); }); }; // 车票信息编辑表单 end useEffect(() => { getPlanDetail(travelAgencyId, gri_sn); //计划详情,含费用列表 getGuestList(coli_sn); //客人列表 getVeiPlanChange(travelAgencyId, gri_sn); //计划变更信息 }, []); return ( {planDetail ? `${planDetail[0].GRI_No} - ${planDetail[0].WL}` : ""}

{ const startDate = planDetail && planDetail.length > 0 && planDetail[planDetail.length - 1].StartDate ? planDetail[planDetail.length - 1].StartDate : ""; await postFlightDetail("", gri_sn, travelAgencyId, { FlightNo: "新的记录", FlightStatus: 1, ServiceType: 2 }, { StartDate: startDate }); //新增加一条记录 getPlanDetail(travelAgencyId, gri_sn); //计划详情,含费用列表 }} okText="是" cancelText="否">

计划变更
( <> {isAddNew ? ( <> {" "} ) : ( )} )}>
({ value: `${String(index + 1).padStart(2, "0")}车`, label: `${String(index + 1).padStart(2, "0")}车`, }))} /> )} {isTicketType && ( <> guestList_OnChange(e)} style={{ minWidth: 320, }}> ( {item.label} )}> {/*
); }; export default TrainticketPlan;