taskSubmit.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="">
  3. <u--form
  4. style="margin: 0 20px"
  5. labelPosition="left"
  6. :model="form"
  7. :rules="rules"
  8. ref="uForm"
  9. labelWidth="140rpx"
  10. >
  11. <u-form-item label="审批建议" prop="reason" required>
  12. <u--textarea
  13. style="width: 100%"
  14. height="120"
  15. border="surround"
  16. placeholder="请输入审批建议"
  17. v-model="form.reason"
  18. ></u--textarea>
  19. </u-form-item>
  20. </u--form>
  21. <view class="btnList">
  22. <u-button
  23. style="width: 45%; margin-bottom: 10rpx"
  24. :loading="loading"
  25. type="success"
  26. text="通过"
  27. @click="handleAudit2(1)"
  28. >
  29. </u-button>
  30. <u-button
  31. style="width: 45%"
  32. :loading="loading"
  33. type="error"
  34. text="驳回"
  35. @click="handleAudit2(0)"
  36. ></u-button>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. outsourceAssign,
  43. outsourceNotPass,
  44. } from "@/api/wt/outsourcedWarehousing.js";
  45. export default {
  46. name: "taskSubmit",
  47. props: {
  48. businessId: {
  49. default: "",
  50. },
  51. taskId: {
  52. default: "",
  53. },
  54. id: {
  55. default: "",
  56. },
  57. taskDefinitionKey: {
  58. default: "",
  59. },
  60. },
  61. data() {
  62. return {
  63. loading: false,
  64. form: {
  65. reason: "同意",
  66. },
  67. rules: {
  68. reason: {
  69. type: "string",
  70. required: true,
  71. message: "请输入审批建议",
  72. trigger: "blur",
  73. },
  74. },
  75. };
  76. },
  77. mounted() {
  78. this.$refs.uForm.setRules(this.rules);
  79. },
  80. methods: {
  81. handleAudit2(status) {
  82. this.$refs.uForm
  83. .validate()
  84. .then(() => {
  85. this._approveTaskThorVariables(status);
  86. })
  87. .catch(() => {});
  88. },
  89. async _approveTaskThorVariables(status) {
  90. this.loading = true;
  91. try {
  92. if (status == 1) {
  93. await outsourceAssign({
  94. businessId: this.businessId,
  95. id: this.taskId,
  96. reason: this.form.reason,
  97. pass: true,
  98. });
  99. this.$emit("handleAudit", {
  100. status,
  101. title: "",
  102. });
  103. } else if (status == 0) {
  104. await outsourceNotPass({
  105. businessId: this.businessId,
  106. id: this.taskId,
  107. reason: this.form.reason,
  108. pass: false,
  109. });
  110. this.$emit("handleAudit", {
  111. status,
  112. title: "驳回",
  113. });
  114. }
  115. } catch (error) {
  116. console.error("审批操作失败", error);
  117. uni.showToast({
  118. title: status == 1 ? "审批失败" : "驳回失败",
  119. icon: "none",
  120. });
  121. } finally {
  122. this.loading = false;
  123. }
  124. },
  125. },
  126. };
  127. </script>
  128. <style scoped>
  129. .btnList {
  130. display: flex;
  131. }
  132. </style>