<template>
  <div>
    <el-button style="width:100%" size="mini"  block @click="onshow">更改成交状态</el-button>
    <el-dialog title="" :visible.sync="dialogForm" width="900px" 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="right" label-width="90px">
            <el-col :span="20">
              <el-form-item prop="tradingstatus"  label="成交状态:" >
                <el-select v-model="form.tradingstatus" 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: "transactionStatus",
  props:["id"],
  data(){
    return {
      dialogForm:false,
      form:{
        tradingstatus:""
      },
      rules:{
        tradingstatus: [
          { 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": 20221012164102,
          "content": {
            "sa_customersids": [this.id],
            "tradingstatus": this.form.tradingstatus//（未成交、已成交、多次成交）
          },
        })
        this.tool.showMessage(res, ()=>{
          this.dialogForm = false
          this.$emit("shareSuccess")
        })
      })
    }
  }
}
</script>

<style scoped>

</style>