approval.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.validate();
  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 } = form;
  21. const data = { auditStatus, opinion, id };
  22. await approvalIotRyDailyReport(data);
  23. formRef.value.loadDetail(form.id);
  24. uni.showToast({
  25. title: auditStatus === 20 ? '通过成功' : '拒绝成功',
  26. icon: 'success',
  27. });
  28. } catch (error) {
  29. console.log('error :>> ', error);
  30. } finally {
  31. formLoading.value = false;
  32. }
  33. };
  34. </script>
  35. <template>
  36. <view class="page">
  37. <scroll-view scroll-y="true" class="segmented-content">
  38. <Form ref="formRef" type="approval"></Form>
  39. </scroll-view>
  40. <view class="segmented-footer">
  41. <view class="footer-btn">
  42. <button
  43. :disabled="formLoading || formRef?.form.auditStatus !== 10"
  44. :loading="formLoading"
  45. class="mini-btn"
  46. type="primary"
  47. @click="submitForm(20)">
  48. 审批通过
  49. </button>
  50. <button
  51. :disabled="formLoading || formRef?.form.auditStatus !== 10"
  52. :loading="formLoading"
  53. class="mini-btn"
  54. type="warn"
  55. @click="submitForm(30)">
  56. 审批驳回
  57. </button>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <style lang="scss" scoped>
  63. @import '@/style/work-order-segmented.scss';
  64. .page {
  65. padding-bottom: 0;
  66. }
  67. .footer-btn {
  68. display: flex;
  69. justify-content: flex-end;
  70. align-items: center;
  71. padding: 0 32px;
  72. height: 100%;
  73. gap: 0 32px;
  74. & > uni-button {
  75. margin: 0;
  76. }
  77. }
  78. :deep(.mini-btn) {
  79. height: 38px !important;
  80. font-size: 16px !important;
  81. }
  82. </style>