<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-03-20 14:36:37
 * @LastEditors  : 无尘
 * @LastEditTime : 2020-02-18 10:11:44
 -->
<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">
            <div class="overstore-tip">
              <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">什么是回收站？<br />GIC分组或门店被删除后将被放置到回收站，如果是误删或想再次启用，您可以随时恢复它们。</span>
                </div>
              </div>
            </div>
            <div class="table-condition-search m-t-20">
              <el-input placeholder="请输入部门名称/CODE/ID" v-model="searchInput" class="w-293" @keyup.native="value => toInput(value, searchInput)" clearable @clear="clearInput"> </el-input
              ><el-select class="w-191 m-l-10" v-model="searchType" placeholder="所有部门类型" @change="changeType">
                <el-option v-for="item in options" :key="item.id" :label="item.label" :value="item.id"> </el-option>
              </el-select>
            </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"
                    ><span class="iconfont icondianpu-kuai color-2f54eb"></span><span class="p-l-10">{{ scope.row.departmentName || '--' }}</span></template
                  >
                </el-table-column>
                <el-table-column prop="" label="ERP CODE" show-overflow-tooltip>
                  <template slot-scope="scope">{{ scope.row.storeCode || '--' }}</template>
                </el-table-column>
                <el-table-column prop="" label="操作" show-overflow-tooltip>
                  <template slot-scope="scope">
                    <el-button type="text" size="small" @click="toRecover(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">
                <el-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"> </el-pagination>
              </div>
            </div>
          </div>
        </div>
      </div>
      <set-department v-if="setVisible" @closeSet="closeSet"></set-department>
    </div>
    <vue-gic-footer></vue-gic-footer>
  </div>
</template>
<script>
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 - 380 + 'px',
      // 面包屑参数
      navpath: [
        {
          name: '首页',
          path: '/index'
        },
        {
          name: '回收站',
          path: ''
        }
      ],
      options: [],
      searchInput: '',
      searchType: '',
      // 分页参数
      currentPage: 1,
      pageSize: 20,
      total: 0,
      tableData: [],
      setVisible: false
    };
  },
  computed: {},
  methods: {
    /**
     * 恢复
     */
    toRecover() {
      const that = this;
      that.setVisible = true;
    },
    closeSet() {
      const that = this;
      that.setVisible = false;
      that.currentPage = 1;
      that.getTableList();
    },
    /**
     * 路由跳转
     */
    changeRoute(path) {
      this.$router.push(path);
    },
    /**
     * 输入
     */
    toInput: _debounce(function(e, value) {
      const that = this;
      that.currentPage = 1;
      that.getTableList();
    }, 500),
    // 搜索清除
    clearInput() {
      const that = this;
      that.currentPage = 1;
      that.getTableList();
    },
    /**
     * 选择类型
     */
    changeType() {
      const that = this;
      that.currentPage = 1;
      that.getTableList();
    },
    /**
     * 分页---页码变化
     */
    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-app-member-web/customer/find_message_list', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            that.tableData = resData.result.list || [];
            that.total = resData.result.total;
            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() {
    let that = this;
    let iconUrl = that.$route.query.appIcon;
    if (iconUrl) {
      that.appIcon = window.unescape(iconUrl);
    }
    document.documentElement.style.backgroundColor = '#f0f2f5';
  },
  destroyed() {
    document.documentElement.style.backgroundColor = '#fff';
  },
  components: {
    navCrumb,
    setDepartment
  }
};
</script>
<style type="text/less" lang="less" scoped>
.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>
