@@ -1,6 +1,6 @@ | |||
import { PlusOutlined } from '@ant-design/icons'; | |||
import { Button, message, Popconfirm } from 'antd'; | |||
import React, { useState, useRef } from 'react'; | |||
import React, { useState, useRef, useEffect } from 'react'; | |||
import { PageContainer } from '@ant-design/pro-layout'; | |||
import ProTable from '@ant-design/pro-table'; | |||
import CreateForm from './components/CreateForm'; | |||
@@ -12,6 +12,7 @@ const batchinginfo = () => { | |||
const [createModalVisible, handleModalVisible] = useState(); | |||
const [stepFormValues, setStepFormValues] = useState({}); | |||
const [selectedRowsState, setSelectedRows] = useState(); | |||
const [codeList, setCodeList] = useState([]); | |||
const uintList = [ | |||
{ value: '1', label: 'g' }, | |||
{ value: '2', label: 'kg' }, | |||
@@ -20,6 +21,13 @@ const batchinginfo = () => { | |||
{ value: '1', label: '液体料' }, | |||
{ value: '2', label: '主料' }, | |||
]; | |||
useEffect(() => { | |||
api.GetBasicRoleCode().then((r) => { | |||
if (r.data) { | |||
setCodeList(r.data) | |||
} | |||
}) | |||
}, []) | |||
const handleAdd = async (fields) => { | |||
await api.add(fields).then((r) => { | |||
if (r.data) { | |||
@@ -118,33 +126,36 @@ const batchinginfo = () => { | |||
fixed: 'right', | |||
width: 350, | |||
render: (_, record) => [ | |||
<a | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setStepFormValues(record); | |||
}} | |||
> | |||
更新 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
api.deleteBatching([record.id]).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
codeList.includes("batchingUp") ? | |||
<a | |||
onClick={() => { | |||
handleModalVisible(true); | |||
setStepFormValues(record); | |||
}} | |||
> | |||
更新 | |||
</a> : "" | |||
, | |||
codeList.includes("batchingDel") ? | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
api.deleteBatching([record.id]).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm> : "", | |||
], | |||
} | |||
] | |||
@@ -165,18 +176,20 @@ const batchinginfo = () => { | |||
labelWidth: 120, | |||
}} | |||
toolBarRender={() => [ | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
var values = { code: randomString(4) } | |||
setStepFormValues(values); | |||
handleModalVisible(true); | |||
}} | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button>, | |||
<BatchDeletion /> | |||
codeList.includes("batchingAdd") ? | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
var values = { code: randomString(4) } | |||
setStepFormValues(values); | |||
handleModalVisible(true); | |||
}} | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button> : "", | |||
codeList.includes("batchingDel") ? | |||
<BatchDeletion /> : "" | |||
]} | |||
request={async (params) => { | |||
let batchingData = []; | |||
@@ -31,4 +31,9 @@ export default { | |||
data: data, | |||
}); | |||
}, | |||
GetBasicRoleCode() { | |||
return request(getDataBaseUrl() + `/api/roles/getBasicRoleCode`, { | |||
method: 'Get', | |||
}); | |||
}, | |||
} |
@@ -0,0 +1,110 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { Checkbox, Col, Modal, Row, Tree } from "antd"; | |||
import Enumerable from 'linq'; | |||
const BasicFunctionForm = (props) => { | |||
const [load, setLoad] = useState([]); | |||
const [checkedKeys, setCheckedKeys] = useState(); | |||
const [indeterminate, setindeterminate] = useState(false); | |||
const [checkAll, setcheckAll] = useState(false); | |||
useEffect(() => { | |||
var arr = []; | |||
var filteredArr = [] | |||
Enumerable.from(props.values).forEach(t => { | |||
if (!t.isParentMenu) { | |||
arr.push(t.id); | |||
} | |||
if (t.id !== null) { | |||
filteredArr.push(t); | |||
} | |||
}); | |||
setCheckedKeys(arr) | |||
var data = props.treeData; | |||
if (getTreeLength(data) === filteredArr.length) { | |||
setcheckAll(true) | |||
setindeterminate(false); | |||
} else { | |||
setcheckAll(false); | |||
if (props.values.length == 0) { | |||
setindeterminate(false); | |||
} else { | |||
setindeterminate(true); | |||
} | |||
} | |||
setLoad(data); | |||
}, [props.values]) | |||
function getTreeLength(tree) { | |||
if (tree != undefined) { | |||
let length = tree.length; | |||
for (let i = 0; i < tree.length; i++) { | |||
if (Array.isArray(tree[i].children)) { | |||
length += getTreeLength(tree[i].children); | |||
} | |||
} | |||
return length; | |||
} | |||
} | |||
const onCheckAllChange = (e) => { | |||
if (!checkAll) { | |||
var data = getAllIds(load, []); | |||
setCheckedKeys(data) | |||
setcheckAll(true) | |||
setindeterminate(false); | |||
} else { | |||
setCheckedKeys([]) | |||
setcheckAll(false) | |||
setindeterminate(false); | |||
} | |||
}; | |||
function getAllIds(tree, result) { | |||
for (const i in tree) { | |||
result.push(tree[i].key); | |||
if (tree[i].children) { | |||
getAllIds(tree[i].children, result); | |||
} | |||
} | |||
return result; | |||
} | |||
return ( | |||
<Modal | |||
width={700} | |||
title={'基础功能授权'} | |||
visible={props.modalVisible} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
onOk={() => props.onSubmit(checkedKeys)} | |||
onCancel={() => props.onCancel()} | |||
maskClosable={false} | |||
destroyOnClose | |||
> | |||
<Row> | |||
<Col span={8}> | |||
<Checkbox | |||
indeterminate={indeterminate} | |||
onChange={onCheckAllChange} | |||
checked={checkAll} | |||
> | |||
全选 | |||
</Checkbox> | |||
<Tree | |||
treeData={load} | |||
onCheck={(keys, e) => { | |||
if (getTreeLength(props.treeData) == keys.length) { | |||
setcheckAll(true) | |||
setindeterminate(false); | |||
} else { | |||
setcheckAll(false) | |||
setindeterminate(true); | |||
} | |||
setCheckedKeys(keys); | |||
}} | |||
defaultExpandAll={false} | |||
checkedKeys={checkedKeys} | |||
checkable | |||
/> | |||
</Col> | |||
</Row> | |||
</Modal> | |||
) | |||
} | |||
export default BasicFunctionForm; |
@@ -74,7 +74,7 @@ const MenuForm = (props) => { | |||
var html = <Modal width={700} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
destroyOnClose | |||
title={'菜单分配'} | |||
title={'企业菜单授权'} | |||
visible={props.modalVisible} | |||
onOk={() => props.onSubmit(checkedKeys)} | |||
onCancel={() => props.onCancel()} | |||
@@ -7,6 +7,7 @@ import ProDescriptions from '@ant-design/pro-descriptions'; | |||
import CreateForm from './components/CreateForm'; | |||
import MenuForm from './components/MenuForm'; | |||
import api from './service'; | |||
import BasicFunctionForm from './components/BasicFunctionForm'; | |||
/** | |||
* 添加节点 | |||
@@ -119,14 +120,22 @@ const companyManage = () => { | |||
const [row, setRow] = useState(); | |||
const [basicTreeData, setBasicTreeData] = useState(); | |||
const [basicValues, setBasicValues] = useState([]); | |||
const [basicModalVisible, handleBasicModalVisible] = useState(false); | |||
useEffect(() => { | |||
var parm={getType:'ALL',type:0} | |||
api.GetMenu(parm).then((r) => { | |||
if(r.data){ | |||
setTreeData(r.data); | |||
} | |||
}); | |||
api.GetBasicFunctionMenuTree().then((r)=>{ | |||
if(r.data){ | |||
setBasicTreeData(r.data) | |||
} | |||
}) | |||
}, []); | |||
/** 国际化配置 */ | |||
@@ -206,6 +215,17 @@ const companyManage = () => { | |||
{' '} | |||
企业菜单授权 | |||
</a>, | |||
<a | |||
onClick={() => { | |||
api.GetBasicFunctionList(record.sysRoleId).then((r) => { | |||
setBasicValues(r.data); | |||
}); | |||
handleBasicModalVisible(true); | |||
setStepFormValues(record); | |||
}} | |||
> | |||
基础功能授权 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
@@ -379,6 +399,32 @@ const companyManage = () => { | |||
datas={stepFormValues || {}} | |||
/> | |||
) : null} | |||
<BasicFunctionForm | |||
onSubmit={async (value) => { | |||
const values = { | |||
sysRoleId: stepFormValues.sysRoleId, | |||
basicMenuIdList: value, | |||
}; | |||
const success = await api.UpdateBasicFunction(values); | |||
if (success) { | |||
message.success("授权成功"); | |||
}else{ | |||
message.error("授权失败"); | |||
} | |||
actionRef.current.reload(); | |||
handleBasicModalVisible(false); | |||
setBasicValues([]) | |||
}} | |||
onCancel={() => { | |||
handleBasicModalVisible(false); | |||
setBasicValues([]) | |||
}} | |||
modalVisible={basicModalVisible} | |||
treeData={basicTreeData} | |||
values={basicValues || {}} | |||
/> | |||
<Drawer | |||
width={600} | |||
visible={showDetail} | |||
@@ -65,5 +65,26 @@ export default { | |||
method: 'post', | |||
data: params, | |||
}); | |||
} | |||
}, | |||
/** 获取基础功能菜单*/ | |||
GetBasicFunctionMenuTree() { | |||
return request(getDataBaseUrl()+`/api/menu/getBasicFunctionMenuTree`, | |||
{ | |||
method: 'Get', | |||
}); | |||
}, | |||
/** 获取角色基础功能菜单*/ | |||
GetBasicFunctionList(params) { | |||
return request(getDataBaseUrl()+`/api/roles/getBasicFunctionList?roleId=${params}`, | |||
{ | |||
method: 'Get', | |||
}); | |||
}, | |||
/** 更新角色基础功能菜单*/ | |||
UpdateBasicFunction(data){ | |||
return request(getDataBaseUrl()+`/api/roles/updateBasicFunction`,{ | |||
method: 'POST', | |||
data: data, | |||
}); | |||
}, | |||
}; |
@@ -18,11 +18,17 @@ const deviceinfo = () => { | |||
const [deviceId, setDeviceId] = useState([]); | |||
const [storeId, setStoreId] = useState([]); | |||
const [isWeight, setIsWeight] = useState(''); | |||
const [codeList, setCodeList] = useState([]); | |||
const enableList = [ | |||
{ value: '1', label: '启用' }, | |||
{ value: '0', label: '停用' }, | |||
]; | |||
useEffect(() => { | |||
api.GetBasicRoleCode().then((r) => { | |||
if (r.data) { | |||
setCodeList(r.data) | |||
} | |||
}) | |||
getAllStoreList() | |||
}, []); | |||
function getAllStoreList() { | |||
@@ -169,45 +175,48 @@ const deviceinfo = () => { | |||
fixed: 'right', | |||
width: 350, | |||
render: (_, record) => [ | |||
<a | |||
onClick={() => { | |||
handleModalOpen(true); | |||
setStepFormValues(record); | |||
}} | |||
> | |||
更新 | |||
</a>, | |||
<a | |||
key="edit" | |||
onClick={() => { | |||
getStoreRecipeList(record.storeId, isWeight); | |||
setStoreId(record.storeId); | |||
setrecipeList(record.id); | |||
setDeviceId(record.id); | |||
setIsModalOpen(true); | |||
}} | |||
> | |||
设置设备配方 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
api.deleteDevice([record.id]).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
codeList.includes("deviceUp") ? | |||
<a | |||
onClick={() => { | |||
handleModalOpen(true); | |||
setStepFormValues(record); | |||
}} | |||
> | |||
更新 | |||
</a> : "", | |||
codeList.includes("deviceSetRecipe") ? | |||
<a | |||
key="edit" | |||
onClick={() => { | |||
getStoreRecipeList(record.storeId, isWeight); | |||
setStoreId(record.storeId); | |||
setrecipeList(record.id); | |||
setDeviceId(record.id); | |||
setIsModalOpen(true); | |||
}} | |||
> | |||
设置设备配方 | |||
</a> : "", | |||
codeList.includes("deviceDel") ? | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
api.deleteDevice([record.id]).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm> : "", | |||
], | |||
} | |||
] | |||
@@ -227,16 +236,18 @@ const deviceinfo = () => { | |||
labelWidth: 120, | |||
}} | |||
toolBarRender={() => [ | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalOpen(true); | |||
}} | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button>, | |||
<BatchDeletion /> | |||
codeList.includes("deviceAdd") ? | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalOpen(true); | |||
}} | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button> : "", | |||
codeList.includes("deviceDel") ? | |||
<BatchDeletion /> : "" | |||
]} | |||
request={async (params) => { | |||
let storeData = []; | |||
@@ -289,7 +300,7 @@ const deviceinfo = () => { | |||
<Modal | |||
width={800} | |||
title="设置门店配方" | |||
title="设置设备配方" | |||
open={isModalOpen} | |||
destroyOnClose | |||
onOk={() => { editDeviceRecipe() }} | |||
@@ -40,4 +40,9 @@ export default { | |||
data: data, | |||
}); | |||
}, | |||
GetBasicRoleCode() { | |||
return request(getDataBaseUrl() + `/api/roles/getBasicRoleCode`, { | |||
method: 'Get', | |||
}); | |||
}, | |||
} |
@@ -3,7 +3,7 @@ const interfacedoc = () => { | |||
return ( | |||
<div style={{ width: '100%', height: '107%', overflow: 'hidden' ,background: '#ffffff' }}> | |||
<iframe | |||
src="http://localhost:8001/" | |||
src="http://192.168.1.50:8001?type=ingredient" | |||
title="接口文档" | |||
style={{ | |||
width: '100%', | |||
@@ -0,0 +1,110 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { Checkbox, Col, Modal, Row, Tree } from "antd"; | |||
import Enumerable from 'linq'; | |||
const BasicFunctionForm = (props) => { | |||
const [load, setLoad] = useState([]); | |||
const [checkedKeys, setCheckedKeys] = useState(); | |||
const [indeterminate, setindeterminate] = useState(false); | |||
const [checkAll, setcheckAll] = useState(false); | |||
useEffect(() => { | |||
var arr = []; | |||
var filteredArr = [] | |||
Enumerable.from(props.values).forEach(t => { | |||
if (!t.isParentMenu) { | |||
arr.push(t.id); | |||
} | |||
if (t.id !== null) { | |||
filteredArr.push(t); | |||
} | |||
}); | |||
setCheckedKeys(arr) | |||
var data = props.treeData; | |||
if (getTreeLength(data) === filteredArr.length) { | |||
setcheckAll(true) | |||
setindeterminate(false); | |||
} else { | |||
setcheckAll(false); | |||
if (props.values.length == 0) { | |||
setindeterminate(false); | |||
} else { | |||
setindeterminate(true); | |||
} | |||
} | |||
setLoad(data); | |||
}, [props.values]) | |||
function getTreeLength(tree) { | |||
if (tree != undefined) { | |||
let length = tree.length; | |||
for (let i = 0; i < tree.length; i++) { | |||
if (Array.isArray(tree[i].children)) { | |||
length += getTreeLength(tree[i].children); | |||
} | |||
} | |||
return length; | |||
} | |||
} | |||
const onCheckAllChange = (e) => { | |||
if (!checkAll) { | |||
var data = getAllIds(load, []); | |||
setCheckedKeys(data) | |||
setcheckAll(true) | |||
setindeterminate(false); | |||
} else { | |||
setCheckedKeys([]) | |||
setcheckAll(false) | |||
setindeterminate(false); | |||
} | |||
}; | |||
function getAllIds(tree, result) { | |||
for (const i in tree) { | |||
result.push(tree[i].key); | |||
if (tree[i].children) { | |||
getAllIds(tree[i].children, result); | |||
} | |||
} | |||
return result; | |||
} | |||
return ( | |||
<Modal | |||
width={700} | |||
title={'基础功能授权'} | |||
visible={props.modalVisible} | |||
bodyStyle={{ padding: '32px 40px 48px' }} | |||
onOk={() => props.onSubmit(checkedKeys)} | |||
onCancel={() => props.onCancel()} | |||
maskClosable={false} | |||
destroyOnClose | |||
> | |||
<Row> | |||
<Col span={8}> | |||
<Checkbox | |||
indeterminate={indeterminate} | |||
onChange={onCheckAllChange} | |||
checked={checkAll} | |||
> | |||
全选 | |||
</Checkbox> | |||
<Tree | |||
treeData={load} | |||
onCheck={(keys, e) => { | |||
if (getTreeLength(props.treeData) == keys.length) { | |||
setcheckAll(true) | |||
setindeterminate(false); | |||
} else { | |||
setcheckAll(false) | |||
setindeterminate(true); | |||
} | |||
setCheckedKeys(keys); | |||
}} | |||
defaultExpandAll={false} | |||
checkedKeys={checkedKeys} | |||
checkable | |||
/> | |||
</Col> | |||
</Row> | |||
</Modal> | |||
) | |||
} | |||
export default BasicFunctionForm; |
@@ -5,11 +5,13 @@ import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; | |||
import ProTable, { ProColumns, ActionType, TableDropdown } from '@ant-design/pro-table'; | |||
import Enumerable from 'linq' | |||
import CreateForm from './components/CreateForm'; | |||
import { Page, add, edit, removeRole, setMenu, GetMenu, GetRoleMenu, SetDataRole } from './service'; | |||
import { Page, add, edit, removeRole, setMenu, GetMenu, GetRoleMenu, SetDataRole, GetBasicFunctionMenuTree, GetBasicFunctionList, UpdateBasicFunction } from './service'; | |||
import { useAccess } from 'umi'; | |||
import MenuForm from './components/MenuForm'; | |||
import OrgForm from './components/OrgForm'; | |||
import {randomString} from '../../comm' | |||
import {randomString} from '../../comm'; | |||
import BasicFunctionForm from './components/BasicFunctionForm'; | |||
/** | |||
* 添加节点 | |||
* @param fields | |||
@@ -106,6 +108,9 @@ const roleManager = () => { | |||
const [selectedRowsState, setSelectedRows] = useState(); | |||
const [selectData, setSelectData] = useState([]); | |||
const [treeData, setTreeData] = useState(); | |||
const [basicTreeData, setBasicTreeData] = useState(); | |||
const [basicValues, setBasicValues] = useState([]); | |||
const [basicModalVisible, handleBasicModalVisible] = useState(false); | |||
/** | |||
* 删除节点 | |||
* @param selectedRows | |||
@@ -119,7 +124,7 @@ const roleManager = () => { | |||
message.success("删除成功"); | |||
actionRef.current.reload(); | |||
}else{ | |||
message.error(r.data); | |||
message.error(r.errors); | |||
} | |||
}) | |||
hide(); | |||
@@ -177,6 +182,21 @@ const roleManager = () => { | |||
> | |||
授权菜单 | |||
</a>); | |||
arr.push( | |||
<a | |||
disabled={record.code == 'sys_manager_role'} | |||
style={{ pointerEvents: record.code == 'sys_manager_role' ? 'none' : 'auto' }} | |||
onClick={()=>{ | |||
GetBasicFunctionList(record.id).then((r)=>{ | |||
setBasicValues(r.data); | |||
}) | |||
handleBasicModalVisible(true); | |||
setStepFormValues(record); | |||
}} | |||
> | |||
授权基础功能 | |||
</a> | |||
) | |||
// arr.push(<a | |||
// disabled={record.code == 'sys_manager_role'} | |||
// style={{ pointerEvents: record.code == 'sys_manager_role' ? 'none' : 'auto' }} | |||
@@ -196,8 +216,12 @@ const roleManager = () => { | |||
if(r.data){ | |||
setTreeData(r.data); | |||
} | |||
}); | |||
GetBasicFunctionMenuTree().then((r)=>{ | |||
if(r.data){ | |||
setBasicTreeData(r.data) | |||
} | |||
}) | |||
}, []); | |||
const columns = [ | |||
@@ -356,6 +380,31 @@ const roleManager = () => { | |||
values={stepFormValues} | |||
/> | |||
) : null} | |||
<BasicFunctionForm | |||
onSubmit={async (value) => { | |||
const values = { | |||
sysRoleId: stepFormValues.id, | |||
basicMenuIdList: value, | |||
}; | |||
const success = await UpdateBasicFunction(values); | |||
if (success) { | |||
message.success("授权成功"); | |||
} else { | |||
message.error("授权失败"); | |||
} | |||
actionRef.current.reload(); | |||
handleBasicModalVisible(false); | |||
setBasicValues([]) | |||
}} | |||
onCancel={() => { | |||
handleBasicModalVisible(false); | |||
setBasicValues([]) | |||
}} | |||
modalVisible={basicModalVisible} | |||
treeData={basicTreeData} | |||
values={basicValues || {}} | |||
/> | |||
</PageContainer> | |||
</>; | |||
@@ -71,3 +71,24 @@ export async function SetDataRole(params) { | |||
method: 'Get', | |||
}); | |||
} | |||
/** 获取基础功能菜单*/ | |||
export async function GetBasicFunctionMenuTree() { | |||
return request(getDataBaseUrl() + `/api/menu/getBasicFunctionMenuTree`, | |||
{ | |||
method: 'Get', | |||
}); | |||
}; | |||
/** 获取角色基础功能菜单*/ | |||
export async function GetBasicFunctionList(params) { | |||
return request(getDataBaseUrl() + `/api/roles/getBasicFunctionList?roleId=${params}`, | |||
{ | |||
method: 'Get', | |||
}); | |||
}; | |||
/** 更新角色基础功能菜单*/ | |||
export async function UpdateBasicFunction(data) { | |||
return request(getDataBaseUrl() + `/api/roles/updateBasicFunction`, { | |||
method: 'POST', | |||
data: data, | |||
}); | |||
}; |
@@ -45,7 +45,7 @@ const CreateAttrForm = (props) => { | |||
return ( | |||
<Modal | |||
key={Date.now} | |||
title={props.values.id ? '编辑配方' : '新建配方'} | |||
title='编辑属性' | |||
width={700} | |||
bodyStyle={{ padding: '32px 40px 1px 48px' }} | |||
visible={props.modalVisible} | |||
@@ -6,7 +6,6 @@ import api from '../service'; | |||
import { useEffect, useRef, useState } from 'react'; | |||
import CreateAttrForm from './CreateAttrForm'; | |||
const RecipeDetailForm = (props) => { | |||
const actionRef = useRef() | |||
const [recipeAttrFormList, setRecipeAttrFormList] = useState([]) | |||
@@ -195,18 +194,21 @@ const RecipeDetailForm = (props) => { | |||
key="primary" | |||
type="primary" | |||
onClick={() => { editAttrRecipe(record) }} | |||
>编辑</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { deleteRecipeAttr(record.id) }} | |||
onCancel | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm> | |||
查看 | |||
</a>, | |||
props.codeList.includes("recipeBatchingDel") ? | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { deleteRecipeAttr(record.id) }} | |||
onCancel | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm> : "" | |||
] | |||
}, | |||
] | |||
@@ -230,16 +232,19 @@ const RecipeDetailForm = (props) => { | |||
colSpan="50%" | |||
height='50%' | |||
> | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
setRecipeAttrFormList(recipeAttrList) | |||
handleModalVisible(true) | |||
}} | |||
> | |||
编辑属性 | |||
</Button> | |||
{ | |||
props.codeList.includes("recipeAttrUp") ? | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
setRecipeAttrFormList(recipeAttrList) | |||
handleModalVisible(true) | |||
}} | |||
> | |||
编辑属性 | |||
</Button> : "" | |||
} | |||
<Button | |||
type="primary" | |||
key="primary" | |||
@@ -258,12 +263,12 @@ const RecipeDetailForm = (props) => { | |||
> | |||
清空选择 | |||
</Button> | |||
<div style={{ marginTop: 10, height:150, overflowY: 'auto' }}> | |||
<div style={{ marginTop: 10, height: 150, overflowY: 'auto' }}> | |||
{ | |||
recipeAttrList == "" ? (<div>点击“编辑属性”添加属性和属性值!</div>) : ( | |||
recipeAttrList.map((item, index) => { | |||
return ( | |||
<div style={{ marginTop: 10, width:'max-content', overflowX: 'auto' }}> | |||
<div style={{ marginTop: 10, width: 'max-content', overflowX: 'auto' }}> | |||
<span><Tag color="blue">{item.name}</Tag>:</span> | |||
<span> | |||
<Radio.Group name={index} buttonStyle="solid" onChange={onChangevalue} value={item.defalutvalue}> | |||
@@ -316,23 +321,29 @@ const RecipeDetailForm = (props) => { | |||
{valueIds === '' ? '基础配方' : names} | |||
</span> | |||
<div style={{ float: 'right' }}> | |||
{valueIds === '' ? ("") : ( | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { setBaseBatchingList(); }} | |||
style={{ marginRight: '8px' }} | |||
> | |||
填入基础配方数据 | |||
</Button> | |||
)} | |||
<Button | |||
type="primary" | |||
key="save" | |||
onClick={() => { setRecipeBatching(); }} | |||
> | |||
保存数据 | |||
</Button> | |||
{ | |||
props.codeList.includes("recipeBatchingUp") ? | |||
(valueIds === '' ? ("") : ( | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { setBaseBatchingList(); }} | |||
style={{ marginRight: '8px' }} | |||
> | |||
填入基础配方数据 | |||
</Button> | |||
)) : "" | |||
} | |||
{ | |||
props.codeList.includes("recipeBatchingUp") ? | |||
<Button | |||
type="primary" | |||
key="save" | |||
onClick={() => { setRecipeBatching(); }} | |||
> | |||
保存数据 | |||
</Button> : "" | |||
} | |||
</div> | |||
</div> | |||
<EditableProTable | |||
@@ -80,14 +80,17 @@ const RecipeInfoForm = (props) => { | |||
onClick={() => { | |||
if (props.groupId == undefined) { | |||
message.error("请先选择一个配方分组"); | |||
return; | |||
} | |||
else { | |||
setRecipeInfo(item) | |||
if (item.name === '+' || item.name === "") { | |||
handleModalVisible(true) | |||
} else { | |||
handleDetailModalOpen(true) | |||
} | |||
if ((item.name === "+" || item.name === "") && !props.codeList.includes("recipeInfoUp")) { | |||
message.error("无新增权限"); | |||
return; | |||
} | |||
setRecipeInfo(item) | |||
if (item.name === '+' || item.name === "") { | |||
handleModalVisible(true) | |||
} else { | |||
handleDetailModalOpen(true) | |||
} | |||
}} | |||
key={index} | |||
@@ -103,30 +106,36 @@ const RecipeInfoForm = (props) => { | |||
...operateStyle | |||
}} | |||
> | |||
<a | |||
onClick={(e) => { | |||
e.stopPropagation() | |||
setRecipeInfo(item) | |||
handleModalVisible(true) | |||
}} | |||
> | |||
<FormOutlined /> | |||
</a> | |||
<a | |||
onClick={(e) => { | |||
e.stopPropagation() | |||
}} | |||
style={{ marginLeft: 5 }} | |||
> | |||
<Popconfirm | |||
title="确认删除吗?" | |||
onConfirm={() => deleteRecipeInfo(item.id)} | |||
okText="确定" | |||
cancelText="取消" | |||
> | |||
<CloseOutlined /> | |||
</Popconfirm> | |||
</a> | |||
{ | |||
props.codeList.includes("recipeInfoUp") ? | |||
<a | |||
onClick={(e) => { | |||
e.stopPropagation() | |||
setRecipeInfo(item) | |||
handleModalVisible(true) | |||
}} | |||
> | |||
<FormOutlined /> | |||
</a> : "" | |||
} | |||
{ | |||
props.codeList.includes("recipeInfoDel") ? | |||
<a | |||
onClick={(e) => { | |||
e.stopPropagation() | |||
}} | |||
style={{ marginLeft: 5 }} | |||
> | |||
<Popconfirm | |||
title="确认删除吗?" | |||
onConfirm={() => deleteRecipeInfo(item.id)} | |||
okText="确定" | |||
cancelText="取消" | |||
> | |||
<CloseOutlined /> | |||
</Popconfirm> | |||
</a> : "" | |||
} | |||
</span> | |||
)} | |||
{item.name} | |||
@@ -188,6 +197,7 @@ const RecipeInfoForm = (props) => { | |||
}} | |||
values={recipeInfo} | |||
isWeight={props.isWeight} | |||
codeList={props.codeList} | |||
detailModalOpen={detailModalOpen} | |||
/> | |||
</div> | |||
@@ -35,7 +35,7 @@ const UpdateRecipeInfoForm = (props) => { | |||
<Input placeholder='请输入配方名称' /> | |||
</Form.Item> | |||
{props.isWeight == 1 ? | |||
<Form.Item name="referenceWeight" label="基准克数"> | |||
<Form.Item name="referenceWeight" label="基准克数" rules={[{ required: true }]}> | |||
<InputNumber /> | |||
</Form.Item> : ""} | |||
<Form.Item name="sort" label="排序"> | |||
@@ -17,6 +17,7 @@ const recipeinfo = () => { | |||
const [current, setCurrent] = useState(1); | |||
const [defaultCurrent, setDefaultCurrent] = useState(1); | |||
const [total, setTotal] = useState(20); | |||
const [codeList, setCodeList] = useState([]); | |||
const isWeightList = [ | |||
{ value: false, label: '标准模式' }, | |||
{ value: true, label: '称重模式' }, | |||
@@ -24,6 +25,11 @@ const recipeinfo = () => { | |||
useEffect(() => { | |||
initGroupList(false); | |||
api.GetBasicRoleCode().then((r) => { | |||
if (r.data) { | |||
setCodeList(r.data) | |||
} | |||
}) | |||
}, []); | |||
const initGroupList = async (isWeight) => { | |||
var data = await api.getRecipeGroupList(isWeight); | |||
@@ -53,9 +59,9 @@ const recipeinfo = () => { | |||
setRecipeInfoValues(data.data); | |||
} | |||
const addRecipePage = async () => { | |||
if(groupId === undefined){ | |||
if (groupId === undefined) { | |||
message.error("请先选择一个配方分组"); | |||
}else{ | |||
} else { | |||
var data = {}; | |||
data.recipeGroupId = groupId; | |||
await api.addRecipePage(data); | |||
@@ -67,9 +73,9 @@ const recipeinfo = () => { | |||
} | |||
} | |||
const deleteRecipePage = async () => { | |||
if(groupId === undefined){ | |||
if (groupId === undefined) { | |||
message.error("请先选择一个配方分组"); | |||
}else{ | |||
} else { | |||
await api.deleteRecipePage(groupId, current).then((r) => { | |||
if (r.data) { | |||
message.success('删除成功') | |||
@@ -118,19 +124,20 @@ const recipeinfo = () => { | |||
style={{ height: '800px', overflowY: 'auto' }} | |||
headStyle={{ position: 'sticky', top: 0, background: 'white', zIndex: 1 }} | |||
extra={ | |||
<Button | |||
type="default" | |||
block | |||
ghost | |||
onClick={() => { | |||
handleModalVisible(true); | |||
}} | |||
style={{ | |||
float: 'right', | |||
background: '#FA541C' | |||
}}> | |||
<PlusOutlined />添加分组 | |||
</Button> | |||
codeList.includes("recipeGroupAdd") ? | |||
<Button | |||
type="default" | |||
block | |||
ghost | |||
onClick={() => { | |||
handleModalVisible(true); | |||
}} | |||
style={{ | |||
float: 'right', | |||
background: '#FA541C' | |||
}}> | |||
<PlusOutlined />添加分组 | |||
</Button> : "" | |||
} | |||
> | |||
<Switch | |||
@@ -174,21 +181,26 @@ const recipeinfo = () => { | |||
borderStyle: 'solid' | |||
}} | |||
extra={ | |||
<div> | |||
<FormOutlined | |||
onClick={() => { | |||
setRecipeGroupValues(x) | |||
handleModalVisible(true) | |||
}} | |||
/> | |||
<Popconfirm | |||
title="确认删除吗?" | |||
onConfirm={() => deleteGroup(x.id)} | |||
okText="确定" | |||
cancelText="取消" | |||
> | |||
<DeleteOutlined style={{ marginLeft: 10 }} /> | |||
</Popconfirm> | |||
<div style={{ height: 20 }}> | |||
{ | |||
codeList.includes("recipeGroupUp") ? <FormOutlined | |||
onClick={() => { | |||
setRecipeGroupValues(x) | |||
handleModalVisible(true) | |||
}} | |||
/> : "" | |||
} | |||
{ | |||
codeList.includes("recipeGroupDel") ? | |||
<Popconfirm | |||
title="确认删除吗?" | |||
onConfirm={() => deleteGroup(x.id)} | |||
okText="确定" | |||
cancelText="取消" | |||
> | |||
<DeleteOutlined style={{ marginLeft: 10 }} /> | |||
</Popconfirm> : "" | |||
} | |||
</div> | |||
} | |||
> | |||
@@ -204,9 +216,9 @@ const recipeinfo = () => { | |||
title='配方' | |||
style={{ height: '800px' }} | |||
> | |||
<div style={{ height:'100%', overflow: 'hidden', clear: 'both' }}> | |||
<div style={{ height: '100%', overflow: 'hidden', clear: 'both' }}> | |||
{ | |||
<RecipeInfoForm values={recipeInfoValues} current={current} groupId={groupId} isWeight={isWeight} /> | |||
<RecipeInfoForm values={recipeInfoValues} current={current} groupId={groupId} isWeight={isWeight} codeList={codeList} /> | |||
} | |||
<div style={{ textAlign: 'center', marginTop: 35 }}> | |||
<Pagination | |||
@@ -218,26 +230,32 @@ const recipeinfo = () => { | |||
onChange={onChangepage} | |||
showSizeChanger={false} | |||
/> | |||
<Button | |||
type="primary" | |||
style={{ marginLeft: 10 }} | |||
onClick={() => addRecipePage()} | |||
> | |||
<PlusOutlined />新增页 | |||
</Button> | |||
<Popconfirm | |||
title="删除当前页及其配方?" | |||
onConfirm={() => deleteRecipePage()} | |||
okText="确定" | |||
cancelText="取消" | |||
> | |||
<Button | |||
type="primary" | |||
style={{ marginLeft: 10 }} | |||
> | |||
<CloseOutlined />删除当前页 | |||
</Button> | |||
</Popconfirm> | |||
{ | |||
codeList.includes("recipeInfoPageAdd") ? | |||
<Button | |||
type="primary" | |||
style={{ marginLeft: 10 }} | |||
onClick={() => addRecipePage()} | |||
> | |||
<PlusOutlined />新增页 | |||
</Button> : "" | |||
} | |||
{ | |||
codeList.includes("recipeInfoPageDel") ? | |||
<Popconfirm | |||
title="删除当前页及其配方?" | |||
onConfirm={() => deleteRecipePage()} | |||
okText="确定" | |||
cancelText="取消" | |||
> | |||
<Button | |||
type="primary" | |||
style={{ marginLeft: 10 }} | |||
> | |||
<CloseOutlined />删除当前页 | |||
</Button> | |||
</Popconfirm> : "" | |||
} | |||
</div> | |||
</div> | |||
</ProCard> | |||
@@ -91,4 +91,9 @@ export default { | |||
method: 'Get', | |||
}); | |||
}, | |||
GetBasicRoleCode() { | |||
return request(getDataBaseUrl() + `/api/roles/getBasicRoleCode`, { | |||
method: 'Get', | |||
}); | |||
}, | |||
} |
@@ -1,46 +1,56 @@ | |||
import { PageContainer } from "@ant-design/pro-layout"; | |||
import { Tabs, Card, Input, DatePicker, Button } from "antd" | |||
import { Tabs, Card, Input, DatePicker, Button, Select } from "antd" | |||
import ProTable from '@ant-design/pro-table'; | |||
import React, { useState, useEffect } from 'react'; | |||
import moment from 'moment'; | |||
import api from "../service"; | |||
const { RangePicker } = DatePicker; | |||
const batchingreport = () =>{ | |||
const batchingreport = () => { | |||
const [tabIndex, setTabIndex] = useState(1); | |||
const [batchingName, setBatchingName] = useState(''); | |||
const [storeName, setStoreName] = useState(''); | |||
const [deviceName, setDeviceName] = useState(''); | |||
const [isWeight, setIsWeight] = useState(); | |||
const [dataSource, setDataSource] = useState([]); | |||
const [loading, setLoading] = useState(false); | |||
const [timeRange, setTimeRange] = useState([ | |||
moment(moment(new Date(Date.now())).format('YYYY-MM-DD 00:00:00')), | |||
moment(moment(new Date(Date.now())).format('YYYY-MM-DD 23:59:59')), | |||
moment().startOf('month'), | |||
moment().endOf('month'), | |||
]); | |||
const isWeightList = [ | |||
{ value: false, label: '标准模式' }, | |||
{ value: true, label: '称重模式' }, | |||
]; | |||
useEffect(() => { | |||
initData(); | |||
}, [tabIndex]); | |||
const initData = async () => { | |||
setLoading(true) | |||
var data = []; | |||
if (tabIndex == 1) { | |||
data = await api.getBatchingUseSummary({ "batchingName": batchingName, "startTime": timeRange[0]._i, "endTime": timeRange[1]._i, "storeName": storeName, "deviceName": deviceName }); | |||
data = await api.getBatchingUseSummary({ "batchingName": batchingName, "startTime": timeRange[0]._i, "endTime": timeRange[1]._i, "storeName": storeName, "deviceName": deviceName, "isWeight": isWeight }); | |||
} | |||
setDataSource(data.data) | |||
setLoading(false) | |||
} | |||
const resetRequest = async () => { | |||
setLoading(true) | |||
setBatchingName('') | |||
setStoreName('') | |||
setDeviceName('') | |||
var startDate = moment(new Date(Date.now())).format('YYYY-MM-DD 00:00:00'); | |||
var endDate = moment(new Date(Date.now())).format('YYYY-MM-DD 23:59:59'); | |||
setTimeRange([moment(startDate),moment(endDate)]) | |||
var startDate = moment().startOf('month'); | |||
var endDate = moment().endOf('month'); | |||
setTimeRange([startDate, endDate]) | |||
var data = [] | |||
if (tabIndex == 1) { | |||
data = await api.getBatchingUseSummary({ "batchingName": "", "startTime": startDate, "endTime": endDate, "storeName": "", "deviceName": "" }); | |||
data = await api.getBatchingUseSummary({ "batchingName": "", "startTime": startDate, "endTime": endDate, "storeName": "", "deviceName": "", "isWeight": "" }); | |||
} | |||
setDataSource(data.data) | |||
setLoading(false) | |||
} | |||
const summaryColumns = [ | |||
{ | |||
@@ -75,12 +85,12 @@ const batchingreport = () =>{ | |||
ellipsis: true, | |||
}, | |||
] | |||
return( | |||
return ( | |||
<PageContainer | |||
header={{ | |||
title: '', | |||
breadcrumb: {}, | |||
}} | |||
header={{ | |||
title: '', | |||
breadcrumb: {}, | |||
}} | |||
> | |||
<Card style={{ marginBottom: 20 }}> | |||
<div style={{ display: 'flex', alignItems: 'center', width: '100%' }}> | |||
@@ -90,14 +100,25 @@ const batchingreport = () =>{ | |||
<Input placeholder="请输入门店名称" style={{ width: '15%', margin: 10 }} value={storeName} onChange={(a) => { setStoreName(a.target.value) }} /> | |||
<span>设备名称:</span> | |||
<Input placeholder="请输入设备名称" style={{ width: '15%', margin: 10 }} value={deviceName} onChange={(a) => { setDeviceName(a.target.value) }} /> | |||
<span>配方模式:</span> | |||
<Select | |||
style={{ width: '15%', margin: 10 }} | |||
options={isWeightList} | |||
placeholder="请选择是否称重" | |||
allowClear | |||
onChange={(a) => { setIsWeight(a) }} | |||
/> | |||
</div> | |||
<div style={{ display: 'flex', alignItems: 'center', width: '100%' }}> | |||
<span>使用时间:</span> | |||
<RangePicker showTime style={{ width: '25%', margin: 10 }} value={timeRange} onChange={(date, dateStrings) => { | |||
let tempDate = [ | |||
moment(moment(new Date(dateStrings[0])).format('YYYY-MM-DD HH:mm:ss')), | |||
moment(moment(new Date(dateStrings[1])).format('YYYY-MM-DD HH:mm:ss')), | |||
] | |||
let tempDate = ['', ''] | |||
if (date != null) { | |||
tempDate = [ | |||
moment(moment(new Date(dateStrings[0])).format('YYYY-MM-DD HH:mm:ss')), | |||
moment(moment(new Date(dateStrings[1])).format('YYYY-MM-DD HH:mm:ss')), | |||
] | |||
} | |||
setTimeRange(tempDate); | |||
}} /> | |||
<Button onClick={() => { resetRequest() }}> | |||
@@ -118,7 +139,7 @@ const batchingreport = () =>{ | |||
return { | |||
label: '物料使用汇总', | |||
key: id, | |||
children: | |||
children: | |||
<ProTable | |||
headerTitle="物料使用汇总" | |||
rowKey="id" | |||
@@ -127,6 +148,7 @@ const batchingreport = () =>{ | |||
toolBarRender={false} | |||
columns={summaryColumns} | |||
dataSource={dataSource} | |||
loading={loading} | |||
/> | |||
} | |||
})} | |||
@@ -1,51 +1,60 @@ | |||
import { PageContainer } from "@ant-design/pro-layout"; | |||
import { Tabs, Card, Input, DatePicker, Button } from "antd" | |||
import { Tabs, Card, Input, DatePicker, Button, Select } from "antd" | |||
import ProTable from '@ant-design/pro-table'; | |||
import React, { useState, useEffect } from 'react'; | |||
import moment from 'moment'; | |||
import api from "../service"; | |||
const { RangePicker } = DatePicker; | |||
const recipereport = () => { | |||
const [tabIndex, setTabIndex] = useState(1); | |||
const [recipeName, setRecipeName] = useState(''); | |||
const [storeName, setStoreName] = useState(''); | |||
const [deviceName, setDeviceName] = useState(''); | |||
const [isWeight, setIsWeight] = useState(); | |||
const [dataSource, setDataSource] = useState([]); | |||
const [loading, setLoading] = useState(false); | |||
const [timeRange, setTimeRange] = useState([ | |||
moment(moment(new Date(Date.now())).format('YYYY-MM-DD 00:00:00')), | |||
moment(moment(new Date(Date.now())).format('YYYY-MM-DD 23:59:59')), | |||
moment().startOf('month'), | |||
moment().endOf('month'), | |||
]); | |||
const isWeightList = [ | |||
{ value: false, label: '标准模式' }, | |||
{ value: true, label: '称重模式' }, | |||
]; | |||
useEffect(() => { | |||
initData(); | |||
}, [tabIndex]); | |||
const initData = async () => { | |||
setLoading(true) | |||
var data = []; | |||
if (tabIndex == 1) { | |||
data = await api.getRecipeUseDetail({ "recipeName": recipeName, "startTime": timeRange[0]._i, "endTime": timeRange[1]._i, "storeName": storeName, "deviceName": deviceName }); | |||
data = await api.getRecipeUseDetail({ "recipeName": recipeName, "startTime": timeRange[0]._i, "endTime": timeRange[1]._i, "storeName": storeName, "deviceName": deviceName, "isWeight": isWeight }); | |||
} else { | |||
data = await api.getRecipeUseSummary({ "recipeName": recipeName, "startTime": timeRange[0]._i, "endTime": timeRange[1]._i, "storeName": storeName, "deviceName": deviceName }); | |||
data = await api.getRecipeUseSummary({ "recipeName": recipeName, "startTime": timeRange[0]._i, "endTime": timeRange[1]._i, "storeName": storeName, "deviceName": deviceName, "isWeight": isWeight }); | |||
} | |||
setDataSource(data.data) | |||
setLoading(false) | |||
} | |||
const resetRequest = async () => { | |||
setLoading(true) | |||
setRecipeName('') | |||
setStoreName('') | |||
setDeviceName('') | |||
var startDate = moment(new Date(Date.now())).format('YYYY-MM-DD 00:00:00'); | |||
var endDate = moment(new Date(Date.now())).format('YYYY-MM-DD 23:59:59'); | |||
setTimeRange([moment(startDate),moment(endDate)]) | |||
var startDate = moment().startOf('month'); | |||
var endDate = moment().endOf('month'); | |||
setTimeRange([startDate, endDate]) | |||
var data = [] | |||
if (tabIndex == 1) { | |||
data = await api.getRecipeUseDetail({ "recipeName": "", "startTime": startDate, "endTime": endDate, "storeName": "", "deviceName": "" }); | |||
data = await api.getRecipeUseDetail({ "recipeName": "", "startTime": startDate, "endTime": endDate, "storeName": "", "deviceName": "", "isWeight": "" }); | |||
} else { | |||
data = await api.getRecipeUseSummary({ "recipeName": "", "startTime": startDate, "endTime": endDate, "storeName": "", "deviceName": "" }); | |||
data = await api.getRecipeUseSummary({ "recipeName": "", "startTime": startDate, "endTime": endDate, "storeName": "", "deviceName": "", "isWeight": "" }); | |||
} | |||
setDataSource(data.data) | |||
setLoading(false) | |||
} | |||
const detailColumns = [ | |||
@@ -129,14 +138,25 @@ const recipereport = () => { | |||
<Input placeholder="请输入门店名称" style={{ width: '15%', margin: 10 }} value={storeName} onChange={(a) => { setStoreName(a.target.value) }} /> | |||
<span>设备名称:</span> | |||
<Input placeholder="请输入设备名称" style={{ width: '15%', margin: 10 }} value={deviceName} onChange={(a) => { setDeviceName(a.target.value) }} /> | |||
<span>配方模式:</span> | |||
<Select | |||
style={{ width: '15%', margin: 10 }} | |||
options={isWeightList} | |||
placeholder="请选择是否称重" | |||
allowClear | |||
onChange={(a) => { setIsWeight(a) }} | |||
/> | |||
</div> | |||
<div style={{ display: 'flex', alignItems: 'center', width: '100%' }}> | |||
<span>使用时间:</span> | |||
<RangePicker showTime style={{ width: '25%', margin: 10 }} value={timeRange} onChange={(date, dateStrings) => { | |||
let tempDate = [ | |||
moment(moment(new Date(dateStrings[0])).format('YYYY-MM-DD HH:mm:ss')), | |||
moment(moment(new Date(dateStrings[1])).format('YYYY-MM-DD HH:mm:ss')), | |||
] | |||
let tempDate = ['', ''] | |||
if (date != null) { | |||
tempDate = [ | |||
moment(moment(new Date(dateStrings[0])).format('YYYY-MM-DD HH:mm:ss')), | |||
moment(moment(new Date(dateStrings[1])).format('YYYY-MM-DD HH:mm:ss')), | |||
] | |||
} | |||
setTimeRange(tempDate); | |||
}} /> | |||
<Button onClick={() => { resetRequest() }}> | |||
@@ -166,6 +186,7 @@ const recipereport = () => { | |||
toolBarRender={false} | |||
columns={detailColumns} | |||
dataSource={dataSource} | |||
loading={loading} | |||
/> | |||
: | |||
<ProTable | |||
@@ -176,6 +197,7 @@ const recipereport = () => { | |||
toolBarRender={false} | |||
columns={summaryColumns} | |||
dataSource={dataSource} | |||
loading={loading} | |||
/> | |||
} | |||
})} | |||
@@ -28,7 +28,7 @@ const CreateForm = (props) => { | |||
<Form.Item name="name" label="门店名称" rules={[{ required: true }]}> | |||
<Input placeholder='请输入门店名称'/> | |||
</Form.Item> | |||
<Form.Item name="orgId" label="组织名称" rules={[{ required: false }]}> | |||
<Form.Item name="orgId" label="组织名称" rules={[{ required: true }]}> | |||
<TreeSelect | |||
style={{ width: '100%' }} | |||
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }} | |||
@@ -44,6 +44,9 @@ const CreateForm = (props) => { | |||
<Form.Item name="phone" label="手机号"> | |||
<Input placeholder='请输入手机号'/> | |||
</Form.Item> | |||
<Form.Item name="position" label="位置"> | |||
<Input placeholder='请输入位置'/> | |||
</Form.Item> | |||
<Form.Item name="description" label="描述"> | |||
<TextArea rows={4} rules={[{ max: 500 }]} /> | |||
</Form.Item> | |||
@@ -16,9 +16,14 @@ const storeinfo = () => { | |||
const [mockData, setMockData] = useState([]); | |||
const [targetKeys, setTargetKeys] = useState([]); | |||
const [storeId, setStoreId] = useState([]); | |||
const [hasDeviceRelation, setHasDeviceRelation] = useState(false); | |||
const [isWeight, setIsWeight] = useState(''); | |||
const [codeList, setCodeList] = useState([]); | |||
useEffect(() => { | |||
api.GetBasicRoleCode().then((r) => { | |||
if (r.data) { | |||
setCodeList(r.data) | |||
} | |||
}) | |||
initOrg() | |||
getAllRecipeList(isWeight) | |||
}, []); | |||
@@ -40,11 +45,6 @@ const storeinfo = () => { | |||
setMockData(tempMockData); | |||
}); | |||
} | |||
const getHasDeviceRelation = async (id) => { | |||
api.getHasDeviceRelation(id).then((r) => { | |||
setHasDeviceRelation(r.data) | |||
}) | |||
} | |||
const BatchDeletion = () => { | |||
return ( | |||
selectedRowsState?.length > 0 && | |||
@@ -145,6 +145,12 @@ const storeinfo = () => { | |||
ellipsis: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '位置', | |||
dataIndex: 'position', | |||
ellipsis: true, | |||
hideInSearch: true, | |||
}, | |||
{ | |||
title: '描述', | |||
dataIndex: 'description', | |||
@@ -158,45 +164,47 @@ const storeinfo = () => { | |||
fixed: 'right', | |||
width: 350, | |||
render: (_, record) => [ | |||
<a | |||
onClick={() => { | |||
handleModalOpen(true); | |||
setStepFormValues(record); | |||
}} | |||
> | |||
更新 | |||
</a>, | |||
<a | |||
key="edit" | |||
onClick={() => { | |||
getHasDeviceRelation(record.id); | |||
getAllRecipeList(isWeight) | |||
setrecipeList(record.id); | |||
setStoreId(record.id); | |||
setIsModalOpen(true); | |||
}} | |||
> | |||
设置门店配方 | |||
</a>, | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
api.deleteStore([record.id]).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm>, | |||
codeList.includes("storeUp") ? | |||
<a | |||
onClick={() => { | |||
handleModalOpen(true); | |||
setStepFormValues(record); | |||
}} | |||
> | |||
更新 | |||
</a> : "", | |||
codeList.includes("storeSetRecipe") ? | |||
<a | |||
key="edit" | |||
onClick={() => { | |||
getAllRecipeList(isWeight) | |||
setrecipeList(record.id); | |||
setStoreId(record.id); | |||
setIsModalOpen(true); | |||
}} | |||
> | |||
设置门店配方 | |||
</a> : "", | |||
codeList.includes("storeDel") ? | |||
<Popconfirm | |||
type="primary" | |||
key="primary" | |||
title="确认删除吗?" | |||
okText="是" | |||
cancelText="否" | |||
onConfirm={() => { | |||
api.deleteStore([record.id]).then((r) => { | |||
if (r.succeeded) { | |||
message.success('删除成功'); | |||
actionRef.current.reload(); | |||
} else { | |||
message.error(r.errors); | |||
} | |||
}); | |||
}} | |||
> | |||
<a href="#">删除</a> | |||
</Popconfirm> : "", | |||
], | |||
} | |||
] | |||
@@ -217,16 +225,18 @@ const storeinfo = () => { | |||
labelWidth: 120, | |||
}} | |||
toolBarRender={() => [ | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalOpen(true); | |||
}} | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button>, | |||
<BatchDeletion /> | |||
codeList.includes("storeAdd") ? | |||
<Button | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
handleModalOpen(true); | |||
}} | |||
> | |||
<PlusOutlined /> 新建 | |||
</Button> : "", | |||
codeList.includes("storeDel") ? | |||
<BatchDeletion /> : "" | |||
]} | |||
request={async (params) => { | |||
let storeData = []; | |||
@@ -281,7 +291,6 @@ const storeinfo = () => { | |||
title="设置门店配方" | |||
open={isModalOpen} | |||
destroyOnClose | |||
footer={hasDeviceRelation ? <span style={{ color: '#FA541C' }}>已有设备使用,请取消该门店下所有设备的绑定配方!</span> : undefined} | |||
onOk={() => { editStoreRecipe() }} | |||
onCancel={() => { | |||
setIsModalOpen(false) | |||
@@ -32,11 +32,6 @@ export default { | |||
method: 'Get', | |||
}); | |||
}, | |||
getHasDeviceRelation(id) { | |||
return request(getDataBaseUrl() + `/api/store/getHasDeviceRelation?storeId=${id}`, { | |||
method: 'Get', | |||
}); | |||
}, | |||
getStoreRelation(id) { | |||
return request(getDataBaseUrl() + `/api/store/getStoreRelation?storeId=${id}`, { | |||
method: 'Get', | |||
@@ -48,4 +43,9 @@ export default { | |||
data: data, | |||
}); | |||
}, | |||
GetBasicRoleCode() { | |||
return request(getDataBaseUrl() + `/api/roles/getBasicRoleCode`, { | |||
method: 'Get', | |||
}); | |||
}, | |||
} |
@@ -69,8 +69,7 @@ const devicelog = () => { | |||
span: '1', | |||
collapseRender: false, | |||
defaultParams: { | |||
storeName: '99', | |||
// createAt: [moment().startOf('day'), moment().endOf('day')], | |||
createAt: [moment().startOf('month'), moment().endOf('month')], | |||
}, | |||
}} | |||
request={async (params) => { | |||