equipmentList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <!-- 设备状态 1-已离线 2-运行中 4-保养中 -->
  2. <template>
  3. <view class="wrap">
  4. <view>
  5. <u-navbar
  6. :title="title"
  7. title-color="#fff"
  8. :custom-back="customBack"
  9. :border-bottom="false"
  10. back-icon-color="#CCE8FF"
  11. :background="{background: '#4D68DC' }"></u-navbar>
  12. </view>
  13. <!-- <u-button class="u-reset-button" @click="selectShow = true">{{deviceType}}</u-button> -->
  14. <u-cell-item icon="setting-fill" :title="deviceTypeName" :arrow="true" @click="selectShow = true" arrow-direction="right"></u-cell-item>
  15. <u-select v-model="selectShow" :list="deviceTypeListData" @confirm="selectConfirm"></u-select>
  16. <u-cell-item class="road-select-cell" icon="map-fill" bg-color="#fff" :border-bottom="false" :title="roadName" :arrow="true" @click="roadSelectShow = true" arrow-direction="right"></u-cell-item>
  17. <u-select v-model="roadSelectShow" :list="roadListData" value-name="roadNo" label-name="roadName" @confirm="roadSelectConfirm"></u-select>
  18. <u-gap height="12" bg-color="#e7e7e7"></u-gap>
  19. <mescroll-uni ref="mescrollRef" @init="mescrollInit" top="300" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
  20. <view class="g-device-item u-flex u-row-between u-m-b-24" v-for="item in dataList" :key="item.id">
  21. <view class="u-font-30" style="color: #414141;">
  22. <view class="u-m-b-10 ">
  23. <text>{{item.deviceType|deviceType}}</text>
  24. <text class="u-p-l-40" style="font-weight: bold;">{{item.roadName}}-{{item.spaceName}}</text>
  25. </view>
  26. <view class="u-m-b-10" v-if="item.deviceType==3">
  27. <text>{{item.entranceName}}</text>
  28. <text class="u-m-l-20">{{item.roadwayName}}</text>
  29. </view>
  30. <view class="u-font-26">设备编号:{{item.deviceNo}}</view>
  31. </view>
  32. <view class="">
  33. <view class="" :class="{'c-offline':item.deviceStatus=='0','c-online':item.deviceStatus=='1','c-repair':item.deviceStatus=='2'}">
  34. {{item.deviceStatus|deviceStatus}}
  35. </view>
  36. </view>
  37. </view>
  38. </mescroll-uni>
  39. </view>
  40. </template>
  41. <script>
  42. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  43. export default{
  44. mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
  45. data(){
  46. return{
  47. selectShow:false,
  48. roadSelectShow:false,
  49. title:"设备列表",
  50. deviceTypeName:'全部类型',
  51. deviceType:null,
  52. roadName:'全部路段/停车场',
  53. roadNo:'',
  54. deviceRunStatus:'',
  55. upOption:{
  56. // page: {
  57. // size: 10 // 每页数据的数量
  58. // },
  59. // auto:false,
  60. // use:false,
  61. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  62. empty:{
  63. tip: '~ 暂无数据 ~', // 提示
  64. // btnText: '去看看'
  65. }
  66. },
  67. dataList: [], //列表数据
  68. deviceTypeId:'',//设备类型id
  69. deviceTypeListData:this.config.deviceTypeList,
  70. roadListData:[],
  71. dictData:[],
  72. }
  73. },
  74. onLoad(page){
  75. // console.log('page',page);
  76. this.deviceRunStatus = page.param;
  77. if(this.deviceRunStatus==''){
  78. this.title = "全部设备"
  79. }else if(this.deviceRunStatus=='0'){
  80. this.title = "离线设备"
  81. } else if(this.deviceRunStatus=='1'){
  82. this.title = "运行中"
  83. }else if(this.deviceRunStatus=='2'){
  84. this.title = "未检测"
  85. }
  86. this.getRoadList();
  87. // this.deviceTypeList();
  88. // this.handlegetDictData('device_run_status');
  89. },
  90. onShow(){
  91. },
  92. computed:{
  93. filterDeviceStatus(){
  94. return function(value){
  95. let v = '';
  96. for (let i = 0; i < this.dictData.length; i++){
  97. // console.log('value',value);
  98. // console.log('value',this.dictData[i]);
  99. let item = this.dictData[i];
  100. if (value == item.status) {
  101. v = item.dictLabel;
  102. break;
  103. }
  104. }
  105. return v
  106. }
  107. }
  108. },
  109. methods:{
  110. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  111. upCallback(page) {
  112. // console.log('page',page)
  113. //联网加载数据
  114. // let keyword = this.tabs[this.tabIndex]?.text;
  115. let params ={
  116. roadNo:this.roadNo,
  117. deviceType:this.deviceType,
  118. deviceStatus:this.deviceRunStatus,
  119. pageNum:page.num,
  120. pageSize:page.size
  121. }
  122. this.$u.api.getDeviceList(params).then(curPageData=>{
  123. console.log('curPageData',curPageData)
  124. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  125. this.mescroll.endSuccess(curPageData.total);
  126. this.mescroll.endBySize(curPageData.data.rows.length, curPageData.total);
  127. //设置列表数据
  128. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  129. this.dataList=this.dataList.concat(curPageData.data.rows); //追加新数据
  130. }).catch((err)=>{
  131. uni.showToast({
  132. title:'链接失败'
  133. });
  134. console.log('err',err)
  135. //联网失败, 结束加载
  136. this.mescroll.endErr();
  137. })
  138. },
  139. //点击空布局按钮的回调
  140. emptyClick(){
  141. },
  142. // 切换菜单
  143. tabChange(index) {
  144. this.dataList = [];// 先置空列表,显示加载进度
  145. this.tabIndex = index;
  146. this.mescroll.resetUpScroll(); // 再刷新列表数据
  147. },
  148. customBack(){
  149. uni.reLaunch({
  150. url: '/pages/index/index'
  151. });
  152. },
  153. handlegetDictData(device_status){
  154. let that = this;
  155. this.$u.api.getDictData(device_status).then(res=>{
  156. if(res.code==200){
  157. res.data.data.map(function(currentValue,index,arr){
  158. that.dictData.push({status:currentValue.dictValue,dictLabel:currentValue.dictLabel})
  159. // console.log('currentValue',currentValue);
  160. })
  161. // this.dictData = res.data.data;
  162. console.log('getDeviceStatis',this.dictData);
  163. }else{
  164. uni.showToast({
  165. icon:'none',
  166. title:res.msg
  167. })
  168. }
  169. console.log('res',res);
  170. }).catch(err=>{
  171. console.log('err',err);
  172. })
  173. },
  174. // deviceTypeList(){
  175. // this.$u.api.getDeviceTypeList().then(res=>{
  176. // if(res.code==200){
  177. // this.deviceTypeListData = res.data;
  178. // // console.log('getDeviceStatis',res);
  179. // }else{
  180. // uni.showToast({
  181. // icon:'none',
  182. // title:res.msg
  183. // })
  184. // }
  185. // console.log('res',res);
  186. // }).catch(err=>{
  187. // console.log('err',err);
  188. // })
  189. // },
  190. selectConfirm(e){
  191. console.log('selectConfirm',e);
  192. this.deviceTypeName = e[0].label;
  193. this.deviceType = e[0].value;
  194. this.mescroll.resetUpScroll();
  195. },
  196. getRoadList(){
  197. let that = this;
  198. that.$u.api.getRoadList()
  199. .then(res=>{
  200. this.roadListData = res.data;
  201. console.log('this.getRoadList',res)
  202. }).catch(err=>{
  203. this.$refs.uToast.show({
  204. title: err.msg,
  205. type: 'error',
  206. });
  207. });
  208. },
  209. roadSelectConfirm(e){
  210. // console.log('roadSelectConfirm',e[0]);
  211. this.roadName = e[0].label;
  212. this.roadNo = e[0].value;
  213. console.log('this.roadNo',this.roadNo);
  214. this.mescroll.resetUpScroll();
  215. },
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. // @import './equipmentList.scss'
  221. </style>