submit.vue 3.9 KB

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