<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="thetopbox">
      <el-form label-width="100px">
        <el-row>
          <el-col :span="4">
            <el-form-item :label="'订单日期'" prop="payTime">
              <el-date-picker
                v-model="queryParams.payTime"
                type="date"
                value-format="yyyy-MM-dd"
                :placeholder="'请选择'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <div class="searchbox">
              <el-button
                class="my_search"
                @click="
                  () => {
                    getSearch();
                    getCzNum();
                  }
                "
              >
                {{ '搜索' }}</el-button
              >
              <el-button class="my_reset" @click="reChongzhi">
                {{ '重置' }}</el-button
              >
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="main">
      <div class="maintop">
        <div class="mainbtn">
          <el-button  v-hasButtons="['newLcExport']" size="small" class="thebtn2" @click="handleExport">
            {{ '导出' }}</el-button
          >
        </div>
      </div>
      <div class="maintable">
        <el-table
          v-loading="loading"
          :data="tableData"
          height="720px"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
          @selection-change="handleSelectionChange"
        >
          <el-table-column prop="colsele" type="selection" width="55">
          </el-table-column>
          <el-table-column
            align="center"
            prop="vertexCode"
            :label="'体系编号'"
            min-width="100px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="vertexName"
            :label="'体系名称'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="firstPurchaseMo"
            min-width="120px"
            :label="'首购新增金额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="firstPurchasePv"
            min-width="120px"
            :label="'首购新增业绩' + `(PV)`"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="repurchaseMo"
            min-width="120px"
            :label="'复购新增金额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="repurchasePv"
            min-width="120px"
            :label="'复购新增业绩' + `(PV)`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="firstPurchaseSumMo"
            min-width="120px"
            :label="'首购累计金额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="firstPurchaseSumPv"
            :label="'首购累计业绩' + `(PV)`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="repurchaseSumMo"
            min-width="120px"
            :label="'复购累计金额' + `(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="repurchaseSumPv"
            :label="'复购累计业绩' + `(PV)`"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="payTime"
            min-width="120px"
            :label="'订单日期'"
          >
          </el-table-column>
        </el-table>
      </div>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getSearch"
    />
  </div>
</template>
          
    <script>
import topBar from "@/components/topBar";
import * as sta from "@/api/statistics";
import { isLocals, isLocalSymbol } from "@/utils/numberToCurrency";
export default {
  name: "NewLc",
  components: {
    topBar,
  },
  filters: {
    numFilter(value) {
      // 截取当前数据到小数点后两位
      let realVal = parseFloat(value).toFixed(2);
      return realVal;
    },
  },
  data() {
    return {
      moren: "newLc",
      topList: [
        {
          name: '联创',
          path: "lcDataReport",
        },
        {
          name: '国内业绩查询',
          path: "chPvInquiry",
        },
        {
          name: '海外业绩汇总',
          path: "othPvInquiry",
        },
        {
          name: "新联创",
          path: "newLc",
        },
      ],
      tableData: [],
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      total: 0,
      multipleSelection: [],
      multiple: true,

      loading: false,
    };
  },
  created() {
    // this.getSearch();
  },
  methods: {
    isLocalSymbol,
    isLocals,
    //导出
    handleExport() {
      this.$confirm('是否确认导出所有数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: "warning",
      }).then((_) => {
        this.download(
          "/report/manager/cu-lianchuang-data-stat/exportHistory",
          { ...this.queryParams },
          `新联创${new Date().getTime()}.xlsx`
        );
      });
    },

    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.multiple = !val.length;
    },
    reChongzhi() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
      };
      this.getSearch();
      this.getCzNum();
    },
    getSearch() {
      this.loading = true;
      sta.getNewLcList(this.queryParams).then((res) => {
        this.loading = false;
        if (res.code == 200) {
          this.tableData = res.rows;
          this.total = res.total;
        }
      });
    },
    getCzNum() {
      this.queryParams.pageNum = 1;
    },
  },
};
</script>
          
   <style lang="scss" scoped>
::v-deep .scopebtn {
  padding: 0;
}
::v-deep .el-image-viewer__close {
  right: 500px;
}
::v-deep .dizhi .el-cascader {
  width: 100%;
}
::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}
.page {
  padding: 10px 20px;
  background: #f9f9f9;
  font-size: 14px;
  .thetopbox {
    padding: 15px 20px 15px 0;
    background: #ffffff;
    border-radius: 8px;
    .searchbox {
      display: flex;
      align-items: center;
      margin-left: 40px;
    }
    .searchtitle {
      margin-right: 10px;
    }
    .searchbtn {
      background: #08143f;
      color: #ffffff;
    }
  }
  .main {
    //margin-top: 20px;
    background: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);

    .maintop {
      display: flex;
      // padding: 10px 0;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn2 {
          color: #ffffff;
          background: #ffad41;
          width: 68px;
          height: 32px;
        }
        .thebtn1 {
          color: #ffffff;
          background: #48b2fd;
          width: 68px;
          height: 32px;
        }
        .thebtn3 {
          color: #ffffff;
          background: #c8161d;
          width: 68px;
          height: 32px;
        }
      }
    }
  }
  .flex_div {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    border-top: 4px solid rgba(0, 0, 0, 0.1);
    .flex_left {
      border-right: 4px solid rgba(0, 0, 0, 0.1);
    }
    .flexs1 {
      flex: 1;
      padding: 10px;

      .left_top {
        display: flex;
        align-items: center;
      }
    }
  }
  .flex_main {
    border: 1px solid #cccccc;
    padding: 10px;
    border-radius: 10px 10px 10px 10px;
    min-height: 300px;
    margin: 10px 0;
  }
  .atext {
    text-align: center;
    font-size: 18px;
    font-family: PingFang SC-Semibold, PingFang SC;
    font-weight: 600;
    color: #000000;
  }
}
::v-deep .el-date-editor--date {
  width: 100%;
}
</style>
          