|
|
@@ -3,13 +3,12 @@ |
|
|
|
// agv线路数据页面 |
|
|
|
import type { ActionType, ProColumns } from '@ant-design/pro-components'; |
|
|
|
import { ProTable } from '@ant-design/pro-components'; |
|
|
|
import { Button, Modal, Form, Input, message, Popconfirm, Tag, QRCode, Table } from 'antd'; |
|
|
|
import { Button, Modal, Form, Input, message, Popconfirm, Tag } from 'antd'; |
|
|
|
import { useEffect, useRef, useState } from 'react'; |
|
|
|
import type { ColumnsType } from 'antd/es/table'; |
|
|
|
import agvlineInfoAPI from '@/api/agvlineService' |
|
|
|
import agvbasicInfoAPI from '@/api/agvbasicService'; |
|
|
|
import Select from 'antd/lib/select'; |
|
|
|
import { render } from 'react-dom'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -24,7 +23,7 @@ const Agvline = () => { |
|
|
|
// 起始点位状态 |
|
|
|
const [startoptin, setstartoptin] = useState<MySelectType.Select[]>([]) |
|
|
|
// 结束点位状态 |
|
|
|
const [endoption,setendoption] = useState<MySelectType.Select[]>([]) |
|
|
|
const [endoption, setendoption] = useState<MySelectType.Select[]>([]) |
|
|
|
const actionRef = useRef<ActionType>(); |
|
|
|
// 1.定义列 |
|
|
|
|
|
|
@@ -44,7 +43,7 @@ const Agvline = () => { |
|
|
|
ellipsis: true, |
|
|
|
align: 'center' |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
title: '起始点位', |
|
|
|
dataIndex: 'startPointId', |
|
|
@@ -54,6 +53,7 @@ const Agvline = () => { |
|
|
|
render:(_,record)=>{ |
|
|
|
return <>{ startoptin.find(x=>x.key === record.startPointId)?.label}</> |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '结束点位', |
|
|
@@ -62,8 +62,8 @@ const Agvline = () => { |
|
|
|
ellipsis: true, |
|
|
|
align: 'center', |
|
|
|
render:(_,record)=>{ |
|
|
|
return <>{ endoption.find(x=>x.key === record.endPointId)?.label}</> |
|
|
|
} |
|
|
|
return <>{endoption.find(x=>x.key === record.endPointId)?.label}</> |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '业务描述', |
|
|
@@ -79,15 +79,12 @@ const Agvline = () => { |
|
|
|
align: 'center', |
|
|
|
// 4.操作内有两个按钮 |
|
|
|
render: (_, record) => [ |
|
|
|
|
|
|
|
<Button |
|
|
|
key="edit" |
|
|
|
type="primary" ghost |
|
|
|
onClick={async () => { |
|
|
|
|
|
|
|
setIsModalOpen(true); |
|
|
|
setModelTitle('编辑分组'); |
|
|
|
|
|
|
|
setModelTitle('编辑线路'); |
|
|
|
const copyFormData = JSON.parse(JSON.stringify(record)); |
|
|
|
typeForm.setFieldsValue(copyFormData); |
|
|
|
}} |
|
|
@@ -99,17 +96,19 @@ const Agvline = () => { |
|
|
|
key="del" |
|
|
|
title="确定要删除此条数据吗?" |
|
|
|
onConfirm={() => { |
|
|
|
|
|
|
|
const EnablejsonData: AgvlineInfoTypes.Info = { |
|
|
|
id: record.id, |
|
|
|
name: '', |
|
|
|
code: '' |
|
|
|
code: '', |
|
|
|
endPointId: '', |
|
|
|
startPointId: '', |
|
|
|
description: '' |
|
|
|
}; |
|
|
|
|
|
|
|
agvlineInfoAPI.Del(EnablejsonData).then((r: MyResponse.Content) => { |
|
|
|
agvlineInfoAPI.Del(EnablejsonData).then((r:MyResponse.Content) => { |
|
|
|
if (r.statusCode === 200) { |
|
|
|
message.success(r.statusCode === 200 ? '删除成功' : r.message); |
|
|
|
actionRef.current?.reload(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}} |
|
|
@@ -120,7 +119,6 @@ const Agvline = () => { |
|
|
|
cancelText="关闭" |
|
|
|
> |
|
|
|
<Button type="primary" danger ghost>删除</Button> |
|
|
|
|
|
|
|
</Popconfirm>, |
|
|
|
] |
|
|
|
|
|
|
@@ -129,67 +127,58 @@ const Agvline = () => { |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
const startList = async () => { |
|
|
|
const data = await agvbasicInfoAPI.selectlist() |
|
|
|
// console.log('data',data); |
|
|
|
const infomation = await agvbasicInfoAPI.selectlist() |
|
|
|
console.log('dinfomation', infomation); |
|
|
|
// data就是点位 |
|
|
|
// eslint-disable-next-line array-callback-return |
|
|
|
data.data.map((item: { label: any; value: any; key: any; })=>{ |
|
|
|
infomation.data.map((item: { label: any; value: any; key: any; })=>{ |
|
|
|
// console.log('222',item.label); |
|
|
|
item.label = item.value |
|
|
|
// item.value = item.key |
|
|
|
}) |
|
|
|
setstartoptin(data.data) |
|
|
|
|
|
|
|
// eslint-disable-next-line array-callback-return |
|
|
|
setstartoptin(infomation.data) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
startList() |
|
|
|
|
|
|
|
const endList = async()=>{ |
|
|
|
const data1 = await agvbasicInfoAPI.selectlist() |
|
|
|
// console.log(data1); |
|
|
|
|
|
|
|
// eslint-disable-next-line array-callback-return |
|
|
|
data1.data.map((item: { label: any; value: any; key: any; })=>{ |
|
|
|
item.label = item.value |
|
|
|
// item.value = item.key |
|
|
|
const endList = async () => { |
|
|
|
const infomation1 = await agvbasicInfoAPI.selectlist() |
|
|
|
console.log('infomation1',infomation1); |
|
|
|
// eslint-disable-next-line array-callback-return, @typescript-eslint/no-unused-vars |
|
|
|
infomation1.data.map((item:{ label: any; value: any; key: any; })=>{ |
|
|
|
// console.log(item,'222'); |
|
|
|
item.label = item.value |
|
|
|
}) |
|
|
|
setendoption(data1.data) |
|
|
|
|
|
|
|
setendoption(infomation1.data) |
|
|
|
} |
|
|
|
endList() |
|
|
|
}, []); |
|
|
|
|
|
|
|
// 7.定义表单提交 |
|
|
|
// 表单提交 |
|
|
|
const OnSubmit = async (values: AgvlineInfoTypes.Info) => { |
|
|
|
console.log(values); |
|
|
|
if (values.id) { |
|
|
|
|
|
|
|
|
|
|
|
const response = await agvlineInfoAPI.Update(values); |
|
|
|
if (response.statusCode === 200) { |
|
|
|
message.success('修改成功'); |
|
|
|
actionRef.current?.reload(); |
|
|
|
setIsModalOpen(false); |
|
|
|
} else { |
|
|
|
message.error(JSON.stringify(response.errors) || '修改失败'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 让code默认为空 |
|
|
|
values.code = ''; |
|
|
|
const response = await agvlineInfoAPI.Add(values); |
|
|
|
|
|
|
|
|
|
|
|
actionRef.current?.reload() |
|
|
|
if (response.statusCode === 200) { |
|
|
|
message.success('添加成功'); |
|
|
|
actionRef.current?.reload() |
|
|
|
setIsModalOpen(false); |
|
|
|
} else { |
|
|
|
message.error(JSON.stringify(response.errors) || '添加失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
// 7.定义表单提交 |
|
|
|
// 表单提交 |
|
|
|
const OnSubmit = async (values: AgvlineInfoTypes.Info) => { |
|
|
|
console.log(values); |
|
|
|
if (values.id) { |
|
|
|
const response = await agvlineInfoAPI.Update(values); |
|
|
|
if (response.statusCode === 200) { |
|
|
|
message.success('修改成功'); |
|
|
|
actionRef.current?.reload(); |
|
|
|
setIsModalOpen(false); |
|
|
|
} else { |
|
|
|
message.error(JSON.stringify(response.errors) || '修改失败'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 让code默认为空 |
|
|
|
values.code = ''; |
|
|
|
const response = await agvlineInfoAPI.Add(values); |
|
|
|
actionRef.current?.reload() |
|
|
|
if (response.statusCode === 200) { |
|
|
|
message.success('添加成功'); |
|
|
|
actionRef.current?.reload() |
|
|
|
setIsModalOpen(false); |
|
|
|
} else { |
|
|
|
message.error(JSON.stringify(response.errors) || '添加失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<ProTable<AgvlineInfoTypes.Info> |
|
|
@@ -199,8 +188,7 @@ const Agvline = () => { |
|
|
|
pageIndex: params.current || 1, |
|
|
|
pageSize: params.pageSize || 10, |
|
|
|
name: params.name || '', |
|
|
|
|
|
|
|
code: '' |
|
|
|
code: '' |
|
|
|
}; |
|
|
|
const response = await agvlineInfoAPI.PagedList(jsonData); |
|
|
|
if (response.statusCode === 200) { |
|
|
@@ -250,6 +238,7 @@ const Agvline = () => { |
|
|
|
onCancel={() => { |
|
|
|
setIsModalOpen(false); |
|
|
|
}} |
|
|
|
|
|
|
|
footer={[ |
|
|
|
<Button |
|
|
|
key="back" |
|
|
@@ -268,7 +257,7 @@ const Agvline = () => { |
|
|
|
{/* 弹窗内的表单 */} |
|
|
|
<Form |
|
|
|
form={typeForm} |
|
|
|
name="basic" |
|
|
|
name="line" |
|
|
|
id="agvlineForm" |
|
|
|
labelAlign='right' |
|
|
|
// lCol={{ span: 4 }} |
|
|
@@ -291,34 +280,30 @@ const Agvline = () => { |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item label="起始点位" name="startPointId" rules={[{ required: true, message: '此项为必填项!' }]} > |
|
|
|
<Select placeholder='请选择起始点位' style={{ width: 375 }}> |
|
|
|
{ |
|
|
|
startoptin.map((item:MySelectType.Select) =>{ |
|
|
|
return <Select.Option value={item.key} key={item.key}> |
|
|
|
<span>{item.value}</span> |
|
|
|
</Select.Option> |
|
|
|
}) |
|
|
|
} |
|
|
|
</Select> |
|
|
|
<Select placeholder='请选择起始点位' style={{ width: 375 }}> |
|
|
|
{ |
|
|
|
startoptin.map((item: MySelectType.Select) => { |
|
|
|
return <Select.Option value={item.key} key={item.key}> |
|
|
|
<span>{item.value}</span> |
|
|
|
</Select.Option> |
|
|
|
}) |
|
|
|
} |
|
|
|
</Select> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item label="结束点位" name="endPointId" rules={[{ required: true, message: '此项为必填项!' }]} > |
|
|
|
<Select placeholder='请选择起始点位' style={{ width: 375 }}> |
|
|
|
{ |
|
|
|
endoption.map((item:MySelectType.Select) =>{ |
|
|
|
return <Select.Option value={item.key} key={item.key}> |
|
|
|
<span>{item.value}</span> |
|
|
|
</Select.Option> |
|
|
|
}) |
|
|
|
} |
|
|
|
</Select> |
|
|
|
<Select placeholder='请选择起始点位' style={{ width: 375 }}> |
|
|
|
{ |
|
|
|
endoption.map((item: MySelectType.Select) => { |
|
|
|
return <Select.Option value={item.key} key={item.key}> |
|
|
|
<span>{item.value}</span> |
|
|
|
</Select.Option> |
|
|
|
}) |
|
|
|
} |
|
|
|
</Select> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item label="点位描述" name="description" rules={[{ required: true, message: '此项为必填项!' }]} > |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</Form> |
|
|
|
</Modal> |
|
|
|
|
|
|
|