diff --git a/config/routes.js b/config/routes.js index a072a0c..6dbd453 100644 --- a/config/routes.js +++ b/config/routes.js @@ -166,10 +166,17 @@ export default [ access: 'k7', }, { - name: '配方下发', + name: '小炒工序', icon: 'smile', - path: '/bom/push', - component: './bom/push', + path: '/bom/cookingwork', + component: './bom/cookingwork', + access: 'k8', + }, + { + name: '机械臂,炒锅配置', + icon: 'smile', + path: '/bom/cookingentry', + component: './bom/cookingentry', access: 'k8', }, ], @@ -358,6 +365,13 @@ export default [ component: './device/deviceFood', access: 'k14', }, + { + name: '小炒', + icon: 'smile', + path: '/device/deviceStirFryTime', + component: './device/deviceStirFryTime', + access: 'k14', + }, { code: 'deviceBOM', name: '设备配方管理', diff --git a/src/app.jsx b/src/app.jsx index 93c794e..f1440a1 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -70,6 +70,14 @@ export async function getInitialState() { component: './device/deviceFood', access: 'k14', }, + { + code: 'deviceStirFryTime', + name: '小炒', + icon: 'smile', + path: '/device/deviceStirFryTime', + component: './device/deviceStirFryTime', + access: 'k14', + }, { code: 'deviceBOM', name: '设备配方管理', @@ -238,6 +246,14 @@ export async function getInitialState() { component: './bom/bomtype', access: 'k7', }, + { + code: 'cookingwork', + name: '小炒工序', + icon: 'smile', + path: '/bom/cookingwork', + component: './bom/cookingwork', + access: 'k7', + }, ], }, { diff --git a/src/pages/bom/cookingentry/components/CreateForm.jsx b/src/pages/bom/cookingentry/components/CreateForm.jsx new file mode 100644 index 0000000..ed02421 --- /dev/null +++ b/src/pages/bom/cookingentry/components/CreateForm.jsx @@ -0,0 +1,77 @@ +import React, { useState, useEffect } from 'react'; +import { Modal, Form, Input, Button, Select, InputNumber } from 'antd'; +import api from '../services'; +const CreateForm = (props) => { + const { Option, OptGroup } = Select; + const [options, setoptions] = useState(); + //每次触发 + useEffect(() => { + const initoptions = async (value) => { + var data = await api.getStirFryArray("stirfrytime"); + if (data != undefined) { + setoptions(data.data); + } + }; + initoptions(); + }, []); + return ( + { + props.onCancel(); + }} + destroyOnClose + > +
+ + + + + + + + + + 注: 持续时间(s),若为0,则等待该流程走完结束 + + + + +
+
+ ); +}; + +export default CreateForm; diff --git a/src/pages/bom/cookingentry/components/PotActions.jsx b/src/pages/bom/cookingentry/components/PotActions.jsx new file mode 100644 index 0000000..f37f548 --- /dev/null +++ b/src/pages/bom/cookingentry/components/PotActions.jsx @@ -0,0 +1,137 @@ +import React, { useState, useEffect } from 'react'; +import { + InputNumber, + Row, + Col, + Switch, + Checkbox, + Space, + Steps, + message, + Modal, + Form, + Input, + Button, + Select, + DatePicker, + Upload +} from 'antd'; +import { MinusCircleOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons'; +import api from '../services'; +const PotActions = (props) => { + + const { Option, OptGroup } = Select; + const [options, setoptions] = useState(); + + const [options11, setoptions11] = useState({potActions:[]}); + //每次触发 + useEffect(() => { + const initoptions = async (value) => { + var data = await api.getStirFryArray("stirfrypotaction"); + if (data != undefined) { + setoptions(data.data); + } + }; + initoptions(); + }, []); + + return ( + { + props.onCancel(); + }} + //关闭时销毁 Modal 里的子元素 + destroyOnClose={true} + > +
+ + + + prevValues.activityType !== currentValues.activityType + } > + {({ getFieldValue }) => + ( + + {(fields, { add, remove }) => ( + <> + {fields?.map(({ key, name, fieldKey, ...restField }, index) => ( + + + { + + } + + + remove(name)} /> + + )) + } + + + + + )} + + + + ) + } + + + + + + +
+
+ ); +}; + +export default PotActions; diff --git a/src/pages/bom/cookingentry/components/RobotActions.jsx b/src/pages/bom/cookingentry/components/RobotActions.jsx new file mode 100644 index 0000000..b98bc67 --- /dev/null +++ b/src/pages/bom/cookingentry/components/RobotActions.jsx @@ -0,0 +1,138 @@ +import React, { useState, useEffect } from 'react'; +import { + InputNumber, + Row, + Col, + Switch, + Checkbox, + Space, + Steps, + message, + Modal, + Form, + Input, + Button, + Select, + DatePicker, + Upload +} from 'antd'; +import { MinusCircleOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons'; + +import api from '../services'; +const RobotActions = (props) => { + + const { Option, OptGroup } = Select; + const [options, setoptions] = useState(); + //每次触发 + useEffect(() => { + const initoptions = async (value) => { + var data = await api.getStirFryArray("sirfryrobotaction"); + if (data != undefined) { + setoptions(data.data); + } + }; + initoptions(); + }, []); + + + return ( + { + props.onCancel(); + }} + //关闭时销毁 Modal 里的子元素 + destroyOnClose={true} + > +
+ + + + prevValues.activityType !== currentValues.activityType + } > + {({ getFieldValue }) => + ( + + + {(fields, { add, remove }) => ( + <> + {fields?.map(({ key, name, fieldKey, ...restField },index) => ( + + + { + + } + + + remove(name)} /> + + )) + } + + + + + )} + + + + ) + } + + + + + + +
+
+ ); +}; + +export default RobotActions; diff --git a/src/pages/bom/cookingentry/index.jsx b/src/pages/bom/cookingentry/index.jsx new file mode 100644 index 0000000..02d6371 --- /dev/null +++ b/src/pages/bom/cookingentry/index.jsx @@ -0,0 +1,330 @@ +import { PlusOutlined } from '@ant-design/icons'; +import { Button, message, Input, Drawer, Modal, 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 CreateForm from './components/CreateForm'; +import PotActions from './components/PotActions'; +import RobotActions from './components/RobotActions'; +import api from './services'; + +//页面 相当于 class +/** + * 添加节点 + * + * @param fields + */ +const handleAdd = async (fields) => { + try { + api.addupdate(JSON.stringify(fields)).then((r) => { + if (r.data) { + message.success('添加成功'); + } else { + message.error('添加失败请重试!'); + } + }); + return true; + } catch (error) { + message.error('添加失败请重试!'); + return false; + } +} +/** + * 批量删除节点 + * + * @param selectedRows + */ +const handleRemove = async (fields) => { + try { + api.delete(fields.id).then((r) => { + if (r.data) { + message.success('删除成功,即将刷新'); + } else { + message.error('删除失败,请重试'); + } + }); + return true; + } catch (error) { + message.error('删除失败,请重试'); + } +} + +/** + * 更新节点 + * + * @param fields + */ + +const handlePotUpdate = async (fields) => { + try { + api.UpdatePot(fields).then((r) => { + if (r.data) { + message.success('修改成功'); + } else { + message.error('修改失败请重试!'); + } + }); + return true; + } catch (error) { + message.error('修改失败请重试!'); + return false; + } +} +const handleRobotUpdate = async (fields) => { + try { + api.UpdateRobot(fields).then((r) => { + if (r.data) { + message.success('修改成功'); + } else { + message.error('修改失败请重试!'); + } + }); + return true; + } catch (error) { + message.error('修改失败请重试!'); + return false; + } +} +const handleUpdate = async (fields) => { + try { + api.addupdate(fields).then((r) => { + if (r.data) { + message.success('修改成功'); + } else { + message.error('修改失败请重试!'); + } + }); + return true; + } catch (error) { + message.error('修改失败请重试!'); + return false; + } +} +const cookingwork = (props) => { + const [values, setUrl] = useState(props.location.query.values ? props.location.query.values : null); + /** 新建/更新窗口的弹窗 */ + const [createModalVisible, handleModalVisible] = useState(false); + /** 分布更新窗口的弹窗 */ + const [createPotActionsModalVisible, handlePotActionsModalVisible] = useState(false); + const [createRobotActionsModalVisible, handleRobotActionsModalVisible] = useState(false); + //绑定 + const actionRef = useRef(); + const [currentRow, setCurrentRow] = useState(); + const [selectedRowsState, setSelectedRows] = useState([]); + // 监控数据变化 + useEffect(() => { + }, []); + + /** 国际化配置 */ + + const columns = [ + { + title: '主键', + dataIndex: 'id', + hideInTable: true, + hideInSearch: true, + }, + { + title: '步骤名称', + dataIndex: 'fryTime', + hideInForm: true, + hideInSearch: true, + }, + { + title: '持续时间(秒)', + dataIndex: 'during', + hideInForm: true, + hideInSearch: true, + }, + + + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + render: (_, record) => [ + { + handleModalVisible(true); + setCurrentRow(record); + }} + > + 修改 + , + { + handleRobotActionsModalVisible(true); + if (typeof (record.robotActions) == 'string') { + record.robotActions = JSON.parse(record.robotActions) + } + setCurrentRow(record); + }} + > + 机器人配置 + , + { + handlePotActionsModalVisible(true); + if (typeof (record.potActions) == 'string') { + record.potActions = JSON.parse(record.potActions) + } + setCurrentRow(record); + }} + > + 炒锅配置 + , + { + handleRemove(record); + actionRef.current?.reloadAndRest(); + }} + onCancel={() => { }} + > + 删除 + , + ], + }, + ]; + + return ( + + [ + , + ]} + //数据绑定 + request={async (params) => { + params.CookingWorkId = props.location.query.values.id; + var data = []; + var total = 0; + await api.getpage(params).then((r) => { + data = r.data.data; + total = r.data.total; + }); + return { + data: data, + success: true, + total: total, + }; + }} + // 每行选择点击事件 + rowSelection={{ + onChange: (_, selectedRows) => { + setSelectedRows(selectedRows); + }, + }} + > + {selectedRowsState?.length > 0 && ( + + 已选择{' '} + + {selectedRowsState.length} + {' '} + 项    + + } + > + + + )} + { + var success = false; + success = await handlePotUpdate(value); + if (success) { + handlePotActionsModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } + }} + onCancel={() => { + setCurrentRow(undefined); + handlePotActionsModalVisible(false); + }} + createModalVisible={createPotActionsModalVisible} + values={currentRow || {}} + /> + { + var success = false; + success = await handleRobotUpdate(value); + if (success) { + handleRobotActionsModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } + }} + onCancel={() => { + setCurrentRow(undefined); + handleRobotActionsModalVisible(false); + }} + createModalVisible={createRobotActionsModalVisible} + values={currentRow || {}} + /> + { + var success = false; + if (value.id) { + success = await handleUpdate(value); + } else { + success = await handleAdd(value); + } + if (success) { + handleModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } + }} + onCancel={() => { + setCurrentRow(undefined); + handleModalVisible(false); + }} + createModalVisible={createModalVisible} + values={currentRow || {}} + /> + + ); +}; + +export default cookingwork; diff --git a/src/pages/bom/cookingentry/services.js b/src/pages/bom/cookingentry/services.js new file mode 100644 index 0000000..082d8ab --- /dev/null +++ b/src/pages/bom/cookingentry/services.js @@ -0,0 +1,42 @@ +// @ts-ignore + +/* eslint-disable */ +import { request } from 'umi'; + +export default { + getpage(data) { + return request(`/kitchen/api/stirFryTime/getpage`, { + method: 'Post', + data: data, + }); + }, + getStirFryArray(data) { + return request(`/kitchen/api/stirFryTime/getStirFryArray?type=`+data, { + method: 'GET', + }); + }, + + addupdate(data) { + return request('/kitchen/api/stirFryTime/AddUpdate', { + method: 'POST', + data: data, + }); + }, + UpdatePot(data) { + return request('/kitchen/api/stirFryTime/UpdatePot', { + method: 'POST', + data: data, + }); + }, + UpdateRobot(data) { + return request('/kitchen/api/stirFryTime/UpdateRobot', { + method: 'POST', + data: data, + }); + }, + delete(data) { + return request('/kitchen/api/stirFryTime/delete?id='+data, { + method: 'GET', + }); + }, +}; diff --git a/src/pages/bom/cookingwork/components/CreateForm.jsx b/src/pages/bom/cookingwork/components/CreateForm.jsx new file mode 100644 index 0000000..d590dfb --- /dev/null +++ b/src/pages/bom/cookingwork/components/CreateForm.jsx @@ -0,0 +1,45 @@ +import React, { useState, useEffect } from 'react'; +import { Modal, Form, Input, Button, Switch,InputNumber } from 'antd'; + +const CreateForm = (props) => { + return ( + { + props.onCancel(); + }} + destroyOnClose + > +
+ + + + + + + + + + + +
+
+ ); +}; + +export default CreateForm; diff --git a/src/pages/bom/cookingwork/index.jsx b/src/pages/bom/cookingwork/index.jsx new file mode 100644 index 0000000..70b4bff --- /dev/null +++ b/src/pages/bom/cookingwork/index.jsx @@ -0,0 +1,280 @@ +import { PlusOutlined } from '@ant-design/icons'; +import { Button, message, Input, Drawer, Modal,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 CreateForm from './components/CreateForm'; +import { history } from 'umi'; +import api from './services'; + +//页面 相当于 class +/** + * 添加节点 + * + * @param fields + */ + const handleAdd = async (fields) => { + try { + api.addupdate(JSON.stringify(fields)).then((r) => { + if (r.data) { + message.success('添加成功'); + } else { + message.error('添加失败请重试!'); + } + }); + return true; + } catch (error) { + message.error('添加失败请重试!'); + return false; + } +} +/** + * 批量删除节点 + * + * @param selectedRows + */ +const handleRemove = async (ids) => { +console.log(ids); + try { + // api.delete(ids).then((r) => { + // if (r.data) { + // message.success('删除成功,即将刷新'); + // } else { + // message.error('删除失败,请重试'); + // } + // }); + return true; + } catch (error) { + message.error('删除失败,请重试'); + } +} + +/** + * 更新节点 + * + * @param fields + */ + +const handleUpdate = async (fields) => { + try { + api.addupdate(fields).then((r) => { + if (r.data) { + message.success('修改成功'); + } else { + message.error('修改失败请重试!'); + } + }); + return true; + } catch (error) { + message.error('修改失败请重试!'); + return false; + } +} +const cookingwork = (props) => { + /** 新建/更新窗口的弹窗 */ + const [createModalVisible, handleModalVisible] = useState(false); + /** 分布更新窗口的弹窗 */ + //绑定 + const actionRef = useRef(); + const [currentRow, setCurrentRow] = useState(); + const [selectedRowsState, setSelectedRows] = useState([]); + // 监控数据变化 + useEffect(() => { + }, []); + + /** 国际化配置 */ + + const columns = [ + { + title: '主键', + dataIndex: 'id', + hideInTable: true, + hideInSearch: true, + }, + { + title: '工序名称', + dataIndex: 'name', + hideInForm: true, + + }, + { + title: '状态', + dataIndex: 'status', + hideInForm: true, + search: false, + valueEnum: { + 0: { + text: '正常', + status: 'Processing', + }, + 1: { + text: '停用', + status: 'Success', + }, + }, + }, + { + title: '工序描述', + dataIndex: 'remark', + hideInForm: true, + hideInSearch: true, + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + render: (_, record) => [ + { + history.push({ + pathname: '/bom/cookingentry', + query: { + isAdd: false, + values:record + }, + }); + }} + > + 配置 + , + { + handleModalVisible(true); + setCurrentRow(record); + }} + > + 更新 + , + + { + record.status = record.status == 0 ? 1 : 0; + handleUpdate(record); + actionRef.current?.reloadAndRest(); + }} + onCancel={() => { }} + >{record.status == 1 ? '启用' : '停用'} + , + { + handleRemove(record); + actionRef.current?.reloadAndRest(); + }} + onCancel={() => { }} + > + 删除 + , + ], + }, + ]; + + return ( + + [ + , + ]} + //数据绑定 + request={async (params) => { + var data = []; + var total = 0; + await api.getpage(params).then((r) => { + data = r.data.data; + total = r.data.total; + }); + return { + data: data, + success: true, + total: total, + }; + }} + // 每行选择点击事件 + rowSelection={{ + onChange: (_, selectedRows) => { + setSelectedRows(selectedRows); + }, + }} + > + {selectedRowsState?.length > 0 && ( + + 已选择{' '} + + {selectedRowsState.length} + {' '} + 项    + + } + > + + + )} + { + var success = false; + if (value.id) { + success = await handleUpdate(value); + } else { + success = await handleAdd(value); + } + if (success) { + handleModalVisible(false); + if (actionRef.current) { + actionRef.current.reload(); + } + } + }} + onCancel={() => { + setCurrentRow(undefined); + handleModalVisible(false); + }} + createModalVisible={createModalVisible} + values={currentRow || {}} + /> + + ); +}; + +export default cookingwork; diff --git a/src/pages/bom/cookingwork/services.js b/src/pages/bom/cookingwork/services.js new file mode 100644 index 0000000..1513456 --- /dev/null +++ b/src/pages/bom/cookingwork/services.js @@ -0,0 +1,25 @@ +// @ts-ignore + +/* eslint-disable */ +import { request } from 'umi'; + +export default { + getpage(data) { + return request(`/kitchen/api/cookingwork/getpage`, { + method: 'Post', + data: data, + }); + }, + addupdate(data) { + return request('/kitchen/api/cookingwork/addupdate', { + method: 'POST', + data: data, + }); + }, + delete(data) { + return request('/kitchen/api/cookingwork/delete', { + method: 'POST', + data: data, + }); + }, +}; diff --git a/src/pages/bom/push/components/CreateForm.jsx b/src/pages/bom/push/components/CreateForm.jsx deleted file mode 100644 index 1980c51..0000000 --- a/src/pages/bom/push/components/CreateForm.jsx +++ /dev/null @@ -1,61 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { Modal, Form, Input, Button, Select, Switch,InputNumber } from 'antd'; - -const CreateForm = (props) => { - const { Option, OptGroup } = Select; - return ( - { - props.onCancel(); - }} - destroyOnClose - > -
- - - - - - - - - - - - - - - - -
-
- ); -}; - -export default CreateForm; diff --git a/src/pages/bom/push/index.jsx b/src/pages/bom/push/index.jsx deleted file mode 100644 index f8054fa..0000000 --- a/src/pages/bom/push/index.jsx +++ /dev/null @@ -1,437 +0,0 @@ -import { PlusOutlined } from '@ant-design/icons'; -import { Button, message, Input, Drawer, Modal } 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 api from './services'; - -const GoodsBomsManage = (props) => { - /** 新建/更新窗口的弹窗 */ - const [createModalVisible, handleModalVisible] = useState(false); - const [BomReplaclVisible, BomReplacVisible] = useState(false); - /** 分布更新窗口的弹窗 */ - const [dicData, setDicData] = useState([]); - const [dicDataAny, setDicDataAny] = useState([]); - const [showDetail, setShowDetail] = useState(false); - const actionRef = useRef(); - const [currentRow, setCurrentRow] = useState(); - const [selectedRowsState, setSelectedRows] = useState([]); - - // //获取商品数据 - const [goods, setgoods] = useState([]); - - //获取原料名称 - const [stockGoods, setstockGoods] = useState([]); - // 监控数据变化 - useEffect(() => { - function initgoods() { - api.goodList({ current: 1, pageSize: 20, status: '0' }).then((r) => { - var arr = r.data.data; - arr.forEach((element) => { - element.text = element.name; - element.goodsId = element.id; - }); - - setgoods(arr); - }); - } - initgoods(); - /** 获取原料名称*/ - function initStockGoods() { - api.postStockGoods().then((r) => { - var arr = r.data; - arr.forEach((element) => { - element.text = element.name; - element.stockGoodsId = element.value; - }); - setstockGoods(arr); - }); - } - initStockGoods(); //回调原料信息 - function intDicData() { - api.GetDicList('BatchingType').then((r) => { - var arr = r.data; - // arr.forEach((element) => { - // //element.text = element.remark; - // // element.batchingTypeId = element.value; - // }); - let data = {}; - if (r.succeeded) { - arr.forEach((item) => { - data[item.value] = { text: item.remark }; - }); - } - setDicDataAny(data); - console.log(arr); - setDicData(arr); - }); - } - intDicData(); - }, []); - - /** - * 添加节点 - * - * @param fields - */ - function handleAdd(fields) { - try { - api.addGoodsBom(JSON.stringify(fields)).then((r) => { - if (r.data) { - message.success('添加成功'); - //刷新数据 - actionRef.current.reload(); - } else { - message.error('添加失败请重试!'); - } - }); - return true; - } catch (error) { - message.error('添加失败请重试!'); - return false; - } - } - /** - * 更新节点 - * - * @param fields - */ - - function handleUpdate(fields) { - console.log(fields); - try { - api - .updateGoodsBom({ - id: fields.id, - goodsID: fields.goods_Id, - stockGoodsCode: fields.stockGoodsCode, - remark: fields.remark, - status: fields.status, - batchingType: fields.batchingType, - isReplace: fields.isReplace, - isMain: fields.isMain, - bomQty: fields.bomQty - }) - .then((r) => { - if (r.data) { - message.success('配置成功'); - } else { - message.error('配置失败请重试!'); - } - //刷新数据 - actionRef.current.reload(); - }); - return true; - } catch (error) { - message.error('配置失败请重试!'); - return false; - } - } - - /** - * 删除节点 - * - * - */ - - function handleRemove() { - if (!selectedRowsState) return true; - try { - api.removeGoodsBom(selectedRowsState.map((row) => row.id)).then((r) => { - if (r.data) { - message.success('删除成功,即将刷新'); - } else { - message.error('删除失败,请重试'); - } - //刷新数据 - actionRef.current.reload(); - }); - return true; - } catch (error) { - message.error('删除失败,请重试'); - return false; - } - } - - /** 国际化配置 */ - - const columns = [ - { - title: '主键', - dataIndex: 'id', - hideInTable: true, - hideInSearch: true, - tip: '规则名称是唯一的 key', - render: (dom, entity) => { - return ( - { - setCurrentRow(entity); - setShowDetail(true); - }} - > - {dom} - - ); - }, - }, - { - title: '原料名称', - dataIndex: 'stockGoodsName', - hideInForm: true, - hideInSearch: true, - }, - { - title: '原料名称', - dataIndex: 'stockGoodsCode', - hideInForm: true, - hideInTable: true, - valueType: 'select', - valueEnum: stockGoods, - }, - { - title: '配料类型', - dataIndex: 'batchingType', - hideInForm: true, - valueEnum: dicDataAny, - }, - { - title: '状态', - dataIndex: 'status', - hideInForm: true, - valueEnum: { - 0: { - text: '正常', - status: 'Processing', - }, - 1: { - text: '停用', - status: 'Error', - }, - 2: { - text: '删除', - status: 'Error', - }, - }, - }, - { - title: '主要原料', - dataIndex: 'isMain', - hideInForm: true, - valueEnum: { - false: { - text: '辅料', - status: 'Processing', - }, - true: { - text: '主料', - status: 'Success', - }, - }, - }, - { - title: '配方用量', - dataIndex: 'bomQty', - hideInSearch: true, - width: 120, - }, - { - title: '是否可以替换', - dataIndex: 'isReplace', - hideInForm: true, - valueEnum: { - false: { - text: '不可替换', - status: 'Processing', - }, - true: { - text: '可替换', - status: 'Success', - }, - }, - }, - - { - title: '创建时间', - dataIndex: 'createAt', - valueType: 'date', - }, - { - title: '操作', - dataIndex: 'option', - valueType: 'option', - render: (_, record) => [ - record.status === '0' && ( - { - record.status = '1'; - handleUpdate(record); - }} - > - 停用 - - ), - (record.status === '1' || record.status === '2') && ( - { - record.status = '0'; - handleUpdate(record); - }} - > - 启用 - - ), - record.status === '0' && record.isReplace && ( - { - record.isReplace = false; - handleUpdate(record); - }} - > - 不启用 - - ), - record.status === '0' && !record.isReplace && ( - { - record.isReplace = true; - handleUpdate(record); - }} - > - 启用替换 - - ), - record.status === '0' && record.isReplace && ( - { - BomReplacVisible(true); - setCurrentRow(record); - }} - > - 替换物料 - - ), - { - handleModalVisible(true); - setCurrentRow(record); - }} - > - 修改 - , - ], - }, - ]; - - return ( - props.onCancel()} - maskClosable={false} - > - [ - , - ]} - //数据绑定 - request={async (params) => { - var goodsBomsData = []; - var total = 0; - //商品编号 - if (props.values.id != undefined) { - params['goodsId'] = props.values.id; - } - await api.goodsBoms(params).then((r) => { - goodsBomsData = r.data.data; - total = r.data.total; - }); - return { - data: goodsBomsData, - success: true, - total: total, - }; - }} - columns={columns} - /> - {/*商品配方(新增,修改) */} - { - var success = false; - value['goodsId'] = props.values.id; - value['goods_Id'] = props.values.id; - if (value.id) { - success = await handleUpdate(value); - } else { - success = await handleAdd(value); - } - if (success) { - handleModalVisible(false); - setCurrentRow(undefined); - - if (actionRef.current) { - actionRef.current.reload(); - } - } - }} - onCancel={() => { - handleModalVisible(false); - setCurrentRow(undefined); - }} - createModalVisible={createModalVisible} - values={currentRow || {}} - /> - {/**物料替换 */} - { - var success = false; - value['goodsId'] = props.values.id; - if (value.id) { - success = await handleUpdate(value); - } else { - success = await handleAdd(value); - } - if (success) { - BomReplacVisible(false); - setCurrentRow(undefined); - - if (actionRef.current) { - actionRef.current.reload(); - } - } - }} - onCancel={() => { - BomReplacVisible(false); - setCurrentRow(undefined); - }} - createModalVisible={BomReplaclVisible} - values={currentRow || {}} - /> - - ); -}; - -export default GoodsBomsManage; diff --git a/src/pages/bom/push/services.js b/src/pages/bom/push/services.js deleted file mode 100644 index a47dec0..0000000 --- a/src/pages/bom/push/services.js +++ /dev/null @@ -1,65 +0,0 @@ -// @ts-ignore - -/* eslint-disable */ -import { request } from 'umi'; - -export default { - /** 获取商品物料 sdsa GET /kitchen/api/rule */ - goodsBoms(data) { - return request(`/kitchen/api/goods-bom/goods-boms`, { - method: 'Post', - data: data, - // params: { ...params }, - // ...(options || {}), - }); - }, - GetDicList(TypeCode) { - return request(`/kitchen/api/dict-data/dic-list/${TypeCode}`, { - method: 'Get', - }); - }, - - /** 更新商品物料 PUT /kitchen/api/rule */ - updateGoodsBom(data) { - return request('/kitchen/api/goods-bom', { - method: 'PUT', - data: data, - // ...(options || {}), - }); - }, - - /** 新建商品物料清单 POST /kitchen/api/rule */ - addGoodsBom(data) { - // http://localhost:7002 - return request('/kitchen/api/goods-bom', { - method: 'POST', - // type:'json', - data: data, - // ...(options || {}), - }); - }, - /** 删除商品物料 DELETE /kitchen/api/rule */ - removeGoodsBom(data) { - return request(`/kitchen/api/goods-bom`, { - method: 'DELETE', - data: data, - // ...(options || {}), - }); - }, - /** 获取商品商品 sdsa GET /kitchen/api/rule */ - goodList(data) { - return request(`/kitchen/api/goods/goodss`, { - method: 'Post', - data: data, - // params: { ...params }, - // ...(options || {}), - }); - }, - /** 获取原料信息 POST /kitchen/api/rule */ - postStockGoods() { - return request(`/kitchen/api/frachisee-stock-adjust/product-list`, { - method: 'Get', - // ...(options || {}), - }); - }, -}; diff --git a/src/pages/device/deviceStirFryTime/components/CreateForm.jsx b/src/pages/device/deviceStirFryTime/components/CreateForm.jsx new file mode 100644 index 0000000..df31112 --- /dev/null +++ b/src/pages/device/deviceStirFryTime/components/CreateForm.jsx @@ -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 ( + props.onCancel()} + onOk={() => props.onSubmit(selectedRowsState)} + maskClosable={false} + > + { + 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), + }} + /> + + ); +}; + +export default CreateForm; diff --git a/src/pages/device/deviceStirFryTime/index.jsx b/src/pages/device/deviceStirFryTime/index.jsx new file mode 100644 index 0000000..c9a7df6 --- /dev/null +++ b/src/pages/device/deviceStirFryTime/index.jsx @@ -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 '../deviceStirFryTimeStock'; +/** + * 添加节点 + * + * @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().then((r) => { + setTreeData(r.data); + }); + } + initfranchiseeType(); + }, []); + const columns = [ + { + title: '商品名称', + dataIndex: 'goods_Name', + } + ]; + return ( + + ( +
+ + [ + setKey(e[0]), + setDeviceInfo(info.node) + ] + } treeData={treeData} /> + +
+ {dom} +
+
+ )} + toolBarRender={() => [ + , + , + ]} + 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 && ( + + 已选择{' '} + + {selectedRowsState.length} + {' '} + 项    + + } + > + + + )} + { + + 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} + /> + {/* 库存调拨 */} + { + setStockModalVisible(false); + }} + stockModalVisible={stockModalVisible} + values={DeviceInfo} + /> +
+ ); +}; + +export default TableList; diff --git a/src/pages/device/deviceStirFryTime/service.js b/src/pages/device/deviceStirFryTime/service.js new file mode 100644 index 0000000..78a665f --- /dev/null +++ b/src/pages/device/deviceStirFryTime/service.js @@ -0,0 +1,40 @@ +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/StoreDeviceTree?isTMC=false', { + data: { + ...params, + }, + }); +} +export async function GetGoods(params) { + return request('/kitchen/​api/Device/GetGoods', { + method: 'POST', + data: { + ...params, + }, + }); +} diff --git a/src/pages/device/deviceStirFryTimeStock/components/CreateForm.jsx b/src/pages/device/deviceStirFryTimeStock/components/CreateForm.jsx new file mode 100644 index 0000000..a46e6e8 --- /dev/null +++ b/src/pages/device/deviceStirFryTimeStock/components/CreateForm.jsx @@ -0,0 +1,94 @@ +import React, { useState, useEffect } from 'react'; +import { InputNumber, Modal, Form, Input, Button, Select } from 'antd'; +import { GetBatchingAsync,GetProductListByBom } from '../services'; + +const CreateForm = (props) => { + const { Option, OptGroup } = Select; + const [batchingList, setBatchingList] = useState([]); + //原料 + //初始化数据 + useEffect(() => { + const initBatching = () => { + + 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 ( + { + props.onCancel(); + }} + destroyOnClose + > +
+ + + + + + + + + + + + + + +
+
+ ); +}; + +export default CreateForm; diff --git a/src/pages/device/deviceStirFryTimeStock/index.jsx b/src/pages/device/deviceStirFryTimeStock/index.jsx new file mode 100644 index 0000000..7dfcb80 --- /dev/null +++ b/src/pages/device/deviceStirFryTimeStock/index.jsx @@ -0,0 +1,349 @@ +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, + CheckStockTMCAdjust +} 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 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); + if (props.isbom) { + await PushDeviceTMC(id).then((r) => { + message.destroy(key); + if (r.data) { + setSelectedRows([]); + message.success('同步成功'); + actionRef.current.reload(); + return true; + } else { + message.success('同步失败'); + actionRef.current.reload(); + return false; + } + }); + } else { + await PushStockAsync(id).then((r) => { + message.destroy(key); + if (r.data) { + setSelectedRows([]); + message.success('同步成功'); + actionRef.current.reload(); + return true; + } else { + message.success('同步失败'); + 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) => [ + { + handleModalVisible(true); + setCurrentRow(record); + }} + > + {' '} + 修改 + , + { + handleRemoveSingle(record.id); + }} + onCancel={() => { }} + > + 删除 + , + ], + }, + ]; + + return ( + props.onCancel()} + maskClosable={false} + > + + [ + { + handleCheckStockAdjust(props.values.key); + }} + onCancel={() => { }} + > + + , + , + , + ]} + 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); + }, + }} + /> + + { + 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 || {}} + /> + + + ); +}; + +export default DeviceStockManager; diff --git a/src/pages/device/deviceStirFryTimeStock/services.js b/src/pages/device/deviceStirFryTimeStock/services.js new file mode 100644 index 0000000..f40ff8e --- /dev/null +++ b/src/pages/device/deviceStirFryTimeStock/services.js @@ -0,0 +1,79 @@ +import { request } from 'umi'; + +/** 获取商品物料库存 */ +export async function GetStoreBatchingStockPageAsync(data) { + return request(`/kitchen/api/Device/GetDeviceStorePage`, { + method: 'POST', + data: data, + }); +} + +/** 同步库存 */ +export async function PushDeviceTMC(data) { + return request(`/kitchen/api/Device/PushDeviceTMC?DeviceId=${data}`, { + method: 'post', + }); +} + +/** 同步库存 */ +export async function PushStockAsync(data) { + return request(`/kitchen/api/Device/PushStirFryTimeAsync?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 || {}), + }); +} + + diff --git a/src/pages/store/storeGoodsInfo/components/CreateForm.jsx b/src/pages/store/storeGoodsInfo/components/CreateForm.jsx index fafe513..b360cba 100644 --- a/src/pages/store/storeGoodsInfo/components/CreateForm.jsx +++ b/src/pages/store/storeGoodsInfo/components/CreateForm.jsx @@ -1,25 +1,24 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Form, Input, Button, Select, InputNumber,message } from 'antd'; -import { getGoods } from '../services'; +import { Modal, Form, Input, Button, Select, InputNumber, message } from 'antd'; +import { getGoods, GetCokingWorkList } from '../services'; const CreateForm = (props) => { const { Option, OptGroup } = Select; + const [CokingWorks, setCokingWorks] = useState([]); + const [goods, setGoods] = useState([]); //初始化数据 useEffect(() => { - const initGoods = () => { - getGoods().then((data) => { - let list = []; - data.data?.data?.forEach((item) => { - list.push({ - text: item.name, - id: item.id, - }); - }); - setGoods(list); - }); + const initCokingWorks = () => { + GetCokingWorkList().then(r => { + var arr = []; + for (var key in r.data) { + arr.push({r.data[key]}) + } + setCokingWorks(arr); + }) }; - initGoods(); + initCokingWorks(); }, []); return ( @@ -43,23 +42,20 @@ const CreateForm = (props) => { - {/* - - */} - + + + + +