<template>
  <div v-loading="loading">
    <div class="white-box">

      <el-form ref="form" :model="form">
        <el-table
            :data="form.baseScore">
          <el-table-column prop="outTitle" label="序号">
            <template slot-scope="scope">
              {{scope.row.sort}}
            </template>
          </el-table-column>
          <el-table-column prop="outTitle" label="月收入范围">
            <template slot-scope="scope">
              {{scope.row.monthTotalPvMin}} - {{scope.row.monthTotalPvMax}}
            </template>
          </el-table-column>
          <el-table-column label="月收入最小值(包含)">
            <template slot-scope="scope">
              <el-input v-model="scope.row.monthTotalPvMin" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="月收入最大值(不包含)">
            <template slot-scope="scope">
              <el-input v-model="scope.row.monthTotalPvMax" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="积分">
            <template slot-scope="scope">
              <el-input v-model="scope.row.score" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
        </el-table>
        <div class="white-box-footer" style="line-height: 1.2;color: #999;">
          <p>注：</p>
          <p>(1) 月收入最大值为0，则表示最大值不受限制；</p>
        </div>
        <div class="white-box-footer">
          <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">更新</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
  import network from '@/utils/network'
  export default {
    name: 'config_score',
    mounted() {
      this.getData()
    },
    data() {
      return {
        form: {
          baseScore: [],
        },
        loading: true,
        submitButtonStat: false,
      }
    },
    methods: {
      onSubmit() {
        this.submitButtonStat = true
        network.postData('config/score', {
          baseScore: this.form.baseScore,
        }).then(response => {
          this.$message({
            message: response,
            type: 'success'
          })
          this.submitButtonStat = false
          this.getData()
        }).catch(response => {
          this.submitButtonStat = false
          this.getData()
        })
      },
      getData() {
        network.getData('config/score').then(response => {
          this.form.baseScore = response.baseScore.VALUE
          this.loading = false
          console.log(this.form.baseScore)
        })
      }
    }
  }
</script>

<style scoped>

</style>
