Newer
Older
xc-business-system / src / views / equipement / info / book / detail.vue
dutingting on 16 Aug 2023 4 KB 修复报错
<!-- 设备台账管理详情页 -->
<script name="EquipmentInfoBookDetail" lang="ts" setup>
import type { Ref } from 'vue'
import type { FormInstance, FormRules, TabPaneName, TabsPaneContext, UploadProps, UploadUserFile } from 'element-plus'
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
import type { IForm } from './book-interface'
import bookBasic from './components/basic.vue'
import bookUseRecord from './components/useRecord.vue'
import bookMaintenanceRecord from './components/maintenanceRecord.vue'
import bookCertificate from './components/certificate.vue'
import bookChangeRecord from './components/changeRecord.vue'
import bookEquipmentHistory from './components/equipmentHistory.vue'
import bookEquipmentFlowLog from './components/equipmentFlowLog.vue'
const textMap: { [key: string]: string } = {
  edit: '编辑',
  add: '新建',
  detail: '详情',
}// 页面类型字典
const $router = useRouter() // 路由实例
const loading = ref(false) // 表单加载状态
const pageType = ref('add') // 页面类型: add, edit, detail
const infoId = ref('') // id
const bookBasicRef = ref() // 子组件--基本信息ref
// -------------------------------------标签--------------------------------------------------
const radioMenus = ref([ // 标签内容
  { name: '基本信息', value: 'book-basic' },
  { name: '使用记录', value: 'book-use-record' },
  { name: '维护记录', value: 'book-maintenance-record' },
  { name: '证书报告', value: 'book-certificate' },
  { name: '状态变更记录', value: 'book-change-record' },
  { name: '设备履历', value: 'book-equipment-history' },
  { name: '设备流转日志', value: 'book-equipment-flowLog' },
])
const current = ref('book-basic') // 选择的tab 默认基本信息

// 点击标签
const clickTab = () => {
  console.log(current.value)
}
// -----------------------------------路由参数-------------------------------------------------
// 从路由中获取页面类型参数
const $route = useRoute()
if ($route.params && $route.params.type) {
  pageType.value = $route.params.type as string
  if ($route.params.id) {
    infoId.value = $route.params.id as string
  }
}
// ---------------------------------右上角按钮(操作表单)------------------------------------------
// 点击关闭
const close = () => {
  $router.back()
}
// 点击rfid标签绑定
const bind = () => {
  ElMessage.info('敬请期待')
}
// 点击提交
const handleSubmit = () => {}

function saveForm() {
  bookBasicRef.value.saveForm()
}
// -------------------------------------------------------------------------------------------
</script>

<template>
  <app-container>
    <detail-page v-loading="loading" :title="`设备台账管理-${textMap[pageType]}`">
      <template #btns>
        <el-button v-if="pageType === 'add'" type="primary" @click="handleSubmit">
          提交
        </el-button>
        <el-button v-if="pageType !== 'detail'" type="primary" @click="saveForm">
          保存
        </el-button>
        <el-button type="primary" @click="bind">
          rfid标签绑定
        </el-button>
        <el-button type="info" @click="close">
          关闭
        </el-button>
      </template>
      <el-radio-group v-model="current">
        <el-radio-button v-for="item in radioMenus" :key="item.value" :label="item.value">
          {{ item.name }}
        </el-radio-button>
      </el-radio-group>
      <!-- <el-tabs v-model="current" type="card" @tab-change="clickTab">
        <el-tab-pane v-for="item in tabMenus" :key="item.value" :label="item.name" :name="item.value" />
      </el-tabs> -->
    </detail-page>
    <!-- 基本信息 -->
    <book-basic v-if="current === 'book-basic'" ref="bookBasicRef" :page-type="pageType" />
    <!-- 使用记录 -->
    <!-- <book-use-record v-if="current === 'book-use-record'" :page-type="pageType" /> -->
    <!-- 维护记录 -->
    <!-- <book-maintenance-record v-if="current === 'book-maintenance-record'" :page-type="pageType" /> -->
    <!-- 证书报告 -->
    <!-- <book-certificate v-if="current === 'book-certificate'" :page-type="pageType" /> -->
    <!-- 状态变更记录 -->
    <!-- <book-change-record v-if="current === 'book-change-record'" :page-type="pageType" /> -->
    <!-- 设备履历 -->
    <!-- <book-equipment-history v-if="current === 'book-equipment-history'" :page-type="pageType" /> -->
    <!-- 设备流转日志 -->
    <!-- <book-equipment-flow-log v-if="current === 'book-equipment-flowLog'" :page-type="pageType" /> -->
  </app-container>
</template>