edit.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.ryNptReason) {
  13. uni.showToast({
  14. title: '非生产时间大于 0 时,必须选择非生产时间原因',
  15. icon: 'none',
  16. });
  17. return;
  18. }
  19. if (Number(form.productionTime) + Number(form.nonProductionTime) !== Number(form.ratedProductionTime)) {
  20. uni.showToast({
  21. title: '生产时间和非生产时间之和必须等于额定生产时间',
  22. icon: 'none',
  23. });
  24. }
  25. formLoading.value = true;
  26. const { createTime, ...other } = form;
  27. const data = { ...other, fillOrderCreateTime: createTime, projectClassification: '2' };
  28. await createIotRyDailyReport(data);
  29. formRef.value.loadDetail(form.id);
  30. uni.showToast({
  31. title: '修改成功',
  32. icon: 'success',
  33. });
  34. } catch (error) {
  35. console.log('error :>> ', error);
  36. } finally {
  37. formLoading.value = false;
  38. }
  39. };
  40. </script>
  41. <template>
  42. <view class="page">
  43. <scroll-view scroll-y="true" class="segmented-content">
  44. <Form ref="formRef" type="edit"></Form>
  45. </scroll-view>
  46. <view class="segmented-footer">
  47. <view class="footer-btn">
  48. <button
  49. :disabled="formLoading || formRef?.form.status !== 0"
  50. :loading="formLoading"
  51. class="mini-btn"
  52. type="primary"
  53. @click="submitForm">
  54. 确定
  55. </button>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <style lang="scss" scoped>
  61. @import '@/style/work-order-segmented.scss';
  62. .page {
  63. padding-bottom: 0;
  64. }
  65. .footer-btn {
  66. display: flex;
  67. justify-content: flex-end;
  68. align-items: center;
  69. padding: 0 32px;
  70. height: 100%;
  71. gap: 0 32px;
  72. & > uni-button {
  73. margin: 0;
  74. }
  75. }
  76. :deep(.mini-btn) {
  77. height: 38px !important;
  78. font-size: 16px !important;
  79. }
  80. </style>