Browse Source

Merge branch 'master' into groupmealweb

groupmealweb
zhaoy 11 months ago
parent
commit
fdcf058f37
4 changed files with 358 additions and 0 deletions
  1. +7
    -0
      config/routes.js
  2. +67
    -0
      src/pages/device/devicepush/components/PushFrom.jsx
  3. +254
    -0
      src/pages/device/devicepush/index.jsx
  4. +30
    -0
      src/pages/device/devicepush/services.js

+ 7
- 0
config/routes.js View File

@@ -189,6 +189,13 @@ export default [
component: './device/productmanage',
access: 'k14',
},
{
name: '设备数据下发',
icon: 'smile',
path: '/device/devicepush',
component: './device/devicepush',
access: 'k14',
},
// {
// name: '设备工艺信息',
// icon: 'smile',


+ 67
- 0
src/pages/device/devicepush/components/PushFrom.jsx View File

@@ -0,0 +1,67 @@
import React, { useState, useEffect,useRef } from 'react';
import { Modal, Row, Col, Checkbox, Select} from 'antd';
import {
GetDeviceList,
} from '../services';
const PushFrom = (props) => {
const [deviceData, setdeviceData] = useState([]);
useEffect(() => {
console.log(props.values)
GetDeviceList().then((r)=>{
var data=r.data.map(x=>{
return {value:x.id,label:x.name}
})
setdeviceData(data)
})
},[props.values])
const handleChange=()=>{

}
const onChangedata=()=>{

}
return (
<Modal
title={'下发数据'}
width={640}
visible={props.createModalVisible}
bodyStyle={{ padding: '32px 40px 1px 48px' }}
okText="保存"
cancelText="取消"
onOk={() => {
}}
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}>
选择数据:
<Checkbox.Group defaultValue={['1','2']} onChange={onChangedata} >
<Checkbox value="1">商品</Checkbox><a style={{marginLeft:2,marginRight:30}}>【选择商品】</a>
<Checkbox value="2">物料 </Checkbox><a style={{marginLeft:2,marginRight:30}}>【选择物料】</a>
<Checkbox value="3">工艺</Checkbox><a style={{marginLeft:2,marginRight:30}}>【选择工艺】</a>
<Checkbox value="4">配方</Checkbox><a style={{marginLeft:2,marginRight:30}}>【选择配方】</a>
</Checkbox.Group>
</Col>
</Row>
</Modal>
);
};

export default PushFrom;

+ 254
- 0
src/pages/device/devicepush/index.jsx View File

@@ -0,0 +1,254 @@
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,
DevicePushRecodeDelete
} from './services';



const DevicePush = () => {
/** 新建/更新窗口的弹窗 */
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: {
1: {
text: '商品',
},
2: {
text: '物料',
},
3: {
text: '工艺',
},
4: {
text: '配方',
},
},
},
{
title: '下发时间',
dataIndex: 'ceateAt',
hideInSearch: true,
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => [
<a
key="config"
onClick={() => {
handleModalVisible(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>,
],
},
];

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;
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>{' '}
项 &nbsp;&nbsp;
{/* <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}
values={currentRow || {}}
/>

<Drawer
width={600}
visible={showDetail}
onClose={() => {
setCurrentRow(undefined);
setShowDetail(false);
}}
closable={false}
>
{currentRow?.name && (
<ProDescriptions
column={2}
title={currentRow?.name}
request={async () => ({
data: currentRow || {},
})}
params={{
id: currentRow?.name,
}}
columns={columns}
/>
)}
</Drawer>
</PageContainer>
);
};

export default DevicePush;

+ 30
- 0
src/pages/device/devicepush/services.js View File

@@ -0,0 +1,30 @@
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',
});
}

Loading…
Cancel
Save