position.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 @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 treeApi from '~api/ledger/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 treeApi.queryTreeList({
  58. contractId: contractId.value,
  59. contractIdRelation: contractIdRelation ?? '',
  60. primaryKeyId: id ?? '',
  61. parentId: id ?? '',
  62. classifyType: contractType ?? '',
  63. })
  64. resolve(getArrValue(data))
  65. }
  66. //树节点被点击
  67. const treeItem = ref({})
  68. const nodeAllTap = ({data}) => {
  69. if (data?.leaf) {
  70. treeItem.value = getObjValue(data);
  71. } else {
  72. treeItem.value = {};
  73. }
  74. }
  75. //数据类型
  76. const bindTypeChange = ({detail}) => {
  77. typeIndex.value = detail.value
  78. }
  79. const toPageNode = () => {
  80. const {primaryKeyId} = treeItem.value
  81. if (!primaryKeyId) {
  82. errorToast('请先选择最后的一个树节点')
  83. return false;
  84. }
  85. //准备跳转路由
  86. return encodeURIComponent(JSON.stringify({
  87. ...pageNode.value,
  88. treeId: primaryKeyId
  89. }));
  90. }
  91. //查看
  92. const viewClick = () => {
  93. const node = toPageNode()
  94. if (!node) return false;
  95. uni.navigateTo({
  96. url: `/pages/image/view?node=${node}`
  97. });
  98. }
  99. //拍照/上传
  100. const uploadClick = () => {
  101. const node = toPageNode()
  102. if (!node) return false;
  103. uni.navigateTo({
  104. url: `/pages/image/form?node=${node}`
  105. })
  106. }
  107. </script>