<template>
  <div class="app-container">
    <div class="filter-container">
      <!-- 搜索条件 -->
      <el-select v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 120px;">
        <el-option
          v-for="item in findAllPasture"
          :key="item.id"

          :label="item.name"
          :value="item.name"
        />
      </el-select>
      <el-select v-model="getdataListParm.parammaps.deptName" clearable placeholder="部门" class="filter-item" style="width: 120px;">
        <el-option
          v-for="item in findAllDepart"
          :key="item.id"
          :label="item.name"
          :value="item.name"
        />
      </el-select>
      <el-select v-model="getdataListParm.parammaps.status" clearable placeholder="状态" class="filter-item" style="width: 120px;">
        <el-option
          v-for="item in getDictByName"
          :key="item.id"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
      <el-date-picker
        v-model="getdataListParm.parammaps.createTime"
        type="date"
        placeholder="录入时间"
        style="width:140px;top:-3px;"
        format="yyyy-MM-dd"
        value-format="yyyy-MM-dd"
      />
      <el-input
        v-model="getdataListParm.parammaps.assetNumber"
        placeholder="内部编号"
        style="width: 120px;"
        class="filter-item"
      />
      <el-input
        v-model="getdataListParm.parammaps.assetName"
        placeholder="设备名称"
        style="width: 120px;"
        class="filter-item"
      />
      <el-button
        v-waves
        class="filter-item"
        type="primary"
        icon="el-icon-search"
        @click="form_search"
      >搜索</el-button>
      <div>
        <el-button
          v-if="isBasicsAdd"
          class="filter-item"
          type="primary"
          icon="el-icon-edit"
          @click="form_add"
        >新增</el-button>
      </div>
    </div>

    <el-table
      :key="tableKey"
      v-loading="listLoading"
      element-loading-text="给我一点时间"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%;"
      :row-style="rowStyle"
      :cell-style="cellStyle"
      class="elTable"
    >
      <el-table-column label="序号" align="center" type="index" width="50px">
        <template slot-scope="scope">
          <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="牧场" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.pastureName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="设备编号" width="130px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.equipmentNumber }}</span>
        </template>
      </el-table-column>
      <el-table-column label="内部编号" min-width="100px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.assetNumber }}</span>
        </template>
      </el-table-column>
      <el-table-column label="设备名称" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.equipmentName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="规格" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.specification }}</span>
        </template>
      </el-table-column>
      <el-table-column label="品牌" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.providerName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.status }}</span>
        </template>
      </el-table-column>
      <el-table-column label="部门" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.deptName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="责任人" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.employeName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="录入时间" min-width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.lrTime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="{row}">
          <el-popover
            placement="right"
            width="170"
            trigger="click"
          >
            <div>
              <el-button
                v-if="isBasicsUpdate"
                type="success"
                size="mini"
                @click="form_edit(row)"
              >编辑
              </el-button>
              <el-button
                v-if="isBasicsDel"
                type="danger"
                size="mini"
                @click="form_delete(row)"
              >删除
              </el-button>
            </div>
            <el-button slot="reference" size="mini">操作</el-button>
          </el-popover>
          <el-button
            v-if="isBasicsCard"
            type="info"
            size="mini"
            @click="handleCard(row)"
          >卡片</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="getdataListParm.offset"
      :limit.sync="getdataListParm.pagecount"
      @pagination="get_table_data"
    />
    <!-- 弹出层新增 -->
    <el-dialog
      :title="textMap[dialogStatus]"
      :visible.sync="dialogFormVisible"
      :close-on-click-modal="false"
    >
      <div class="app-content">
        <el-form
          ref="temp"
          :rules="rules"
          :model="temp"
          label-position="right"
          label-width="110px"
          style="width: 800px; margin-left:50px;margin-bottom:30px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item label="设备类别" prop="assTypeId">
                <tree-select
                  :height="400"
                  :width="330"
                  size="small"
                  :data="parentClass"
                  :default-props="defaultProps"
                  :node-key="nodeKey"
                  :disabled="dialogStatus==='update'"
                  :checked-keys="defaultCheckedKeys"
                  style="width:330px;"
                  clearable
                  @popoverHide="popoverHide"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="品牌" prop="providerId">
                <el-autocomplete
                  v-model="temp.providerName"
                  style="width:350px"
                  value-key="name"
                  class="inline-input"
                  :fetch-suggestions="providerSearch"
                  placeholder="请输入内容"
                  @select="handleSelect"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="资产编号" prop="equipmentNumber">
                <el-input
                  ref="equipmentNumber"
                  v-model="temp.equipmentNumber"
                  disabled
                  @popoverHide="popoverHide"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="设备名称" prop="equipmentName">
                <el-input
                  ref="equipmentName"
                  v-model="temp.equipmentName"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="内部编号" prop="assetNumber">
                <el-input
                  ref="assetNumber"
                  v-model="temp.assetNumber"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="规格" prop="specification">
                <el-input
                  ref="specification"
                  v-model="temp.specification"
                />
              </el-form-item>
            </el-col>
            <!-- <el-col :span="8">
              <el-form-item label="品牌" prop="providerId">
                <el-autocomplete
                  v-model="temp.providerName"
                  value-key="name"
                  class="inline-input"
                  :fetch-suggestions="providerSearch"
                  placeholder="请输入内容"
                  @select="handleSelect"
                />
              </el-form-item>
            </el-col> -->
            <el-col :span="8">
              <el-form-item label="用途" prop="purpose">
                <el-input ref="purpose" v-model="temp.purpose" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="状态" prop="status">
                <el-select v-model="temp.status" placeholder="状态" class="filter-item">
                  <el-option
                    v-for="item in getDictByName"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="牧场" prop="pastureId">
                <el-select v-model="temp.pastureId" placeholder="牧场" class="filter-item">
                  <el-option
                    v-for="item in findAllPasture"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="部门" prop="departmentId">
                <el-select v-model="temp.departmentId" placeholder="部门" class="filter-item">
                  <el-option
                    v-for="item in findAllDepart"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="负责人" prop="employeId">
                <el-select ref="employeId" v-model="temp.employeId" placeholder="负责人" class="filter-item">
                  <el-option
                    v-for="item in findAllEmploye"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="购置日期" prop="purchaseDate">
                <el-date-picker
                  v-model="temp.purchaseDate"
                  type="date"
                  placeholder="选择日期"
                  style="width:170px;"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                />
              <!-- <el-input ref="deptname" v-model="temp.purchaseDate" @keyup.enter.native="deptenter" /> -->
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="入场日期" prop="entranceDate">
                <el-date-picker
                  v-model="temp.entranceDate"
                  type="date"
                  placeholder="选择日期"
                  style="width:170px;"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="财务编号" prop="financeNumber">
                <el-input
                  ref="financeNumber"
                  v-model="temp.financeNumber"
                  @keyup.enter.native="deptenter"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="总保养费用" prop="yearUpkeepCost">
                <el-input
                  ref="yearUpkeepCost"
                  v-model="temp.yearUpkeepCost"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="总维修费用" prop="yearMaintainDost">
                <el-input
                  ref="yearMaintainDost"
                  v-model="temp.yearMaintainDost"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="原值" prop="yuanzhi">
                <el-input ref="yuanzhi" v-model="temp.yuanzhi" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="录入人" prop="employeId">
                <el-select ref="employeId" v-model="temp.employeId" placeholder="录入人" class="filter-item">
                  <el-option
                    v-for="item in findAllEmploye"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="录入时间" prop="inputDatetime">
                <el-date-picker
                  v-model="temp.inputDatetime"
                  type="date"
                  placeholder="录入时间"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  disabled
                  style="width:170px;"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:30px">
          <el-button
            v-if="dialogStatus==='create'"
            ref="createb"
            type="success"
            @click="add_dialog_save_again()"
          >确认新增</el-button>
          <el-button type="primary" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">确认</el-button>
          <el-button @click="dialogFormVisible = false">关闭</el-button>
        </div>
      </div>
    </el-dialog>
    <!-- 卡片 -->
    <el-dialog
      :title="textMap[dialogStatusCard]"
      :visible.sync="dialogFormVisibleCard"
      :close-on-click-modal="false"
    >
      <div class="app-contentcard">
        <div style="position: absolute;top:20px;left:150px;font:18px/24px '' ;color:#303133;">
          <span style="margin:0 10px;">设备名称：{{ temp.equipmentName }}</span>
          <span>内部编号:{{ temp.assetNumber }}</span>
        </div>
        <div class="card" style="width:100%;margin:0 auto">
          <el-tabs v-model="activeName">
            <el-tab-pane label="基础信息" name="six">
              <el-form
                ref="temp"
                :rules="rules"
                :model="temp"
                label-position="right"
                label-width="100px"
                style="width: 800px;margin-bottom:30px"
              >
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="资产编号" prop="equipmentNumber">
                      <el-input
                        v-model="temp.equipmentNumber"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="设备名称" prop="equipmentName">
                      <el-input
                        v-model="temp.equipmentName"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="状态" prop="status">
                      <el-select v-model="temp.status" placeholder="状态" class="filter-item" disabled>
                        <el-option
                          v-for="item in getDictByName"
                          :key="item.id"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="规格" prop="specification">
                      <el-input
                        ref="specification"
                        v-model="temp.specification"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="品牌" prop="providerId">
                      <el-autocomplete
                        v-model="temp.providerName"
                        value-key="name"
                        class="inline-input"
                        :fetch-suggestions="providerSearch"
                        placeholder="请输入内容"
                        disabled
                        @select="handleSelect"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="用途" prop="purpose">
                      <el-input ref="purpose" v-model="temp.purpose" disabled />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="牧场" prop="pastureId">
                      <el-select v-model="temp.pastureId" placeholder="牧场" class="filter-item" disabled>
                        <el-option
                          v-for="item in findAllPasture"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="部门" prop="departmentId">
                      <el-select v-model="temp.departmentId" placeholder="部门" class="filter-item" disabled>
                        <el-option
                          v-for="item in findAllDepart"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="负责人" prop="employeId">
                      <el-select v-model="temp.employeId" placeholder="负责人" class="filter-item" disabled>
                        <el-option
                          v-for="item in findAllEmploye"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="购置日期" prop="purchaseDate">
                      <el-date-picker
                        v-model="temp.purchaseDate"
                        type="date"
                        placeholder="选择日期"
                        style="width:170px;"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        disabled
                      />
                    <!-- <el-input ref="deptname" v-model="temp.purchaseDate" @keyup.enter.native="deptenter" /> -->
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="入场日期" prop="entranceDate">
                      <el-date-picker
                        v-model="temp.entranceDate"
                        type="date"
                        placeholder="选择日期"
                        style="width:170px;"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="内部编号" prop="assetNumber">
                      <el-input
                        v-model="temp.assetNumber"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="总保养费用" prop="yearUpkeepCost">
                      <el-input
                        ref="yearUpkeepCost"
                        v-model="temp.yearUpkeepCost"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="总维修费用" prop="yearMaintainDost">
                      <el-input
                        ref="yearMaintainDost"
                        v-model="temp.yearMaintainDost"
                        disabled
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="原值" prop="yuanzhi">
                      <el-input ref="yuanzhi" v-model="temp.yuanzhi" disabled />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="设备类别" prop="typeName">
                      <el-input ref="typeName" v-model="temp.typeName" disabled />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="财务编号" prop="financeNumber">
                      <el-input
                        ref="financeNumber"
                        v-model="temp.financeNumber"
                        disabled
                        @keyup.enter.native="deptenter"
                      />
                    </el-form-item>
                  </el-col> <el-col :span="8">
                    <el-form-item label="录入时间" prop="inputDatetime">
                      <el-date-picker
                        v-model="temp.inputDatetime"
                        type="date"
                        placeholder="录入时间"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        disabled
                        style="width:170px;"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="点检记录" name="first">
              <el-table
                :key="tableKey"
                v-loading="listLoadingSpotCheck1"
                element-loading-text="给我一点时间"
                :data="listAssetSpotCheck1"
                border
                fit
                highlight-current-row
                style="width: 100%;"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable"
              >
                <!-- table表格 -->
                <el-table-column label="序号" align="center" type="index" width="50px">
                  <template slot-scope="scope">
                    <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="点检日期" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.date }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="点检人" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.empname }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="点检结果" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.inspectionResults }}</span>
                  </template>
                </el-table-column>

                <!-- <el-table-column label="部门" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.stand }}</span>
                  </template>
                </el-table-column> -->
              </el-table>
              <!-- 分页 -->
              <pagination
                v-show="total>0"
                :total="totalSpotCheck1"
                :page.sync="getdataListParmGetAssetSpotCheck1.offset"
                :limit.sync="getdataListParmGetAssetSpotCheck1.pagecount"
                @pagination="getSportCheck"
              />
            </el-tab-pane>
            <el-tab-pane label="保养记录" name="second">
              <el-table
                :key="tableKey"
                v-loading="listLoadingMaintain1"
                element-loading-text="给我一点时间"
                :data="listAssetMaintain1"
                border
                fit
                highlight-current-row
                style="width: 100%;"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable"
              >
                <!-- table表格 -->
                <el-table-column label="序号" align="center" type="index" width="50px">
                  <template slot-scope="scope">
                    <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="计划名称" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.pastureName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="保养类型" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="保养设定" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.pastureName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="日期" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件领用状态" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="领用单号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="保养状态" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
              </el-table>
              <!-- 分页 -->
              <pagination
                v-show="total>0"
                :total="totalMaintain1"
                :page.sync="getdataListParmGetAssetMaintain1.offset"
                :limit.sync="getdataListParmGetAssetMaintain1.pagecount"
                @pagination="getMaintain1"
              />
            </el-tab-pane>
            <el-tab-pane label="维修记录" name="third">
              <el-table
                :key="tableKey"
                v-loading="listLoadingMaintain1"
                element-loading-text="给我一点时间"
                :data="listAssetMaintain1"
                border
                fit
                highlight-current-row
                style="width: 100%;"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable"
              >
                <!-- table表格 -->
                <el-table-column label="序号" align="center" type="index" width="50px">
                  <template slot-scope="scope">
                    <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="维修单编号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.repairNumber }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="申请人" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.applyName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="申请时间" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.applyTime }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="故障部位" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="故障现象" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.appearanceName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="故障详情" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.details }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="维修时间" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.dealTime }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="处理结果" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.checkResult }}</span>
                  </template>
                </el-table-column>
              </el-table>
              <!-- 分页 -->
              <pagination
                v-show="total>0"
                :total="totalMaintain1"
                :page.sync="getdataListParmGetAssetMaintain1.offset"
                :limit.sync="getdataListParmGetAssetMaintain1.pagecount"
                @pagination="getMaintain1"
              />
            </el-tab-pane>
            <el-tab-pane label="设备启停记录" name="fouth">
              <div class="filter-container">
                <!-- 搜索条件 -->
                <el-date-picker
                  v-model="getdataListParmGetAssetSTT1.parammaps.enabledTime"
                  type="date"
                  placeholder="启用时间"
                  style="width:170px;top:-3px;"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                />
                <el-date-picker
                  v-model="getdataListParmGetAssetSTT1.parammaps.blockTime"
                  type="date"
                  placeholder="停用时间"
                  style="width:170px;top:-3px;"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                />
                <el-button
                  v-waves
                  class="filter-item"
                  type="primary"
                  icon="el-icon-search"
                  @click="form_searchSTT"
                >搜索</el-button>
              </div>
              <el-table
                :key="tableKey"
                v-loading="listLoadingSTT1"
                element-loading-text="给我一点时间"
                :data="listAssetSTT1"
                border
                fit
                highlight-current-row
                style="width: 100%;"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable"
              >
                <!-- table表格 -->
                <el-table-column label="序号" align="center" type="index" width="50px">
                  <template slot-scope="scope">
                    <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="启用时间" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.enabledTime }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="停用时间" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.blockTime }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="启用人" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.enabledName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="停用人" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.blockName }}</span>
                  </template>
                </el-table-column>
              </el-table>
              <!-- 分页 -->
              <pagination
                v-show="total>0"
                :total="totalSTT1"
                :page.sync="getdataListParmGetAssetSTT1.offset"
                :limit.sync="getdataListParmGetAssetSTT1.pagecount"
                @pagination="getSTT1"
              />
            </el-tab-pane>
            <el-tab-pane label="变更记录" name="fifith">
              <el-table
                :key="tableKey"
                v-loading="listLoadingChange1"
                element-loading-text="给我一点时间"
                :data="listAssetChange1"
                border
                fit
                highlight-current-row
                style="width: 100%;"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable"
              >
                <!-- table表格 -->
                <el-table-column label="序号" align="center" type="index" width="50px">
                  <template slot-scope="scope">
                    <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="变更时间" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.changeTime }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="变更状态" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.changeStatue }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="变更人" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.changeName }}</span>
                  </template>
                </el-table-column>
              </el-table>
              <!-- 分页 -->
              <pagination
                v-show="total>0"
                :total="totalChange1"
                :page.sync="getdataListParmGetAssetChange1.offset"
                :limit.sync="getdataListParmGetAssetChange1.pagecount"
                @pagination="getChange1"
              />
            </el-tab-pane>
          </el-tabs>
        </div>
        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:30px">
          <el-button @click="dialogFormVisibleCard = false">关闭</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// 引入
import { GetDataByName, GetDataByNames, PostDataByName, getRecuData, checkButtons } from '@/api/common'
import waves from '@/directive/waves' // waves directive
import { parseTime } from '@/utils/index.js'
// eslint-disable-next-line no-unused-vars
import { validateEMail } from '@/utils/validate.js'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import { MessageBox } from 'element-ui'
import TreeSelect from '@/components/TreeSelect'
import Cookies from 'js-cookie'
export default {
  name: 'SpBasic',
  components: { Pagination, TreeSelect },
  directives: { waves },
  data() {
    return {
      // 权限按钮
      isBasicsAdd: [],
      isBasicsCard: [],
      isBasicsUpdate: [],
      isBasicsDel: [],
      tableKey: 0,
      list: null,
      total: 0,
      totalSTT1: 0,
      totalSpotCheck1: 0,
      totalChange1: 0,
      totalMaintain1: 0,
      totalBasics: 0,
      listLoading: true,
      listLoadingbasics: true,
      listLoadingSTT1: true,
      listLoadingSpotCheck1: true,
      listLoadingChange1: true,
      listLoadingMaintain1: true,
      // 1.资产卡片-设备启停记录列表
      listAssetSTT1: [],
      // 2.资产卡片-点检记录列表
      listAssetSpotCheck1: [],
      // 3.资产卡片-变更记录列表
      listAssetChange1: [],
      // 4.资产卡片-维修记录列表
      listAssetMaintain1: [],
      activeName: 'six',
      getRecuListParm: { name: 'getAssetTypeList',
        idname: 'id',
        params: [-1] },
      requestParam: {
        name: 'insertAsset',
        offset: 0,
        pagecount: 0,
        parammaps: {}
      },
      // 1-2:table&搜索传参
      getdataListParm: {
        name: 'getAssetList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          assetNumber: '',
          assetName: '',
          pastureName: Cookies.get('pasturename'),
          status: '',
          createTime: ''
        }
      },
      // 1.资产卡片-设备启停记录列表
      getdataListParmGetBasics: {
        name: 'getAssetSTT1',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      // 1.资产卡片-设备启停记录列表
      getdataListParmGetAssetSTT1: {
        name: 'getAssetSTT1',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      // 2.资产卡片-点检记录列表
      getdataListParmGetAssetSpotCheck1: {
        name: 'getAssetBigSpotCheck1',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      // 3.资产卡片-变更记录列表
      getdataListParmGetAssetChange1: {
        name: 'getAssetChange1',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      // 4.资产卡片-维修记录列表
      getdataListParmGetAssetMaintain1: {
        name: 'getAssetMaintain1',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      getdataEQNumber: {
        name: 'cerateEQNumber',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      // 2-3：下拉框请求后数据加入[]
      findAllProvider: [],
      findAllAssetType: [],
      findAllPasture: [],
      findAllDepart: [],
      findAllEmploye: [],
      getDictByName: [],
      // 2-1.请求下拉框接口
      requestParams: [
        { name: 'findAllProvider', offset: 0, pagecount: 0, params: [] },
        { name: 'findAllAssetType', offset: 0, pagecount: 0, params: [] },
        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
        // { name: 'findAllDepart', offset: 0, pagecount: 0, params: [this.$store.state.user.pastureid] },
        // { name: 'findAllEmploye', offset: 0, pagecount: 0, params: [this.$store.state.user.pastureid] },
        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
        { name: 'getDictByName', offset: 0, pagecount: 0, params: ['资产状态'] },
        { name: 'getAssetSTT1', offset: 0, pagecount: 0, parammaps: {}}
      ],
      temp: {
        inputDatetime: parseTime(new Date(), '{y}-{m}-{d}'),
        typeName: '',
        assTypeId: '',
        equipmentNumber: '',
        employeId: this.$store.state.user.employeid,
        departmentId: this.$store.state.user.departmentid,
        pastureId: this.$store.state.user.pastureid,
        equipmentName: '',
        specification: '',
        providerName: '',
        financeNumber: '',
        status: '',
        purpose: '',
        purchaseDate: '',
        entranceDate: '',
        assetNumber: '',
        yearUpkeepCost: '',
        yearMaintainDost: '',
        yuanzhi: ''
      },
      dialogFormVisible: false,
      dialogStatus: '',
      dialogFormVisibleCard: false,
      dialogStatusCard: '',
      textMap: {
        update: '编辑',
        create: '新增',
        card: '查看设备信息'
      },
      dialogPvVisible: false,
      // 校验规则
      rules: {
        assetNumber: [{ required: true, message: '必填', trigger: 'blur' }
        // 引入自定义校验并使用
          // { validator: validateEMail, trigger: 'blur' }
        ],
        equipmentName: [{ required: true, message: '必填', trigger: 'blur' }],
        assTypeId: [{ required: true, message: '必填', trigger: 'blur' }]
      },
      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
      cellStyle: { padding: 0 + 'px' },
      parentClass: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      nodeKey: 'id',
      defaultCheckedKeys: [],
      Classid: '',
      buttons: []
    }
  },
  created() {
    const that = this
    GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
      that.buttons = response.data.list
      that.get_auto_buttons()
    })
    this.get_select_list()
    this.getDownClassList()
    this.get_table_data()
  },
  methods: {
    get_auto_buttons() {
      // 新增
      const BasicsAdd = 'asset:basics:add'
      const isBasicsAdd = checkButtons(this.$store.state.user.buttons, BasicsAdd)
      this.isBasicsAdd = isBasicsAdd
      // 卡片
      // eslint-disable-next-line no-redeclare
      const BasicsCard = 'asset:basics:kapian'
      const isBasicsCard = checkButtons(this.$store.state.user.buttons, BasicsCard)
      this.isBasicsCard = isBasicsCard
      // 编辑
      const BasicsUpdate = 'asset:basics:update'
      const isBasicsUpdate = checkButtons(this.$store.state.user.buttons, BasicsUpdate)
      this.isBasicsUpdate = isBasicsUpdate
      // 删除
      const BasicsDel = 'asset:basics:del'
      const isBasicsDel = checkButtons(this.$store.state.user.buttons, BasicsDel)
      this.isBasicsDel = isBasicsDel
    },
    // 供应商模糊查询
    providerSearch(queryString, cb) {
      var returnList = this.findAllProvider
      var results = queryString ? returnList.filter(this.createFilter(queryString)) : returnList
      // 调用 callback 返回建议列表的数据
      cb(results)
    },
    createFilter(queryString) {
      console.log(queryString)
      return returnValue => {
        return (
          returnValue.name.toLowerCase().indexOf(queryString.toLowerCase()) >= 0
        )
      }
    },
    handleSelect(item) {
      this.temp.providerId = item.id
      this.temp.providerName = item.name
    },
    // 1-1: table&搜索
    get_table_data() {
      this.listLoading = true
      if (this.getdataListParm.parammaps.createTime === null) {
        this.getdataListParm.parammaps.createTime = ''
      }
      GetDataByName(this.getdataListParm).then(response => {
        this.list = response.data.list
        this.pageNum = response.data.pageNum
        this.pageSize = response.data.pageSize
        if (response.data.total) {
          this.total = response.data.total
        }
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 100)
      })
    },

    // 1.资产卡片-基础信息列表
    getBasics(id, pastureId) {
      GetDataByName(this.getdataListParmGetBasics).then(response => {
        this.listBasics = response.data.list
        if (response.data.total) {
          this.totalBasics = response.data.total
        }
        setTimeout(() => {
          this.listLoadingBasics = false
        }, 100)
      })
    },
    // 1.资产卡片-设备启停记录列表
    getSTT1(id, pastureId) {
      GetDataByName(this.getdataListParmGetAssetSTT1).then(response => {
        this.listAssetSTT1 = response.data.list
        this.pageNum = response.data.pageNum
        this.pageSize = response.data.pageSize
        if (response.data.total) {
          this.totalSTT1 = response.data.total
        }
        setTimeout(() => {
          this.listLoadingSTT1 = false
        }, 100)
      })
    },
    // 2.资产卡片-点检记录列表
    getSportCheck(id, pastureId) {
      GetDataByName(this.getdataListParmGetAssetSpotCheck1).then(response => {
        this.listAssetSpotCheck1 = response.data.list
        this.pageNum = response.data.pageNum
        this.pageSize = response.data.pageSize
        if (response.data.total) {
          this.totalSpotCheck1 = response.data.total
        }
        setTimeout(() => {
          this.listLoadingSpotCheck1 = false
        }, 100)
      })
    },
    // 3.资产卡片-变更记录列表
    getChange1(id, pastureId) {
      GetDataByName(this.getdataListParmGetAssetChange1).then(response => {
        this.listAssetChange1 = response.data.list
        this.pageNum = response.data.pageNum
        this.pageSize = response.data.pageSize
        if (response.data.total) {
          this.totalChange1 = response.data.total
        }
        setTimeout(() => {
          this.listLoadingChange1 = false
        }, 100)
      })
    },
    // 4.资产卡片-维修记录列表
    getMaintain1(id, pastureId) {
      GetDataByName(this.getdataListParmGetAssetMaintain1).then(response => {
        this.listAssetMaintain1 = response.data.list
        this.pageNum = response.data.pageNum
        this.pageSize = response.data.pageSize
        if (response.data.total) {
          this.totalMaintain1 = response.data.total
        }
        setTimeout(() => {
          this.listLoadingMaintain1 = false
        }, 100)
      })
    },
    // 2-2：下拉框
    get_select_list() {
      // console.log(this.$store.state.user.pastureid)
      GetDataByNames(this.requestParams).then(response => {
        this.findAllProvider = response.data.findAllProvider.list
        this.findAllAssetType = response.data.findAllAssetType.list
        this.findAllPasture = response.data.findAllPasture.list
        this.findAllDepart = response.data.findAllDepart.list
        this.findAllEmploye = response.data.findAllEmploye.list
        this.getDictByName = response.data.getDictByName.list
      })
    },

    popoverHide(checkedIds, checkedData) {
      console.log(checkedData.checkNumber)
      // 请求资产编号接口
      this.getdataEQNumber.parammaps.checkNumber = checkedData.checkNumber
      if (checkedData.children.length === 0) {
        this.temp.assTypeId = checkedIds
        this.getEQNumber()
      } else {
        this.defaultCheckedKeys = []
        this.$message({
          type: 'warning',
          message: '请选择具体设备类型'
        })
      }
    },
    getEQNumber() {
      this.getdataEQNumber.parammaps.pastureId = Cookies.get('pastureid')
      GetDataByName(this.getdataEQNumber).then(response => {
        this.temp.equipmentNumber = response.data.list[0].createNumber
      })
    },
    getDownClassList() {
      getRecuData(this.getRecuListParm).then(response => {
        this.parentClass = response.data
        // this.parentClass.push({ id: '', name: '' })
      })
    },

    deptenter() {
      this.$nextTick(() => {
        this.$refs['remark'].focus()
      })
    },
    form_search() {
      this.listLoading = true
      this.getdataListParm.offset = 1
      this.get_table_data()
    },
    form_searchSTT() {
      this.listLoading = true
      this.getdataListParmGetAssetSTT1.offset = 1
      this.getSTT1()
    },
    handleModifyStatus(row, status) {
      this.$message({
        message: '操作成功',
        type: 'success'
      })
      row.status = status
    },
    form_reset() {
      this.defaultCheckedKeys = []
      this.temp.inputDatetime = parseTime(new Date(), '{y}-{m}-{d}')
      this.temp.typeName = ''
      this.temp.assTypeId = ''
      this.temp.employeId = this.$store.state.user.employeid
      this.temp.departmentId = this.$store.state.user.departmentid
      this.temp.pastureId = this.$store.state.user.pastureid
      this.temp.equipmentNumber = ''
      this.temp.equipmentName = ''
      this.temp.specification = ''
      this.temp.providerName = ''
      this.temp.financeNumber = ''
      this.temp.status = ''
      this.temp.providerName = ''
      this.temp.purpose = ''
      this.temp.purchaseDate = ''
      this.temp.purchaseDate = ''
      this.temp.entranceDate = ''
      this.temp.assetNumber = ''
      this.temp.yearUpkeepCost = ''
      this.temp.yearMaintainDost = ''
      this.temp.yuanzhi = ''
      this.temp.financeNumber = ''
      this.temp.inputDatetime = ''
    },
    // 新增
    form_add() {
      this.form_reset()
      this.dialogStatus = 'create'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['temp'].clearValidate()
      })
    },
    add_dialog_save() {
      this.$refs['temp'].validate(valid => {
        if (valid) {
          this.requestParam.name = 'insertAsset'
          this.requestParam.parammaps = this.temp

          PostDataByName(this.requestParam).then(response => {
            console.log(response)
            if (response.msg === 'fail') {
              this.$notify({
                title: '失败',
                message: '保存失败-' + response.data,
                type: 'danger',
                duration: 2000
              })
            } else {
              this.get_table_data()
              this.dialogFormVisible = false
              this.$notify({
                title: '成功',
                message: '新增成功',
                type: 'success',
                duration: 2000
              })
            }
          })
        }
      })
    },
    // 继续新增
    add_dialog_save_again() {
      this.$refs['temp'].validate(valid => {
        if (valid) {
          this.requestParam.name = 'insertAsset'
          this.requestParam.parammaps = this.temp
          PostDataByName(this.requestParam).then(() => {
            this.get_table_data()
            this.form_reset()
            this.$notify({
              title: '成功',
              message: '新增成功',
              type: 'success',
              duration: 2000
            })
          })
        }
      })
    },
    // 编辑
    form_edit(row) {
      this.temp = Object.assign({}, row) // copy obj
      this.defaultCheckedKeys = [this.temp.assTypeId]
      this.dialogStatus = 'update'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['temp'].clearValidate()
      })
    },
    edit_dialog_save() {
      this.$refs['temp'].validate(valid => {
        if (valid) {
          this.requestParam.name = 'updateAsset'
          this.requestParam.parammaps = this.temp
          PostDataByName(this.requestParam).then(response => {
            console.log(response)
            if (response.msg === 'fail') {
              this.$notify({
                title: '失败',
                message: '保存失败-' + response.data,
                type: 'warning',
                duration: 2000
              })
            } else {
              this.get_table_data()
              this.dialogFormVisible = false
              this.$notify({
                title: '成功',
                message: '修改成功',
                type: 'success',
                duration: 2000
              })
            }
          })
        }
      })
    },
    // 删除
    form_delete(row) {
      MessageBox.confirm('设备名称：' + row.equipmentName, '确认删除？', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.requestParam.name = 'deleteAsset'
        this.requestParam.parammaps = {}
        this.requestParam.parammaps['id'] = row.id
        PostDataByName(this.requestParam).then(() => {
          this.get_table_data()
          this.dialogFormVisible = false
          this.$notify({
            title: '成功',
            message: '删除成功',
            type: 'success',
            duration: 2000
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 卡片
    handleCard(row) {
      this.temp = Object.assign({}, row) // copy obj
      this.dialogStatusCard = 'card'
      this.dialogFormVisibleCard = true
      // 1.资产卡片-设备启停记录列表
      this.getdataListParmGetAssetSTT1.parammaps.assetId = row.id
      this.getdataListParmGetAssetSTT1.parammaps.pastureId = row.pastureId
      this.getSTT1(this.getdataListParmGetAssetSTT1.parammaps.assetId, this.getdataListParmGetAssetSTT1.parammaps.pastureId)
      // 2.资产卡片-点检记录列表
      this.getdataListParmGetAssetSpotCheck1.parammaps.assetId = row.id
      this.getdataListParmGetAssetSpotCheck1.parammaps.pastureId = row.pastureId
      this.getSportCheck(this.getdataListParmGetAssetSpotCheck1.parammaps.assetId, this.getdataListParmGetAssetSpotCheck1.parammaps.pastureId)
      // 3.资产卡片-变更记录列表
      this.getdataListParmGetAssetChange1.parammaps.assetId = row.id
      this.getdataListParmGetAssetChange1.parammaps.pastureId = row.pastureId
      this.getChange1(this.getdataListParmGetAssetChange1.parammaps.assetId, this.getdataListParmGetAssetChange1.parammaps.pastureId)
      // 4.资产卡片-维修记录列表
      this.getdataListParmGetAssetMaintain1.parammaps.assetId = row.id
      this.getdataListParmGetAssetMaintain1.parammaps.pastureId = row.pastureId
      this.getMaintain1(this.getdataListParmGetAssetMaintain1.parammaps.assetId, this.getdataListParmGetAssetMaintain1.parammaps.pastureId)
    }
  }
}
</script>
<style lang="scss" scoped>
  .el-autocomplete-suggestion li{
    padding:0 3px!important;
  }
  .el-table .warning-row {
      background: oldlace;
  }
  .el-table .success-row {
      background: #f0f9eb;
  }
</style>
