Browse Source

feat: 审批流程模板,新增“删除”“编辑名称”功能,编辑流程更名为“配置流程”

lanjianrong 3 years ago
parent
commit
8791fe5cd1

+ 1 - 1
src/pages/Institutions/Company/Detail/components/OrganizationModal.tsx

@@ -195,7 +195,7 @@ const OrganizationModal: React.FC<OrganizationModalProps> = ({
         {type === ModalTypeEnum.DEL ? (
           <>
             <ProFormText name="ID" hidden />
-            <p>确删除?</p>
+            <p>确删除?</p>
             {accountTotal ? (
               <div>
                 <p>请设置包含人员至新的组织架构中:</p>

+ 1 - 1
src/pages/Institutions/Staff/components/StaffDetail.tsx

@@ -219,7 +219,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
                 ]}
               />
               <ProFormText.Password
-                label="确新密码"
+                label="确新密码"
                 name="confirmPassword"
                 rules={[
                   { required: true, message: '请输入新密码' },

+ 2 - 2
src/pages/Institutions/Staff/index.tsx

@@ -161,8 +161,8 @@ const CompanyList: React.FC<ListProps> = () => {
             编辑
           </div>
           {/* <Popconfirm
-            title="确删除吗?"
-            okText="确"
+            title="确删除吗?"
+            okText="确"
             cancelText="取消"
             onConfirm={() => tryDelProject({ id: record.id })}
           >

+ 3 - 3
src/pages/Permission/Role/components/RoleLeftMenu/index.tsx

@@ -113,15 +113,15 @@ const RoleLeftMenu = ({ onSelect }) => {
                             onChange={e => onChangeName(e.currentTarget.value)}
                           />
                         }
-                        okText="确"
+                        okText="确"
                         cancelText="取消"
                         onConfirm={() => tryUpdateRole(item.ID, state.name)}
                         icon="">
                         <FormOutlined className="pr-1" />
                       </Popconfirm>
                       <Popconfirm
-                        title="确删除该角色"
-                        okText="确"
+                        title="确删除该角色"
+                        okText="确"
                         cancelText="取消"
                         onConfirm={() => tryDelRole(item.ID)}
                         icon={<QuestionCircleOutlined style={{ color: 'red' }} />}>

+ 2 - 2
src/pages/Permission/Role/index.tsx

@@ -79,8 +79,8 @@ const Role = () => {
       width: '10%',
       render: (_, record) => (
         <Popconfirm
-          title="确移除吗?"
-          okText="确"
+          title="确移除吗?"
+          okText="确"
           cancelText="取消"
           onConfirm={() => tryUnLinkRoleAccount({ ID: state.ID, accountID: record.ID })}>
           <span className="text-hex-fd3995 cursor-pointer hover:text-hex-e7026e">

+ 2 - 2
src/pages/Project/Management/List/index.tsx

@@ -159,8 +159,8 @@ const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
             编辑
           </div>
           <Popconfirm
-            title="确删除吗?"
-            okText="确"
+            title="确删除吗?"
+            okText="确"
             cancelText="取消"
             onConfirm={() => tryDelProject({ ID: record.ID })}>
             <div className="pl-2 text-hex-fd3995 cursor-pointer hover:text-hex-e7026e">

+ 2 - 2
src/pages/Project/Verification/Detail/Flow/components/Toolbar/index.tsx

@@ -26,8 +26,8 @@ export default function ToolBar(props: {
       return message.warning('请添加审批人')
     }
     Modal.confirm({
-      title: '确发布该审批流程',
-      okText: '确',
+      title: '确发布该审批流程',
+      okText: '确',
       cancelText: '取消',
       onOk: async () => {
         const { code = -1 } = await addApprovalFlow({

+ 50 - 42
src/pages/Project/Verification/index.tsx

@@ -2,19 +2,23 @@ import AnimateContent from '@/components/AnimateContent'
 import consts from '@/utils/consts'
 import { PageContainer } from '@ant-design/pro-layout'
 import ProTable from '@ant-design/pro-table'
-import { Button, message } from 'antd'
+import { Button, message, Popconfirm } from 'antd'
 import { useRef, useState } from 'react'
 import { useRequest } from 'umi'
-import { addApproval, getApprovalList, publishApproval, saveApproval } from '@/services/api/project'
-import type { ActionType } from '@ant-design/pro-table'
+import { addApproval, delApproval, getApprovalList, saveApproval } from '@/services/api/project'
+import type { ActionType, ProColumnType } from '@ant-design/pro-table'
 
 import ApprovalDetail from './Detail'
 import { ModalForm, ProFormText } from '@ant-design/pro-form'
 import type { ProFormInstance } from '@ant-design/pro-form'
 
-export enum PublishType {
-  FAIL = '0',
-  SUCCESS = '1'
+// export enum PublishType {
+//   FAIL = '0',
+//   SUCCESS = '1'
+// }
+export enum ApprovalModalType {
+  ADD,
+  UPDATE
 }
 
 const FlowList = () => {
@@ -32,12 +36,12 @@ const FlowList = () => {
     }
   })
 
-  // const { run: tryDel } = useRequest(delApproval, {
-  //   manual: true,
-  //   onSuccess: () => {
-  //     tRef.current?.reload()
-  //   }
-  // })
+  const { run: tryDel } = useRequest(delApproval, {
+    manual: true,
+    onSuccess: () => {
+      tRef.current?.reload()
+    }
+  })
   const { run: tryAdd } = useRequest(addApproval, {
     manual: true,
     onSuccess: () => {
@@ -58,18 +62,13 @@ const FlowList = () => {
       tRef.current?.reload()
     }
   })
-  const columns = [
-    // {
-    //   dataIndex: 'name',
-    //   title: '项目名称',
-    //   onHeaderCell: () => ({ style: { textAlign: 'center' } })
-    // },
+  const columns: ProColumnType = [
     {
       dataIndex: 'name',
       title: '模板名称',
       onHeaderCell: () => ({ style: { textAlign: 'center' } }),
-      renderText: (_, record) => (
-        <span
+      render: (_, record) => (
+        <div
           className="text-primary hover:cursor-pointer hover:text-blue-600"
           onClick={() => {
             setState({
@@ -78,8 +77,13 @@ const FlowList = () => {
               current: { dataID: record.ID, name: record.name, readPretty: true }
             })
           }}>
-          {record.name}
-        </span>
+          {record.stickyTop ? (
+            <span className="w-30px text-center rounded-lg text-primary border border-hex-0089ff bg-hex-e9f5ff">
+              默
+            </span>
+          ) : null}
+          <span className="ml-2">{record.name}</span>
+        </div>
       )
     },
     // {
@@ -103,29 +107,30 @@ const FlowList = () => {
       onHeaderCell: () => ({ style: { textAlign: 'center' } }),
       align: 'center',
       render: (_, record) => (
-        <div className="divide-x divide-bg-gray-400 ">
+        <div className="divide-x divide-bg-gray-400">
           <span
             className="pr-2 text-primary cursor-pointer hover:text-hex-967bbd"
             onClick={() => {
               setState({
                 ...state,
-                visible: true,
+                modalType: ApprovalModalType.UPDATE,
+                modalVisible: true,
                 current: { dataID: record.ID, name: record.name }
               })
             }}>
-            编辑流程
+            编辑名称
           </span>
-          {/* <span
-            className="px-2 text-primary hover:cursor-pointer hover:text-blue-600"
-            onClick={() =>
+          <span
+            className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
+            onClick={() => {
               setState({
                 ...state,
                 visible: true,
-                current: { ...record.approval, readPretty: true }
+                current: { dataID: record.ID, name: record.name }
               })
-            }>
-            查看流程图
-          </span> */}
+            }}>
+            编辑流程
+          </span>
           {/* <span
             className={[
               'pl-2',
@@ -134,13 +139,14 @@ const FlowList = () => {
             onClick={() => !record.publish && tryPublish({ ID: record.approval.ID })}>
             发布
           </span> */}
-          {/* <Popconfirm
-            title={`确认删除${record.name}吗?`}
-            okText="确认"
+
+          <Popconfirm
+            title="是否删除此流程模板?"
+            okText="确定"
             cancelText="取消"
             onConfirm={() => tryDel({ ID: record.ID })}>
             <span className="text-red-500 pl-2 cursor-pointer hover:text-red-600">删除</span>
-          </Popconfirm> */}
+          </Popconfirm>
         </div>
       )
     }
@@ -172,7 +178,9 @@ const FlowList = () => {
           actions: [
             <Button
               type="primary"
-              onClick={() => setState({ ...state, modalType: 'add', modalVisible: true })}
+              onClick={() =>
+                setState({ ...state, modalType: ApprovalModalType.ADD, modalVisible: true })
+              }
               key="add_flow_btn">
               新建流程
             </Button>
@@ -191,20 +199,21 @@ const FlowList = () => {
       <ModalForm
         visible={state.modalVisible}
         isKeyPressSubmit
+        layout="horizontal"
         modalProps={{
           width: '30%'
         }}
         onVisibleChange={visible => setState({ ...state, modalVisible: visible })}
-        title={`${state.modalType === 'add' ? '新建' : '编辑'}审批流程`}
+        title={`${state.modalType === ApprovalModalType.ADD ? '新建' : '编辑'}审批流程`}
         formRef={formRef}
         onFinish={async values => {
           try {
-            if (state.modalType === 'add') {
+            if (state.modalType === ApprovalModalType.ADD) {
               await tryAdd(values)
             } else {
-              await tryUpdate(values)
+              await tryUpdate({ ...values, ID: state.current.dataID })
             }
-            message.success(`${state.modalType === 'add' ? '新增' : '编辑'}成功`)
+            message.success(`${state.modalType === ApprovalModalType.ADD ? '新增' : '编辑'}成功`)
             tRef.current?.reload()
             return true
           } catch (error) {
@@ -212,7 +221,6 @@ const FlowList = () => {
             return false
           }
         }}>
-        <ProFormText name="ID" hidden />
         <ProFormText name="name" label="名称" rules={[{ required: true }]} />
       </ModalForm>
     </PageContainer>

+ 6 - 11
src/pages/System/AdminUpdate/index.tsx

@@ -22,23 +22,20 @@ const AdminUpdate = () => {
           wrapperCol={{ span: 3 }}
           layout="horizontal"
           form={form}
-          initialValues={{ username: 'admin' }}
-        >
+          initialValues={{ username: 'admin' }}>
           <Form.Item label="帐号" name="username">
             <Input disabled />
           </Form.Item>
           <Form.Item
             label="旧密码"
             name="password"
-            rules={[{ required: true, message: '请输入密码' }]}
-          >
+            rules={[{ required: true, message: '请输入密码' }]}>
             <Input.Password placeholder="请输入" />
           </Form.Item>
           <Form.Item
             label="新密码"
             name="newPassword"
-            rules={[{ required: true, message: '请输入密码' }]}
-          >
+            rules={[{ required: true, message: '请输入密码' }]}>
             <Input.Password placeholder="请输入" />
           </Form.Item>
           <Form.Item
@@ -54,8 +51,7 @@ const AdminUpdate = () => {
                   return Promise.reject(new Error('两次输入的密码不一致!'))
                 }
               })
-            ]}
-          >
+            ]}>
             <Input.Password placeholder="请输入" />
           </Form.Item>
           <Form.Item wrapperCol={{ offset: 2, span: 8 }}>
@@ -66,9 +62,8 @@ const AdminUpdate = () => {
                   await tryUpdate(values)
                   form.resetFields()
                 })
-              }}
-            >
-              确认修改
+              }}>
+              确定修改
             </Button>
           </Form.Item>
         </Form>

+ 1 - 1
src/pages/System/Setting/index.tsx

@@ -71,7 +71,7 @@ const Setting = () => {
           </Form.Item>
           <Form.Item wrapperCol={{ offset: 2, span: 8 }}>
             <Button type="primary" htmlType="submit">
-              确
+              确
             </Button>
           </Form.Item>
         </Form>