<template>
  <div>
    <el-button style="width:100%"  size="mini" type="primary" block @click="onshow" >回收</el-button>
    <el-dialog title="" :visible.sync="dialogForm" width="400px" append-to-body>
      <div slot="title" style="font-size: 15px">
        回收客户
      </div>
      <div>
        <el-row :gutter="20">
          <el-form :model="form" :rules="rules"  ref="form"  size="mini" label-position="top" label-width="90px">
            <el-col :span="24">
              <el-form-item prop="sa_customerpoolid"  label="公海池:" >
                <el-select v-model="form.sa_customerpoolid" placeholder="请选择公海池" style="width: 100%">
                  <el-option
                      v-for="item in pool"
                      :key="item.sa_customerpoolid"
                      :label="item.poolname"
                      :value="item.sa_customerpoolid">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <div class="dialog-footer">
        <el-button size="small" @click="dialogForm = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" @click="onSubmit" class="normal-btn-width btn-warning">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "recovery",
  props:["data","disabled"],
  data() {
    return {
      dialogForm: false,
      form: {
        sa_customerpoolid: "",
        sa_customersid: ""
      },
      createby:"",
      name:"",
      pool: [],
      rules: {
        sa_customerpoolid: [
          {required: true, message: '未选择公海池', trigger: 'change'},
        ],
      }
    }
  },
  methods:{
    onshow(){
      this.dialogForm = true
      this.poolList()
      if (this.data.leader.length !== 0){
        this.createby = this.data.leader[0].createby
        this.name = this.data.leader[0].name
      }
      this.$emit("onshow")
    },
    onSubmit(){
      this.$refs['form'].validate(async (valid) => {
        if (!valid) return false
        const res = await this.$api.requested({
          "id": 20221014165602,
          "content": {
            "sa_customerpoolid":this.form.sa_customerpoolid,//公海池id
            "sa_customersid":this.data.sa_customersid//客户id
          },
        })
        this.tool.showMessage(res, ()=>{
          this.dialogForm = false
          this.$emit("backSuccess")
          this.$router.go(-1)
        })
      })
    },
    /*公海池列表*/
    async poolList(){
      const res = await this.$api.requested({
        "id": 20221009100702,
        "content": {
          "pageNumber": 1,
          "pageSize": 90,
          "where": {
            "condition": "",
          }
        },
      })
      console.log(res)
      this.pool = res.data
    }
  },
  mounted() {
  }
}
</script>

<style scoped>

</style>