@@ -357,6 +357,41 @@ export default [ | |||
}, | |||
], | |||
}, | |||
{ | |||
name: '设备数据下发', | |||
icon: 'BankFilled', | |||
path: '/push', | |||
routes: [ | |||
{ | |||
name: '商品数据下发', | |||
icon: 'smile', | |||
path: '/push/goodspush', | |||
component: './push/goodspush', | |||
access: 'k12', | |||
}, | |||
{ | |||
name: '物料数据下发', | |||
icon: 'smile', | |||
path: '/push/batchingpush', | |||
component: './push/batchingpush', | |||
access: 'k14', | |||
}, | |||
{ | |||
name: '配方数据下发', | |||
icon: 'smile', | |||
path: '/push/bompush', | |||
component: './push/bompush', | |||
access: 'k14', | |||
}, | |||
{ | |||
name: '工艺数据下发', | |||
icon: 'smile', | |||
path: '/push/technologypush', | |||
component: './push/technologypush', | |||
access: 'k14', | |||
}, | |||
], | |||
}, | |||
{ | |||
name: '订单管理', | |||
icon: 'BankFilled', | |||
@@ -114,4 +114,4 @@ const PushFrom = (props) => { | |||
); | |||
}; | |||
export default PushFrom; | |||
export default PushFrom; |
@@ -80,15 +80,10 @@ const goodspush = () => { | |||
dataIndex: 'type', | |||
ellipsis: true, | |||
valueEnum: { | |||
1: { | |||
text: '商品', | |||
}, | |||
2: { | |||
text: '物料', | |||
}, | |||
3: { | |||
text: '配方', | |||
}, | |||
}, | |||
}, | |||
{ | |||
@@ -255,7 +250,7 @@ const HandleOk= async(values)=>{ | |||
<ProDescriptions.Item label="topic" valueType="text" copyable={true}> | |||
<a href='#'>{currentRow?.topic}</a> | |||
</ProDescriptions.Item> | |||
<ProDescriptions.Item label="下发数据" valueType="jsonCode" > | |||
<ProDescriptions.Item contentStyle={{ maxWidth: '85%'}} label="下发数据" valueType="jsonCode" > | |||
{currentRow?.dataResore} | |||
</ProDescriptions.Item> | |||
</ProDescriptions> | |||
@@ -265,4 +260,4 @@ const HandleOk= async(values)=>{ | |||
); | |||
}; | |||
export default goodspush; | |||
export default goodspush; |
@@ -36,4 +36,4 @@ export async function GetDevicePushRecodePage(data) { | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
} |
@@ -89,18 +89,18 @@ const PushFrom = (props) => { | |||
}else{ | |||
var de=DeviceInfo.find(x=>x.id==DeviceIds); | |||
var data={goodsinfo:[]}; | |||
if(isGlogy){ | |||
data.goodstechnology=[] | |||
} | |||
// if(isGlogy){ | |||
// data.goodstechnology=[] | |||
// } | |||
selectedRowsState.map(x=>{ | |||
var pa={id:x.id,code:x.code,goodsTypeId:x.goodsTypeId,goodsTypeName:x.goodsTypeName,goodsUintId:x.goodsUintId,imgUrl:x.imgUrl,isAttrubute:x.isAttrubute,name:x.name,price:x.price,design:x.design,remark:x.remark} | |||
data.goodsinfo.push(pa); | |||
if(isGlogy){ | |||
//data.goodstechnology=[] | |||
if(x.goodstechnology.length>0){ | |||
data.goodstechnology.push(x.goodstechnology) | |||
} | |||
} | |||
// if(isGlogy){ | |||
// //data.goodstechnology=[] | |||
// if(x.goodstechnology.length>0){ | |||
// data.goodstechnology.push(x.goodstechnology) | |||
// } | |||
// } | |||
}) | |||
var parm={deviceId:de.id,deviceName:de.name,deviceAutoKey:de.autoKey,type:1,data:data} | |||
props.HandleOk(parm) | |||
@@ -126,12 +126,12 @@ const PushFrom = (props) => { | |||
</Col> | |||
</Row> | |||
<Row style={{marginBottom:20}}> | |||
{/* <Row style={{marginBottom:20}}> | |||
<Col lg={24} md={24} sm={24}> | |||
是否包含工艺: | |||
<Switch checkedChildren="是" unCheckedChildren="否" checked={isGlogy} value={isGlogy} onChange={onChange} /> | |||
</Col> | |||
</Row> | |||
</Row> */} | |||
<Row gutter={26}> | |||
<Col span={24}> | |||
选择数据: | |||
@@ -158,4 +158,4 @@ const PushFrom = (props) => { | |||
); | |||
}; | |||
export default PushFrom; | |||
export default PushFrom; |
@@ -83,12 +83,7 @@ const goodspush = () => { | |||
1: { | |||
text: '商品', | |||
}, | |||
2: { | |||
text: '物料', | |||
}, | |||
3: { | |||
text: '配方', | |||
}, | |||
}, | |||
}, | |||
{ | |||
@@ -255,7 +250,7 @@ const HandleOk= async(values)=>{ | |||
<ProDescriptions.Item label="topic" valueType="text" copyable={true}> | |||
<a href='#'>{currentRow?.topic}</a> | |||
</ProDescriptions.Item> | |||
<ProDescriptions.Item label="下发数据" valueType="jsonCode" > | |||
<ProDescriptions.Item contentStyle={{ maxWidth: '85%'}} label="下发数据" valueType="jsonCode" > | |||
{currentRow?.dataResore} | |||
</ProDescriptions.Item> | |||
</ProDescriptions> | |||
@@ -265,4 +260,4 @@ const HandleOk= async(values)=>{ | |||
); | |||
}; | |||
export default goodspush; | |||
export default goodspush; |
@@ -43,4 +43,4 @@ export async function GetDevicePushRecodePage(data) { | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} | |||
} |
@@ -0,0 +1,166 @@ | |||
import React, { useState, useEffect,useRef } from 'react'; | |||
import { Modal, Row, Col, Checkbox, Select,message,Switch} 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 [isGlogy, setisGlogy] = useState(false); | |||
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} | |||
GetGoodsData(params) | |||
},[props.values]) | |||
const GetGoodsData=(params)=>{ | |||
GetGoodsPage(params).then((r) => { | |||
setdataSource(r.data.data); | |||
//console.log(goodsData) | |||
//total = r.data.total; | |||
}); | |||
} | |||
const handleChange=(value)=>{ | |||
setDeviceIds(value) | |||
var params={current:1,pageSize:10,deviceId:value} | |||
GetGoodsData(params) | |||
} | |||
const onChange=(checked)=>{ | |||
if(!DeviceIds){ | |||
message.error('请先选择设备'); | |||
}else{ | |||
setisGlogy(checked) | |||
} | |||
} | |||
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={() => { | |||
if(!DeviceIds){ | |||
message.error('请选择设备'); | |||
}else{ | |||
var de=DeviceInfo.find(x=>x.id==DeviceIds); | |||
var data={goodstechnology:[]}; | |||
// if(isGlogy){ | |||
// data.goodstechnology=[] | |||
// } | |||
selectedRowsState.map(x=>{ | |||
// var pa={id:x.id,code:x.code,goodsTypeId:x.goodsTypeId,goodsTypeName:x.goodsTypeName,goodsUintId:x.goodsUintId,imgUrl:x.imgUrl,isAttrubute:x.isAttrubute,name:x.name,price:x.price,design:x.design,remark:x.remark} | |||
// data.goodsinfo.push(pa); | |||
// if(isGlogy){ | |||
// //data.goodstechnology=[] | |||
if(x.goodstechnology.length>0){ | |||
data.goodstechnology.push(x.goodstechnology) | |||
} | |||
// } | |||
}) | |||
if(data.goodstechnology.length==0){ | |||
message.error('选择的商品还没有工艺'); | |||
}else{ | |||
var parm={deviceId:de.id,deviceName:de.name,deviceAutoKey:de.autoKey,type:4,data:data} | |||
props.HandleOk(parm) | |||
console.log(de) | |||
} | |||
} | |||
}} | |||
onCancel={() => { | |||
props.onCancel(); | |||
}} | |||
destroyOnClose | |||
> | |||
<Row gutter={26} style={{marginBottom:20}}> | |||
<Col lg={24} md={24} sm={24}> | |||
选择设备: | |||
<Select | |||
allowClear | |||
style={{width: '60%'}} | |||
placeholder="请选择要下发设备" | |||
onChange={handleChange} | |||
options={deviceData} | |||
/> | |||
</Col> | |||
</Row> | |||
{/* <Row style={{marginBottom:20}}> | |||
<Col lg={24} md={24} sm={24}> | |||
是否包含工艺: | |||
<Switch checkedChildren="是" unCheckedChildren="否" checked={isGlogy} value={isGlogy} onChange={onChange} /> | |||
</Col> | |||
</Row> */} | |||
<Row gutter={26}> | |||
<Col span={24}> | |||
选择数据: | |||
<ProTable | |||
headerTitle="" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
pagination={{ defaultPageSize: 10 }} | |||
search={{ | |||
labelWidth: 120, | |||
}} | |||
dataSource={dataSource} | |||
columns={columns} | |||
rowSelection={{ | |||
onChange: (_, selectedRows) => { | |||
setSelectedRows(selectedRows); | |||
}, | |||
}} | |||
> | |||
</ProTable> | |||
</Col> | |||
</Row> | |||
</Modal> | |||
); | |||
}; | |||
export default PushFrom; |
@@ -0,0 +1,262 @@ | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { Button, message, Input, Drawer, Popconfirm } from 'antd'; | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import ProDescriptions from '@ant-design/pro-descriptions'; | |||
import PushFrom from './components/PushFrom'; | |||
import { | |||
GetDevicePushRecodePage, | |||
DevicePushRecodeAdd, | |||
DevicePushRecodeDelete | |||
} from './services'; | |||
const goodspush = () => { | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
/** 分布更新窗口的弹窗 */ | |||
const [showDetail, setShowDetail] = useState(false); | |||
const actionRef = useRef(); | |||
const [currentRow, setCurrentRow] = useState(); | |||
const [selectedRowsState, setSelectedRows] = useState([]); | |||
/** 国际化修改 */ | |||
useEffect(() => { | |||
}, []); | |||
/** | |||
* 批量删除 | |||
* | |||
* @param selectedRows | |||
*/ | |||
const handleRemove = async (selectedRows) => { | |||
const hide = message.loading('正在删除'); | |||
if (!selectedRows) return true; | |||
await DevicePushRecodeDelete(selectedRows.map((row) => row.id)).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
hide(); | |||
return true; | |||
}; | |||
const columns = [ | |||
{ | |||
title: '主键', | |||
dataIndex: 'id', | |||
hideInSearch: true, | |||
hideInTable: true, | |||
tip: '规则名称是唯一的 key', | |||
render: (dom, entity) => { | |||
return ( | |||
<a | |||
onClick={() => { | |||
setCurrentRow(entity); | |||
setShowDetail(true); | |||
}} | |||
> | |||
{dom} | |||
</a> | |||
); | |||
}, | |||
}, | |||
{ | |||
title: '下发设备', | |||
dataIndex: 'deviceName', | |||
valueType: 'textarea', | |||
ellipsis: true, | |||
}, | |||
{ | |||
title: '下发数据', | |||
dataIndex: 'type', | |||
ellipsis: true, | |||
valueEnum: { | |||
4: { | |||
text: '工艺', | |||
}, | |||
}, | |||
}, | |||
{ | |||
title: '下发时间', | |||
dataIndex: 'createAt', | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
valueType: 'option', | |||
render: (_, record) => [ | |||
<a | |||
key="config" | |||
onClick={() => { | |||
setShowDetail(true); | |||
setCurrentRow(record); | |||
}} | |||
> | |||
下发详情 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={async () => { | |||
await DeleteGoodsType(record.id).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
onCancel={() => {}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
], | |||
}, | |||
]; | |||
const HandleOk= async(values)=>{ | |||
await DevicePushRecodeAdd(values).then((res)=>{ | |||
if(res.data){ | |||
message.success('操作成功'); | |||
handleModalVisible(false); | |||
actionRef.current.reload(); | |||
}else{ | |||
message.error('操作失败'); | |||
} | |||
}) | |||
} | |||
return ( | |||
<PageContainer host header={{ | |||
title: '', | |||
breadcrumb: {}, | |||
}}> | |||
<ProTable | |||
headerTitle="" | |||
actionRef={actionRef} | |||
rowKey="id" | |||
pagination={{ defaultPageSize: 10 }} | |||
search={{ | |||
labelWidth: 120, | |||
}} | |||
toolBarRender={() => [ | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalVisible(true); | |||
}} | |||
> | |||
<PlusOutlined /> 下发数据 | |||
</Button>, | |||
]} | |||
request={async (params) => { | |||
var goodsData = []; | |||
var total = 0; | |||
params.type=4 | |||
await GetDevicePushRecodePage(params).then((r) => { | |||
goodsData = r.data.data; | |||
total = r.data.total; | |||
}); | |||
return { | |||
data: goodsData, | |||
success: true, | |||
total: total, | |||
}; | |||
}} | |||
columns={columns} | |||
rowSelection={{ | |||
onChange: (_, selectedRows) => { | |||
setSelectedRows(selectedRows); | |||
}, | |||
}} | |||
/> | |||
{selectedRowsState?.length > 0 && ( | |||
<FooterToolbar | |||
extra={ | |||
<div> | |||
已选择{' '} | |||
<a | |||
style={{ | |||
fontWeight: 600, | |||
}} | |||
> | |||
{selectedRowsState.length} | |||
</a>{' '} | |||
项 | |||
{/* <span> | |||
服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + item.id, 0)} 万 | |||
</span> */} | |||
</div> | |||
} | |||
> | |||
<Button | |||
onClick={async () => { | |||
await handleRemove(selectedRowsState); | |||
setSelectedRows([]); | |||
actionRef.current?.reloadAndRest?.(); | |||
}} | |||
> | |||
删除 | |||
</Button> | |||
{/* <Button type="primary">批量审批</Button> */} | |||
</FooterToolbar> | |||
)} | |||
<PushFrom | |||
onFinish={async (value) => { | |||
}} | |||
onCancel={() => { | |||
handleModalVisible(false); | |||
setCurrentRow(undefined); | |||
}} | |||
createModalVisible={createModalVisible} | |||
HandleOk={HandleOk} | |||
values={currentRow || {}} | |||
/> | |||
<Drawer | |||
width={600} | |||
visible={showDetail} | |||
onClose={() => { | |||
setCurrentRow(undefined); | |||
setShowDetail(false); | |||
}} | |||
closable={false} | |||
> | |||
{currentRow?.deviceName && ( | |||
<ProDescriptions | |||
column={1} | |||
title="下发详情" | |||
> | |||
<ProDescriptions.Item label="下发设备" valueType="text"> | |||
{currentRow?.deviceName} | |||
</ProDescriptions.Item> | |||
<ProDescriptions.Item label="topic" valueType="text" copyable={true}> | |||
<a href='#'>{currentRow?.topic}</a> | |||
</ProDescriptions.Item> | |||
<ProDescriptions.Item contentStyle={{ maxWidth: '85%'}} label="下发数据" valueType="jsonCode" > | |||
{currentRow?.dataResore} | |||
</ProDescriptions.Item> | |||
</ProDescriptions> | |||
)} | |||
</Drawer> | |||
</PageContainer> | |||
); | |||
}; | |||
export default goodspush; |
@@ -0,0 +1,46 @@ | |||
import { request } from 'umi'; | |||
export async function GetDevicePushRecodePage(data) { | |||
return request(`/saasstore/api/devicepushrecode/page`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
export async function DevicePushRecodeAdd(data) { | |||
return request(`/saasstore/api/devicepushrecode/add`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
export async function DevicePushRecodeUpdate(data) { | |||
return request(`/saasstore/api/devicepushrecode/update`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
export async function DevicePushRecodeDelete(data) { | |||
return request(`/saasstore/api/devicepushrecode/delete`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
export async function GetDeviceList() { | |||
return request(`/saasbase/api/device/list`, { | |||
method: 'GET', | |||
}); | |||
} | |||
export async function GetGoodsTypeTree(params) { | |||
return request('/saasbase/api/goodstype/tree', { | |||
method: 'GET', | |||
data: { | |||
...params, | |||
}, | |||
}); | |||
} | |||
export async function GetGoodsPage(data) { | |||
return request(`/saasbase/api/goods/page`, { | |||
method: 'Post', | |||
data: data, | |||
// params: { ...params }, | |||
// ...(options || {}), | |||
}); | |||
} |