123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <template>
- <view class="site-wrapper">
- <!-- 筛选框start -->
- <view style="height:90rpx"></view>
- <view class="ding">
- <view class="cu-bar search bg-gray filter-section">
- <view class="search-form round bg-white">
- <text class="cuIcon-search"></text>
- <input class="" type="text" placeholder="请输入设备名称"
- confirm-type="search" v-model="deviceName"></input>
- </view>
- <view class="action">
- <button class="cu-btn bg-blue round" @click="searchSiteList">查询</button>
- </view>
- </view>
- </view>
- <!-- 筛选框end -->
- <!-- 站点列表start -->
- <view class="site-items" style="margin-top:0;height: calc(100vh - 286rpx);">
- <view class="cu-list menu-avatar">
- <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in siteList" :key="index"
- @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
- <view class="cu-avatar round lg" style="background-image: url(/static/device-icon.png);"></view>
- <view class="content">
- <view class="text-grey site-tit">{{item.deviceName}}</view>
- </view>
- <view class="nav-right num">
-
- </view>
- <view class="move">
- <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
- <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
- </view>
- </view>
- </view>
- <view v-if="!siteList.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
- </view>
- <!-- 站点列表end -->
- <!-- 新增按钮start -->
- <view class="plus">
- <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage()"></image>
- </view>
- <!-- 新增按钮end -->
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- modalName: null,
- listTouchStart: 0,
- listTouchDirection: null,
- deviceName: '',
- siteList: [],
- siteListRes: 0,
- siteId:''
- };
- },
- onLoad: function(option) {
- this.siteId=option.siteId;
- //设备列表渲染
- this.getDeviceList({"siteId":option.siteId})
-
- },
-
- methods: {
- //筛选
- searchSiteList() {
- this.getDeviceList({
- "deviceName": this.deviceName,"siteId":this.siteId
- })
- },
-
- //编辑
- editItem(item) {
- uni.navigateTo({
- url: '/pages/deviceAdd/deviceAdd?id=' + item.siteId + '&deviceCode=' + item.deviceCode + '',
- });
- },
- //删除
- deleteItem(item) {
- uni.showModal({
- title: '确认删除吗?',
- content: '',
- success: function(result) {
- if (result.confirm) {
- this.setDelSite({
- "id": item.id
- })
- } else if (result.cancel) {
- // console.log('用户点击取消');
- }
- }.bind(this)
- });
- },
-
- async setDelSite(ming = {}) {
- const res = await this.$myRequest({
- url: 'DeviceManagement/setDelSite',
- data: ming
- })
- if (!res.data.flag) {
- uni.showToast({
- title: "删除失败",
- icon: "none"
- });
- }else{
- uni.showToast({
- title: "删除成功",
- });
- setTimeout(() => {
- this.getDeviceList({"siteId":this.siteId})
- }, 1000);
- }
-
- },
- async getDeviceList(ming = {}) {
- const res = await this.$myRequest({
- url: 'DeviceManagement/getDeviceList',
- showLoading: true,
- data: ming
- })
- this.siteListRes = 1;
- this.siteList = res.data.data
- console.log(res.data.data);
- },
-
- // 新增跳转
- goAddPage() {
- uni.navigateTo({
- url: '/pages/deviceAdd/deviceAdd?id=' + this.siteId + '',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
-
-
- // ListTouch触摸开始
- ListTouchStart(e) {
- this.listTouchStart = e.touches[0].pageX
- },
- // ListTouch计算方向
- ListTouchMove(e) {
- this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
- },
- // ListTouch计算滚动
- ListTouchEnd(e) {
- if (this.listTouchDirection == 'left') {
- this.modalName = e.currentTarget.dataset.target
- } else {
- this.modalName = null
- }
- this.listTouchDirection = null
- }
- }
- }
- </script>
- <style>
- </style>
|