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

      <el-form ref="form" :model="form">
        <div class="filter-box">
          开启转账功能
          <el-switch v-model="form.transferOpen"></el-switch>
        </div>
        <el-table
            :data="form.allowWallet">
          <el-table-column prop="outTitle" label="转出/转入钱包类型">
            <template slot-scope="scope">
              {{getWalletName(scope.row.out)}} -> {{getWalletName(scope.row.in)}}
            </template>
          </el-table-column>
          <el-table-column label="转出金额下限" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.outMin" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="转出金额上限" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.outMax" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="手续费%" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.fee" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="手续费下限" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.feeMin" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="手续费上限" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.feeMax" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="期转出总额上限" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.weekMax" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="结算月转出总额上限" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.monthMax" size="small" maxlength="16"></el-input>
            </template>
          </el-table-column>
          <!--<el-table-column width="90" label="同体系转账">-->
            <!--<template slot-scope="scope">-->
              <!--<el-switch v-model="scope.row.isSystem"></el-switch>-->
            <!--</template>-->
          <!--</el-table-column>-->
          <!--<el-table-column width="90" label="点位绑定">-->
            <!--<template slot-scope="scope">-->
              <!--<el-switch v-model="scope.row.isBind"></el-switch>-->
            <!--</template>-->
          <!--</el-table-column>-->
          <el-table-column width="90" label="是否启用">
            <template slot-scope="scope">
              <el-switch v-model="scope.row.isOpen"></el-switch>
            </template>
          </el-table-column>
        </el-table>
        <div class="white-box-footer" style="line-height: 1.2;color: #999;">
          <p>注：</p>
          <p>(1) 期转出总额上限是指该转账规则一期之内会员最多可以转账的总金额；</p>
          <p>(2) 结算月转出总额上限是指该转账规则一个结算月内会员最多可转账的总金额；</p>
          <p>(3) 填写空则为不限制；</p>
          <!--<p>(4) 同体系转账开启，只有同体系会员能转账；(不包含大小体系，两个体系ID必须一致)</p>-->
          <!--<p>(5) 点位绑定开启，只允许点位绑定一起的会员间转账。</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_transfer',
    mounted() {
      this.getData()
    },
    data() {
      return {
        form: {
          transferOpen: true,
          allowWallet: [],
        },
        loading: true,
        submitButtonStat: false,
        allWallet:{'bonus':'会员账户','cash':'现金钱包'}
      }
    },
    methods: {
      getWalletName(type){
        return this.allWallet[type]
      },
      onSubmit() {
        this.submitButtonStat = true
        network.postData('config/transfer', {
          transferOpen: this.form.transferOpen,
          allowWallet: this.form.allowWallet,
        }).then(response => {
          this.$message({
            message: response,
            type: 'success'
          })
          this.submitButtonStat = false
          this.getData()
        }).catch(response => {
          this.submitButtonStat = false
          this.getData()
        })
      },
      getData() {
        network.getData('config/transfer').then(response => {
          this.form.transferOpen = response.transferOpen.VALUE
          this.form.allowWallet = response.allowWallet.VALUE
          this.loading = false
        })
      }
    }
  }
</script>

<style scoped>

</style>