<template>
  <div class="unreview-wrap common-set-wrap">
    <div class="app-detail-pane border-box p-20">
      <div class="m-b-20">
        <el-checkbox v-model="clerkPhoneFlag" 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-checkbox v-model="clerkChangeFlag"  class="w-195">允许店长编辑门店信息</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" @click="submit">保 存</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import { postRequest, getRequest } from '@/api/api';
import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
export default {
  name: 'setting',
  data() {
    return {
      wxEnterpriseId: sessionStorage.getItem('userInfos') ? JSON.parse(sessionStorage.getItem('userInfos')).wxEnterpriseId : '',
      clerkPhoneFlag: 0,
      storeEditFlag: 0
    };
  },
  methods: {
    submit() {
      let para = { wxEnterpriseId: this.wxEnterpriseId, clerkPhoneFlag: this.clerkPhoneFlag, storeEditFlag: this.storeEditFlag };
      postRequest('/haoban-manage3-web/setting/operation-setting/save-or-update', para)
        .then(res => {
          if (res.data.errorCode == 1) {
            showMsg.showmsg('保存成功', 'success');
          }
          errMsg.errorMsg(res.data);
        })
        .catch(error => {
          this.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },
    getData() {
      getRequest('/haoban-manage3-web/setting/get-operation-setting', { wxEnterpriseId: this.wxEnterpriseId })
        .then(res => {
          const { clerkPhoneFlag, storeEditFlag } = res.data.result || {};
          this.clerkPhoneFlag = clerkPhoneFlag || 0;
          this.storeEditFlag = storeEditFlag || 0;
        })
        .catch(error => {
          this.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  mounted() {
    this.$emit('showTab', 6);
    document.documentElement.style.backgroundColor = '#f0f2f5';
    this.getData();
  },
  destroyed() {
    document.documentElement.style.backgroundColor = '#fff';
  }
};
</script>
<style lang="scss" scoped>
.w-195 {
  width: 195px;
}

.p-20 {
  padding: 20px;
}

.m-l-25 {
  margin-left: 25px;
}

.set-tip-item {
  padding: 5px 0 0 25px;
}

.boxline {
  display: flex;
  align-items: center;
}
</style>
