write.vue 4.4 KB

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