@@ -1,7 +1,7 @@ | |||
import React, { useRef, useState, useEffect } from "react"; | |||
import styles from "./index.less"; | |||
import { PageContainer } from '@ant-design/pro-layout'; | |||
import { PlusOutlined, UserOutlined } from '@ant-design/icons'; | |||
import { UserOutlined } from '@ant-design/icons'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import { Avatar, message, Modal, Table } from 'antd'; | |||
import cardAPI from "../service"; | |||
@@ -28,6 +28,10 @@ const memberAccount = () => { | |||
const [consPageSize, setConsPageSize] = useState(10); | |||
const [consTotal, setConsTotal] = useState(0); | |||
const [expendTotalCount, setExpendTotalCount] = useState(0); | |||
const [personTotalcCount, setPersonTotalcCount] = useState(0); | |||
const [dateRange, setDateRange] = useState(); | |||
/** | |||
* 获取账户消费、充值记录 | |||
* @param {*} record | |||
@@ -40,6 +44,10 @@ const memberAccount = () => { | |||
"memberCardId": "", | |||
"type": type | |||
} | |||
if (dateRange) { | |||
jsonData.startTime = dateRange[0]; | |||
jsonData.endTime = dateRange[1]; | |||
} | |||
const response = await cardAPI.GetMemberAccountCardConsRecord(jsonData); | |||
setCurrentOption({ | |||
functionName: 'onFetchAccountConsRecord', | |||
@@ -67,6 +75,10 @@ const memberAccount = () => { | |||
"memberCardId": record.id, | |||
"type": type | |||
} | |||
if (dateRange) { | |||
jsonData.startTime = dateRange[0]; | |||
jsonData.endTime = dateRange[1]; | |||
} | |||
const response = await cardAPI.GetMemberAccountCardConsRecord(jsonData); | |||
setCurrentOption({ | |||
functionName: 'onFetchCardConsRecord', | |||
@@ -84,11 +96,18 @@ const memberAccount = () => { | |||
//账号列表 | |||
const columns = [ | |||
{ | |||
title: '起止时间', | |||
dataIndex: 'dateRange', | |||
hideInTable: true, | |||
valueType: 'dateRange' | |||
}, | |||
{ | |||
title: '头像', | |||
dataIndex: 'headImgUrl', | |||
ellipsis: true, | |||
width: 100, | |||
hideInSearch: true, | |||
align: 'center', | |||
render: (text, record) => { | |||
return <Avatar size={64} shape="square" icon={<UserOutlined />} src={record.headImgUrl} /> | |||
@@ -99,22 +118,30 @@ const memberAccount = () => { | |||
dataIndex: 'name', | |||
ellipsis: true, | |||
}, | |||
{ | |||
title: '卡号', | |||
dataIndex: 'memberCardNum', | |||
ellipsis: true, | |||
}, | |||
{ | |||
title: '联系方式', | |||
dataIndex: 'memberPhone', | |||
ellipsis: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '余额', | |||
dataIndex: 'money', | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '操作', | |||
valueType: 'option', | |||
key: 'option', | |||
render: (text, record) => [ | |||
<a onClick={() => onFetchAccountConsRecord(record, -1)}>账户消费记录</a>, | |||
<a onClick={() => onFetchAccountConsRecord(record, 1)}>账户充值记录</a>, | |||
// <a onClick={() => onFetchAccountConsRecord(record, 1)}>账户充值记录</a>, | |||
], | |||
}, | |||
]; | |||
@@ -175,7 +202,7 @@ const memberAccount = () => { | |||
key: 'option', | |||
render: (text, record) => [ | |||
<a onClick={() => onFetchCardConsRecord(record, -1)}>会员卡消费记录</a>, | |||
<a onClick={() => onFetchCardConsRecord(record, 1)}>会员卡充值记录</a>, | |||
// <a onClick={() => onFetchCardConsRecord(record, 1)}>会员卡充值记录</a>, | |||
], | |||
} | |||
]; | |||
@@ -201,33 +228,33 @@ const memberAccount = () => { | |||
</div> | |||
} | |||
}, | |||
{ | |||
title: '之前余额', | |||
dataIndex: 'beforeMoney', | |||
render: (_, record) => { | |||
return <div style={{ color: 'green' }}> | |||
{record.beforeMoney} | |||
</div> | |||
} | |||
}, | |||
{ | |||
title: '消费金额', | |||
dataIndex: 'money', | |||
render: (_, record) => { | |||
return <div style={{ color: 'red' }}> | |||
{record.money} | |||
</div> | |||
} | |||
}, | |||
{ | |||
title: '之后余额', | |||
dataIndex: 'afterMoney', | |||
render: (_, record) => { | |||
return <div style={{ color: 'blue' }}> | |||
{record.afterMoney} | |||
</div> | |||
} | |||
} | |||
// { | |||
// title: '之前余额', | |||
// dataIndex: 'beforeMoney', | |||
// render: (_, record) => { | |||
// return <div style={{ color: 'green' }}> | |||
// {record.beforeMoney} | |||
// </div> | |||
// } | |||
// }, | |||
// { | |||
// title: '消费金额', | |||
// dataIndex: 'money', | |||
// render: (_, record) => { | |||
// return <div style={{ color: 'red' }}> | |||
// {record.money} | |||
// </div> | |||
// } | |||
// }, | |||
// { | |||
// title: '之后余额', | |||
// dataIndex: 'afterMoney', | |||
// render: (_, record) => { | |||
// return <div style={{ color: 'blue' }}> | |||
// {record.afterMoney} | |||
// </div> | |||
// } | |||
// } | |||
]; | |||
useEffect(() => { | |||
@@ -243,17 +270,35 @@ const memberAccount = () => { | |||
<PageContainer> | |||
<div className={styles.member_card_container}> | |||
<ProTable | |||
title={() => <div className={styles.expend_total_count}>消费次数{expendTotalCount},消费人数{personTotalcCount}</div>} | |||
columns={columns} | |||
actionRef={actionRef} | |||
expandable={{ | |||
expandedRowRender: record => expandedRowRender(record) | |||
}} | |||
request={ | |||
async () => { | |||
const response = await cardAPI.GetMemberAccountPageList({ | |||
current, | |||
pageSize | |||
}); | |||
async (values) => { | |||
if (values.memberCardNum) { | |||
values.cardNum = values.memberCardNum; | |||
} | |||
if (values.dateRange) { | |||
setDateRange(values.dateRange); | |||
const response = await cardAPI.GetMemberAccountRecordTotal({ | |||
startTime: values.dateRange[0], | |||
endTime: values.dateRange[1] | |||
}); | |||
if (response.statusCode === 200) { | |||
setExpendTotalCount(response.data.expendTotalCount); | |||
setPersonTotalcCount(response.data.personTotalcCount); | |||
} | |||
} else { | |||
setDateRange(null); | |||
setExpendTotalCount(0); | |||
setPersonTotalcCount(0); | |||
} | |||
delete values.dateRange; | |||
delete values.memberCardNum; | |||
const response = await cardAPI.GetMemberAccountPageList(values); | |||
setTotal(response.data.data); | |||
return { | |||
data: response.data.data, | |||
@@ -267,7 +312,6 @@ const memberAccount = () => { | |||
type: 'multiple', | |||
}} | |||
rowKey="id" | |||
search={false} | |||
options={{ | |||
setting: { | |||
listsHeight: 400, | |||
@@ -280,7 +324,7 @@ const memberAccount = () => { | |||
dateFormatter="string" | |||
headerTitle="储值卡账户管理" | |||
/> | |||
<Modal width={800} title='消费记录' visible={isModalOpen} footer={false} onCancel={() => {setIsModalOpen(false); setConsCurrent(1)}}> | |||
<Modal width={800} title='消费记录' visible={isModalOpen} footer={false} onCancel={() => { setIsModalOpen(false); setConsCurrent(1) }}> | |||
<Table columns={consColumns} dataSource={consList} pagination={{ | |||
current: consCurrent, | |||
pageSize: consPageSize, | |||
@@ -0,0 +1,6 @@ | |||
.expend_total_count { | |||
background-color: #fff2e8; | |||
border: 1px solid #ffbb96; | |||
padding: 15px; | |||
font-size: 18px; | |||
} |
@@ -32,6 +32,18 @@ export default { | |||
}); | |||
}, | |||
/** | |||
* 获取会员消费记录总次数和总人数 | |||
* @param {*} data | |||
* @returns | |||
*/ | |||
GetMemberAccountRecordTotal(data) { | |||
return request('/kitchen/api/member/member-account-record-total', { | |||
method: 'POST', | |||
data | |||
}); | |||
}, | |||
/** 档口管理:Start */ | |||
// 新增档口 | |||
AddGate(data) { | |||
@@ -128,6 +128,7 @@ const storedValueCard = () => { | |||
title: '会员名称', | |||
dataIndex: 'memberName', | |||
ellipsis: true, | |||
hideInSearch: true | |||
}, | |||
{ | |||
title: '会员头像', | |||
@@ -135,6 +136,7 @@ const storedValueCard = () => { | |||
ellipsis: true, | |||
width: 100, | |||
align: 'center', | |||
hideInSearch: true, | |||
render: (text, record) => { | |||
return <Avatar size={64} shape="square" icon={<UserOutlined />} src={record.headImgUrl} /> | |||
} | |||
@@ -143,11 +145,13 @@ const storedValueCard = () => { | |||
title: '会员电话', | |||
dataIndex: 'phone', | |||
ellipsis: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '状态', | |||
dataIndex: 'state', | |||
valueType: 'select', | |||
hideInSearch: true, | |||
valueEnum: { | |||
0: { | |||
text: '禁用', | |||
@@ -171,6 +175,7 @@ const storedValueCard = () => { | |||
title: '类型', | |||
dataIndex: 'type', | |||
valueType: 'select', | |||
hideInSearch: true, | |||
valueEnum: { | |||
1: { | |||
text: '人脸', | |||
@@ -237,11 +242,8 @@ const storedValueCard = () => { | |||
columns={columns} | |||
actionRef={actionRef} | |||
request={ | |||
async () => { | |||
const response = await cardAPI.GetMemberCardPageList({ | |||
current, | |||
pageSize | |||
}); | |||
async (values) => { | |||
const response = await cardAPI.GetMemberCardPageList(values); | |||
return { | |||
data: response.data.data, | |||
success: true, | |||
@@ -254,7 +256,6 @@ const storedValueCard = () => { | |||
type: 'multiple', | |||
}} | |||
rowKey="id" | |||
search={false} | |||
options={{ | |||
setting: { | |||
listsHeight: 400, | |||
@@ -482,9 +482,36 @@ const BomConfig = (props) => { | |||
columns={columnsChoose} | |||
rowSelection={{ | |||
type: 'checkbox', | |||
onSelect: (record, selected) => { | |||
const currentSelectedRows = JSON.parse(JSON.stringify(selectedRows)); | |||
const currentSelectedRowKeys = JSON.parse(JSON.stringify(selectedRowKeys)); | |||
const findRowIndex = currentSelectedRows.findIndex(item => item.id === record.id); | |||
const findKeysIndex = currentSelectedRowKeys.findIndex(item => item === record.id); | |||
if (selected) { | |||
if (findRowIndex < 0) { | |||
currentSelectedRows.push(record); | |||
} | |||
if (findKeysIndex < 0) { | |||
currentSelectedRowKeys.push(record.id); | |||
} | |||
} else { | |||
if (findRowIndex > -1) { | |||
currentSelectedRows.splice(findRowIndex, 1); | |||
} | |||
if (findKeysIndex > -1) { | |||
currentSelectedRowKeys.splice(findKeysIndex, 1); | |||
} | |||
} | |||
setSetSelectedRows(currentSelectedRows); | |||
setSelectRowKeys(currentSelectedRowKeys); | |||
}, | |||
onChange: (selectedRowKeys, selectedRows) => { | |||
setSelectRowKeys(selectedRowKeys); | |||
setSetSelectedRows(selectedRows); | |||
if (selectedRowKeys.length === 0) { | |||
setSelectRowKeys([]); | |||
} | |||
if (selectedRows.length === 0) { | |||
setSetSelectedRows([]); | |||
} | |||
}, | |||
selectedRowKeys: selectedRowKeys | |||
}} | |||
@@ -1,121 +1,86 @@ | |||
import React, { useState, useEffect, useRef } from 'react'; | |||
import ReactDOM from 'react-dom'; | |||
import { OrganizationGraph } from '@ant-design/graphs'; | |||
import { nanoid } from 'nanoid' | |||
import quickAPI from "../../service"; | |||
import indexStyles from "../../index.less"; | |||
import { message } from 'antd'; | |||
/** | |||
* 确认配置 | |||
* @returns | |||
*/ | |||
const ConfirmConfig = (props) => { | |||
const data = { | |||
id: 'root', | |||
const [orgData, setOrgData] = useState({ | |||
// 门店 | |||
id: props.storeConfig.id, | |||
value: { | |||
name: '股东会', | |||
name: props.storeConfig.name, | |||
}, | |||
// 设备 | |||
children: [ | |||
{ | |||
id: 'joel', | |||
id: props.deviceConfig.id, | |||
value: { | |||
name: 'Joel Alan', | |||
name: props.deviceConfig.deviceName, | |||
}, | |||
children: [ | |||
{ | |||
id: 'c1', | |||
value: { | |||
name: 'c1', | |||
}, | |||
children: [ | |||
{ | |||
id: 'c1-1', | |||
value: { | |||
name: 'c1-1', | |||
}, | |||
}, | |||
{ | |||
id: 'c1-2', | |||
value: { | |||
name: 'c1-2', | |||
}, | |||
children: [ | |||
{ | |||
id: 'c1-2-1', | |||
value: { | |||
name: 'c1-2-1', | |||
}, | |||
}, | |||
{ | |||
id: 'c1-2-2', | |||
value: { | |||
name: 'c1-2-2', | |||
}, | |||
}, | |||
], | |||
}, | |||
], | |||
}, | |||
{ | |||
id: 'c2', | |||
value: { | |||
name: 'c2', | |||
}, | |||
//菜谱 | |||
children: [] | |||
} | |||
] | |||
}); | |||
const initOrgData = () => { | |||
const tempData = JSON.parse(JSON.stringify(orgData)); | |||
props.foodMenuConfig.forEach((foodMenu, foodMenuIndex) => { | |||
tempData.children[0].children[foodMenuIndex] = { | |||
id: nanoid(), | |||
value: { | |||
name: foodMenu.name, | |||
}, | |||
children: [] | |||
} | |||
foodMenu?.goodsConfig.forEach((foodItem, foodIndex) => { | |||
tempData.children[0].children[foodMenuIndex].children[foodIndex] = { | |||
id: nanoid(), | |||
value: { | |||
name: foodItem.name, | |||
}, | |||
{ | |||
id: 'c3', | |||
children: [] | |||
} | |||
foodItem?.bomConfig.forEach((bomItem, bomIndex) => { | |||
tempData.children[0].children[foodMenuIndex].children[foodIndex].children[bomIndex] = { | |||
id: nanoid(), | |||
value: { | |||
name: 'c3', | |||
name: bomItem.name, | |||
}, | |||
children: [ | |||
{ | |||
id: 'c3-1', | |||
value: { | |||
name: 'c3-1', | |||
}, | |||
}, | |||
{ | |||
id: 'c3-2', | |||
value: { | |||
name: 'c3-2', | |||
}, | |||
children: [ | |||
{ | |||
id: 'c3-2-1', | |||
value: { | |||
name: 'c3-2-1', | |||
}, | |||
}, | |||
{ | |||
id: 'c3-2-2', | |||
value: { | |||
name: 'c3-2-2', | |||
}, | |||
}, | |||
{ | |||
id: 'c3-2-3', | |||
value: { | |||
name: 'c3-2-3', | |||
}, | |||
}, | |||
], | |||
}, | |||
{ | |||
id: 'c3-3', | |||
value: { | |||
name: 'c3-3', | |||
}, | |||
}, | |||
], | |||
}, | |||
], | |||
}, | |||
], | |||
}; | |||
children: [] | |||
} | |||
bomItem?.materialConfig.forEach((materialItem, materialIndex) => { | |||
tempData.children[0].children[foodMenuIndex].children[foodIndex].children[bomIndex].children[materialIndex] = { | |||
id: nanoid(), | |||
value: { | |||
name: materialItem.name, | |||
} | |||
} | |||
}); | |||
}); | |||
}); | |||
}); | |||
setOrgData(tempData); | |||
} | |||
useEffect(() => { | |||
initOrgData(); | |||
}, []); | |||
return <> | |||
<OrganizationGraph style={{ width: '100%', height: 'auto' }} data={orgData} behaviors={['drag-canvas', 'zoom-canvas']} nodeCfg={{ autoWidth: true }} /> | |||
</> | |||
} | |||
@@ -745,9 +745,36 @@ const GoodsConfig = (props) => { | |||
columns={columnsChoose} | |||
rowSelection={{ | |||
type: 'checkbox', | |||
onSelect: (record, selected) => { | |||
const currentSelectedRows = JSON.parse(JSON.stringify(selectedRows)); | |||
const currentSelectedRowKeys = JSON.parse(JSON.stringify(selectedRowKeys)); | |||
const findRowIndex = currentSelectedRows.findIndex(item => item.id === record.id); | |||
const findKeysIndex = currentSelectedRowKeys.findIndex(item => item === record.id); | |||
if (selected) { | |||
if (findRowIndex < 0) { | |||
currentSelectedRows.push(record); | |||
} | |||
if (findKeysIndex < 0) { | |||
currentSelectedRowKeys.push(record.id); | |||
} | |||
} else { | |||
if (findRowIndex > -1) { | |||
currentSelectedRows.splice(findRowIndex, 1); | |||
} | |||
if (findKeysIndex > -1) { | |||
currentSelectedRowKeys.splice(findKeysIndex, 1); | |||
} | |||
} | |||
setSetSelectedRows(currentSelectedRows); | |||
setSelectRowKeys(currentSelectedRowKeys); | |||
}, | |||
onChange: (selectedRowKeys, selectedRows) => { | |||
setSelectRowKeys(selectedRowKeys); | |||
setSetSelectedRows(selectedRows); | |||
if (selectedRowKeys.length === 0) { | |||
setSelectRowKeys([]); | |||
} | |||
if (selectedRows.length === 0) { | |||
setSetSelectedRows([]); | |||
} | |||
}, | |||
selectedRowKeys: selectedRowKeys | |||
}} | |||
@@ -202,6 +202,11 @@ const MaterialConfig = (props) => { | |||
], | |||
}, | |||
}, | |||
{ | |||
title: '物料数量', | |||
dataIndex: 'BomQty', | |||
width: 50 | |||
}, | |||
{ | |||
title: '操作', | |||
dataIndex: 'option', | |||
@@ -218,6 +223,13 @@ const MaterialConfig = (props) => { | |||
}} | |||
> | |||
移除物料 | |||
</a>, | |||
<a key="primary3" | |||
type="primary" style={{ marginLeft: '10px' }} onClick={() => { | |||
editMaterialForm.setFieldsValue(record); | |||
setIsModalEditMaterial(true); | |||
}}> | |||
设置数量 | |||
</a> | |||
], | |||
}, | |||
@@ -256,7 +268,11 @@ const MaterialConfig = (props) => { | |||
} | |||
const findBom = bomDropDown.find(item => item.id === currentSelectedBom); | |||
if (findBom) { | |||
props.onMaterialRelationBom(findBom.id, selectedRows); | |||
const temp = JSON.parse(JSON.stringify(selectedRows)); | |||
temp.forEach(item => { | |||
item.BomQty = 0; | |||
}); | |||
props.onMaterialRelationBom(findBom.id, temp); | |||
setSelectRowKeys([]); | |||
setSetSelectedRows([]); | |||
} | |||
@@ -271,6 +287,12 @@ const MaterialConfig = (props) => { | |||
} | |||
} | |||
/** | |||
* 更新物料信息 | |||
*/ | |||
const [isModalEditMaterial, setIsModalEditMaterial] = useState(false); | |||
const [editMaterialForm] = Form.useForm(); | |||
useEffect(() => { | |||
onFetchMaterialTypeList(); | |||
onFetchMaterialUnit(); | |||
@@ -630,7 +652,7 @@ const MaterialConfig = (props) => { | |||
</Form> | |||
</Modal> | |||
<Drawer width={800} title="物料关联配方" placement="right" onClose={() => setShowMenuDrawer(false)} visible={showMenuDrawer}> | |||
<Drawer width={900} title="物料关联配方" placement="right" onClose={() => setShowMenuDrawer(false)} visible={showMenuDrawer}> | |||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: '10px' }}> | |||
<div className={indexStyles.current_selected_obj}> | |||
当前配方: | |||
@@ -683,9 +705,36 @@ const MaterialConfig = (props) => { | |||
columns={columnsChoose} | |||
rowSelection={{ | |||
type: 'checkbox', | |||
onSelect: (record, selected) => { | |||
const currentSelectedRows = JSON.parse(JSON.stringify(selectedRows)); | |||
const currentSelectedRowKeys = JSON.parse(JSON.stringify(selectedRowKeys)); | |||
const findRowIndex = currentSelectedRows.findIndex(item => item.id === record.id); | |||
const findKeysIndex = currentSelectedRowKeys.findIndex(item => item === record.id); | |||
if (selected) { | |||
if (findRowIndex < 0) { | |||
currentSelectedRows.push(record); | |||
} | |||
if (findKeysIndex < 0) { | |||
currentSelectedRowKeys.push(record.id); | |||
} | |||
} else { | |||
if (findRowIndex > -1) { | |||
currentSelectedRows.splice(findRowIndex, 1); | |||
} | |||
if (findKeysIndex > -1) { | |||
currentSelectedRowKeys.splice(findKeysIndex, 1); | |||
} | |||
} | |||
setSetSelectedRows(currentSelectedRows); | |||
setSelectRowKeys(currentSelectedRowKeys); | |||
}, | |||
onChange: (selectedRowKeys, selectedRows) => { | |||
setSelectRowKeys(selectedRowKeys); | |||
setSetSelectedRows(selectedRows); | |||
if (selectedRowKeys.length === 0) { | |||
setSelectRowKeys([]); | |||
} | |||
if (selectedRows.length === 0) { | |||
setSetSelectedRows([]); | |||
} | |||
}, | |||
selectedRowKeys: selectedRowKeys | |||
}} | |||
@@ -694,7 +743,67 @@ const MaterialConfig = (props) => { | |||
</div> | |||
<Button className={indexStyles.sure_add_btn} type='primary' onClick={onMaterialRelationBom}>确定关联</Button> | |||
</Drawer> | |||
<Modal title="设置物料数量" visible={isModalEditMaterial} footer={null} onCancel={() => setIsModalEditMaterial(false)}> | |||
<Form | |||
form={editMaterialForm} | |||
name="basic" | |||
labelCol={{ | |||
span: 8, | |||
}} | |||
wrapperCol={{ | |||
span: 16, | |||
}} | |||
initialValues={{ | |||
remember: true, | |||
}} | |||
onFinish={(values) => { | |||
props.onUpdateMaterial(currentSelectedBom, values); | |||
setIsModalEditMaterial(false); | |||
}} | |||
autoComplete="off" | |||
> | |||
<Form.Item name="id" hidden={true}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item | |||
label="物料名称" | |||
name="name" | |||
rules={[ | |||
{ | |||
required: true, | |||
message: '请输入物料名称', | |||
}, | |||
]} | |||
> | |||
<Input disabled /> | |||
</Form.Item> | |||
<Form.Item | |||
label="物料数量" | |||
name="BomQty" | |||
rules={[ | |||
{ | |||
required: true, | |||
message: '请输入物料数量', | |||
}, | |||
]} | |||
> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item | |||
wrapperCol={{ | |||
offset: 8, | |||
span: 16, | |||
}} | |||
> | |||
<Button type="primary" htmlType="submit"> | |||
确定 | |||
</Button> | |||
</Form.Item> | |||
</Form> | |||
</Modal> | |||
</> | |||
} | |||
@@ -1,6 +1,8 @@ | |||
import { Button } from 'antd'; | |||
import styles from "./index.less"; | |||
import { notification } from 'antd'; | |||
import quickAPI from "../../service"; | |||
const StepsButton = (props) => { | |||
const onClickNext = () => { | |||
@@ -84,8 +86,17 @@ const StepsButton = (props) => { | |||
}); | |||
return; | |||
} | |||
for(let n = 0; n < materialList.length; n++) { | |||
if (!materialList[n].BomQty) { | |||
notification.error({ | |||
message: '物料配置出错', | |||
description: `请为物料【${materialList[n].name}】设置数量!`, | |||
placement: 'topRight' | |||
}); | |||
return; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
props.next(); | |||
@@ -93,6 +104,56 @@ const StepsButton = (props) => { | |||
} | |||
} | |||
const onCreateConfig = async () => { | |||
const jsonData = { | |||
storeId: props.storeConfig.id, | |||
deviceId: props.deviceConfig.id, | |||
foodMenuList: [] | |||
}; | |||
props.foodMenuConfig.forEach((foodMenu, foodMenuIndex) => { | |||
jsonData.foodMenuList[foodMenuIndex] = { | |||
id: foodMenu.id, | |||
goodsList: [] | |||
} | |||
foodMenu?.goodsConfig.forEach((foodItem, foodIndex) => { | |||
jsonData.foodMenuList[foodMenuIndex].goodsList[foodIndex] = { | |||
id: foodItem.id, | |||
price: foodItem.price, | |||
vipPrice: foodItem.vipPrice, | |||
isdevice: true, | |||
BOMList: [] | |||
} | |||
foodItem?.bomConfig.forEach((bomItem, bomIndex) => { | |||
jsonData.foodMenuList[foodMenuIndex].goodsList[foodIndex].BOMList[bomIndex] = { | |||
id: bomItem.id, | |||
BatchingList: [] | |||
} | |||
bomItem?.materialConfig.forEach((materialItem, materialIndex) => { | |||
jsonData.foodMenuList[foodMenuIndex].goodsList[foodIndex].BOMList[bomIndex].BatchingList[materialIndex] = { | |||
id: materialItem.id, | |||
BomQty: materialItem.BomQty | |||
} | |||
}); | |||
}); | |||
}); | |||
}); | |||
const response = await quickAPI.QuickStartAdd(jsonData); | |||
if (response.data.isSuccess) { | |||
notification.success({ | |||
message: '快速开始', | |||
description: '配置成功!', | |||
placement: 'topRight' | |||
}); | |||
props.success(); | |||
} else { | |||
notification.error({ | |||
message: '快速开始', | |||
description: '配置失败!请重试!', | |||
placement: 'topRight' | |||
}); | |||
} | |||
} | |||
return <div className={styles.steps_btns}> | |||
{props.current > 0 && ( | |||
<Button | |||
@@ -112,7 +173,7 @@ const StepsButton = (props) => { | |||
)} | |||
{props.current === props.steps.length - 1 && ( | |||
<Button type="primary"> | |||
<Button type="primary" onClick={onCreateConfig}> | |||
创建配置 | |||
</Button> | |||
)} | |||
@@ -1,4 +1,4 @@ | |||
import { Steps, Card, message } from 'antd'; | |||
import { Steps, Card, Result, Button } from 'antd'; | |||
import React, { useState, useEffect } from 'react'; | |||
import styles from "./index.less"; | |||
import { PageContainer } from '@ant-design/pro-layout'; | |||
@@ -14,7 +14,7 @@ import StepsButton from "./components/StepsButton"; | |||
const { Step } = Steps; | |||
const QuickStart = () => { | |||
const [isSuccess, setIsSuccess] = useState(false); | |||
const [current, setCurrent] = useState(0); | |||
const [quickStartObj, setQuickStartObj] = useState({ | |||
storeConfig: {}, | |||
@@ -93,6 +93,27 @@ const QuickStart = () => { | |||
}); | |||
} | |||
/** | |||
* 更新物料信息 | |||
* @param {*} bomId | |||
* @param {*} material | |||
*/ | |||
const onUpdateMaterial = (bomId, material) => { | |||
const tempQuick = JSON.parse(JSON.stringify(quickStartObj)); | |||
tempQuick.foodMenuConfig.forEach(findFoodMenu => { | |||
findFoodMenu.goodsConfig.forEach(findGoods => { | |||
const findBom = findGoods.bomConfig.find(item => item.id === bomId); | |||
if (findBom) { | |||
const findMaterial = findBom.materialConfig.find(materialItem => materialItem.id === material.id); | |||
if (findMaterial) { | |||
findMaterial.BomQty = Number.parseFloat(material.BomQty) || 0; | |||
setQuickStartObj(tempQuick); | |||
} | |||
} | |||
}); | |||
}); | |||
} | |||
//下一步 | |||
const next = () => { | |||
setCurrent(current + 1); | |||
@@ -108,18 +129,15 @@ const QuickStart = () => { | |||
const stepsContent = [ | |||
<StoreConfig storeConfig={quickStartObj.storeConfig} current={current} steps={stepsText} next={next} onSelectedChange={onSelectedChange}></StoreConfig>, | |||
<DeviceConfig storeConfig={quickStartObj.storeConfig} deviceConfig={quickStartObj.deviceConfig} current={current} steps={stepsText} prev={prev} next={next} onSelectedChange={onSelectedChange} ></DeviceConfig>, | |||
<FoodMenuConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} prev={prev} next={next} onSelectedChange={onSelectedChange}></FoodMenuConfig>, | |||
<FoodMenuConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} prev={prev} next={next} onSelectedChange={onSelectedChange}></FoodMenuConfig>, | |||
<GoodsConfig deviceConfig={quickStartObj.deviceConfig} foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} onAddGoodsToFoodMenu={onAddGoodsToFoodMenu} prev={prev} next={next} ></GoodsConfig>, | |||
<BomConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} prev={prev} next={next} onBomRelationGoods={onBomRelationGoods}></BomConfig>, | |||
<MaterialConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} onMaterialRelationBom={onMaterialRelationBom} prev={prev} next={next}></MaterialConfig>, | |||
<ConfirmConfig quickStartObj={quickStartObj} current={current} steps={stepsText} prev={prev}></ConfirmConfig> | |||
<MaterialConfig foodMenuConfig={quickStartObj.foodMenuConfig} current={current} steps={stepsText} onMaterialRelationBom={onMaterialRelationBom} onUpdateMaterial={onUpdateMaterial} prev={prev} next={next}></MaterialConfig>, | |||
<ConfirmConfig {...quickStartObj} current={current} steps={stepsText} prev={prev} ></ConfirmConfig> | |||
]; | |||
useEffect(() => { | |||
if (current > 4) { | |||
console.log('终极JSON对象:', JSON.stringify(quickStartObj)); | |||
} | |||
console.log('JSON对象更新啦', quickStartObj); | |||
console.log('对象更新', quickStartObj) | |||
}, [quickStartObj]); | |||
return <PageContainer> | |||
@@ -133,15 +151,41 @@ const QuickStart = () => { | |||
</Card> | |||
</div> | |||
<Card> | |||
<div className={styles.steps_content}>{stepsContent[current]}</div> | |||
</Card> | |||
<div className={styles.steps_navbar_bottom}> | |||
<Card> | |||
<StepsButton {...quickStartObj} current={current} steps={stepsText} prev={prev} next={next}></StepsButton> | |||
</Card> | |||
</div> | |||
{ | |||
isSuccess ? | |||
<Card> | |||
<Result | |||
status="success" | |||
title="成功配置所有信息!" | |||
subTitle="欢迎再次使用!" | |||
extra={[ | |||
<Button type="primary" key="console" onClick={() => { | |||
setQuickStartObj({ | |||
storeConfig: {}, | |||
deviceConfig: {}, | |||
foodMenuConfig: [], | |||
}) | |||
setCurrent(0); | |||
setIsSuccess(false); | |||
}}> | |||
快速开始 | |||
</Button> | |||
]} | |||
/> | |||
</Card> | |||
: | |||
<> | |||
<Card> | |||
<div className={styles.steps_content}>{stepsContent[current]}</div> | |||
</Card> | |||
<div className={styles.steps_navbar_bottom}> | |||
<Card> | |||
<StepsButton {...quickStartObj} current={current} steps={stepsText} prev={prev} next={next} success={() => setIsSuccess(true)}></StepsButton> | |||
</Card> | |||
</div> | |||
</> | |||
} | |||
</PageContainer> | |||
} | |||
@@ -399,6 +399,12 @@ export default { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
}, | |||
QuickStartAdd(data) { | |||
return request('/kitchen/api/quickstart/add', { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
} | |||
} |