<template>
  <basic-container>
    <el-row>
      <el-col :span="6">
          <el-form ref="form" :model="form" label-width="150px">
          <el-form-item label="是否开启分销">
            <el-switch v-model="form.isOpen"></el-switch>
          </el-form-item>
          <el-form-item label="分销关系绑定天数" >
            <el-input v-model="form.bindingDays" type="number" size=""></el-input>
          </el-form-item>
          <el-form-item label="分销结算天数" >
            <el-input v-model="form.settleDays" type="number" size=""></el-input>
          </el-form-item>
          <el-form-item label="订单分销比例" >
            <el-input v-model="form.proportion" type="number" size=""></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="rowSave">保存</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>

  </basic-container>
</template>

<script>
  import {getDetail, add} from "@/api/config/distributionconfig";
  import {mapGetters} from "vuex";

  export default {
    data() {
      return {
        form: {
          id: null,
          isOpen: false,
          bindingDays: 0,
          settleDays: 0,
          proportion: 0
        },
        query: {},
        loading: true,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },

        data: []
      };
    },
    created() {
      getDetail().then(res => {
        console.log(res);
        if(res.data.data){
          this.form = res.data.data
        }
      });
    },
    computed: {
      ...mapGetters(["permission"]),
    },
    methods: {
      rowSave() {
        console.log(this.form, '-----------form-------------');
        // return
        add(this.form).then(() => {
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        }, error => {
          window.console.log(error);
        });
      },

    }
  };
</script>

<style>
</style>
