<template>
  <div>
    <el-button style="color:#999" type="text" size="mini" @click="onShow(dialogTableVisible = true)">变 更</el-button>
    <el-dialog title="选择团队人员" append-to-body :visible.sync="dialogTableVisible" width="600px">
      <el-form size="small" inline label-position="left" label-width="50px" :model="search">
        <el-form-item label="搜索">
          <el-input v-model="params.content.where.condition" prefix-icon="el-icon-search" placeholder="员工名称" @clear="listData(params.content.pageNumber = 1)" @keyup.native.enter="listData(params.content.pageNumber = 1)" clearable></el-input>
        </el-form-item>
      </el-form>
     <el-table
      ref="multipleTable"
      :data="list"
      size="mini"
      tooltip-effect="dark"
      style="width: 100%"
      :header-cell-style="{background:'#EEEEEE',color:'#333'}"
      border
      stripe>
      <el-table-column
        prop="name"
        label="昵称"
        width="120">
      </el-table-column>
      <el-table-column
        prop="depname"
        label="部门">
      </el-table-column>
      <el-table-column
        prop="position"
        label="职位">
      </el-table-column>
       <el-table-column
        label="操作"
        width="90">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="onSubmit(scope.row)">
            添 加
          </el-button>
        </template>
      </el-table-column>
     </el-table>
      <div style="margin-top:16px;text-align:right">
        <el-pagination
          background
          small
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="params.content.pageSize"
          layout="total, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
      <div class="dialog-footer">
        <el-button size="small" @click="dialogTableVisible = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" :disabled="selection.length === 0" @click="onSubmit" class="normal-btn-width">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import tablelayout from '@/components/table/index.vue'
export default {
  props:['ownertable'],
  components:{
    tablelayout
  },
  data () {
    return {
      dialogTableVisible:false,
      params:{
        id:'20221018122201',
        content: {
          "ownertable":this.ownertable,
          "ownerid":this.$route.query.id,
          "where":{
            "condition":"",
            "withoutselect":1
          }
        },
      },
      search:{},
      selection:[],
      tablecols:[],
      list:[],
      total:0,
      currentPage:0
    }
  },
  methods:{
    onShow () {
      this.listData()
    },
     async listData () {
      const res = await this.$api.requested(this.params)
      this.list = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.listData()
    },
    checkboxCallBack (val) {
      console.log(val)
      this.selection = val
    },
    async onSubmit (row) {
      const res = await this.$api.requested({
        "id": 20220930103601,
        "content": {
            "ownertable":this.ownertable,
            "ownerid":this.$route.query.id,
            "userid":row.userid
        }
      })
      this.tool.showMessage(res,()=>{
        this.dialogTableVisible = false
        this.$emit('onSuccess')
      })
    },
  },
  created () {
    //获取表结构
  }
}

</script>
<style>
</style>