Prechádzať zdrojové kódy

添加审批通过拒绝

Renxy 2 rokov pred
rodič
commit
57ff513819

+ 2 - 2
config/config.js

@@ -140,8 +140,8 @@ export default {
   chainWebpack: webpackPlugin,
   proxy: {
     '/api': {
-      // target: 'http://192.168.20.152:8888/',
-      target: 'http://47.96.12.136:8888/',
+      target: 'http://192.168.20.152:8888/',
+      // target: 'http://47.96.12.136:8888/',
       // target: 'http://oraysmart.com:8889/',
       // target: 'http://oraysmart.com:8888/api',
       // changeOrigin: true,

+ 1 - 1
src/components/Flow/node/circle/index.tsx

@@ -35,7 +35,7 @@ export default function CustomRect(props) {
           alignItems: 'center',
         }}
       >
-        <span>{label}</span>
+        <span style={{ textAlign: 'center', lineHeight: '20px' }}>{label}</span>
       </div>
     </Badge>
   );

+ 1 - 31
src/components/Flow/node/circle/mapServe.tsx

@@ -23,37 +23,7 @@ export interface IConfig {
 }
 
 const Component = (props: any) => {
-  // const auditList = [
-  //   {
-  //     icon_url: 'https://gw.alicdn.com/tfs/TB13f_aCQzoK1RjSZFlXXai4VXa-102-102.png',
-  //     is_new_process: false,
-  //     process_code: 'PROC-EF6YLU2SO2-TFNDPQR6RMN2002KUULI2-B7P8DLSI-V4',
-  //     gmt_modified: '2021-01-27 21:39:23',
-  //     flow_title: '财务证照及合同借用',
-  //     icon_name: 'tag',
-  //     attendance_type: 0,
-  //   },
-  //   {
-  //     icon_url: 'https://gw.alicdn.com/tfs/TB1KMniCNYaK1RjSZFnXXa80pXa-102-102.png',
-  //     is_new_process: false,
-  //     process_code: 'PROC-MOEKBM6V-GSAR5LHCTQYYP1BCEWCL1-GK9VAQBJ-5',
-  //     gmt_modified: '2021-03-05 10:28:06',
-  //     flow_title: '外部打印申请单',
-  //     icon_name: 'general_log',
-  //     attendance_type: 0,
-  //   },
-  //   {
-  //     icon_url: 'https://gw.alicdn.com/tfs/TB1KMniCNYaK1RjSZFnXXa80pXa-102-102.png',
-  //     is_new_process: false,
-  //     process_code: 'PROC-6B508B53-83F5-484C-8052-2FCA4FB57110',
-  //     gmt_modified: '2021-03-05 10:28:06',
-  //     flow_title: '组织架构调整',
-  //     icon_name: 'general_log',
-  //     attendance_type: 0,
-  //   },
-  // ];
-  const { config, plugin = {}, auditList } = props; //, auditList
-  console.log(auditList);
+  const { config, plugin = {}, auditList } = props;
   const { updateNode } = plugin;
   const [nodeConfig, setNodeConfig] = useState<IConfig>({
     ...config,

+ 30 - 2
src/pages/PurchaseAdmin/PurchaseList/Detail/AuditFlow.js

@@ -1,5 +1,5 @@
 import React, { useMemo, useEffect, useState, useRef } from 'react';
-import { Steps, Popover, Alert } from 'antd';
+import { Steps, Popover, Alert, Button } from 'antd';
 import styles from './Index.less';
 import { queryDDProcessesForecast } from '@/services/boom';
 import { connect } from 'dva';
@@ -18,15 +18,17 @@ function AuditFlow(props) {
     tasks,
     userList,
     cc_userids = [],
+    onApprove,
   } = props;
   const [flow, setFlow] = useState({ workflowActivityRules: [] });
+  // const [showAduit, setShowAduit] = useState(false);
   const timerRef = useRef({
     id: '',
     status: false,
   });
   const current = useMemo(() => {
     if (!tasks || tasks.length == 0) {
-      return flow.workflowActivityRules.length;
+      return false;
     } else {
       // 查询最后一个task的activityId
       let current = 0;
@@ -44,6 +46,19 @@ function AuditFlow(props) {
     }
   }, [tasks, flow]);
 
+  const showAduit = useMemo(() => {
+    //当前处理中的审批人和登录人是一个人显示审批通过和拒绝
+    if (!tasks || tasks.length == 0) {
+      return false;
+    } else {
+      // 查询最后一个task的activityId
+      const activityId = tasks[tasks.length - 1].activity_id;
+      const task = tasks.find(task => task.activity_id == activityId);
+      if (!task) return false;
+      if (task.task_status == 'RUNNING' && task.userid == userId) return true;
+    }
+  }, [tasks, flow]);
+
   const getDesc = item => {
     const { activityId } = item;
     if (!tasks || tasks.length == 0) return;
@@ -135,6 +150,7 @@ function AuditFlow(props) {
           formComponentValues,
         });
         setFlow(flow);
+        console.log(flow);
       } catch (error) {}
       setTimeout(() => {
         // 延时解锁
@@ -163,6 +179,18 @@ function AuditFlow(props) {
           ))}
           {/* <Step key={item.activityId} title={item?.activityName} description={renderDesc(item)} /> */}
         </Steps>
+        <div className={styles.btns} style={{ marginLeft: 80 }}>
+          {showAduit && (
+            <>
+              <Button type="primary" onClick={() => onApprove(true, tasks[current].taskid)}>
+                审批通过
+              </Button>
+              <Button onClick={() => onApprove(false, tasks[current].taskid)} danger>
+                审批拒绝
+              </Button>
+            </>
+          )}
+        </div>
       </div>
       {status !== undefined && renderAlert()}
     </>

+ 1 - 1
src/pages/PurchaseAdmin/PurchaseList/Detail/FlowModal.js

@@ -115,7 +115,7 @@ function FlowModal(props) {
           activityId: '',
           cc_userids: [],
           status: 'undefined',
-          name: curNode?.label || itemDataList[0].FlowInfo.name,
+          name: curNode?.label || '未知节点',
         };
         if (processInstance?.tasks && processInstance.tasks?.length > 0) {
           // let item = flowDetail.nodes.find(item => item.Id == version.template_node_id);

+ 55 - 16
src/pages/PurchaseAdmin/PurchaseList/Detail/Index.js

@@ -20,10 +20,11 @@ import CommitAuditModal from './CommitAuditModal';
 import CommentContent from '@/components/CommentContent';
 import MergeModal from './MergeModal';
 import { GetTokenFromUrl, getToken } from '@/utils/utils';
-import { queryDetail } from '@/services/boom';
+import { queryDetail, queryDingInstanceExecute } from '@/services/boom';
 import HistoryDrawer from './HistoryDrawer';
 import AuditFlow from './AuditFlow';
 import { getCurrentUser } from '@/utils/authority';
+import { async } from '@antv/x6/es/registry/marker/async';
 const LocalData = localStorage.luckysheet;
 
 const { Option } = Select;
@@ -349,7 +350,7 @@ function Detail(props) {
     });
   };
 
-  const onApprove = flag => {
+  const onApprove = (flag, taskId) => {
     if (!flag) {
       setAuditVisible(true);
       return;
@@ -391,9 +392,10 @@ function Detail(props) {
         );
       }
     }
-    Modal.confirm({
+    /*Modal.confirm({
       title: '提示',
-      content: isSingle
+      content: 
+      isSingle
         ? `节点【${serviceNode.label}】只能拥有一个清单,是否覆盖?`
         : `是否通过审批。`,
       okText: '确定',
@@ -439,6 +441,47 @@ function Detail(props) {
           },
         });
       },
+    });*/
+
+    const callback = () => {
+      // 更新flow流程图
+      dispatch({
+        type: 'xflow/queryBoomFlowDetail',
+        payload: {
+          id: templateId,
+        },
+      });
+
+      // 更新审批流
+      dispatch({
+        type: 'detail/queryDingInstanceDetail',
+        payload: {
+          process_instance_id: version.ding_instance_id, //创建表单成功返回的id
+        },
+      });
+    };
+
+    Modal.confirm({
+      title: '提示',
+      content: isSingle
+        ? `节点【${serviceNode.label}】只能拥有一个清单,是否覆盖?`
+        : `是否通过审批。`,
+      okText: '确定',
+      cancelText: '取消',
+      onOk: async () => {
+        let param = {
+          request: {
+            process_instance_id: version.ding_instance_id,
+            result: flag ? 'agree' : 'refuse',
+            actioner_userid: currentUser.DingUserId || getCurrentUser()?.DingUserId,
+            task_id: taskId,
+          },
+        };
+        let res = await queryDingInstanceExecute(param);
+        if (res?.data?.result) {
+          callback();
+        }
+      },
     });
   };
 
@@ -881,6 +924,12 @@ function Detail(props) {
     dispatch({
       type: 'user/fetch',
     });
+    dispatch({
+      type: 'detail/queryListParentByUser',
+      payload: {
+        userid: currentUser.DingUserId || getCurrentUser()?.DingUserId,
+      },
+    });
   }, []);
 
   useEffect(() => {
@@ -955,18 +1004,8 @@ function Detail(props) {
         />
       </div>
       {/* <TimeNode flow={flow} isAuditor={isAuditor} onApprove={onApprove}></TimeNode> */}
-      {version.flow_id ? (
-        <AuditFlow
-          {...auditDetail}
-          // status={auditDetail.status}
-          // processCode={auditDetail.processCode}
-          // deptId={auditDetail.deptId}
-          // userId={auditDetail.userId}
-          // tasks={auditDetail.tasks}
-          // cc_userids={auditDetail.cc_userids}
-          // formComponentValues={auditDetail.formComponentValues}
-        />
-      ) : null}
+      {version.flow_id ? <AuditFlow {...auditDetail} onApprove={onApprove} /> : null}
+
       {/* {renderAlert()} */}
       {/* 判断是否为比对模式 */}
       {compareList.length == 2 ? (

+ 11 - 1
src/pages/PurchaseAdmin/PurchaseList/Detail/models/detail.js

@@ -33,6 +33,7 @@ import {
   queryAuditRecord,
   queryDingSchema,
   queryDingInstanceDetail,
+  queryListParentByUser,
 } from '@/services/boom';
 import { queryRole } from '@/services/SysAdmin';
 import { setCurrentUser } from '@/utils/authority';
@@ -75,7 +76,7 @@ export default {
     authority: [],
     versionTree: [],
     auditExcel: [],
-    dingInstanceDetail: {},
+    dingInstanceD: [],
   },
 
   effects: {
@@ -531,6 +532,15 @@ export default {
         });
       }
     },
+    *queryListParentByUser({ payload, callback }, { call, put }) {
+      const response = yield call(queryListParentByUser, payload);
+      if (response) {
+        yield put({
+          type: 'save',
+          payload: { parentDepList: response.data?.result },
+        });
+      }
+    },
   },
 
   reducers: {

+ 12 - 0
src/services/boom.js

@@ -114,6 +114,18 @@ export async function queryDingInstanceDetail(params) {
     body: params,
   });
 }
+export async function queryDingInstanceExecute(params) {
+  return request(`/api/v1/purchase/bom/ding/instance-execute`, {
+    method: 'POST',
+    body: params,
+  });
+}
+export async function queryListParentByUser(params) {
+  return request(`/api/v1/purchase/bom/ding/department/list-parent-by-user`, {
+    method: 'POST',
+    body: params,
+  });
+}
 /**
  * 查看项目流程列表
  * project_id