index.vue 6.6 KB

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