diff --git a/src/pages/card/memberAccount/index.jsx b/src/pages/card/memberAccount/index.jsx index 4d2e66a..0a73191 100644 --- a/src/pages/card/memberAccount/index.jsx +++ b/src/pages/card/memberAccount/index.jsx @@ -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 } 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) => [ onFetchAccountConsRecord(record, -1)}>账户消费记录, - onFetchAccountConsRecord(record, 1)}>账户充值记录, + // onFetchAccountConsRecord(record, 1)}>账户充值记录, ], }, ]; @@ -175,7 +202,7 @@ const memberAccount = () => { key: 'option', render: (text, record) => [ onFetchCardConsRecord(record, -1)}>会员卡消费记录, - onFetchCardConsRecord(record, 1)}>会员卡充值记录, + // onFetchCardConsRecord(record, 1)}>会员卡充值记录, ], } ]; @@ -201,33 +228,33 @@ const memberAccount = () => { } }, - { - title: '之前余额', - dataIndex: 'beforeMoney', - render: (_, record) => { - return
- {record.beforeMoney} -
- } - }, - { - title: '消费金额', - dataIndex: 'money', - render: (_, record) => { - return
- {record.money} -
- } - }, - { - title: '之后余额', - dataIndex: 'afterMoney', - render: (_, record) => { - return
- {record.afterMoney} -
- } - } + // { + // title: '之前余额', + // dataIndex: 'beforeMoney', + // render: (_, record) => { + // return
+ // {record.beforeMoney} + //
+ // } + // }, + // { + // title: '消费金额', + // dataIndex: 'money', + // render: (_, record) => { + // return
+ // {record.money} + //
+ // } + // }, + // { + // title: '之后余额', + // dataIndex: 'afterMoney', + // render: (_, record) => { + // return
+ // {record.afterMoney} + //
+ // } + // } ]; useEffect(() => { @@ -243,17 +270,35 @@ const memberAccount = () => {
消费次数{expendTotalCount},消费人数{personTotalcCount}
} 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="储值卡账户管理" /> - {setIsModalOpen(false); setConsCurrent(1)}}> + { setIsModalOpen(false); setConsCurrent(1) }}> { 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 } 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, diff --git a/src/pages/quickStart/components/BomConfig/index.jsx b/src/pages/quickStart/components/BomConfig/index.jsx index f400b97..ece69cd 100644 --- a/src/pages/quickStart/components/BomConfig/index.jsx +++ b/src/pages/quickStart/components/BomConfig/index.jsx @@ -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 }} diff --git a/src/pages/quickStart/components/ConfirmConfig/index.jsx b/src/pages/quickStart/components/ConfirmConfig/index.jsx index 259235b..24ef9d5 100644 --- a/src/pages/quickStart/components/ConfirmConfig/index.jsx +++ b/src/pages/quickStart/components/ConfirmConfig/index.jsx @@ -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 <> + } diff --git a/src/pages/quickStart/components/GoodsConfig/index.jsx b/src/pages/quickStart/components/GoodsConfig/index.jsx index 69cda87..94cd8f1 100644 --- a/src/pages/quickStart/components/GoodsConfig/index.jsx +++ b/src/pages/quickStart/components/GoodsConfig/index.jsx @@ -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 }} diff --git a/src/pages/quickStart/components/MaterialConfig/index.jsx b/src/pages/quickStart/components/MaterialConfig/index.jsx index 8c578cf..1aae0a5 100644 --- a/src/pages/quickStart/components/MaterialConfig/index.jsx +++ b/src/pages/quickStart/components/MaterialConfig/index.jsx @@ -202,6 +202,11 @@ const MaterialConfig = (props) => { ], }, }, + { + title: '物料数量', + dataIndex: 'BomQty', + width: 50 + }, { title: '操作', dataIndex: 'option', @@ -218,6 +223,13 @@ const MaterialConfig = (props) => { }} > 移除物料 + , + { + editMaterialForm.setFieldsValue(record); + setIsModalEditMaterial(true); + }}> + 设置数量 ], }, @@ -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) => { - setShowMenuDrawer(false)} visible={showMenuDrawer}> + setShowMenuDrawer(false)} visible={showMenuDrawer}>
当前配方: @@ -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) => {
+ setIsModalEditMaterial(false)}> +
{ + props.onUpdateMaterial(currentSelectedBom, values); + setIsModalEditMaterial(false); + }} + autoComplete="off" + > + + + + + + + + + + + + + +
} diff --git a/src/pages/quickStart/components/StepsButton/index.jsx b/src/pages/quickStart/components/StepsButton/index.jsx index 69ba52d..dced2c5 100644 --- a/src/pages/quickStart/components/StepsButton/index.jsx +++ b/src/pages/quickStart/components/StepsButton/index.jsx @@ -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
{props.current > 0 && ( )} diff --git a/src/pages/quickStart/index.jsx b/src/pages/quickStart/index.jsx index f8ce716..7b3edb2 100644 --- a/src/pages/quickStart/index.jsx +++ b/src/pages/quickStart/index.jsx @@ -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 = [ , , - , + , , , - , - + , + ]; useEffect(() => { - if (current > 4) { - console.log('终极JSON对象:', JSON.stringify(quickStartObj)); - } - console.log('JSON对象更新啦', quickStartObj); + console.log('对象更新', quickStartObj) }, [quickStartObj]); return @@ -133,15 +151,41 @@ const QuickStart = () => {
- -
{stepsContent[current]}
-
- -
- - - -
+ { + isSuccess ? + + { + setQuickStartObj({ + storeConfig: {}, + deviceConfig: {}, + foodMenuConfig: [], + }) + setCurrent(0); + setIsSuccess(false); + }}> + 快速开始 + + ]} + /> + + : + <> + +
{stepsContent[current]}
+
+ +
+ + setIsSuccess(true)}> + +
+ + } } diff --git a/src/pages/quickStart/service.js b/src/pages/quickStart/service.js index 085a466..0f24e73 100644 --- a/src/pages/quickStart/service.js +++ b/src/pages/quickStart/service.js @@ -399,6 +399,12 @@ export default { method: 'POST', data: data, }); - } + }, + QuickStartAdd(data) { + return request('/kitchen/api/quickstart/add', { + method: 'POST', + data: data, + }); + } } \ No newline at end of file