<template>
  <div class="app-table">

    <div class="table">
      <el-table
        :key="table.tableKey"
        v-loading="table.listLoading"
        :element-loading-text="$t('common.tableMsg')"
        :data="table.list"
        border
        fit
        highlight-current-row
        style="width: 100%;"
        :row-style="rowStyle"
        :cell-style="cellStyle"
        class="elTable table-fixed"
      >
        <el-table-column :key="1" :label="$t('formulationEvaluation.xh')" prop="sort" align="center" width="50px" />
        <el-table-column :key="2"  :label="$t('errorAnalysis.isHouseName')"  prop="barname" min-width="90px" align="center" />
        <el-table-column :key="3" label="第一层" min-width="90px" align="center">
          <el-table-column label="比例 (%)" prop="onerate" min-width="90px" align="center" />
          <el-table-column label="重量 (g)" prop="oneweight" min-width="90px" align="center" />
        </el-table-column>
        <el-table-column :key="4" label="第二层" min-width="90px" align="center">
          <el-table-column label="比例 (%)" prop="tworate" min-width="90px" align="center" />
          <el-table-column label="重量 (g)" prop="twoweight" min-width="90px" align="center" />
        </el-table-column>
        <el-table-column :key="5" label="第三层" min-width="90px" align="center">
          <el-table-column label="比例 (%)" prop="threerate" min-width="90px" align="center" />
          <el-table-column label="重量 (g)" prop="threeweight" min-width="90px" align="center" />
        </el-table-column>

      </el-table>
      <Pagination v-show="table.total>0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
    </div>

  </div>
</template>

<script>
import { GetDataByName } from '@/api/common'
import draggable from 'vuedraggable'
import Cookies from 'js-cookie'
import { parseTime } from '@/utils/index.js'
import Pagination from '@/components/Pagination'
export default {
  name: 'MaterialIssuancePlan',
  display: 'Two list header slot',
  order: 14,
  components: { Pagination },
  data() {
    return {
      table: {
        getdataListParm: {
          name: 'getDungHistory',
          page: 1,
          offset: 1,
          pagecount: 12,
          returntype: 'Map',
          parammaps: {
            pastureid: Cookies.get('pastureid'),
            operatetime: ''
          }
        },
        list: [],
        total: 0,
        tableKey: 0,
        listLoading: false,
        temp: {},
        changeList: [],
        startObj: {}
      },

      textMap: {
        seeHistory: '粪便筛修改记录'
      },
      seeHistory: {
        dialogFormVisible: false, dialogStatus: '',
        total: 0, tableKey: 0, listLoading: false,
        getdataListParm: {
          name: 'getDungHistoryBar', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
          parammaps: {
            pastureid: Cookies.get('pastureid'),
            barid: '',
            inputDatetime: '',
            time1: '',
            time2: ''
          }
        }
      },

      rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
      cellStyle: { padding: 0 + 'px' }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    changeDate() {
      this.getList()
    },
    getList() {
      this.table.listLoading = true
      GetDataByName(this.table.getdataListParm).then(response => {
        console.log('table数据', response.data.list)
        if (response.data.list !== null) {
          this.table.list = response.data.list
          this.table.pageNum = response.data.pageNum
          this.table.pageSize = response.data.pageSize
          this.table.total = response.data.total
        } else {
          this.table.list = []
        }
        setTimeout(() => {
          this.table.listLoading = false
        }, 100)
      })
    },

    form_search() {
      if (this.table.getdataListParm.parammaps.operatetime == '' || this.table.getdataListParm.parammaps.operatetime == null ) {
        this.table.getdataListParm.parammaps.operatetime = ''
      } else {
        this.table.getdataListParm.parammaps.operatetime = parseTime(this.table.getdataListParm.parammaps.operatetime, '{y}-{m}-{d}')
      }
      this.getList()
    },
    handleRefresh() {
      this.table.getdataListParm.parammaps.operatetime = ''
      this.getList()
    },


  }
}
</script>

<style  lang="scss" scoped>
 .search{margin-bottom: 10px;}
</style>
