<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="物资类型" prop="maType">
            <el-input
              v-model="queryParams.maType"
              placeholder="请输入物资名称"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="物资名称" prop="maName">
            <el-input
              v-model="queryParams.maName"
              placeholder="请输入物资名称"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>

          <el-form-item label="规格型号" prop="maModel">
            <el-input
              v-model="queryParams.maModel"
              placeholder="请输入规格型号"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </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-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              >导出
            </el-button>
          </el-col>
          <right-toolbar
            :showSearch.sync="showSearch"
            @queryTable="getList"
          ></right-toolbar>
        </el-row>

        <el-table
          v-loading="loading"
          :data="typeList"
          row-key="id"
          border
        >
          <el-table-column label="序号" align="center" width="80" type="index">
                <template slot-scope="scope">
                    <span>{{(queryParams.pageNum - 1) * 10 + scope.$index + 1}}</span>
                </template>
            </el-table-column>
          <el-table-column
            label="物资类型"
            align="center"
            key="maType"
            prop="maType"
            show-overflow-tooltip
          />
          <el-table-column
            label="物资名称"
            align="center"
            key="maName"
            prop="maName"
            show-overflow-tooltip
          />
          <el-table-column
            label="规格型号"
            align="center"
            key="maModel"
            prop="maModel"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            label="修改前租赁价格(元)"
            align="center"
            key="beforePrice"
            prop="beforePrice"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            label="修改后租赁价格(元)"
            align="center"
            key="afterPrice"
            prop="afterPrice"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            label="修改人"
            align="center"
            key="createBy"
            prop="createBy"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            label="修改时间"
            align="center"
            key="createTime"
            prop="createTime"
            show-overflow-tooltip
          >
          </el-table-column>
        </el-table>

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

  </div>
</template>

<script>

import {
  getMaTypeHistoryList,

} from "@/api/ma/base";

export default {
  name: "PriceHistory",

  data() {
    return {
      // 遮罩层
      loading: true,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,


      //列表数据
      typeList: undefined,
      // 是否显示弹出层
      open: false,
      // 弹出层标题
      title: "",

      // 日期范围
      dateRange: [],

      // 表单参数
      form: {
        companyId: "",
      },
      chosenTypeId: "",
      leasePrice: "",


      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        maType: undefined,
        maName: undefined,
        maModel: undefined,
      },
      companyId: undefined,

    };
  },

  created() {
    this.getList()
  },
  methods: {


    /** 查询列表 */
    getList() {
      this.loading = true;
      getMaTypeHistoryList(this.queryParams).then((response) => {
        this.typeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },


    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      // this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.pageNum = 1;
      this.queryParams.pageSize = 10;
      this.handleQuery();
    },

    /** 导出按钮作 */
    handleExport() {
      let queryTemp = this.queryParams;
      // queryTemp.level = 0;
      this.download(
        "/material/ma_type/exportHistory",
        {
          ...queryTemp,
        },
        `租赁价格历史信息_${new Date().getTime()}.xlsx`
      );
    },

  },
};
</script>
<style lang="scss" scoped>
::v-deep.el-table .fixed-width .el-button--mini {
  width: 60px !important;
  margin-bottom: 10px;
}

// 表格内文字样式
::v-deep .el-table {
  font-size: 14px;

  th {
    font-weight: 500;
    color: #303133;
  }

  td {
    color: #606266;
  }
}


</style>
