|
|
@ -1,5 +1,5 @@ |
|
|
|
/* eslint-disable array-callback-return */ |
|
|
|
import { Button, Form, Input, message, Select, InputNumber, Cascader, Row, Col } from "antd"; |
|
|
|
import { Button, Form, Input, message, Select, InputNumber, Cascader, Row, Col, Spin } from "antd"; |
|
|
|
import { useEffect, useRef, useState } from "react"; |
|
|
|
import { useNavigate } from "react-router"; |
|
|
|
import { getDetailList, saveMeasurement_new } from "../../../services/measure/analysis"; |
|
|
@ -44,13 +44,15 @@ export default function MeasureConfig() { |
|
|
|
const [unitType, setUnitType] = useState<number>() |
|
|
|
const inputRef = useRef<InputRef>(null); |
|
|
|
const systemState = useAppSelector((store) => store.systemState); |
|
|
|
const [currentDate, setCurrentDate] = useState<string>() |
|
|
|
|
|
|
|
const [kilMet, setKilMet] = useState<Record<string, any>>({}) |
|
|
|
const [loading, setLoading] = useState(false) |
|
|
|
useEffect(()=>{ |
|
|
|
showLastForm() |
|
|
|
queryDictionaryList() |
|
|
|
resetRailTypes() |
|
|
|
resetDataSource() |
|
|
|
queryRailData() |
|
|
|
// queryRailData()
|
|
|
|
console.log('systemState.orgInfo---', systemState.orgInfo) |
|
|
|
setTimeout(() => { |
|
|
|
if(inputRef.current){ |
|
|
|
inputRef.current.focus() |
|
|
@ -60,53 +62,50 @@ export default function MeasureConfig() { |
|
|
|
|
|
|
|
|
|
|
|
//获取铁路局数据
|
|
|
|
function queryRailData(){ |
|
|
|
getOrgListService().then((res) => { |
|
|
|
if (res && res.data) { |
|
|
|
let resData: OrgItem[] = res.data; |
|
|
|
let data = convertToCascaderData(resData) |
|
|
|
setKTJOrgList(data) |
|
|
|
// 使用上次保存时的参数。
|
|
|
|
showLastForm() |
|
|
|
} |
|
|
|
}).catch((e) => {}); |
|
|
|
} |
|
|
|
// function queryRailData(){
|
|
|
|
// getOrgListService().then((res) => {
|
|
|
|
// if (res && res.data) {
|
|
|
|
// let resData: OrgItem[] = res.data;
|
|
|
|
// let data = convertToCascaderData(resData)
|
|
|
|
// setKTJOrgList(data)
|
|
|
|
// // 使用上次保存时的参数。
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }).catch((e) => {});
|
|
|
|
// }
|
|
|
|
|
|
|
|
function showLastForm () { |
|
|
|
const measureForm = localStorage.getItem('measureForm') |
|
|
|
let mfInfo: any = {} |
|
|
|
if(!measureForm) { |
|
|
|
// 获取记录中的第一条数据
|
|
|
|
const params = { |
|
|
|
pageSize: 1, |
|
|
|
pageNum: 5, |
|
|
|
} |
|
|
|
getDetailList(params).then(res => { |
|
|
|
if(res.success){ |
|
|
|
const list = res.data.list |
|
|
|
if(list && list.length){ |
|
|
|
mfInfo = list[0] |
|
|
|
setForm(mfInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}else { |
|
|
|
mfInfo = JSON.parse(measureForm) |
|
|
|
setForm(mfInfo) |
|
|
|
const params = { |
|
|
|
pageSize: 5, |
|
|
|
pageNum: 1, |
|
|
|
} |
|
|
|
setLoading(true) |
|
|
|
getDetailList(params).then(res => { |
|
|
|
if(res.success){ |
|
|
|
const list = res.data.list |
|
|
|
if(list && list.length){ |
|
|
|
mfInfo = list[0] |
|
|
|
setForm(mfInfo) |
|
|
|
}else{ |
|
|
|
setForm({}) |
|
|
|
} |
|
|
|
} |
|
|
|
setLoading(false) |
|
|
|
}).catch( ()=> { |
|
|
|
setLoading(false) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const getDate = () => { |
|
|
|
const currentDate = new Date(); // 获取当前时间
|
|
|
|
|
|
|
|
const year = currentDate.getFullYear(); // 获取完整的年份
|
|
|
|
let month: string | number = currentDate.getMonth() + 1; // 获取月份(0-11),需要加1
|
|
|
|
let day: string | number = currentDate.getDate(); // 获取日
|
|
|
|
month = month < 10 ? "0" + month : month |
|
|
|
day = day < 10 ? "0" + day : day |
|
|
|
const currentTime = `${year}-${month}-${day}` |
|
|
|
console.log('------------currentTime------------------', currentTime) |
|
|
|
setCurrentDate(currentTime) |
|
|
|
let now = `${year}${month}${day}` |
|
|
|
return { |
|
|
|
now, |
|
|
@ -123,30 +122,37 @@ export default function MeasureConfig() { |
|
|
|
} |
|
|
|
const ymd = getDate(); |
|
|
|
const createTime = mfInfo.createTime |
|
|
|
let todayNumber = mfInfo.todayNumber |
|
|
|
if(createTime.indexOf(ymd.nowfm) === -1 ){ |
|
|
|
let todayNumber = mfInfo.todayNumber || 0 |
|
|
|
if(createTime && createTime.indexOf(ymd.nowfm) === -1 ){ |
|
|
|
todayNumber = 0 |
|
|
|
} |
|
|
|
let orgInfo = systemState.orgInfo; |
|
|
|
let labels: string[] = [] |
|
|
|
let orgCode: string[] = [] |
|
|
|
if(orgInfo && orgInfo.value){ |
|
|
|
const orgValue = JSON.parse(orgInfo.value) |
|
|
|
orgValue && orgValue.forEach((org: OrgOptions) => { |
|
|
|
console.log('label===', org.label) |
|
|
|
labels.push(org.label) |
|
|
|
orgCode.push(org.value) |
|
|
|
}) |
|
|
|
} |
|
|
|
let label = labels.join('-') |
|
|
|
let name = `${label}-${ymd.now}${(Number(todayNumber) + 1).toString().padStart(4, '0') }` |
|
|
|
|
|
|
|
setKilMet({ |
|
|
|
kilometre, |
|
|
|
meters |
|
|
|
}) |
|
|
|
const user = localStorage.getItem("user"); |
|
|
|
let userData = JSON.parse(user || ""); |
|
|
|
form.setFieldsValue({ |
|
|
|
...mfInfo, |
|
|
|
orgValues: [mfInfo.tljCode, mfInfo.gwdCode, mfInfo.xmCode], |
|
|
|
orgValues: orgCode, |
|
|
|
kilometre, |
|
|
|
meters, |
|
|
|
name, |
|
|
|
operator: userData.nickname || userData.account |
|
|
|
}); |
|
|
|
const railList = [mfInfo.tljCode, mfInfo.gwdCode, mfInfo.xmCode] |
|
|
|
const railList = orgCode |
|
|
|
setOrgValues(railList) |
|
|
|
getStationData(railList) |
|
|
|
setDataSource(mfInfo.dataSource) |
|
|
@ -206,9 +212,17 @@ export default function MeasureConfig() { |
|
|
|
|
|
|
|
//车站数据
|
|
|
|
const getStationData = (railData: string[]) => { |
|
|
|
let tljCode = railData[0] |
|
|
|
let gwdCode = railData[1] |
|
|
|
let xmCode = railData[2] |
|
|
|
let orgInfo = systemState.orgInfo; |
|
|
|
let orgCode: string[] = [] |
|
|
|
if(orgInfo && orgInfo.value){ |
|
|
|
const orgValue = JSON.parse(orgInfo.value) |
|
|
|
orgValue && orgValue.forEach((org: OrgOptions) => { |
|
|
|
orgCode.push(org.value) |
|
|
|
}) |
|
|
|
} |
|
|
|
let tljCode = orgCode[0] |
|
|
|
let gwdCode = orgCode[1] |
|
|
|
let xmCode = orgCode[2] |
|
|
|
const params = { |
|
|
|
tljCode, |
|
|
|
gwdCode, |
|
|
@ -311,15 +325,22 @@ export default function MeasureConfig() { |
|
|
|
} |
|
|
|
console.log('values--11-', values) |
|
|
|
|
|
|
|
|
|
|
|
let orgInfo = systemState.orgInfo; |
|
|
|
let orgCode: string[] = [] |
|
|
|
if(orgInfo && orgInfo.value){ |
|
|
|
const orgValue = JSON.parse(orgInfo.value) |
|
|
|
orgValue && orgValue.forEach((org: OrgOptions) => { |
|
|
|
orgCode.push(org.value) |
|
|
|
}) |
|
|
|
} |
|
|
|
const params = { |
|
|
|
operator: values["operator"],//操作员
|
|
|
|
name: values["name"],//测量名称
|
|
|
|
location: values["location"],//位置
|
|
|
|
direction: values["direction"],//方向
|
|
|
|
tljCode: values["tljCode"],//铁路局
|
|
|
|
gwdCode: values["gwdCode"],//铁路段
|
|
|
|
xmCode: values["xmCode"],//铁路线
|
|
|
|
tljCode: orgCode[0],//values["tljCode"],//铁路局
|
|
|
|
gwdCode: orgCode[1],//values["gwdCode"],//铁路段
|
|
|
|
xmCode: orgCode[2],//values["xmCode"],//铁路线
|
|
|
|
lineClassify: values["lineClassify"],//线路分类
|
|
|
|
dataType: values["dataType"],//采集方式
|
|
|
|
dataSource: values["dataSource"],//数据来源
|
|
|
@ -355,6 +376,7 @@ export default function MeasureConfig() { |
|
|
|
params.alignPoints = measureData |
|
|
|
} |
|
|
|
localStorage.setItem('measureForm', JSON.stringify(params)) |
|
|
|
console.log('params---', params) |
|
|
|
saveMeasurement_new(params) |
|
|
|
.then((res) => { |
|
|
|
if (res.success) { |
|
|
@ -374,8 +396,8 @@ export default function MeasureConfig() { |
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
|
<div> |
|
|
|
<Spin spinning={loading}> |
|
|
|
<div > |
|
|
|
<Form |
|
|
|
form={form} |
|
|
|
size="large" |
|
|
@ -386,11 +408,13 @@ export default function MeasureConfig() { |
|
|
|
> |
|
|
|
<div style={{marginTop: '1rem', display:'grid', gridTemplateColumns: '1fr 1fr 1fr'}}> |
|
|
|
<Form.Item |
|
|
|
labelCol={{span: 3}} |
|
|
|
style={{marginLeft:'-1rem'}} |
|
|
|
label={resetLabel('测量名称')} |
|
|
|
name="name" |
|
|
|
rules={[{ required: true, message: "请输入测量名称" }]} |
|
|
|
> |
|
|
|
<Input ref={inputRef} style={{width: '30rem'}} className="label-vh" placeholder="请输入测量名称" /> |
|
|
|
<Input ref={inputRef} style={{width: '71vw'}} className="label-vh" placeholder="请输入测量名称" /> |
|
|
|
</Form.Item> |
|
|
|
</div> |
|
|
|
|
|
|
@ -400,7 +424,7 @@ export default function MeasureConfig() { |
|
|
|
name="operator" |
|
|
|
rules={[{ required: true, message: "请输入操作员姓名" }]} |
|
|
|
> |
|
|
|
<Input className="label-vh"/> |
|
|
|
<Input className="label-vh w-[18vw]"/> |
|
|
|
</Form.Item> |
|
|
|
{/* <Form.Item |
|
|
|
label={resetLabel('铁路局')} |
|
|
@ -440,14 +464,14 @@ export default function MeasureConfig() { |
|
|
|
}))} |
|
|
|
></Select> |
|
|
|
</Form.Item> |
|
|
|
|
|
|
|
<Form.Item |
|
|
|
{stationList && <Form.Item |
|
|
|
label={resetLabel('车站')} |
|
|
|
name="stationCode" |
|
|
|
rules={[{ required: true, message: "请选择车站" }]} |
|
|
|
> |
|
|
|
<Select |
|
|
|
className="label-vh" |
|
|
|
style={{width: '18vw'}} |
|
|
|
placeholder="请选择车站" |
|
|
|
onChange={onSatioinChange} |
|
|
|
options={stationList.map((item) => ({ |
|
|
@ -456,7 +480,8 @@ export default function MeasureConfig() { |
|
|
|
}))} |
|
|
|
> |
|
|
|
</Select> |
|
|
|
</Form.Item> |
|
|
|
</Form.Item>} |
|
|
|
|
|
|
|
|
|
|
|
<Form.Item |
|
|
|
label={resetLabel('线路分类')} |
|
|
@ -493,7 +518,7 @@ export default function MeasureConfig() { |
|
|
|
name="batch" |
|
|
|
rules={[{ required: true, message: "请输入批次" }]} |
|
|
|
> |
|
|
|
<Input className="label-vh" placeholder="请输入批次" /> |
|
|
|
<InputNumber className="label-vh w-[18vw]" placeholder="请输入批次" /> |
|
|
|
</Form.Item> |
|
|
|
{dataSource === 'DCDC' ? ( |
|
|
|
<> |
|
|
@ -548,17 +573,16 @@ export default function MeasureConfig() { |
|
|
|
rules={[{ required: true, message: "请输入" }]} |
|
|
|
> |
|
|
|
<div style={{display:"flex",alignItems:"center"}}> |
|
|
|
<InputNumber className="label-vh w-[18vw]" placeholder="公里" />千米 |
|
|
|
<InputNumber className="label-vh w-[16vw]" defaultValue={kilMet.kilometre} placeholder="公里" />千米 |
|
|
|
</div> |
|
|
|
</Form.Item> |
|
|
|
|
|
|
|
<Form.Item |
|
|
|
label={resetLabel('百米')} |
|
|
|
name="meters" |
|
|
|
rules={[{ required: true, message: "请输入" }]} |
|
|
|
> |
|
|
|
<div style={{display:"flex",alignItems:"center"}}> |
|
|
|
<InputNumber className="label-vh w-[18vw]" placeholder="百米" />米 |
|
|
|
<InputNumber className="label-vh w-[18vw]" defaultValue={kilMet.meters} placeholder="百米" />米 |
|
|
|
</div> |
|
|
|
</Form.Item> |
|
|
|
</> |
|
|
@ -601,6 +625,6 @@ export default function MeasureConfig() { |
|
|
|
</div> |
|
|
|
</Form> |
|
|
|
</div> |
|
|
|
</> |
|
|
|
</Spin> |
|
|
|
); |
|
|
|
} |