index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="app-container">
  3. <el-tabs type="border-card">
  4. <el-tab-pane label="任务处理">
  5. <el-form ref="form" :model="form" label-width="80px">
  6. <el-row :gutter="20">
  7. <el-col :span="6"><el-form-item label="申请人" >{{form.userId}}</el-form-item></el-col>
  8. <el-col :span="6">
  9. <el-form-item label="请假类型" prop="leaveType">
  10. {{ getDictDataLabel(DICT_TYPE.OA_LEAVE_TYPE, form.leaveType) }}
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="6"><el-form-item label="原因" prop="reason">{{form.reason}}</el-form-item></el-col>
  14. </el-row>
  15. <el-row :gutter="20">
  16. <el-col :span="6"><el-form-item label="开始时间" >{{ parseTime(form.startTime) }}</el-form-item></el-col>
  17. <el-col :span="6"><el-form-item label="结束时间" prop="endTime">{{ parseTime(form.endTime) }}</el-form-item></el-col>
  18. <el-form-item label="申请时间" prop="applyTime">{{ parseTime(form.applyTime) }}</el-form-item>
  19. </el-row>
  20. </el-form>
  21. <el-divider></el-divider>
  22. <el-form ref="taskForm" :model="leaveApprove" :rules="rules" label-width="80px">
  23. <el-form-item label="是否同意" prop="approved">
  24. <el-select v-model="leaveApprove.approved" placeholder="是否同意" v-on:change="approveChange">
  25. <el-option
  26. v-for="dict in approvedData"
  27. :key="parseInt(dict.value)"
  28. :label="dict.label"
  29. :value="parseInt(dict.value)"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="处理意见" prop="comment">
  34. <el-col :span="11">
  35. <el-input
  36. type="textarea"
  37. :rows="3"
  38. v-model="leaveApprove.comment">
  39. </el-input>
  40. </el-col>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="primary" @click="submitForm">确 定</el-button>
  44. </el-form-item>
  45. </el-form>
  46. </el-tab-pane>
  47. <el-tab-pane label="历史跟踪">
  48. <el-steps :active="stepActive" simple finish-status="success">
  49. <el-step :title="stepTitle(item)" icon="el-icon-edit" v-for="(item) in handleTask.historyTask" ></el-step>
  50. </el-steps>
  51. <br/>
  52. <el-steps direction="vertical" :active="stepActive" space="65px">
  53. <el-step :title="stepTitle(item)" :description="stepDes(item)" v-for="(item) in handleTask.historyTask" ></el-step>
  54. </el-steps>
  55. </el-tab-pane>
  56. <el-tab-pane label="流程图">流程图-TODO</el-tab-pane>
  57. </el-tabs>
  58. </div>
  59. </template>
  60. <script>
  61. import { getLeave } from "@/api/oa/leave"
  62. import { completeTask,taskSteps } from "@/api/oa/todo";
  63. import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
  64. export default {
  65. name: "ApproveLeaderLeave",
  66. components: {
  67. },
  68. data() {
  69. return {
  70. // 表单参数
  71. form: {},
  72. // 表单校验
  73. rules: {
  74. comment: [{ required: true, message: "意见不能为空", trigger: "blur" }]
  75. },
  76. handleTask: {
  77. historyTask:[]
  78. },
  79. leaveApprove: {
  80. approved : 1,
  81. variables: {},
  82. taskId: "",
  83. comment: "同意"
  84. },
  85. approvedData: [
  86. {
  87. value: 1,
  88. label: '同意'
  89. },
  90. {
  91. value: 0,
  92. label: '不同意'
  93. }
  94. ],
  95. statusFormat(row, column) {
  96. return getDictDataLabel(DICT_TYPE.OA_LEAVE_STATUS, row.status)
  97. },
  98. leaveTypeDictData: getDictDatas(DICT_TYPE.OA_LEAVE_TYPE),
  99. leaveStatusData: getDictDatas(DICT_TYPE.OA_LEAVE_STATUS)
  100. };
  101. },
  102. created() {
  103. const businessKey = this.$route.query.businessKey;
  104. const taskId = this.$route.query.taskId;
  105. this.leaveApprove.taskId = taskId;
  106. this.getForm(businessKey);
  107. },
  108. computed:{
  109. stepActive: function () {
  110. let idx = 0;
  111. for(let i=0; i<this.handleTask.historyTask.length; i++){
  112. if(this.handleTask.historyTask[i].status === 1){
  113. idx= idx+1;
  114. }else{
  115. break;
  116. }
  117. }
  118. return idx;
  119. },
  120. stepTitle() {
  121. return function (item) {
  122. let name = item.stepName;
  123. if (item.status === 1) {
  124. name += '(已完成)'
  125. }
  126. if (item.status === 0) {
  127. name += '(进行中)'
  128. }
  129. return name;
  130. }
  131. },
  132. stepDes(){
  133. return function (item) {
  134. let desc = "";
  135. if (item.status === 1) {
  136. desc+="审批人:["+ item.assignee +"] 审批意见: [" + item.comment + "] 审批时间: " + this.parseTime(item.endTime);
  137. }
  138. return desc;
  139. }
  140. }
  141. },
  142. methods: {
  143. /** 提交按钮 */
  144. submitForm() {
  145. this.$refs["taskForm"].validate(valid => {
  146. if (!valid) {
  147. return;
  148. }
  149. if (this.leaveApprove.approved == 1) {
  150. this.leaveApprove.variables["deptLeaderApproved"] = true;
  151. }
  152. if (this.leaveApprove.approved == 0) {
  153. this.leaveApprove.variables["deptLeaderApproved"] = false;
  154. }
  155. completeTask(this.leaveApprove).then(response => {
  156. this.msgSuccess("执行任务成功");
  157. this.$store.dispatch('tagsView/delView', this.$route).then(({ visitedViews }) => {
  158. //if (this.isActive(this.$route)) {
  159. this.$router.push({path: '/oa/todo'})
  160. //}
  161. })
  162. });
  163. });
  164. },
  165. getForm(id){
  166. getLeave(id).then(response => {
  167. this.form = response.data;
  168. });
  169. const data = {
  170. taskId : this.leaveApprove.taskId,
  171. businessKey: id,
  172. }
  173. taskSteps(data).then(response => {
  174. this.handleTask = response.data;
  175. });
  176. },
  177. approveChange(){
  178. if (this.leaveApprove.approved === 1) {
  179. this.leaveApprove.comment = "同意"
  180. }
  181. if(this.leaveApprove.approved === 0){
  182. this.leaveApprove.comment = "不同意"
  183. }
  184. }
  185. }
  186. };
  187. </script>