浏览代码

工作流组件及controller

yuedefeng 6 年之前
父节点
当前提交
0c246a4ae4

+ 57 - 0
src/dashoo.cn/backend/api/controllers/workflow/workflow.go

@@ -0,0 +1,57 @@
+package workflow
+
+import (
+	"dashoo.cn/backend/api/business/workflow"
+	. "dashoo.cn/backend/api/controllers"
+	"dashoo.cn/business2/permission"
+	"dashoo.cn/business2/userRole"
+	"dashoo.cn/utils"
+)
+
+// 动作接口说明
+type WorkflowController struct {
+	BaseController
+}
+
+
+// @Title get
+// @Description get workflow by token
+// @Success 200 {object} historicTasks
+// @router /historytask [get]
+func (this *WorkflowController) GetHistoricTask() {
+	businessKey := this.GetString("business")
+	processKey := this.GetString("process")
+	processInstanceId := this.GetString("instance")
+
+	var historicTasks []workflow.ActiHistoricTask
+	svcActiviti := workflow.GetActivitiService(utils.DBE)
+	historicTasks = svcActiviti.GetHistoricTasks(processKey, businessKey, processInstanceId)
+
+	var datainfo DataInfo
+	datainfo.Items = historicTasks
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 获取所有用户
+// @Description get user by token
+// @Success 200 {object} models.User
+// @router /userlist [get]
+func (this *WorkflowController) UserList() {
+	keyword := this.GetString("keyword")
+	svc := permission.GetPermissionService(utils.DBE)
+	var users []userRole.Base_User
+
+	where := "IsVisible=1 and AccCode='" + this.User.AccCode + "' "
+	if keyword != "" {
+		where = where + " and Realname like '%" + keyword + "%'"
+	}
+	total := svc.GetPagingEntitiesWithOrder(1, 1000, "Id", false, &users, where)
+
+	var datainfo DataInfo
+	datainfo.Items = users
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+

+ 168 - 0
src/dashoo.cn/frontend_web/src/components/workflow/wfhistory.vue

@@ -0,0 +1,168 @@
+<template>
+  <div>
+    <el-table :data="historyTask" border>
+      <el-table-column prop="taskName" sortable min-width="130" label="当前状态" align="center" show-overflow-tooltip></el-table-column>
+      <el-table-column prop="remarks" sortable min-width="130" label="审批意见" align="center" show-overflow-tooltip></el-table-column>
+      <el-table-column prop="assignee" sortable min-width="100" label="审核人" align="center" show-overflow-tooltip>
+        <template slot-scope="scope">
+          <span style="font-weight: bold" v-if="scope.row.assignee">
+            {{ assigneeToAssignee(scope.row.assignee) }}
+          </span>
+          <el-tooltip class="item" v-if="!scope.row.assignee" content="当前步骤有审批权限的人员" placement="top-start">
+            <span style="font-style: italic; color:#00F">
+              {{ assigneeToUsers(scope.row.users) }}
+            </span>
+          </el-tooltip>
+        </template>
+      </el-table-column>
+      <el-table-column prop="startTime" sortable min-width="150" label="开始时间" align="center" show-overflow-tooltip>
+        <template slot-scope="scope">
+          {{ timestampToTime(scope.row.startTime) }}
+        </template>
+      </el-table-column>
+      <el-table-column prop="endTime" sortable min-width="150" label="结束时间" align="center" show-overflow-tooltip>
+        <template slot-scope="scope">
+          {{ jstimehandle(timestampToTime(scope.row.endTime)) }}
+        </template>
+      </el-table-column>
+    </el-table>
+    <div style="margin-top:10px;">
+      <img :src="baseurl + 'limsdataentry/historyimg/' + entryinfo.instance " v-if="entryinfo.instance">
+    </div>
+  </div>
+</template>
+
+<script>
+  import {
+    mapGetters
+  } from 'vuex'
+
+  export default {
+    name: 'wfhistory',
+    props: {
+      visible: {
+        type: Boolean,
+        default: false
+      },
+      entryinfo: {}
+    },
+    created() {
+      this.getuserlist()
+    },
+    computed: {
+      ...mapGetters({
+        session: 'session'
+      })
+    },
+
+    data() {
+      return {
+        baseurl: process.env.baseURL,
+        process: '',
+        business: '',
+        instance: '',
+        selfVisible: this.visible, // 避免vue双向绑定警告
+        historyTask: [],
+        userlist: [],
+      }
+    },
+    methods: {
+      getHistoryTask() {
+        let _this = this
+        const params = {
+          process: _this.entryinfo.process,
+          business: _this.entryinfo.business,
+          instance: _this.entryinfo.instance,
+        }
+        this.$axios.get('workflow/historytask', {
+          params
+        })
+          .then(res => {
+              debugger
+            _this.historyTask = res.data.items
+          })
+          .catch(err => {
+            // handle error
+            console.error(err)
+          })
+      },
+      assigneeToAssignee(val) {
+        for (let i = 0; i < this.userlist.length; i++) {
+          if (val == this.userlist[i].Id) {
+            return this.userlist[i].Realname
+          }
+        }
+      },
+      assigneeToUsers(users) {
+        let userNames = ""
+        let userArr = users.split(',')
+        for(let idx=0; idx<userArr.length; idx++) {
+          let val = userArr[idx]
+          for (let i = 0; i < this.userlist.length; i++) {
+            if (parseInt(val) == parseInt(this.userlist[i].Id)) {
+              userNames += this.userlist[i].Realname + ", "
+            }
+          }
+        }
+        if(userNames.length > 0) {
+          userNames = userNames.substring(0, userNames.length-2)
+        }
+        return userNames;
+      },
+      getuserlist() {
+        let _this = this
+        _this.$axios.get('workflow/userlist', {})
+          .then(res => {
+            // response
+            _this.userlist = res.data.items
+
+            this.getHistoryTask()
+          })
+          .catch(err => {
+            // handle error
+            console.error(err)
+          })
+      },
+      timestampToTime(val) {
+        var date = new Date(val) //时间戳为10位需*1000,时间戳为13位的话不需乘1000
+        var Y = date.getFullYear() + '-'
+        var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
+        var D = date.getDate() + ' '
+        var h = date.getHours() + ':'
+        var m = date.getMinutes() + ':'
+        var s = date.getSeconds()
+        return Y + M + D + h + m + s
+      },
+      jstimehandle(val) {
+        if (val === '') {
+          return '----'
+        } else if (val === '0001-01-01T08:00:00+08:00') {
+          return '----'
+        } else if (val === '5000-01-01T23:59:59+08:00') {
+          return '永久'
+        } else if (val === '1970-01-01 8:0:0') {
+          return '----'
+        } else if (val === '1970-01-1 8:0:0') {
+          return '----'
+        } else {
+          val = val.replace('T', ' ')
+          return val.substring(0, 19)
+        }
+      },
+    }
+  }
+
+</script>
+
+<style>
+  .samplerecoveope .el-radio {
+    padding: 8px 15px 0 0;
+    margin-left: -2px;
+  }
+  .dialog-footer img{
+    position: relative;
+    width: 100%;
+    height: 100%;
+  }
+
+</style>