index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. <view v-for="(item, index) in statCardList" :key="index" class="rounded-lg p-4 shadow-sm"
  12. :class="`bg-${item.bgColor}`" @click="handleIconClick(urbanDistrictData[item.dataKey],item)">
  13. <text class="text-gray-500 text-sm block mb-1">{{ item.name }}</text>
  14. <text class="text-xl font-bold">{{ item.value }}</text>
  15. </view>
  16. </view>
  17. <!-- 第二行数据卡片 -->
  18. <view class="grid grid-cols-3 gap-4 mb-6">
  19. <view class="rounded-lg p-4 shadow-sm bg-[#F8FAFF]" @click="householdsPage()">
  20. <text class="text-gray-500 text-sm block mb-1">总户数</text>
  21. <text class="text-sm font-bold">暂未统计</text>
  22. </view>
  23. <view class="rounded-lg p-4 shadow-sm bg-[#F7FFF9]" @click="householdsPage()">
  24. <text class="text-gray-500 text-sm block mb-1">已上报</text>
  25. <text class="font-bold text-sm">暂未统计</text>
  26. </view>
  27. <view class="rounded-lg p-4 shadow-sm bg-[#FFF7F7]">
  28. <text class="text-gray-500 text-sm block mb-1" @click="householdsPage()">未上报</text>
  29. <text class="text-sm font-bold text-red-500">暂未统计</text>
  30. </view>
  31. </view>
  32. <!-- 第三行数据卡片 -->
  33. <view class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
  34. <!-- 待审核 -->
  35. <view class="rounded-lg p-4 shadow-sm hover:shadow-md transition-all duration-300 bg-pink-50">
  36. <text class="text-gray-500 text-sm block mb-1">待审核</text>
  37. <text class="text-sm font-bold text-pink-500">暂未统计</text>
  38. </view>
  39. <!-- 未通过 -->
  40. <view class="rounded-lg p-4 shadow-sm hover:shadow-md transition-all duration-300 bg-orange-50">
  41. <text class="text-gray-500 text-sm block mb-1">未通过</text>
  42. <text class="text-sm font-bold text-orange-500">暂未统计</text>
  43. </view>
  44. <!-- 待公示 -->
  45. <!-- <view class="rounded-lg p-4 shadow-sm hover:shadow-md transition-all duration-300 bg-amber-50">
  46. <text class="text-gray-500 text-sm block mb-1">待公示</text>
  47. <text class="text-xl font-bold text-amber-500">188260</text>
  48. </view> -->
  49. <!-- 已公示 -->
  50. <!-- <view class="rounded-lg p-4 shadow-sm hover:shadow-md transition-all duration-300 bg-green-50">
  51. <text class="text-gray-500 text-sm block mb-1">已公示</text>
  52. <text class="text-xl font-bold text-green-500">0</text>
  53. </view> -->
  54. </view>
  55. <!-- 功能按钮区域 -->
  56. <!-- <view class="grid grid-cols-2 gap-4 mb-6">
  57. <view
  58. class="bg-white rounded-lg p-4 flex items-center justify-between shadow-sm hover:shadow-md transition-shadow"
  59. @click="goToTask()">
  60. <text class="font-medium text-blue-600 underline">现场调查任务</text>
  61. <uni-icons type="right" color="#3B82F6" size="18"></uni-icons>
  62. </view>
  63. <view
  64. class="bg-white rounded-lg p-4 flex items-center justify-between shadow-sm hover:shadow-md transition-shadow"
  65. @click="goArchive">
  66. <text class="font-medium text-blue-600 underline">档案资料</text>
  67. <uni-icons type="right" color="#3B82F6" size="18"></uni-icons>
  68. </view>
  69. </view> -->
  70. <!-- 乡镇数据列表 -->
  71. <view class="space-y-4">
  72. <view class="bg-white rounded-lg p-4 shadow-sm hover:shadow-md transition-shadow"
  73. v-for="(item,index) in dataList" :key="index" @click="handleCardClick(item)">
  74. <text class="font-medium text-base mb-3 block">{{item.fbfmc}}</text>
  75. <view class="grid grid-cols-4 gap-2 text-sm">
  76. <view>
  77. <text class="text-gray-500 block">总户数</text>
  78. <text class="font-medium bg-gray-100 px-2 py-1 rounded inline-block">未统计</text>
  79. </view>
  80. <view>
  81. <text class="text-gray-500 block">未上报</text>
  82. <text class="font-medium text-red-500 bg-red-50 px-2 py-1 rounded inline-block">未统计</text>
  83. </view>
  84. <view>
  85. <text class="text-gray-500 block">已上报</text>
  86. <text class="font-medium bg-gray-100 px-2 py-1 rounded inline-block">未统计</text>
  87. </view>
  88. <view class="flex items-end justify-between">
  89. <view>
  90. <text class="text-gray-500 block">已完成</text>
  91. <text class="font-medium bg-gray-100 px-2 py-1 rounded inline-block">未统计</text>
  92. </view>
  93. <uni-icons type="right" color="#999" size="16"></uni-icons>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </template>
  101. <script setup lang="ts">
  102. import { ref } from 'vue';
  103. import { onLoad } from '@dcloudio/uni-app';
  104. import { employerLogin } from '@/api/cgbList.js';
  105. const pageType = ref(null)
  106. // 状态卡片配置(统一管理,便于维护)
  107. const statCardList = [
  108. {
  109. name: '总发包方',
  110. value: '暂未统计',
  111. dataKey: 'mainEmployer',
  112. type: 'mainEmployer',
  113. bgColor: 'fffaff' // 对应原 bg-[#FFFAFF]
  114. },
  115. {
  116. name: '未开始',
  117. value: '暂未统计',
  118. dataKey: 'notStarted',
  119. type: 'notStarted',
  120. bgColor: 'fff7f8' // 对应原 bg-[#FFF7F8]
  121. },
  122. {
  123. name: '摸底中',
  124. value: '暂未统计',
  125. dataKey: 'underInvestigation',
  126. type: 'underInvestigation',
  127. bgColor: 'fffef9' // 对应原 bg-[#FFFEF9]
  128. },
  129. {
  130. name: '公示中',
  131. value: '暂未统计',
  132. dataKey: 'underPublicity',
  133. type: 'underPublicity',
  134. bgColor: 'fffeb2' // 对应原 bg-[#FFFEB2]
  135. }
  136. ];
  137. // 接口数据
  138. const dataList = ref([]);
  139. const handleCardClick = (item) => {
  140. uni.navigateTo({
  141. url: `/pages/official/index_totalSHlist?groupInfo=${encodeURIComponent(JSON.stringify(item))}&type=${pageType.value}`
  142. })
  143. }
  144. /**
  145. * 查询农户信息并处理结果
  146. */
  147. async function getTotal() {
  148. // 加载中提示
  149. uni.showLoading({
  150. title: '查询中...'
  151. })
  152. try {
  153. // 调用查询接口
  154. const res = await employerLogin({
  155. fbfbm: uni.getStorageSync('investigator_FBFBM'),
  156. });
  157. dataList.value = res.data
  158. // 1. 判断返回数据是否为空数组
  159. if (Array.isArray(res.data) && res.data.length === 0) {
  160. uni.hideLoading() // 关闭加载态
  161. uni.showToast({
  162. title: '暂无次发包方的信息',
  163. icon: 'none',
  164. duration: 2000
  165. })
  166. return // 终止后续逻辑
  167. }
  168. uni.hideLoading() // 关闭加载态
  169. } catch (err) {
  170. console.error('暂无次发包方的信息:', err)
  171. uni.hideLoading() // 异常时关闭加载态
  172. uni.showToast({
  173. title: '查询失败,请检查网络',
  174. icon: 'none'
  175. })
  176. }
  177. }
  178. // ==================== 入口 ====================
  179. onLoad(async (options) => {
  180. console.log(12,options.type)
  181. pageType.value = options.type;
  182. getTotal()
  183. });
  184. </script>
  185. <style>
  186. /* 统一定义背景色(避免行内样式,提升可维护性) */
  187. .bg-fffaff {
  188. background-color: #FFFAFF;
  189. }
  190. .bg-fff7f8 {
  191. background-color: #FFF7F8;
  192. }
  193. .bg-fffef9 {
  194. background-color: #FFFEF9;
  195. }
  196. .bg-fffeb2 {
  197. background-color: #FFFEB2;
  198. }
  199. </style>