<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="['00:00:00', '23:59:59']"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table width="100%"  v-loading="loading" :data="quotsList" :row-class-name="rowQuotsIndex">
      <el-table-column label="序号" align="center" prop="index" width="80"/>
      <el-table-column label="quot_id" align="center" prop="quot_id" v-if="false"/>
      <el-table-column label="报价单号" width="260" align="center" prop="quotCode" />
      <el-table-column label="报价客户" width="200" align="center" prop="quotCustomer" />
      <el-table-column label="报价项目" width="200" align="center" prop="quotProject" />
      <el-table-column label="联系人"align="center" prop="quotLxr" />
      <el-table-column label="联系人电话"align="center" prop="quotLxrdh" />
      <el-table-column label="创建日期" width="200" align="center" prop="createTime" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  import { listQuots } from "@/api/redBook/redBook";

  export default {
      name: "quots",
      data() {
        return {
          // 遮罩层
          loading: true,
          // 显示搜索条件
          showSearch: true,
          // 总条数
          total: 0,
          //报价单数据
          quotsList: [],

          // 查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10
          },
        }
      },
      created() {
        this.getList();
      },
      methods: {
        /** 查询报价单列表 */
        getList() {
          this.loading = true;
          listQuots(this.queryParams).then(response => {
            this.quotsList = response.rows;
            this.total = response.total;
            this.loading = false;
          });
        },

        rowQuotsIndex({ row, rowIndex }) {
          row.index = rowIndex + 1;
        },
        /** 搜索按钮操作 */
        handleQuery() {
          this.queryParams.pageNum = 1;
          this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
          this.resetForm("queryForm");
          this.handleQuery();
        },
      }
    }
</script>

<style scoped>

</style>
