From 7e94a0d0737e5957a9808944c04ecb9ebcf2c1cd Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Sat, 26 Oct 2024 09:15:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E6=96=99=E7=B3=BB=E7=BB=9F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8F=90=E4=BA=A420241026?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/batching/batchinginfo/index.jsx | 93 +++++++------ src/pages/batching/batchinginfo/service.js | 5 + .../account/components/BasicFunctionForm.jsx | 110 +++++++++++++++ .../company/account/components/MenuForm.jsx | 2 +- src/pages/company/account/index.jsx | 48 ++++++- src/pages/company/account/service.js | 23 +++- src/pages/device/deviceInfo/index.jsx | 111 ++++++++------- src/pages/device/deviceInfo/service.js | 5 + src/pages/interfacedoc/index/index.jsx | 2 +- .../roles/components/BasicFunctionForm.jsx | 110 +++++++++++++++ src/pages/org/roles/index.jsx | 57 +++++++- src/pages/org/roles/service.js | 21 +++ .../recipeinfo/components/CreateAttrForm.jsx | 2 +- .../components/RecipeDetailForm.jsx | 93 +++++++------ .../recipeinfo/components/RecipeInfoForm.jsx | 72 +++++----- .../components/UpdateRecipeInfoForm.jsx | 2 +- src/pages/recipe/recipeinfo/index.jsx | 126 ++++++++++-------- src/pages/recipe/recipeinfo/service.js | 5 + src/pages/report/batchingreport/index.jsx | 60 ++++++--- src/pages/report/recipereport/index.jsx | 52 +++++--- .../store/storeinfo/components/CreateForm.jsx | 5 +- src/pages/store/storeinfo/index.jsx | 121 +++++++++-------- src/pages/store/storeinfo/service.js | 10 +- src/pages/sys/devicelog/index.jsx | 3 +- 24 files changed, 814 insertions(+), 324 deletions(-) create mode 100644 src/pages/company/account/components/BasicFunctionForm.jsx create mode 100644 src/pages/org/roles/components/BasicFunctionForm.jsx diff --git a/src/pages/batching/batchinginfo/index.jsx b/src/pages/batching/batchinginfo/index.jsx index 87cc494..e1f42a6 100644 --- a/src/pages/batching/batchinginfo/index.jsx +++ b/src/pages/batching/batchinginfo/index.jsx @@ -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) => [ - { - handleModalVisible(true); - setStepFormValues(record); - }} - > - 更新 - , - { - api.deleteBatching([record.id]).then((r) => { - if (r.succeeded) { - message.success('删除成功'); - actionRef.current.reload(); - } else { - message.error(r.errors); - } - }); - }} - > - 删除 - , + codeList.includes("batchingUp") ? + { + handleModalVisible(true); + setStepFormValues(record); + }} + > + 更新 + : "" + , + codeList.includes("batchingDel") ? + { + api.deleteBatching([record.id]).then((r) => { + if (r.succeeded) { + message.success('删除成功'); + actionRef.current.reload(); + } else { + message.error(r.errors); + } + }); + }} + > + 删除 + : "", ], } ] @@ -165,18 +176,20 @@ const batchinginfo = () => { labelWidth: 120, }} toolBarRender={() => [ - , - + codeList.includes("batchingAdd") ? + : "", + codeList.includes("batchingDel") ? + : "" ]} request={async (params) => { let batchingData = []; diff --git a/src/pages/batching/batchinginfo/service.js b/src/pages/batching/batchinginfo/service.js index bbcfbdf..dadf7b6 100644 --- a/src/pages/batching/batchinginfo/service.js +++ b/src/pages/batching/batchinginfo/service.js @@ -31,4 +31,9 @@ export default { data: data, }); }, + GetBasicRoleCode() { + return request(getDataBaseUrl() + `/api/roles/getBasicRoleCode`, { + method: 'Get', + }); + }, } diff --git a/src/pages/company/account/components/BasicFunctionForm.jsx b/src/pages/company/account/components/BasicFunctionForm.jsx new file mode 100644 index 0000000..7a935e6 --- /dev/null +++ b/src/pages/company/account/components/BasicFunctionForm.jsx @@ -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 ( + props.onSubmit(checkedKeys)} + onCancel={() => props.onCancel()} + maskClosable={false} + destroyOnClose + > + + + + 全选 + + { + if (getTreeLength(props.treeData) == keys.length) { + setcheckAll(true) + setindeterminate(false); + } else { + setcheckAll(false) + setindeterminate(true); + } + setCheckedKeys(keys); + }} + defaultExpandAll={false} + checkedKeys={checkedKeys} + checkable + /> + + + + ) +} + +export default BasicFunctionForm; \ No newline at end of file diff --git a/src/pages/company/account/components/MenuForm.jsx b/src/pages/company/account/components/MenuForm.jsx index 8201025..e80a1b5 100644 --- a/src/pages/company/account/components/MenuForm.jsx +++ b/src/pages/company/account/components/MenuForm.jsx @@ -74,7 +74,7 @@ const MenuForm = (props) => { var html = props.onSubmit(checkedKeys)} onCancel={() => props.onCancel()} diff --git a/src/pages/company/account/index.jsx b/src/pages/company/account/index.jsx index d1312a7..fe40140 100644 --- a/src/pages/company/account/index.jsx +++ b/src/pages/company/account/index.jsx @@ -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 = () => { {' '} 企业菜单授权 , + { + api.GetBasicFunctionList(record.sysRoleId).then((r) => { + setBasicValues(r.data); + }); + handleBasicModalVisible(true); + setStepFormValues(record); + }} + > + 基础功能授权 + , { datas={stepFormValues || {}} /> ) : null} + + { + 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 || {}} + /> + { 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) => [ - { - handleModalOpen(true); - setStepFormValues(record); - }} - > - 更新 - , - { - getStoreRecipeList(record.storeId, isWeight); - setStoreId(record.storeId); - setrecipeList(record.id); - setDeviceId(record.id); - setIsModalOpen(true); - }} - > - 设置设备配方 - , - { - api.deleteDevice([record.id]).then((r) => { - if (r.succeeded) { - message.success('删除成功'); - actionRef.current.reload(); - } else { - message.error(r.errors); - } - }); - }} - > - 删除 - , + codeList.includes("deviceUp") ? + { + handleModalOpen(true); + setStepFormValues(record); + }} + > + 更新 + : "", + codeList.includes("deviceSetRecipe") ? + { + getStoreRecipeList(record.storeId, isWeight); + setStoreId(record.storeId); + setrecipeList(record.id); + setDeviceId(record.id); + setIsModalOpen(true); + }} + > + 设置设备配方 + : "", + codeList.includes("deviceDel") ? + { + api.deleteDevice([record.id]).then((r) => { + if (r.succeeded) { + message.success('删除成功'); + actionRef.current.reload(); + } else { + message.error(r.errors); + } + }); + }} + > + 删除 + : "", ], } ] @@ -227,16 +236,18 @@ const deviceinfo = () => { labelWidth: 120, }} toolBarRender={() => [ - , - + codeList.includes("deviceAdd") ? + : "", + codeList.includes("deviceDel") ? + : "" ]} request={async (params) => { let storeData = []; @@ -289,7 +300,7 @@ const deviceinfo = () => { { editDeviceRecipe() }} diff --git a/src/pages/device/deviceInfo/service.js b/src/pages/device/deviceInfo/service.js index 9b24c10..25a5bcf 100644 --- a/src/pages/device/deviceInfo/service.js +++ b/src/pages/device/deviceInfo/service.js @@ -40,4 +40,9 @@ export default { data: data, }); }, + GetBasicRoleCode() { + return request(getDataBaseUrl() + `/api/roles/getBasicRoleCode`, { + method: 'Get', + }); + }, } \ No newline at end of file diff --git a/src/pages/interfacedoc/index/index.jsx b/src/pages/interfacedoc/index/index.jsx index 96cc463..42d1cce 100644 --- a/src/pages/interfacedoc/index/index.jsx +++ b/src/pages/interfacedoc/index/index.jsx @@ -3,7 +3,7 @@ const interfacedoc = () => { return (