<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-03-20 14:36:37
 * @LastEditors: 无尘
 * @LastEditTime: 2020-06-22 09:59:52
 -->
<template>
  <div class="my-customer-wrap common-set-wrap">
    <nav-crumb :navpath="navpath"> </nav-crumb>
    <div class="right-content">
      <div class="right-box" :style="{ 'min-height': bgHeight }">
        <div class="apps-content flex" :style="{ 'min-height': bgHeight }">
          <div class="apps-content-right">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane label="会员分组列表" name="first">
                <div class="overstore-tip" style="width:643px;">
                  <div role="alert" class="el-alert el-alert--info flex flex-align-start">
                    <i class="el-alert__icon el-icon-info font-12 color-2f54eb"></i>
                    <div class="el-alert__content">
                      <span class="el-alert__title color-606266 font-14">仅保存近一年失败日志</span>
                    </div>
                  </div>
                </div>
                <div class="m-t-20">
                  <el-table class="select-table" ref="multipleTable" :data="tableData" tooltip-effect="dark" :style="{ width: '100%', minHeight: tableH }">
                    <el-table-column label="提交人" show-overflow-tooltip>
                      <template slot-scope="scope">{{ scope.row.userName }}</template>
                    </el-table-column>
                    <el-table-column prop="" label="同步时间" show-overflow-tooltip>
                      <template slot-scope="scope">
                        <div class="line-18">{{ scope.row.createTime | timeStampToYmd }}</div>
                        <div class="line-18">{{ scope.row.createTime | timeStampToHms }}</div>
                      </template>
                    </el-table-column>
                    <el-table-column prop="" label="完成时间" show-overflow-tooltip>
                      <template slot-scope="scope">
                        <div class="line-18">{{ scope.row.updateTime | timeStampToYmd }}</div>
                        <div class="line-18">{{ scope.row.updateTime | timeStampToHms }}</div>
                      </template>
                    </el-table-column>
                    <el-table-column prop="" label="同步内容" show-overflow-tooltip>
                      <template slot-scope="scope">{{ scope.row.taskDesc | '--' }}</template>
                    </el-table-column>
                    <el-table-column prop="" label="状态" show-overflow-tooltip>
                      <template slot-scope="scope">
                        <span :class="['span-dot', scope.row.statusFlag == 4 ? 'bg-52c41a' : 'bg-f5222d']"></span><span class="font-14 color-606266">{{ scope.row.statusFlag == 4 ? '成功' : scope.row.statusFlag == 5 ? '完成有错误' : scope.row.statusFlag == 6 ? '有错误关闭' : '' }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column prop="" label="操作" show-overflow-tooltip>
                      <template slot-scope="scope">
                        <el-button v-if="scope.row.statusFlag == 5 || scope.row.statusFlag == 6" type="text" @click="toShowLog(scope.$index, scope.row)">查看失败日志</el-button>
                      </template>
                    </el-table-column>
                  </el-table>
                  <div class="block common-wrap__page text-right m-t-24" v-if="tableData.length != 0">
                    <dm-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[20, 40, 60, 80]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"> </dm-pagination>
                  </div>
                </div>
              </el-tab-pane>
            </el-tabs>
          </div>
        </div>
      </div>
    </div>
    <!-- <vue-gic-footer></vue-gic-footer> -->
    <fail-log v-if="logShow" :taskId="taskId" @closeLog="closeLog"></fail-log>
  </div>
</template>
<script>
import failLog from '@/components/company/fail-log.vue';
import navCrumb from '@/components/nav/nav.vue';
import setDepartment from '@/components/company/set-department.vue';
import { getRequest } from '@/api/api';
import errMsg from '@/common/js/error';
// import { _debounce } from '@/common/js/public';
export default {
  name: 'reviewed',
  data() {
    return {
      bgHeight: window.screen.availHeight - 288 + 'px',
      // 面包屑参数
      navpath: [
        {
          name: '首页',
          path: '/index'
        },
        {
          name: '通讯录',
          path: '/contactsList'
        },
        /* {
          name: '组织架构管理',
          path: '/orgStructSet'
        }, */
        {
          name: '通讯录日志',
          path: ''
        }
      ],
      activeName: 'first',
      searchInput: '',
      // 分页参数
      currentPage: 1,
      pageSize: 20,
      total: 0,
      tableData: [],
      logShow: false,
      taskId: ''
    };
  },
  computed: {},
  methods: {
    /**
     * 切换tab
     */
    handleClick(tab, event) {
      console.log(tab, event);
    },
    /**
     * 查看失败日志
     */
    toShowLog(index, item) {
      const that = this;
      that.taskId = item.taskId;
      that.logShow = true;
    },
    closeLog() {
      const that = this;
      that.taskId = '';
      that.logShow = false;
    },
    /**
     * 路由跳转
     */
    changeRoute(path) {
      this.$router.push(path);
    },

    /**
     * 分页---页码变化
     */
    handleSizeChange(val) {
      const that = this;
      that.pageSize = val;
      that.getTableList();
    },

    /**
     * 分页---当前页变化
     */
    handleCurrentChange(val) {
      const that = this;
      that.currentPage = val;
      that.getTableList();
    },
    /**
     * 获取列表数据
     */
    getTableList(val) {
      const that = this;
      let para = {
        keyWord: that.searchInput || '', // 搜索字段
        pageNum: that.currentPage, // 当前页
        pageSize: that.pageSize // 一页显示个数
      };
      getRequest('/haoban-manage3-web/sync-task', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            that.tableData = resData.result.result || [];
            that.total = resData.result.totalCount;
            return false;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  watch: {
    activeBrand: function(newData, oldData) {
      const that = this;
      that.activeBrand = newData;
    },
    activeGroup: function(newData, oldData) {
      const that = this;
      that.activeGroup = newData;
    }
  },
  mounted() {
    const that = this;
    that.getTableList();
    document.documentElement.style.backgroundColor = '#f0f2f5';
  },
  destroyed() {
    document.documentElement.style.backgroundColor = '#fff';
  },
  components: {
    navCrumb,
    setDepartment,
    failLog
  }
};
</script>
<style type="text/less" lang="less" scoped>
.span-dot {
  display: inline-block;
  vertical-align: middle;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 3px;
  &.bg-52c41a {
    background: #52c41a;
  }
  &.bg-f5222d {
    background: #f5222d;
  }
}
.bg-82C5FF {
  background: #82c5ff;
}
.color-508CEE {
  color: #508cee;
}
.color-FF585C {
  color: #ff585c;
}
.line-h-18 {
  line-height: 18px;
}
.tooltip-text {
  width: 100%;
  white-space: pre-wrap;
  word-break: break-all;
}
.w-293 {
  width: 293px;
}
.w-191 {
  width: 191px;
}
.el-alert--info {
  background: rgba(240, 245, 255, 1);
  border-radius: 2px;
  border: 1px solid rgba(133, 165, 255, 1);
  -webkit-box-align: flex-start;
  -webkit-align-items: flex-start;
  -ms-flex-align: flex-start;
  align-items: flex-start;
  .el-alert__icon {
    font-size: 12px;
    padding-top: 3px;
  }
}
.my-customer-wrap {
  height: 100%;
}
.right-content {
  /*width: 100%;*/
  padding: 0 20px 20px 20px;
  min-height: calc(100% - 160px);
  .right-box {
    background: #fff;
    min-height: 500px;
    padding: 0px;
    .apps-content {
      .apps-content-right {
        width: 100%;
        padding: 20px;
        background: #fff;
        .overstore-body {
          background: #fff;
        }
        .daily-set-wrap {
          height: 100%;
          background: #fff;
        }
        .app-detail-wrap {
          height: 100%;
          background: #fff;
        }
        .common-set-wrap {
          height: 100%;
          background: #fff;
        }
      }
    }
  }
}
</style>
