submit.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. @click="handleAudit(1)"
  26. >通过
  27. </el-button>
  28. <el-button
  29. icon="el-icon-circle-close"
  30. type="danger"
  31. size="mini"
  32. @click="handleAudit(0)"
  33. v-if="!['starter', 'starterFillApprove'].includes(taskDefinitionKey)"
  34. >驳回
  35. </el-button>
  36. <el-dropdown @command="(command) => handleCommand(command)" style="margin-left: 30px;">
  37. <span class="el-dropdown-link">更多<i class="el-icon-arrow-down el-icon--right"></i></span>
  38. <el-dropdown-menu slot="dropdown">
  39. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  40. </el-dropdown-menu>
  41. </el-dropdown>
  42. <!-- <el-button
  43. icon="el-icon-circle-close"
  44. type="danger"
  45. size="mini"
  46. @click="handleBackList"
  47. >退回
  48. </el-button> -->
  49. <!-- <el-button
  50. icon="el-icon-circle-close"
  51. type="danger"
  52. size="mini"
  53. @click="handleAudit(0)"
  54. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  55. >不通过
  56. </el-button>
  57. <el-button
  58. icon="el-icon-edit-outline"
  59. type="primary"
  60. size="mini"
  61. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  62. @click="handleUpdateAssignee"
  63. >转办
  64. </el-button> -->
  65. </div>
  66. </el-col>
  67. </template>
  68. <script>
  69. import { UpdateInformation, cancel } from '@/api/bpm/components/contractManage/contractBook';
  70. import {approveTaskWithVariables, rejectTask,cancelTask} from '@/api/bpm/task';
  71. import { listAllUserBind } from '@/api/system/organization';
  72. // 流程实例的详情页,可用于审批
  73. export default {
  74. name: '',
  75. components: {
  76. // Parser
  77. },
  78. props: {
  79. businessId: {
  80. default: ''
  81. },
  82. taskId: {
  83. default: ''
  84. },
  85. id: {
  86. default: ''
  87. },
  88. taskDefinitionKey: {
  89. default: ''
  90. }
  91. },
  92. data() {
  93. return {
  94. form: {
  95. technicianId: '',
  96. reason: ''
  97. },
  98. userOptions: []
  99. };
  100. },
  101. created() {
  102. this.userOptions = [];
  103. listAllUserBind().then((data) => {
  104. this.userOptions.push(...data);
  105. });
  106. },
  107. methods: {
  108. /** 处理转办审批人 */
  109. handleUpdateAssignee() {
  110. this.$emit('handleUpdateAssignee');
  111. },
  112. /** 退回 */
  113. handleBackList() {
  114. this.$emit('handleBackList');
  115. },
  116. async handleAudit(status) {
  117. //发起人补充
  118. if (
  119. this.taskDefinitionKey === 'starter' ||
  120. this.taskDefinitionKey === 'starterFillApprove'
  121. ) {
  122. let arr = await this.getTableValue();
  123. if (!arr) {
  124. return;
  125. }
  126. let data = await UpdateInformation(arr);
  127. if (data.code != '0') {
  128. return;
  129. }
  130. }
  131. this._approveTaskWithVariables(status);
  132. },
  133. async _approveTaskWithVariables(status) {
  134. let variables = {
  135. pass: !!status
  136. };
  137. let API = !!status ? approveTaskWithVariables : rejectTask;
  138. API({
  139. id: this.taskId,
  140. reason: this.form.reason,
  141. variables
  142. }).then((res) => {
  143. if (res.data.code != '-1') {
  144. this.$emit('handleAudit', {
  145. status,
  146. title: status === 0 ? '驳回' : ''
  147. });
  148. }
  149. });
  150. },
  151. getTableValue() {
  152. return new Promise((resolve, reject) => {
  153. this.$emit('getTableValue', async (data) => {
  154. resolve(await data);
  155. });
  156. });
  157. },
  158. //更多
  159. handleCommand(command) {
  160. if (command === 'cancel') {
  161. this.$confirm("是否确认作废?", {
  162. type: 'warning',
  163. cancelButtonText: '取消',
  164. confirmButtonText: '确定'
  165. }).then(() => {
  166. cancelTask({
  167. id: this.id,
  168. taskId: this.taskId,
  169. reason: this.form.reason,
  170. businessId: this.businessId,
  171. }).then(() => {
  172. this.$emit('handleClose');
  173. }).catch(() => {
  174. this.$message.error("流程作废失败");
  175. });
  176. }).catch(() => {});
  177. }
  178. },
  179. }
  180. };
  181. </script>
  182. <style lang="scss"></style>