123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- <template>
- <view class="site-wrapper" ref="contentWrapper">
- <!-- 筛选框start -->
- <view style="height:200rpx"></view>
- <view class="ding">
- <view class="cu-bar search bg-gray filter-section" style="padding-top:10rpx">
- <view class="search-form round bg-white" style="position:relative;overflow:auto">
- <input name="siteName" v-model="formMess.siteName" @click="toggleShow" @focus="focusfns"
- @input="handleInput()" placeholder="请输入或选择所属线路"></input>
- </view>
-
- </view>
- <view class="cu-bar search bg-gray filter-section">
- <view class="search-form round bg-white">
- <text class="cuIcon-search"></text>
- <input class="" @focus="InputFocus" v-model="siteName" @blur="InputBlur" :adjust-position="false" type="text"
- placeholder="请输入站点名称" confirm-type="search"></input>
- </view>
- <view class="action">
- <button class="cu-btn bg-blue round" @click="searchData()">查询</button>
- </view>
-
- </view>
-
- </view>
- <view class="siteItems" v-if="isShow2" style="max-height:60vh;overflow:auto;position:absolute;z-index:999; margin: 0 32rpx;
- width: calc(100% - 64rpx);top:100rpx">
- <view class=" site-item" v-if="!siteItemData.length">暂无结果</view>
- <view class="site-item" v-for="(item,index) in siteItemData" @click="changeModel(item,index)" :key="index" style="padding:16rpx 22rpx">
- {{item.route_name}}
- </view>
- </view>
- <!-- 筛选框end -->
- <!-- 站点列表start -->
- <view class="site-items" style="margin-top: 0px">
- <view class="cu-list menu-avatar longPressUl">
- <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in newSiteListData"
- :key="index" :data-target="'move-box-' + index">
- <view class="cu-avatar round lg" style="background-image: url(../../static/site-icon-alarm.png);"></view>
- <view class="content" @tap="goDeviceType(item)" @longpress="showDetail(item)">
- <view class="text-grey site-tit">
- <text style="width:350rpx;" class="inOneLine">{{item.siteName}}</text>
- <text style="font-size:28rpx;text-align:right">
- ( 共{{item.count}}个设备 )
- </text>
- </view>
- <view class="showDetail" v-if="item.isShow" @tap.stop="goSiteDetail(item)">查看详情</view>
- </view>
- <view class="nav-right num">
- <view class="text-grey">
- <text class="icon iconfont margin-right-xs margin-left-lg"></text>
- </view>
- </view>
- </view>
- </view>
- <view v-if="!siteListData.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
- </view>
- <!-- 站点列表end -->
- </view>
- </template>
- <script>
- import json from '../../data/json.js';
- export default {
- data() {
- return {
- siteListRes: 0,
- siteName: '',
- type: '0',
- siteListData: [],
- modalName: null,
- listTouchStart: 0,
- listTouchDirection: null,
- CustomBar: this.CustomBar,
-
- isShow2: false,
- formMess: {
- "siteName": "",
- },
- siteItemDataOrigin: [],
- siteItemData: [],
- };
- },
- onPullDownRefresh() {
- console.log('refresh');
- setTimeout(function() {
- uni.stopPullDownRefresh();
- }, 1000);
- },
- computed: {
- newSiteListData() {
- return this.siteListData.map(item => {
- this.$set(item, "isShow", false)
- return item
- })
- }
- },
- mounted() {
- document.addEventListener('click', (e) => {
- if (e.target.className != 'showDetail') {
- this.siteListData.forEach(item => {
- item.isShow = false
- })
- }
- })
- },
- onLoad() {
- this.getSiteList();
- this.getRoutrBox()
- },
- methods: {
-
-
-
- //线路名称下拉数据请求
- async getRoutrBox(params = {}) {
- const res = await this.$myRequest({
- url: 'Archives/getRoutrBox',
- showLoading: true,
- data: params
- })
- // this.routeListData = res.data.data;
- // console.log(this.routeListData)
-
- this.siteItemData = res.data.data;
- this.siteItemDataOrigin = res.data.data;
- this.siteItemData = this.siteItemDataOrigin;
- },
- //选中下拉选项,隐藏框,赋值
- changeModel: function(item, index) {
- this.isShow2 = false;
- this.formMess.siteName = item.route_name;
- },
-
- // 输入框点击 显示隐藏下拉框
- toggleShow: function() {
- this.isShow2 = !this.isShow2;
- },
- //点击下拉筛选
- handleInput() {
- //将元素根据搜索内容过滤出来 这里改变了siteItemData
- this.siteItemData = this.siteItemDataOrigin;
- this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) > -1);
- },
- focusfns: function(e) {
- //将元素根据搜索内容过滤出来 这里改变了siteItemData
- this.siteItemData = this.siteItemDataOrigin;
- this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) >
- -1);
- },
-
-
-
-
- searchData() {
- this.getSiteList({
- "siteName": this.siteName,
- "route_name": this.formMess.siteName
- })
- },
- async getSiteList(ming) {
- const res = await this.$myRequest({
- url: 'OperationMonitoring/getSiteList',
- showLoading: true,
- data: ming
- })
- this.siteListRes = 1;
- console.log(res.data.data)
- this.siteListData = res.data.data
- },
- // 隐藏显示
- showDetail(e) {
- // 存储点击那一项的状态
- const nowStatu = e.isShow;
- // 将每一项列表的isShow设置为false,让所有的列表都隐藏
- this.siteListData.forEach(item => {
- item.isShow = false
- })
- // 用于再次点击该项的取反
- e.isShow = !nowStatu
- },
- InputFocus(e) {
- this.InputBottom = e.detail.height
- },
- InputBlur(e) {
- this.InputBottom = 0
- },
- goDeviceType(item) {
- if (item.count) {
- uni.navigateTo({
- url: '/pages/deviceType/deviceType?companyCode=' + item.companyCode,
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- }
- },
- goSiteDetail(item) {
- uni.navigateTo({
- url: '/pages/siteDetail/siteDetail?id=' + item.id + '',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- }
- }
- </script>
- <style>
- .showDetail {
- position: absolute;
- background: #fff;
- box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
- padding: 0rpx 32rpx;
- border-radius: 10rpx;
- top: 42rpx;
- right: 45%;
- z-index: 3000000;
- font-size: 28rpx;
- }
- * {
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- }
- input {
- -webkit-touch-callout:initial !important;
- -webkit-user-select:initial !important;
- -khtml-user-select:initial !important;
- -moz-user-select:initial !important;
- -ms-user-select:initial !important;
- user-select: initial !important;
- }
-
- </style>
|