<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2020-04-14 09:50:16
 * @LastEditors: 无尘
 * @LastEditTime: 2020-04-14 15:24:58
 -->
<!--
  <sync-fail :syncData="syncData" @refreshSync="refreshSync" @repeatSync="repeatSync"></sync-fail>
  import syncFail from '@/components/company/sync-fail.vue';
 -->
<template>
  <el-dialog class="hide-header-dialog" center title="" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
    <div>
      <div class="text-center"><span class="font-36 el-icon-circle-close color-f83431"></span></div>
      <div class="font-18 color-303133 m-t-25 text-center">出错了！</div>
      <div class="font-14 color-606266 m-t-10 text-center line-h-20">同步失败，您所提交的同步内容未同步成功，请查看日志后重新同步失败门店或分组。关闭提示后不能再进行剩余同步！</div>
    </div>
    <div slot="footer" class="dialog-footer m-b-20 ">
      <el-button @click="closeSync">取 消</el-button>
      <el-button type="primary" @click="toLog">查看日志</el-button>
      <el-button type="primary" @click="toContinue">继续同步</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { postRequest } from '@/api/api';
import errMsg from '@/common/js/error';
export default {
  props: {
    syncData: {
      type: Object,
      default() {
        return {
          syncStatus: '4',
          totalDeal: 0
        };
      }
    }
  },
  data() {
    return {
      dialogVisible: true
    };
  },
  methods: {
    /**
     * 关闭同步
     */
    closeSync() {
      const that = this;
      let para = {};
      postRequest('/haoban-manage3-web/close-sync', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            that.$emit('refreshSync');
            return false;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },
    handleClose(done) {
      // const that = this;
      done();
    },
    toLog() {
      // const that = this;
      window.open('/haoban-3/#/syncLog');
    },
    toContinue() {
      const that = this;
      let para = {};
      postRequest('/haoban-manage3-web/re-sync', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            that.$emit('repeatSync');
            return false;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  }
};
</script>
<style lang="less" scoped>
.m-b-20 {
  margin-bottom: 20px;
}
.m-t-25 {
  margin-top: 25px;
}
.m-t-10 {
  margin-top: 10px;
}
.line-h-20 {
  line-height: 20px;
}

.font-18 {
  font-size: 18px;
}

.font-36 {
  font-size: 36px;
}

.color-f83431 {
  color: #f83431;
}
</style>
