<style>
  .Sysuser_Date .el-input__inner {
    background: transparent !important;
    border: 0 !important;
  }

  .myTable_Zk tbody tr:first-child td {
    background: yellow !important;
  }

  .myTable_Zk tbody tr:first-child {
    background: yellow !important;
    z-index: 1 !important;
  }

  .TotalredClass {
    color: red;
  }
</style>
<template>
  <div class="page-body">
    <div class="col row wrap q-mb-lg" style="justify-content:space-between;">
      <div class="col-3 Sysuser_Date q-mr-lg">
        <q-field filled dense>
          <template v-slot:control>
            <el-date-picker v-model="myDate" style="width:100%" value-format="yyyy-MM" @change="getCheckDate()"
              size="small" type="month" placeholder="选择年月">
            </el-date-picker>
          </template>
        </q-field>
      </div>
      <div>
        <q-btn color="accent" class="q-mr-md" size="sm" icon="download" style="margin-top:15px;" label="下载"
          @click="downloadStudentMarket" />
      </div>
    </div>
    <div class="page-content">
      <q-table :pagination="msg" ref="table" :loading="loading" :style="{'height':tableHeight+'px'}"
        no-data-label="暂无相关数据" flat class="sticky-column-table sticky-header-column-table no-bottom-table myTable_Zk"
        separator="none" :data="dataList" :columns="columns" row-key="">
        <template v-slot:bottom>
        </template>
      </q-table>
    </div>
  </div>
</template>
<script>
  import {
    GetStudentMarket
  } from '../../api/sale/sale';
  import {
    EduDownLoad
  } from "../../api/common/common";
  export default {
    props: {},
    meta: {
      title: "市场部每日数据统计"
    },
    components: {},
    data() {
      return {
        columns: [{
            name: 'DateStr',
            label: '日期',
            field: 'DateStr',
            align: 'left'
          },
          {
            name: 'PushCount',
            label: '进单人数',
            field: 'PushCount',
            align: 'left'
          },
          {
            name: 'TrainCount',
            label: '语培需求',
            field: 'TrainCount',
            align: 'left',
          },
          {
            name: 'StudyCount',
            label: '留学需求',
            field: 'StudyCount',
            align: 'left',
          },
          {
            name: 'MeiTuanCount',
            label: '美团点评',
            field: 'MeiTuanCount',
            align: 'left'
          },
          {
            name: 'EduCustomerSign',
            label: '教育同行(签约)',
            field: 'EduCustomerSign',
            align: 'left'
          },
          {
            name: 'EduCustomerNotSign',
            label: '教育同行(未签约)',
            field: 'EduCustomerNotSign',
            align: 'left'
          },
          {
            name: 'PassBy',
            label: '过路客(直客)',
            field: 'PassBy',
            align: 'left'
          },
          {
            name: 'WeChatFriend',
            label: '朋友圈',
            field: 'WeChatFriend',
            align: 'left'
          },
          {
            name: 'TransCount',
            label: '学员转介绍',
            field: 'TransCount',
            align: 'left'
          },
          {
            name: 'SchoolPromote',
            label: '校园推广',
            field: 'SchoolPromote',
            align: 'left'
          },
          {
            name: 'SchoolAgent',
            label: '校园代理',
            field: 'SchoolAgent',
            align: 'left'
          },
          {
            name: 'OfflineActivity',
            label: '线下活动',
            field: 'OfflineActivity',
            align: 'left'
          },
          {
            name: 'OfficialAccount',
            label: '公众号',
            field: 'OfficialAccount',
            align: 'left'
          },
          {
            name: 'TeacherRecommend',
            label: '教师推荐',
            field: 'TeacherRecommend',
            align: 'left'
          },
          {
            name: 'ByteDance',
            label: '字节跳动',
            field: 'ByteDance',
            align: 'left'
          },
          {
            name: 'ThirdPartyPlatform',
            label: '第三方平台',
            field: 'ThirdPartyPlatform',
            align: 'left'
          },
          {
            name: 'Other',
            label: '其他',
            field: 'Other',
            align: 'left'
          },
          {
            name: 'ClassACount',
            label: 'A类客户',
            field: 'ClassACount',
            align: 'left'
          },
          {
            name: 'ClassBCount',
            label: 'B类客户',
            field: 'ClassBCount',
            align: 'left'
          },
          {
            name: 'ClassCCount',
            label: 'C类客户',
            field: 'ClassCCount',
            align: 'left'
          },
          {
            name: 'ClassDCount',
            label: 'D类客户',
            field: 'ClassDCount',
            align: 'left'
          },
          {
            name: 'InvalidCount',
            label: '无效',
            field: 'InvalidCount',
            align: 'left'
          },
          {
            name: 'ContractCount',
            label: '签约(成交.续费)',
            field: 'ContractCount',
            align: 'left'
          },
          {
            name: 'OrderMoney',
            label: '语培签约金额',
            field: 'OrderMoney',
            align: 'left'
          },
          {
            name: 'OrderNotMoney',
            label: '语培签约待收金额',
            field: 'OrderNotMoney',
            align: 'left'
          },
          {
            name: 'StudyOrderMoney',
            label: '留学签约金额',
            field: 'StudyOrderMoney',
            align: 'left'
          },
          {
            name: 'StudyOrderNotMoney',
            label: '留学签约待收金额',
            field: 'StudyOrderNotMoney',
            align: 'left'
          }
        ],
        dataList: [],
        loading: false,
        myDate: '',
        tableHeight: 500,
        msg: {
          YearStr: '',
          MonthStr: '',
          rowsPerPage: 0
        },
      }
    },
    created() {
      setTimeout(() => {
        this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 90;
      }, 100)
    },
    mounted() {
      let d = new Date();
      this.msg.YearStr = d.getFullYear().toString();
      this.msg.MonthStr = (d.getMonth() + 1).toString();
      this.myDate = this.msg.YearStr + '-' + this.msg.MonthStr
      this.getList();
    },
    methods: {
      //下载文件
      downloadStudentMarket() {
        this.loading = true;
        var msg = JSON.parse(JSON.stringify(this.msg));
        EduDownLoad(
          "/StudentStat/DownLoadStudentMarket",
          msg,
          "市场部每日数据统计.xls", res => {
            this.loading = false;
          }
        );
      },
      getCheckDate() {
        if (this.myDate) {
          this.msg.YearStr = this.myDate.split('-')[0];
          this.msg.MonthStr = this.myDate.split('-')[1];
          this.getList();
        }
      },
      //获取数据
      getList() {
        this.loading = true;
        GetStudentMarket(this.msg).then(res => {
          this.loading = false;
          if (res.Code == 1) {
            this.dataList = res.Data;
          }
        })
      }
    }
  }
</script>
<style lang="sass">
  @import url('~assets/css/table.sass')
</style>