userWeight.vue 1.28 KB
<template>
  <div>
    <el-select v-model="weight" size="mini" @change="changeWeight(row)">
      <el-option label="1" :value="1">
      </el-option>
      <el-option label="2" :value="2">
      </el-option>
      <el-option label="3" :value="3">
      </el-option>
      <el-option label="无法成为意向" :value="100">
      </el-option>
    </el-select>
  </div>
</template>

<script>
  import {editUserWeightApi} from "../../service/api";

  export default {
    name: "userWeight",
    props:[
      'row'
    ],
    data(){
      return {
        weight:this.row.weight
      }
    },
    methods:{
      changeWeight(data){
        this.$prompt('标记意向或非意向的原因', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(({ value }) => {
          editUserWeightApi(data.id,this.weight,{desc:value}).then(()=>{
            this.$message({
              type:'success',
              message:'数据更改成功'
            });
            this.$emit('onSuccess');
            this.weight = this.row.weight
          })
        }).catch(() => {
          this.weight = this.row.weight
        })
      },
    },
    watch:{
      'row.weight'(value){
        this.weight = value
      }
    }
  }
</script>

<style scoped>

</style>