submit.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <el-col :span="16" :offset="6">
  3. <el-form label-width="100px" ref="formRef" :model="form">
  4. <el-form-item
  5. label="审批建议"
  6. style="margin-bottom: 20px"
  7. :rules="{
  8. required: true,
  9. message: '请选择',
  10. trigger: 'change'
  11. }"
  12. >
  13. <el-input
  14. type="textarea"
  15. v-model="form.reason"
  16. placeholder="请输入审批建议"
  17. />
  18. </el-form-item>
  19. </el-form>
  20. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  21. <el-button
  22. icon="el-icon-edit-outline"
  23. type="success"
  24. size="mini"
  25. v-click-once
  26. @click="handleAudit(1)"
  27. >通过
  28. </el-button>
  29. <el-button
  30. icon="el-icon-circle-close"
  31. type="danger"
  32. size="mini"
  33. v-click-once
  34. @click="_approveTaskWithVariables(0)"
  35. >驳回
  36. </el-button>
  37. <el-dropdown @command="(command) => handleCommand(command)" style="margin-left: 30px;">
  38. <span class="el-dropdown-link">更多<i class="el-icon-arrow-down el-icon--right"></i></span>
  39. <el-dropdown-menu slot="dropdown">
  40. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  41. </el-dropdown-menu>
  42. </el-dropdown>
  43. </div>
  44. </el-col>
  45. </template>
  46. <script>
  47. import {
  48. approveTaskWithVariables,
  49. rejectTask,
  50. cancelTask
  51. } from '@/api/bpm/task';
  52. // 流程实例的详情页,可用于审批
  53. export default {
  54. name: '',
  55. components: {
  56. // Parser
  57. },
  58. props: {
  59. businessId: {
  60. default: ''
  61. },
  62. taskId: {
  63. default: ''
  64. },
  65. id: {
  66. default: ''
  67. },
  68. taskDefinitionKey: {
  69. default: ''
  70. }
  71. },
  72. data() {
  73. return {
  74. form: {
  75. technicianId: '',
  76. reason: ''
  77. },
  78. tabOptions: [
  79. { key: 'starter', permissionType: 'update', name: '发起人申请' },
  80. {
  81. key: 'deptLeaderApprove',
  82. permissionType: 'view',
  83. name: '部门主管审批'
  84. },
  85. { key: 'financeApprove', permissionType: 'update', name: '财务审批' }
  86. ]
  87. };
  88. },
  89. created() {},
  90. methods: {
  91. /** 处理转办审批人 */
  92. handleUpdateAssignee() {
  93. this.$emit('handleUpdateAssignee');
  94. },
  95. /** 退回 */
  96. handleBackList() {
  97. this.$emit('handleBackList');
  98. },
  99. async handleAudit(status) {
  100. let permissionType = this.tabOptions.find(
  101. (item) => item.key == this.taskDefinitionKey
  102. )?.permissionType;
  103. if (permissionType === 'update') {
  104. const id = await this.getTableValue();
  105. if (typeof id !== 'string') return;
  106. }
  107. await this._approveTaskWithVariables(status);
  108. },
  109. async _approveTaskWithVariables(status) {
  110. let variables = {
  111. pass: !!status
  112. };
  113. let API = !!status ? approveTaskWithVariables : rejectTask;
  114. API({
  115. id: this.taskId,
  116. reason: this.form.reason,
  117. variables
  118. }).then((res) => {
  119. if (res.data.code != '-1') {
  120. this.$emit('handleAudit', {
  121. status,
  122. title: status === 0 ? '驳回' : ''
  123. });
  124. }
  125. });
  126. },
  127. getTableValue() {
  128. return new Promise((resolve, reject) => {
  129. this.$emit('getTableValue', async (data) => {
  130. resolve(await data);
  131. });
  132. });
  133. },
  134. //更多
  135. handleCommand(command) {
  136. if (command === 'cancel') {
  137. this.$confirm('是否确认作废?', {
  138. type: 'warning',
  139. cancelButtonText: '取消',
  140. confirmButtonText: '确定'
  141. })
  142. .then(() => {
  143. cancelTask({
  144. id: this.id,
  145. taskId: this.taskId,
  146. reason: this.form.reason,
  147. businessId: this.businessId
  148. })
  149. .then(() => {
  150. this.$emit('handleClose');
  151. })
  152. .catch(() => {
  153. this.$message.error('流程作废失败');
  154. });
  155. })
  156. .catch(() => {});
  157. }
  158. }
  159. }
  160. };
  161. </script>
  162. <style lang="scss"></style>