index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="page-index">
  3. <view class="status_bar"></view>
  4. <div class="title">
  5. <text class="tab" :class="type==='user'?'active':''" @click="changeTab('user')">我的</text>
  6. <text class="tab" :class="type==='group'?'active':''" @click="changeTab('group')">部门</text>
  7. </div>
  8. <div class="statistics">
  9. <div class="head">任务统计</div>
  10. <div class="container">
  11. <div class="item" @click="changeStuas(0,'待巡检')">
  12. <image class="icon" src="@/static/index/wait.png" alt=""></image>
  13. <text>待巡检{{statistics.wait}}个</text>
  14. </div>
  15. <div class="item" @click="changeStuas(2,'已逾期')">
  16. <image class="icon" src="@/static/index/expire.png" alt=""></image>
  17. <text>已逾期{{statistics.expire}}个</text>
  18. </div>
  19. <div class="item" @click="changeStuas(1,'已完成')">
  20. <image class="icon" src="@/static/index/complete.png" alt=""></image>
  21. <text>已完成{{statistics.complete}}个</text>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="task-list">
  26. <div class="head">{{title}}任务</div>
  27. <template v-if="items.length>0">
  28. <div class="item" v-for="(item,index) in items" :key="item.taskId" @click="linkTo(item)">
  29. <div class="task-title">{{item.taskTitle}}</div>
  30. <div class="time">{{item.expectedStartDate}}-{{item.expectedEndDate}}</div>
  31. </div>
  32. </template>
  33. <template v-else>
  34. <view class="empty">
  35. <image class="icon-empty" src="/static/icon/empty.png" mode="widthFix"></image>
  36. <p>暂无数据</p>
  37. </view>
  38. </template>
  39. </div>
  40. </view>
  41. </template>
  42. <script>
  43. import {getCheckTaskByList,goaftaskstatis} from '@/api/task.js'
  44. export default {
  45. data() {
  46. return {
  47. statusBarHeight:0,
  48. type:'user',
  49. title:"待巡检",
  50. statistics: {
  51. wait:0,
  52. expire:0,
  53. complete:0
  54. },
  55. items:[],
  56. conditions: {
  57. status: 0,
  58. accountId:undefined
  59. },
  60. accountId:undefined,
  61. groupId:undefined
  62. }
  63. },
  64. onLoad(){
  65. this.initStatusBarHeight()
  66. },
  67. onPullDownRefresh (){
  68. this.getData()
  69. },
  70. onShow() {
  71. const accountInfo=uni.getStorageSync('accountInfo');
  72. const groupId=accountInfo.groupId
  73. const accountId=accountInfo.userId
  74. this.accountId=accountId
  75. this.groupId=groupId
  76. this.getData()
  77. this.goaftaskstatis()
  78. },
  79. methods: {
  80. initStatusBarHeight(){
  81. this.statusBarHeight=uni.getSystemInfoSync().statusBarHeight
  82. },
  83. getData(){
  84. let conditions={}
  85. if(this.type==='user'){
  86. conditions.handleAccountId=this.accountId
  87. }else{
  88. conditions.handleGroupId=this.groupId
  89. }
  90. getCheckTaskByList({
  91. status:this.conditions.status,
  92. ...conditions,
  93. }).then((res)=>{
  94. this.items=res.data
  95. })
  96. },
  97. goaftaskstatis(){
  98. let conditions={}
  99. if(this.type==='user'){
  100. conditions.handleAccountId=this.accountId
  101. }else{
  102. conditions.handleGroupId=this.groupId
  103. }
  104. goaftaskstatis(conditions).then((res)=>{
  105. this.statistics={
  106. wait:res.data.goafTaskWaitingNum,
  107. expire:res.data.goafTaskExceedNum,
  108. complete:res.data.goafTaskCompletedNum
  109. }
  110. })
  111. },
  112. changeTab(type){
  113. this.type=type
  114. this.getData()
  115. this.goaftaskstatis()
  116. },
  117. linkTo(item){
  118. if(this.type==='user'){
  119. uni.setStorageSync('task-item',item)
  120. uni.navigateTo({
  121. url:'/pages/task/task'
  122. })
  123. }
  124. },
  125. changeStuas(status,name){
  126. this.conditions.status=status
  127. this.title=name
  128. this.getData()
  129. },
  130. onScanCode(){
  131. uni.scanCode({
  132. success: function (res) {
  133. uni.setStorageSync('scanCode-info',res.result)
  134. uni.navigateTo({
  135. url:'/pages/task/taskList/taskList'
  136. })
  137. }
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .page-index{
  145. background: linear-gradient(180deg, #4D73FF 0%, rgba(77, 115, 255, 0) 100%);
  146. padding: 0 30upx;
  147. .title{
  148. display: flex;
  149. align-items: center;
  150. .tab{
  151. font-size: 34upx;
  152. line-height: 50upx;
  153. margin-right: 32upx;
  154. color: rgba(255, 255, 255, 0.6);
  155. &.active{
  156. color: #fff;
  157. }
  158. }
  159. .icon-xiangji{
  160. font-size: 44rpx;
  161. line-height: 1;
  162. color: #fff;
  163. padding: 0 20rpx;
  164. }
  165. }
  166. .statistics{
  167. &{
  168. border-radius: 24upx;
  169. background-color: #fff;
  170. padding:36upx 0 44upx 24upx;
  171. margin-top: 48upx;
  172. }
  173. .head{
  174. font-weight: 900;
  175. font-size: 34upx;
  176. line-height: 50upx;
  177. color: #151515;
  178. }
  179. .container{
  180. display: flex;
  181. justify-content: center;
  182. align-items: center;
  183. .item{
  184. width: 33.33%;
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. flex-direction: column;
  189. .icon{
  190. display: block;
  191. width:88upx;
  192. height: 88upx;
  193. }
  194. text{
  195. font-size: 28upx;
  196. line-height: 42upx;
  197. color: #151515;
  198. padding-top: 18upx;
  199. }
  200. }
  201. }
  202. }
  203. .task-list{
  204. border-radius: 24upx;
  205. background-color: #fff;
  206. margin-top: 24upx;
  207. padding: 36upx 24upx;
  208. .head{
  209. font-weight: 900;
  210. font-size: 34upx;
  211. line-height: 50upx;
  212. color: #151515;
  213. }
  214. .item{
  215. padding: 30upx 40upx 38upx 40upx;
  216. .task-title{
  217. color: #212121;
  218. font-size: 32upx;
  219. padding-bottom: 24upx;
  220. }
  221. .time{
  222. background-image: url(/static/index/time.png);
  223. background-repeat: no-repeat;
  224. background-position: left center;
  225. background-size: 24upx 24upx;
  226. padding-left: 36upx;
  227. color: #999;
  228. font-size: 24upx;
  229. }
  230. }
  231. }
  232. }
  233. .container {
  234. padding: 20px;
  235. font-size: 14px;
  236. line-height: 24px;
  237. }
  238. .empty{
  239. text-align: center;
  240. font-size: 28rpx;
  241. margin-top: 10%;
  242. color: #666;
  243. .icon-empty{
  244. display: block;
  245. width: 100px;
  246. margin: 0 auto;
  247. }
  248. }
  249. </style>