diff --git a/config/routes.js b/config/routes.js index 7509713..66edc4a 100644 --- a/config/routes.js +++ b/config/routes.js @@ -436,6 +436,19 @@ export default [ }, ], }, + { + name: '产盘管理', + icon: 'BankFilled', + path: '/groupMeal/diningPlate', + routes: [ + { + name: '产盘管理', + icon: 'smile', + path: '/groupMeal/diningPlate', + component: './groupMeal/diningPlate', + }, + ], + }, { path: '/', redirect: '/welcome', diff --git a/src/pages/groupMeal/diningPlate/index.jsx b/src/pages/groupMeal/diningPlate/index.jsx new file mode 100644 index 0000000..c19c10b --- /dev/null +++ b/src/pages/groupMeal/diningPlate/index.jsx @@ -0,0 +1,227 @@ +import { Button, Modal, Form, Input, Drawer, Popconfirm, TreeSelect } from 'antd'; +import React, { useState, useRef, useEffect } from 'react'; +import { PageContainer } from '@ant-design/pro-layout'; +import ProTable from '@ant-design/pro-table'; +import { DropboxOutlined, PlusOutlined } from '@ant-design/icons'; +import api from './service'; +import { message } from 'antd/lib'; +const app = () => { + const [isModalOpen, setIsModalOpen] = useState(false); + const [form] = Form.useForm(); + //绑定 + const actionRef = useRef(); + const [current, setCurrent] = useState({}); + + + const columns = [ + { + title: '主键', + dataIndex: 'id', + tip: '规则名称是唯一的 key', + hideInSearch: true, + hideInTable: true + }, + { + title: '二维码', + dataIndex: 'qrCode', + ellipsis: { + showTitle: false, + }, + valueType: 'textarea', + }, + { + title: '芯片码', + dataIndex: 'chipCode', + ellipsis: { + showTitle: false, + }, + valueType: 'textarea', + }, + { + title: '状态', + dataIndex: 'status', + valueEnum: { + 0: { + text: '正常', + status: 'Processing', + }, + 1: { + text: '停用', + status: 'Success', + }, + }, + }, + { + title: '是否绑定', + dataIndex: 'isOccupy', + valueEnum: { + false: { + text: '未绑定', + status: 'Processing', + }, + true: { + text: '已绑定', + status: 'Success', + }, + }, + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + key: 'operation', + fixed: 'right', + width: 150, + render: (_, record) => [ + { + form.setFieldsValue(record); + setCurrent(record); + setIsModalOpen(true); + }} + > + 更新 + , + { + api.EnableDisable(record).then((re) => { + if (re.data) { + message.success('成功'); + actionRef.current.reloadAndRest(); + } else { + message.error(re.errors ||'失败'); + } + }); + + }} + > + {record.status==0?"停用":"正常"} + , + { + api.Del(record.id).then((re) => { + if (re.data) { + message.success('删除成功'); + actionRef.current.reloadAndRest(); + } else { + message.error(re.errors ||'修改失败'); + } + }); + }} + okText="确定" + cancelText="取消" + > + 删除 + + ], + }, + ]; + return ( + <> + + [ + , + ]} + //数据绑定 + request={async (params) => { + + var res = await api.Page(params); + var datas = res.data.data; + var total = res.data.total; + return { + data: datas, + success: true, + total: total, + }; + }}> + + {/* 餐盘管理 */} + { + form.submit(); + }} + onCancel={() => { + setIsModalOpen(false); + }}> +
{ + if (value.id) { + api.Update(value).then((re) => { + if (re.data) { + message.success('修改成功'); + setIsModalOpen(false); + actionRef.current.reloadAndRest(); + } else { + message.error(re.errors ||'修改失败'); + } + }); + } else { + api.Add(value).then((re) => { + if (re.data) { + setIsModalOpen(false); + message.success('添加成功'); + actionRef.current.reloadAndRest(); + } else { + message.error(re.errors || '添加失败'); + } + }); + } + + + }} + onFinishFailed={() => { }} + autoComplete="off" > + + + + + + + + + +
+
+
+ + + ); +}; + +export default app; diff --git a/src/pages/groupMeal/diningPlate/service.js b/src/pages/groupMeal/diningPlate/service.js new file mode 100644 index 0000000..dc6edbc --- /dev/null +++ b/src/pages/groupMeal/diningPlate/service.js @@ -0,0 +1,42 @@ +import { request } from 'umi'; +import { getDataBaseUrl,getgroupmealUrl } from '@/global_data'; + +export default { + + Page(data) { + return request(getgroupmealUrl()+`/api/DiningPlate/Page`, { + method: 'Post', + data: data, + }); + }, + Add(data) { + return request(getgroupmealUrl()+`/api/DiningPlate/Add`, { + method: 'Post', + data: data, + }); + }, + Update(data) { + return request(getgroupmealUrl()+`/api/DiningPlate/Update`, { + method: 'Post', + data: data, + }); + }, + EnableDisable(data) { + return request(getgroupmealUrl()+`/api/DiningPlate/EnableDisable`, { + method: 'Post', + data: data, + }); + }, + EnableDisable(data) { + return request(getgroupmealUrl()+`/api/DiningPlate/EnableDisable`, { + method: 'Post', + data: data, + }); + }, + Del(data) { + return request(getgroupmealUrl()+`/api/DiningPlate/Del?id=`+data, { + method: 'Post', + data: data, + }); + }, +};