detail.vue 3.0 KB

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