index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="min-h-screen bg-gray-50">
  3. <!-- 顶部导航栏 -->
  4. <view class="flex items-center justify-between bg-white p-4 border-b">
  5. <text class="text-xl font-bold">常德市</text>
  6. </view>
  7. <!-- 主要内容区域 -->
  8. <view class="p-4">
  9. <!-- 第一行数据卡片 -->
  10. <view class="grid grid-cols-2 md-grid-cols-4 gap-4 mb-6">
  11. <!-- 抽离配置项,通过循环渲染(减少重复代码) -->
  12. <view v-for="(item, index) in statCardList" :key="index" class="rounded-lg p-4 shadow-sm"
  13. :class="`bg-${item.bgColor}`" @click="handleIconClick(urbanDistrictData[item.dataKey],item)">
  14. <text class="text-gray-500 text-sm block mb-1">{{ item.name }}</text>
  15. <text class="text-xl font-bold">{{ urbanDistrictData[item.dataKey] }}</text>
  16. </view>
  17. </view>
  18. <!-- 第二行数据卡片 -->
  19. <view class="grid grid-cols-3 gap-4 mb-6">
  20. <view class="rounded-lg p-4 shadow-sm bg-[#F8FAFF]" @click="householdsPage()">
  21. <text class="text-gray-500 text-sm block mb-1">总户数</text>
  22. <text class="text-sm font-bold">统计中</text>
  23. </view>
  24. <view class="rounded-lg p-4 shadow-sm bg-[#F7FFF9]" @click="householdsPage()">
  25. <text class="text-gray-500 text-sm block mb-1">已上报</text>
  26. <text class="text-sm font-bold">统计中</text>
  27. </view>
  28. <view class="rounded-lg p-4 shadow-sm bg-[#FFF7F7]">
  29. <text class="text-gray-500 text-sm block mb-1" @click="householdsPage()">未上报</text>
  30. <text class="text-sm font-bold text-red-500">统计中</text>
  31. </view>
  32. </view>
  33. <!-- 第三行数据卡片 -->
  34. <view class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
  35. <!-- 待审核 -->
  36. <view class="rounded-lg p-4 shadow-sm hover:shadow-md transition-all duration-300 bg-pink-50"
  37. @click="toBeReviewedTotal()">
  38. <text class="text-gray-500 text-sm block mb-1">待审核</text>
  39. <text class="text-xl font-bold text-pink-500">统计中</text>
  40. </view>
  41. <!-- 未通过 -->
  42. <view class="rounded-lg p-4 shadow-sm hover:shadow-md transition-all duration-300 bg-orange-50">
  43. <text class="text-gray-500 text-sm block mb-1">未通过</text>
  44. <text class="text-xl font-bold text-orange-500">统计中</text>
  45. </view>
  46. <!-- 待公示 -->
  47. <!-- <view class="rounded-lg p-4 shadow-sm hover:shadow-md transition-all duration-300 bg-amber-50">
  48. <text class="text-gray-500 text-sm block mb-1">待公示</text>
  49. <text class="text-xl font-bold text-amber-500">暂未统计</text>
  50. </view> -->
  51. <!-- 已公示 -->
  52. <!-- <view class="rounded-lg p-4 shadow-sm hover:shadow-md transition-all duration-300 bg-green-50">
  53. <text class="text-gray-500 text-sm block mb-1">已公示</text>
  54. <text class="text-xl font-bold text-green-500">暂未统计</text>
  55. </view> -->
  56. </view>
  57. <!-- 功能按钮区域 -->
  58. <!-- <view class="grid grid-cols-2 gap-4 mb-6">
  59. <view
  60. class="bg-white rounded-lg p-4 flex items-center justify-between shadow-sm hover:shadow-md transition-shadow"
  61. @click="goToTask()">
  62. <text class="font-medium text-blue-600 underline">现场调查任务</text>
  63. <uni-icons type="right" color="#3B82F6" size="18"></uni-icons>
  64. </view>
  65. <view
  66. class="bg-white rounded-lg p-4 flex items-center justify-between shadow-sm hover:shadow-md transition-shadow"
  67. @click="goArchive">
  68. <text class="font-medium text-blue-600 underline">档案资料</text>
  69. <uni-icons type="right" color="#3B82F6" size="18"></uni-icons>
  70. </view>
  71. </view> -->
  72. <!-- 乡镇数据列表 -->
  73. <view class="space-y-4">
  74. <view class="bg-white rounded-lg p-4 shadow-sm hover:shadow-md transition-shadow"
  75. v-for="(item,index) in townData" :key="index" @click="jumpTown(item)">
  76. <text class="font-medium text-base mb-3 block">{{item.nameAll}}</text>
  77. <view class="grid grid-cols-4 gap-2 text-sm">
  78. <view>
  79. <text class="text-gray-500 block">总户数</text>
  80. <text class="font-medium bg-gray-100 px-2 py-1 rounded inline-block">统计中</text>
  81. </view>
  82. <view>
  83. <text class="text-gray-500 block">未上报</text>
  84. <text class="font-medium text-red-500 bg-red-50 px-2 py-1 rounded inline-block">统计中</text>
  85. </view>
  86. <view>
  87. <text class="text-gray-500 block">已上报</text>
  88. <text class="font-medium bg-gray-100 px-2 py-1 rounded inline-block">统计中</text>
  89. </view>
  90. <view class="flex items-end justify-between">
  91. <view>
  92. <text class="text-gray-500 block">已完成</text>
  93. <text class="font-medium bg-gray-100 px-2 py-1 rounded inline-block">统计中</text>
  94. </view>
  95. <uni-icons type="right" color="#999" size="16"></uni-icons>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script setup lang="ts">
  104. import { ref } from 'vue';
  105. import { onLoad } from '@dcloudio/uni-app';
  106. import { getbuildTree } from '@/api/region.js';
  107. import { getTotalLauncher } from '@/api/employer.js';
  108. const pageType = ref(null)
  109. // 无需额外逻辑,直接展示静态数据
  110. const urbanDistrictData = {
  111. mainEmployer: ref(),
  112. notStarted: 0,
  113. underInvestigation: 6698,
  114. underPublicity: 0
  115. }
  116. // 状态卡片配置(统一管理,便于维护)
  117. const statCardList = [
  118. {
  119. name: '总发包方',
  120. dataKey: 'mainEmployer',
  121. type: 'mainEmployer',
  122. bgColor: 'fffaff' // 对应原 bg-[#FFFAFF]
  123. },
  124. {
  125. name: '未开始',
  126. dataKey: 'notStarted',
  127. type: 'notStarted',
  128. bgColor: 'fff7f8' // 对应原 bg-[#FFF7F8]
  129. },
  130. {
  131. name: '摸底中',
  132. dataKey: 'underInvestigation',
  133. type: 'underInvestigation',
  134. bgColor: 'fffef9' // 对应原 bg-[#FFFEF9]
  135. },
  136. {
  137. name: '公示中',
  138. dataKey: 'underPublicity',
  139. type: 'underPublicity',
  140. bgColor: 'fffeb2' // 对应原 bg-[#FFFEB2]
  141. }
  142. ];
  143. //获取到所有石门县下的镇数据
  144. const townData = ref([]);
  145. async function getList() {
  146. try {
  147. // 传入参数
  148. const res = await getbuildTree({
  149. qsdwdm: '430726'
  150. });
  151. townData.value = res.data;
  152. } catch (err) {
  153. console.error('获取失败:', err);
  154. }
  155. }
  156. //暂时获取所有发包方统计数
  157. //暂时获取所有发包方的total
  158. async function getTotal() {
  159. let data = uni.getStorageSync('investigator_FBFBM');
  160. console.log(data)
  161. try {
  162. // 传入参数
  163. const res = await getTotalLauncher({
  164. fbfbm: data,
  165. fbfmc: '',
  166. pageNum: '1',
  167. pageSize: '10'
  168. });
  169. console.log(res.data.total)
  170. urbanDistrictData.mainEmployer.value = res.data.total;
  171. } catch (err) {
  172. console.error('获取失败:', err);
  173. }
  174. }
  175. const jumpTown = (value) => {
  176. uni.navigateTo({
  177. url: `/pages/investigator/employerModule/index?groupInfo=${encodeURIComponent(JSON.stringify(value))}`
  178. })
  179. }
  180. const handleIconClick = (e, value) => {
  181. if (e === 0) {
  182. uni.showToast({
  183. title: '暂无数据',
  184. icon: 'none',
  185. });
  186. } else {
  187. uni.navigateTo({
  188. url: `/pages/investigator/employerModule/index?groupInfo=${encodeURIComponent(JSON.stringify(value))}`
  189. })
  190. }
  191. }
  192. const toBeReviewedTotal = () => {
  193. console.log(1123,pageType.value)
  194. uni.navigateTo({
  195. url: `/pages/official/index_totalSHlist?type=` + pageType.value
  196. })
  197. // uni.navigateTo({
  198. // url: `/pages/investigator/Households/index`
  199. // })
  200. }
  201. const householdsPage = () => {
  202. uni.navigateTo({
  203. url: `/pages/investigator/Households/index`
  204. })
  205. }
  206. // 跳转现场调查任务跳转现场调查任务跳转现场调查任务
  207. // 跳转现场调查任务跳转现场调查任务跳转现场调查任务
  208. const goToTask = () => {
  209. uni.navigateTo({
  210. url: '/pages/task/index'
  211. });
  212. };
  213. // ==================== 入口 ====================
  214. onLoad(async (options) => {
  215. pageType.value = options.type;
  216. getList()
  217. });
  218. // getTotal()
  219. </script>
  220. <style>
  221. /* 统一定义背景色(避免行内样式,提升可维护性) */
  222. .bg-fffaff {
  223. background-color: #FFFAFF;
  224. }
  225. .bg-fff7f8 {
  226. background-color: #FFF7F8;
  227. }
  228. .bg-fffef9 {
  229. background-color: #FFFEF9;
  230. }
  231. .bg-fffeb2 {
  232. background-color: #FFFEB2;
  233. }
  234. </style>