<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
      <el-form-item label="肉商" prop="keyword">
        <el-input
          v-model="queryParams.keyword"
          placeholder="请输入肉商"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="日期" prop="produceTime">
        <el-date-picker clearable
          v-model="queryParams.produceTime"
          type="date"
            value-format="yyyy-MM-dd"
          placeholder="请选择日期">
        </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-row :gutter="10" class="mb8">
      <el-col :span="1.5">
       </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="reportList">
      <el-table-column label="屠宰日期" align="center" prop="dateTag" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dateTag,"{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="肉商" align="center" prop="purchaserName" min-width="220"/>
      <el-table-column label="数量(头)" align="center" prop="totalAmount" width="120"/>
      <el-table-column label="白条重量(kg)" align="center" prop="totalSideWeight" />
      <el-table-column label="猪头重量(kg)" align="center" prop="totalHeadWeight" />
      <el-table-column label="红脏重量(kg)" align="center" prop="totalRedWeight" />
      <el-table-column label="白脏重量(kg)" align="center" prop="totalWhiteWeight" />
      <el-table-column label="销售去向" align="center" prop="salePlace" width="120">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.app_origin_type" :value="scope.row.salePlace"/>
        </template>
      </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 { listGetWeightReport } from "@/api/app/dataReport";

export default {
  name: "WeightReport",
  dicts: ['app_origin_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      reportList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        produceTime: null,
        keyword: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      listGetWeightReport(this.queryParams).then(response => {
        this.reportList = response.rows;

        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
