<template>
  <div v-loading="loading">
    <workpoints :initia_arr="initia_arr" :initia_head="initia_head" @initia="initia" />
  </div>
</template>
<script>
import workpoints from "@/components/publics/workpoints";
export default {
  data() {
    return {
      loading: false,
      initia_head: {
        initial_suername: "初始分",
        initial_suertext: "基础分和工龄分均为B分",
        initial_left: "85px",
        initial_width: "83px",
      },
      initia_arr: [
        {
          initialName: "基础分",
          initia_mark: true,
          initia_input: {
            age: "",
          },
          initial_text:
            "基础分是为了让积分保持正激励的作用，减少出现0分<br/>以下的情况，更好地激励员工挣分；<br/>设置分值后，系统将为全部员工自动加上此项基础分；<br/>此项基础分仅加一次，计入每个员工的累积总分",
        },
        {
          initialName: "工龄分",
          initia_mark: true,
          initia_input: {
            age: "",
          },
          initial_text:
            "工龄分是为了更好的认可老员工；<br/>首次加分=员工已在职的月份*工龄分，未满一个月的不<br/>加分；后续加分按设置的工龄分值每月自动累加",
        },
      ],
      obj: [
        {
          base_point: "",
          service_point: "",
        },
      ],
    };
  },
  components: {
    workpoints,
  },
  created() {},
  mounted() {
    this.cheak_ax();
  },
  methods: {
    initia(ok) {
      this.loading = true;
      this.obj.base_point = +ok[0].sj;
      this.obj.service_point = +ok[1].sj;
      this.$axios('post',"/api/integral/site/config", this.obj).then((res) => {
          if (res.data.code == 1) {
            this.$message({
              message: res.data.msg,
              type: "success",
            });
          }
        }).finally(err=>{
			this.loading = false;
		});
    },
    cheak_ax() {
      this.loading = true;
      this.$axios('get',"/api/integral/site/config").then((res) => {
        var arr = [];
        for (let i in res.data.data) {
          arr.push(res.data.data[i]);
        }
        this.initia_arr[0].initia_input.age = Math.abs(arr[0]);
        this.initia_arr[1].initia_input.age = Math.abs(arr[3]);
      }).finally(err=>{
			this.loading = false;
	  });
    },
  },
};
</script>

<style  scoped lang="scss">
</style>