edit.vue 3.5 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. </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 ref="reportFormEditRef" :report-id="reportId" :report-data="detailData" />
  19. </view>
  20. <!-- <view class="work-order-bom-list" v-if="currentTab === 2">
  21. <report-form-copy ref="reportFormEditRef" :report-id="reportId" :report-data="detailData" />
  22. </view> -->
  23. </scroll-view>
  24. <!-- 底部总览 及 操作按钮 -->
  25. <view class="segmented-footer">
  26. <uni-row class="flex-row align-center justify-end">
  27. <uni-col :span="6">
  28. <view class="footer-btn">
  29. <button class="mini-btn" type="primary" @click="save">
  30. {{ t('operation.save') }}
  31. </button>
  32. </view>
  33. </uni-col>
  34. </uni-row>
  35. </view>
  36. </view>
  37. </template>
  38. <script setup>
  39. import { onLoad } from '@dcloudio/uni-app';
  40. import { ref, getCurrentInstance } from 'vue';
  41. // -------------------------- 引入api接口 start--------------------------
  42. import { getRuiDuReportDetail } from '@/api/ruiDu.js';
  43. // -------------------------- 引入api接口 end--------------------------
  44. // --------------------------引入组件----------------------------------
  45. import reportInfo from './compontents/report-info.vue';
  46. import reportForm from './compontents/report-form.vue';
  47. // --------------------------引用全局变量$t-------------------------------
  48. const { appContext } = getCurrentInstance();
  49. const t = appContext.config.globalProperties.$t;
  50. // ----------------------------选项卡----------------------------------
  51. // 选项卡标题
  52. const tabTitles = ref([t('ruiDu.taskInfo'), t('ruiDu.reportInfo')]);
  53. const currentTab = ref(0);
  54. const styleType = ref('text');
  55. const activeColor = ref('#004098');
  56. const onClickTabItem = e => {
  57. currentTab.value = e.currentIndex;
  58. };
  59. // --------------------------页面变量----------------------------------
  60. // 报告ID
  61. const reportId = ref('');
  62. // 报告详情数据
  63. const detailData = ref({});
  64. // 表单组件ref
  65. const reportFormEditRef = ref(null);
  66. // --------------------------生命周期函数----------------------------------
  67. onLoad(option => {
  68. // 页面加载
  69. reportId.value = option.id; // 获取页面参数
  70. // 获取日报详情
  71. getReportDetail();
  72. });
  73. // -------------------------- 页面方法 --------------------------
  74. // 获取日报详情
  75. const getReportDetail = () => {
  76. getRuiDuReportDetail({ id: reportId.value })
  77. .then(res => {
  78. if (res.code === 0) {
  79. detailData.value = Object.assign(detailData.value, res.data || {});
  80. }
  81. })
  82. .catch(res => {});
  83. };
  84. // 保存
  85. const save = () => {
  86. reportFormEditRef.value.submitForm();
  87. };
  88. // -------------------------- 页面方法 end --------------------------
  89. </script>
  90. <style lang="scss" scoped>
  91. @import '@/style/work-order-segmented.scss';
  92. .page {
  93. padding-bottom: 0;
  94. }
  95. </style>