diff --git a/src/pages/company/account/components/MenuForm.jsx b/src/pages/company/account/components/MenuForm.jsx index cd21632..8201025 100644 --- a/src/pages/company/account/components/MenuForm.jsx +++ b/src/pages/company/account/components/MenuForm.jsx @@ -1,36 +1,76 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Tree, Row, Col, List,Tag } from 'antd'; +import { Modal, Tree, Row, Col, Checkbox } from 'antd'; import api from '../service'; import Enumerable from 'linq'; const MenuForm = (props) => { - const [load, setLoad] = useState(); - const [selectedRowsState, setSelectedRows] = useState(); + const [load, setLoad] = useState([]); const [checkedKeys, setCheckedKeys] = useState(); + const [indeterminate, setindeterminate] = useState(false); + const [checkAll,setcheckAll] = useState(false); useEffect(async () => { var arr = []; + var filteredArr=[] Enumerable.from(props.values).forEach(t => { if(!t.isParentMenu){ arr.push(t.id); } - + if(t.id !== null && typeof t.id !== "undefined"){ + filteredArr.push(t); + } }); setCheckedKeys(arr) - console.log("props.values",props.datas) - var parm={getType:'ALL',type:props.datas.type} - var ret = await api.GetMenu(parm); - var data = Enumerable.from(ret.data).toArray(); + 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.modalVisible]) - - const lbl = () => { - var arr = []; - Enumerable.from(props.values).forEach(t => { - arr.push({t.name}); - }); - return arr; + function getTreeLength(tree) { + 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) { + console.log(tree) + //遍历树 获取id数组 + for (const i in tree) { + result.push(tree[i].key); // 遍历项目满足条件后的操作 + if (tree[i].children) { + //存在子节点就递归 + getAllIds(tree[i].children, result); + } + } + return result; } - var html = { maskClosable={false}> + + 全选 + { setCheckedKeys(keys) }} - defaultExpandAll={true} + 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 /> diff --git a/src/pages/company/account/index.jsx b/src/pages/company/account/index.jsx index d4db7a2..e4ed5ea 100644 --- a/src/pages/company/account/index.jsx +++ b/src/pages/company/account/index.jsx @@ -123,7 +123,7 @@ const companyManage = () => { var parm={getType:'ALL',type:0} api.GetMenu(parm).then((r) => { if(r.data){ - setTreeData(r.data.data); + setTreeData(r.data); } }); diff --git a/src/pages/database/goods/goodstypemanage/components/CreateForm.jsx b/src/pages/database/goods/goodstypemanage/components/CreateForm.jsx index 23b6d38..8b9d197 100644 --- a/src/pages/database/goods/goodstypemanage/components/CreateForm.jsx +++ b/src/pages/database/goods/goodstypemanage/components/CreateForm.jsx @@ -26,7 +26,7 @@ const CreateForm = (props) => { - + { > 更新 , - + { + await DelDeviceInfo([record.id]).then((r) => { + if(r.data){ + message.success('删除成功,即将刷新'); + actionRef.current.reload(); + }else{ + message.error('删除失败'); + } + + }); + }} + onCancel={() => { }} + > + 删除 + , // { @@ -326,15 +346,15 @@ const handleRemove = async (selectedRows) => { > 新建 , - , + // , ]} request={async (params) => { var data = []; diff --git a/src/pages/device/deviceVesion/index.jsx b/src/pages/device/deviceVesion/index.jsx index b2f6e90..20ce765 100644 --- a/src/pages/device/deviceVesion/index.jsx +++ b/src/pages/device/deviceVesion/index.jsx @@ -6,7 +6,7 @@ import { PlusOutlined } from '@ant-design/icons'; import ProTable from '@ant-design/pro-table'; import CreateForm from './components/CreateForm'; import { GetDeviceVesionPage, AddDeviceVesion, DelDeviceVesion, UpdateDeviceVesion, GetProductList,UpdateStatus } from "./services" - +import { history } from 'umi'; const key = 'message'; //添加 @@ -136,16 +136,17 @@ const GoodsTypeManage = () => { dataIndex: 'productName', valueType: 'textarea', }, - { - title: '是否存在模板', - dataIndex: 'templatePath', - valueType: 'textarea', - render: (_, record) => [ -
- 存在模板 - 无模板 -
], - }, + // { + // title: '是否存在模板', + // dataIndex: 'templatePath', + // valueType: 'textarea', + // hideInSearch: true, + // render: (_, record) => [ + //
+ // 存在模板 + // 无模板 + //
], + // }, { title: '操作', dataIndex: 'option', @@ -182,26 +183,37 @@ const GoodsTypeManage = () => { >
删除 , - { - setCurrentRow(record); - setIsModalOpen(true); - setIsAddGoodsTemplate(false); - }} > 上传设备工艺模型, - { - setCurrentRow(record); - setIsModalOpen(true); - setIsAddGoodsTemplate(true); - }} > 上传商品工艺模版, - 下载工艺模板 + // { + // setCurrentRow(record); + // setIsModalOpen(true); + // setIsAddGoodsTemplate(false); + // }} > 上传设备工艺模型, + // { + // setCurrentRow(record); + // setIsModalOpen(true); + // setIsAddGoodsTemplate(true); + // }} > 上传商品工艺模版, + // 下载工艺模板, + { + history.push({ + pathname: '/device/productmanage', + query: { + isAdd: false, + values: record, + tabStatus: 'basis' + }, + }); + }} > 管理, ], }, ]; diff --git a/src/pages/device/product/index.jsx b/src/pages/device/product/index.jsx index ecdd9e1..1f2771b 100644 --- a/src/pages/device/product/index.jsx +++ b/src/pages/device/product/index.jsx @@ -6,7 +6,7 @@ import { PlusOutlined } from '@ant-design/icons'; import ProTable from '@ant-design/pro-table'; import CreateForm from './components/CreateForm'; import { GetProductPage, AddProduct, DelProduct, UpdateProduct,UpdateStatus } from "./services" -import { history } from 'umi'; + const key = 'message'; const { Paragraph, Text } = Typography; const GoodsTypeManage = () => { @@ -75,18 +75,7 @@ const GoodsTypeManage = () => { > 删除 , - { - history.push({ - pathname: '/device/productmanage', - query: { - isAdd: false, - values: record, - tabStatus: 'basis' - }, - }); - }} > 管理, + ], }, ]; diff --git a/src/pages/device/productmanage/components/CreateForm.jsx b/src/pages/device/productmanage/components/CreateForm.jsx index 3204eae..d3f88bd 100644 --- a/src/pages/device/productmanage/components/CreateForm.jsx +++ b/src/pages/device/productmanage/components/CreateForm.jsx @@ -50,7 +50,7 @@ const CreateForm = (props) => { form.setFieldsValue({ id: props?.values?.id, type: props?.values?.type, - deviceVersionKey: props?.values?.deviceVersionKey, + //deviceVersionKey: props?.values?.deviceVersionKey, name: props?.values?.name, dataType: props?.values?.dataType, dataRange: props?.values?.dataRange, @@ -200,7 +200,7 @@ const onChangeboolLabel1=(e)=>{ - + {/* - + */} 属性 diff --git a/src/pages/device/productmanage/components/CreateTopis.jsx b/src/pages/device/productmanage/components/CreateTopis.jsx index 2a39da9..94ca18f 100644 --- a/src/pages/device/productmanage/components/CreateTopis.jsx +++ b/src/pages/device/productmanage/components/CreateTopis.jsx @@ -51,7 +51,7 @@ const onChange=(e)=>{ // initialValues={props?.values} onFinish={()=>{ form.setFieldsValue({ - topics:"/"+props.productCode+"/${deviceKey}/use/"+topics + topics:"/"+props.productCode+"/"+props.productVesion+"/${deviceKey}/use/"+topics }) console.log(form.getFieldsValue()) props?.onFinish(form.getFieldsValue()) @@ -61,20 +61,20 @@ const onChange=(e)=>{ - + - + { const [load, setLoad] = useState(); - const [selectedRowsState, setSelectedRows] = useState(); const [checkedKeys, setCheckedKeys] = useState(); + const [indeterminate, setindeterminate] = useState(false); + const [checkAll,setcheckAll] = useState(false); useEffect(async () => { var arr = []; + var filteredArr=[] Enumerable.from(props.values).forEach(t => { - arr.push(t.id); + if(!t.isParentMenu){ + arr.push(t.id); + } + if(t.id !== null && typeof t.id !== "undefined"){ + filteredArr.push(t); + } }); setCheckedKeys(arr) - var ret = await api.SelectTree(); - var data = Enumerable.from(ret.data).toArray(); + var data =props.treeData; + console.log("props.values",props.values) + console.log("data",data) + console.log("filteredArr",filteredArr) + 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.modalVisible]) + function getTreeLength(tree) { + 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); + } + + }; - const lbl = () => { - var arr = []; - Enumerable.from(props.values).forEach(t => { - arr.push({t.name}); - }); - return arr; + function getAllIds(tree, result) { + console.log(tree) + //遍历树 获取id数组 + for (const i in tree) { + result.push(tree[i].key); // 遍历项目满足条件后的操作 + if (tree[i].children) { + //存在子节点就递归 + getAllIds(tree[i].children, result); + } + } + return result; } - var html = { maskClosable={false}> + + 全选 + { setCheckedKeys(keys) }} - defaultExpandAll={true} + 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 /> diff --git a/src/pages/org/roles/index.jsx b/src/pages/org/roles/index.jsx index 9a536d4..b820318 100644 --- a/src/pages/org/roles/index.jsx +++ b/src/pages/org/roles/index.jsx @@ -5,7 +5,7 @@ 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, setUserGrantData, Enable, Disable, GetRoleMenu, SetDataRole } from './service'; +import { Page, add, edit, removeRole, setMenu, GetMenu, GetRoleMenu, SetDataRole } from './service'; import { useAccess } from 'umi'; import MenuForm from './components/MenuForm'; import OrgForm from './components/OrgForm'; @@ -105,7 +105,7 @@ const roleManager = () => { const [row, setRow] = useState(); const [selectedRowsState, setSelectedRows] = useState(); const [selectData, setSelectData] = useState([]); - + const [treeData, setTreeData] = useState(); /** * 删除节点 * @param selectedRows @@ -190,6 +190,15 @@ const roleManager = () => { return arr; } + useEffect(() => { + var parm={getType:'ALL',type:0} + GetMenu(parm).then((r) => { + if(r.data){ + setTreeData(r.data); + } + + }); + }, []); const columns = [ { @@ -342,6 +351,7 @@ const roleManager = () => { }} modalVisible={updateMenuModalVisible} values={row || {}} + treeData={treeData} /> ) : null} diff --git a/src/pages/org/roles/service.js b/src/pages/org/roles/service.js index dff95d6..e253d2d 100644 --- a/src/pages/org/roles/service.js +++ b/src/pages/org/roles/service.js @@ -64,3 +64,10 @@ export async function SetDataRole(params) { data:params }); } + /** 查询功能菜单*/ + export async function GetMenu(params) { + return request(getDataBaseUrl()+`​/api/menu/menuparmytrees?getType=${params.getType}&&type=${params.type}`, + { + method: 'Get', + }); +} diff --git a/src/pages/sys/dictionary/dictdata/components/CreateForm.jsx b/src/pages/sys/dictionary/dictdata/components/CreateForm.jsx index 73e717b..f8d0bc6 100644 --- a/src/pages/sys/dictionary/dictdata/components/CreateForm.jsx +++ b/src/pages/sys/dictionary/dictdata/components/CreateForm.jsx @@ -34,7 +34,7 @@ const CreateForm = (props) => { - { ); })} - + */} {/* { dataIndex: 'code', ellipsis:true }, - { - title: '字典类型', - dataIndex: 'typeName', - hideInForm: true, - hideInSearch: true, - }, - { - title: '字典类型', - dataIndex: 'typeId', - hideInForm: true, - hideInTable: true, - hideInSearch: true, - valueEnum: typeNames, - }, + // { + // title: '字典类型', + // dataIndex: 'typeName', + // hideInForm: true, + // hideInSearch: true, + // }, + // { + // title: '字典类型', + // dataIndex: 'typeId', + // hideInForm: true, + // hideInTable: true, + // hideInSearch: true, + // valueEnum: typeNames, + // }, { title: '备注', dataIndex: 'remark', @@ -279,7 +279,7 @@ const DictDataManage = (props) => { { - + value.typeId=props.currentRow.id; var success = false; if (value.id) { success = await handleUpdate(value); diff --git a/src/pages/sys/menus/index.jsx b/src/pages/sys/menus/index.jsx index 43c90e2..66a3b21 100644 --- a/src/pages/sys/menus/index.jsx +++ b/src/pages/sys/menus/index.jsx @@ -179,7 +179,6 @@ const handleUpdate = async (fields) => { { title: '创建时间', dataIndex: 'createAt', - sorter: true, hideInSearch: true, }, {