<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-03-20 14:36:37
 * @LastEditors: 无尘
 * @LastEditTime: 2020-08-26 10:05:42
 -->
<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-body">
              <div class="overstore-tip">
                <div role="alert" class="el-alert el-alert--info flex flex-align-start ">
                  <i class="el-alert__icon el-icon-warning font-12 color-2f54eb"></i>
                  <div class="el-alert__content">
                    <span class="el-alert__title color-303133 font-13">仅展示近一年数据，数据截取时间：2020-12-31至2021-12-31</span>
                  </div>
                </div>
                <div role="tips" class="tips flex flex-align-start">
                  <i class="el-icon-warning-outline font-14 color-2f54eb"></i>
                  <div class="el-alert__content">
                    <span class="el-alert__title color-2f54eb font-13">查看指标说明</span>
                  </div>
                </div>
              </div>
              <div class="table-condition-search m-t-20">
                <el-input placeholder="请输入计划名称" prefix-icon="el-icon-search" v-model="pageParams.cluePlanName" class="w-260" @change="reFetch" clearable @clear="clearInput"> </el-input>
                <el-date-picker class="m-l-10" prefix-icon="el-icon-time" :picker-options="pickerOptions" v-model="pageParams.date" @change="reFetch" :value-format="'yyyy-MM-dd'" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间"> </el-date-picker>
              </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.cluePlanName || '--' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="任务总数">
                    <template slot-scope="scope">{{ scope.row.taskCount || '--' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="已完成">
                    <template slot-scope="scope">{{ scope.row.finishCount || '--' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="完成率">
                    <template slot-scope="scope">{{ scope.row.completionRate + '%' || '--' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="待完成">
                    <template slot-scope="scope">{{ scope.row.waitFinishCount || '--' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="逾期中">
                    <template slot-scope="scope">{{ scope.row.overdueCount || '--' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="触达转化收益（元）">
                    <template slot-scope="scope">{{ scope.row.totalProfit || '--' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="操作">
                    <template slot-scope="scope">
                      <el-button type="text" size="small" @click="showDetail(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="pageNum" :page-sizes="[20, 40, 60, 80]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"> </dm-pagination>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- <vue-gic-footer></vue-gic-footer> -->
  </div>
</template>
<script>
import navCrumb from '@/components/nav/nav.vue';
import { getRequest } from '@/api/api';
import errMsg from '@/common/js/error';
import { _debounce } from '@/common/js/public';
export default {
  name: 'taskList',
  data() {
    return {
      bgHeight: window.screen.availHeight - 298 + 'px',
      // 面包屑参数
      navpath: [
        {
          name: '首页',
          path: '/index'
        },
        {
          name: '销售线索',
          path: ''
        }
      ],
      pageParams: {
        pageNum: 1,
        pageSize: 20
      },
      // 分页参数
      total: 0,
      tableData: [
        {
          storeId: '12121',
          storeName: '12',
          taskCount: 111,
          finishCount: 34,
          completionRate: '12',
          waitFinishCount: 77,
          overdueCount: 23,
          totalProfit: 3424123,
          potentialProfit: 43242
        }
      ],
      pickerOptions: {
        disabledDate: time => {
          const end = new Date();
          return time.getTime() < end.getTime() - 3600 * 1000 * 24 * 365 || time.getTime() > end.getTime();
        }
      }
    };
  },
  computed: {},
  methods: {
    /**
     * 路由跳转
     */
    changeRoute(path) {
      this.$router.push(path);
    },
    /**
     * 筛选
     */
    reFetch: _debounce(function(e, value) {
      const that = this;
      that.pageParams.pageNum = 1;
      that.getTableList();
    }, 500),
    /**
     * 分页---页码变化
     *  @param {Number} val
     */
    handleSizeChange(val) {
      const that = this;
      that.pageParams.pageNum = 1;
      that.pageParams.pageSize = val;
      that.getTableList();
    },

    /**
     * 分页---当前页变化
     *  @param {Number} val
     */
    handleCurrentChange(val) {
      const that = this;
      that.pageParams.pageNum = val;
      that.getTableList();
    },
    /**
     * 获取列表数据
     */
    getTableList(val) {
      const that = this;
      let para = { ...that.pageParams };
      if (para.date) {
        para.startTime = para.date[0];
        para.endTime = para.date[1];
        delete para.date;
      }
      getRequest('/haoban-manage3-web/store-full-list', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            that.tableData = resData.result.list || [];
            that.total = resData.result.total;
          } else {
            errMsg.errorMsg(resData);
          }
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },
    showDetail(item) {
      this.$router.push(`taskDetail/${item.gicTaskId}`);
    }
  },
  watch: {},
  mounted() {
    // const that = this;
    // that.getTableList();
    document.documentElement.style.backgroundColor = '#f0f2f5';
  },
  destroyed() {
    document.documentElement.style.backgroundColor = '#fff';
  },
  components: {
    navCrumb
  }
};
</script>
<style type="text/scss" lang="scss" 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-260 {
  width: 260px;
}
.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;
  }
}
.my-customer-wrap {
  height: 100%;
}
.right-content {
  /*width: 100%;*/
  padding: 0;
  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;
          .overstore-tip {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            .el-alert--info {
              align-items: center;
              width: 444px;
              height: 32px;
              padding: 0 0 0 17px;
              margin-right: 17px;
              .el-alert__content {
                padding-left: 0;
              }
            }
            .tips {
              cursor: pointer;
              .el-alert__content {
                padding: 0 3px;
              }
            }
          }
        }
        .daily-set-wrap {
          height: 100%;
          background: #fff;
        }
        .app-detail-wrap {
          height: 100%;
          background: #fff;
        }
        .common-set-wrap {
          height: 100%;
          background: #fff;
        }
      }
    }
  }
}
</style>
