<template>
  <view class="work-container">
    <view class="header">
      <u-search placeholder="请输入设备名称" :clearabled="true" @clear="searchDevice" @custom="searchDevice" v-model="search.deviceName" @search="searchDevice"></u-search>
    </view>
    <view style="margin-top: 10px">
      <uni-card v-for="item in resetList" :title="item.deviceName" :extra="item.createTime">

        <view style="position: relative">
          <view>设备编号:{{item.deviceNo}}</view>
          <view>操作人:{{item.userName}}</view>
          <view>原机构:{{item.oriDeptName}}</view>
<!--          <view v-if="item.status != 3" style="width: 50px;position: absolute;right:-10px;bottom:0px"><u-button @click="handle(item)" type="error" :plain="true" size="mini" text="处理"></u-button>-->
<!--          </view>-->

        </view>
      </uni-card>
      <uni-load-more @clickLoadMore="getMore" :contentText="contenText" :status="loadStatus"></uni-load-more>

      <u-modal :show="showErrDlg" title="处理结果" @confirm="close" >
        <view class="slot-content">

          <u--textarea style="width:500rpx" autoheight v-model="chooseItem.result" disabled="" ></u--textarea>

        </view>
      </u-modal>
    </view>
  </view>
</template>

<script>
import {resetList} from '@/api/device/device';
export default {
  data() {
    return {
      show:true,
      resetList:[],
      search:{
        deviceName:""
      },
      pageNum:1,
      pageSize:10,
      chooseItem: {},
      contenText:{contentdown: "点击加载更多",contentrefresh: "正在加载...",contentnomore: "没有更多数据了"},
      loadStatus:"more",
      showErrDlg:false,
    }
  },
  onLoad(){
    this.getresetList();
  },
  methods: {
    searchDevice(){
      this.pageNum =1;
      this.resetList=[];
      this.getresetList();
    },
    getMore(){
      this.pageNum ++;
      this.getresetList();
    },
    open(item) {
      this.chooseItem = item;
      this.showErrDlg = true;
    },
    close() {
      this.chooseItem = {};
      this.showErrDlg = false;
    },
    confirm(text){

      if(!text){
        uni.showToast({
          icon:"error",
          title:"请输入内容"
        })
        return;
      }
      let item = this.chooseItem;
      item.remark = text;
      this.close();
      handleAlert(item).then(res=>{
        if(res.code == 200){
          item.status = 3;
        }
      })
    },
    searchDept(){
      this.getDeptList();
    },
    watchResult(item){
      this.open(item);
    },
    handle(item){
      this.open(item);
    },
    getresetList(){
      this.loadStatus = "loading"
      resetList(this.pageNum,this.pageSize,this.search.deviceName).then(res=>{
        if(res.total == this.resetList.length){
          uni.showToast({
            icon:"none",
            title:"没有更多了"
          })
          this.loadStatus = "noMore"
          return;
        }
        this.loadStatus = "more"
        this.resetList = this.resetList.concat(res.rows);
      });
    }
  }
}
</script>

<style lang="scss">
/* #ifndef APP-NVUE */
.u-collapse-content{
  display: flex;
  flex-direction: column;
}
page {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background-color: #fff;
  min-height: 100%;
  height: auto;
}

view {
  font-size: 14px;
  line-height: inherit;
}

/* #endif */

.text {
  text-align: center;
  font-size: 26rpx;
  margin-top: 10rpx;
}

.grid-item-box {
  flex: 1;
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 0;
}

.uni-margin-wrap {
  width: 690rpx;
  width: 100%;
;
}

.swiper {
  height: 300rpx;
}

.swiper-box {
  height: 150px;
}

.swiper-item {
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  height: 300rpx;
  line-height: 300rpx;
}

@media screen and (min-width: 500px) {
  .uni-swiper-dot-box {
    width: 400px;
    /* #ifndef APP-NVUE */
    margin: 0 auto;
    /* #endif */
    margin-top: 8px;
  }

  .image {
    width: 100%;
  }
}
</style>
