<template>
  <div>
    <el-button size="mini" :type="!disabled?'':'primary'" block @click="onshow" :disabled="!disabled">更改合作状态</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="status"  label="状态:" >
                <el-select v-model="form.status" placeholder="请选择状态" style="width: 100%">
                  <el-option
                      v-for="item in status"
                      :key="item.value"
                      :label="item.value"
                      :value="item.value">
                  </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: "statusChange",
  props:["id","disabled"],
  data(){
    return {
      dialogForm:false,
      form:{
        status:""
      },
      rules:{
        status: [
          { required: true, message: '未选择状态', trigger: 'change' },
        ],
      },
      status:[
        {
          label:'潜在',
          value:'潜在'
        },
        {
          label:'合作中',
          value:'合作中'
        },
        {
          label:'已终止',
          value:'已终止'
        }
      ]
    }
  },
  methods:{
    onshow(){
      this.dialogForm = true
      this.$emit("onshow")
    },
    onSubmit(){
      this.$refs['form'].validate(async (valid) => {
        if (!valid) return false
        const res = await this.$api.requested({
          "id": 20221010164602,
          "content": {
            "sa_customersids": [this.id],
            "status": this.form.status//（未成交、已成交、多次成交）
          },
        })
        this.tool.showMessage(res, ()=>{
          this.dialogForm = false
          this.$emit("statusChangeSuccess")
        })
      })
    }
  }
}
</script>

<style scoped>

</style>