<template>
  <div class="integralSetting">
    <div class="el-card__header">
      <span>用户积分设置</span>
    </div>

    <div class="form-box">
      <el-form :model="msg" style="padding:0 50px;" ref="msg" label-width="170px">
        <el-form-item label="用户积分"  >
          <el-input v-model="msg.IntegralNum" class="el-input--small" step="1"  min="0" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" >
            <template slot="append">积分抵扣1元</template>
          </el-input>
        </el-form-item>
        <el-form-item label="用户积分使用规则"  >
          <el-input
            type="textarea"
            :rows="2"
            v-model="msg.Explain">
          </el-input>
        </el-form-item>
      </el-form>
    </div>
    <el-button type="primary" style="margin: 12px 0 " @click="preserve()" :loading="loading">保存</el-button>

  </div>

</template>

<script>
    export default {
        name: "integralSetting",
      data(){
          return{
            msg:{
              ID:0,
              IntegralNum:0,
              Explain:'',
            },
            loading:false

          }
      },
      created(){
        this.getIntegralSettingsList()

      },
      methods:{
        getIntegralSettingsList(){
          this.apipost("/api/Integral/GetIntegralSettingsList",{} , res => {
            if (res.data.resultCode == 1) {
              this.msg.ID =res.data.data.ID
              this.msg.IntegralNum =res.data.data.IntegralNum
              this.msg.Explain =res.data.data.Explain
            } else {
              this.Info(res.data.message);
            }
          })
        },
        preserve(){
          this.loading=true
          this.apipost("/api/Integral/AddOrUpdateIntegralSettings",this.msg , res => {
            this.loading=false

            if (res.data.resultCode == 1) {
              this.Success(res.data.message);

            } else {
              this.Info(res.data.message);
            }
          })
        }
      }

    }
</script>

<style scoped>
  .integralSetting .el-card__header{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 18px 20px;

  }
  .integralSetting .el-button--small{
    padding: 9px 15px;
  }
  .integralSetting .form-box{
    padding: 20px 0;
    background-color: #fff;
    margin-bottom: 20px;
    padding-right: 50%;
  }
  .integralSetting .el-input__inner{
    height: 32px;
    line-height: 32px
  }
  .integralSetting .el-input--small .el-input__inner{
    height: 32px;
    line-height: 32px;
  }
</style>
