position.vue 4.4 KB

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