Browse Source

钉钉审批对接

fenghaifu 9 months ago
parent
commit
4c365ed49f

+ 7 - 0
src/api/login.js

@@ -63,4 +63,11 @@ export function logout(logoutToken) {
       'X-Access-Token':  logoutToken
     }
   })
+}
+export function oaLogin(parameter) {
+  return axios({
+    url: '/sys/oaLogin',
+    method: 'post',
+    data: parameter
+  })
 }

+ 15 - 12
src/cas/sso.js

@@ -5,23 +5,26 @@ import store from '@/store'
  * 单点登录
  */
 const init = (callback) => {
-  console.log("-------单点登录开始-------");
-  let token = Vue.ls.get(ACCESS_TOKEN);
-  let st = getUrlParam("ticket");
-  var sevice = "http://"+window.location.host+"/";
-  // console.log("-------单点登1录开始-------",st);
-  // console.log("-------单点登2录开始-------",sevice);
-  if(token){
+  if (window.location.href.indexOf("/activiti/check/")>-1){
     loginSuccess(callback);
   }else{
-    if(st){
-      validateSt(st,sevice,callback);
+    let token = Vue.ls.get(ACCESS_TOKEN);
+    let st = getUrlParam("ticket");
+    var sevice = "http://"+window.location.host+"/";
+    // console.log("-------单点登1录开始-------",st);
+    // console.log("-------单点登2录开始-------",sevice);
+    if(token){
+      loginSuccess(callback);
     }else{
-      var serviceUrl = encodeURIComponent(sevice);
-      window.location.href = window._CONFIG['casPrefixUrl']+"/login?service="+serviceUrl;
+      if(st){
+        validateSt(st,sevice,callback);
+      }else{
+        var serviceUrl = encodeURIComponent(sevice);
+        window.location.href = window._CONFIG['casPrefixUrl']+"/login?service="+serviceUrl;
+      }
     }
+    console.log("-------单点登录结束-------");
   }
-  console.log("-------单点登录结束-------");
 };
 const SSO = {
   init: init

+ 4 - 0
src/config/router.config.js

@@ -394,5 +394,9 @@ export const constantRouterMap = [
     path: '/IncidentTicketModalDetail',
     component: () => import(/* webpackChunkName: "fail" */ '../views/oa/modules/IncidentTicketModalDetail.vue')
   },
+   {//////////////外部审批路径
+    path: '/activiti/check/:id',
+    component: () => import(/* webpackChunkName: "fail" */ '../views/activiti/taskCheck.vue')
+  },
 
 ]

+ 9 - 5
src/permission.js

@@ -58,12 +58,16 @@ router.beforeEach((to, from, next) => {
       }
     }
   } else {
-    if (whiteList.indexOf(to.path) !== -1) {
-      // 在免登录白名单,直接进入
+    if (window.location.href.indexOf("/activiti/check/")>-1){
       next()
-    } else {
-      next({ path: '/user/login', query: { redirect: to.fullPath } })
-      NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
+    }else{
+      if (whiteList.indexOf(to.path) !== -1) {
+        // 在免登录白名单,直接进入
+        next()
+      } else {
+        next({ path: '/user/login', query: { redirect: to.fullPath } })
+        NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
+      }
     }
   }
 })

+ 1 - 0
src/router/index.js

@@ -18,6 +18,7 @@ export default new Router({
   // mode: 'history',
   base: process.env.BASE_URL,
   scrollBehavior: () => ({ y: 0 }),
+  mode: 'history',
   routes: constantRouterMap
 })
 

+ 24 - 1
src/store/modules/user.js

@@ -1,5 +1,5 @@
 import Vue from 'vue'
-import { automaticLogin,login, logout, phoneLogin } from "@/api/login"
+import { automaticLogin,login, logout, phoneLogin, oaLogin } from "@/api/login"
 import { ACCESS_TOKEN, USER_NAME,USER_INFO,USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"
 import { welcome } from "@/utils/util"
 import { queryPermissionsByUser } from '@/api/api'
@@ -240,6 +240,29 @@ const user = {
         })
       })
     },
+    // 设置登录信息
+    OaLogin({ commit }, userInfo) {
+      return new Promise((resolve, reject) => {
+        oaLogin(userInfo).then(response => {
+          if(response.code =='200'){
+            const result = response.result
+            const userInfo = result.userInfo
+            Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
+            Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
+            Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
+            commit('SET_TOKEN', result.token)
+            commit('SET_INFO', userInfo)
+            commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname, welcome: welcome() })
+            commit('SET_AVATAR', userInfo.avatar)
+            resolve(response)
+          }else{
+            reject(response)
+          }
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    },
   }
 }
 

+ 296 - 0
src/views/activiti/taskCheck.vue

@@ -0,0 +1,296 @@
+<template>
+  <div>
+    <!--流程表单-->
+    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="100%" :closable="false">
+      <component
+        :disabled="lcModa.disabled"
+        v-if="lcModa.visible"
+        :is="lcModa.formComponent"
+        :processData="lcModa.processData"
+        :isNew="lcModa.isNew"
+        @close=";(lcModa.visible = false), (lcModa.disabled = false)"
+        @getDataList="getDataList"
+      ></component>
+    </a-modal>
+
+    <!-- 审批操作 -->
+    <a-modal :title="modalTaskTitle" v-model="modalTaskVisible" :mask-closable="false" width="100%">
+      <div v-if="modalTaskVisible">
+        <a-form ref="form" :model="form" :label-width="85" :rules="formValidate">
+          <a-form-item label="审批意见" prop="reason">
+            <a-input type="textarea" v-model="form.comment" :rows="4" />
+          </a-form-item>
+          <a-form-item label="下一审批人" prop="assignees" v-show="showAssign" :error="error">
+            <a-select v-model="form.assignees" placeholder="请选择" allowClear mode="multiple" :loading="userLoading">
+              <a-select-option v-for="(item, i) in assigneeList" :key="i" :value="item.username">{{
+                item.realname
+              }}</a-select-option>
+            </a-select>
+          </a-form-item>
+          <a-form-item label="下一审批人" v-show="isGateway">
+            <span>分支网关处暂不支持自定义选择下一审批人,将发送给下一节点所有人</span>
+          </a-form-item>
+          <div v-show="form.type == 1">
+            <a-form-item label="驳回至">
+              <a-select v-model="form.backTaskKey" :loading="backLoading" @change="changeBackTask">
+                <a-select-option v-for="(item, i) in backList" :key="i" :value="item.key">{{item.name}}
+              </a-select-option>
+              </a-select>
+            </a-form-item>
+            <a-form-item label="指定原节点审批人" prop="assignees" v-show="form.backTaskKey != -1" :error="error">
+              <a-select v-model="form.assignees" placeholder="请选择" allowClear mode="multiple" :loading="userLoading">
+                <a-select-option v-for="(item, i) in assigneeList" :key="i" :value="item.username">{{item.realname}}
+                </a-select-option>
+              </a-select>
+            </a-form-item>
+          </div>
+          <a-form-item label="选择委托人" prop="userId" :error="error" v-show="form.type == 2">
+            <JSelectUserByDep v-model="form.userId" :multi="false"></JSelectUserByDep>
+          </a-form-item>
+          <a-form-item label="消息通知">
+            <a-checkbox v-model="form.sendMessage">站内消息通知</a-checkbox>
+            <!-- <a-checkbox v-model="form.sendSms" disabled>短信通知</a-checkbox>
+            <a-checkbox v-model="form.sendEmail" disabled>邮件通知</a-checkbox> -->
+          </a-form-item>
+        </a-form>
+      </div>
+      <div slot="footer">
+        <a-button type="text" @click="modalTaskVisible = false">取消</a-button>
+        <a-button type="primary" :loading="submitLoading" @click="handelSubmit">提交</a-button>
+      </div>
+    </a-modal>
+    <outerForm-check ref="outerFormCheck" @refreshData="handleSearch" ></outerForm-check>
+  </div>
+</template>
+
+<script>
+  import { getAction,postAction } from '@/api/manage'
+  import { mapActions } from 'vuex'
+  import store from '@/store/'
+  import outerFormCheck from '../../share/modal/OuterFormCheck'
+  import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
+
+  export default {
+    name: "taskCheck",
+    components: { JSelectUserByDep, outerFormCheck },
+    data() {
+      return {
+        key : "",
+        taskInfo:{},
+
+        modalTaskVisible: false,
+        backList: [
+          {
+            key: '-1',
+            name: '发起人'
+          }
+        ],
+        error: '',
+        showAssign: false,
+        searchForm: {
+          // 搜索框对应data对象
+          name: ''
+        },
+        modalTaskTitle: '',
+        modalTitle: '', // 添加或编辑标题
+        form: {
+          id: '',
+          userId: '',
+          procInstId: '',
+          comment: '',
+          type: 0,
+          assignees: [],
+          backTaskKey: '-1',
+          sendMessage: true,
+          sendSms: false,
+          sendEmail: false
+        },
+        formValidate: {
+          // 表单验证规则
+        },
+        submitLoading: false, // 添加或编辑提交状态
+        data: [], // 表单数据
+        total: 0, // 表单数据总数
+        dictPriority: [],
+        isGateway: false,
+        lcModa: {
+          title: '',
+          disabled: false,
+          visible: false,
+          formComponent: null,
+          isNew: false
+        },
+
+        url:{
+          taskInfoUrl:"/actTask/getSelfTaskById",
+          outformViewUrl:"/actBusiness/external/getViewUrl",
+        }
+      }
+    },
+    created () {
+      this.key = this.$route.params.id;   
+      this.$message.info(this.key)
+      this.login(this.key);   
+    },
+    methods: {
+      ...mapActions(['OaLogin']),
+      login(key){
+        this.OaLogin({key,key})
+          .then(res => {
+
+            this.getTaskInfo(key);
+          })
+      },
+      // 根据taskid获取待办任务的某一条
+      getTaskInfo(key){
+        getAction(this.url.taskInfoUrl,{key:key}).then(res => {
+          if (res.success) {
+            if (res.result.length == 0){
+              this.$message.info("待办任务不存在");
+              return;
+            }
+            this.taskInfo = res.result[0];
+            this.showTask(this.taskInfo);
+          }else{
+            this.$message.error(res.message);
+          }
+        })
+
+      },
+      // 显示任务信息
+      showTask(r){
+        if (!r.routeName) {
+          this.$message.warning('该流程信息未配置表单,请联系开发人员!')
+          return
+        }
+        r.operationType = '1' //代办
+        if (r.routeName.indexOf('外部表单') != -1||r.tableName.indexOf('外部表单') != -1) {
+          //其他项目的表单流程
+          var id = r.tableId //项目管理合同数据id
+          this.showOuterFormViewDlg(r.tableId, '业务流程审批:' + r.processName, r);
+        } else if (r.routeName.indexOf('自定义') != -1) {
+          //自定义的表单流程
+          this.lcModa.disabled = true
+          this.lcModa.title = '查看流程业务信息:' + r.processName
+          let com = { component: () => import(`@/views/activiti/form/demoForm2`) }
+          this.lcModa.formComponent = com.component
+          this.lcModa.isNew = false
+          this.lcModa.processData = r
+          this.lcModa.visible = true
+        } else {
+          //固定的表单流程
+          this.lcModa.disabled = true
+          this.lcModa.title = '查看流程业务信息:' + r.processName
+          this.lcModa.formComponent = this.getFormComponent(r.routeName).component
+          this.lcModa.processData = r
+          this.lcModa.isNew = false
+          this.lcModa.visible = true
+        }
+      },
+      // 显示外部表单
+      showOuterFormViewDlg(tableId, title, processData){
+        getAction(this.url.outformViewUrl,{tableId:tableId}).then(res=>{
+            if (res.success){
+              var url = res.result.url;
+              var param = res.result.param;
+              url = url+"?"+this.jsonToUrlParam(param);
+
+              this.$refs.outerFormCheck.openDialog(url, title, processData);
+            }else{
+                this.$message.error(res.message);
+            }        
+        });
+      },
+      // 封装跳转地址
+      jsonToUrlParam(query){
+        var tmpArr = [];
+        for (var i in query){
+          var key = encodeURIComponent(i);
+          var value = encodeURIComponent(query[i]);
+          tmpArr.push(key+"="+value);
+        }
+        return tmpArr.join("&");
+      },
+      // 提交表单
+      handelSubmit() {
+        console.log('提交')
+        this.submitLoading = true
+        var formData = Object.assign({}, this.form)
+        formData.assignees = formData.assignees.join(',')
+        if (formData.type == 0) {
+          // 通过
+          if (this.showAssign && formData.assignees.length < 1) {
+            this.$message.error('请至少选择一个审批人')
+            this.submitLoading = false
+            return
+          } else {
+            this.error = ''
+          }
+          this.postFormAction(this.url.pass, formData).then(res => {
+            this.submitLoading = false
+            if (res.success) {
+              this.$message.success('操作成功')
+              this.modalTaskVisible = false
+              this.getDataList()
+            }
+          })
+        } else if (formData.type == 1) {
+          // 驳回
+          if (formData.backTaskKey == '-1') {
+            // 驳回至发起人
+            this.postFormAction(this.url.back, formData).then(res => {
+              this.submitLoading = false
+              if (res.success) {
+                this.$message.success('操作成功')
+                this.modalTaskVisible = false
+                this.getDataList()
+              }
+            })
+          } else {
+            // 自定义驳回
+            if (formData.backTaskKey != '-1' && formData.assignees.length < 1) {
+              this.$message.error('请至少选择一个审批人')
+              this.submitLoading = false
+              return
+            } else {
+              this.error = ''
+            }
+            this.postFormAction(this.url.backToTask, formData).then(res => {
+              this.submitLoading = false
+              if (res.success) {
+                this.$message.success('操作成功')
+                this.modalTaskVisible = false
+                this.getDataList()
+              }
+            })
+          }
+        } else if (formData.type == 2) {
+          // 委托
+          if (!formData.userId) {
+            this.$message.error('请选择一委托人')
+            this.submitLoading = false
+            return
+          } else {
+            this.error = ''
+          }
+          this.postFormAction(this.url.delegate, formData).then(res => {
+            this.submitLoading = false
+            if (res.success) {
+              this.$message.success('操作成功')
+              this.modalTaskVisible = false
+              this.getDataList()
+            }
+          })
+        }
+      },
+      handleSearch(){
+
+      }
+
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>