position.vue 4.3 KB

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