|
|
@@ -5,85 +5,115 @@ |
|
|
|
*/ |
|
|
|
import type { ActionType, ProColumns } from '@ant-design/pro-components'; |
|
|
|
import { ProTable } from '@ant-design/pro-components'; |
|
|
|
import { Button, Modal, Form, Input, message, Popconfirm, Transfer, Tag, Col } from 'antd'; |
|
|
|
import { useRef, useState, useEffect } from 'react'; |
|
|
|
import { history } from '@umijs/max'; |
|
|
|
import { Button, Modal, Form, Input, message, Popconfirm, Tag } from 'antd'; |
|
|
|
import { useRef, useState,useEffect } from 'react'; |
|
|
|
// import { history } from '@umijs/max'; |
|
|
|
import DeviceInfoAPI from '@/api/DeviceInfo'; |
|
|
|
import RecipeAPI from '@/api/recipeService' |
|
|
|
import { TransferDirection } from 'antd/es/transfer'; |
|
|
|
// import RecipeAPI from '@/api/recipeService' |
|
|
|
// import { TransferDirection } from 'antd/es/transfer'; |
|
|
|
|
|
|
|
|
|
|
|
interface RecordType { |
|
|
|
key: string; |
|
|
|
title: string; |
|
|
|
description: string; |
|
|
|
chosen: boolean; |
|
|
|
} |
|
|
|
let selectRecordId :string; |
|
|
|
// interface RecordType { |
|
|
|
// key: string; |
|
|
|
// title: string; |
|
|
|
// description: string; |
|
|
|
// chosen: boolean; |
|
|
|
// } |
|
|
|
// let selectRecordId :string; |
|
|
|
export default () => { |
|
|
|
//表单 |
|
|
|
const [typeForm] = Form.useForm(); |
|
|
|
//穿梭框数据 |
|
|
|
const [materialData,setMaterialData] = useState<RecordType[]>(); |
|
|
|
// const [materialData,setMaterialData] = useState<RecordType[]>(); |
|
|
|
//穿梭框选择数据 |
|
|
|
const [targetKeys,setTargetKeys] = useState<string[]>(); |
|
|
|
|
|
|
|
const filterOption = (inputValue: string, option: RecordType) => |
|
|
|
option.description.indexOf(inputValue) > -1; |
|
|
|
// const [targetKeys,setTargetKeys] = useState<string[]>(); |
|
|
|
// const filterOption = (inputValue: string, option: RecordType) => |
|
|
|
// option.description.indexOf(inputValue) > -1; |
|
|
|
|
|
|
|
const handleChange = (newTargetKeys: string[]) => { |
|
|
|
setTargetKeys(newTargetKeys); |
|
|
|
}; |
|
|
|
// const handleChange = (newTargetKeys: string[]) => { |
|
|
|
// setTargetKeys(newTargetKeys); |
|
|
|
// }; |
|
|
|
|
|
|
|
const handleSearch = (dir: TransferDirection, value: string) => { |
|
|
|
console.log('search:', dir, value); |
|
|
|
}; |
|
|
|
const GetTransferData = (record: DeviceTypes.Info) => { |
|
|
|
const tempTargetKeys:any[] = []; |
|
|
|
const tempMockData:any[] = []; |
|
|
|
|
|
|
|
//获取所有配方 |
|
|
|
RecipeAPI.List().then((item:MyResponse.Content)=>{ |
|
|
|
if (item.statusCode===200) { |
|
|
|
item.data.forEach((res:MaterialsTypes.MaterialsInfo)=>{ |
|
|
|
const data = { |
|
|
|
key: res.id, |
|
|
|
title:res.name, |
|
|
|
description: res.name, |
|
|
|
}; |
|
|
|
tempMockData.push(data); |
|
|
|
}); |
|
|
|
setMaterialData(tempMockData); |
|
|
|
} |
|
|
|
}).then(()=>{ |
|
|
|
DeviceInfoAPI.RecipeList(record.id).then((res:MyResponse.Content)=>{ |
|
|
|
if (res.statusCode===200) { |
|
|
|
res.data.forEach((item:any)=>{ |
|
|
|
tempTargetKeys.push(item.recipesId) |
|
|
|
} |
|
|
|
) |
|
|
|
setTargetKeys(tempTargetKeys); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
// const handleSearch = (dir: TransferDirection, value: string) => { |
|
|
|
// console.log('search:', dir, value); |
|
|
|
// }; |
|
|
|
// const GetTransferData = (record: DeviceTypes.Info) => { |
|
|
|
// const tempTargetKeys:any[] = []; |
|
|
|
// const tempMockData:any[] = []; |
|
|
|
|
|
|
|
// //获取所有配方 |
|
|
|
// RecipeAPI.List().then((item:MyResponse.Content)=>{ |
|
|
|
// if (item.statusCode===200) { |
|
|
|
// item.data.forEach((res:MaterialsTypes.MaterialsInfo)=>{ |
|
|
|
// const data = { |
|
|
|
// key: res.id, |
|
|
|
// title:res.name, |
|
|
|
// description: res.name, |
|
|
|
// }; |
|
|
|
// tempMockData.push(data); |
|
|
|
// }); |
|
|
|
// setMaterialData(tempMockData); |
|
|
|
// } |
|
|
|
// }).then(()=>{ |
|
|
|
// DeviceInfoAPI.RecipeList(record.id).then((res:MyResponse.Content)=>{ |
|
|
|
// if (res.statusCode===200) { |
|
|
|
// res.data.forEach((item:any)=>{ |
|
|
|
// tempTargetKeys.push(item.recipesId) |
|
|
|
// } |
|
|
|
// ) |
|
|
|
// setTargetKeys(tempTargetKeys); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// }); |
|
|
|
// }; |
|
|
|
//下拉列表 |
|
|
|
const [isMaterialModalOpen, setIsMaterialModalOpen] = useState(false); |
|
|
|
// const [isMaterialModalOpen, setIsMaterialModalOpen] = useState(false); |
|
|
|
const [modelTitle, setModelTitle] = useState<string>(); |
|
|
|
//编辑/新增弹窗 |
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false); |
|
|
|
const actionRef = useRef<ActionType>(); |
|
|
|
const columns: ProColumns<DeviceTypes.Info>[] = [ |
|
|
|
{ |
|
|
|
title: 'id', |
|
|
|
dataIndex: 'id', |
|
|
|
tip: '规则名称是唯一的 key', |
|
|
|
hideInSearch: true, |
|
|
|
hideInTable: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备名称', |
|
|
|
dataIndex: 'name', |
|
|
|
ellipsis: true, |
|
|
|
}, |
|
|
|
// { |
|
|
|
// title: '设备型号', |
|
|
|
// dataIndex: 'code', |
|
|
|
// ellipsis: true, |
|
|
|
// hideInSearch: true, |
|
|
|
// }, |
|
|
|
{ |
|
|
|
title: '设备编码', |
|
|
|
title: '设备编号', |
|
|
|
dataIndex: 'code', |
|
|
|
hideInSearch: true, |
|
|
|
|
|
|
|
ellipsis: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备描述', |
|
|
|
dataIndex: 'des', |
|
|
|
ellipsis: true, |
|
|
|
hideInSearch: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备类型', |
|
|
|
dataIndex: 'type', |
|
|
|
ellipsis: true, |
|
|
|
hideInSearch: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备维保日期', |
|
|
|
dataIndex: 'data', |
|
|
|
ellipsis: true, |
|
|
|
hideInSearch: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
@@ -92,41 +122,55 @@ export default () => { |
|
|
|
render: (_, record) => [ |
|
|
|
<Button |
|
|
|
key="edit" |
|
|
|
type="primary" ghost |
|
|
|
type="primary" ghost |
|
|
|
onClick={async () => { |
|
|
|
setIsModalOpen(true); |
|
|
|
setModelTitle('编辑信息'); |
|
|
|
const copyFormData = JSON.parse(JSON.stringify(record)); |
|
|
|
copyFormData.state = copyFormData.state === '0' ? true : false; |
|
|
|
copyFormData.state = copyFormData.state === '0'; |
|
|
|
typeForm.setFieldsValue(copyFormData); |
|
|
|
}} |
|
|
|
> |
|
|
|
编辑 |
|
|
|
</Button>, |
|
|
|
<Button |
|
|
|
key="xfa" |
|
|
|
type="primary" ghost |
|
|
|
onClick={async () => { |
|
|
|
setIsMaterialModalOpen(true); |
|
|
|
console.log('record',record); |
|
|
|
selectRecordId = record.id |
|
|
|
console.log('record',selectRecordId); |
|
|
|
GetTransferData(record); |
|
|
|
}} |
|
|
|
> |
|
|
|
配方下发 |
|
|
|
</Button>, |
|
|
|
// <Button |
|
|
|
// key="xfa" |
|
|
|
// type="primary" ghost |
|
|
|
// onClick={async () => { |
|
|
|
// setIsMaterialModalOpen(true); |
|
|
|
// console.log('record',record); |
|
|
|
// selectRecordId = record.id |
|
|
|
// console.log('record',selectRecordId); |
|
|
|
// GetTransferData(record); |
|
|
|
// }} |
|
|
|
// > |
|
|
|
// 配方下发 |
|
|
|
// </Button>, |
|
|
|
<Popconfirm |
|
|
|
key="del" |
|
|
|
title="确定要删除此条数据吗?" |
|
|
|
// onConfirm={() => { |
|
|
|
// const delData: MaterialsTypes.MaterialsInfo = { |
|
|
|
// id: record.id, |
|
|
|
// name: '', |
|
|
|
// code: '', |
|
|
|
// unit: '' |
|
|
|
// }; |
|
|
|
// MaterialsInfoAPI.Del(delData).then((r) => { |
|
|
|
// if (r.statusCode === 200) { |
|
|
|
// message.success(r.statusCode === 200 ? '删除成功' : r.message); |
|
|
|
// actionRef.current?.reload(); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// }} |
|
|
|
onConfirm={() => { |
|
|
|
|
|
|
|
|
|
|
|
const EnablejsonData: DeviceTypes.Info = { |
|
|
|
id: record.id, |
|
|
|
name: '', |
|
|
|
code: '' |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
DeviceInfoAPI.Del(EnablejsonData).then((r) => { |
|
|
|
if (r.statusCode === 200) { |
|
|
|
message.success(r.statusCode === 200 ? '删除成功' : r.message); |
|
|
@@ -140,7 +184,7 @@ export default () => { |
|
|
|
okText="确认" |
|
|
|
cancelText="关闭" |
|
|
|
> |
|
|
|
<Button type="primary" danger ghost>删除</Button> |
|
|
|
<Button type="primary" danger ghost>删除</Button> |
|
|
|
</Popconfirm>, |
|
|
|
], |
|
|
|
}, |
|
|
@@ -152,15 +196,15 @@ export default () => { |
|
|
|
useEffect(() => { |
|
|
|
// 下拉列表信息 |
|
|
|
const RegionDataList = () => { |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
RegionDataList(); |
|
|
|
}, []); |
|
|
|
|
|
|
|
/* |
|
|
|
*表单提交 |
|
|
|
*/ |
|
|
|
const OnSubmit = async (values: DeviceTypes.Info) => { |
|
|
|
|
|
|
|
if (values.id) { |
|
|
|
const response = await DeviceInfoAPI.Update(values); |
|
|
|
if (response.statusCode === 200) { |
|
|
@@ -168,7 +212,7 @@ export default () => { |
|
|
|
actionRef.current?.reload(); |
|
|
|
setIsModalOpen(false); |
|
|
|
} else { |
|
|
|
message.error(response.errors || '修改失败'); |
|
|
|
message.error(JSON.stringify(response.errors) || '修改失败'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
const response = await DeviceInfoAPI.Add(values); |
|
|
@@ -178,7 +222,7 @@ export default () => { |
|
|
|
actionRef.current?.reload(); |
|
|
|
setIsModalOpen(false); |
|
|
|
} else { |
|
|
|
message.error(response.errors || '添加失败'); |
|
|
|
message.error(JSON.stringify(response.errors) || '添加失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
@@ -258,7 +302,8 @@ export default () => { |
|
|
|
form={typeForm} |
|
|
|
name="basic" |
|
|
|
id="myForm" |
|
|
|
labelCol={{ span: 4 }} |
|
|
|
|
|
|
|
lCol={{ span: 4 }} |
|
|
|
wrapperCol={{ span: 12 }} |
|
|
|
onFinish={OnSubmit} |
|
|
|
autoComplete="off" |
|
|
@@ -266,6 +311,7 @@ export default () => { |
|
|
|
<Form.Item label="id" name="id" hidden> |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
|
|
|
|
<Form.Item |
|
|
|
label="设备名称" |
|
|
|
name="name" |
|
|
@@ -273,14 +319,28 @@ export default () => { |
|
|
|
> |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item label="设备编码" name="code" rules={[{ required: true, message: '此项为必填项!' }]} > |
|
|
|
<Input /> |
|
|
|
<Form.Item label="设备编号" name="code" rules={[{ required: true, message: '此项为必填项!' }]} > |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
|
|
|
|
|
|
|
|
{/* <Form.Item label="设备型号" name="code2" rules={[{ required: true, message: '此项为必填项!' }]} > |
|
|
|
<Input /> |
|
|
|
</Form.Item> */} |
|
|
|
|
|
|
|
<Form.Item label="设备描述" name="des" > |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item label="设备类型" name="type" rules={[{ required: true, message: '此项为必填项!' }]} > |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item label="设备维保日期" name="data" rules={[{ required: true, message: '此项为必填项!' }]} > |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
|
|
|
|
</Form> |
|
|
|
</Modal> |
|
|
|
|
|
|
|
<Modal |
|
|
|
{/* <Modal |
|
|
|
key="02" |
|
|
|
width={800} |
|
|
|
|
|
|
@@ -339,7 +399,7 @@ export default () => { |
|
|
|
></Transfer> |
|
|
|
</Modal> |
|
|
|
|
|
|
|
|
|
|
|
*/} |
|
|
|
</> |
|
|
|
); |
|
|
|
}; |