edit.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view class="page ridu-edit-page">
  3. <view class="segmented-header">
  4. <uni-segmented-control
  5. :current="currentTab"
  6. :values="tabTitles"
  7. :style-type="styleType"
  8. :active-color="activeColor"
  9. @clickItem="onClickTabItem"
  10. />
  11. </view>
  12. <scroll-view scroll-y="true" class="segmented-content">
  13. <!-- 工单信息 -->
  14. <view class="work-order-info" v-show="currentTab === 0">
  15. <report-info :report-id="reportId" :report-data="detailData" />
  16. </view>
  17. <!-- 保养项列表 -->
  18. <view class="work-order-bom-list" v-show="currentTab === 1">
  19. <report-form ref="reportFormEditRef" :report-id="reportId" :report-data="detailData" />
  20. </view>
  21. </scroll-view>
  22. <!-- 底部总览 及 操作按钮 -->
  23. <view class="segmented-footer">
  24. <uni-row class="flex-row align-center justify-end">
  25. <uni-col :span="6">
  26. <view class="footer-btn">
  27. <button class="mini-btn" type="primary" @click="save">
  28. {{ t("operation.save") }}
  29. </button>
  30. </view>
  31. </uni-col>
  32. </uni-row>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import { onLoad, onReady, onBackPress } from "@dcloudio/uni-app";
  38. import {
  39. reactive,
  40. ref,
  41. onMounted,
  42. onBeforeUnmount,
  43. nextTick,
  44. getCurrentInstance,
  45. watch,
  46. } from "vue";
  47. import dayjs from "dayjs";
  48. // -------------------------- 引入api接口 start--------------------------
  49. import { getRuiDuReportDetail } from "@/api/ruiDu.js";
  50. // -------------------------- 引入api接口 end--------------------------
  51. // --------------------------引入组件----------------------------------
  52. import reportInfo from "./compontents/report-info.vue";
  53. import reportForm from "./compontents/report-form.vue";
  54. // --------------------------引用全局变量$t-------------------------------
  55. const { appContext } = getCurrentInstance();
  56. const t = appContext.config.globalProperties.$t;
  57. // ----------------------------选项卡----------------------------------
  58. // 选项卡标题
  59. const tabTitles = ref([t("ruiDu.taskInfo"), t("ruiDu.reportInfo")]);
  60. const currentTab = ref(0);
  61. const styleType = ref("text");
  62. const activeColor = ref("#004098");
  63. const onClickTabItem = (e) => {
  64. currentTab.value = e.currentIndex;
  65. };
  66. // --------------------------页面变量----------------------------------
  67. // 报告ID
  68. const reportId = ref("");
  69. // 报告详情数据
  70. const detailData = ref({});
  71. // 表单组件ref
  72. const reportFormEditRef = ref(null);
  73. // --------------------------生命周期函数----------------------------------
  74. onLoad((option) => {
  75. // 页面加载
  76. reportId.value = option.id; // 获取页面参数
  77. // 获取日报详情
  78. getReportDetail();
  79. });
  80. // -------------------------- 页面方法 --------------------------
  81. // 获取日报详情
  82. const getReportDetail = () => {
  83. getRuiDuReportDetail({ id: reportId.value })
  84. .then((res) => {
  85. if (res.code === 0) {
  86. detailData.value = Object.assign(detailData.value, res.data || {});
  87. console.log(
  88. "🚀 ~ getReportDetail ~ detailData.value:",
  89. detailData.value
  90. );
  91. }
  92. })
  93. .catch((res) => {});
  94. };
  95. // 保存
  96. const save = () => {
  97. reportFormEditRef.value.submitForm();
  98. };
  99. // -------------------------- 页面方法 end --------------------------
  100. </script>
  101. <style lang="scss" scoped>
  102. @import "@/style/work-order-segmented.scss";
  103. .page {
  104. padding-bottom: 0;
  105. }
  106. </style>