position.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. <hc-tree @load="getWorksLoad" @nodeTap="nodeWorksTap"/>
  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. typeIndex.value = detail.value
  79. }
  80. //获取隐蔽工程的节点
  81. const getWorksLoad = async(node, resolve) => {
  82. const { contractType } = contractInfo.value
  83. const { id, contractIdRelation } = getObjValue(node.data)
  84. const { data } = await mainApi.queryWorksTree({
  85. contractId: contractId.value,
  86. contractIdRelation: contractIdRelation ?? '',
  87. primaryKeyId: id ?? '',
  88. parentId: id ?? '',
  89. classifyType: contractType ?? '',
  90. classId: pageNode.value?.id,
  91. })
  92. resolve(getArrValue(data))
  93. }
  94. //树节点被点击
  95. const nodeWorksTap = ({data}) => {
  96. if (data?.notExsitChild) {
  97. treeItem.value = getObjValue(data);
  98. } else {
  99. treeItem.value = {};
  100. }
  101. }
  102. const toPageNode = () => {
  103. const {primaryKeyId} = treeItem.value
  104. if (!primaryKeyId) {
  105. errorToast('请先选择最后的一个树节点')
  106. return false;
  107. }
  108. //准备跳转路由
  109. return encodeURIComponent(JSON.stringify({
  110. ...pageNode.value,
  111. treeId: primaryKeyId
  112. }));
  113. }
  114. //查看
  115. const viewClick = () => {
  116. const node = toPageNode()
  117. if (!node) return false;
  118. uni.navigateTo({
  119. url: `/pages/image/view?node=${node}`
  120. });
  121. }
  122. //拍照/上传
  123. const uploadClick = () => {
  124. const node = toPageNode()
  125. if (!node) return false;
  126. uni.navigateTo({
  127. url: `/pages/image/form?node=${node}`
  128. })
  129. }
  130. </script>