edit.vue 3.7 KB

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