query.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div v-loading="boxLoading" class="hc-layout-box">
  3. <HcNewCard v-if="menuDatas.length <= 0" ui="flex-1">
  4. <HcStatus />
  5. </HcNewCard>
  6. <template v-if="menuDatas.length > 0">
  7. <div class="hc-layout-left">
  8. <el-scrollbar>
  9. <el-menu :default-active="menuKey" class="hc-ledger-query-menu" unique-opened>
  10. <el-sub-menu v-for="item in menuDatas" :key="item?.primaryKeyId" :index="item?.primaryKeyId">
  11. <template #title>{{ item?.title }}</template>
  12. <el-menu-item :index="`${item?.primaryKeyId}-form`" @click="handleMenuValue('form', item)">
  13. 日志填报
  14. </el-menu-item>
  15. <el-menu-item :index="`${item?.primaryKeyId}-table`" @click="handleMenuValue('table', item)">
  16. 日志列表查看
  17. </el-menu-item>
  18. </el-sub-menu>
  19. </el-menu>
  20. </el-scrollbar>
  21. </div>
  22. <HcTableForm
  23. v-if="menuType === 'form'" :contract-id="contractId" :items="menuItem"
  24. :project-id="projectId" :user-name="userInfo.real_name"
  25. />
  26. <HcTableList v-if="menuType === 'table'" :contract-id="contractId" :items="menuItem" :project-id="projectId" />
  27. </template>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { onMounted, ref } from 'vue'
  32. import { useAppStore } from '~src/store'
  33. import queryApi from '~api/ledger/query'
  34. import HcTableForm from './components/table-form.vue'
  35. import HcTableList from './components/table-list.vue'
  36. import { getArrValue } from 'js-fast-way'
  37. //初始变量
  38. const useAppState = useAppStore()
  39. //全局变量
  40. const projectId = ref(useAppState.getProjectId)
  41. const contractId = ref(useAppState.getContractId)
  42. const userInfo = ref(useAppState.getUserInfo)
  43. //渲染完成
  44. onMounted(() => {
  45. queryLogList()
  46. })
  47. //日志类型变量
  48. const boxLoading = ref(false)
  49. const menuDatas = ref([])
  50. const menuKey = ref('')
  51. const menuItem = ref({})
  52. const menuType = ref('form')
  53. //获取当前合同段下的日志类型
  54. const queryLogList = async () => {
  55. boxLoading.value = true
  56. const { error, code, data } = await queryApi.queryLogList({
  57. contractId: contractId.value,
  58. })
  59. //判断状态
  60. boxLoading.value = false
  61. const dataArr = getArrValue(data)
  62. if (!error && code === 200 && dataArr.length > 0) {
  63. menuDatas.value = dataArr
  64. menuItem.value = dataArr[0]
  65. menuKey.value = `${dataArr[0]?.primaryKeyId}-form`
  66. menuType.value = 'form'
  67. } else {
  68. menuDatas.value = []
  69. menuItem.value = {}
  70. menuKey.value = ''
  71. menuType.value = ''
  72. }
  73. }
  74. //菜单被点击
  75. const handleMenuValue = (type, item) => {
  76. menuItem.value = item
  77. menuKey.value = `${item?.primaryKeyId}-${type}`
  78. menuType.value = type
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. @import "../../styles/ledger/query.scss";
  83. </style>
  84. <style lang="scss">
  85. .hc-ledger-query-menu.el-menu {
  86. padding: 5px 24px;
  87. border-right: 0;
  88. background-color: initial;
  89. --el-menu-text-color: #595959;
  90. .el-menu {
  91. border-right: 0;
  92. background-color: initial;
  93. }
  94. .el-sub-menu, .el-menu-item {
  95. user-select: none;
  96. }
  97. .el-sub-menu .el-sub-menu__icon-arrow {
  98. right: 4px;
  99. }
  100. .el-sub-menu .el-menu-item.is-active {
  101. background: #f1f5f8;
  102. border-radius: 6px;
  103. box-shadow: 4px 4px 8px 0 rgba(54, 92, 167, 0.15), -4px -4px 8px 0 #ffffff;
  104. }
  105. }
  106. </style>