<template>
  <div v-loading="loading">
    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="150px" class="order_form">
      <el-form-item label="新销售负责人" prop="F_Name">
        <el-input v-model="ruleForm.F_Name" placeholder="请输入新销售负责人"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { formatterContent } from '@/utils'
import { getTransfer } from '@/api/memberManagement/memberList'
export default {
  name: "AddOrEdit",
  props: {
    rowid: {
      type: Array,
      default: []
    },
    callid: {
      type: Number,
      default: 0
    },
    layerid: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      ruleForm: {
        F_Name: "" //客户姓名
      },
      rules: {
        F_Name: [
          {
            required: true,
            trigger: "blur",
            message: "请输入新负责人姓名"
          }
        ]
      },
      loading: false
    };
  },
  created() {
    if (this.callid) {
      this.ruleForm.unique_id = this.callid;
    }
    Promise.all([]).then(() => {
      if (this.rowid) {
      }
    });
  },
  methods: {
    submitForm() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          this.loading = true;
          return new Promise(resolve => {
            // const params ={
            //   ids:this.rowid,
            //   toperson: this.ruleForm.F_Name
            // }
            // console.log(params)
            // 添加
            if (this.rowid) {
              getTransfer(this.rowid,this.ruleForm.F_Name)
                .then(response => {
                  this.loading = false;
                  if (response.state.toLowerCase() === "success") {
                    this.$parent.$layer.close(this.layerid);
                    this.$parent.btn_search(); // 重新加载父级数据
                    this.$message.success("恭喜你，转移成功!");
                  }
                })
                .catch(() => {
                  this.loading = false;
                });
            }
          });
        } else {
          this.$message.error("请输入有效的必填项信息!");
          return false;
        }
      });
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.order_form {
  .form_select {
    width: 100%;
  }
  .form_date {
    width: 100%;
  }
  .col_select_text {
    text-align: right;
    padding-right: 15px;
  }
}
</style>