<template>
  <div class="mod-role">
    <div class="rect rect-form">
      <el-form size="mini" :inline="true" :model="dataForm">
        <!-- <el-form-item style="width: 100px">
          <el-select placeholder="猪舍"></el-select>
        </el-form-item>
        <el-form-item style="width: 100px">
          <el-select placeholder="单元"></el-select>
        </el-form-item>
        <el-form-item style="width: 100px">
          <el-select placeholder="栏期"></el-select>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.roleName" placeholder="角色名称" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.roleName" placeholder="角色名称" clearable></el-input>
        </el-form-item> -->
        <el-form-item>
          <el-button 
            icon="el-icon-search"
            @click="getDataList()">
            查 询
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="rect rect-table">
      <!-- <el-form size="mini" :inline="true" :model="dataForm">
        <el-form-item>
          <el-button 
            icon="el-icon-plus"
            v-if="isAuth('sys:role:save')" 
            type="primary" 
            @click="addOrUpdateHandle()">新 增</el-button>
          <el-button 
            icon="el-icon-delete"
            v-if="isAuth('sys:role:delete')" 
            type="danger" 
            @click="deleteHandle()" 
            :disabled="dataListSelections.length <= 0">删 除</el-button>
        </el-form-item>
      </el-form> -->
      <el-table
        :data="dataList"
        border
        stripe
        size="mini"
        height="587"
        v-loading="dataListLoading"
        style="width: 100%;"
        :header-cell-style="{background:'rgb(245,245,245)',color:'#000',height: '45px',fontSize: '13px',fontWeight: 'normal',borderBottom: '1px solid #ccc'}" 
        :cell-style="{color: '#888',fontSize: '13px'}">
        <!-- <el-table-column
          type="selection"
          header-align="center"
          align="center">
        </el-table-column> -->
        <el-table-column
          prop="eartagNo"
          header-align="center"
          align="center"
          label="耳标">
        </el-table-column>
        <el-table-column
          prop="pigHomeName"
          header-align="center"
          align="center"
          label="所属猪舍">
        </el-table-column>
        <el-table-column
          prop="unitName"
          header-align="center"
          align="center"
          label="所属单元">
        </el-table-column>
        <el-table-column
          prop="feedIntake"
          header-align="center"
          align="center"
          label="采食量">
        </el-table-column>
        <el-table-column
          prop="weight"
          header-align="center"
          align="center"
          label="当前重量">
        </el-table-column>
        <el-table-column
          prop="weightIncrease"
          header-align="center"
          align="center"
          label="体重增加量">
        </el-table-column>
        <el-table-column
          prop="date"
          header-align="center"
          align="center"
          label="采集时间">
        </el-table-column>
        <!-- <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          label="操作">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
            <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <!-- <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> -->
    </div>
  </div>
</template>

<script>
  // import AddOrUpdate from './bfeed-add-or-update'
  export default {
    data () {
      return {
        dataForm: {
          roleName: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        // dataListSelections: [],
        // addOrUpdateVisible: false
      }
    },
    // components: {
    //   AddOrUpdate
    // },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/management/breedfeedweighe/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize
          })
        }).then(({data}) => {
          console.log('这是饲料种类配方');
          console.log(data);
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
            this.$message.error(data.msg)
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      // selectionChangeHandle (val) {
      //   this.dataListSelections = val
      // },
      // // 新增 / 修改
      // addOrUpdateHandle (id) {
      //   console.log(id);
      //   this.addOrUpdateVisible = true
      //   this.$nextTick(() => {
      //     this.$refs.addOrUpdate.init(id)
      //   })
      // },
      // // 删除
      // deleteHandle (id) {
      //   var ids = id ? [id] : this.dataListSelections.map(item => {
      //     return item.id
      //   })
      //   this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      //   }).then(() => {
      //     this.$http({
      //       url: this.$http.adornUrl('/management/breedfeedweighe/delete'),
      //       method: 'post',
      //       data: this.$http.adornData(ids, false)
      //     }).then(({data}) => {
      //       if (data && data.code === 0) {
      //         this.getDataList()
      //         this.$message({
      //           message: '操作成功',
      //           type: 'success',
      //           duration: 1500,
      //           // onClose: () => {
      //           //   this.getDataList()
      //           // }
      //         })
      //       } else {
      //         this.$message.error(data.msg)
      //       }
      //     })
      //   }).catch(() => {})
      // }
    }
  }
</script>
<style scoped>
.rect {
  background-color: #fff;
  padding: 30px 15px;
  border-radius: 5px;
  border: 1px solid #e8e8e8;
}
.rect-form {
  padding-bottom: 10px;
}
.rect-table {
  margin-top: 20px;
}
.demo-table-expand {
  font-size: 0;
  margin-left: 40px;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 80%;
}
.el-table .height {
  background: rgba(254, 254, 254, 0.5);
}
/deep/ .el-table--mini td, .el-table--mini th {
  padding: 3px 0 !important;
  height: 20px !important;
}
/deep/ .el-checkbox__input.is-checked+.el-checkbox__label {
  color: rgb(24,144,255);
  background-color: rgb(24,144,255);
  border-color: rgb(24,144,255);
}
/deep/.el-table .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  background-color: rgb(24,144,255);
  border-color: rgb(24,144,255);
}
/deep/.el-table .el-checkbox__inner:hover {
  border-color: rgb(24,144,255);
}
/deep/.el-table .el-checkbox__input.is-focus .el-checkbox__inner {
  border-color: rgb(24,144,255);
}
/deep/.el-table #select .cell .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  background-color: rgb(24,144,255);
  border-color: rgb(24,144,255);
}
</style>
