index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <hc-sys navBarUi="hc-bg-white">
  3. <template #navBar>
  4. <hc-nav-back-bar ui="hc-bg-white" title="资料填报"/>
  5. </template>
  6. <view class="hc-search-bar">
  7. <uni-search-bar radius="5" bgColor="#f5f5f5" placeholder="搜索" cancelButton="none" @input="searchInput" @confirm="searchConfirm"/>
  8. </view>
  9. <view class="hc-page-body">
  10. <scroll-view scroll-y class="hc-page-menu">
  11. <template v-for="item in menuData">
  12. <view class="hc-page-menu-item"
  13. @click="menuItemClick(item)"
  14. :class="item.primaryKeyId === menuItem.primaryKeyId ? 'cur': ''"
  15. >
  16. <text :class="item.colorStatus === 2 ? 'text-blue-5':item.colorStatus === 3 ? 'text-orange-5': item.colorStatus === 4 ? 'text-green-5': ''">
  17. {{ item.title }}【{{ item.submitCounts ?? 0 }}】
  18. </text>
  19. </view>
  20. </template>
  21. </scroll-view>
  22. <scroll-view scroll-y class="hc-page-data">
  23. <template v-for="(item, index) in pageNode">
  24. <view class="hc-page-data-item"
  25. @click="pageItemClick(item, index)"
  26. :class="item.primaryKeyId === pageItem.primaryKeyId ? 'cur': ''"
  27. >
  28. <text :class="item.colorStatus === 2 ? 'text-blue-5':item.colorStatus === 3 ? 'text-orange-5': item.colorStatus === 4 ? 'text-green-5': ''">
  29. {{ item.title }}【{{ item.submitCounts ?? 0 }}】
  30. </text>
  31. </view>
  32. </template>
  33. </scroll-view>
  34. </view>
  35. </hc-sys>
  36. </template>
  37. <script setup>
  38. import {ref, onMounted} from "vue";
  39. import {useAppStore} from "@/store";
  40. import wbsApi from '~api/data-fill/wbs';
  41. import {getObjValue, getArrValue, deepClone} from "js-fast-way"
  42. import {setStorage, delStorage} from "@/utils/storage";
  43. const store = useAppStore()
  44. //初始变量
  45. const contractInfo = ref(store.contractInfo);
  46. const projectId = ref(store.projectId);
  47. const contractId = ref(store.contractId);
  48. //渲染完成
  49. onMounted(() => {
  50. delStorage('dataFill')
  51. getLoadNode()
  52. })
  53. let menuData = ref([]);
  54. let menuItem = ref({});
  55. //获取数据
  56. const getLoadNode = async () => {
  57. uni.showLoading({title: '获取数据中...', mask: true});
  58. //获取根节点的数据
  59. const {error, code, data} = await wbsApi.queryWbsTreeData({
  60. contractId: contractId.value || '',
  61. contractIdRelation: '',
  62. primaryKeyId: '',
  63. parentId: '',
  64. classifyType: '',
  65. tableOwner: contractInfo.value?.contractType ?? ''
  66. })
  67. //处理根节点的数据
  68. const nodeData = getArrValue(data)
  69. if (!error && code === 200 && nodeData.length > 0) {
  70. const {contractIdRelation, primaryKeyId, id} = getObjValue(nodeData[0])
  71. const {item, list} = await getChildNodeData({
  72. contractIdRelation: contractIdRelation ?? '',
  73. primaryKeyId: id,
  74. parentId: contractIdRelation ? primaryKeyId : id
  75. })
  76. menuItem.value = item
  77. menuData.value = list
  78. await menuItemClick(item)
  79. uni.hideLoading();
  80. } else {
  81. menuItem.value = {}
  82. menuData.value = []
  83. uni.hideLoading();
  84. }
  85. }
  86. //左侧菜单被点击
  87. const pageNodes = ref([])
  88. const pageNode = ref([])
  89. const pageItem = ref({})
  90. const menuItemClick = async (item) => {
  91. pageNodes.value = []
  92. pageNode.value = []
  93. menuItem.value = item
  94. const {contractIdRelation, primaryKeyId, id} = item
  95. const {list} = await getChildNodeData({
  96. contractIdRelation: contractIdRelation ?? '',
  97. primaryKeyId: id,
  98. parentId: contractIdRelation ? primaryKeyId : id
  99. })
  100. pageNodes.value = list
  101. pageNode.value = list
  102. }
  103. //右侧菜单被点击
  104. const pageItemClick = (item, index) => {
  105. setStorage('dataFill', {
  106. title: menuItem.value.title,
  107. node: pageNode.value,
  108. index: index,
  109. })
  110. uni.navigateTo({
  111. url: '/pages/data-fill/treeData'
  112. });
  113. }
  114. //获取子节点的数据
  115. const getChildNodeData = async (obj) => {
  116. const {error, code, data} = await wbsApi.queryWbsTreeData({
  117. ...obj,
  118. contractId: contractId.value || '',
  119. classifyType: contractInfo.value?.contractType ?? '',
  120. tableOwner: contractInfo.value?.contractType ?? ''
  121. })
  122. //处理二级节点的数据
  123. const nodeData = getArrValue(data)
  124. if (!error && code === 200 && nodeData.length > 0) {
  125. return {
  126. item: getObjValue(nodeData[0]),
  127. list: nodeData
  128. }
  129. } else {
  130. return {item: {}, list: []}
  131. }
  132. }
  133. //搜索
  134. const searchInput = (value) => {
  135. querySearch(value)
  136. }
  137. const searchConfirm = ({value}) => {
  138. querySearch(value)
  139. }
  140. const querySearch = (value) => {
  141. const pageNodeRes = deepClone(pageNodes.value)
  142. const results = value ? pageNodeRes.filter(createFilter(value)) : pageNodeRes
  143. pageNode.value = deepClone(results)
  144. }
  145. const createFilter = (value) => {
  146. return (item) => {
  147. return (item.title.toLowerCase().indexOf(value.toLowerCase()) >= 0)
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. page {
  153. background: #FAFBFE;
  154. }
  155. </style>
  156. <style lang="scss" scoped>
  157. @import "@/style/data-fill/index.scoped.scss";
  158. </style>