index.vue 6.4 KB

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