position.vue 4.3 KB

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