<!--
 * @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-select class="w-103" v-model="pageParams.taskStatus" slot="prepend" placeholder="所有完成情况" @change="reFetch">
                  <el-option label="已完成" :value="2"></el-option>
                  <el-option label="未完成" :value="1"></el-option>
                </el-select>
                <el-select class="w-103" v-model="pageParams.overdueStatus" slot="prepend" placeholder="所有逾期情况" @change="reFetch">
                  <el-option label="已逾期" :value="2"></el-option>
                  <el-option label="未逾期" :value="1"></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 width="87">
                    <template slot-scope="scope">{{ scope.row.taskTitle || '--' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="指派对象" width="176">
                    <template slot-scope="scope">
                      <div class="flex flex-align-center personal-info">
                        <el-image :src="scope.row.clerkImgUrl || headDefault" fit="cover"></el-image>
                        <div>
                          <p class="color-303133 line-20">{{ scope.row.clerkName || '--' }}</p>
                          <p class="color-909399 line-20">{{ scope.row.clerkPhoneNum || '--' }}</p>
                        </div>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="" label="会员">
                    <template slot-scope="scope">
                      <div class="flex flex-align-center personal-info">
                        <el-image :src="scope.row.memberImgUrl || headDefault" fit="cover"></el-image>
                        <div>
                          <p class="color-303133 line-20">{{ scope.row.memberName || '--' }}</p>
                          <p class="color-909399 line-20">{{ scope.row.memberCardNum || '--' }}</p>
                        </div>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="" label="创建时间" width="114">
                    <template slot-scope="scope">
                      <div class="color-606266 line-20">{{ scope.row.createTime | timeStampToYmd }}</div>
                      <div class="color-606266 line-20">{{ scope.row.createTime | timeStampToHms }}</div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="" label="逾期期限" width="114">
                    <template slot-scope="scope">
                      <div class="color-606266 line-20">{{ scope.row.overdueTime | timeStampToYmd }}</div>
                      <div class="color-606266 line-20">{{ scope.row.overdueTime | timeStampToHms }}</div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="" label="逾期情况" width="102">
                    <template slot-scope="scope"><span class="point" :style="'background:' + overdueStyle[scope.row.overdueStatus] + ';'"></span>{{ scope.row.overdueStatus === 1 ? '未逾期' : scope.row.overdueStatus === 2 ? '已逾期' : '' }}</template>
                  </el-table-column>
                  <el-table-column prop="" label="完成状态" width="102">
                    <template slot-scope="scope"><span class="point" :style="'background:' + taskStyle[scope.row.taskStatus] + ';'"></span>{{ scope.row.taskStatus === 1 ? '未完成' : scope.row.taskStatus === 2 ? '已完成' : '' }}</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-column prop="" label="操作" width="150">
                    <template slot-scope="scope">
                      <el-button type="text" size="small" @click="showDetail(scope.row)">预览</el-button>
                      <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>
              <salesleads-taskinfo :item="confirmDetail" v-if="confirmDetailShow"></salesleads-taskinfo>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- <vue-gic-footer></vue-gic-footer> -->
  </div>
</template>
<script>
import salesleadsTaskinfo from '@/components/review/salesleads-task-info.vue';
import headDefault from '@/assets/head_default.jpg';
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: 'taskDetail',
  data() {
    return {
      headDefault,
      bgHeight: window.screen.availHeight - 298 + 'px',
      // 面包屑参数
      navpath: [
        {
          name: '首页',
          path: '/index'
        },
        {
          name: '销售线索',
          path: ''
        }
      ],
      pageParams: {
        storeId: this.$route.params.id,
        pageNum: 1,
        pageSize: 20,
        overdueStatus: 1
      },
      // 分页参数
      total: 0,
      tableData: [
        {
          taskId: '12', // 任务id
          taskTitle: 'kasjhdk', // 任务名称
          clerkId: 'sdfsdf', // 导购id
          clerkName: 'sdfsdf', // 导购名字
          clerkImgUrl: '', // 导购头像
          clerkPhoneNum: '13634565656', // 导购手机号
          memberId: 'sdfsdf', // 会员id
          memberName: 'sdfsdf', // 会员名称
          memberImgUrl: '', // 会员头像
          memberCardNum: '3332345665654332039', // 会员卡号
          createTime: '2021-03-24T15:19:00', // 创建时间
          overdueTime: '2021-03-24T15:19:00', // 逾期时间
          overdueStatus: 1, // 逾期状态
          taskStatus: 2 // 完成状态
        }
      ],
      overdueStyle: ['none', '#2F54EB', '#F5222D'],
      taskStyle: ['none', '#F5222D', '#33AF4A'],
      confirmDetailShow: false,
      confirmDetail: {},
      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) {
      console.log(item);
      this.confirmDetailShow = true;
    }
  },
  watch: {},
  mounted() {
    // const that = this;
    // that.getTableList();
    document.documentElement.style.backgroundColor = '#f0f2f5';
  },
  destroyed() {
    document.documentElement.style.backgroundColor = '#fff';
  },
  components: {
    navCrumb,
    salesleadsTaskinfo
  }
};
</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: 291px;
              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;
        }
      }
    }
  }
}
.personal-info {
  .el-image {
    width: 40px;
    height: 40px;
    margin-right: 10px;
  }
}
.point {
  display: inline-block;
  width: 6px;
  height: 6px;
  vertical-align: top;
  margin-top: 8px;
  border-radius: 100%;
  margin-right: 5px;
}
</style>
<style lang="sass"></style>
