approval.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <script setup>
  2. import { ref } from "vue";
  3. import { approvalIotRyDailyReport } from "@/api/ruiying";
  4. import Form from "./components/form.vue";
  5. const formRef = ref(null);
  6. const formLoading = ref(false);
  7. const submitForm = async auditStatus => {
  8. if (!formRef.value) return;
  9. try {
  10. await formRef.value.formRef.validateField("constructionBrief");
  11. const form = formRef.value.form;
  12. // if (form.nonProductionTime && !form.nptReason) {
  13. // uni.showToast({
  14. // title: '非生产时间大于 0 时,必须选择非生产时间原因',
  15. // icon: 'none',
  16. // });
  17. // return;
  18. // }
  19. formLoading.value = true;
  20. const { opinion, id, constructionBrief } = form;
  21. const data = { auditStatus, opinion, id, constructionBrief };
  22. // console.log('data :>> ', data);
  23. await approvalIotRyDailyReport(data);
  24. formRef.value.loadDetail(id);
  25. uni.showToast({
  26. title: auditStatus === 20 ? "通过成功" : "拒绝成功",
  27. icon: "success",
  28. });
  29. } catch (error) {
  30. console.log("error :>> ", error);
  31. } finally {
  32. formLoading.value = false;
  33. }
  34. };
  35. </script>
  36. <template>
  37. <view class="page">
  38. <scroll-view scroll-y="true" class="segmented-content">
  39. <Form ref="formRef" type="approval"></Form>
  40. </scroll-view>
  41. <view class="segmented-footer">
  42. <view class="footer-btn">
  43. <button
  44. :disabled="formLoading || formRef?.form.auditStatus !== 10"
  45. :loading="formLoading"
  46. class="mini-btn"
  47. type="primary"
  48. @click="submitForm(20)">
  49. 审批通过
  50. </button>
  51. <button
  52. :disabled="formLoading || formRef?.form.auditStatus !== 10"
  53. :loading="formLoading"
  54. class="mini-btn"
  55. type="warn"
  56. @click="submitForm(30)">
  57. 审批驳回
  58. </button>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <style lang="scss" scoped>
  64. @import "@/style/work-order-segmented.scss";
  65. .page {
  66. padding-bottom: 0;
  67. }
  68. .footer-btn {
  69. display: flex;
  70. justify-content: flex-end;
  71. align-items: center;
  72. padding: 0 32px;
  73. height: 100%;
  74. gap: 0 32px;
  75. & > uni-button {
  76. margin: 0;
  77. }
  78. }
  79. :deep(.mini-btn) {
  80. height: 38px !important;
  81. font-size: 16px !important;
  82. }
  83. </style>