edit.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <script setup>
  2. import { ref } from 'vue';
  3. import { createIotRyDailyReport } from '@/api/ruiying';
  4. import Form from './components/form.vue';
  5. const formRef = ref(null);
  6. const formLoading = ref(false);
  7. const submitForm = async () => {
  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 { createTime, ...other } = form;
  21. const data = { ...other, fillOrderCreateTime: createTime, projectClassification: '1' };
  22. await createIotRyDailyReport(data);
  23. formRef.value.loadDetail(form.id);
  24. uni.showToast({
  25. title: '修改成功',
  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="edit"></Form>
  39. </scroll-view>
  40. <view class="segmented-footer">
  41. <view class="footer-btn">
  42. <button
  43. :disabled="formLoading || formRef?.form.status !== 0"
  44. :loading="formLoading"
  45. class="mini-btn"
  46. type="primary"
  47. @click="submitForm">
  48. 确定
  49. </button>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <style lang="scss" scoped>
  55. @import '@/style/work-order-segmented.scss';
  56. .page {
  57. padding-bottom: 0;
  58. }
  59. .footer-btn {
  60. display: flex;
  61. justify-content: flex-end;
  62. align-items: center;
  63. padding: 0 32px;
  64. height: 100%;
  65. gap: 0 32px;
  66. & > uni-button {
  67. margin: 0;
  68. }
  69. }
  70. :deep(.mini-btn) {
  71. height: 38px !important;
  72. font-size: 16px !important;
  73. }
  74. </style>