<template>
  <view class="work-container">
    <view class="header">
      <u-search placeholder="请输入客户名称" :clearabled="true" @clear="searchDept" @custom="searchDept" v-model="search.deptName" @search="searchDept"></u-search>
    </view>
    <view style="margin-top: 10px">
        <uni-card v-if="item.parentId !==0" v-for="item in deptList" :title="item.deptName" :extra="item.createTime">

          <view style="position: relative">
            <view>联系人:{{item.leader}}</view>
            <view>联系电话:{{item.phone}}</view>
            <view style="width: 50px;position: absolute;right:-10px;bottom:0px"><u-button @click="toUser(item)" type="primary" :plain="true" size="mini" text="查看人员"></u-button>
            </view>

            <view style="width: 50px;position: absolute;right:100rpx;bottom:0rpx"><u-button type="success" @click="toDeviceList(item)" :plain="true" size="mini" text="查看设备"></u-button>
            </view>

          </view>

        </uni-card>
    </view>
  </view>
</template>

<script>
import authObj from '@/plugins/auth.js';
import {getDeptList,getUserListByDept} from '@/api/user/user';
import UText from "../../uni_modules/uview-ui/components/u-text/u-text";
export default {
  components: {UText},
  data() {
      return {
        deptList:[],
        search:{
          deptName:""
        }
      }
    },
  onLoad(){
    this.getDeptList();
  },
    methods: {
      searchDept(){
        this.getDeptList();
      },
      toUser(item){
        uni.navigateTo({
          url: '/pages/user/list?deptId='+item.deptId
        });
      },
      toDeviceList(item){
        uni.navigateTo({
          url: '/pages/device/index?deptId='+item.deptId
        });
      },
      getDeptList(){
        getDeptList(this.search.deptName).then(res=>{
          this.deptList = res.data;
        });
      }
    }
  }
</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>
