<template>
  <div class="ServiceManage">
      <div class="head-title">
        服务人员列表
        <el-button @click="CommonJump('ServiceManageEdit')" style="float:right;margin-top: -5px;" size="small" type="primary">
          添加服务人员
        </el-button>
      </div>
      <div class="content">
        <div>
          <div class="searchInput">
            <el-input style="display:inline-block;width:225px;height:30px" placeholder="服务人员姓名"
              v-model="msg.Name" size="small" clearable @keyup.enter.native="msg.pageIndex=1,getList()">
            </el-input>
            <span class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"
              @click="msg.pageIndex=1,getList()"> </span>
          </div>
          <div class="searchInput">
            <el-input style="display:inline-block;width:225px;height:30px" placeholder="电话"
              v-model="msg.Telephone" size="small" clearable @keyup.enter.native="msg.pageIndex=1,getList()">
            </el-input>
            <span class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"
              @click="msg.pageIndex=1,getList()"></span>
          </div>
          <div style="display:inline-block;">
            <el-button @click="operateShelves(1)" style="margin-left:10px;" size="mini">启用</el-button>
            <el-button @click="operateShelves(2)" style="margin-left:10px;" size="mini">禁用</el-button>
          </div>
        </div>
        <el-table :data="dataList" v-loading="loading" border style="width: 100%;margin:20px 0"
          @selection-change="tableSelect">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column label="头像" width="100">
            <template slot-scope="scope">
              <img :src="scope.row.ServiceLogo" style="width:35px;height:35px;">
            </template>
          </el-table-column>
          <el-table-column prop="Name" label="名称">
          </el-table-column>
          <el-table-column prop="StoreName" label="店铺名称">
          </el-table-column>
          <el-table-column prop="OrderNum" label="预约次数">
          </el-table-column>
          <el-table-column prop="CreateDateStr" label="创建时间" width="180">
          </el-table-column>
          <el-table-column label="状态" width="120">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.ServiceStatus==1" type="success">启用中</el-tag>
              <el-tag v-if="scope.row.ServiceStatus==2" type="warning">禁用中</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="Telephone" label="电话" width="180">
          </el-table-column>
          <el-table-column prop="Major" label="职务" width="180">
          </el-table-column>
          <el-table-column prop="GenderStr" label="性别" width="180">
          </el-table-column>
          <el-table-column label="操作" width="120">
            <template slot-scope="scope">
              <img @click="goUrl('ServiceManageEdit',scope.row.ID)" src="../../assets/img/userman/edit.png" alt="">
              <el-tooltip class="item" effect="dark" content="查看排班情况" placement="top">
                <img @click="goUrl('scheduling',scope.row.ID)" style="margin-left:10px;width:32px;height:32px;" src="../../assets/img/userman/icon-show.png" alt="">
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination style="text-align:right" background @current-change="handleCurrentChange"
          :page-size="msg.pageSize" layout="prev, pager, next" :total="total">
        </el-pagination>
      </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        loading: false,
        dataList: [],
        msg: {
          pageIndex: 1,
          pageSize: 15,
          Name:'', //服务人员姓名
          ID:0, //编号
          Telephone:'' //电话
        },
        GoodsIds: [], //列表选中的商品编号
        total: 0,
        checkedkeys:[],//默认选中的
      };
    },
    created() {

    },
    methods: {
      //表格选中
      tableSelect(val) {
        this.GoodsIds = val;
      },
      //操作上下架
      operateShelves(type){
        if (this.GoodsIds.length == 0) {
          this.Error("请先勾选要设置的服务人员!");
          return;
        }
        let idList = [];
        this.GoodsIds.forEach(item => {
          idList.push(item.ID)
        })
        let IdsList = idList.join(',');
        let msg = {
          Ids: IdsList,
          ServiceStatus: type
        }
        let str = "";
        if (type == 1) {
          str = "批量启用,是否继续";
        }
        if (type == 2) {
          str = "批量禁用,是否继续";
        }
        let that = this;
        that.Confirm(str, function () {
          that.apipost('/api/Reserve/EnableServicePersonalInfo', msg,
            res => {
              if (res.data.resultCode === 1) {
                that.getList();
                that.Success(res.data.message);
              } else {
                that.Error(res.data.message);
              }
            },
            null
          );
        });
      },
      //操作对应商品类型
      getUseType(val){
        if(val ==1){
          this.category=true;
          this.$nextTick(() => {//在弹出dialog之前执行$nextTick回调函数,确保el-tree已经渲染
            this.$refs.tree.setCheckedKeys(this.checkedkeys);
          });
        }else if(val==2){
          this.checkedkeys=[]
          this.commodity =true
        }
      },
      goUrl(path,ID){
        this.$router.push({
            name: path,
            query: {
              ID:ID,
              blank: "y"
            }
        });
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      getList() {
        this.loading=true;
        this.apipost("/api/Reserve/GetServicePersonalPageList", this.msg, res => {
          this.loading=false;
          if (res.data.resultCode == 1) {
            this.dataList = res.data.data.pageData;
            this.total = res.data.data.count;
          } else {
            this.Error(res.data.message);
          }
        })
      }
    },
    mounted() {
      this.getList();
    }
  };

</script>
<style>
  .ServiceManage .content {
    background: #fff;
    margin-top: 10px;
    padding: 20px;
    box-sizing: border-box;
  }
</style>