From bc61e6e1ea9a834f89ead247735766241abdeb88 Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Fri, 12 Aug 2022 14:52:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=BA=97=E9=93=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.js | 7 + src/app.jsx | 7 + .../storeStaff/components/CreateForm.jsx | 56 ++++ src/pages/store/storeStaff/index.jsx | 246 ++++++++++++++++++ src/pages/store/storeStaff/services.js | 38 +++ 5 files changed, 354 insertions(+) create mode 100644 src/pages/store/storeStaff/components/CreateForm.jsx create mode 100644 src/pages/store/storeStaff/index.jsx create mode 100644 src/pages/store/storeStaff/services.js diff --git a/config/routes.js b/config/routes.js index 64dac7e..a072a0c 100644 --- a/config/routes.js +++ b/config/routes.js @@ -266,6 +266,13 @@ export default [ component: './store/storeType', access: 'k12', }, + { + name: '店铺员工', + icon: 'smile', + path: '/store/storeStaff', + component: './store/storeStaff', + access: 'k12', + }, { name: '店铺小票打印机', icon: 'smile', diff --git a/src/app.jsx b/src/app.jsx index 5855dc4..93c794e 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -351,6 +351,13 @@ export async function getInitialState() { component: './store/storeDesktopNumber', access: 'k12', }, + { + name: '店铺员工', + icon: 'smile', + path: '/store/storeStaff', + component: './store/storeStaff', + access: 'k12', + }, { code: 'Printer', name: '店铺小票打印机', diff --git a/src/pages/store/storeStaff/components/CreateForm.jsx b/src/pages/store/storeStaff/components/CreateForm.jsx new file mode 100644 index 0000000..8ed115a --- /dev/null +++ b/src/pages/store/storeStaff/components/CreateForm.jsx @@ -0,0 +1,56 @@ +import React, { useState, useEffect } from 'react'; +import { Modal, Form, Input, Button, Select } from 'antd'; + +const CreateForm = (props) => { + const { Option, OptGroup } = Select; + return ( + { + props.onCancel(); + }} + destroyOnClose + > +
+ + + + + + + + + + + + + + + + + + +
+
+ ); +}; + +export default CreateForm; diff --git a/src/pages/store/storeStaff/index.jsx b/src/pages/store/storeStaff/index.jsx new file mode 100644 index 0000000..fadae4a --- /dev/null +++ b/src/pages/store/storeStaff/index.jsx @@ -0,0 +1,246 @@ +import { PlusOutlined } from '@ant-design/icons'; +import { Modal,Button, message, Input, Drawer } from 'antd'; +import React, { useState, useRef } from 'react'; +import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; +import ProTable from '@ant-design/pro-table'; +import QRCode from 'qrcode.react'; +import ProDescriptions from '@ant-design/pro-descriptions'; +import CreateForm from './components/CreateForm'; +import { Getstorestaffpage, Addstorestaff, Updatestorestaff, Delstorestaff, } from "./services" + +const key = 'message'; + +//添加 +const handleAdd = async (fields) => { + try { + message.loading('正在添加', key); + await Addstorestaff(JSON.stringify(fields)).then((r) => { + message.destroy(key); + if (r.data) { + message.success('添加成功'); + return true; + } else { + message.error('添加失败'); + return false; + } + }); + } catch (error) { + message.error('添加失败请重试!'); + return false; + } +}; + + +//修改 +const handleUpdate = async (fields) => { + try { + message.loading('正在修改', key); + message.destroy(key); + await Updatestorestaff(JSON.stringify(fields)).then((r) => { + message.destroy(key); + if (r.data) { + message.success('修改成功',); + return true; + } else { + message.error('修改失败'); + return false; + } + }); + } catch (error) { + message.error('修改失败请重试!'); + return false; + } +}; + + +//删除 +const handleRemove = async (selectedRows) => { + try { + message.loading('正在删除'); + let ids = []; + selectedRows.forEach((item) => { + ids.push(item.id); + }); + await Delstorestaff(ids).then((r) => { + if (r.data) { + message.success('删除成功'); + return true; + } else { + message.error('删除失败'); + return false; + } + }); + } catch (error) { + message.error('删除失败请重试!'); + return false; + } +}; + +const GoodsTypeManage = () => { + /** 新建/更新窗口的弹窗 */ + const [createModalVisible, handleModalVisible] = useState(false); + /** 分布更新窗口的弹窗 */ + + const [showDetail, setShowDetail] = 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', + valueType: 'textarea', + search: false, + + }, + { + title: '电话', + dataIndex: 'phone', + valueType: 'textarea', + search: false, + }, + { + title: '职工编号', + dataIndex: 'number', + valueType: 'textarea', + search: false, + }, + { + title: '状态', + dataIndex: 'status', + hideInForm: true, + search: false, + valueEnum: { + 0: { text: '正常', status: 'Processing' }, + 1: { text: '停用', status: 'Success' }, + 2: { text: '删除', status: 'Error' }, + }, + }, + { + title: '创建时间', + dataIndex: 'createAt', + hideInForm: true, + search: false, + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + render: (_, record) => [ + { + handleModalVisible(true); + setCurrentRow(record); + }} > 更新 + ], + }, + ]; + + return ( + + [ + , + ]} + request={async (params) => { + var data = []; + var total = 0; + await Getstorestaffpage(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 && ( + + 已选择{' '} + + {selectedRowsState.length} + {' '} + 项    + {/* + 服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + item.id, 0)} 万 + */} + + } + > + + {/* */} + + )} + + + { + 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 GoodsTypeManage; diff --git a/src/pages/store/storeStaff/services.js b/src/pages/store/storeStaff/services.js new file mode 100644 index 0000000..d519f0f --- /dev/null +++ b/src/pages/store/storeStaff/services.js @@ -0,0 +1,38 @@ +import { request } from 'umi'; + +/** 获取 */ +export async function Getstorestaffpage(data) { + return request(`/kitchen/api/store-staff/store-staff-page`, { + method: 'POST', + data: data, + }); + } + + /** 新增 */ +export async function Addstorestaff(data) { + return request(`/kitchen/api/store-staff/store-staff`, { + method: 'POST', + data: data, + }); + } + + /** 修改 */ +export async function Updatestorestaff(data) { + return request(`/kitchen​/api/store-staff/store-staff`, { + method: 'put', + data: data, + // params: { ...params }, + // ...(options || {}), + }); + } + + /** 删除 */ +export async function Delstorestaff(data) { + return request(`​/kitchen/api/store-staff/del-store-staff`, { + method: 'POST', + data: data, + // params: { ...params }, + + // ...(options || {}), + }); + }