<style>
  
  
  </style>
  <template>
    <div class="page-body salesRules">
      <div class="page-search row items-center">
        <div class="col row wrap q-mr-lg q-col-gutter-md">
          <div class="col-3">
            <q-input filled v-model="Money" label="提成金额" type="number" />
          </div>
          <div>
            <q-btn color="accent" size="sm" v-if='isSalerule_preserve == true'  @click="preservation()" ref="addBtn" label="保存规则" />
          </div>
        </div>
      </div>
     
  
    </div>
  </template>
  <script>
    
    import {
        getTeacherContributeConfig,
        setTeacherContributeConfig
    } from '../../../api/finance/index'
    export default {
      meta: {
        title: "投稿提成规则"
      },
      props: {},
      components: {},
      data() {
        return {
           
            Money:0,
            isSalerule_preserve:false
  
       
        }
      },
      created() {
        let userinfo = this.getLocalStorage();
          userinfo.ActionMenuList.map(x=>{//判断权限
            if(x.FunctionCode == "F_Contribution_rule"){//判断是否有保存的权限
              this.isSalerule_preserve = true;
              return
            }
          })
      },
      mounted() {
  
        this.getRule(); //获取规则
      },
      methods: {
  
  
  
        getRule() {
            getTeacherContributeConfig({}).then(res => {
                if (res.Code == 1) {
                    this.Money = res.Data.Money
                
                }
            })
        },
        preservation() { //保存规则
          
            setTeacherContributeConfig({Money:this.Money}).then(res => {
            if (res.Code == 1) {
              this.$q.notify({
                icon: 'iconfont icon-chenggong',
                color: 'accent',
                timeout: 2000,
                message: '数据保存成功！',
                position: 'top'
              })
              this.getTeacherContributeConfig()
            }
          })
        },
        
  
      },
    }
  
  </script>
  <style lang="sass">
    @import url('~assets/css/table.sass')
  
  </style>
  