edit.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <script setup>
  2. import { ref } from "vue";
  3. import { onLoad } from "@dcloudio/uni-app";
  4. import { updateRuiHenTask } from "@/api/ruihen";
  5. import Form from "./components/form.vue";
  6. const formRef = ref(null);
  7. const formLoading = ref(false);
  8. const id = ref(null);
  9. onLoad((options) => {
  10. id.value = Number(options.id) || null;
  11. });
  12. const submitForm = async () => {
  13. if (!formRef.value) return;
  14. try {
  15. await formRef.value.validate();
  16. formLoading.value = true;
  17. await updateRuiHenTask({ taskList: [formRef.value.buildSubmitData()] });
  18. uni.showToast({
  19. title: "修改成功",
  20. icon: "success",
  21. });
  22. setTimeout(() => {
  23. uni.navigateBack();
  24. }, 500);
  25. } catch (error) {
  26. console.log("submit edit task error", error);
  27. } finally {
  28. formLoading.value = false;
  29. }
  30. };
  31. </script>
  32. <template>
  33. <view class="page">
  34. <scroll-view scroll-y="true" class="segmented-content">
  35. <!-- 复用任务表单组件,传入编辑模式和任务 id -->
  36. <Form ref="formRef" type="edit" :id="id"></Form>
  37. </scroll-view>
  38. <view class="segmented-footer">
  39. <view class="footer-btn">
  40. <!-- 编辑页底部确认按钮 -->
  41. <button
  42. :loading="formLoading"
  43. class="mini-btn"
  44. type="primary"
  45. @click="submitForm">
  46. 确定
  47. </button>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <style lang="scss" scoped>
  53. @import "@/style/work-order-segmented.scss";
  54. .page {
  55. padding-bottom: 0;
  56. }
  57. .footer-btn {
  58. display: flex;
  59. justify-content: flex-end;
  60. align-items: center;
  61. padding: 0 16px;
  62. height: 100%;
  63. }
  64. :deep(.mini-btn) {
  65. height: 38px !important;
  66. font-size: 16px !important;
  67. margin: 0;
  68. }
  69. </style>