<template>
  <div class="app-container">
    <div class="operation">
      <el-button class="success" @click="handleCreate">新增</el-button>
      <el-button class="danger" @click="handleDelete">删除</el-button>
      <el-button class="success" @click="handleFeedBank">饲料库</el-button>
    </div>

    <div class="search">
      <el-input v-model="table.getdataListParm.parammaps.assetCode" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
      <tree-select
        class="filter-item typeSelect"
        :height="150"
        :width="150"
        size="small"
        clearable
        :data="type.parentDept"
        :disabled="type.disabled"
        :placeholder="type.placeholder"
        style="display:inline-block;"
        :default-props="type.defaultProps"
        :node-key="type.nodeKey"
        :checked-keys="type.defaultCheckedKeys"
        @popoverHide="popoverHide"
      />
      <el-select v-model="table.getdataListParm.parammaps.enable" placeholder="饲料来源" class="filter-item" style="width: 120px;" clearable>
        <el-option v-for="item in feedSourcesList" :key="item.id" :label="item.name" :value="item.name" />
      </el-select>
      <el-select v-model="table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
        <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.name" />
      </el-select>
      <div ref="selectInput" class="filter-item selectInput">
        <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
        <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
        <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
        <ul v-if="arrowUp" class="selectUl">
          <li><a>允许误差数</a><el-input type="text" name="" value="" style="width: 245px;" /></li>
          <li><a>跳转重量域</a><el-input type="text" name="" value="" style="width: 245px;" /></li>
          <li>
            <a>跳转延时</a>
            <el-select v-model="table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 245px;" clearable>
              <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.name" />
            </el-select>
          </li>
          <li>
            <div style="float: right;">
              <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
              <el-button class="miniSuccess" @click="handleSearch">搜索</el-button>
            </div>
          </li>
        </ul>
      </div>

      <el-button class="successBorder" @click="handleSearch">查询</el-button>
      <el-button class="successBorder" @click="handleRefresh">重置</el-button>
    </div>

    <div class="table">
      <el-table
        :key="table.tableKey"
        v-loading="table.listLoading"
        element-loading-text="给我一点时间"
        :data="table.list"
        border
        fit
        highlight-current-row
        style="width: 100%;"
        :row-style="rowStyle"
        :cell-style="cellStyle"
        class="elTable table-fixed"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" align="center" width="50" />
        <el-table-column label="序号" align="center" type="index" width="50px">
          <template slot-scope="scope">
            <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="饲料名称" min-width="130px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="饲料分类" min-width="130px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="唯一编码" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="饲料来源" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="计划类型" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="允许误差数(kg)" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="包装单位重量(kg)" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="单价" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="跳转重量(kg)" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="跳转延时" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="确认开始" min-width="110px" align="center">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.confirmStart" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
          </template>
        </el-table-column>
        <el-table-column label="继电器位置" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="备用字段01" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="备用字段02" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="备用字段03" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.brandName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="是否启用" min-width="110px" align="center">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="{row}">
            <el-button class="miniSuccess" @click="handleNutritive (row)">营养价值</el-button>
            <el-button class="miniSuccess" @click="handleRelation(row)">关联</el-button>
            <el-button class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
            <el-button class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
          </template>
        </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>

    <!-- 新增/编辑 -->
    <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
      <div class="app-add">
        <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
          <el-row>
            <el-col :span="24">
              <h3 style="width: 160px;text-align: right;">基础信息</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="饲料名称:" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入饲料名称" type="textarea" :autosize="{ minRows:1}" maxlength="32" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="饲料类别:" prop="location">
                <tree-select
                  class="filter-item typeSelect"
                  :height="150"
                  :width="150"
                  size="small"
                  clearable
                  :data="type.parentDept"
                  :disabled="type.disabled"
                  :placeholder="type.placeholder"
                  style="display:inline-block;"
                  :default-props="type.defaultProps"
                  :node-key="type.nodeKey"
                  :checked-keys="type.defaultCheckedKeys"
                  @popoverHide="popoverHide"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="唯一编码:" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入唯一编码" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="饲料来源:" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="用户自定义" type="text" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="计划类型:" prop="location">
                <el-select v-model="create.temp.location" placeholder="计划类型" class="filter-item" style="width: 100%;">
                  <el-option v-for="item in create.planTypeList" :key="item.id" :label="item.name" :value="item.name" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="包装单位重量(kg):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="正整数" type="text" style="width: 100%;" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="单价:" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="最多俩位小数" type="text" style="width: 100%;" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="允许误差数(kg):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="正整数" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="跳转重量域(kg):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="最多俩位小数" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="跳转延时:" prop="location">
                <el-select v-model="create.temp.location" placeholder="跳转延时" class="filter-item" style="width: 100%;">
                  <el-option v-for="item in jumpDelayList" :key="item.id" :label="item.name" :value="item.name" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="确认开始:" prop="location">
                <el-select v-model="create.temp.location" placeholder="确认开始" class="filter-item" style="width: 100%;">
                  <el-option v-for="item in confirmStartList" :key="item.id" :label="item.name" :value="item.name" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="是否启用:" prop="location">
                <el-select v-model="create.temp.location" placeholder="是否启用" class="filter-item" style="width: 100%;">
                  <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.name" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="继电器位置:" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="继电器位置" type="text" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <h3 style="width: 160px;text-align: right;">备用字段</h3>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="备用字段01:" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="备用字段01" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="备用字段02:" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="备用字段02" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="备用字段03:" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="备用字段03" type="text" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button class="cancel" @click="create.dialogFormVisible = false; ">关闭</el-button>
          <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 饲料库/关联 -->
    <el-dialog :title="textMap[feedBank.dialogStatus]" :visible.sync="feedBank.dialogFormVisible" :close-on-click-modal="false" width="90%">
      <div class="app-add">
        <div class="search">
          <el-input v-model="feedBank.getdataListParm.parammaps.assetCode" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
          <el-select v-if="feedBank.dialogStatus==='feedBank'" v-model="feedBank.getdataListParm.parammaps.enable" placeholder="关联状态" class="filter-item" style="width: 120px;" clearable>
            <el-option v-for="item in associationStatusList" :key="item.id" :label="item.name" :value="item.name" />
          </el-select>
          <el-button class="successBorder" @click="handleFeedBankSearch">查询</el-button>
          <el-button class="successBorder" @click="handleFeedBankRefresh">重置</el-button>
        </div>
        <div class="table">
          <el-table
            :key="feedBank.tableKey"
            v-loading="feedBank.listLoading"
            element-loading-text="给我一点时间"
            :data="feedBank.list"
            border
            fit
            highlight-current-row
            style="width: 100%;margin: 0 auto 50px;"
            :row-style="rowStyle"
            :cell-style="cellStyle"
            class="elTable table-fixed"
          >
            <el-table-column label="序号" align="center" type="index" width="50px">
              <template slot-scope="scope">
                <span>{{ scope.$index + (feedBank.pageNum-1) * feedBank.pageSize + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column label="来源" min-width="90" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="中国饲料号" min-width="100px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="饲料名称" min-width="90px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="价格" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="样品说明" min-width="90px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="干物质(DM%)" min-width="70px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="淀粉(%DM)" min-width="70px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="粗蛋白(CP%DM)" min-width="75px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="钙(Ca%DM)" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="磷(P%DM)" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="产奶净能(%DM)" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="脂肪(%DM)" min-width="70px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="ADF(%DM)" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="NDF(%DM)" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="NDIP%" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="粗灰分(Ash%)" min-width="70px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="粗料" min-width="70px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brandName }}</span>
              </template>
            </el-table-column>
            <el-table-column v-if="feedBank.dialogStatus=='relation'" label="操作" min-width="70px" align="center">
              <template slot-scope="{row}">
                <el-button class="miniSuccess" @click="disassociateData (row)">取消关联</el-button>
                <el-button class="miniSuccess" @click="relationData(row)">关联</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>

        <div slot="footer" class="dialog-footer">
          <el-button class="cancel" @click="feedBank.dialogFormVisible = false; ">关闭</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 营养价值 -->
    <el-dialog :title="textMap[nutritive.dialogStatus]" :visible.sync="nutritive.dialogFormVisible" :close-on-click-modal="false" width="90%">
      <div class="app-add">
        <el-form ref="temp" :rules="nutritive.rules" :model="nutritive.temp" label-position="right" label-width="160px" style="width: 100%;margin:0 auto 50px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="干物质(DM%):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入干物质" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="淀粉(%DM):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入淀粉" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="粗蛋白(CP%DM):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入粗蛋白" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="钙(Ca%DM):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入钙" type="text" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="磷(P%DM):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入磷" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="产奶净能(%DM):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入产奶净能" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="脂肪(%DM):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入脂肪" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="ADF(%DM):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入ADF" type="text" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="NDF(%DM):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入NDF" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="NDIP(%):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入NDIP" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="粗灰分(Ash%):" prop="location">
                <el-input ref="location" v-model="create.temp.location" class="filter-item" placeholder="请输入粗灰分" type="text" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
          <el-button @click="nutritive.dialogFormVisible = false; ">关闭</el-button>
          <el-button v-if="nutritive.dialogStatus==='nutritive'" type="success" :disabled="isokDisable" @click="nutritiveData()">确认</el-button>
        </div>
      </div>
    </el-dialog>
  </div>

</template>

<script>
import { GetDataByName, transData } from '@/api/common'
import Pagination from '@/components/Pagination'
import TreeSelect from '@/components/TreeSelect'
export default {
  name: 'FeedTable',
  components: { Pagination, TreeSelect },
  data() {
    return {
      enableList: [{ id: 0, name: '是' }, { id: 1, name: '否' }], // 是否启用
      jumpDelayList: [{ id: 0, name: '禁用' }, { id: 1, name: '3秒' }, { id: 2, name: '6秒' }, { id: 3, name: '9秒' }], // 跳转延时
      feedSourcesList: [{ id: 0, name: '系统内置' }, { id: 1, name: '用户自定义' }], // 饲料来源
      confirmStartList: [{ id: 0, name: '禁用' }, { id: 1, name: '启用' }], // 确认开始
      associationStatusList: [{ id: 0, name: '是' }, { id: 1, name: '否' }], // 关联状态

      table: {
        tableKey: 0,
        list: [],
        total: 0,
        listLoading: true,
        getdataListParm: {
          name: 'getAssetList',
          page: 1,
          offset: 1,
          pagecount: 10,
          returntype: 'Map',
          parammaps: {
            enable: ''
          }
        }
      },

      // 饲料类别
      type: {
        getDeptListParm: { name: 'getpart_classList' },
        listType: [],
        parentDept: [],
        disabled: false,
        placeholder: '请选择饲料类别',
        defaultProps: {
          children: 'children',
          label: 'partClassNameCode'
        },
        nodeKey: 'id',
        defaultCheckedKeys: []
      },

      // 多项搜索显示隐藏
      arrowDown: true,
      arrowUp: false,

      // 新增/编辑
      create: {
        dialogFormVisible: false,
        dialogStatus: '',
        temp: {},
        planTypeList: [{ id: 0, name: '无' }, { id: 1, name: '铲车' }, { id: 2, name: '精料' }],
        rules: {}
      },

      // 关联/饲料库
      feedBank: {
        dialogFormVisible: false,
        dialogStatus: '',
        temp: {},
        rules: {},
        tableKey: 0,
        list: [],
        total: 0,
        listLoading: true,
        getdataListParm: {
          name: 'getAssetList',
          page: 1,
          offset: 1,
          pagecount: 10,
          returntype: 'Map',
          parammaps: {
            enable: ''
          }
        }
      },

      // 营养价值
      nutritive: {
        dialogFormVisible: false,
        dialogStatus: '',
        temp: {},
        rules: {}
      },

      textMap: {
        create: '新增',
        update: '编辑',
        feedBank: '饲料库',
        relation: '关联',
        nutritive: '营养价值'
      },

      isokDisable: false,
      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
      cellStyle: { padding: 0 + 'px' }

    }
  },
  mounted() {
    document.addEventListener('click', (e) => {
      if (this.$refs.selectInput !== undefined) {
        if (!this.$refs.selectInput.contains(e.target)) {
          this.arrowDown = true
          this.arrowUp = false
        } else {
          this.arrowDown = false
          this.arrowUp = true
        }
      }
    })
  },
  created() {
    this.getList()
    this.getTypeList()
  },

  methods: {
    getTypeList() {
      this.type.getDeptListParm.parammaps = this.deptform
      GetDataByName(this.type.getDeptListParm).then(response => {
        this.type.listType = response.data
        if (response.data.list !== null) {
          this.type.listType = transData(response.data.list, 'id', 'pid', 'children')
        }
        this.type.parentDept = this.type.listType
      })
    },
    popoverHide(checkedIds, checkedData) {
      console.log(checkedIds, checkedData)
      if (checkedIds !== null) {
        if (checkedData.childrens == 0) {
          console.log(checkedData)
        } else {
          this.type.defaultCheckedKeys = []
          this.$message({ type: 'warning', message: '请选择饲料子类别' })
        }
      } else {
        this.type.defaultCheckedKeys = []
      }
    },

    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)
      })
    },

    handleSearch() {
      console.log('点击了查询')
      this.getList()
      this.arrowDown = true
      this.arrowUp = false
    },
    handleRefresh() {
      console.log('点击了重置')
    },
    handleSelectionChange(val) {
      console.log('勾选数据', val)
    },
    resetTemp() {

    },
    // 新增
    handleCreate() {
      console.log('点击了新增')
      this.resetTemp()
      this.create.dialogStatus = 'create'
      this.create.dialogFormVisible = true
    },
    createData() {
      console.log('点击了新增保存')
    },
    // 饲料库
    handleFeedBank() {
      console.log('点击了饲料库')
      this.feedBank.dialogStatus = 'feedBank'
      this.feedBank.dialogFormVisible = true
      this.getFeedBankList()
    },
    getFeedBankList() {
      this.feedBank.listLoading = true
      GetDataByName(this.feedBank.getdataListParm).then(response => {
        console.log('table数据', response.data.list)
        if (response.data.list !== null) {
          this.feedBank.list = response.data.list
          this.feedBank.pageNum = response.data.pageNum
          this.feedBank.pageSize = response.data.pageSize
            this.feedBank.total = response.data.total
        } else {
          this.feedBank.list = []
        }
        setTimeout(() => {
          this.feedBank.listLoading = false
        }, 100)
      })
    },
    handleFeedBankSearch() {
      console.log('点击了饲料库搜索')
    },
    handleFeedBankRefresh() {
      console.log('点击了饲料库重置')
    },
    // 关联
    handleRelation(row) {
      console.log('点击了关联')
      this.feedBank.dialogStatus = 'relation'
      this.feedBank.dialogFormVisible = true
      this.getFeedBankList()
    },
    disassociateData() {
      console.log('点击了取消关联')
    },
    relationData() {
      console.log('点击了关联保存')
    },

    // 编辑
    handleUpdate(row) {
      console.log('点击了编辑')
      this.create.dialogStatus = 'update'
      this.create.dialogFormVisible = true
    },
    updateData() {
      console.log('点击了编辑保存')
    },

    // 营养价值
    handleNutritive(row) {
      console.log('点击了营养价值')
      this.nutritive.dialogStatus = 'nutritive'
      this.nutritive.dialogFormVisible = true
    },
    nutritiveData() {
      console.log('点击了营养价值保存')
    },

    // 行内删除
    handleRowDelete() {
      console.log('点击了行内删除')
    },

    // 多项删除
    handleDelete() {
      console.log('点击了删除')
    }
  }
}
</script>
<style lang="scss" scoped>
  .search{margin-top:10px;}
  .table{margin-top:10px;}
  $width:350px;
  $left:325px;
  .selectInput{
    position: relative;
    display: inline-block;
    .Input{width: $width;position: relative;}
    .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
    .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
    .selectUl{
      z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
      li{
        list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
        a{float:left;width: 80px;}
        a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
      }
    }
  }
 </style>
 <style lang="scss">
   .typeSelect span .el-popover__reference .el-input--suffix {
       .el-input__inner{
         height:40px !important;
       }
     }
 </style>