|
|
@@ -1,6 +1,6 @@
|
|
|
-import {Modal, Form, Select, message, InputNumber, TimePicker, Input} from 'antd';
|
|
|
+import {Form, Input, InputNumber, message, Modal, Select, TimePicker} from 'antd';
|
|
|
import axios from '@/utils/axios.js'
|
|
|
-import {useEffect, useState} from 'react'
|
|
|
+import {useEffect} from 'react'
|
|
|
import './modal.scss'
|
|
|
import dayjs from "dayjs";
|
|
|
import customParseFormat from 'dayjs/plugin/customParseFormat'
|
|
|
@@ -45,9 +45,43 @@ export default function ModalHooks({isModalOpen, closeModal, row, lineList, opti
|
|
|
closeModal(false);
|
|
|
form.resetFields()
|
|
|
};
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找线路的开始和结束
|
|
|
+ * @param id
|
|
|
+ * @param list
|
|
|
+ */
|
|
|
+ function setStartAndEnd(id, list) {
|
|
|
+ let row = list.find(item => {
|
|
|
+ return item.lineId === id
|
|
|
+ })
|
|
|
+ let modelStationList = row.lineModeList[0].modeStationsList
|
|
|
+ // 正向起始
|
|
|
+ let forwardStart = modelStationList.find(item => item.direction === 1)
|
|
|
+ form.setFieldValue('upStartStation', forwardStart.stationName)
|
|
|
+ // 反向起始
|
|
|
+ let reverseStart = modelStationList.find(item => item.direction === 2)
|
|
|
+ form.setFieldValue('downStartStation', reverseStart.stationName)
|
|
|
+ modelStationList.reverse()
|
|
|
+ // 正向结束
|
|
|
+ let forwardEnd = modelStationList.find(item => item.direction === 1)
|
|
|
+ form.setFieldValue('upEndStation', forwardEnd.stationName)
|
|
|
+ // 反向结束
|
|
|
+ let reverseEnd = modelStationList.find(item => item.direction === 2)
|
|
|
+ form.setFieldValue('downEndStation', reverseEnd.stationName)
|
|
|
+ // formData.upStartStation = modelStationList[0].stationName
|
|
|
+ // 下面根据各个表格不同变换
|
|
|
+ // formData.downEndTime = dayjs(formData.downEndTime, 'HH:mm')
|
|
|
+ // console.log(row.lineModeList[0].modeStationsList)
|
|
|
+ }
|
|
|
+
|
|
|
// 表单
|
|
|
useEffect(() => {
|
|
|
form.setFieldValue('lineId', val)
|
|
|
+ if (val && !row.id) {
|
|
|
+
|
|
|
+ setStartAndEnd(val, lineList)
|
|
|
+ }
|
|
|
if (row.id) {
|
|
|
dayjs.extend(customParseFormat)
|
|
|
let formData = JSON.parse(JSON.stringify(row))
|
|
|
@@ -156,7 +190,6 @@ export default function ModalHooks({isModalOpen, closeModal, row, lineList, opti
|
|
|
{
|
|
|
required: true,
|
|
|
message: '请输入',
|
|
|
-
|
|
|
},
|
|
|
]}
|
|
|
>
|
|
|
@@ -187,6 +220,7 @@ export default function ModalHooks({isModalOpen, closeModal, row, lineList, opti
|
|
|
>
|
|
|
<TimePicker format={'HH:mm'} style={{width: '100%'}}></TimePicker>
|
|
|
</Form.Item>
|
|
|
+
|
|
|
<Form.Item
|
|
|
label="上行结束时间"
|
|
|
name="upEndTime"
|