<template>
  <div style="background: #fff;">
    <van-nav-bar title="基础分设置" left-text="返回" @click-left="$route_back" left-arrow></van-nav-bar>
    <van-row style="margin: 0.8rem 0 0.3rem;">
      <van-col span="20" offset="2" style="font-size: 14px; color: rgb(144, 147, 153);">基础分是为了让积分保持正激励的作用，减少出现0分以下的情况，更好地激励员工挣分。</van-col>
    </van-row>
    <van-row style="margin: 0 0 0.5rem 0;" type="flex">
      <van-col span="6" offset="2"><div class="base_point_label">基础分</div></van-col>
      <van-col span="8" class="base_point"><van-field class="base_point_bg" v-model="parameter.base_point" placeholder="输入分值" type="digit"></van-field></van-col>
      <van-col span="6" class="base_point_right">B分</van-col>
    </van-row>

    <van-row style="margin-bottom: 0.5rem;">
      <van-col :span="20" offset="2"><van-button size="large" type="info" @click="saveBase" :loading="send_loading">保存设置</van-button></van-col>
    </van-row>

    <van-row>
      <van-col span="20" offset="2" style="font-size: 14px; color: rgb(144, 147, 153);">
        设置分值后，系统将为全部员工自动加上此项基础分此项基础分仅加一次，记入每个员工的累计总分
      </van-col>
    </van-row>
    <!--
    <div style="font-size:0.24rem; padding:0.32rem; color:#909399; padding-left:0.8rem; position: absolute; bottom:0rem;">
      <p>· 一定的基础分会给予员工安全感和危机感</p>
      <p>· 员工不会轻易掉到0分，正分更能激励人</p>
      <p>· 员工接近0分或低于0分，将考虑淘汰或调岗</p>
    </div> -->
  </div>
</template>

<script>
import request from '@/utils/request'
import Vue from 'vue'
import { Field, Button, Col, Row } from 'vant'
import moment from 'moment'
import { getToken } from '@/utils/auth'
Vue.use(Field)
  .use(Button)
  .use(Col)
  .use(Row)
export default {
  name: 'point_base',
  data () {
    return {
      send_loading: false,
	    parameter:{base_point: 0 },
    }
  },
  components: {},
  methods: {
    saveBase () {
      if (this.parameter.base_point == '') {
        this.$toast('请输入基础分')
        return
      }
      request('post','/api/integral/site/config',this.parameter,'v2').then(res => {
        if (res.data.code == 1) {
          this.$toast('设置成功')
        } else {
          this.$toast(res.data.msg)
        }
      })
    },
    getPoint () {
      request('get', '/api/integral/site/config').then(res => {
        if (res.data.code == 1) {
          this.parameter = res.data.data
        }
      })
    }
  },
  mounted () {
    this.getPoint()
  }
}
</script>

<style scoped lang="less">
.base_point {
  position: relative;
  .base_point_bg {
    background: #f5f7fa;
  }
}
.base_point_right {
  font-size: 14px;
  color: #909399;
  line-height: 0.92rem;
  text-align: center;
  background: #f5f7fa;
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}
.base_point_label {
  font-size: 0.32rem;
  display: inline-block;
  background: #26a2ff;
  color: #fff;
  text-align: center;
  width: 100%;
  vertical-align: middle;
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
  padding: 0.24rem 0;
}
</style>
