<template>
  <div class="app-container">
    <el-form :inline="true">
      <el-form-item label="条码" prop="Code">
        <el-input v-model="pagerDto._Eq_Code" />
      </el-form-item>
      <el-form-item label="操作员" prop="OperationUser">
        <el-select
          v-model="pagerDto._Eq_OperationUser"
          placeholder="操作人"
          clearable
          filterable
        >
          <el-option
            v-for="item in operationUsers"
            :key="item.NickName"
            :label="item.NickName"
            :value="item.Id"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <div class="block">
          <el-date-picker
            v-model="operationTime"
            type="daterange"
            range-separator="至"
            start-placeholder="操作开始日期"
            value-format="yyyy-MM-dd"
            end-placeholder="操作结束日期"
          />
        </div>
      </el-form-item>
      <el-form-item>
        <el-button
          :loading="loading"
          icon="el-icon-search"
          size="small"
          type="primary"
          @click="pagerSerach()"
        >搜索</el-button>
      </el-form-item>
      <el-form-item>
        <el-button
          size="small"
          type=""
          icon="el-icon-download"
          @click="out()"
        >导出</el-button>
      </el-form-item>
    </el-form>
    <div>
      <el-table :data="sData" border height="660">
        <el-table-column label="操作人" prop="OperationUserName" width="100" />
        <el-table-column label="条码" prop="Code" width="400" />
        <el-table-column label="操作时间" prop="OperationTime" />
        <el-table-column label="称重" prop="Weight" width="100" />
        <el-table-column label="长" prop="Length" width="100" />
        <el-table-column label="宽" prop="Width" width="100" />
        <el-table-column label="高" prop="Height" width="100" />
        <el-table-column label="操作结果" prop="RetMsg" />
        <el-table-column label="设备ID" prop="DeviceId" />
      </el-table>
      <el-pagination
        :hide-on-single-page="true"
        :page-sizes="[100, 200, 300, 400]"
        :current-page="pagerDto.PageIndex"
        :page-size="pagerDto.PageSize"
        background
        layout="prev, pager, next ,total ,jumper,sizes,slot "
        :total="pagerDto.total"
        @current-change="pagerSerach"
      />
    </div>
  </div>
</template>
<script>
import { _getOperationName, _getUserInfos } from '@/api/baseInfo'
import { _getWeightingLogs, _outWeightingLogs } from '@/api/userwork'

export default {
  name: 'WeightingLog',
  data() {
    return {
      loading: false,
      operationTime: [],
      operationUsers: [],
      sData: [],
      pagerDto: {
        PageIndex: 1,
        PageSize: 100,
        total: 0,
        QuerySort: [{ Field: 'Id', IsDesc: true }],
        _Eq_Code: '',
        _Eq_OperationUser: '',
        OperationTime: '',
        _GrE_OperationTime: '',
        _LeE_OperationTime: ''
      }
    }
  },
  created() {
    _getUserInfos('行运易').then((response) => {
      this.operationUsers = response
    })
  },
  methods: {
    pagerSerach(page) {
      this.loading = true
      this.pagerDto._GrE_OperationTime = this.operationTime[0]
      this.pagerDto._LeE_OperationTime = this.operationTime[1]
      if (page && page > 0) this.pagerDto.PageIndex = page
      else this.pagerDto.PageIndex = 1
      _getWeightingLogs(this.pagerDto).then((response) => {
        this.sData = response.Result
        this.pagerDto.total = response.TotalCount
        this.loading = false
      })
    },
    out() {
      _outWeightingLogs(this.pagerDto)
    }
  }
}
</script>
