query.vue 3.6 KB

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