
<template>
  <div class="app-container">
    <div v-if="isPercentage" class="percentage" style="width: 210px;height: 90px;background: #fff;position: fixed;bottom: 0;left: 0;z-index: 9999999999999;">
      <h4 style="padding-left: 10px;line-height: 0;">导出进度：</h4>
      <el-progress style="padding-left: 10px;" :text-inside="true" :stroke-width="26" :percentage="percentage" />
    </div>
    <div class="filter-container">
      <el-select ref="pastureName" v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" @change="changePastureName">
        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
      </el-select>
      <el-input v-model="getdataListParm.parammaps.assetCode" placeholder="设备内部编号" clearable class="filter-item" style="width: 130px" />
      <el-input v-model="getdataListParm.parammaps.eqName" placeholder="设备名称" style="width: 130px;" class="filter-item" />

      <el-select v-model="getdataListParm.parammaps.departmentId" clearable placeholder="部门" class="filter-item" style="width: 100px">
        <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.id" />
      </el-select>
      <el-select v-model="getdataListParm.parammaps.status" clearable placeholder="状态" class="filter-item" style="width: 100px">
        <el-option v-for="item in getDictByName" :key="item.id" :label="item.label" :value="item.id" />
      </el-select>
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
      <div>
        <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_add">变更</el-button>
        <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</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"
    >
      <!-- 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.pastureName }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="资产编号" min-width="130px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.assetCode }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="设备名称" min-width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.eqName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="设备内部编号" min-width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.eqCode }}</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="90px" 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-popover placement="right" title="" trigger="hover">
            <img v-if="scope.row.picpath !== ''" :src="scope.row.picpath">
            <img v-if="scope.row.picpath !== ''" slot="reference" :src="scope.row.picpath" :alt="scope.row.srcpath" style="height: 100px;width:100px;">
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="部门" width="90px" 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.status }}</span>
        </template>
      </el-table-column>
      <el-table-column label="变更日期" sortable prop="changeTime" min-width="110px" align="center" />

      <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="{row}">
          <el-button type="warning" size="mini" @click="form_edit(row)">状态变更</el-button>
          <el-button type="primary" size="mini" @click="form_see(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="getList" />
    <!-- 弹出层新增or修改 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
      <el-form ref="temp" :rules="rules" :model="temp" label-position="right" label-width="140px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="设备名称：" prop="assetName">
              <el-autocomplete
                ref="assetName"
                v-model="temp.assetName"
                value-key="assetName"
                class="inline-input"
                :fetch-suggestions="formNameSearch"
                placeholder="请输入内容"
                :disabled="dialogStatus==='update'"
                style="width:100%;"
                @select="handleformNameSelect"
              >
                <template slot-scope="{ item }">
                  <div class="name" style="display: inline;">{{ item.eqName }}</div>
                  <span class="addr">{{ item.eqCode }}</span>
                </template>
              </el-autocomplete>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="牧场设备编号：" prop="eqCode">
              <el-autocomplete
                ref="eqCode"
                v-model="temp.eqCode"
                value-key="eqCode"
                class="inline-input"
                :fetch-suggestions="formNumberSearch"
                placeholder="请输入内容"
                :disabled="dialogStatus==='update'"
                style="width:100%;"
                @select="handleformNumberSelect"
              >
                <template slot-scope="{ item }">
                  <div class="name" style="display: inline;">{{ item.eqName }}</div>
                  <span class="addr">{{ item.eqCode }}</span>
                </template>
              </el-autocomplete>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="变更状态：">
              <!-- <el-input v-model="temp.changeStatue" style="width:250px;" /> -->
              <el-select v-model="temp.status" clearable placeholder="状态" class="filter-item" style="width:100%;">
                <el-option v-for="item in getDictByName" :key="item.id" :label="item.label" :value="item.id" />
              </el-select>

            </el-form-item>

          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="牧场：">
              <!-- <span>{{ temp.pastureName }}</span> -->
              <el-input v-model="temp.pastureName" disabled style="width:100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="部门：">
              <el-input v-model="temp.deptName" disabled style="width:100%;" />
            </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="变更时间"

                style="width:100%;"
                :picker-options="pickerOptions0"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="8">
            <el-form-item label="变更人：" prop="empId">
              <el-select v-model="temp.empId" placeholder="操作人" class="filter-item" style="width:100%;">
                <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-form>
      <div slot="footer" class="dialog-footer">

        <el-button type="primary" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">确认</el-button>
        <el-button @click="dialogFormVisible = false;getList()">关闭</el-button>
      </div>
    </el-dialog>
    <!-- 变更记录 -->
    <el-dialog :title="cardTitle" :visible.sync="dialogFormVisibleCard" :close-on-click-modal="false" width="90%">
      <div class="app-contentcard">
        <el-form ref="rowSeeData" :rules="rules" :model="rowSeeData" label-position="right" label-width="120px" style="width: 100%;margin:0 auto;">
          <div class="filter-container">
            <el-select
              v-model="getdataListParmSee.parammaps.changeStatue"
              clearable
              placeholder="状态"
              class="filter-item"
              style="width: 100px"
            >
              <el-option
                v-for="item in getDictByName"
                :key="item.id"
                :label="item.label"
                :value="item.id"
              />
            </el-select>

            <el-date-picker ref="inputDatetime2" v-model="getdataListParmSee.parammaps.inputDatetime" class="inputDatetime" type="datetimerange" style="width: 250px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />
            <el-button
              v-waves
              class="filter-item"
              type="primary"
              icon="el-icon-search"
              @click="form_searchDelivery"
            >搜索</el-button>
          </div>
        </el-form>
        <el-table
          :key="tableKey"
          v-loading="listLoadingSee"
          element-loading-text="给我一点时间"
          :data="listSee"
          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="变更日期" sortable prop="changeTime" min-width="110px" align="center" />
          <el-table-column label="变更状态" min-width="110px" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.status }}</span>
            </template>
          </el-table-column>
          <el-table-column label="变更人" min-width="110px" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.empname }}</span>
            </template>
          </el-table-column>

        </el-table>
        <pagination
          v-show="totalSee>0"
          :total="totalSee"
          :page.sync="getdataListParmSee.offset"
          :limit.sync="getdataListParmSee.pagecount"
          @pagination="getListSee"
        />
        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:10px">
          <el-button @click="dialogFormVisibleCard = false">关闭</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// 引入
import { GetDataByName, GetDataByNames, ExecDataByConfig, GetAccount } 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 Cookies from 'js-cookie'
import { json2excel } from '@/utils/index.js'
export default {
  name: 'Install',
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      requestParam: {
        name: 'insertAsset',
        offset: 0,
        pagecount: 0,
        parammaps: {}
      },
      // 1-2:table&搜索传参
      getdataListParm: {
        name: 'geteqChangeList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          assetCode: '',
          eqName: '',
          pastureName: Cookies.get('pasturename'),
          status: '',
          deptName: '',
          departmentId: ''

        }
      },
      downLoadParm: {},
      downLoadList: [],
      // 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: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
        { name: 'getDictByName', offset: 0, pagecount: 0, params: ['资产状态'] }
      ],
      getDepartParam: {
        name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }
      },
      postDataPramas: {
        'common': { 'returnmap': '0' },
        'data': [
          { 'name': 'updateChangeStatue', 'type': 'e',
            'parammaps': {
              'status': '',
              'assetId': '',
              'pastureId': Cookies.get('pastureid')
            }},
          { 'name': 'updateAssetChange', 'type': 'e',
            'parammaps': {
              'changeStatue': '',
              'assetId': '',
              'assetName': '',
              'assetNumber': '',
              'pastureId': Cookies.get('pastureid'),
              'empId': ''
            }}
        ] },
      temp: {
        pastureName: '',
        deptName: '',
        deptId: '',
        eqName: '',
        assetId: '',
        eqCode: '',
        status: '',
        statusId: '',
        inputDatetime: new Date(),
        typeName: '',
        assTypeId: '',
        syStatus: '',
        employeId: this.$store.state.user.employeid,
        departmentId: this.$store.state.user.departmentid,
        employeName: this.$store.state.user.employename,
        pastureId: this.$store.state.user.pastureid
      },
      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: '修改状态',
        create: '新增'
      },
      dialogPvVisible: false,
      requestFilterParams: {
        name: 'findAssetMain', offset: 0, pagecount: 20,
        returntype: 'Map',
        parammaps: {}
      },

      // 新加的列表用的==========================================
      cardTitle: '变更记录',
      dialogFormVisibleCard: false,
      dialogStatusCard: '',
      listLoadingSee: true,
      rowSeeData: {},
      listSee: [],
      totalSee: 0,
      getdataListParmSee: {
        name: 'getAssetchangeList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          eqId: '',
          changeStatue: '',
          inputDatetime: '',
          startTime: '',
          stopTime: '',
          pastureId: Cookies.get('pastureid')
        }
      },
      checkStatus: '',
      // 新加的列表用的==========================================
      // 时间设置
      pickerOptions0: {
        disabledDate(time) {
          return time.getTime() > Date.now() - 8.64e6
        }
      },

      // 校验规则
      rules: {
        assetName: [{ required: true, message: '必填', trigger: 'remove-tag' }],
        eqCode: [{ required: true, message: '必填', trigger: 'expand-change' }],
        equipmentName: [{ required: true, message: '必填', trigger: 'blur' }]
      },
      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
      cellStyle: { padding: 0 + 'px' },
      isPercentage: false,
      percentage: 1
    }
  },
  created() {
    this.get_select_list()
    this.getList()
  },

  methods: {
    // 模糊查询-名称
    formNumberSearch(queryString, cb) {
      this.requestFilterParams.parammaps['eqCode'] = queryString
      this.requestFilterParams.parammaps['assetName'] = ''
      this.requestFilterParams.parammaps['pastureId'] = this.$store.state.user.pastureid
      GetDataByName(this.requestFilterParams).then(response => {
        cb(response.data.list)
      })
    },
    formNameSearch(queryString, cb) {
      this.requestFilterParams.parammaps['eqCode'] = ''
      this.requestFilterParams.parammaps['assetName'] = queryString
      this.requestFilterParams.parammaps['pastureId'] = this.$store.state.user.pastureid
      GetDataByName(this.requestFilterParams).then(response => {
        cb(response.data.list)
      })
    },

    handleformNumberSelect(item) {
      this.temp.assetNumber = item.assetNumber
      this.temp.assetName = item.assetName
      this.temp.eqCode = item.eqCode
      this.temp.eqName = item.eqName
      this.temp.eqId = item.eqId
      this.temp.id = item.assetId
      this.temp.assetId = item.assetId
      this.temp.pastureId = item.pastureId
      this.temp.pastureName = item.pastureName
      this.temp.deptName = item.deptName
      this.temp.deptId = item.deptName
      this.temp.changeStatue = item.changeStatue
      this.temp.status = item.status

      // this.temp.statusId = item.statusId
      this.checkStatus = item.status
      this.temp.employeId = item.employeId
      this.temp.employeName = item.employeName
      this.temp.inputDatetime = new Date()
      // this.temp.inputDatetime = this.temp.inputDatetime
      if (item.sttId === undefined || item.sttId === null) {
        this.temp.sttId = 0
      } else {
        this.temp.sttId = item.sttId
      }
    },

    handleformNameSelect(item) {
      console.log(item)
      this.temp.assetNumber = item.assetNumber
      this.temp.assetName = item.assetName
      this.temp.eqCode = item.eqCode
      this.temp.eqName = item.eqName
      this.temp.eqId = item.eqId
      this.temp.id = item.assetId
      this.temp.assetId = item.assetId
      this.temp.pastureId = item.pastureId
      this.temp.pastureName = item.pastureName
      this.temp.deptName = item.deptName
      this.temp.deptId = item.deptName
      this.temp.changeStatue = item.changeStatue
      this.temp.status = item.status
      // this.temp.statusId = item.statusId
      this.checkStatus = item.status
      this.temp.employeId = item.employeId
      this.temp.employeName = item.employeName
      // this.temp.inputDatetime = parse(new Date(), '{y}-{m}-{d} {h}:{i}')
      // this.temp.inputDatetime = this.temp.inputDatetime
      console.log(item.inputDatetime)
      if (item.sttId === undefined || item.sttId === null) {
        this.temp.sttId = 0
      } else {
        this.temp.sttId = item.sttId
      }
    },

    // 1-1: table&搜索
    getList() {
      this.listLoading = true
      GetDataByName(this.getdataListParm).then(response => {
        console.log('表格：', response.data.list)
        this.list = response.data.list
        if (response.data.list !== null) {
          for (let i = 0; i < response.data.list.length; i++) {
            if (response.data.list[i].srcpath !== null && response.data.list[i].picpath !== null && response.data.list[i].srcpath !== undefined && response.data.list[i].picpath !== undefined) {
              this.list[i].srcpath = process.env.VUE_APP_BASE_API + response.data.list[i].srcpath
              this.list[i].picpath = process.env.VUE_APP_BASE_API + response.data.list[i].picpath
            } else {
              this.list[i].srcpath = ''
              this.list[i].picpath = ''
            }
            console.log(this.list[i].srcpath)
          }
        }
        this.pageNum = response.data.pageNum
        this.pageSize = response.data.pageSize
        if (response.data.total) {
          this.total = response.data.total
        }
        // this.$refs['pastureName'].val =  Cookies.get('employename')
        // console.log('-----------',this.$refs['pastureName'])
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 100)
      })
    },
    // 2-2：下拉框
    get_select_list() {
      GetDataByNames(this.requestParams).then(response => {
        this.findAllProvider = response.data.findAllProvider.list
        this.findAllAssetType = response.data.findAllAssetType.list
        this.findAllPasture = response.data.findAllPasture.list
        this.findAllEmploye = response.data.findAllEmploye.list
        this.getDictByName = response.data.getDictByName.list
        this.getDepartDownList()
      })
    },
    getDepartDownList() {
      GetDataByName(this.getDepartParam).then(response => {
        this.findAllDepart = response.data.list
      })
    },
    changePastureName(item) {
      this.getDepartParam.parammaps.pastureId = this.findAllPasture.find(obj => obj.name == item).id
      this.getdataListParm.parammaps.departmentId = ''
      this.getDepartDownList()
    },
    form_search() {
      this.listLoading = true
      this.getdataListParm.offset = 1
      this.getList()
    },
    handleModifyStatus(row, statusId) {
      this.$message({
        message: '操作成功',
        type: 'success'
      })
      // row.status = status
      row.statusId = statusId
    },
    form_reset() {
      this.temp = {
        pastureName: '',
        deptName: '',
        deptId: '',
        employeName: '',
        eqName: '',
        assetId: '',
        eqCode: '',
        status: '',
        statusId: '',
        inputDatetime: new Date(),
        typeName: '',
        assTypeId: '',
        syStatus: '',
        employeId: this.$store.state.user.employeid,
        departmentId: this.$store.state.user.departmentid,
        employeName: this.$store.state.user.employeid,

        pastureId: this.$store.state.user.pastureid
      }
      this.checkStatus = ''
      // this.temp.inputDatetime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}')
      // this.temp.typeName = ''
      // this.temp.assTypeId = ''
      // this.temp.eqName = ''
      // this.temp.eqCode = ''
      // this.temp.deptName = ''
      // this.temp.deptId = ''
      // this.temp.status = ''
      // this.temp.statusId = ''

      // this.temp.pastureName = ''
      // this.temp.employeId = this.$store.state.user.employeId
      // this.temp.departmentId = this.$store.state.user.departmentid
    },

    add_dialog_save() {
      if (this.temp.assetId == '' || this.temp.eqCode == '' || this.temp.eqName == '') {
        this.$notify({
          title: '',
          message: '请输入设备名称或设备内部编号',
          type: 'warning',
          duration: 2000
        })
      } else {
        if (this.checkStatus == this.temp.status) {
          this.$notify({
            title: '',
            message: '请选择变更状态',
            type: 'warning',
            duration: 2000
          })
        } else {
          this.postDataPramas.data[0].parammaps.status = this.temp.status
          this.postDataPramas.data[0].parammaps.assetId = this.temp.assetId
          this.postDataPramas.data[1].parammaps.changeStatue = this.temp.status
          this.postDataPramas.data[1].parammaps.assetId = this.temp.assetId
          this.postDataPramas.data[1].parammaps.assetName = this.temp.eqName
          this.postDataPramas.data[1].parammaps.assetNumber = this.temp.eqCode
          this.postDataPramas.data[1].parammaps.empId = this.temp.empId

          ExecDataByConfig(this.postDataPramas).then(response => {
            if (response.msg === 'fail') {
              this.$notify({
                title: '变更失败',
                message: response.data,
                type: 'warning',
                duration: 2000
              })
            } else {
              this.getList()
              this.dialogFormVisible = false
              this.$notify({
                title: '',
                message: '变更成功',
                type: 'success',
                duration: 2000
              })
            }
          })
        }
      }
    },

    edit_dialog_save() {
      if (this.checkStatus == this.temp.status) {
        this.$notify({
          title: '',
          message: '请选择变更状态',
          type: 'warning',
          duration: 2000
        })
      } else {
        this.postDataPramas.data[0].parammaps.status = this.temp.status
        this.postDataPramas.data[0].parammaps.assetId = this.temp.assetId
        this.postDataPramas.data[1].parammaps.changeStatue = this.temp.status
        this.postDataPramas.data[1].parammaps.assetId = this.temp.assetId
        this.postDataPramas.data[1].parammaps.assetName = this.temp.eqName
        this.postDataPramas.data[1].parammaps.assetNumber = this.temp.eqCode
        this.postDataPramas.data[1].parammaps.empId = this.temp.empId
        this.postDataPramas.data[1].parammaps.changeId = this.temp.employeId

        ExecDataByConfig(this.postDataPramas).then(response => {
          if (response.msg === 'fail') {
            this.$notify({
              title: '变更失败',
              message: response.data,
              type: 'warning',
              duration: 2000
            })
          } else {
            this.getList()
            this.dialogFormVisible = false
            this.$notify({
              title: '',
              message: '变更成功',
              type: 'success',
              duration: 2000
            })
          }
        })
      }
    },

    form_edit(row) {
      console.log('row', row)
      this.temp = Object.assign({}, row) // copy obj
      this.temp.inputDatetime = new Date()
      this.temp.empId = this.$store.state.user.employeid
      this.checkStatus = row.status
      this.dialogStatus = 'update'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['temp'].clearValidate()
      })
    },

    form_add() {
      this.form_reset()
      this.dialogStatus = 'create'
      this.dialogFormVisible = true
      this.temp.empId = this.$store.state.user.employeid
      this.$nextTick(() => {
        this.$refs['temp'].clearValidate()
      })
    },

    form_see(row) {
      console.log(row)
      this.rowSeeData = Object.assign({}, row)
      this.cardTitle = '变更记录  设备名称：' + row.eqName + '设备编号：' + row.eqCode
      this.dialogFormVisibleCard = true
      this.getdataListParmSee.parammaps.eqId = row.id
      this.getListSee()
    },
    form_searchDelivery() {
      // this.getdataListParmSee.parammaps.eqId = row.id
      if (this.getdataListParmSee.parammaps.inputDatetime === null) {
        this.getdataListParmSee.parammaps.inputDatetime = ''
      }
      console.log('getdataListParmSee', this.getdataListParmSee)
      this.getdataListParmSee.offset = 1
      this.getListSee()
    },
    getListSee() {
      console.log('enabledTime', this.$refs['inputDatetime2'])

      if (this.$refs['inputDatetime2'] !== undefined && this.$refs['inputDatetime2'].value !== null) {
        this.getdataListParmSee.parammaps.startTime = this.$refs['inputDatetime2'].value[0]
        this.getdataListParmSee.parammaps.stopTime = this.$refs['inputDatetime2'].value[1]
      } else {
        this.getdataListParmSee.parammaps.startTime = ''
        this.getdataListParmSee.parammaps.stopTime = ''
      }

      GetDataByName(this.getdataListParmSee).then(response => {
        this.listSee = response.data.list
        console.log('记录列表数据', response.data.list)
        this.pageNum = response.data.pageNum
        this.pageSize = response.data.pageSize
        if (response.data.total) {
          this.totalSee = response.data.total
        }
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoadingSee = false
        }, 300)
      })
    },
    handleDownload() {
      this.$alert('设备变更正在导出中，请勿刷新或离开本页面，若导出时间过长，建议缩小导出数据范围重新导出', {})
      this.isPercentage = true
      this.percentage = 1
      var timer = setInterval(() => {
        this.percentage += 5
        if (this.percentage > 95) {
          this.percentage = 99
          clearInterval(timer)
        }
        this.percentage = this.percentage
      }, 1000)
      this.downLoadParm.name = 'geteqChangeList'
      this.downLoadParm.parammaps = this.getdataListParm.parammaps
      GetAccount(this.downLoadParm).then(response => {
        this.downLoadList = response.data.list
        if (response.data.list !== '') {
          this.percentage = 99
          setTimeout(() => {
            this.isPercentage = false
          }, 2000)
        }
        console.log(this.downLoadList)
        const elecExcelDatas = [
          {
            tHeader: ['牧场', '设备名称', '设备内部编号', '规格', '品牌', '部门', '状态', '变更日期'],
            filterVal: ['pastureName', 'eqName', 'eqCode', 'specification', 'brandName', 'deptName', 'status', 'changeTime'],
            tableDatas: this.downLoadList,
            sheetName: '设备变更'
          }
        ]
        json2excel(elecExcelDatas, '设备变更', true, 'xlsx')
      })
    }
  }
}
</script>
