<!--草稿箱-->
<template>
  <div class="draftPage">
    <div class="draftPage-min">
      <el-form :model="queryParamsData" class="form-box" ref="queryForm" :inline="true">
        <el-form-item label="关键字" prop="searchValue">
          <el-input
            style="width:210px;"
            maxLength="30"
            v-model="queryParamsData.searchValue"
            placeholder="编号/化学品名/实验室"
            clearable
            size="small"
          />
        </el-form-item>
        <el-form-item label="创建时间" prop="terminalStatus">
          <el-date-picker
            :clearable="false"
            v-model="dateRange"
            size="small"
            style="width: 220px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
          <p class="reset-button-one" @click="resetQuery">重置</p>
        </el-form-item>
        <el-form-item style="float: right;">
          <el-col :span="1.5">
            <p class="reset-button-one"
               @click="backPage"
            >返回</p>
          </el-col>
        </el-form-item>
      </el-form>
      <el-table  border :data="tableList"ref="multipleTable">
        <el-table-column label="申购编号" align="center" prop="applyNum" width="210" show-overflow-tooltip/>
        <el-table-column label="实验室" align="center" prop="subName" width="307" show-overflow-tooltip/>
        <el-table-column label="申购信息" align="center" prop="chemicalNames" show-overflow-tooltip/>
        <el-table-column label="创建时间" align="center" prop="createTime" width="200" show-overflow-tooltip/>
        <el-table-column label="操作" align="center" prop="operator" width="130">
          <template slot-scope="scope">
            <div class="button-box">
              <p class="table-min-button"
                 style="margin:0!important;"
                 @click="goPageInfo(2,scope.row)"
              >编辑</p>
              <p class="table-min-button"
                 style="margin:0!important;"
                 @click="goPageInfo(2,scope.row)"
              >删除</p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page-sizes="[20, 30, 40, 50]"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
  import { getHxpapplyMyDraftsList } from "@/api/studentApi/chemicalManagement/index";
  export default {
    name: "draftPage",
    data(){
      return{
        // 遮罩层
        loading:false,
        //页面状态
        pageType:1,
        // 创建时间
        dateRange:[],
        // 搜索数据
        queryParamsData:{
          pageNum:1,
          pageSize:20,
        },
        // 搜索实际发送数据
        queryParams:{
          pageNum:1,
          pageSize:20,
        },
        //数据数量
        total:0,
        //数据数组
        tableList:[],
      }
    },
    created() {

    },
    mounted(){
      this.getList();
    },
    methods: {
      //获取数据列表
      getList(){
        this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
        if(this.dateRange[0]){
          this.queryParamsData.beginCreateTime = this.dateRange[0];
          this.queryParamsData.endCreateTime = this.dateRange[1];
        }else {
          this.queryParamsData.beginCreateTime = null
          this.queryParamsData.endCreateTime = null
        }
        getHxpapplyMyDraftsList(this.queryParamsData).then(response => {
          this.total = response.total;
          this.tableList = response.rows;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParamsData.pageNum = 1;
        this.queryParamsData.pageSize = 20;
        this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.$set(this,'queryParamsData',{});
        this.$set(this,'queryParams',{});
        this.$set(this,'dateRange',[]);
        this.handleQuery();
      },
      //返回
      backPage(){
        this.$parent.pageToggle(1);
      },
    }
  }
</script>

<style scoped lang="scss">
  .draftPage{
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    p{
      margin:0;
      padding:0;
    }
    .draftPage-min{
      flex:1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      padding:20px;
      .button-box{
        display: flex;
      }
    }
  }
</style>
