Browse Source

feat(调酒): 添加调酒

添加调酒
dev
txb 2 years ago
parent
commit
85c08f29be
8 changed files with 877 additions and 2 deletions
  1. +8
    -1
      config/routes.js
  2. +7
    -1
      src/app.jsx
  3. +107
    -0
      src/pages/device/devicemorkmwStock/components/CreateForm.jsx
  4. +335
    -0
      src/pages/device/devicemorkmwStock/index.jsx
  5. +78
    -0
      src/pages/device/devicemorkmwStock/services.js
  6. +64
    -0
      src/pages/device/devicemorkmwpush/components/CreateForm.jsx
  7. +237
    -0
      src/pages/device/devicemorkmwpush/index.jsx
  8. +41
    -0
      src/pages/device/devicemorkmwpush/service.js

+ 8
- 1
config/routes.js View File

@@ -468,7 +468,14 @@ export default [
path: '/device/deviceRecipeStock',
component: './device/deviceRecipeStock',
access: 'k14',
}
},
{
name: '调酒设备',
icon: 'smile',
path: '/device/devicemorkmwpush',
component: './device/devicemorkmwpush',
access: 'k14',
},

],
},


+ 7
- 1
src/app.jsx View File

@@ -90,7 +90,13 @@ export async function getInitialState() {
path: '/device/deviceBom',
component: './device/deviceBom',
access: 'k14',
}
}, {
name: '调酒设备',
icon: 'smile',
path: '/device/devicemorkmwpush',
component: './device/devicemorkmwpush',
access: 'k14',
},
],
},
// {


+ 107
- 0
src/pages/device/devicemorkmwStock/components/CreateForm.jsx View File

@@ -0,0 +1,107 @@
import React, { useState, useEffect } from 'react';
import { InputNumber, Modal, Form, Input, Button, Select } from 'antd';
import { GetBatchingAsync,GetProductListByBom,getloc } from '../services';

const CreateForm = (props) => {
console.log("设备库存",props.DeviceId);
const { Option, OptGroup } = Select;
const [batchingList, setBatchingList] = useState([]);
const [loc, setloc] = useState([]);
//原料
//初始化数据
useEffect(() => {
const initBatching = () => {
getloc(props.deviceKey).then((data) => {
//
setloc(data.data);
});
if(props.isbom){
GetProductListByBom({ DeviceId: props.DeviceId,BomIds:props.bomIds }).then((data) => {
setBatchingList(data.data);
});

}else {
GetBatchingAsync({ DeviceId: props.DeviceId }).then((data) => {
setBatchingList(data.data);
});
}

};
initBatching();
}, []);
return (
<Modal
title={props.values.id ? '编辑' : '新建'}
width={640}
visible={props.createModalVisible}
bodyStyle={{ padding: '32px 40px 48px' }}
footer={null}
onCancel={() => {
props.onCancel();
}}
destroyOnClose
>
<Form
layout="vertical"
preserve={false}
initialValues={props.values}
onFinish={props.onFinish}
>
<Form.Item name="id" hidden={true}>
<Input />
</Form.Item>
<Form.Item
name="batching_Id"
label="原料名称"
rules={[{ required: true, message: '请选择原料名称' }]}
>
<Select placeholder="请选择原料名称" showSearch
optionFilterProp="children"
filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
}>
{batchingList?.map((item, index) => {
return (
<Select.Option index={index} value={item.id} key={item.id}>
{item.name}
</Select.Option>
);
})}
</Select>
</Form.Item>
<Form.Item
name="batching_Loc"
label="库存位置"
rules={[{ required: true }]}
defaultValue="0"
>
<Select placeholder="请选择库存位置" >
{loc?.map((item, index) => {
return (
<Select.Option index={index} value={item.loc} key={item.loc}>
{item.loc}
</Select.Option>
);
})}
</Select>
</Form.Item>
<Form.Item
name="batching_Count"
label="原料数量"
rules={[{ required: true }]}
defaultValue="0"
>
<InputNumber min={0} placeholder="请输入原料数量" />
</Form.Item>

<Form.Item>
<Button type="primary" htmlType="submit">
保存
</Button>
</Form.Item>
</Form>
</Modal>
);
};

export default CreateForm;

+ 335
- 0
src/pages/device/devicemorkmwStock/index.jsx View File

@@ -0,0 +1,335 @@
import { PlusOutlined } from '@ant-design/icons';
import { Popconfirm, Modal, Button, message, Input, Drawer } from 'antd';
import React, { useEffect, useState, useRef } 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 CreateForm from './components/CreateForm';
import {
GetStoreBatchingStockPageAsync,
AddStoreBatchingStocAsync,
UpdateStoreBatchingStocAsync,
PushStockAsync,
CheckStockAdjust,
removeSingleStockAdjust,
PushDeviceTMC,
} from './services';

const key = 'message';

const DeviceStockManager = (props) => {
/** 新建/更新窗口的弹窗 */
const [createModalVisible, handleModalVisible] = useState(false);
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
const [total, setTotal] = useState(0);
const [deviceKey, setdeviceKey] = useState();
//添加
const handleAdd = async (fields) => {
try {
fields.DeviceId = props.values.key;
message.loading('正在添加', key);
await AddStoreBatchingStocAsync(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.data) {
message.success('添加成功');
actionRef.current.reload();
return true;
} else {
message.error('添加失败' + r.errors);
actionRef.current.reload();
return false;
}
});
} catch (error) {
message.error('添加失败请重试!');
actionRef.current.reload();
return false;
}
};

//同步
const pushStock = async (id) => {
try {
message.loading('正在同步', key);
await PushStockAsync(id).then((r) => {
message.destroy(key);
if (r.data) {
setSelectedRows([]);
message.success('同步成功');
actionRef.current.reload();
return true;
} else {
message.error('同步失败' + r.errors);
actionRef.current.reload();
return false;
}
});

} catch (error) {
message.error('同步失败请重试!');
actionRef.current.reload();
return false;
}
};

//获取实时库存
const handleCheckStockAdjust = async (id) => {
console.log("fdsfds");
try {
if (props.isbom) {
await CheckStockTMCAdjust(id).then((r) => {
message.destroy(key);
if (r.data) {
message.success('获取成功');
actionRef.current.reload();
return true;
} else {
message.error('获取失败' + r.errors);
actionRef.current.reload();
return false;
}
});
} else {
await CheckStockAdjust(id).then((r) => {
message.destroy(key);
if (r.data) {
message.success('获取成功');
actionRef.current.reload();
return true;
} else {
message.error('获取失败' + r.errors);
actionRef.current.reload();
return false;
}
});
}
} catch (error) {
message.error("获取失败!");
actionRef.current.reload();
return false;
}
};
const handleRemoveSingle = async (value) => {
try {
await removeSingleStockAdjust(value).then((r) => {
if (r.data) {
message.success('删除成功,即将刷新');
//刷新数据
actionRef.current.reload();
} else {
message.error('删除失败,请重试');
actionRef.current.reload();
}
});
return true;
} catch (error) {
message.error('删除失败,请重试');
actionRef.current.reload();
}
};

//修改
const handleUpdate = async (fields) => {
try {
message.loading('正在修改', key);
message.destroy(key);
fields.DeviceId = props.values.key;
await UpdateStoreBatchingStocAsync(JSON.stringify(fields)).then((r) => {
message.destroy(key);
if (r.data) {
message.success('修改成功');
return true;
} else {
message.error('修改失败' + r.errors);
return false;
}
});
} catch (error) {
message.error('修改失败请重试!');
return false;
}
};

const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key',
},
{
title: '物料',
dataIndex: 'batching_Name',
valueType: 'textarea',
},
{
title: '数量',
dataIndex: 'batching_Count',
valueType: 'textarea',
},
{
title: '库位',
dataIndex: 'batching_Loc',
},
{
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={() => {
handleRemoveSingle(record.id);
}}
onCancel={() => { }}
>
<a href="#">删除</a>
</Popconfirm>,
],
},
];

return (
<Modal
width={1200}
bodyStyle={{ padding: '32px 40px 48px' }}
destroyOnClose
//(props.values == undefined ? '' : props.values.store_Name) +
title={(props.values == undefined ? '' : props.values.title) + '库存原料调整'}
search={false}
visible={props.stockModalVisible}
footer={false}
onCancel={() => props.onCancel()}
maskClosable={false}
>
<PageContainer
header={{
title: '',
breadcrumb: {},
}}
>
<ProTable
headerTitle=""
actionRef={actionRef}
rowKey="id"
search={false}
toolBarRender={() => [
<Popconfirm
type="primary"
key="primary"
title="获取实时库存会覆盖本次补货数据"
okText="是"
cancelText="否"
onConfirm={() => {
handleCheckStockAdjust(props.values.key);
}}
onCancel={() => { }}
>
<Button type="primary" key="primary">
获取实时库存
</Button>
</Popconfirm>,
<Button
type="primary"
key="primary"
onClick={() => {
if (selectedRowsState.length == 0) {
message.error('请选择需要同步的数据!!');
}
// else if (selectedRowsState.length < 6) {
// message.error('必须同步6个库存位置的数据,现在条件不满足不能同步!!');
// }
else {
pushStock(props.values.key);
actionRef.current?.reloadAndRest?.();
}
}}
>
同步库存原料
</Button>,
<Button
disabled={props.isbom && total > 14}
type="primary"
key="primary"
onClick={() => {
handleModalVisible(true);
setdeviceKey(props.values.deviceTypeKey)
}}
>
<PlusOutlined /> 新增库存原料
</Button>,
]}
request={async (params) => {
var data = [];
var total = 0;
//params.DeviceId ='263971c3-38d6-43a2-a2df-bb5be147d05e'; //props.values.key;
params.DeviceId = props.values.key;

await GetStoreBatchingStockPageAsync(params).then((r) => {
data = r.data.data;
total = r.data.total;
setTotal(total);
});
return {
data: data,
success: true,
total: total,
};
}}
columns={columns}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
/>

<CreateForm
isbom={props.isbom}
bomIds={props.bomIds}
deviceKey = {props.values == undefined ? '' : props.values.deviceTypeKey}
DeviceId={props.values == undefined ? '' : props.values.key}
onFinish={async (value) => {
var success = false;
if (value.id) {
success = handleUpdate(value);
} else {
success = handleAdd(value);
}
if (success) {
handleModalVisible(false);
setCurrentRow(undefined);
actionRef.current.reload();
}
}}
onCancel={() => {
handleModalVisible(false);
setCurrentRow(undefined);
}}
createModalVisible={createModalVisible}
values={currentRow || {}}

/>
</PageContainer>
</Modal>
);
};

export default DeviceStockManager;

+ 78
- 0
src/pages/device/devicemorkmwStock/services.js View File

@@ -0,0 +1,78 @@
import { request } from 'umi';
/**获取位置配置 */
export async function getloc(data) {
return request(`/kitchen/api/deviceconfig/getlocs?Code=${data}`, {
method: 'GET',
});
}
/** 获取商品物料库存 */
export async function GetStoreBatchingStockPageAsync(data) {
return request(`/kitchen/api/Device/GetDeviceStorePage`, {
method: 'POST',
data: data,
});
}

/** 同步库存 */
export async function PushStockAsync(data) {
return request(`/kitchen/api/Device/PushMorkMWAsync?DeviceId=${data}`, {
method: 'post',
});
}


/** 获取实时库存 */
export async function CheckStockAdjust(data) {
return request(`/kitchen/api/Device/CheckStockAdjust?DeviceId=${data}`, {
method: 'POST',
});
}
/** 获取实时库存 */
export async function CheckStockTMCAdjust(data) {
return request(`/kitchen/api/Device/CheckStockTMCAdjust?DeviceId=${data}`, {
method: 'POST',
});
}



/** 添加商品物料库存 */
export async function AddStoreBatchingStocAsync(data) {
return request(`/kitchen/api/Device/AddUpdateDeviceStocAsync`, {
method: 'POST',
data: data,
});
}

/** 获取原料 */
export async function GetProductListByBom(data) {
return request(`/kitchen/api/Device/GetProductListByBom`, {
method: 'post',
data: data,
});
}

/** 获取原料 */
export async function GetBatchingAsync(data) {
return request(`/kitchen/api/Device/GetProductList`, {
method: 'post',
data: data,
});
}

/** 修改商品物料库存 */
export async function UpdateStoreBatchingStocAsync(data) {
return request(`/kitchen/api/Device/AddUpdateDeviceStocAsync`, {
method: 'put',
data: data,
});
}
export async function removeSingleStockAdjust(data) {
return request(`/kitchen/api/Device/DelStockAdjust?Id=${data}`, {
method: 'DELETE',
// data: data,
// ...(options || {}),
});
}



+ 64
- 0
src/pages/device/devicemorkmwpush/components/CreateForm.jsx View File

@@ -0,0 +1,64 @@
import {Modal } from 'antd';
import React, { useState} from 'react';
import ProTable from '@ant-design/pro-table';
import { GetGoods } from '../service';
const CreateForm = (props) => {

const [selectedRowsState, setSelectedRows] = useState([]);
const columns = [
{
title: '商品id',
dataIndex: 'goodsId',
tip: '规则名称是唯一的 key',
hideInSearch: true,
hideInTable: true,
},
{
title: '商品名称',
dataIndex: 'goodsName',
},
];
return (
<Modal
width={700}
bodyStyle={{ padding: '32px 40px 48px' }}
destroyOnClose
title="选择商品"
visible={props.modalVisible}
onCancel={() => props.onCancel()}
onOk={() => props.onSubmit(selectedRowsState)}
maskClosable={false}
>
<ProTable
headerTitle="商品信息"
rowKey="goodsId"
pagination={{ defaultPageSize: 5000 }}
search={false}
toolBarRender={false}
params={{
DeviceId:props.values,
}}
//数据绑定
request={async (params) => {
var Data = [];
var total = 0;
await GetGoods(params).then((r) => {
Data = r.data;
total = 1;
});
return {
data: Data,
success: true,
total: total,
};
}}
columns={columns}
rowSelection={{
onChange: (_, selectedRows) => setSelectedRows(selectedRows),
}}
/>
</Modal>
);
};

export default CreateForm;

+ 237
- 0
src/pages/device/devicemorkmwpush/index.jsx View File

@@ -0,0 +1,237 @@
import { PlusOutlined } from '@ant-design/icons';
import { Card, Tree, Button, message, Input, Drawer, Divider } 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 CreateForm from './components/CreateForm';
import { add, getpage, gettree, DelDeviceGood } from './service';
import DeviceStock from '../devicemorkmwStock';
/**
* 添加节点
*
* @param fields
*/

const handleAdd = async (fields) => {
const hide = message.loading('正在添加');
try {
await add({ ...fields }).then((r) => {
if (!r.succeeded) {
message.error(r.errors);
return false;
}
});
hide();
message.success('添加成功');
return true;
} catch (error) {
hide();
message.error('添加失败请重试!');
return false;
}
};
/**
* 删除节点
*
* @param selectedRows
*/
const handleRemove = async (selectedRows) => {
try {
message.loading('正在删除');
let ids = [];
selectedRows.forEach((item) => {
ids.push(item.id);
});
await DelDeviceGood(ids).then((r) => {
if (r.data) {
message.success('删除成功');
return true;
} else {
message.success('删除失败');
return false;
}
});
} catch (error) {
message.error('删除失败请重试!');
return false;
}
};
const TableList = () => {
/** 新建窗口的弹窗 */
const [createModalVisible, handleModalVisible] = useState();
/*绑定数据 */
const actionRef = useRef();
const [treeData, setTreeData] = useState();
/*选中*/
const [selectedRowsState, setSelectedRows] = useState();
const [stockModalVisible, setStockModalVisible] = useState(false);

const [DeviceInfo, setDeviceInfo] = useState();
const [DeviceId, setKey] = useState();
/** 国际化配置 */
useEffect(() => {
function initfranchiseeType() {
gettree({"DeviceTypeKey":"MORKMW"}).then((r) => {
setTreeData(r.data);
});
}
initfranchiseeType();
}, []);
const columns = [
{
title: '商品名称',
dataIndex: 'goods_Name',
}
];
return (
<PageContainer>
<ProTable
headerTitle="商品列表"
actionRef={actionRef}
rowKey="id"
search={{
labelWidth: 120,
}}
tableRender={(_, dom) => (
<div
style={{
display: 'flex',
width: '100%',
}}
>
<Card title="店铺设备列表">
<Tree defaultExpandAll={true} onSelect={(e, info) => [
setKey(e[0]),
setDeviceInfo(info.node)
]
} treeData={treeData} />
</Card>
<div
style={{
flex: 1,
}}
>
{dom}
</div>
</div>
)}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleModalVisible(true);
}}
>
<PlusOutlined /> 上架菜品商品
</Button>,
<Button
type="primary"
key="primary"
onClick={() => {
if (DeviceId == undefined) {
message.error('请选择设备');
return;
}
if (DeviceInfo.parentId != "0") { setStockModalVisible(true); }

}}
>
设备库存管理
</Button>,
]}
params={{
DeviceId,
}}
request={async (params) => {
let UserData = [];
var total = 0;

await getpage(params).then((r) => {
UserData = r.data.data;
total = r.data.total;
});
return {
data: UserData,
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;
</div>
}
>
<Button
onClick={async () => {
await handleRemove(selectedRowsState);
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}
>
批量删除
</Button>
</FooterToolbar>
)}
<CreateForm
onSubmit={async (value) => {

if (DeviceId == undefined) {
message.error('请选择设备');
handleModalVisible(false);
} else {
const defaultData = [];
value.map((data) => {
defaultData.push({ FoodId: data.goodsId });
});
const valuejson = { DeviceId: DeviceId, Foodss: defaultData }
var success = false;
success = await handleAdd(valuejson);
if (success) {
handleModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}


}}
onCancel={() => {
handleModalVisible(false);
}}
modalVisible={createModalVisible}
values={DeviceId}
/>
{/* 库存调拨 */}
<DeviceStock
onCancel={() => {
setStockModalVisible(false);
}}
stockModalVisible={stockModalVisible}
values={DeviceInfo}
/>
</PageContainer>
);
};

export default TableList;

+ 41
- 0
src/pages/device/devicemorkmwpush/service.js View File

@@ -0,0 +1,41 @@
import { request } from 'umi';

export async function getpage(params, options) {
return request('/kitchen/api/Device/GetDeviceGoods', {
method: 'POST',
data: {
...params,
},
});
}
export async function add(params) {
return request('/kitchen/api/Device/AddDeviceGood', {
method: 'POST',
data: {
...params,
},
});
}
export async function DelDeviceGood(data) {
return request(`​/kitchen/api/Device/DelDeviceGood`, {
method: 'POST',
data: data,
});
}

export async function gettree(params) {
return request('/kitchen/api/Device/StoreDeviceTreeV1', {
method: 'POST',
data: {
...params,
},
});
}
export async function GetGoods(params) {
return request('/kitchen/​api/Device/GetGoods', {
method: 'POST',
data: {
...params,
},
});
}

Loading…
Cancel
Save