index.uvue 8.5 KB

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