Browse Source

后厨分支

tmp
zhaoy 9 months ago
parent
commit
aef58e02aa
9 changed files with 400 additions and 1 deletions
  1. +1
    -1
      config/defaultSettings.js
  2. +8
    -0
      config/proxy.js
  3. +21
    -0
      config/routes.js
  4. +24
    -0
      src/app.jsx
  5. +0
    -0
     
  6. +0
    -0
     
  7. +87
    -0
      src/pages/scene/store/components/CreateForm.jsx
  8. +232
    -0
      src/pages/scene/store/index.jsx
  9. +27
    -0
      src/pages/scene/store/services.js

+ 1
- 1
config/defaultSettings.js View File

@@ -7,7 +7,7 @@ const Settings = {
fixedHeader: false,
fixSiderbar: true,
colorWeak: false,
title: '黑菠萝智慧厨',
title: '黑菠萝智慧厨',
pwa: false,
logo: '/logo.svg',
iconfontUrl: '',


+ 8
- 0
config/proxy.js View File

@@ -16,6 +16,14 @@
'/saasbase/': '',
},
},
'/saasstore/': {
target: 'http://192.168.1.19:5008',
changeOrigin: true,
secure: false, //关闭证书验证
pathRewrite: {
'/saasstore/': '',
},
},
// Nginx发布的时候需要配置
'/cos/':{
target: 'https://hbl-test-1305371387.cos.ap-chengdu.myqcloud.com',


+ 21
- 0
config/routes.js View File

@@ -206,6 +206,27 @@ export default [
// },
],
},
{
name: '场景管理',
icon: 'BankFilled',
path: '/scene',
routes: [
{
name: '场景基础信息',
icon: 'smile',
path: '/scene/store',
component: './scene/store',
access: 'k12',
},
{
name: '场景菜谱信息',
icon: 'smile',
path: '/scene/foodmenu',
component: './scene/foodmenu',
access: 'k14',
},
],
},
{
path: '/',
redirect: '/welcome',


+ 24
- 0
src/app.jsx View File

@@ -248,6 +248,30 @@ export async function getInitialState() {
},
]
},
{
code: 'scene',
name: '场景管理',
icon: 'PrinterOutlined',
path: '/scene',
routes: [
{
code: 'store',
name: '场景基础信息',
icon: 'smile',
path: '/scene/store',
component: './scene/store',
access: 'k12',
},
{
code: 'foodmenu',
name: '场景菜谱信息',
icon: 'smile',
path: '/scene/foodmenu',
component: './scene/foodmenu',
access: 'k14',
},
],
},
];
// api.queryMenus();
return data;


+ 0
- 0
View File


+ 0
- 0
View File


+ 87
- 0
src/pages/scene/store/components/CreateForm.jsx View File

@@ -0,0 +1,87 @@
import React, { useState, useEffect,useRef } from 'react';
import { PlusOutlined } from '@ant-design/icons';
import { Modal, Form, Input, Button, TreeSelect,InputNumber } from 'antd';
import {
} from '../services';
const CreateForm = (props) => {
const [orgId,setorgId]=useState();
const [form] = Form.useForm();
useEffect(() => {
console.log(props.values)
if(props?.values?.id){
form.setFieldsValue({
id:props?.values?.id,
name:props?.values?.name,
orgId:props?.values?.orgId,
phone:props?.values?.phone,
sort:props?.values?.sort,
description:props?.values?.description,
orgName:props?.values?.orgName,

})
setorgId(props?.values?.orgId)
}else{
form.resetFields();
}
},[props.values])
const handleChange=(value, label, extra)=>{
console.log(label)
form.setFieldsValue({
orgName:label[0]
})
setorgId(value)
}
return (
<Modal
title={props.values.id ? '编辑' : '新建'}
width={640}
visible={props.createModalVisible}
bodyStyle={{ padding: '32px 40px 48px' }}
footer={null}
onCancel={() => {
props.onCancel();
}}
destroyOnClose
>
<Form
layout="Horizontal"
labelCol={{ span: 4 }}
preserve={false}
form={form}
initialValues={props.values}
onFinish={props.onFinish}
>
<Form.Item name="id" hidden={true}>
<Input />
</Form.Item>
<Form.Item name="orgName" hidden={true}>
<Input />
</Form.Item>
<Form.Item label={'场景名称'} name="name" rules={[{ required: true, max: 50 }]}>
<Input />
</Form.Item>

<Form.Item label={'所属机构'} name="orgId" rules={[{ required: true }]}>
<TreeSelect allowClear treeDefaultExpandAll treeData={props.OrgList} onChange={handleChange} value={orgId}/>
</Form.Item>
<Form.Item label={'电话'} name="phone" rules={[{ required: true }]}>
<Input />
</Form.Item>
<Form.Item name="sort" label="排序">
<InputNumber min={1} decimalSeparator="0"/>
</Form.Item>
<Form.Item label={'描述'} name="description">
<Input />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
保存
</Button>
</Form.Item>
</Form>
</Modal>
);
};

export default CreateForm;

+ 232
- 0
src/pages/scene/store/index.jsx View File

@@ -0,0 +1,232 @@
import { PlusOutlined } from '@ant-design/icons';
import { Modal, Button, message } 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 CreateForm from './components/CreateForm';
import {
GetStorePage,
StoreAdd,
StoreUpdate,
StoreDelete,
} from './services';
import { gettree } from '../../org/orgamange/service';
const key = 'message';


const StoreManage = () => {
const [OrgList, setOrgList] = useState([]);
//初始化数据
useEffect(() => {
gettree().then((r)=>{
setOrgList(r.data)
})
}, []);
/** 新建/更新窗口的弹窗 */
const [createModalVisible, handleModalVisible] = useState(false);
/** 分布更新窗口的弹窗 */
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState();
const [selectedRowsState, setSelectedRows] = useState([]);
/** 国际化配置 */

const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key',
},
{
title: '场景名称',
dataIndex: 'name',
},
{
title: '所属组织',
dataIndex: 'orgName',
hideInSearch: true,
},
{
title: '电话',
dataIndex: 'phone',
search: false,
},
{
title: '排序',
dataIndex: 'sort',
search: false,
},
{
title: '描述',
dataIndex: 'description',
},

{
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 200,
render: (_, record) => [
<a
key="update"
onClick={() => {
handleModalVisible(true);
setCurrentRow(record);
}}
>
更新
</a>,
<a
key="status"
onClick={async () => {
var ids=[{id:record.id}]
handleRemove(ids);
}}
>
删除
</a>,

],
},
];
//添加
const handleAdd = async (fields) => {
await StoreAdd(JSON.stringify(fields)).then((r) => {
if (r.succeeded) {
message.success('添加成功');
handleModalVisible(false);
setCurrentRow(undefined);
actionRef.current.reload();
} else {
message.error(r.errors);
}
});
};
//修改
const handleUpdate = async (fields) => {
await StoreUpdate(JSON.stringify(fields)).then((r) => {

if (r.succeeded) {
message.success('修改成功');
handleModalVisible(false);
setCurrentRow(undefined);
actionRef.current.reload();
} else {
message.error(r.errors);
}
});
};

//删除
const handleRemove = async (selectedRows) => {
let ids = [];
selectedRows.forEach((item) => {
ids.push(item.id);
});
await StoreDelete(ids).then((r) => {
if (r.succeeded) {
message.success('删除成功');
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
} else {
message.error(r.errors);
}
});
};

return (
<PageContainer host header={{
title: '',
breadcrumb: {},
}}>
<ProTable
headerTitle="场景信息"
actionRef={actionRef}
rowKey="id"
pagination={{ defaultPageSize: 10 }}
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
handleModalVisible(true);
}}
>
<PlusOutlined /> 新建
</Button>,
]}
request={async (params) => {
var data = [];
var total = 0;
await GetStorePage(params).then((r) => {
data = r.data.data;
total = r.data.total;
});
return {
data: data,
success: true,
total: total,
};
}}
columns={columns}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
/>
{selectedRowsState?.length > 0 && (
<FooterToolbar
extra={
<div>
已选择{' '}
<a
style={{
fontWeight: 600,
}}
>
{selectedRowsState.length}
</a>{' '}
项 &nbsp;&nbsp;
{/* <span>
服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + item.id, 0)} 万
</span> */}
</div>
}
>
{/* <Button type="primary">批量审批</Button> */}
</FooterToolbar>
)}

<CreateForm
OrgList={OrgList}
onFinish={async (value) => {
if (value.id) {
await handleUpdate(value);
} else {
await handleAdd(value);
}
}}
onCancel={() => {
handleModalVisible(false);
setCurrentRow(undefined);
}}
createModalVisible={createModalVisible}
values={currentRow || {}}
/>

</PageContainer>
);
};

export default StoreManage;

+ 27
- 0
src/pages/scene/store/services.js View File

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

/** 获取场景列表 */
export async function GetStorePage(data) {
return request(`/saasstore/api/store/page`, {
method: 'POST',
data: data,
});
}
export async function StoreAdd(data) {
return request(`/saasstore/api/store/add`, {
method: 'POST',
data: data,
});
}
export async function StoreUpdate(data) {
return request(`/saasstore/api/store/update`, {
method: 'POST',
data: data,
});
}
export async function StoreDelete(data) {
return request(`/saasstore/api/store/delete`, {
method: 'POST',
data: data,
});
}

Loading…
Cancel
Save