<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-wrap flex-end">
      <div class="flex flex-center1 flex-center2 m-bottom10  " style="">
        <div>积分类型</div>
        <el-select v-model="formData.classKey" placeholder="请选择">
                <el-option v-for="item in formData.optionsStatus" :key="item.code" :label="item.name"
                  :value="item.code">
                </el-option>
              </el-select>
      </div>
      <div class="flex flex-center1 flex-center2 m-bottom10" style="">
        <div>积分时间</div>
          <div>
            <el-date-picker v-model="formData.createdTimeFrom" type="datetime" placeholder="开始时间"
            format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss">
          </el-date-picker>至 <el-date-picker v-model="formData.createdTimeTo" type="datetime" placeholder="结束时间"
            format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss">
          </el-date-picker>
          </div>
      </div>
      <!-- <div class="flex flex-center1 flex-center2 m-bottom10" style="">
                <div>状态：</div>
                <el-select v-model="StatusName" placeholder="请选择">
                    <el-option v-for="item in Status" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>

            </div>
            <div class="flex flex-center1 flex-center2 m-bottom10" style="">
                <div>兑换时间选择：</div>
                <el-date-picker v-model="ExchangeTime" type="date" placeholder="选择日期">
                </el-date-picker>
            </div> -->
      <div>
        <el-button type="primary" class="m-bottom10" @click="handleSearch">查询</el-button>
      </div>
    </div>
    <div >
      <el-table :data="tableData" border     height="250"      >
        <el-table-column label="序号" width="80" header-align="center" align="center" type="index"></el-table-column>
        <el-table-column prop="pointsClassName" header-align="center" align="center" label="积分类型">
        </el-table-column>
        <el-table-column prop="createdTime" header-align="center" align="center" label="积分时间">
        </el-table-column>
        <!-- <el-table-column prop="ActivityCount" header-align="center" align="center" label="姓名">
                </el-table-column> -->
        . <el-table-column prop="operationName" header-align="center" align="center" label="名称">
        </el-table-column>
        <el-table-column prop="pointsDelta" header-align="center" align="center" label="类型">
        </el-table-column>
        <el-table-column prop="pointsClass" header-align="center" align="center" label="积分">
        </el-table-column>
        <!-- <el-table-column prop="ActivityCount" header-align="center" align="center" label="核销时间">
                </el-table-column>
                <el-table-column prop="ActivityCount" header-align="center" align="center" label="状态">
                </el-table-column> -->
        <!-- <el-table-column label="操作" fixed="right" width="250" header-align="center" align="center" class="operate">
          <template slot-scope="scope">
            <el-button type="text" style="color:#1C6AFD;" size="small" @click="handleDetail(scope.row)">查看</el-button>
            <el-button type="text" style="color:#1C6AFD;" size="small"
              @click="handleEdit(scope.row)">活动记录</el-button>
            <el-button  type="text" style="color:#1C6AFD;" size="small"
              @click="handleDelete(scope.row)">积分调整</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <div>
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="pageNo"
          :page-sizes="[10, 20, 50]" :page-size="pageSize" layout="sizes, prev, pager, next, total" :total="total">
        </el-pagination>
      </div>

    </div>
    <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 {
      formData:{
        createdTimeTo:"",
        createdTimeTo:"",
        classKey:"",
        optionsStatus: [],
        },
        labelPosition: 'right',
        tableData: [],
        integralnum: 1,
        radio:3,
        textarea: '',
        options: [],
        behaviorName: '',
        description:"",
        pointsDelta:"",
        Positive:'',
        pageSize: 10,
        pageNo: 1,
        total: 0,
    };
  },
  props:{
    list:{
      type: Object,
      default: () => {}
    }
  },
  created() {
    console.log(this.list,"list");
    this.getlist()
    this.getpoint1s()

  },
  computed:{
  
  },
  methods: {
    //查询
    handleSearch(val) {
            this.pageNo = 1;
            this.getlist();
          },
          handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        this.pageSize = val;
        window.localStorage.setItem("pageSize", val);
        this.getlist();
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.pageNo = val;
        this.getlist();
      },
    //选+-
    handleRadioChange(val){
     console.log(val);
     this.Positive = val === 3 ? '+' : val === 6 ? '-' : '';
     console.log(this.Positive);
     
    },
    
    //获取积分行为
    async getpoint1s() {
 const url = "/voluntary/points/adjustVolunteerPoints/reasonsList";
 let params={
 }
await requestGet(url,params).then((res)=>{
  if (res.code === 0) {
   console.log("列表请求成功！！！！！！！！！！！！！！");
   this.optionsStatus = res.data
   console.log(this.optionsStatus);
   
 } 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 {
        }
      },
  
      async getlist() {
        const url = "/voluntary/points/listPointsChangeRecord";
        let params={
          volunteerId:this.list.id,
          createdTimeFrom:this.formData.createdTimeFrom,
          createdTimeTo:this.formData.createdTimeTo,
          description:this.description,
          pageNo:this.pageNo,
          pageSize:this.pageSize,
          // 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 requestGet(url,params);
        if (code === 0) {
          this.tableData=data.list
          this.total=data.total
          console.log("列表请求成功！！！！！！！！！！！！！！");
   
          // 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>