<template>
  <div class="g-main"  style="padding: 30px;">
    <el-form ref="ref_form" :label-position="labelPosition" :model="tableData" style="margin-left: 80px; margin-bottom: 30px;" >
      <el-form-item label="姓名" prop="name">
        {{ tableData.name }}
      </el-form-item>
      <el-form-item label="积分" prop="points">
        {{ tableData.points }}
      </el-form-item>
      <el-form-item label="积分行为" width="200px"  prop="behaviorName">
        <el-select v-model="behaviorName" placeholder="请选择">
          <el-option v-for="item in options" :key="item.code" :label="item.name" :value="item.code">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="调整原因"  hide-required-asterisk="true"  prop="description">
        <el-input type="textarea" placeholder="不超过500子" v-model="description" maxlength="500" show-word-limit>
        </el-input>

      </el-form-item>
      <el-form-item label="操作类型"  hide-required-asterisk="false" reqired prop="radio">
        <el-radio-group v-model="radio" @change="handleRadioChange">
          <el-radio :label="3">加积分
          </el-radio>
          <el-radio :label="6">减积分</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="积分调整"   prop="integralnum">
        <el-input-number v-model="integralnum" @change="handleadjustment" :min="1" :max="10"
          label="描述文字"></el-input-number>
      </el-form-item>
    </el-form>
    <div class="flex flex-center1 flex-center2">
      <el-button type="info" @click="handleremove" >取消</el-button>
      <el-button   type="danger" @click="getTableData" >确定</el-button>
    </div>
    <div>
    </div>
  </div>
</template>
<script>
  import { requestPost,requestGet } from "@/js/dai/request";
export default {
    
   name: "see",
    data() {
    return {
        labelPosition: 'right',
        tableData: [],
        integralnum: 1,
        radio:3,
        textarea: '',
        options: [],
        behaviorName: '',
        description:"",
        pointsDelta:"",
        Positive:'',
    };
  },
  props:{
    list:{
      type: Object,
      default: () => {}
    }
  },
  created() {
    console.log(this.list,"list");
    this.tableData=this.list
    this.getpoints()

  },
  computed:{
  
  },
  methods: {
    //选+-
    handleRadioChange(val){
     console.log(val);
     this.Positive = val === 3 ? '+' : val === 6 ? '-' : '';
     console.log(this.Positive);
     
    },
    //获取积分行为
    async getpoints() {
 const url = "/voluntary/points/adjustVolunteerPoints/reasonsList";
 let params={
 
 }
await requestGet(url,params).then((res)=>{
  if (res.code === 0) {
   console.log("列表请求成功！！！！！！！！！！！！！！");
   this.options = res.data
 } else {
 }
})
},
    //调整积分
          async getTableData() {
        const url = "/voluntary/points/adjustVolunteerPoints/commit";
        let params={
          volunteerId:this.tableData.id,
          reason:this.behaviorName,
          description:this.description,
          pointsDelta:this.Positive+this.integralnum,
          primaryPoints:this.tableData.points
          // volunteerId:this.list.id,
          // mobile:this.formData.phone,
          // name:this.formData.name
        }
        console.log(params,"params");
        
        const { data, code, msg } = await requestPost(url,params);
        if (code === 0) {
          console.log("列表请求成功！！！！！！！！！！！！！！");
          this.$message({
            message: "调整成功",
            type: "success",
          });
          this.$emit('summDetailClose')
        } else {
        }
      },

    handleSubmit(){
      this.$emit('summDetailClose')
    },
    handleremove(){
      this.$emit('summDetailClose')
    },
    handleadjustment(value) {
      console.log(value,"num");
  },
}

}

</script>
<style lang="scss" scoped>
  @import "@/assets/scss/modules/management/volunteet.scss";
</style>