submit.vue 5.1 KB

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