submit.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <el-col :span="16" :offset="6" v-loading="loading">
  3. <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
  4. <el-form-item label="审批建议" prop="reason" style="margin-bottom: 20px">
  5. <el-input
  6. v-model="form.reason"
  7. type="textarea"
  8. :rows="3"
  9. maxlength="500"
  10. show-word-limit
  11. placeholder="请输入审批建议"
  12. />
  13. </el-form-item>
  14. </el-form>
  15. <div class="actions">
  16. <el-button
  17. v-click-once
  18. type="success"
  19. size="mini"
  20. icon="el-icon-check"
  21. :loading="loading"
  22. @click="handleAudit(1)"
  23. >
  24. 通过
  25. </el-button>
  26. <el-button
  27. v-click-once
  28. type="danger"
  29. size="mini"
  30. icon="el-icon-close"
  31. :loading="loading"
  32. @click="handleAudit(0)"
  33. >
  34. 驳回
  35. </el-button>
  36. </div>
  37. </el-col>
  38. </template>
  39. <script>
  40. import { approveTaskWithVariables, rejectTask } from '@/api/bpm/task';
  41. export default {
  42. name: 'StockBatchChangeSubmit',
  43. props: {
  44. businessId: {
  45. default: ''
  46. },
  47. taskId: {
  48. default: ''
  49. },
  50. id: {
  51. default: ''
  52. },
  53. taskDefinitionKey: {
  54. default: ''
  55. }
  56. },
  57. data() {
  58. return {
  59. loading: false,
  60. form: {
  61. reason: '同意'
  62. },
  63. rules: {
  64. reason: [
  65. {
  66. required: true,
  67. whitespace: true,
  68. message: '请输入审批建议',
  69. trigger: 'blur'
  70. }
  71. ]
  72. }
  73. };
  74. },
  75. methods: {
  76. /** 校验审批意见后执行当前流程任务。 */
  77. handleAudit(status) {
  78. this.$refs.formRef.validate((valid) => {
  79. if (valid) {
  80. this.submitTask(status);
  81. }
  82. });
  83. },
  84. async submitTask(status) {
  85. const API = status ? approveTaskWithVariables : rejectTask;
  86. this.loading = true;
  87. try {
  88. const payload = {
  89. id: this.taskId,
  90. reason: this.form.reason
  91. };
  92. if (status) {
  93. payload.variables = { pass: true };
  94. }
  95. const res = await API(payload);
  96. // 仅接口明确返回成功码时关闭处理弹窗并刷新待办。
  97. if (res && res.data && (res.data.code === 0 || res.data.code === '0')) {
  98. this.$emit('handleAudit', {
  99. status,
  100. title: status === 0 ? '驳回' : ''
  101. });
  102. }
  103. } finally {
  104. this.loading = false;
  105. }
  106. }
  107. }
  108. };
  109. </script>
  110. <style scoped lang="scss">
  111. .actions {
  112. margin: 0 0 20px 10%;
  113. font-size: 14px;
  114. }
  115. </style>