write.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="hc-layout-box">
  3. <div v-if="sbTableKey !== 'weather'" :style="`width:${leftWidth}px;`" class="hc-layout-left-box bg-white">
  4. <div class="hc-project-box">
  5. <div class="hc-project-icon-box">
  6. <HcIcon name="stack" />
  7. </div>
  8. <div class="ml-2 project-name-box">
  9. <span class="text-xl text-cut project-alias">{{ projectInfo.projectAlias }}</span>
  10. <div class="text-xs text-cut project-name">{{ projectInfo.name }}</div>
  11. </div>
  12. </div>
  13. <div class="hc-tree-box">
  14. <el-scrollbar>
  15. <WbsTree
  16. :auto-expand-keys="treeAutoExpandKeys" :contract-id="contractId" :project-id="projectId"
  17. @nodeTap="nodeWbsElTreeClick"
  18. />
  19. </el-scrollbar>
  20. </div>
  21. <!-- 左右拖动 -->
  22. <div class="horizontal-drag-line" @mousedown="onmousedown" />
  23. </div>
  24. <div class="hc-layout-content-box ledger-write-box">
  25. <HcTabsSimple :cur="sbTableKey" :datas="sbTableData" @tabClick="sbTableClick">
  26. <template #tab-internal>
  27. <HcInternal
  28. v-if="sbTableKey === 'internal'" :contract-id="contractId" :project-id="projectId"
  29. :tree-data="nodeDataInfo"
  30. />
  31. </template>
  32. <template #tab-construction>
  33. <HcConstruction
  34. v-if="sbTableKey === 'construction'" :contract-id="contractId" :project-id="projectId"
  35. :tree-data="nodeDataInfo"
  36. />
  37. </template>
  38. <template #tab-weather>
  39. <HcWeather v-if="sbTableKey === 'weather'" :contract-id="contractId" :project-id="projectId" />
  40. </template>
  41. </HcTabsSimple>
  42. </div>
  43. </div>
  44. </template>
  45. <script setup>
  46. import { onMounted, ref, watch } from 'vue'
  47. import { useAppStore } from '~src/store'
  48. import { useRoute, useRouter } from 'vue-router'
  49. import WbsTree from './components/WbsTree.vue'
  50. import HcInternal from './components/internal.vue'
  51. import HcWeather from './components/weather.vue'
  52. import HcConstruction from './components/construction.vue'
  53. import { getStoreValue, setStoreValue } from '~src/utils/storage'
  54. //变量
  55. const router = useRouter()
  56. const useRoutes = useRoute()
  57. const useAppState = useAppStore()
  58. const projectId = ref(useAppState.getProjectId)
  59. const contractId = ref(useAppState.getContractId)
  60. const projectInfo = ref(useAppState.getProjectInfo)
  61. const isCollapse = ref(useAppState.getCollapse)
  62. //路由参数
  63. const routerQuery = useRoutes?.query
  64. const dataType = routerQuery?.type || 'weather'
  65. //监听
  66. watch(() => [
  67. useAppState.getCollapse,
  68. ], ([Collapse]) => {
  69. isCollapse.value = Collapse
  70. })
  71. //自动展开缓存
  72. const treeAutoExpandKeys = ref([])
  73. //类型处理
  74. const sbTableKey = ref(dataType)
  75. const sbTableData = ref([
  76. { icon: 'bar-chart-box', label: '内业台账', key: 'internal' },
  77. { icon: 'tools', label: '施工台账', key: 'construction' },
  78. { icon: 'sun-cloudy', label: '天气台账', key: 'weather' },
  79. ])
  80. const sbTableClick = (key) => {
  81. sbTableKey.value = key
  82. router.push({
  83. path: useRoutes.path,
  84. query: { type: key },
  85. })
  86. getTypeData(key)
  87. }
  88. //加载完成
  89. onMounted(() => {
  90. getTypeData(dataType)
  91. })
  92. //根据类型获取相关数据
  93. const getTypeData = (key) => {
  94. if (key === 'internal' || key === 'construction') {
  95. treeAutoExpandKeys.value = getStoreValue('ledgerWriteTreeKeys') || []
  96. }
  97. }
  98. //树被点击
  99. const nodeDataInfo = ref({})
  100. const nodeWbsElTreeClick = ({ data, keys }) => {
  101. nodeDataInfo.value = data
  102. setStoreValue('ledgerWriteTreeKeys', keys)
  103. treeAutoExpandKeys.value = keys || []
  104. }
  105. //左右拖动,改变树形结构宽度
  106. const leftWidth = ref(382)
  107. const onmousedown = () => {
  108. const leftNum = isCollapse.value ? 142 : 272
  109. document.onmousemove = (ve) => {
  110. const diffVal = ve.clientX - leftNum
  111. if (diffVal >= 310 && diffVal <= 900) {
  112. leftWidth.value = diffVal
  113. }
  114. }
  115. document.onmouseup = () => {
  116. document.onmousemove = null
  117. document.onmouseup = null
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. @import "../../styles/ledger/write.scss";
  123. .hc-layout-box .hc-layout-left-box .hc-tree-box {
  124. height: calc(100% - 81px);
  125. }
  126. </style>
  127. <style lang="scss">
  128. .hc-layout-box .hc-layout-content-box.ledger-write-box .hc-card-box.el-card {
  129. border-radius: 0 var(--el-card-border-radius) var(--el-card-border-radius) var(--el-card-border-radius);
  130. height: calc(100% - 44px);
  131. }
  132. </style>