Browse Source

系统管理模块-还差审批设置

shaogen1995 1 month ago
parent
commit
c397ba213f

+ 1 - 1
后台管理/src/components/MyTable/index.tsx

@@ -126,7 +126,7 @@ function MyTable({
 
 
           if (v[4]) {
           if (v[4]) {
             tempCom = tableComObj(v[4], [tempCom, item[v[2]]])
             tempCom = tableComObj(v[4], [tempCom, item[v[2]]])
-          } else if (item[v[2]].length >= v[3]) {
+          } else if (item[v[2]] && item[v[2]].length >= v[3]) {
             tempCom = (
             tempCom = (
               <span style={{ cursor: 'pointer' }} title={item[v[2]]}>
               <span style={{ cursor: 'pointer' }} title={item[v[2]]}>
                 {tempCom}
                 {tempCom}

+ 12 - 0
后台管理/src/pages/D2approval/data.ts

@@ -0,0 +1,12 @@
+export type D2listType = {
+  createTime: string
+  creatorId: number
+  creatorName?: any
+  enabled: number
+  id: number
+  name: string
+  process: any[]
+  remark: string
+  typeKey: string
+  updateTime: string
+}

+ 2 - 2
后台管理/src/pages/D2approval/index.module.scss

@@ -1,4 +1,4 @@
 .D2approval {
 .D2approval {
-  :global {
-  }
+  background-color: #fff;
+  border-radius: 10px;
 }
 }

+ 42 - 1
后台管理/src/pages/D2approval/index.tsx

@@ -1,9 +1,50 @@
-import React from 'react'
+import React, { useCallback, useEffect, useMemo } from 'react'
 import styles from './index.module.scss'
 import styles from './index.module.scss'
+import { useDispatch, useSelector } from 'react-redux'
+import { D2_APIgetlist } from '@/store/action/D2approval'
+import { RootState } from '@/store'
+import MyTable from '@/components/MyTable'
+import { D2tableC } from '@/utils/tableData'
+import { D2listType } from './data'
+import { Button } from 'antd'
 function D2approval() {
 function D2approval() {
+  const dispatch = useDispatch()
+
+  const getListFu = useCallback(() => {
+    dispatch(D2_APIgetlist())
+  }, [dispatch])
+
+  useEffect(() => {
+    getListFu()
+  }, [getListFu])
+
+  const tableList = useSelector((state: RootState) => state.D2approval.list)
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '操作',
+        render: (item: D2listType) => (
+          <Button size='small' type='text'>
+            编辑
+          </Button>
+        )
+      }
+    ]
+  }, [])
+
   return (
   return (
     <div className={styles.D2approval}>
     <div className={styles.D2approval}>
       <div className='pageTitle'>审批设置</div>
       <div className='pageTitle'>审批设置</div>
+
+      <MyTable
+        yHeight={750}
+        list={tableList}
+        columnsTemp={D2tableC}
+        lastBtn={tableLastBtn}
+        pagingInfo={false}
+        widthSet={{ remark: 800 }}
+      />
     </div>
     </div>
   )
   )
 }
 }

+ 121 - 0
后台管理/src/pages/D3role/D3add/index.module.scss

@@ -0,0 +1,121 @@
+.D3add {
+  :global {
+    .ant-modal-close {
+      display: none;
+    }
+
+    .ant-modal {
+      top: 30px !important;
+      width: 980px !important;
+    }
+
+    .ant-modal-body {
+      border-top: 1px solid #ccc;
+
+      .ant-form-item-label {
+        max-width: 100px;
+      }
+    }
+
+    .D3aMain {
+      width: 900px;
+      position: relative;
+      padding-top: 15px;
+      .fromRow2 {
+        position: relative;
+
+        .fromRowTit {
+          position: absolute;
+          left: 200px;
+          top: 5px;
+          color: #999;
+          font-size: 12px;
+        }
+      }
+      .fromRow {
+        display: flex;
+        align-items: center;
+        margin-bottom: 24px;
+        .fromRowll {
+          width: 94px;
+          text-align: right;
+          position: relative;
+        }
+        .fromRowrr {
+          width: calc(100% - 94px);
+        }
+      }
+
+      .Z5Rtit {
+        pointer-events: none;
+        width: 142px;
+        text-align: center;
+        .ant-radio {
+          display: none;
+        }
+      }
+
+      // 功能权限和数据权限
+      .D3abox {
+        display: flex;
+        .D3aboxll {
+          width: 100px;
+          text-align: right;
+          & > span {
+            color: #ff4d4f;
+          }
+        }
+        .D3aboxrr {
+          width: calc(100% - 100px);
+          .D3aRow {
+            margin-bottom: 10px;
+            display: flex;
+
+            .D3aRow1 {
+              width: 70px;
+              font-weight: 700;
+              text-align: right;
+              margin-right: 10px;
+            }
+
+            .D3aRow2 {
+              width: calc(100% - 80px);
+            }
+          }
+
+          .D3aErr {
+            margin-bottom: 20px;
+            text-align: center;
+            color: #ff4d4f;
+            opacity: 0;
+            pointer-events: none;
+            transition: all 0.3s;
+            position: relative;
+            top: -10px;
+          }
+
+          .D3aErrAc {
+            opacity: 1;
+            top: 0;
+          }
+          .D3aboxrr_1 {
+            margin-top: 5px;
+          }
+        }
+        .D3aboxrr2 {
+          margin-bottom: 15px;
+        }
+      }
+      .D3abox0 {
+        margin-top: -24px;
+      }
+      .D3abox1 {
+        .D3aboxll {
+          width: 150px;
+          text-align: left;
+        }
+        padding-left: 110px;
+      }
+    }
+  }
+}

+ 181 - 0
后台管理/src/pages/D3role/D3add/index.tsx

@@ -0,0 +1,181 @@
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import styles from './index.module.scss'
+import { Button, Checkbox, Form, FormInstance, Input, InputNumber, Modal } from 'antd'
+import { D3_APIgetAddTreeList, D3_APIgetInfo, D3_APIsave } from '@/store/action/D3role'
+import { MessageFu } from '@/utils/message'
+import { TypeD3Role } from '../data'
+import classNmaes from 'classnames'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import TextArea from 'antd/es/input/TextArea'
+
+type Props = {
+  sId: number
+  closeFu: () => void
+  addTableFu: () => void
+  editTableFu: () => void
+}
+
+function D3add({ sId, closeFu, addTableFu, editTableFu }: Props) {
+  // 设置表单ref
+  const FormBoxRef = useRef<FormInstance>(null)
+
+  // 编辑进来获取详情
+  const getInfoFu = useCallback(async (id: number) => {
+    const res = await D3_APIgetInfo(id)
+    if (res.code === 0) {
+      FormBoxRef.current?.setFieldsValue(res.data.role)
+      setRoleArr(res.data.permission)
+    }
+  }, [])
+
+  // 新增的默认数据
+  const [roleArr, setRoleArr] = useState<TypeD3Role[]>([])
+
+  const getAddInfoFu = useCallback(async () => {
+    const res = await D3_APIgetAddTreeList()
+    if (res.code === 0) {
+      setRoleArr(res.data || [])
+    }
+  }, [])
+
+  useEffect(() => {
+    if (sId > 0) getInfoFu(sId)
+    else {
+      FormBoxRef.current?.setFieldsValue({ sort: 999 })
+      getAddInfoFu()
+    }
+  }, [getAddInfoFu, getInfoFu, sId])
+
+  // 多选框变化
+  const onChange = useCallback(
+    (val: boolean, id: number) => {
+      setRoleArr(
+        roleArr.map(v => ({
+          ...v,
+          authority: v.id === id ? val : v.authority
+        }))
+      )
+    },
+    [roleArr]
+  )
+
+  // 二级选中的数组id集合
+  const checkIds = useMemo(() => {
+    const arr: number[] = []
+    roleArr.forEach(v => {
+      if (v.authority) arr.push(v.id)
+    })
+    return arr
+  }, [roleArr])
+
+  // 没有通过校验
+  const onFinishFailed = useCallback(async () => {
+    // return MessageFu.warning("有表单不符号规则!");
+  }, [])
+
+  // 通过校验点击确定
+  const onFinish = useCallback(
+    async (values: any) => {
+      const obj = {
+        ...values,
+        id: sId > 0 ? sId : null,
+        resources: checkIds
+      }
+
+      const res = await D3_APIsave(obj)
+
+      if (res.code === 0) {
+        MessageFu.success(sId > 0 ? '编辑成功' : '新增成功')
+        sId > 0 ? editTableFu() : addTableFu()
+        closeFu()
+      }
+    },
+    [addTableFu, checkIds, closeFu, editTableFu, sId]
+  )
+
+  return (
+    <Modal
+      wrapClassName={styles.D3add}
+      open={true}
+      title={sId > 0 ? '编辑' : '新增'}
+      footer={
+        [] // 设置footer为空,去掉 取消 确定默认按钮
+      }
+    >
+      <div className='D3aMain'>
+        <Form
+          scrollToFirstError={true}
+          ref={FormBoxRef}
+          name='basic'
+          labelCol={{ span: 3 }}
+          onFinish={onFinish}
+          onFinishFailed={onFinishFailed}
+          autoComplete='off'
+        >
+          <Form.Item
+            label='角色名称'
+            name='roleName'
+            rules={[{ required: true, message: '请输入角色名称' }]}
+          >
+            <Input maxLength={10} showCount placeholder='请输入内容' />
+          </Form.Item>
+
+          <Form.Item label='角色说明' name='roleDesc'>
+            <TextArea maxLength={100} showCount placeholder='请输入内容' />
+          </Form.Item>
+
+          <div className='fromRow2'>
+            <Form.Item
+              label='排序值'
+              name='sort'
+              rules={[{ required: true, message: '请输入排序值!' }]}
+            >
+              <InputNumber min={1} max={999} precision={0} placeholder='请输入' />
+            </Form.Item>
+            <div className='fromRowTit'>
+              请输入1~999的数字。数字越小,排序越靠前。数字相同时,更新发布的内容排在前面
+            </div>
+          </div>
+
+          <div className='D3abox'>
+            <div className='D3aboxll'>
+              <span> * </span> 功能权限:
+            </div>
+            <div className='D3aboxrr'>
+              {roleArr.map(v => (
+                <div key={v.id} className='D3aRow'>
+                  <Checkbox
+                    key={v.id}
+                    checked={v.authority}
+                    onChange={e => {
+                      onChange(e.target.checked, v.id)
+                    }}
+                  >
+                    {v.name}
+                  </Checkbox>
+                </div>
+              ))}
+
+              <div className={classNmaes('D3aErr', checkIds.length <= 0 ? 'D3aErrAc' : '')}>
+                至少选中一个
+              </div>
+            </div>
+          </div>
+          {/* 确定和取消按钮 */}
+          <br />
+          <Form.Item wrapperCol={{ offset: 11, span: 16 }}>
+            <Button type='primary' htmlType='submit' disabled={checkIds.length <= 0}>
+              提交
+            </Button>
+            &emsp;
+            <MyPopconfirm txtK='取消' onConfirm={closeFu} />
+          </Form.Item>
+        </Form>
+      </div>
+    </Modal>
+  )
+}
+
+const MemoD3add = React.memo(D3add)
+
+export default MemoD3add

+ 23 - 0
后台管理/src/pages/D3role/data.ts

@@ -0,0 +1,23 @@
+export type D3listType = {
+  count?: any
+  createTime: string
+  creatorId?: any
+  creatorName?: any
+  dataScope?: any
+  id: number
+  isEnabled: number
+  roleDesc: string
+  roleKey: string
+  roleName: string
+  sort: number
+  updateTime: string
+}
+
+// 功能权限列表
+export type TypeD3Role = {
+  authority: boolean
+  children: TypeD3Role[]
+  id: number
+  name: string
+  resourceType: string
+}

+ 13 - 0
后台管理/src/pages/D3role/index.module.scss

@@ -1,4 +1,17 @@
 .D3role {
 .D3role {
+  background-color: #fff;
+  border-radius: 10px;
+  padding: 20px;
   :global {
   :global {
+    .D3top {
+      text-align: right;
+    }
+    .tableBox {
+      border-radius: 10px;
+      overflow: hidden;
+      margin-top: 15px;
+      height: calc(100% - 24px);
+      background-color: #fff;
+    }
   }
   }
 }
 }

+ 106 - 1
后台管理/src/pages/D3role/index.tsx

@@ -1,9 +1,114 @@
-import React from 'react'
+import React, { useCallback, useEffect, useMemo, useState } from 'react'
 import styles from './index.module.scss'
 import styles from './index.module.scss'
+import { useDispatch, useSelector } from 'react-redux'
+import { D3_APIdel, D3_APIgetList } from '@/store/action/D3role'
+import { RootState } from '@/store'
+import { MessageFu } from '@/utils/message'
+import { D3listType } from './data'
+import { Button } from 'antd'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import MyTable from '@/components/MyTable'
+import { D3tableC } from '@/utils/tableData'
+import D3add from './D3add'
 function D3role() {
 function D3role() {
+  const dispatch = useDispatch()
+
+  // 顶部筛选
+  const [fromData, setFromData] = useState({
+    pageNum: 1,
+    pageSize: 10,
+    searchKey: ''
+  })
+
+  // 封装发送请求的函数
+  const getList = useCallback(() => {
+    dispatch(D3_APIgetList(fromData))
+  }, [dispatch, fromData])
+
+  useEffect(() => {
+    getList()
+  }, [getList])
+
+  // 从仓库中获取表格数据
+  const tableInfo = useSelector((state: RootState) => state.D3role.tableInfo)
+
+  // 点击删除
+  const delTableFu = useCallback(
+    async (id: number) => {
+      const res: any = await D3_APIdel(id)
+      if (res.code === 0) {
+        MessageFu.success('删除成功!')
+        getList()
+      }
+    },
+    [getList]
+  )
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '操作',
+        width: 200,
+        render: (item: D3listType) => {
+          return item.id === 1 ? (
+            '-'
+          ) : (
+            <>
+              <Button size='small' type='text' onClick={() => setEditId(item.id)}>
+                编辑
+              </Button>
+              <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
+            </>
+          )
+        }
+      }
+    ]
+  }, [delTableFu])
+
+  // 点击重置
+  const resetSelectFu = useCallback(() => {
+    setFromData({
+      pageNum: 1,
+      pageSize: 10,
+      searchKey: ''
+    })
+  }, [])
+
+  // 点击新增和编辑
+  const [editId, setEditId] = useState(0)
+
   return (
   return (
     <div className={styles.D3role}>
     <div className={styles.D3role}>
       <div className='pageTitle'>角色管理</div>
       <div className='pageTitle'>角色管理</div>
+      <div className='D3top'>
+        <Button type='primary' onClick={() => setEditId(-1)}>
+          新增
+        </Button>
+      </div>
+      {/* 表格主体 */}
+      <div className='tableBox'>
+        <MyTable
+          yHeight={630}
+          list={tableInfo.list}
+          columnsTemp={D3tableC}
+          lastBtn={tableLastBtn}
+          pageNum={fromData.pageNum}
+          pageSize={fromData.pageSize}
+          total={tableInfo.total}
+          onChange={(pageNum, pageSize) => setFromData({ ...fromData, pageNum, pageSize })}
+          widthSet={{ roleDesc: 800 }}
+        />
+      </div>
+
+      {/* 新增和编辑 */}
+      {editId ? (
+        <D3add
+          sId={editId}
+          closeFu={() => setEditId(0)}
+          addTableFu={resetSelectFu}
+          editTableFu={getList}
+        />
+      ) : null}
     </div>
     </div>
   )
   )
 }
 }

+ 10 - 10
后台管理/src/pages/Layout/data.ts

@@ -7,13 +7,13 @@ const tabLeftArr: RouterType = [
     name: '工作台',
     name: '工作台',
     son: [
     son: [
       {
       {
-        id: 200,
+        id: 100,
         name: '工作台',
         name: '工作台',
         path: '/',
         path: '/',
         Com: React.lazy(() => import('../A1workbench'))
         Com: React.lazy(() => import('../A1workbench'))
       },
       },
       {
       {
-        id: 300,
+        id: 200,
         name: '数据统计',
         name: '数据统计',
         path: '/statistics',
         path: '/statistics',
         Com: React.lazy(() => import('../A2statistics'))
         Com: React.lazy(() => import('../A2statistics'))
@@ -26,25 +26,25 @@ const tabLeftArr: RouterType = [
     name: '藏品管理',
     name: '藏品管理',
     son: [
     son: [
       {
       {
-        id: 200,
+        id: 300,
         name: '藏品总账',
         name: '藏品总账',
         path: '/ledger',
         path: '/ledger',
         Com: React.lazy(() => import('../B1ledger'))
         Com: React.lazy(() => import('../B1ledger'))
       },
       },
       {
       {
-        id: 300,
+        id: 400,
         name: '藏品登记',
         name: '藏品登记',
         path: '/register',
         path: '/register',
         Com: React.lazy(() => import('../B2register'))
         Com: React.lazy(() => import('../B2register'))
       },
       },
       {
       {
-        id: 100,
+        id: 500,
         name: '藏品修改',
         name: '藏品修改',
         path: '/edit',
         path: '/edit',
         Com: React.lazy(() => import('../B3edit'))
         Com: React.lazy(() => import('../B3edit'))
       },
       },
       {
       {
-        id: 400,
+        id: 600,
         name: '藏品删除',
         name: '藏品删除',
         path: '/delete',
         path: '/delete',
         Com: React.lazy(() => import('../B4delete'))
         Com: React.lazy(() => import('../B4delete'))
@@ -57,25 +57,25 @@ const tabLeftArr: RouterType = [
     name: '库存管理',
     name: '库存管理',
     son: [
     son: [
       {
       {
-        id: 100,
+        id: 700,
         name: '库房管理',
         name: '库房管理',
         path: '/storage',
         path: '/storage',
         Com: React.lazy(() => import('../C1storage'))
         Com: React.lazy(() => import('../C1storage'))
       },
       },
       {
       {
-        id: 200,
+        id: 800,
         name: '藏品入库',
         name: '藏品入库',
         path: '/storageIn',
         path: '/storageIn',
         Com: React.lazy(() => import('../C2storageIn'))
         Com: React.lazy(() => import('../C2storageIn'))
       },
       },
       {
       {
-        id: 300,
+        id: 900,
         name: '藏品移库',
         name: '藏品移库',
         path: '/storageMove',
         path: '/storageMove',
         Com: React.lazy(() => import('../C3storageMove'))
         Com: React.lazy(() => import('../C3storageMove'))
       },
       },
       {
       {
-        id: 400,
+        id: 1000,
         name: '藏品出库',
         name: '藏品出库',
         path: '/storageOut',
         path: '/storageOut',
         Com: React.lazy(() => import('../C4storageOut'))
         Com: React.lazy(() => import('../C4storageOut'))

+ 53 - 36
后台管理/src/pages/Layout/index.tsx

@@ -16,9 +16,22 @@ import classNames from 'classnames'
 import { RouterType, RouterTypeRow } from '@/types'
 import { RouterType, RouterTypeRow } from '@/types'
 import tabLeftArr from './data'
 import tabLeftArr from './data'
 import MyPopconfirm from '@/components/MyPopconfirm'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { UserListType } from '../Z1user/Z1auth'
+import { useDispatch } from 'react-redux'
+import { D1_APIgetlist } from '@/store/action/D1dict'
+import { D3_APIgetInfo } from '@/store/action/D3role'
 
 
 function Layout() {
 function Layout() {
+  // 获取字典值
+  const dispatch = useDispatch()
+
+  const getListFu = useCallback(() => {
+    dispatch(D1_APIgetlist())
+  }, [dispatch])
+
+  useEffect(() => {
+    getListFu()
+  }, [getListFu])
+
   // 当前路径选中的左侧菜单
   // 当前路径选中的左侧菜单
   const location = useLocation()
   const location = useLocation()
   const [path, setPath] = useState('')
   const [path, setPath] = useState('')
@@ -35,49 +48,53 @@ function Layout() {
   const getUserAuthFu = useCallback(async () => {
   const getUserAuthFu = useCallback(async () => {
     const userInfo = getTokenInfo().user
     const userInfo = getTokenInfo().user
 
 
-    // 待完善
-    const isOkIdArr: number[] = [100, 200, 300, 400, 500]
-
-    const tempList: UserListType[] = []
-    // console.log(123, tempList);
-    tempList.forEach(v => {
-      if (v.perm) isOkIdArr.push(v.id)
-    })
-    // 是管理员
-    if (userInfo.isAdmin === 1) {
-      ;[2100, 2200, 2300, 2400, 2500].forEach(v => {
-        isOkIdArr.push(v)
-      })
-    }
+    const res = await D3_APIgetInfo(userInfo.roleId)
+
+    if (res.code === 0) {
+      const isOkIdArr: number[] = []
 
 
-    const tempArr: RouterTypeRow = []
+      const roleArr: any[] = res.data.permission
 
 
-    tabLeftArr.forEach(v1 => {
-      if (v1.son && v1.son[0]) {
-        v1.son.forEach(v2 => {
-          if (isOkIdArr.includes(v2.id)) {
-            tempArr.push(v2)
-          }
+      roleArr.forEach(v => {
+        if (v.authority) isOkIdArr.push(v.id)
+      })
+
+      // 是管理员
+      if (userInfo.isAdmin === 1) {
+        ;[2100, 2200, 2300, 2400, 2500].forEach(v => {
+          isOkIdArr.push(v)
         })
         })
       }
       }
-    })
 
 
-    setRouterCom(tempArr)
+      const tempArr: RouterTypeRow = []
 
 
-    // 如果当前页面没有权限了,跳转有权限的第一个页面
-    const urlAll = window.location.hash
-    const isNowPath = urlAll.replace('#', '')
-    const pathArr = tempArr.map(v => v.path)
-    if (!pathArr.includes(isNowPath)) {
-      history.push(pathArr[0])
-    }
+      tabLeftArr.forEach(v1 => {
+        if (v1.son && v1.son[0]) {
+          v1.son.forEach(v2 => {
+            if (isOkIdArr.includes(v2.id)) {
+              tempArr.push(v2)
+            }
+          })
+        }
+      })
 
 
-    const resList = tabLeftArr.map(v => ({
-      ...v,
-      son: v.son.filter(c => isOkIdArr.includes(c.id))
-    }))
+      setRouterCom(tempArr)
 
 
-    setList(resList)
+      // 如果当前页面没有权限了,跳转有权限的第一个页面
+      const urlAll = window.location.hash
+      const isNowPath = urlAll.replace('#', '')
+      const pathArr = tempArr.map(v => v.path)
+      if (!pathArr.includes(isNowPath)) {
+        history.push(pathArr[0])
+      }
+
+      const resList = tabLeftArr.map(v => ({
+        ...v,
+        son: v.son.filter(c => isOkIdArr.includes(c.id))
+      }))
+
+      setList(resList)
+    }
   }, [])
   }, [])
 
 
   useEffect(() => {
   useEffect(() => {

+ 32 - 5
后台管理/src/pages/Z1user/UserAdd/index.tsx

@@ -1,10 +1,13 @@
 import { getUserInfoByIdAPI, userSaveAPI } from '@/store/action/Z1user'
 import { getUserInfoByIdAPI, userSaveAPI } from '@/store/action/Z1user'
 import { SaveUserType } from '@/types'
 import { SaveUserType } from '@/types'
 import { MessageFu } from '@/utils/message'
 import { MessageFu } from '@/utils/message'
-import { Button, Form, FormInstance, Input, Modal } from 'antd'
+import { Button, Form, FormInstance, Input, Modal, Select } from 'antd'
 import React, { useCallback, useEffect, useRef } from 'react'
 import React, { useCallback, useEffect, useRef } from 'react'
 import styles from './index.module.scss'
 import styles from './index.module.scss'
 import MyPopconfirm from '@/components/MyPopconfirm'
 import MyPopconfirm from '@/components/MyPopconfirm'
+import { useDispatch, useSelector } from 'react-redux'
+import { D3_APIgetList } from '@/store/action/D3role'
+import { RootState } from '@/store'
 
 
 type Props = {
 type Props = {
   id: any
   id: any
@@ -14,6 +17,20 @@ type Props = {
 }
 }
 
 
 function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
 function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
+  // 角色
+  const dispatch = useDispatch()
+  useEffect(() => {
+    dispatch(
+      D3_APIgetList({
+        pageNum: 1,
+        pageSize: 99999,
+        searchKey: ''
+      })
+    )
+  }, [dispatch])
+
+  const { list: roleList } = useSelector((state: RootState) => state.D3role.tableInfo)
+
   // 设置表单初始数据(区分编辑和新增)
   // 设置表单初始数据(区分编辑和新增)
   const FormBoxRef = useRef<FormInstance>(null)
   const FormBoxRef = useRef<FormInstance>(null)
 
 
@@ -40,10 +57,7 @@ function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
     async (values: any) => {
     async (values: any) => {
       const obj: SaveUserType = {
       const obj: SaveUserType = {
         ...values,
         ...values,
-        id: id ? id : null,
-        // 角色id写死 2=》普通用户
-        roleId: 2,
-        deptId: 0
+        id: id ? id : null
       }
       }
 
 
       const res: any = await userSaveAPI(obj)
       const res: any = await userSaveAPI(obj)
@@ -101,6 +115,19 @@ function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
             <Input maxLength={8} showCount placeholder='请输入内容' />
             <Input maxLength={8} showCount placeholder='请输入内容' />
           </Form.Item>
           </Form.Item>
 
 
+          <Form.Item
+            label='角色'
+            name='roleId'
+            rules={[{ required: true, message: '请选择角色!' }]}
+          >
+            <Select
+              style={{ width: 240 }}
+              placeholder='请选择'
+              options={roleList.filter(v => v.id !== 1)}
+              fieldNames={{ value: 'id', label: 'roleName' }}
+            />
+          </Form.Item>
+
           {id ? null : <div className='passTit'>* 默认密码 Aa147852</div>}
           {id ? null : <div className='passTit'>* 默认密码 Aa147852</div>}
 
 
           {/* 确定和取消按钮 */}
           {/* 确定和取消按钮 */}

+ 0 - 189
后台管理/src/pages/Z1user/Z1auth.tsx

@@ -1,189 +0,0 @@
-import React, { useCallback, useEffect, useMemo, useState } from 'react'
-import styles from './index.module.scss'
-import { Button, Checkbox, Modal, Radio } from 'antd'
-import MyPopconfirm from '@/components/MyPopconfirm'
-import { Z1_APIgetAuthByUserId, Z1_APIsetAuth } from '@/store/action/Z1user'
-import classNmaes from 'classnames'
-import { MessageFu } from '@/utils/message'
-
-export type UserListType = {
-  id: number
-  name: string
-  perm: boolean
-}
-
-type Props = {
-  authInfo: { id: number; name: string }
-  closeFu: () => void
-}
-
-function Z1auth({ authInfo, closeFu }: Props) {
-  const getAuthByUserIdFu = useCallback(async () => {
-    const res = await Z1_APIgetAuthByUserId(authInfo.id)
-    if (res.code === 0) {
-      const info = res.data
-      setResources(info.resources)
-      setDataScopeIds(info.scope)
-      setDataScope(info.dataScope || 1)
-    }
-  }, [authInfo.id])
-
-  useEffect(() => {
-    getAuthByUserIdFu()
-  }, [getAuthByUserIdFu])
-
-  // 页面权限
-  const [resources, setResources] = useState<UserListType[]>([])
-
-  // 选择古桥或者全部
-  const [dataScope, setDataScope] = useState(0)
-
-  // 古桥权限
-  const [dataScopeIds, setDataScopeIds] = useState<UserListType[]>([])
-
-  // 多选框变化
-  const onChange1 = useCallback(
-    (val: boolean, id: number) => {
-      setResources(
-        resources.map(v => ({
-          ...v,
-          perm: v.id === id ? val : v.perm
-        }))
-      )
-    },
-    [resources]
-  )
-  const onChange2 = useCallback(
-    (val: boolean, id: number) => {
-      setDataScopeIds(
-        dataScopeIds.map(v => ({
-          ...v,
-          perm: v.id === id ? val : v.perm
-        }))
-      )
-    },
-    [dataScopeIds]
-  )
-
-  //  页面权限id集合
-  const ids1 = useMemo(() => {
-    return resources.filter(v => v.perm).map(c => c.id)
-  }, [resources])
-
-  // 古桥权限id集合
-  const ids2 = useMemo(() => {
-    return dataScopeIds.filter(v => v.perm).map(c => c.id)
-  }, [dataScopeIds])
-
-  // 点击确定
-  const btnOkFu = useCallback(async () => {
-    const obj = {
-      userId: authInfo.id,
-      resources: ids1,
-      dataScopeIds: ids2,
-      dataScope
-    }
-
-    const res = await Z1_APIsetAuth(obj)
-
-    if (res.code === 0) {
-      MessageFu.success('授权成功!')
-      closeFu()
-    }
-  }, [authInfo.id, closeFu, dataScope, ids1, ids2])
-
-  // 按钮是否能点击
-  const btnFlag = useMemo(() => {
-    let txt = ''
-    if (ids1.length === 0) txt = '至少选中一个页面权限'
-    else if (dataScope === 2 && ids2.length === 0) txt = '至少选中一个数据权限'
-    return txt
-  }, [dataScope, ids1.length, ids2.length])
-
-  return (
-    <Modal
-      wrapClassName={styles.Z1auth}
-      open={true}
-      title={`${authInfo.name} - 权限管理`}
-      footer={
-        [] // 设置footer为空,去掉 取消 确定默认按钮
-      }
-    >
-      <div className='Z1aEmain'>
-        <div className='Z1aRow'>
-          <div className='Z1aRowll'>页面权限:</div>
-          <div className='Z1aRowrr'>
-            {resources.map(c => (
-              <Checkbox
-                key={c.id}
-                checked={c.perm}
-                onChange={e => onChange1(e.target.checked, c.id)}
-              >
-                {c.name}
-              </Checkbox>
-            ))}
-          </div>
-        </div>
-
-        <div className='Z1aRow'>
-          <div className='Z1aRowll'>数据权限:</div>
-          <div className='Z1aRowrr'>
-            <Radio.Group
-              value={dataScope}
-              onChange={e => setDataScope(e.target.value)}
-              options={[
-                { value: 1, label: '全部' },
-                { value: 2, label: '按古桥' }
-              ]}
-            />
-          </div>
-        </div>
-
-        <div className='Z1aRow' hidden={dataScope !== 2}>
-          <div className='Z1aRowll'>
-            <Checkbox
-              indeterminate={ids2.length > 0 && ids2.length < dataScopeIds.length}
-              onChange={e => {
-                const perm = e.target.checked
-                setDataScopeIds(
-                  dataScopeIds.map(v => ({
-                    ...v,
-                    perm
-                  }))
-                )
-              }}
-              checked={ids2.length === dataScopeIds.length}
-            >
-              {ids2.length === dataScopeIds.length ? '反' : '全'}选
-            </Checkbox>
-          </div>
-          <div className='Z1aRowrr Z1aRowrr2'>
-            {dataScopeIds.map(c => (
-              <Checkbox
-                key={c.id}
-                checked={c.perm}
-                onChange={e => onChange2(e.target.checked, c.id)}
-              >
-                {c.name}
-              </Checkbox>
-            ))}
-          </div>
-        </div>
-
-        <div className={classNmaes('Z1aErr', btnFlag ? 'Z1aErrAc' : '')}>{btnFlag}</div>
-      </div>
-
-      <div className='Z1aEbtn'>
-        <Button type='primary' onClick={btnOkFu} disabled={!!btnFlag}>
-          提交
-        </Button>
-        &emsp;
-        <MyPopconfirm txtK='取消' onConfirm={closeFu} />
-      </div>
-    </Modal>
-  )
-}
-
-const MemoZ1auth = React.memo(Z1auth)
-
-export default MemoZ1auth

+ 1 - 16
后台管理/src/pages/Z1user/index.tsx

@@ -10,7 +10,6 @@ import UserAdd from './UserAdd'
 import MyTable from '@/components/MyTable'
 import MyTable from '@/components/MyTable'
 import { Z1tableC } from '@/utils/tableData'
 import { Z1tableC } from '@/utils/tableData'
 import MyPopconfirm from '@/components/MyPopconfirm'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import Z1auth from './Z1auth'
 
 
 function Z1user() {
 function Z1user() {
   const dispatch = useDispatch()
   const dispatch = useDispatch()
@@ -113,13 +112,7 @@ function Z1user() {
                   </Button>
                   </Button>
                 }
                 }
               />
               />
-              <Button
-                size='small'
-                type='text'
-                onClick={() => setAuthInfo({ id: item.id, name: item.userName })}
-              >
-                权限管理
-              </Button>
+
               <Button size='small' type='text' onClick={() => openEditPageFu(item.id)}>
               <Button size='small' type='text' onClick={() => openEditPageFu(item.id)}>
                 编辑
                 编辑
               </Button>
               </Button>
@@ -131,9 +124,6 @@ function Z1user() {
     ]
     ]
   }, [delTableFu, openEditPageFu, resetPassFu])
   }, [delTableFu, openEditPageFu, resetPassFu])
 
 
-  // 授权管理
-  const [authInfo, setAuthInfo] = useState({ id: 0, name: '' })
-
   return (
   return (
     <div className={styles.Z1user}>
     <div className={styles.Z1user}>
       <div className='pageTitle'>用户管理</div>
       <div className='pageTitle'>用户管理</div>
@@ -190,11 +180,6 @@ function Z1user() {
           addTableList={resetSelectFu}
           addTableList={resetSelectFu}
         />
         />
       ) : null}
       ) : null}
-
-      {/* 点击授权 */}
-      {authInfo.id ? (
-        <Z1auth authInfo={authInfo} closeFu={() => setAuthInfo({ id: 0, name: '' })} />
-      ) : null}
     </div>
     </div>
   )
   )
 }
 }

+ 2 - 2
后台管理/src/store/action/D1dict.ts

@@ -16,14 +16,14 @@ export const D1_APIgetlist = (parentId?: string): any => {
 }
 }
 
 
 /**
 /**
- * 删除字典
+ * 字典管理-删除字典
  */
  */
 export const D1_APIdel = (id: string) => {
 export const D1_APIdel = (id: string) => {
   return http.get(`cms/dict/remove/${id}`)
   return http.get(`cms/dict/remove/${id}`)
 }
 }
 
 
 /**
 /**
- * 新增/修改
+ * 字典管理-新增/修改
  */
  */
 export const D1_APIsave = (data: any) => {
 export const D1_APIsave = (data: any) => {
   return http.post('cms/dict/save', data)
   return http.post('cms/dict/save', data)

+ 20 - 0
后台管理/src/store/action/D2approval.ts

@@ -0,0 +1,20 @@
+import http from '@/utils/http'
+import { AppDispatch } from '..'
+/**
+ * 流程设置-获取列表
+ */
+export const D2_APIgetlist = (): any => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.get('cms/flow/getList')
+    if (res.code === 0) {
+      dispatch({ type: 'D2/getList', payload: res.data })
+    }
+  }
+}
+
+/**
+ * 流程设置-
+ */
+// export const D1_APIdel = (id: string) => {
+//   return http.get(`cms/dict/remove/${id}`)
+// }

+ 46 - 0
后台管理/src/store/action/D3role.ts

@@ -0,0 +1,46 @@
+import http from '@/utils/http'
+import { AppDispatch } from '..'
+/**
+ * 角色管理 -获取分页列表
+ */
+export const D3_APIgetList = (data: any): any => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post('sys/role/list', data)
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total
+      }
+
+      dispatch({ type: 'D3/getList', payload: obj })
+    }
+  }
+}
+
+/**
+ * 角色管理 -删除
+ */
+export const D3_APIdel = (id: number) => {
+  return http.get(`sys/role/remove/${id}`)
+}
+
+/**
+ * 角色管理 -新增--获取权限列表
+ */
+export const D3_APIgetAddTreeList = () => {
+  return http.get('sys/user/perm/getTree')
+}
+
+/**
+ * 角色管理 -新增/编辑
+ */
+export const D3_APIsave = (data: any) => {
+  return http.post('sys/role/save', data)
+}
+
+/**
+ * 角色管理 -获取详情
+ */
+export const D3_APIgetInfo = (id: number) => {
+  return http.get(`sys/role/detail/${id}`)
+}

+ 25 - 0
后台管理/src/store/reducer/D2approval.ts

@@ -0,0 +1,25 @@
+import { D2listType } from '@/pages/D2approval/data'
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  list: [] as D2listType[]
+}
+
+// 定义 action 类型
+type Props = {
+  type: 'D2/getList'
+  payload: D2listType[]
+}
+
+// reducer
+export default function userReducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case 'D2/getList':
+      return { ...state, list: action.payload }
+
+    default:
+      return state
+  }
+}

+ 28 - 0
后台管理/src/store/reducer/D3role.ts

@@ -0,0 +1,28 @@
+import { D3listType } from '@/pages/D3role/data'
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  tableInfo: {
+    list: [] as D3listType[],
+    total: 0
+  }
+}
+
+// 定义 action 类型
+type Props = {
+  type: 'D3/getList'
+  payload: { list: D3listType[]; total: number }
+}
+
+// reducer
+export default function userReducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case 'D3/getList':
+      return { ...state, tableInfo: action.payload }
+
+    default:
+      return state
+  }
+}

+ 4 - 0
后台管理/src/store/reducer/index.ts

@@ -4,6 +4,8 @@ import { combineReducers } from 'redux'
 // 导入 登录 模块的 reducer
 // 导入 登录 模块的 reducer
 import A0Layout from './layout'
 import A0Layout from './layout'
 import D1dict from './D1dict'
 import D1dict from './D1dict'
+import D2approval from './D2approval'
+import D3role from './D3role'
 
 
 import Z1user from './Z1user'
 import Z1user from './Z1user'
 import Z2log from './Z2log'
 import Z2log from './Z2log'
@@ -12,6 +14,8 @@ import Z2log from './Z2log'
 const rootReducer = combineReducers({
 const rootReducer = combineReducers({
   A0Layout,
   A0Layout,
   D1dict,
   D1dict,
+  D2approval,
+  D3role,
   Z1user,
   Z1user,
   Z2log
   Z2log
 })
 })

+ 13 - 1
后台管理/src/utils/tableData.ts

@@ -14,9 +14,21 @@
 //     ["text", "创建日期",'description', 50,A],
 //     ["text", "创建日期",'description', 50,A],
 //   ];
 //   ];
 
 
+export const D2tableC = [
+  ['txt', '流程名称', 'name'],
+  ['text', '流程说明', 'remark', '100'],
+  ['txtChange', '状态', 'enabled', { 0: '禁用', 1: '启用' }]
+]
+
+export const D3tableC = [
+  ['txt', '角色名称', 'roleName'],
+  ['text', '角色说明', 'roleDesc', '100'],
+  ['txt', '排序值', 'sort']
+]
+
 export const Z1tableC = [
 export const Z1tableC = [
   ['txt', '用户名', 'userName'],
   ['txt', '用户名', 'userName'],
-  ['txtChange', '角色', 'isAdmin', { 1: '管理员', 0: '普通成员' }],
+  ['txt', '角色', 'roleName'],
   ['txt', '真实姓名', 'realName'],
   ['txt', '真实姓名', 'realName'],
   ['txt', '创建日期', 'createTime']
   ['txt', '创建日期', 'createTime']
 ]
 ]