create.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <script setup>
  2. import { ref } from "vue";
  3. import { createRuiHenTask } from "@/api/ruihen";
  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.validate();
  11. formLoading.value = true;
  12. await createRuiHenTask({ taskList: [formRef.value.buildSubmitData()] });
  13. uni.showToast({
  14. title: "新增成功",
  15. icon: "success",
  16. });
  17. setTimeout(() => {
  18. uni.navigateBack();
  19. }, 500);
  20. } catch (error) {
  21. console.log("submit create task error", error);
  22. } finally {
  23. formLoading.value = false;
  24. }
  25. };
  26. </script>
  27. <template>
  28. <view class="page">
  29. <scroll-view scroll-y="true" class="segmented-content">
  30. <!-- 复用任务表单组件 -->
  31. <Form ref="formRef" type="create"></Form>
  32. </scroll-view>
  33. <view class="segmented-footer">
  34. <view class="footer-btn">
  35. <!-- 新增页底部确认按钮 -->
  36. <button
  37. :loading="formLoading"
  38. class="mini-btn"
  39. type="primary"
  40. @click="submitForm">
  41. 确定
  42. </button>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <style lang="scss" scoped>
  48. @import "@/style/work-order-segmented.scss";
  49. .page {
  50. padding-bottom: 0;
  51. }
  52. .footer-btn {
  53. display: flex;
  54. justify-content: flex-end;
  55. align-items: center;
  56. padding: 0 16px;
  57. height: 100%;
  58. }
  59. :deep(.mini-btn) {
  60. height: 38px !important;
  61. font-size: 16px !important;
  62. margin: 0;
  63. }
  64. </style>