detail.vue 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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" :form-disable="true" />
  20. </view>
  21. </scroll-view>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { onLoad, onReady, onBackPress } from "@dcloudio/uni-app";
  26. import {
  27. reactive,
  28. ref,
  29. onMounted,
  30. onBeforeUnmount,
  31. nextTick,
  32. getCurrentInstance,
  33. watch,
  34. } from "vue";
  35. import dayjs from "dayjs";
  36. // -------------------------- 引入api接口 start--------------------------
  37. import { getRuiDuReportDetail } from "@/api/ruiDu.js";
  38. // -------------------------- 引入api接口 end--------------------------
  39. // --------------------------引入组件----------------------------------
  40. import reportInfo from "./compontents/report-info.vue";
  41. import reportForm from "./compontents/report-form.vue";
  42. // --------------------------引用全局变量$t-------------------------------
  43. const { appContext } = getCurrentInstance();
  44. const t = appContext.config.globalProperties.$t;
  45. // ----------------------------选项卡----------------------------------
  46. // 选项卡标题
  47. const tabTitles = ref([t("ruiDu.taskInfo"), t("ruiDu.reportInfo")]);
  48. const currentTab = ref(0);
  49. const styleType = ref("text");
  50. const activeColor = ref("#004098");
  51. const onClickTabItem = (e) => {
  52. currentTab.value = e.currentIndex;
  53. };
  54. // --------------------------页面变量----------------------------------
  55. // 报告ID
  56. const reportId = ref("");
  57. // 报告详情数据
  58. const detailData = ref({});
  59. // 表单组件ref
  60. const reportFormEditRef = ref(null);
  61. // --------------------------生命周期函数----------------------------------
  62. onLoad((option) => {
  63. // 页面加载
  64. reportId.value = option.id; // 获取页面参数
  65. // 获取日报详情
  66. getReportDetail();
  67. });
  68. // -------------------------- 页面方法 --------------------------
  69. // 获取日报详情
  70. const getReportDetail = () => {
  71. getRuiDuReportDetail({ id: reportId.value })
  72. .then((res) => {
  73. if (res.code === 0) {
  74. detailData.value = Object.assign(detailData.value, res.data || {});
  75. console.log(
  76. "🚀 ~ getReportDetail ~ detailData.value:",
  77. detailData.value
  78. );
  79. }
  80. })
  81. .catch((res) => {});
  82. };
  83. // -------------------------- 页面方法 end --------------------------
  84. </script>
  85. <style lang="scss" scoped>
  86. @import "@/style/work-order-segmented.scss";
  87. .page {
  88. padding-bottom: 0;
  89. }
  90. .segmented-content{
  91. height: calc(100% - 45px - 20px);
  92. }
  93. </style>