|
|
@@ -0,0 +1,137 @@ |
|
|
|
import React, { useState, useEffect,useRef } from 'react'; |
|
|
|
import { Modal, Row, Col, Checkbox, Select} from 'antd'; |
|
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
|
import { |
|
|
|
GetDeviceList, |
|
|
|
GetGoodsPage, |
|
|
|
GetGoodsTypeTree |
|
|
|
} from '../services'; |
|
|
|
const PushFrom = (props) => { |
|
|
|
const [deviceData, setdeviceData] = useState([]); |
|
|
|
const [selectedRowsState, setSelectedRows] = useState([]); |
|
|
|
const [dataSource,setdataSource]= useState([]); |
|
|
|
const [treeData, setTreeData] = useState(); |
|
|
|
const [DeviceIds, setDeviceIds] = useState([]); |
|
|
|
const [DeviceInfo, setDeviceInfo] = useState([]); |
|
|
|
const actionRef = useRef(); |
|
|
|
useEffect(() => { |
|
|
|
console.log(props.values) |
|
|
|
GetDeviceList().then((r)=>{ |
|
|
|
setDeviceInfo(r.data); |
|
|
|
var data=r.data.map(x=>{ |
|
|
|
return {value:x.id,label:x.name} |
|
|
|
}) |
|
|
|
setdeviceData(data) |
|
|
|
}) |
|
|
|
GetGoodsTypeTree().then((r) => { |
|
|
|
setTreeData(r.data); |
|
|
|
}); |
|
|
|
var params={current:1,pageSize:10} |
|
|
|
GetGoodsPage(params).then((r) => { |
|
|
|
setdataSource(r.data.data); |
|
|
|
//console.log(goodsData) |
|
|
|
//total = r.data.total; |
|
|
|
}); |
|
|
|
},[props.values]) |
|
|
|
const handleChange=(value)=>{ |
|
|
|
setDeviceIds(value) |
|
|
|
} |
|
|
|
const columns=[ |
|
|
|
{ |
|
|
|
title: '编码', |
|
|
|
dataIndex: 'code', |
|
|
|
valueType: 'textarea', |
|
|
|
hideInTable: true, |
|
|
|
hideInSearch: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '名称', |
|
|
|
dataIndex: 'name', |
|
|
|
valueType: 'textarea', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '商品类型', |
|
|
|
dataIndex: 'goodsTypeName', |
|
|
|
valueType: 'treeSelect', |
|
|
|
fieldProps: { |
|
|
|
showSearch:true, |
|
|
|
allowClear:true, |
|
|
|
options: treeData |
|
|
|
}, |
|
|
|
}, |
|
|
|
] |
|
|
|
return ( |
|
|
|
<Modal |
|
|
|
title={'下发数据'} |
|
|
|
width={1040} |
|
|
|
visible={props.createModalVisible} |
|
|
|
bodyStyle={{ padding: '32px 40px 1px 48px' }} |
|
|
|
okText="确定" |
|
|
|
cancelText="取消" |
|
|
|
onOk={() => { |
|
|
|
console.log(selectedRowsState) |
|
|
|
console.log(DeviceIds) |
|
|
|
if(DeviceIds.length>0){ |
|
|
|
|
|
|
|
} |
|
|
|
}} |
|
|
|
onCancel={() => { |
|
|
|
props.onCancel(); |
|
|
|
}} |
|
|
|
destroyOnClose |
|
|
|
> |
|
|
|
<Row gutter={26}> |
|
|
|
<Col lg={24} md={24} sm={24}> |
|
|
|
选择设备: |
|
|
|
<Select |
|
|
|
mode="multiple" |
|
|
|
allowClear |
|
|
|
style={{width: '60%'}} |
|
|
|
placeholder="请选择要下发设备" |
|
|
|
onChange={handleChange} |
|
|
|
options={deviceData} |
|
|
|
/> |
|
|
|
</Col> |
|
|
|
|
|
|
|
</Row> |
|
|
|
<Row gutter={26}> |
|
|
|
<Col span={24}> |
|
|
|
选择数据: |
|
|
|
<ProTable |
|
|
|
headerTitle="" |
|
|
|
actionRef={actionRef} |
|
|
|
rowKey="id" |
|
|
|
pagination={{ defaultPageSize: 10 }} |
|
|
|
search={{ |
|
|
|
labelWidth: 120, |
|
|
|
}} |
|
|
|
dataSource={dataSource} |
|
|
|
// request={async (params) => { |
|
|
|
// var goodsData = []; |
|
|
|
// var total = 0; |
|
|
|
// await goods(params).then((r) => { |
|
|
|
// goodsData = r.data.data; |
|
|
|
// console.log(goodsData) |
|
|
|
// total = r.data.total; |
|
|
|
// }); |
|
|
|
// return { |
|
|
|
// data: goodsData, |
|
|
|
// success: true, |
|
|
|
// total: total, |
|
|
|
// }; |
|
|
|
// }} |
|
|
|
columns={columns} |
|
|
|
rowSelection={{ |
|
|
|
onChange: (_, selectedRows) => { |
|
|
|
setSelectedRows(selectedRows); |
|
|
|
}, |
|
|
|
}} |
|
|
|
> |
|
|
|
</ProTable> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Modal> |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
export default PushFrom; |