Plan.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view >
  3. <uni-nav-bar fixed="true" height="80px" dark color="#ffffff" backgroundColor="#1989fa" shadow left-icon="home"
  4. title="巡检计划" @clickLeft="GoBackHome()"/>
  5. <div style="padding:0 20px;">
  6. <div @click="open" style="height:40px;line-height:40px;border-bottom: 1px solid #e8e8e8;margin-bottom:20px">
  7. <label style="float:left">巡检日期</label>
  8. <input style="float:left;position:relative;top:9px;margin-left:15px;line-height:60px;" v-model="seledDate" placeholder="请选择日期">
  9. </div>
  10. <uni-calendar
  11. ref="calendar"
  12. :insert="false"
  13. :startDate="startDate"
  14. @confirm="confirm"
  15. />
  16. <button @click="getPlanList" style="width:100%;height:40px;line-height:40px;border-radius:4px;background-color:#1989fa;color:#fff;border:#1989fa;margin-bottom:20px">查询</button>
  17. </div>
  18. <uni-list style="position:static;">
  19. <view v-for="item in listdata" class="view_tupian_wenzi" bindtap="click" >
  20. <view class="view_wenzi2">
  21. <view style="font-size:18px;">
  22. <uni-icons type="map-pin-ellipse" size="20" style="padding-right:8px;"></uni-icons>
  23. {{item.planname}}
  24. </view>
  25. <view class="text_small">
  26. <uni-icons type="calendar" size="18" style="padding-right:8px;"></uni-icons>
  27. {{item.plantime}}
  28. </view>
  29. <text class="text_small">巡更人员: {{item.usernames}}</text>
  30. <text class="text_small">巡检进度: {{item.planprogress}}</text>
  31. </view>
  32. <button v-if="'开始巡逻'==item.planstatus" @click="GoRouteViews(item.plancode,item.plandate,item.plantime,item.planstatus)"
  33. class="btn" style="background: #1989fa;">{{item.planstatus}}</button>
  34. <button v-else class="btn" style="background:#969799;" >{{item.planstatus}}</button>
  35. </view>
  36. </uni-list>
  37. <uni-load-more :status="statusLoadMore" />
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. startDate:'',
  45. seledDate:'',
  46. pageNumber: 1, // 请求第几页
  47. pageSize: 10, // 每页请求的数量
  48. statusLoadMore:"nomore",//more,loading,nomore
  49. listdata: []
  50. };
  51. },
  52. created(){
  53. this.startDate = this.getcurrentDate();
  54. this.seledDate=this.getcurrentDate();
  55. this.getPlanList()
  56. },
  57. methods: {
  58. open(){
  59. this.$refs.calendar.open();
  60. },
  61. confirm(e) {
  62. this.seledDate = e.fulldate;
  63. },
  64. getPlanList() {
  65. if(this.$store.state.data.staffCode == undefined){
  66. uni.showToast({
  67. icon: 'none',
  68. title: "token过期请重新登录~",
  69. duration:1500
  70. });
  71. setTimeout(function() {
  72. uni.navigateTo({
  73. url:'../index/login'
  74. })
  75. }, 1500);
  76. return
  77. }
  78. var data ={
  79. staffcode: this.$store.state.data.staffCode,
  80. datestr: this.seledDate,
  81. pageNumber: this.pageNumber,
  82. pageSize: this.pageSize
  83. }
  84. this.$api.GetEmployeePlanList(data).then(res=>{
  85. if (res.isSuccess && res.data !=undefined && res.data.length>0) {
  86. this.listdata = res.data // 将接口返回赋值data定义的数组
  87. // 加载状态结束 状态更新为false
  88. this.statusLoadMore = "more"
  89. }else{
  90. this.listdata =[]
  91. this.statusLoadMore = "nomore"
  92. uni.showToast({
  93. icon: 'none',
  94. title: "没有查询到巡更记录~"
  95. });
  96. }
  97. })
  98. },
  99. GoRouteViews (plancode,plandate,plantime) {
  100. uni.navigateTo({
  101. url:'/pages/inspection/Route?plancode='+encodeURIComponent(plancode)+'&plandate='+encodeURIComponent(plandate)+'&plantime='+encodeURIComponent(plantime)
  102. });
  103. },
  104. /**
  105. * 下拉刷新回调函数
  106. */
  107. onPullDownRefresh() {
  108. console.log("下拉刷新")
  109. var that = this
  110. setTimeout(function() {
  111. //隐藏转圈动画
  112. uni.stopPullDownRefresh()
  113. uni.showToast({
  114. icon: 'none',
  115. title: "加载成功~"
  116. });
  117. this.statusLoadMore="nomore"
  118. }, 1000)
  119. },
  120. // /**
  121. // * 上拉加载更多
  122. // */
  123. // onReachBottom() {
  124. // console.log("上拉加载更多")
  125. // this.statusLoadMore = "loading"
  126. // var that = this
  127. // setTimeout(function() {
  128. // // 显示没有更多数据了
  129. // that.statusLoadMore = "nomore"
  130. // }, 2000)
  131. // },
  132. GoBackHome(){
  133. uni.navigateTo({
  134. url:"/pages/index/home"
  135. })
  136. },
  137. getcurrentDate(){
  138. let year = new Date().getFullYear();
  139. let month = new Date().getMonth() +1;
  140. let day = new Date().getDate();
  141. return year + '-' + month + '-' + day;
  142. }
  143. }
  144. };
  145. </script>
  146. <style lang="scss">
  147. .uni-list{border:none;background-color: #fff;padding-bottom: 20px;}
  148. .view_tupian_wenzi {
  149. height: 200rpx;
  150. display: flex;
  151. flex-direction: row;
  152. align-items: center;
  153. /* 圆角 */
  154. border-radius: 5rpx;
  155. border-bottom: 0.5rpx solid #e8e8e8;
  156. background-color: #ffffff;
  157. margin: 10rpx;
  158. /* padding使得文字和图片不至于贴着边框 */
  159. padding: 40rpx 10rpx;
  160. }
  161. /* 包裹两行文字 */
  162. .view_wenzi2 {
  163. width: 100%;
  164. margin-left: 25rpx;
  165. display: flex;
  166. flex-direction: column;
  167. }
  168. /* 小字 */
  169. .text_small {
  170. font-size: 30rpx;
  171. word-break: break-all;
  172. color: #7a7878;
  173. margin-top: 10rpx
  174. }
  175. .btn{
  176. background: #1989fa;
  177. height:72rpx;
  178. border-radius:10rpx;
  179. width:240rpx;
  180. font-size:30rpx;
  181. border:0;
  182. color:#fff
  183. }
  184. </style>