submit.vue 5.2 KB

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