<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2020-03-16 15:12:59
 * @LastEditors: 无尘
 * @LastEditTime: 2020-05-29 10:42:07
 -->
<template>
  <div class="unreview-wrap common-set-wrap">
    <div class="right-content">
      <div class="right-box" style="min-height: calc(100vh - 126px)">
        <!-- <div>
          <el-switch v-model="storeSwitch" active-text="" inactive-text=""> </el-switch>
          <el-tooltip content="开启后，所有门店在小程序端修改门店资料需要审核通过后才能修改" placement="top">
            <span class="inline-block font-14 color-303133 m-l-20" style="cursor: pointer;padding-bottom: 2px; border-bottom: 1px dashed #2F54EB;">开启门店资料修改审核</span>
          </el-tooltip>
        </div> -->
        <div class="m-b-20">
          <el-checkbox v-model="storeSwitch" class="w-195" :true-label="1" :false-label="0">开启门店资料修改审核</el-checkbox>
          <div class="font-14 color-909399 set-tip-item">开启后，所有门店在小程序端修改门店资料需要审核通过后才能修改</div>
        </div>
        <!-- <div class="m-t-20">
          <el-switch v-model="clerkChangeFlag" active-text="" inactive-text=""> </el-switch>
          <el-tooltip content="开启后，企业微信成员在好办小程序店长删除或新增导购需要进行审核" placement="top">
            <span class="inline-block font-14 color-303133 m-l-20" style="cursor: pointer;padding-bottom: 2px; border-bottom: 1px dashed #2F54EB;">门店导购变更审核</span>
          </el-tooltip>
        </div> -->
        <div class="m-b-20">
          <el-checkbox v-model="clerkChangeFlag" class="w-195" :true-label="1" :false-label="0">门店导购变更审核</el-checkbox>
          <div class="font-14 color-909399 set-tip-item">开启后，企业微信成员在好办小程序店长删除或新增导购需要进行审核</div>
        </div>
        <div class="m-t-46 m-l-25">
          <el-button type="primary" :loading="loading" @click="postData">保 存</el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
// import { _debounce } from '@/common/js/public';
import { getRequest, postRequest } from '@/api/api';
export default {
  name: 'unreview',
  data() {
    return {
      storeSwitch: false,
      clerkChangeFlag: false,
      wxEnterpriseId: sessionStorage.getItem('userInfos') ? JSON.parse(sessionStorage.getItem('userInfos')).wxEnterpriseId : ''
    };
  },
  methods: {
    postData(val) {
      let para = {
        wxEnterpriseId: this.wxEnterpriseId,
        auditFlag: this.storeSwitch,
        clerkChangeFlag: this.clerkChangeFlag
      };
      postRequest('/haoban-manage3-web/audit/open-or-close', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            showMsg.showmsg('操作成功', 'success');
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          this.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },
    /**
     * 获取数据
     */
    getData(val) {
      let para = {
        wxEnterpriseId: this.wxEnterpriseId
      };
      getRequest('/haoban-manage3-web/audit/find-setting', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            this.storeSwitch = resData.result.auditFlag;
            this.clerkChangeFlag = resData.result.clerkChangeFlag;
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          this.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  mounted() {
    this.$emit('showTab', 3);
    this.getData();
  }
};
</script>
<style lang="scss" scoped>
.m-l-20 {
  margin-left: 20px;
}
.w-195 {
  width: 195px;
}
.set-tip-item {
  padding: 5px 0 0 25px;
}

.right-content {
  min-height: calc(100% - 126px);
  .right-box {
    background: #fff;
    min-height: 500px;
  }
}
.m-l-25 {
  margin-left: 25px;
}
</style>
