index.uvue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <uni-navbar-lite :showLeft=false title="首页"></uni-navbar-lite>
  3. <view class="page-container">
  4. <!-- 快捷功能卡片 -->
  5. <view class="quick-cards">
  6. <view v-for="(item, index) in quickFunctions" :key="index" class="quick-card" @click="handleQuickClick(item)">
  7. <image class="quick-card-bg" :src="item.bgImage" mode="aspectFill"></image>
  8. <view class="quick-card-content">
  9. <text class="quick-card-title">{{ item.title }}</text>
  10. </view>
  11. <view class="management-badge">
  12. <text class="badge-text">0</text>
  13. </view>
  14. </view>
  15. </view>
  16. <view>
  17. <!-- 最近申请 -->
  18. <view class="section-title-container">
  19. <view class="section-header">
  20. <text class="section-title">最近申请</text>
  21. <text class="view-all" @click="navigateToApply" v-if="applyListData.length > 0">查看全部</text>
  22. </view>
  23. </view>
  24. <template v-if="applyListData.length > 0">
  25. <common-list
  26. :dataList="applyListData.slice(0, 4)"
  27. :loading="applyLoading"
  28. :hasMore="false"
  29. :refresherEnabled="false"
  30. :itemKey="'id'"
  31. @itemClick="handleApplyItemClick"
  32. >
  33. <template #default="{ item }">
  34. <view class="list-item">
  35. <view class="item-container">
  36. <view class="item-header">
  37. <text class="item-title">标题</text>
  38. </view>
  39. <view class="info-row">
  40. <text class="text-gray">申请单编码:</text>
  41. </view>
  42. <view class="info-row">
  43. <text class="overdue-title"></text>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <template #loadMore>
  49. <view></view>
  50. </template>
  51. </common-list>
  52. </template>
  53. <template v-else>
  54. <view class="empty-tips">
  55. <text class="empty-text">暂无物料申请单</text>
  56. </view>
  57. </template>
  58. </view>
  59. <!-- 底部 TabBar -->
  60. <custom-tabbar :current="0" />
  61. </view>
  62. </template>
  63. <script setup lang="uts">
  64. import { ref, onMounted } from 'vue'
  65. import { getUserInfo } from '../../utils/storage'
  66. type QuickFunction = {
  67. id: number
  68. title: string
  69. bgImage: string
  70. icon: string
  71. path: string
  72. }
  73. const applyListData = ref<any[]>([])
  74. const applyLoading = ref<boolean>(false)
  75. // 快捷功能列表
  76. const quickFunctions = ref<QuickFunction[]>([
  77. {
  78. id: 1,
  79. title: '我的签收',
  80. bgImage: '/static/images/workbench/2.png',
  81. icon: '',
  82. path: ''
  83. },
  84. {
  85. id: 2,
  86. title: '我的消息',
  87. bgImage: '/static/images/workbench/3.png',
  88. icon: '',
  89. path: ''
  90. },
  91. {
  92. id: 3,
  93. title: '申请物料',
  94. bgImage: '/static/images/workbench/4.png',
  95. icon: '',
  96. path: ''
  97. }
  98. ])
  99. // 快捷功能点击
  100. const handleQuickClick = (item: QuickFunction): void => {
  101. if (item.path.length > 0) {
  102. uni.navigateTo({
  103. url: item.path,
  104. fail: (err: any) => {
  105. console.log('导航失败', err)
  106. }
  107. })
  108. } else {
  109. uni.showToast({
  110. title: item.title,
  111. icon: 'none'
  112. })
  113. }
  114. }
  115. // 跳转到超时工单列表
  116. const navigateToApply = (): void => {
  117. // 跳转到超时工单页面
  118. uni.navigateTo({
  119. url: '/pages/apply/index'
  120. })
  121. }
  122. // 物料申请点击事件
  123. const handleApplyItemClick = (item: any, index: number): void => {
  124. if (item == null) return
  125. const apply = item as UTSJSONObject
  126. try {
  127. uni.navigateTo({
  128. url: `/pages/apply/index?id=${apply['id']}`
  129. })
  130. } catch (e) {
  131. console.error('处理物料申请事件失败:', e)
  132. }
  133. }
  134. // 用户名
  135. const userName = ref<string>('用户')
  136. // 初始化
  137. onMounted(() => {
  138. const userInfo = getUserInfo()
  139. if (userInfo != null) {
  140. const realName = userInfo['nickName'] as string | null
  141. userName.value = realName ?? '用户'
  142. }
  143. })
  144. </script>
  145. <style lang="scss">
  146. .page-container {
  147. position: relative;
  148. flex: 1;
  149. padding-top: env(safe-area-inset-top);
  150. background-color: #e8f0f9;
  151. padding: 20rpx;
  152. }
  153. .bg-image {
  154. position: absolute;
  155. top: 0;
  156. left: 0;
  157. width: 100%;
  158. height: 100%;
  159. z-index: 0;
  160. }
  161. .bg-color {
  162. position: absolute;
  163. top: 0;
  164. left: 0;
  165. width: 100%;
  166. height: 100%;
  167. z-index: -1;
  168. background: #71a6e4;
  169. }
  170. .page-content {
  171. position: relative;
  172. flex: 1;
  173. margin-bottom: 150rpx;
  174. padding: 20rpx;
  175. z-index: 10;
  176. }
  177. .header {
  178. flex-direction: row;
  179. height: 40px;
  180. &-title {
  181. font-size: 40rpx;
  182. color: #ffffff;
  183. font-weight: bold;
  184. margin-bottom: 15rpx;
  185. }
  186. &-greeting {
  187. font-size: 28rpx;
  188. color: rgba(255, 255, 255, 0.9);
  189. }
  190. }
  191. .section-title {
  192. font-size: 32rpx;
  193. color: #333333;
  194. font-weight: bold;
  195. margin-bottom: 20rpx;
  196. }
  197. .quick-cards {
  198. flex-direction: row;
  199. flex-wrap: wrap;
  200. justify-content: space-between;
  201. .quick-card {
  202. position: relative;
  203. width: 212rpx;
  204. height: 120rpx;
  205. margin-bottom: 20rpx;
  206. overflow: hidden;
  207. border-radius: 16rpx;
  208. &-bg {
  209. position: absolute;
  210. top: 0;
  211. left: 0;
  212. width: 226rpx;
  213. height: 140rpx;
  214. z-index: 0;
  215. }
  216. &-content {
  217. position: relative;
  218. z-index: 1;
  219. padding: 20rpx;
  220. height: 140rpx;
  221. justify-content: flex-start;
  222. }
  223. &-title {
  224. font-size: 28rpx;
  225. color: #333333;
  226. font-weight: bold;
  227. }
  228. .management-badge {
  229. position: absolute;
  230. top: 20rpx;
  231. right: 20rpx;
  232. width: 32rpx;
  233. height: 32rpx;
  234. background-color: #ff3b30;
  235. border-radius: 16rpx;
  236. justify-content: center;
  237. align-items: center;
  238. .badge-text {
  239. font-size: 20rpx;
  240. color: #ffffff;
  241. line-height: 20rpx;
  242. }
  243. }
  244. }
  245. }
  246. .section-title-container {
  247. // margin-top: 20rpx;
  248. padding: 20rpx 30rpx;
  249. .section-header {
  250. flex-direction: row;
  251. justify-content: space-between;
  252. align-items: center;
  253. .section-title {
  254. font-size: 32rpx;
  255. color: #333333;
  256. font-weight: bold;
  257. // margin-bottom: 20rpx;
  258. }
  259. .view-all {
  260. font-size: 28rpx;
  261. color: #165dff;
  262. }
  263. }
  264. }
  265. .list-item {
  266. margin: 0 30rpx 24rpx 30rpx;
  267. background-color: #ffffff;
  268. border-radius: 16rpx;
  269. .item-container {
  270. padding: 30rpx;
  271. }
  272. .item-header {
  273. flex-direction: row;
  274. align-items: center;
  275. margin-bottom: 16rpx;
  276. .location-icon {
  277. width: 32rpx;
  278. height: 32rpx;
  279. margin-right: 8rpx;
  280. }
  281. .item-title {
  282. flex: 1;
  283. font-size: 32rpx;
  284. color: #333333;
  285. font-weight: bold;
  286. }
  287. .detail-link {
  288. font-size: 28rpx;
  289. color: #999999;
  290. }
  291. }
  292. .item-address {
  293. font-size: 26rpx;
  294. color: #999999;
  295. margin-bottom: 20rpx;
  296. line-height: 40rpx;
  297. }
  298. .item-info {
  299. padding: 20rpx;
  300. background-color: #f8f9fa;
  301. border-radius: 8rpx;
  302. .info-row {
  303. flex-direction: row;
  304. margin-bottom: 16rpx;
  305. &:last-child {
  306. margin-bottom: 0;
  307. }
  308. .info-item {
  309. flex: 1;
  310. flex-direction: row;
  311. align-items: center;
  312. .info-label {
  313. font-size: 26rpx;
  314. color: #666666;
  315. margin-right: 8rpx;
  316. white-space: nowrap;
  317. }
  318. .info-value {
  319. flex: 1;
  320. font-size: 26rpx;
  321. color: #333333;
  322. }
  323. }
  324. }
  325. }
  326. }
  327. .empty-tips {
  328. padding: 30rpx;
  329. justify-content: center;
  330. align-items: center;
  331. .empty-text {
  332. font-size: 26rpx;
  333. color: #999999;
  334. }
  335. }
  336. </style>