<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-08-01 14:42:38
 * @LastEditors: 无尘
 * @LastEditTime: 2020-12-14 15:24:29
 -->
<template>
  <div class="storePermission-wrap common-set-wrap">
    <nav-crumb :navpath="navpath"></nav-crumb>
    <div class="right-content">
      <div class="right-box">
        <div class="">
          <div class="check-box-wrap inline-block vertical-top">
            <el-checkbox v-model="contactHideFlag">隐藏通讯录模块</el-checkbox>
          </div>
          <div class="tip-text-wrap w-440 inline-block vertical-top">注：隐藏后，APP将不展示通讯录，通讯录仍可用，但无法进行通讯录及门店管理，以及添加员工操作。所有通讯录内容仅可在PC管理后台进行操作和管理。</div>
        </div>
        <div class="m-b-20">
          <div class="check-box-wrap inline-block vertical-top">
            <el-checkbox v-model="contactHideFlag">通讯录姓名修改后覆盖用户姓名</el-checkbox>
          </div>
          <div class="tip-text-wrap w-440 inline-block vertical-top"></div>
        </div>
        <div>
          <el-button type="primary" @click="saveSet">保 存</el-button>
        </div>
      </div>
    </div>
    <vue-gic-footer></vue-gic-footer>
  </div>
</template>
<script>
import navCrumb from '@/components/nav/nav.vue';
import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
import { _debounce } from '@/common/js/public';
import { postRequest } from '@/api/api';
export default {
  name: 'contactPermission',
  data() {
    return {
      // 面包屑参数
      navpath: [
        {
          name: '首页',
          path: '/index'
        },
        {
          name: '设置',
          path: '/companyAddress'
        },
        {
          name: '通讯录信息',
          path: '/staffDetails'
        },
        {
          name: '通讯录控制',
          path: ''
        }
      ],
      contactHideFlag: false
    };
  },
  methods: {
    saveSet: _debounce(function() {
      const that = this;
      let para = {
        contactHideFlag: that.contactHideFlag ? '1' : '0'
      };
      postRequest('/haoban-manage-web/contact/save-contact-setting', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            showMsg.showmsg('保存成功', 'success');
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }, 300),
    /**
     * 获取设置数据
     */
    getSetData() {
      const that = this;
      let para = {};
      postRequest('/haoban-manage-web/contact/find-contact-setting', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            that.contactHideFlag = resData.result.contactHideFlag == 1 ? true : false;
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  mounted() {
    const that = this;
    that.getSetData();
  },
  components: {
    navCrumb
  }
};
</script>
<style lang="less" scoped>
.bg-fff {
  background: #fff;
}

.common-set-wrap {
  .right-content {
    /*width: 100%;*/
    padding: 24px;
    min-height: calc(100% - 240px);

    .right-box {
      /*background: #fff;*/
      /*padding: 24px;*/
      min-height: 500px;

      .m-t-24 {
        margin-top: 24px;
      }
      .w-440 {
        width: 440px;
        white-space: pre-wrap;
        word-break: break-all;
        font-size: 12px;
        color: #909399;
      }
      .tip-text-wrap {
        line-height: 24px;
        padding-left: 20px;
      }
      .vertical-top {
        vertical-align: top;
      }
    }
  }
}
</style>
