position.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <hc-sys navBarUi="white">
  3. <template #navBar>
  4. <hc-nav-back-bar title="声像资料">
  5. <view class="text-26">
  6. <picker :range="typeData" :value="typeIndex" @change="bindTypeChange">
  7. <view class="flex items-center">
  8. <text>{{typeData[typeIndex]}}</text>
  9. <text class="i-iconoir-nav-arrow-down" un-text-36 un-text-gray-6/>
  10. </view>
  11. </picker>
  12. </view>
  13. </hc-nav-back-bar>
  14. </template>
  15. <view class="relative" un-border-t="1 solid gray-2" v-if="typeIndex === 0">
  16. <hc-tree counts @load="getAllLoad" @nodeTap="nodeAllTap"/>
  17. </view>
  18. <view class="relative" un-border-t="1 solid gray-2" v-if="typeIndex === 1">
  19. 暂无接口
  20. </view>
  21. <!--底部操作栏-->
  22. <HcTabbarBlock :height="70"/>
  23. <hc-tabbars class="flex items-center">
  24. <view class="w-200 mr-4">
  25. <button hover-class="none" class="cu-btn block bg-gray-4 text-white" @click="viewClick">查看</button>
  26. </view>
  27. <view class="flex-1">
  28. <button hover-class="none" class="cu-btn block bg-purple-8 text-white" @click="uploadClick">拍照/上传</button>
  29. </view>
  30. </hc-tabbars>
  31. </hc-sys>
  32. </template>
  33. <script setup>
  34. import {ref} from "vue";
  35. import {onLoad} from '@dcloudio/uni-app'
  36. import mainApi from '~api/image/index';
  37. import {useAppStore} from "@/store";
  38. import {getArrValue, getObjValue} from "js-fast-way";
  39. import {errorToast} from "@/utils/tools";
  40. //初始变量
  41. const store = useAppStore()
  42. const contractInfo = ref(store.contractInfo);
  43. const projectId = ref(store.projectId);
  44. const contractId = ref(store.contractId);
  45. //基础变量
  46. const pageNode = ref({});
  47. const typeData = ['全显示', '隐蔽工程']
  48. const typeIndex = ref(0)
  49. //页面启动
  50. onLoad(({node}) => {
  51. pageNode.value = node ? JSON.parse(decodeURIComponent(node)) : {};
  52. })
  53. //全部树
  54. const getAllLoad = async (node, resolve) => {
  55. const { contractType } = contractInfo.value
  56. const { id, contractIdRelation } = getObjValue(node.data)
  57. const { data } = await mainApi.queryTreeList({
  58. contractId: contractId.value,
  59. contractIdRelation: contractIdRelation ?? '',
  60. primaryKeyId: id ?? '',
  61. parentId: id ?? '',
  62. classifyType: contractType ?? '',
  63. classId: pageNode.value?.id,
  64. })
  65. resolve(getArrValue(data))
  66. }
  67. //树节点被点击
  68. const treeItem = ref({})
  69. const nodeAllTap = ({data}) => {
  70. if (data?.notExsitChild) {
  71. treeItem.value = getObjValue(data);
  72. } else {
  73. treeItem.value = {};
  74. }
  75. }
  76. //数据类型
  77. const bindTypeChange = ({detail}) => {
  78. const val = detail.value
  79. typeIndex.value = val
  80. if (val === 1) {
  81. queryWorksTree()
  82. }
  83. }
  84. //获取隐蔽工程的节点
  85. const queryWorksTree = async () => {
  86. const {id} = pageNode.value
  87. const {data} = await mainApi.queryWorksTree({
  88. contractId: contractId.value,
  89. classId: id,
  90. })
  91. console.log(data)
  92. }
  93. const toPageNode = () => {
  94. const {primaryKeyId} = treeItem.value
  95. if (!primaryKeyId) {
  96. errorToast('请先选择最后的一个树节点')
  97. return false;
  98. }
  99. //准备跳转路由
  100. return encodeURIComponent(JSON.stringify({
  101. ...pageNode.value,
  102. treeId: primaryKeyId
  103. }));
  104. }
  105. //查看
  106. const viewClick = () => {
  107. const node = toPageNode()
  108. if (!node) return false;
  109. uni.navigateTo({
  110. url: `/pages/image/view?node=${node}`
  111. });
  112. }
  113. //拍照/上传
  114. const uploadClick = () => {
  115. const node = toPageNode()
  116. if (!node) return false;
  117. uni.navigateTo({
  118. url: `/pages/image/form?node=${node}`
  119. })
  120. }
  121. </script>