<template>
  <div class="record">
    <div>上传记录</div>
    <div class="searchBox">
      <div class="search_inside">
        <span><img src="" alt="" /></span>
        <input type="text" name="" id="" placeholder="请输入要搜索的资料名" />
        <button>搜索</button>
      </div>
    </div>
    <div class="sortBox">
      <div class="sort_inside">
        <span>是否下载</span>
        <select name="" id="">
          <option value="">不限</option>
          <option value="">是</option>
          <option value="">否</option>
        </select>
        <span>是否反馈</span>
        <select name="" id="">
          <option value="">不限</option>
          <option value="">是</option>
          <option value="">否</option>
        </select>
        <span>排序</span>
        <select name="" id="">
          <option value="">时间降序</option>
          <option value="">时间升序</option>
        </select>
      </div>
      <button>确定</button>
    </div>
    <div class="tableD">
      <UpLoadTable
        :trStyle="trStyle"
        :tableHeader="tableHeaderD"
        :tableData="tableData"
        :tableHeadStyle="tableHeadStyle"
        :operation="operation"
        :discolor="discolor"
        :flag="false"
      />
    </div>
    <div class="pageD">
      <Tablepage
        :totalPage="totalPage"
        :currentPage="currentPage"
        @change_page="changePage"
        @jump_page="jumpPage"
      />
    </div>
  </div>
</template>

<script>
import Tablepage from "../../components/TablePage";
import UpLoadTable from "../../components/Table";
export default {
  props: {
    isManufacturer: {
      type: String,
      default: "distributor",
    },
  },
  components: {
    Tablepage,
    UpLoadTable,
  },
  data() {
    return {
      tableHeaderD: [
        "资料名称",
        "时间类型",
        "传播类型",
        "上传时间",
        "下载状态",
        "反馈状态",
        "操作",
      ],
      operation: [
        {
          name: "下载",
          function: () => {
            this.download();
          },
        },
        {
          name: "反馈",
          function: () => {
            this.feedback();
          },
        },
        {
          name: "查看详情>",
          function: () => {
            this.showDetail();
          },
        },
      ],
      // 表格配置
      sum: 240, // 一共有多少条数据
      pageSize: 20, // 每页展示的数据
      discolor: false, // 是否隔行变色
      currentPage: 1,
      flag: 0,
      tableData: [
        {
          name: "北京博瑞",
          time: "2021/04",
          spread: "传播类型1",
          uploadTime: "",
          down: "50/20",
          feedback: "已反馈",
        },
        {
          name: "雷克萨斯纯电动SUV",
          time: "2021/04",
          spread: "传播类型1",
          uploadTime: "",
          down: "50/20",
          feedback: "已反馈",
        },
        {
          name: "a，续航可达400公里",
          time: "2021/04",
          spread: "传播类型1",
          uploadTime: "",
          down: "50/20",
          feedback: "已反馈",
        },
      ],
      tableHeadStyle: {
        background: "#848484",
        height: "30px",
        color: "white",
      },
      trStyle: {
        width: "150px",
        height: "30px",
        overflow: "hidden",
      },
    };
  },
  computed: {
    // 表格总页数
    totalPage() {
      return Math.ceil(this.sum / this.pageSize);
    },
  },
  methods: {
    showDetail: () => {
      alert("展示详情");
    },
    feedback: () => {
      alert("反馈");
    },
    download: () => {
      alert("下载");
    },
    // 获取某一页面的数据，展示在表格
    changePage: function (page) {
      this.currentPage = page;
      console.log(page);
    },
    // 点击上一页，下一页，首页，尾页
    jumpPage: function (item) {
      switch (item) {
        case 1:
          this.currentPage = 1;
          break;
        case 2:
          this.currentPage = this.currentPage - 1;
          break;
        case 3:
          this.currentPage = this.currentPage + 1;
          break;
        case 4:
          this.currentPage = this.totalPage;
          break;
      }
      console.log(this.currentPage);
    },
    submit: function () {
      console.log(this.totalPage);
      this.sum = this.sum + 1;
      console.log(
        this.inforName,
        this.inforDes,
        this.materialTime,
        this.range,
        this.addByCustomize
      );
    },
  },
};
</script>

<style scoped lang="less">
.searchBox {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  margin-left: 40px;
}

.sortBox {
  display: flex;
  justify-content: flex-end;
  height: 40px;
  align-items: center;
}
.sort_inside {
  display: flex;
  width: 400px;
  justify-content: space-between;
}
</style>
