Browse Source

修改了计量检验预警bug

duanxiaoduan 11 months ago
parent
commit
417c01850a

BIN
dist.zip


File diff suppressed because it is too large
+ 0 - 0
dist/index.html


+ 630 - 630
src/views/special/earlyWarning/components/insulatAingAppliances.vue

@@ -1,630 +1,630 @@
-<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 v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 150px;">
-        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
-      </el-select>
-      <el-select v-model="getdataListParm.parammaps.status" placeholder="检验预警状态" class="filter-item" style="width: 150px;">
-        <el-option v-for="item in warningStatus" :key="item.id" :label="item.name" :value="item.name" />
-      </el-select>
-      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
-    </div>
-    <div class="app-btn">
-      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
-      <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
-      <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
-        <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
-      </el-upload>
-      <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
-    </div>
-    <el-table
-      :key="tableKey"
-      v-loading="listLoading"
-      element-loading-text="给我一点时间"
-      :data="list"
-      border
-      fit
-      highlight-current-row
-      style="width: 100%;"
-      :row-class-name="tableRowClassName"
-      :row-style="selectedHighlight"
-      :cell-style="cellStyle"
-      class="elTable table-fixed"
-      :max-height="myHeight"
-    >
-      <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="140px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.warnName }}</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="100px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.level }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="出厂编号" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.measureRange }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="出厂日期" min-width="80px" align="center" sortable prop="factoryNumber" />
-      <el-table-column label="使用部门" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.departmentName }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="责任人" min-width="100px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.empName }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="检验日期" min-width="80px" align="center" sortable prop="lastCheckDate" />
-      <el-table-column label="有效日期" min-width="110px" align="center" sortable prop="validityDate" />
-      <el-table-column label="校验周期" min-width="80px" align="center" sortable prop="amount" />
-      <el-table-column label="备注" min-width="110px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.note }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
-        <template slot-scope="{row}">
-          <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
-          <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
-          <el-button type="danger" size="mini" @click="form_delete(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" width="80%">
-      <div class="app-add">
-        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="115px" style="width: 90%;margin:0 auto 30px">
-          <el-row>
-            <el-col :span="8">
-              <el-form-item ref="pastureId" label="牧场:" prop="pastureId">
-                <el-select v-model="createTemp.pastureId " placeholder="请输入牧场" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changePasture">
-                  <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="warnName">
-                <el-input ref="warnName" v-model="createTemp.warnName" placeholder="请输入设备名称" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="规程型号:" prop="specification">
-                <el-input ref="specification" v-model="createTemp.specification" placeholder="请输入规格型号" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="生产厂家:" prop="level">
-                <el-input ref="level" v-model="createTemp.level" placeholder="请输入生产厂家" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="出厂编号:" prop="measureRange">
-                <el-input ref="measureRange" v-model="createTemp.measureRange" placeholder="请输入出厂编号" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="出场日期:" prop="factoryNumber">
-                <el-date-picker v-model="createTemp.factoryNumber" type="date" placeholder="请输入出场日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="使用部门:" prop="departmentName">
-                <el-select v-model="createTemp.departmentName" placeholder="请输入使用部门" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changeDepartment">
-                  <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.name" />
-                </el-select>
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="责任人:" prop="empName">
-                <el-select ref="empName" v-model="createTemp.empName" filterable placeholder="请输入责任人" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changeEmp">
-                  <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.name" />
-                </el-select>
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="检验日期:" prop="lastCheckDate">
-                <el-date-picker v-model="createTemp.lastCheckDate" :picker-options="pickerOptions1" type="date" placeholder="请输入检验日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="有效日期:" prop="validityDate">
-                <el-date-picker v-model="createTemp.validityDate" :picker-options="pickerOptions2" type="date" placeholder="请输入有效日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="检验周期:" prop="amount">
-                <el-input ref="amount" v-model="createTemp.amount" placeholder="请输入检验周期" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="备注:" prop="note">
-                <el-input ref="note" v-model="createTemp.note" placeholder="请输入备注" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
-        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
-          <el-button v-if="dialogStatus==='create' || dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
-          <el-button @click="dialogFormVisible = false; getdataListParm.parammaps.inputDatetime = ''">取消并关闭</el-button>
-        </div>
-      </div>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-import waves from '@/directive/waves'
-import { GetDataByNames, GetDataByName, PostDataByName, failproccess, GetAccount } from '@/api/common'
-import Cookies from 'js-cookie'
-import { json2excel } from '@/utils/index.js'
-import { MessageBox } from 'element-ui'
-import { getToken } from '@/utils/auth'
-import { parseTime } from '@/utils/index.js'
-import Pagination from '@/components/Pagination'
-export default {
-  name: 'InsulatAingAppliances',
-  directives: { waves },
-  components: { Pagination },
-  data() {
-    return {
-      myHeight:document.documentElement.clientHeight - 85- 250,
-      warningStatus: [{ id: 0, name: '全部' }, { id: 1, name: '正常' }, { id: 2, name: '预警期' }],
-      findAllPasture: [],
-      findAllDepart: [],
-      findAllEmploye: [],
-      requestParams: [
-        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
-        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
-        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
-      ],
-      rules: {
-        pastureId: [{ required: true, message: '必填', trigger: 'blur' }],
-        warnName: [{ required: true, message: '必填', trigger: 'blur' }],
-        specification: [{ required: true, message: '必填', trigger: 'blur' }],
-        lastCheckDate: [{ required: true, message: '必填', trigger: 'blur' }],
-        validityDate: [{ required: true, message: '必填', trigger: 'blur' }]
-      },
-      getdataListParm: {
-        name: 'getExaminewarningList',
-        page: 1,
-        offset: 1,
-        pagecount: 10,
-        returntype: 'Map',
-        parammaps: {
-          pastureName: Cookies.get('pasturename'),
-          warningType: '绝缘用具'
-        }
-      },
-      tableKey: 0,
-      listLoading: false,
-      total: 0,
-      list: [],
-      getIndexList: [],
-      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
-      cellStyle: { padding: 0 + 'px' },
-      pickerOptions1: {
-        disabledDate: (time) => {
-          if (this.createTemp.validityDate !== '') {
-            return parseTime(time.getTime(), '{y}-{m}-{d}') >= this.createTemp.validityDate
-          } else {
-            return ''
-          }
-        }
-      },
-      pickerOptions2: {
-        disabledDate: (time) => {
-          return parseTime(time.getTime(), '{y}-{m}-{d}') <= this.createTemp.lastCheckDate
-        }
-      },
-      createTemp: {
-        pastureId: this.$store.state.user.pastureid,
-        pastureName: this.$store.state.user.pasturename,
-        departmentName: this.$store.state.user.departmentname,
-        departmentId: this.$store.state.user.departmentid,
-        warnName: '',
-        specification: '',
-        level: '',
-        measureRange: '',
-        factoryNumber: '',
-        lastCheckDate: '',
-        validityDate: '',
-        amount: '',
-        note: '',
-        empId: '',
-        empName: ''
-      },
-      dialogFormVisible: false,
-      dialogStatus: '',
-      textMap: {
-        create: '新增',
-        update: '编辑',
-        see: '查看'
-      },
-      isokDisable: false,
-      postDataPramas: {},
-      downLoadParm: {},
-      isPercentage: false,
-      percentage: 1
-    }
-  },
-  computed: {
-    headers() {
-      return {
-        token: getToken()
-      }
-    },
-    uploadData() {
-      return {
-        name: 'uploadExaminewarnJY',
-        importParams: '牧场,设备名称,规程型号,生产厂家,出厂编号,出厂日期,使用部门,责任人,校验日期,有效期至,校验周期,备注',
-        sheetname: 'SheetJS'
-      }
-    },
-    // 设置上传地址
-    uploadExcelUrl() {
-      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
-    }
-  },
-  created() {
-    this.get_select_list()
-    this.get_table_data()
-  },
-
-  // 设置变量
-
-  methods: {
-    get_select_list() {
-      GetDataByNames(this.requestParams).then(response => {
-        this.findAllPasture = response.data.findAllPasture.list
-        this.findAllDepart = response.data.findAllDepart.list
-        this.findAllEmploye = response.data.findAllEmploye.list
-      })
-    },
-    getNextDate(date, day) {
-      var dd = new Date(date)
-      dd.setDate(dd.getDate() + day)
-      var y = dd.getFullYear()
-      var m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1
-      var d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
-      return y + '-' + m + '-' + d
-    },
-    tableRowClassName({ row, rowIndex }) {
-      // 把每一行的索引放进row
-      row.index = rowIndex
-    },
-    get_table_data() {
-      this.listLoading = true
-      GetDataByName(this.getdataListParm).then(response => {
-        if (response.data.list !== null || response.data !== null) {
-          this.list = []
-        } else {
-          console.log('table数据', response.data.list)
-          this.getIndexList = []
-          for (let i = 0; i < response.data.list.length; i++) {
-            response.data.list[i].index = i
-            if (this.getNextDate(response.data.list[i].validityDate, -30) <= parseTime(new Date(), '{y}-{m}-{d}')) {
-              this.getIndexList.push({ 'myindex': response.data.list[i].index })
-            }
-          }
-          this.list = response.data.list
-          this.pageNum = response.data.pageNum
-          this.pageSize = response.data.pageSize
-          this.total = response.data.total
-        }
-        setTimeout(() => {
-          this.listLoading = false
-        }, 100)
-      })
-    },
-    selectedHighlight({ row, rowIndex }) {
-      for (let i = 0; i < this.getIndexList.length; i++) {
-        if (this.getIndexList[i].myindex === rowIndex) {
-          return {
-            color: 'red'
-          }
-        }
-      }
-    },
-
-    form_search() {
-      console.log('点击了搜索')
-      this.getdataListParm.offset = 1
-      this.get_table_data()
-    },
-    resetCreateTemp() {
-      this.createTemp.pastureId = this.$store.state.user.pastureid
-      this.createTemp.pastureName = this.$store.state.user.pasturename
-      this.createTemp.departmentName = this.$store.state.user.departmentname
-      this.createTemp.departmentId = this.$store.state.user.departmentid
-      this.createTemp.warnName = ''
-      this.createTemp.specification = ''
-      this.createTemp.level = ''
-      this.createTemp.measureRange = ''
-      this.createTemp.factoryNumber = ''
-      this.createTemp.lastCheckDate = ''
-      this.createTemp.validityDate = ''
-      this.createTemp.amount = ''
-      this.createTemp.note = ''
-      this.createTemp.empName = ''
-      this.createTemp.empId = ''
-    },
-    form_add() {
-      console.log('点击了新增')
-      this.resetCreateTemp()
-      this.dialogStatus = 'create'
-      this.dialogFormVisible = true
-    },
-    changePasture(item) {
-      this.createTemp.pastureName = this.findAllPasture.find(obj => obj.id === item).name
-    },
-    changeDepartment(item) {
-      this.createTemp.departmentId = this.findAllDepart.find(obj => obj.name === item).id
-    },
-    changeEmp(item) {
-      this.createTemp.empId = this.findAllEmploye.find(obj => obj.name === item).id
-    },
-    add_dialog_save() {
-      console.log('点击了保存')
-      this.isokDisable = true
-      setTimeout(() => {
-        this.isokDisable = false
-      }, 1000)
-      this.$refs['createTemp'].validate(valid => {
-        if (valid) {
-          this.postDataPramas.name = 'insertExaminewarning'
-          this.postDataPramas.parammaps = {}
-          this.postDataPramas.parammaps = this.createTemp
-          this.postDataPramas.parammaps.warningType = '绝缘用具'
-          PostDataByName(this.postDataPramas).then(response => {
-            console.log('新增保存发送参数', this.postDataPramas)
-            if (response.msg !== 'fail') {
-              this.dialogFormVisible = false
-              this.get_table_data()
-              this.$notify({
-                title: '成功',
-                message: '新增成功',
-                type: 'success',
-                duration: 2000
-              })
-            } else {
-              failproccess(response, this.$notify)
-            }
-          })
-        }
-      })
-    },
-    form_edit(row) {
-      console.log('点击了编辑')
-      this.dialogStatus = 'update'
-      this.dialogFormVisible = true
-      this.createTemp = Object.assign({}, row)
-      this.createTemp.pastureId = parseFloat(row.pastureId)
-      this.createTemp.departmentId = parseFloat(row.departmentId)
-      this.createTemp.empId = parseFloat(row.empId)
-    },
-    edit_dialog_save() {
-      console.log('点击了编辑保存')
-      this.isokDisable = true
-      setTimeout(() => {
-        this.isokDisable = false
-      }, 1000)
-      this.$refs['createTemp'].validate(valid => {
-        if (valid) {
-          this.postDataPramas.name = 'updateExaminewarning'
-          this.postDataPramas.parammaps = {}
-          this.postDataPramas.parammaps = this.createTemp
-          this.postDataPramas.parammaps.id = this.createTemp.id
-          this.postDataPramas.parammaps.warningType = '绝缘用具'
-          PostDataByName(this.postDataPramas).then(response => {
-            console.log('编辑保存发送参数', this.postDataPramas)
-            if (response.msg !== 'fail') {
-              this.dialogFormVisible = false
-              this.get_table_data()
-              this.$notify({
-                title: '成功',
-                message: '保存成功',
-                type: 'success',
-                duration: 2000
-              })
-            } else {
-              failproccess(response, this.$notify)
-            }
-          })
-        }
-      })
-    },
-    form_see(row) {
-      console.log('点击了查看', row)
-      this.dialogStatus = 'see'
-      this.dialogFormVisible = true
-      this.createTemp = Object.assign({}, row)
-      this.createTemp.pastureId = parseFloat(row.pastureId)
-      this.createTemp.departmentId = parseFloat(row.departmentId)
-      this.createTemp.empId = parseFloat(row.empId)
-    },
-    form_delete(row) {
-      MessageBox.confirm('确认删除此信息?', {
-        confirmButtonText: '确认',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        console.log('点击了删除', row)
-        this.postDataPramas.name = 'deleteExaminewarning'
-        this.postDataPramas.parammaps = {}
-        this.postDataPramas.parammaps.id = row.id
-        this.postDataPramas.parammaps.warningType = '绝缘用具'
-        PostDataByName(this.postDataPramas).then(response => {
-          console.log('删除保存发送参数', this.postDataPramas)
-          if (response.msg !== 'fail') {
-            this.dialogFormVisible = false
-            this.get_table_data()
-            this.$notify({
-              title: '成功',
-              message: '删除成功',
-              type: 'success',
-              duration: 2000
-            })
-          } else {
-            failproccess(response, this.$notify)
-          }
-        })
-      })
-    },
-    handleDownloadTemp() {
-      console.log('点击了模板')
-      import('@/vendor/Export2Excel').then(excel => {
-        const list1 = []
-        const tHeader = [
-          '牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注'
-        ]
-        const filterVal = [
-          '牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注'
-        ]
-        const data1 = this.formatJson(filterVal, list1)
-        excel.export_json_to_excel({
-          header: tHeader,
-          data: data1,
-          filename: '绝缘用具模板',
-          autoWidth: true,
-          bookType: 'xlsx'
-        })
-      })
-    },
-    beforeImportExcel(file) {
-      const isLt2M = file.size / 1024 / 1024 < 6
-      if (!isLt2M) {
-        this.$message.error('上传文件大小不能超过 6MB!')
-      }
-      return isLt2M
-    },
-    handleImportExcelSuccess(res, file) {
-      this.get_table_data()
-      if (res.msg === 'ok') {
-        this.$message({
-          title: '成功',
-          message: '导入成功:' + res.data.success + '条!',
-          type: 'success',
-          duration: 2000
-        })
-        if (res.data.err_count > 0) {
-          this.$notify({
-            title: '失败',
-            message: '导入失败:' + res.data.err_count + '条!',
-            type: 'danger',
-            duration: 2000
-          })
-           import('@/vendor/Export2Excel').then(excel => {
-             const list1 = res.data.result
-             const tHeader = [
-               '牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注', '报错信息'
-             ]
-             const filterVal = [
-               '牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注', 'error_msg'
-             ]
-             const data1 = this.formatJson(filterVal, list1)
-             excel.export_json_to_excel({
-               header: tHeader,
-               data: data1,
-               filename: '绝缘用具报错信息',
-               autoWidth: true,
-               bookType: 'xlsx'
-             })
-           })
-        }
-      } else {
-        this.$notify({
-          title: '失败',
-          message: '上传失败',
-          type: 'danger',
-          duration: 2000
-        })
-      }
-    },
-    formatJson(filterVal, jsonData) {
-      return jsonData.map(v =>
-        filterVal.map(j => {
-          if (j === 'timestamp') {
-            return parseTime(v[j])
-          } else {
-            return v[j]
-          }
-        })
-      )
-    },
-    handleDownload() {
-      console.log('点击了导出')
-      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 = 'getExaminewarningList'
-      this.downLoadParm.parammaps = this.getdataListParm.parammaps
-      GetAccount(this.downLoadParm).then(response => {
-        if (response.data.list !== '') {
-          this.percentage = 99
-          setTimeout(() => {
-            this.isPercentage = false
-          }, 2000)
-        }
-        this.$nextTick(() => {
-          this.downLoadList = response.data.list
-          console.log('导出table数据', this.downLoadList)
-          const ExcelDatas = [
-            {
-              tHeader: ['牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注'],
-              filterVal: ['pastureName', 'warnName', 'specification', 'level', 'measureRange', 'factoryNumber', 'departmentName', 'empName', 'lastCheckDate', 'validityDate', 'amount', 'note'],
-              tableDatas: this.downLoadList,
-              sheetName: '绝缘用具'
-            }
-          ]
-          json2excel(ExcelDatas, '绝缘用具', true, 'xlsx')
-        })
-      })
-    }
-
-  }
-}
-</script>
-<style lang="scss" scoped>
-.app-btn {
-  margin-bottom: 10px;
-}
-</style>
-
+<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 v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 150px;">
+        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
+      </el-select>
+      <el-select v-model="getdataListParm.parammaps.status" placeholder="检验预警状态" class="filter-item" style="width: 150px;">
+        <el-option v-for="item in warningStatus" :key="item.id" :label="item.name" :value="item.name" />
+      </el-select>
+      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
+    </div>
+    <div class="app-btn">
+      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
+      <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
+      <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
+        <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
+      </el-upload>
+      <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
+    </div>
+    <el-table
+      :key="tableKey"
+      v-loading="listLoading"
+      element-loading-text="给我一点时间"
+      :data="list"
+      border
+      fit
+      highlight-current-row
+      style="width: 100%;"
+      :row-class-name="tableRowClassName"
+      :row-style="selectedHighlight"
+      :cell-style="cellStyle"
+      class="elTable table-fixed"
+      :max-height="myHeight"
+    >
+      <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="140px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.warnName }}</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="100px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.level }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="出厂编号" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.measureRange }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="出厂日期" min-width="80px" align="center" sortable prop="factoryNumber" />
+      <el-table-column label="使用部门" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.departmentName }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="责任人" min-width="100px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.empName }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="检验日期" min-width="80px" align="center" sortable prop="lastCheckDate" />
+      <el-table-column label="有效日期" min-width="110px" align="center" sortable prop="validityDate" />
+      <el-table-column label="校验周期" min-width="80px" align="center" sortable prop="amount" />
+      <el-table-column label="备注" min-width="110px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.note }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
+        <template slot-scope="{row}">
+          <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
+          <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
+          <el-button type="danger" size="mini" @click="form_delete(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" width="80%">
+      <div class="app-add">
+        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="115px" style="width: 90%;margin:0 auto 30px">
+          <el-row>
+            <el-col :span="8">
+              <el-form-item ref="pastureId" label="牧场:" prop="pastureId">
+                <el-select v-model="createTemp.pastureId " placeholder="请输入牧场" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changePasture">
+                  <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="warnName">
+                <el-input ref="warnName" v-model="createTemp.warnName" placeholder="请输入设备名称" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="规程型号:" prop="specification">
+                <el-input ref="specification" v-model="createTemp.specification" placeholder="请输入规格型号" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="生产厂家:" prop="level">
+                <el-input ref="level" v-model="createTemp.level" placeholder="请输入生产厂家" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="出厂编号:" prop="measureRange">
+                <el-input ref="measureRange" v-model="createTemp.measureRange" placeholder="请输入出厂编号" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="出场日期:" prop="factoryNumber">
+                <el-date-picker v-model="createTemp.factoryNumber" type="date" placeholder="请输入出场日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="使用部门:" prop="departmentName">
+                <el-select v-model="createTemp.departmentName" placeholder="请输入使用部门" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changeDepartment">
+                  <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.name" />
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="责任人:" prop="empName">
+                <el-select ref="empName" v-model="createTemp.empName" filterable placeholder="请输入责任人" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changeEmp">
+                  <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.name" />
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="检验日期:" prop="lastCheckDate">
+                <el-date-picker v-model="createTemp.lastCheckDate" :picker-options="pickerOptions1" type="date" placeholder="请输入检验日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="有效日期:" prop="validityDate">
+                <el-date-picker v-model="createTemp.validityDate" :picker-options="pickerOptions2" type="date" placeholder="请输入有效日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="检验周期:" prop="amount">
+                <el-input ref="amount" v-model="createTemp.amount" placeholder="请输入检验周期" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="备注:" prop="note">
+                <el-input ref="note" v-model="createTemp.note" placeholder="请输入备注" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
+          <el-button v-if="dialogStatus==='create' || dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
+          <el-button @click="dialogFormVisible = false; getdataListParm.parammaps.inputDatetime = ''">取消并关闭</el-button>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import waves from '@/directive/waves'
+import { GetDataByNames, GetDataByName, PostDataByName, failproccess, GetAccount } from '@/api/common'
+import Cookies from 'js-cookie'
+import { json2excel } from '@/utils/index.js'
+import { MessageBox } from 'element-ui'
+import { getToken } from '@/utils/auth'
+import { parseTime } from '@/utils/index.js'
+import Pagination from '@/components/Pagination'
+export default {
+  name: 'InsulatAingAppliances',
+  directives: { waves },
+  components: { Pagination },
+  data() {
+    return {
+      myHeight:document.documentElement.clientHeight - 85- 250,
+      warningStatus: [{ id: 0, name: '全部' }, { id: 1, name: '正常' }, { id: 2, name: '预警期' }],
+      findAllPasture: [],
+      findAllDepart: [],
+      findAllEmploye: [],
+      requestParams: [
+        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
+        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
+        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
+      ],
+      rules: {
+        pastureId: [{ required: true, message: '必填', trigger: 'blur' }],
+        warnName: [{ required: true, message: '必填', trigger: 'blur' }],
+        specification: [{ required: true, message: '必填', trigger: 'blur' }],
+        lastCheckDate: [{ required: true, message: '必填', trigger: 'blur' }],
+        validityDate: [{ required: true, message: '必填', trigger: 'blur' }]
+      },
+      getdataListParm: {
+        name: 'getExaminewarningList',
+        page: 1,
+        offset: 1,
+        pagecount: 10,
+        returntype: 'Map',
+        parammaps: {
+          pastureName: Cookies.get('pasturename'),
+          warningType: '绝缘用具'
+        }
+      },
+      tableKey: 0,
+      listLoading: false,
+      total: 0,
+      list: [],
+      getIndexList: [],
+      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
+      cellStyle: { padding: 0 + 'px' },
+      pickerOptions1: {
+        disabledDate: (time) => {
+          if (this.createTemp.validityDate !== '') {
+            return parseTime(time.getTime(), '{y}-{m}-{d}') >= this.createTemp.validityDate
+          } else {
+            return ''
+          }
+        }
+      },
+      pickerOptions2: {
+        disabledDate: (time) => {
+          return parseTime(time.getTime(), '{y}-{m}-{d}') <= this.createTemp.lastCheckDate
+        }
+      },
+      createTemp: {
+        pastureId: this.$store.state.user.pastureid,
+        pastureName: this.$store.state.user.pasturename,
+        departmentName: this.$store.state.user.departmentname,
+        departmentId: this.$store.state.user.departmentid,
+        warnName: '',
+        specification: '',
+        level: '',
+        measureRange: '',
+        factoryNumber: '',
+        lastCheckDate: '',
+        validityDate: '',
+        amount: '',
+        note: '',
+        empId: '',
+        empName: ''
+      },
+      dialogFormVisible: false,
+      dialogStatus: '',
+      textMap: {
+        create: '新增',
+        update: '编辑',
+        see: '查看'
+      },
+      isokDisable: false,
+      postDataPramas: {},
+      downLoadParm: {},
+      isPercentage: false,
+      percentage: 1
+    }
+  },
+  computed: {
+    headers() {
+      return {
+        token: getToken()
+      }
+    },
+    uploadData() {
+      return {
+        name: 'uploadExaminewarnJY',
+        importParams: '牧场,设备名称,规程型号,生产厂家,出厂编号,出厂日期,使用部门,责任人,校验日期,有效期至,校验周期,备注',
+        sheetname: 'SheetJS'
+      }
+    },
+    // 设置上传地址
+    uploadExcelUrl() {
+      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
+    }
+  },
+  created() {
+    this.get_select_list()
+    this.get_table_data()
+  },
+
+  // 设置变量
+
+  methods: {
+    get_select_list() {
+      GetDataByNames(this.requestParams).then(response => {
+        this.findAllPasture = response.data.findAllPasture.list
+        this.findAllDepart = response.data.findAllDepart.list
+        this.findAllEmploye = response.data.findAllEmploye.list
+      })
+    },
+    getNextDate(date, day) {
+      var dd = new Date(date)
+      dd.setDate(dd.getDate() + day)
+      var y = dd.getFullYear()
+      var m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1
+      var d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
+      return y + '-' + m + '-' + d
+    },
+    tableRowClassName({ row, rowIndex }) {
+      // 把每一行的索引放进row
+      row.index = rowIndex
+    },
+    get_table_data() {
+      this.listLoading = true
+      GetDataByName(this.getdataListParm).then(response => {
+        if (response.data.list !== null || response.data !== null) {
+          console.log('table数据', response.data.list)
+          this.getIndexList = []
+          for (let i = 0; i < response.data.list.length; i++) {
+            response.data.list[i].index = i
+            if (this.getNextDate(response.data.list[i].validityDate, -30) <= parseTime(new Date(), '{y}-{m}-{d}')) {
+              this.getIndexList.push({ 'myindex': response.data.list[i].index })
+            }
+          }
+          this.list = response.data.list
+          this.pageNum = response.data.pageNum
+          this.pageSize = response.data.pageSize
+          this.total = response.data.total
+        } else {
+          this.list = []
+        }
+        setTimeout(() => {
+          this.listLoading = false
+        }, 100)
+      })
+    },
+    selectedHighlight({ row, rowIndex }) {
+      for (let i = 0; i < this.getIndexList.length; i++) {
+        if (this.getIndexList[i].myindex === rowIndex) {
+          return {
+            color: 'red'
+          }
+        }
+      }
+    },
+
+    form_search() {
+      console.log('点击了搜索')
+      this.getdataListParm.offset = 1
+      this.get_table_data()
+    },
+    resetCreateTemp() {
+      this.createTemp.pastureId = this.$store.state.user.pastureid
+      this.createTemp.pastureName = this.$store.state.user.pasturename
+      this.createTemp.departmentName = this.$store.state.user.departmentname
+      this.createTemp.departmentId = this.$store.state.user.departmentid
+      this.createTemp.warnName = ''
+      this.createTemp.specification = ''
+      this.createTemp.level = ''
+      this.createTemp.measureRange = ''
+      this.createTemp.factoryNumber = ''
+      this.createTemp.lastCheckDate = ''
+      this.createTemp.validityDate = ''
+      this.createTemp.amount = ''
+      this.createTemp.note = ''
+      this.createTemp.empName = ''
+      this.createTemp.empId = ''
+    },
+    form_add() {
+      console.log('点击了新增')
+      this.resetCreateTemp()
+      this.dialogStatus = 'create'
+      this.dialogFormVisible = true
+    },
+    changePasture(item) {
+      this.createTemp.pastureName = this.findAllPasture.find(obj => obj.id === item).name
+    },
+    changeDepartment(item) {
+      this.createTemp.departmentId = this.findAllDepart.find(obj => obj.name === item).id
+    },
+    changeEmp(item) {
+      this.createTemp.empId = this.findAllEmploye.find(obj => obj.name === item).id
+    },
+    add_dialog_save() {
+      console.log('点击了保存')
+      this.isokDisable = true
+      setTimeout(() => {
+        this.isokDisable = false
+      }, 1000)
+      this.$refs['createTemp'].validate(valid => {
+        if (valid) {
+          this.postDataPramas.name = 'insertExaminewarning'
+          this.postDataPramas.parammaps = {}
+          this.postDataPramas.parammaps = this.createTemp
+          this.postDataPramas.parammaps.warningType = '绝缘用具'
+          PostDataByName(this.postDataPramas).then(response => {
+            console.log('新增保存发送参数', this.postDataPramas)
+            if (response.msg !== 'fail') {
+              this.dialogFormVisible = false
+              this.get_table_data()
+              this.$notify({
+                title: '成功',
+                message: '新增成功',
+                type: 'success',
+                duration: 2000
+              })
+            } else {
+              failproccess(response, this.$notify)
+            }
+          })
+        }
+      })
+    },
+    form_edit(row) {
+      console.log('点击了编辑')
+      this.dialogStatus = 'update'
+      this.dialogFormVisible = true
+      this.createTemp = Object.assign({}, row)
+      this.createTemp.pastureId = parseFloat(row.pastureId)
+      this.createTemp.departmentId = parseFloat(row.departmentId)
+      this.createTemp.empId = parseFloat(row.empId)
+    },
+    edit_dialog_save() {
+      console.log('点击了编辑保存')
+      this.isokDisable = true
+      setTimeout(() => {
+        this.isokDisable = false
+      }, 1000)
+      this.$refs['createTemp'].validate(valid => {
+        if (valid) {
+          this.postDataPramas.name = 'updateExaminewarning'
+          this.postDataPramas.parammaps = {}
+          this.postDataPramas.parammaps = this.createTemp
+          this.postDataPramas.parammaps.id = this.createTemp.id
+          this.postDataPramas.parammaps.warningType = '绝缘用具'
+          PostDataByName(this.postDataPramas).then(response => {
+            console.log('编辑保存发送参数', this.postDataPramas)
+            if (response.msg !== 'fail') {
+              this.dialogFormVisible = false
+              this.get_table_data()
+              this.$notify({
+                title: '成功',
+                message: '保存成功',
+                type: 'success',
+                duration: 2000
+              })
+            } else {
+              failproccess(response, this.$notify)
+            }
+          })
+        }
+      })
+    },
+    form_see(row) {
+      console.log('点击了查看', row)
+      this.dialogStatus = 'see'
+      this.dialogFormVisible = true
+      this.createTemp = Object.assign({}, row)
+      this.createTemp.pastureId = parseFloat(row.pastureId)
+      this.createTemp.departmentId = parseFloat(row.departmentId)
+      this.createTemp.empId = parseFloat(row.empId)
+    },
+    form_delete(row) {
+      MessageBox.confirm('确认删除此信息?', {
+        confirmButtonText: '确认',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        console.log('点击了删除', row)
+        this.postDataPramas.name = 'deleteExaminewarning'
+        this.postDataPramas.parammaps = {}
+        this.postDataPramas.parammaps.id = row.id
+        this.postDataPramas.parammaps.warningType = '绝缘用具'
+        PostDataByName(this.postDataPramas).then(response => {
+          console.log('删除保存发送参数', this.postDataPramas)
+          if (response.msg !== 'fail') {
+            this.dialogFormVisible = false
+            this.get_table_data()
+            this.$notify({
+              title: '成功',
+              message: '删除成功',
+              type: 'success',
+              duration: 2000
+            })
+          } else {
+            failproccess(response, this.$notify)
+          }
+        })
+      })
+    },
+    handleDownloadTemp() {
+      console.log('点击了模板')
+      import('@/vendor/Export2Excel').then(excel => {
+        const list1 = []
+        const tHeader = [
+          '牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注'
+        ]
+        const filterVal = [
+          '牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注'
+        ]
+        const data1 = this.formatJson(filterVal, list1)
+        excel.export_json_to_excel({
+          header: tHeader,
+          data: data1,
+          filename: '绝缘用具模板',
+          autoWidth: true,
+          bookType: 'xlsx'
+        })
+      })
+    },
+    beforeImportExcel(file) {
+      const isLt2M = file.size / 1024 / 1024 < 6
+      if (!isLt2M) {
+        this.$message.error('上传文件大小不能超过 6MB!')
+      }
+      return isLt2M
+    },
+    handleImportExcelSuccess(res, file) {
+      this.get_table_data()
+      if (res.msg === 'ok') {
+        this.$message({
+          title: '成功',
+          message: '导入成功:' + res.data.success + '条!',
+          type: 'success',
+          duration: 2000
+        })
+        if (res.data.err_count > 0) {
+          this.$notify({
+            title: '失败',
+            message: '导入失败:' + res.data.err_count + '条!',
+            type: 'danger',
+            duration: 2000
+          })
+           import('@/vendor/Export2Excel').then(excel => {
+             const list1 = res.data.result
+             const tHeader = [
+               '牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注', '报错信息'
+             ]
+             const filterVal = [
+               '牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注', 'error_msg'
+             ]
+             const data1 = this.formatJson(filterVal, list1)
+             excel.export_json_to_excel({
+               header: tHeader,
+               data: data1,
+               filename: '绝缘用具报错信息',
+               autoWidth: true,
+               bookType: 'xlsx'
+             })
+           })
+        }
+      } else {
+        this.$notify({
+          title: '失败',
+          message: '上传失败',
+          type: 'danger',
+          duration: 2000
+        })
+      }
+    },
+    formatJson(filterVal, jsonData) {
+      return jsonData.map(v =>
+        filterVal.map(j => {
+          if (j === 'timestamp') {
+            return parseTime(v[j])
+          } else {
+            return v[j]
+          }
+        })
+      )
+    },
+    handleDownload() {
+      console.log('点击了导出')
+      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 = 'getExaminewarningList'
+      this.downLoadParm.parammaps = this.getdataListParm.parammaps
+      GetAccount(this.downLoadParm).then(response => {
+        if (response.data.list !== '') {
+          this.percentage = 99
+          setTimeout(() => {
+            this.isPercentage = false
+          }, 2000)
+        }
+        this.$nextTick(() => {
+          this.downLoadList = response.data.list
+          console.log('导出table数据', this.downLoadList)
+          const ExcelDatas = [
+            {
+              tHeader: ['牧场', '设备名称', '规程型号', '生产厂家', '出厂编号', '出厂日期', '使用部门', '责任人', '校验日期', '有效期至', '校验周期', '备注'],
+              filterVal: ['pastureName', 'warnName', 'specification', 'level', 'measureRange', 'factoryNumber', 'departmentName', 'empName', 'lastCheckDate', 'validityDate', 'amount', 'note'],
+              tableDatas: this.downLoadList,
+              sheetName: '绝缘用具'
+            }
+          ]
+          json2excel(ExcelDatas, '绝缘用具', true, 'xlsx')
+        })
+      })
+    }
+
+  }
+}
+</script>
+<style lang="scss" scoped>
+.app-btn {
+  margin-bottom: 10px;
+}
+</style>
+

+ 650 - 650
src/views/special/earlyWarning/components/pressureGauge.vue

@@ -1,650 +1,650 @@
-<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 v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 150px;">
-        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
-      </el-select>
-      <el-select v-model="getdataListParm.parammaps.status" placeholder="检验预警状态" class="filter-item" style="width: 150px;">
-        <el-option v-for="item in warningStatus" :key="item.id" :label="item.name" :value="item.name" />
-      </el-select>
-      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
-    </div>
-    <div class="app-btn">
-      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
-      <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
-      <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
-        <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
-      </el-upload>
-      <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
-    </div>
-    <el-table
-      :key="tableKey"
-      v-loading="listLoading"
-      element-loading-text="给我一点时间"
-      :data="list"
-      border
-      fit
-      highlight-current-row
-      style="width: 100%;"
-      :row-class-name="tableRowClassName"
-      :row-style="selectedHighlight"
-      :cell-style="cellStyle"
-      class="elTable table-fixed"
-      :max-height="myHeight"
-    >
-      <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="140px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.warnName }}</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="150px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.level }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="测量范围" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.measureRange }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="出厂编号" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.factoryNumber }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="数量" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.amount }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="制造单位" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.unit }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="检定周期" min-width="100px" align="center" sortable prop="cycle" />
-      <el-table-column label="检验日期" min-width="80px" align="center" sortable prop="lastCheckDate" />
-      <el-table-column label="有效日期" min-width="110px" align="center" sortable prop="validityDate" />
-      <el-table-column label="检定单位" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.warnUnit }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="计量器具用途" min-width="110px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.purpose }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="安装使用地点" min-width="110px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.location }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
-        <template slot-scope="{row}">
-          <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
-          <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
-          <el-button type="danger" size="mini" @click="form_delete(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" width="80%">
-      <div class="app-add">
-        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="145px" style="width: 90%;margin:0 auto 30px">
-          <el-row>
-            <el-col :span="8">
-              <el-form-item ref="pastureId" label="牧场:" prop="pastureId">
-                <el-select v-model="createTemp.pastureId " placeholder="请输入牧场" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changePasture">
-                  <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="warnName">
-                <el-input ref="warnName" v-model="createTemp.warnName" placeholder="请输入计量器具名称" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="规格型号:" prop="specification">
-                <el-input ref="specification" v-model="createTemp.specification" placeholder="请输入规格型号" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="准确度等级、不确定度或最大允许误差:" prop="level">
-                <el-input ref="level" v-model="createTemp.level" placeholder="请输入准确度等级、不确定度或最大允许误差" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="测量范围:" prop="measureRange">
-                <el-input ref="measureRange" v-model="createTemp.measureRange" placeholder="请输入测量范围" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="出厂编号:" prop="factoryNumber">
-                <el-input ref="factoryNumber" v-model="createTemp.factoryNumber" placeholder="请输入出厂编号" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="数量:" prop="amount">
-                <el-input ref="amount" v-model="createTemp.amount" placeholder="请输入数量" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="制造单位:" prop="unit">
-                <el-input ref="unit" v-model="createTemp.unit" placeholder="请输入制造单位" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="检定周期:" prop="cycle">
-                <el-input ref="cycle" v-model="createTemp.cycle" placeholder="请输入检定周期" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="检验日期:" prop="lastCheckDate">
-                <el-date-picker v-model="createTemp.lastCheckDate" :picker-options="pickerOptions1" type="date" placeholder="请输入检验日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="有效日期:" prop="validityDate">
-                <el-date-picker v-model="createTemp.validityDate" :picker-options="pickerOptions2" type="date" placeholder="请输入有效日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="检定单位:" prop="warnUnit">
-                <el-input ref="warnUnit" v-model="createTemp.warnUnit" placeholder="请输入检定单位" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="计量器具用途:" prop="purpose">
-                <el-input ref="purpose" v-model="createTemp.purpose" placeholder="请输入计量器具用途" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="安装使用地点:" prop="location">
-                <el-input ref="location" v-model="createTemp.location" placeholder="请输入安装使用地点" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
-        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
-          <el-button v-if="dialogStatus==='create' || dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
-          <el-button @click="dialogFormVisible = false; getdataListParm.parammaps.inputDatetime = ''">取消并关闭</el-button>
-        </div>
-      </div>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-import waves from '@/directive/waves'
-import { GetDataByNames, GetDataByName, PostDataByName, failproccess, GetAccount } from '@/api/common'
-import Cookies from 'js-cookie'
-import { json2excel } from '@/utils/index.js'
-import { MessageBox } from 'element-ui'
-import { getToken } from '@/utils/auth'
-import { parseTime } from '@/utils/index.js'
-import Pagination from '@/components/Pagination'
-export default {
-  name: 'PressureGauge',
-  directives: { waves },
-  components: { Pagination },
-  data() {
-    return {
-      myHeight:document.documentElement.clientHeight - 85- 250,
-      warningStatus: [{ id: 0, name: '全部' }, { id: 1, name: '正常' }, { id: 2, name: '预警期' }],
-      findAllPasture: [],
-      findAllDepart: [],
-      findAllEmploye: [],
-      requestParams: [
-        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
-        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
-        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
-      ],
-      rules: {
-        pastureId: [{ required: true, message: '必填', trigger: 'blur' }],
-        warnName: [{ required: true, message: '必填', trigger: 'blur' }],
-        specification: [{ required: true, message: '必填', trigger: 'blur' }],
-        lastCheckDate: [{ required: true, message: '必填', trigger: 'blur' }],
-        validityDate: [{ required: true, message: '必填', trigger: 'blur' }]
-      },
-      getdataListParm: {
-        name: 'getExaminewarningList',
-        page: 1,
-        offset: 1,
-        pagecount: 10,
-        returntype: 'Map',
-        parammaps: {
-          pastureName: Cookies.get('pasturename'),
-          warningType: '压力表'
-        }
-      },
-      tableKey: 0,
-      listLoading: false,
-      total: 0,
-      list: [],
-      getIndexList: [],
-      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
-      cellStyle: { padding: 0 + 'px' },
-      pickerOptions1: {
-        disabledDate: (time) => {
-          if (this.createTemp.validityDate !== '') {
-            return parseTime(time.getTime(), '{y}-{m}-{d}') >= this.createTemp.validityDate
-          } else {
-            return ''
-          }
-        }
-      },
-      pickerOptions2: {
-        disabledDate: (time) => {
-          return parseTime(time.getTime(), '{y}-{m}-{d}') <= this.createTemp.lastCheckDate
-        }
-      },
-      createTemp: {
-        pastureId: this.$store.state.user.pastureid,
-        pastureName: this.$store.state.user.pasturename,
-        // departmentName: this.$store.state.user.departmentname,
-        // departmentId: this.$store.state.user.departmentid,
-        warnName: '',
-        specification: '',
-        level: '',
-        measureRange: '',
-        factoryNumber: '',
-        amount: '',
-        unit: '',
-        cycle: '',
-        lastCheckDate: '',
-        validityDate: '',
-        warnUnit: '',
-        purpose: '',
-        location: ''
-      },
-      dialogFormVisible: false,
-      dialogStatus: '',
-      textMap: {
-        create: '新增',
-        update: '编辑',
-        see: '查看'
-      },
-      isokDisable: false,
-      postDataPramas: {},
-      downLoadParm: {},
-      isPercentage: false,
-      percentage: 1
-    }
-  },
-  computed: {
-    headers() {
-      return {
-        token: getToken()
-      }
-    },
-    uploadData() {
-      return {
-        name: 'uploadExaminewarnYLB',
-        importParams: '牧场,计量器具名称,规格型号,准确度等级、不确定度或最大允许误差,测量范围,出厂编号,数量,制造单位,检定周期,上次检定日期,有效期至,检定单位,计量器具用途,安装使用地点',
-        sheetname: 'SheetJS'
-      }
-    },
-    // 设置上传地址
-    uploadExcelUrl() {
-      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
-    }
-  },
-  created() {
-    this.get_select_list()
-    this.get_table_data()
-  },
-
-  // 设置变量
-
-  methods: {
-    get_select_list() {
-      GetDataByNames(this.requestParams).then(response => {
-        this.findAllPasture = response.data.findAllPasture.list
-        this.findAllDepart = response.data.findAllDepart.list
-        this.findAllEmploye = response.data.findAllEmploye.list
-      })
-    },
-    getNextDate(date, day) {
-      var dd = new Date(date)
-      dd.setDate(dd.getDate() + day)
-      var y = dd.getFullYear()
-      var m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1
-      var d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
-      return y + '-' + m + '-' + d
-    },
-    tableRowClassName({ row, rowIndex }) {
-      // 把每一行的索引放进row
-      row.index = rowIndex
-    },
-    get_table_data() {
-      this.listLoading = true
-      GetDataByName(this.getdataListParm).then(response => {
-        if (response.data.list !== null || response.data !== null) {
-          this.list = []
-        } else {
-          console.log('table数据', response.data.list)
-          this.getIndexList = []
-          for (let i = 0; i < response.data.list.length; i++) {
-            response.data.list[i].index = i
-            if (this.getNextDate(response.data.list[i].validityDate, -30) <= parseTime(new Date(), '{y}-{m}-{d}')) {
-              this.getIndexList.push({ 'myindex': response.data.list[i].index })
-            }
-          }
-          this.list = response.data.list
-          this.pageNum = response.data.pageNum
-          this.pageSize = response.data.pageSize
-          this.total = response.data.total
-        }
-        setTimeout(() => {
-          this.listLoading = false
-        }, 100)
-      })
-    },
-    selectedHighlight({ row, rowIndex }) {
-      for (let i = 0; i < this.getIndexList.length; i++) {
-        if (this.getIndexList[i].myindex === rowIndex) {
-          return {
-            color: 'red'
-          }
-        }
-      }
-    },
-
-    form_search() {
-      console.log('点击了搜索')
-      this.getdataListParm.offset = 1
-      this.get_table_data()
-    },
-    resetCreateTemp() {
-      this.createTemp.pastureId = this.$store.state.user.pastureid
-      this.createTemp.pastureName = this.$store.state.user.pasturename
-      // this.createTemp.departmentName = this.$store.state.user.departmentname
-      // this.createTemp.departmentId = this.$store.state.user.departmentid
-      this.createTemp.warnName = ''
-      this.createTemp.specification = ''
-      this.createTemp.level = ''
-      this.createTemp.measureRange = ''
-      this.createTemp.factoryNumber = ''
-      this.createTemp.amount = ''
-      this.createTemp.unit = ''
-      this.createTemp.cycle = ''
-      this.createTemp.lastCheckDate = ''
-      this.createTemp.validityDate = ''
-      this.createTemp.warnUnit = ''
-      this.createTemp.purpose = ''
-      this.createTemp.location = ''
-    },
-    form_add() {
-      console.log('点击了新增')
-      this.resetCreateTemp()
-      this.dialogStatus = 'create'
-      this.dialogFormVisible = true
-    },
-    changePasture(item) {
-      this.createTemp.pastureName = this.findAllPasture.find(obj => obj.id === item).name
-    },
-    add_dialog_save() {
-      console.log('点击了保存')
-      this.isokDisable = true
-      setTimeout(() => {
-        this.isokDisable = false
-      }, 1000)
-      this.$refs['createTemp'].validate(valid => {
-        if (valid) {
-          this.postDataPramas.name = 'insertExaminewarning'
-          this.postDataPramas.parammaps = {}
-          this.postDataPramas.parammaps = this.createTemp
-          this.postDataPramas.parammaps.warningType = '压力表'
-          PostDataByName(this.postDataPramas).then(response => {
-            console.log('新增保存发送参数', this.postDataPramas)
-            if (response.msg !== 'fail') {
-              this.dialogFormVisible = false
-              this.get_table_data()
-              this.$notify({
-                title: '成功',
-                message: '新增成功',
-                type: 'success',
-                duration: 2000
-              })
-            } else {
-              failproccess(response, this.$notify)
-            }
-          })
-        }
-      })
-    },
-    form_edit(row) {
-      console.log('点击了编辑')
-      this.dialogStatus = 'update'
-      this.dialogFormVisible = true
-      this.createTemp = Object.assign({}, row)
-      this.createTemp.pastureId = parseFloat(row.pastureId)
-      this.createTemp.departmentId = parseFloat(row.departmentId)
-      this.createTemp.empId = parseFloat(row.empId)
-    },
-    edit_dialog_save() {
-      console.log('点击了编辑保存')
-      this.isokDisable = true
-      setTimeout(() => {
-        this.isokDisable = false
-      }, 1000)
-      this.$refs['createTemp'].validate(valid => {
-        if (valid) {
-          this.postDataPramas.name = 'updateExaminewarning'
-          this.postDataPramas.parammaps = {}
-          this.postDataPramas.parammaps = this.createTemp
-          this.postDataPramas.parammaps.id = this.createTemp.id
-          this.postDataPramas.parammaps.warningType = '压力表'
-          PostDataByName(this.postDataPramas).then(response => {
-            console.log('编辑保存发送参数', this.postDataPramas)
-            if (response.msg !== 'fail') {
-              this.dialogFormVisible = false
-              this.get_table_data()
-              this.$notify({
-                title: '成功',
-                message: '保存成功',
-                type: 'success',
-                duration: 2000
-              })
-            } else {
-              failproccess(response, this.$notify)
-            }
-          })
-        }
-      })
-    },
-    form_see(row) {
-      console.log('点击了查看', row)
-      this.dialogStatus = 'see'
-      this.dialogFormVisible = true
-      this.createTemp = Object.assign({}, row)
-      this.createTemp.pastureId = parseFloat(row.pastureId)
-      this.createTemp.departmentId = parseFloat(row.departmentId)
-      this.createTemp.empId = parseFloat(row.empId)
-    },
-    form_delete(row) {
-      MessageBox.confirm('确认删除此信息?', {
-        confirmButtonText: '确认',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        console.log('点击了删除', row)
-        this.postDataPramas.name = 'deleteExaminewarning'
-        this.postDataPramas.parammaps = {}
-        this.postDataPramas.parammaps.id = row.id
-        this.postDataPramas.parammaps.warningType = '压力表'
-        PostDataByName(this.postDataPramas).then(response => {
-          console.log('删除保存发送参数', this.postDataPramas)
-          if (response.msg !== 'fail') {
-            this.dialogFormVisible = false
-            this.get_table_data()
-            this.$notify({
-              title: '成功',
-              message: '删除成功',
-              type: 'success',
-              duration: 2000
-            })
-          } else {
-            failproccess(response, this.$notify)
-          }
-        })
-      })
-    },
-    handleDownloadTemp() {
-      console.log('点击了模板')
-      import('@/vendor/Export2Excel').then(excel => {
-        const list1 = []
-        const tHeader = [
-          '牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'
-        ]
-        const filterVal = [
-          '牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'
-        ]
-        const data1 = this.formatJson(filterVal, list1)
-        excel.export_json_to_excel({
-          header: tHeader,
-          data: data1,
-          filename: '压力表模板',
-          autoWidth: true,
-          bookType: 'xlsx'
-        })
-      })
-    },
-    beforeImportExcel(file) {
-      const isLt2M = file.size / 1024 / 1024 < 6
-      if (!isLt2M) {
-        this.$message.error('上传文件大小不能超过 6MB!')
-      }
-      return isLt2M
-    },
-    handleImportExcelSuccess(res, file) {
-      this.get_table_data()
-      if (res.msg === 'ok') {
-        this.$message({
-          title: '成功',
-          message: '导入成功:' + res.data.success + '条!',
-          type: 'success',
-          duration: 2000
-        })
-        if (res.data.err_count > 0) {
-          this.$notify({
-            title: '失败',
-            message: '导入失败:' + res.data.err_count + '条!',
-            type: 'danger',
-            duration: 2000
-          })
-           import('@/vendor/Export2Excel').then(excel => {
-             const list1 = res.data.result
-             const tHeader = [
-               '牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点', '报错信息'
-             ]
-             const filterVal = [
-               '牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点', 'error_msg'
-             ]
-             const data1 = this.formatJson(filterVal, list1)
-             excel.export_json_to_excel({
-               header: tHeader,
-               data: data1,
-               filename: '压力表报错信息',
-               autoWidth: true,
-               bookType: 'xlsx'
-             })
-           })
-        }
-      } else {
-        this.$notify({
-          title: '失败',
-          message: '上传失败',
-          type: 'danger',
-          duration: 2000
-        })
-      }
-    },
-    formatJson(filterVal, jsonData) {
-      return jsonData.map(v =>
-        filterVal.map(j => {
-          if (j === 'timestamp') {
-            return parseTime(v[j])
-          } else {
-            return v[j]
-          }
-        })
-      )
-    },
-    handleDownload() {
-      console.log('点击了导出')
-      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 = 'getExaminewarningList'
-      this.downLoadParm.parammaps = this.getdataListParm.parammaps
-      GetAccount(this.downLoadParm).then(response => {
-        if (response.data.list !== '') {
-          this.percentage = 99
-          setTimeout(() => {
-            this.isPercentage = false
-          }, 2000)
-        }
-        this.$nextTick(() => {
-          this.downLoadList = response.data.list
-          console.log('导出table数据', this.downLoadList)
-          const ExcelDatas = [
-            {
-              tHeader: ['牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'],
-              filterVal: ['pastureName', 'warnName', 'specification', 'level', 'measureRange', 'factoryNumber', 'amount', 'unit', 'cycle', 'lastCheckDate', 'validityDate', 'warnUnit', 'purpose', 'location'],
-              tableDatas: this.downLoadList,
-              sheetName: '压力表'
-            }
-          ]
-          json2excel(ExcelDatas, '压力表', true, 'xlsx')
-        })
-      })
-    }
-
-  }
-}
-</script>
-<style lang="scss" scoped>
-.app-btn {
-  margin-bottom: 10px;
-}
-</style>
-
+<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 v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 150px;">
+        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
+      </el-select>
+      <el-select v-model="getdataListParm.parammaps.status" placeholder="检验预警状态" class="filter-item" style="width: 150px;">
+        <el-option v-for="item in warningStatus" :key="item.id" :label="item.name" :value="item.name" />
+      </el-select>
+      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
+    </div>
+    <div class="app-btn">
+      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
+      <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
+      <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
+        <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
+      </el-upload>
+      <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
+    </div>
+    <el-table
+      :key="tableKey"
+      v-loading="listLoading"
+      element-loading-text="给我一点时间"
+      :data="list"
+      border
+      fit
+      highlight-current-row
+      style="width: 100%;"
+      :row-class-name="tableRowClassName"
+      :row-style="selectedHighlight"
+      :cell-style="cellStyle"
+      class="elTable table-fixed"
+      :max-height="myHeight"
+    >
+      <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="140px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.warnName }}</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="150px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.level }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="测量范围" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.measureRange }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="出厂编号" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.factoryNumber }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="数量" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.amount }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="制造单位" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.unit }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="检定周期" min-width="100px" align="center" sortable prop="cycle" />
+      <el-table-column label="检验日期" min-width="80px" align="center" sortable prop="lastCheckDate" />
+      <el-table-column label="有效日期" min-width="110px" align="center" sortable prop="validityDate" />
+      <el-table-column label="检定单位" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.warnUnit }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="计量器具用途" min-width="110px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.purpose }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="安装使用地点" min-width="110px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.location }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
+        <template slot-scope="{row}">
+          <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
+          <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
+          <el-button type="danger" size="mini" @click="form_delete(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" width="80%">
+      <div class="app-add">
+        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="145px" style="width: 90%;margin:0 auto 30px">
+          <el-row>
+            <el-col :span="8">
+              <el-form-item ref="pastureId" label="牧场:" prop="pastureId">
+                <el-select v-model="createTemp.pastureId " placeholder="请输入牧场" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changePasture">
+                  <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="warnName">
+                <el-input ref="warnName" v-model="createTemp.warnName" placeholder="请输入计量器具名称" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="规格型号:" prop="specification">
+                <el-input ref="specification" v-model="createTemp.specification" placeholder="请输入规格型号" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="准确度等级、不确定度或最大允许误差:" prop="level">
+                <el-input ref="level" v-model="createTemp.level" placeholder="请输入准确度等级、不确定度或最大允许误差" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="测量范围:" prop="measureRange">
+                <el-input ref="measureRange" v-model="createTemp.measureRange" placeholder="请输入测量范围" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="出厂编号:" prop="factoryNumber">
+                <el-input ref="factoryNumber" v-model="createTemp.factoryNumber" placeholder="请输入出厂编号" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="数量:" prop="amount">
+                <el-input ref="amount" v-model="createTemp.amount" placeholder="请输入数量" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="制造单位:" prop="unit">
+                <el-input ref="unit" v-model="createTemp.unit" placeholder="请输入制造单位" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="检定周期:" prop="cycle">
+                <el-input ref="cycle" v-model="createTemp.cycle" placeholder="请输入检定周期" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="检验日期:" prop="lastCheckDate">
+                <el-date-picker v-model="createTemp.lastCheckDate" :picker-options="pickerOptions1" type="date" placeholder="请输入检验日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="有效日期:" prop="validityDate">
+                <el-date-picker v-model="createTemp.validityDate" :picker-options="pickerOptions2" type="date" placeholder="请输入有效日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="检定单位:" prop="warnUnit">
+                <el-input ref="warnUnit" v-model="createTemp.warnUnit" placeholder="请输入检定单位" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="计量器具用途:" prop="purpose">
+                <el-input ref="purpose" v-model="createTemp.purpose" placeholder="请输入计量器具用途" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="安装使用地点:" prop="location">
+                <el-input ref="location" v-model="createTemp.location" placeholder="请输入安装使用地点" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
+          <el-button v-if="dialogStatus==='create' || dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
+          <el-button @click="dialogFormVisible = false; getdataListParm.parammaps.inputDatetime = ''">取消并关闭</el-button>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import waves from '@/directive/waves'
+import { GetDataByNames, GetDataByName, PostDataByName, failproccess, GetAccount } from '@/api/common'
+import Cookies from 'js-cookie'
+import { json2excel } from '@/utils/index.js'
+import { MessageBox } from 'element-ui'
+import { getToken } from '@/utils/auth'
+import { parseTime } from '@/utils/index.js'
+import Pagination from '@/components/Pagination'
+export default {
+  name: 'PressureGauge',
+  directives: { waves },
+  components: { Pagination },
+  data() {
+    return {
+      myHeight:document.documentElement.clientHeight - 85- 250,
+      warningStatus: [{ id: 0, name: '全部' }, { id: 1, name: '正常' }, { id: 2, name: '预警期' }],
+      findAllPasture: [],
+      findAllDepart: [],
+      findAllEmploye: [],
+      requestParams: [
+        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
+        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
+        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
+      ],
+      rules: {
+        pastureId: [{ required: true, message: '必填', trigger: 'blur' }],
+        warnName: [{ required: true, message: '必填', trigger: 'blur' }],
+        specification: [{ required: true, message: '必填', trigger: 'blur' }],
+        lastCheckDate: [{ required: true, message: '必填', trigger: 'blur' }],
+        validityDate: [{ required: true, message: '必填', trigger: 'blur' }]
+      },
+      getdataListParm: {
+        name: 'getExaminewarningList',
+        page: 1,
+        offset: 1,
+        pagecount: 10,
+        returntype: 'Map',
+        parammaps: {
+          pastureName: Cookies.get('pasturename'),
+          warningType: '压力表'
+        }
+      },
+      tableKey: 0,
+      listLoading: false,
+      total: 0,
+      list: [],
+      getIndexList: [],
+      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
+      cellStyle: { padding: 0 + 'px' },
+      pickerOptions1: {
+        disabledDate: (time) => {
+          if (this.createTemp.validityDate !== '') {
+            return parseTime(time.getTime(), '{y}-{m}-{d}') >= this.createTemp.validityDate
+          } else {
+            return ''
+          }
+        }
+      },
+      pickerOptions2: {
+        disabledDate: (time) => {
+          return parseTime(time.getTime(), '{y}-{m}-{d}') <= this.createTemp.lastCheckDate
+        }
+      },
+      createTemp: {
+        pastureId: this.$store.state.user.pastureid,
+        pastureName: this.$store.state.user.pasturename,
+        // departmentName: this.$store.state.user.departmentname,
+        // departmentId: this.$store.state.user.departmentid,
+        warnName: '',
+        specification: '',
+        level: '',
+        measureRange: '',
+        factoryNumber: '',
+        amount: '',
+        unit: '',
+        cycle: '',
+        lastCheckDate: '',
+        validityDate: '',
+        warnUnit: '',
+        purpose: '',
+        location: ''
+      },
+      dialogFormVisible: false,
+      dialogStatus: '',
+      textMap: {
+        create: '新增',
+        update: '编辑',
+        see: '查看'
+      },
+      isokDisable: false,
+      postDataPramas: {},
+      downLoadParm: {},
+      isPercentage: false,
+      percentage: 1
+    }
+  },
+  computed: {
+    headers() {
+      return {
+        token: getToken()
+      }
+    },
+    uploadData() {
+      return {
+        name: 'uploadExaminewarnYLB',
+        importParams: '牧场,计量器具名称,规格型号,准确度等级、不确定度或最大允许误差,测量范围,出厂编号,数量,制造单位,检定周期,上次检定日期,有效期至,检定单位,计量器具用途,安装使用地点',
+        sheetname: 'SheetJS'
+      }
+    },
+    // 设置上传地址
+    uploadExcelUrl() {
+      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
+    }
+  },
+  created() {
+    this.get_select_list()
+    this.get_table_data()
+  },
+
+  // 设置变量
+
+  methods: {
+    get_select_list() {
+      GetDataByNames(this.requestParams).then(response => {
+        this.findAllPasture = response.data.findAllPasture.list
+        this.findAllDepart = response.data.findAllDepart.list
+        this.findAllEmploye = response.data.findAllEmploye.list
+      })
+    },
+    getNextDate(date, day) {
+      var dd = new Date(date)
+      dd.setDate(dd.getDate() + day)
+      var y = dd.getFullYear()
+      var m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1
+      var d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
+      return y + '-' + m + '-' + d
+    },
+    tableRowClassName({ row, rowIndex }) {
+      // 把每一行的索引放进row
+      row.index = rowIndex
+    },
+    get_table_data() {
+      this.listLoading = true
+      GetDataByName(this.getdataListParm).then(response => {
+        if (response.data.list !== null || response.data !== null) {
+          console.log('table数据', response.data.list)
+          this.getIndexList = []
+          for (let i = 0; i < response.data.list.length; i++) {
+            response.data.list[i].index = i
+            if (this.getNextDate(response.data.list[i].validityDate, -30) <= parseTime(new Date(), '{y}-{m}-{d}')) {
+              this.getIndexList.push({ 'myindex': response.data.list[i].index })
+            }
+          }
+          this.list = response.data.list
+          this.pageNum = response.data.pageNum
+          this.pageSize = response.data.pageSize
+          this.total = response.data.total
+        } else {
+          this.list = []
+        }
+        setTimeout(() => {
+          this.listLoading = false
+        }, 100)
+      })
+    },
+    selectedHighlight({ row, rowIndex }) {
+      for (let i = 0; i < this.getIndexList.length; i++) {
+        if (this.getIndexList[i].myindex === rowIndex) {
+          return {
+            color: 'red'
+          }
+        }
+      }
+    },
+
+    form_search() {
+      console.log('点击了搜索')
+      this.getdataListParm.offset = 1
+      this.get_table_data()
+    },
+    resetCreateTemp() {
+      this.createTemp.pastureId = this.$store.state.user.pastureid
+      this.createTemp.pastureName = this.$store.state.user.pasturename
+      // this.createTemp.departmentName = this.$store.state.user.departmentname
+      // this.createTemp.departmentId = this.$store.state.user.departmentid
+      this.createTemp.warnName = ''
+      this.createTemp.specification = ''
+      this.createTemp.level = ''
+      this.createTemp.measureRange = ''
+      this.createTemp.factoryNumber = ''
+      this.createTemp.amount = ''
+      this.createTemp.unit = ''
+      this.createTemp.cycle = ''
+      this.createTemp.lastCheckDate = ''
+      this.createTemp.validityDate = ''
+      this.createTemp.warnUnit = ''
+      this.createTemp.purpose = ''
+      this.createTemp.location = ''
+    },
+    form_add() {
+      console.log('点击了新增')
+      this.resetCreateTemp()
+      this.dialogStatus = 'create'
+      this.dialogFormVisible = true
+    },
+    changePasture(item) {
+      this.createTemp.pastureName = this.findAllPasture.find(obj => obj.id === item).name
+    },
+    add_dialog_save() {
+      console.log('点击了保存')
+      this.isokDisable = true
+      setTimeout(() => {
+        this.isokDisable = false
+      }, 1000)
+      this.$refs['createTemp'].validate(valid => {
+        if (valid) {
+          this.postDataPramas.name = 'insertExaminewarning'
+          this.postDataPramas.parammaps = {}
+          this.postDataPramas.parammaps = this.createTemp
+          this.postDataPramas.parammaps.warningType = '压力表'
+          PostDataByName(this.postDataPramas).then(response => {
+            console.log('新增保存发送参数', this.postDataPramas)
+            if (response.msg !== 'fail') {
+              this.dialogFormVisible = false
+              this.get_table_data()
+              this.$notify({
+                title: '成功',
+                message: '新增成功',
+                type: 'success',
+                duration: 2000
+              })
+            } else {
+              failproccess(response, this.$notify)
+            }
+          })
+        }
+      })
+    },
+    form_edit(row) {
+      console.log('点击了编辑')
+      this.dialogStatus = 'update'
+      this.dialogFormVisible = true
+      this.createTemp = Object.assign({}, row)
+      this.createTemp.pastureId = parseFloat(row.pastureId)
+      this.createTemp.departmentId = parseFloat(row.departmentId)
+      this.createTemp.empId = parseFloat(row.empId)
+    },
+    edit_dialog_save() {
+      console.log('点击了编辑保存')
+      this.isokDisable = true
+      setTimeout(() => {
+        this.isokDisable = false
+      }, 1000)
+      this.$refs['createTemp'].validate(valid => {
+        if (valid) {
+          this.postDataPramas.name = 'updateExaminewarning'
+          this.postDataPramas.parammaps = {}
+          this.postDataPramas.parammaps = this.createTemp
+          this.postDataPramas.parammaps.id = this.createTemp.id
+          this.postDataPramas.parammaps.warningType = '压力表'
+          PostDataByName(this.postDataPramas).then(response => {
+            console.log('编辑保存发送参数', this.postDataPramas)
+            if (response.msg !== 'fail') {
+              this.dialogFormVisible = false
+              this.get_table_data()
+              this.$notify({
+                title: '成功',
+                message: '保存成功',
+                type: 'success',
+                duration: 2000
+              })
+            } else {
+              failproccess(response, this.$notify)
+            }
+          })
+        }
+      })
+    },
+    form_see(row) {
+      console.log('点击了查看', row)
+      this.dialogStatus = 'see'
+      this.dialogFormVisible = true
+      this.createTemp = Object.assign({}, row)
+      this.createTemp.pastureId = parseFloat(row.pastureId)
+      this.createTemp.departmentId = parseFloat(row.departmentId)
+      this.createTemp.empId = parseFloat(row.empId)
+    },
+    form_delete(row) {
+      MessageBox.confirm('确认删除此信息?', {
+        confirmButtonText: '确认',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        console.log('点击了删除', row)
+        this.postDataPramas.name = 'deleteExaminewarning'
+        this.postDataPramas.parammaps = {}
+        this.postDataPramas.parammaps.id = row.id
+        this.postDataPramas.parammaps.warningType = '压力表'
+        PostDataByName(this.postDataPramas).then(response => {
+          console.log('删除保存发送参数', this.postDataPramas)
+          if (response.msg !== 'fail') {
+            this.dialogFormVisible = false
+            this.get_table_data()
+            this.$notify({
+              title: '成功',
+              message: '删除成功',
+              type: 'success',
+              duration: 2000
+            })
+          } else {
+            failproccess(response, this.$notify)
+          }
+        })
+      })
+    },
+    handleDownloadTemp() {
+      console.log('点击了模板')
+      import('@/vendor/Export2Excel').then(excel => {
+        const list1 = []
+        const tHeader = [
+          '牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'
+        ]
+        const filterVal = [
+          '牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'
+        ]
+        const data1 = this.formatJson(filterVal, list1)
+        excel.export_json_to_excel({
+          header: tHeader,
+          data: data1,
+          filename: '压力表模板',
+          autoWidth: true,
+          bookType: 'xlsx'
+        })
+      })
+    },
+    beforeImportExcel(file) {
+      const isLt2M = file.size / 1024 / 1024 < 6
+      if (!isLt2M) {
+        this.$message.error('上传文件大小不能超过 6MB!')
+      }
+      return isLt2M
+    },
+    handleImportExcelSuccess(res, file) {
+      this.get_table_data()
+      if (res.msg === 'ok') {
+        this.$message({
+          title: '成功',
+          message: '导入成功:' + res.data.success + '条!',
+          type: 'success',
+          duration: 2000
+        })
+        if (res.data.err_count > 0) {
+          this.$notify({
+            title: '失败',
+            message: '导入失败:' + res.data.err_count + '条!',
+            type: 'danger',
+            duration: 2000
+          })
+           import('@/vendor/Export2Excel').then(excel => {
+             const list1 = res.data.result
+             const tHeader = [
+               '牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点', '报错信息'
+             ]
+             const filterVal = [
+               '牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点', 'error_msg'
+             ]
+             const data1 = this.formatJson(filterVal, list1)
+             excel.export_json_to_excel({
+               header: tHeader,
+               data: data1,
+               filename: '压力表报错信息',
+               autoWidth: true,
+               bookType: 'xlsx'
+             })
+           })
+        }
+      } else {
+        this.$notify({
+          title: '失败',
+          message: '上传失败',
+          type: 'danger',
+          duration: 2000
+        })
+      }
+    },
+    formatJson(filterVal, jsonData) {
+      return jsonData.map(v =>
+        filterVal.map(j => {
+          if (j === 'timestamp') {
+            return parseTime(v[j])
+          } else {
+            return v[j]
+          }
+        })
+      )
+    },
+    handleDownload() {
+      console.log('点击了导出')
+      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 = 'getExaminewarningList'
+      this.downLoadParm.parammaps = this.getdataListParm.parammaps
+      GetAccount(this.downLoadParm).then(response => {
+        if (response.data.list !== '') {
+          this.percentage = 99
+          setTimeout(() => {
+            this.isPercentage = false
+          }, 2000)
+        }
+        this.$nextTick(() => {
+          this.downLoadList = response.data.list
+          console.log('导出table数据', this.downLoadList)
+          const ExcelDatas = [
+            {
+              tHeader: ['牧场', '计量器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'],
+              filterVal: ['pastureName', 'warnName', 'specification', 'level', 'measureRange', 'factoryNumber', 'amount', 'unit', 'cycle', 'lastCheckDate', 'validityDate', 'warnUnit', 'purpose', 'location'],
+              tableDatas: this.downLoadList,
+              sheetName: '压力表'
+            }
+          ]
+          json2excel(ExcelDatas, '压力表', true, 'xlsx')
+        })
+      })
+    }
+
+  }
+}
+</script>
+<style lang="scss" scoped>
+.app-btn {
+  margin-bottom: 10px;
+}
+</style>
+

+ 654 - 654
src/views/special/earlyWarning/components/safetyValve.vue

@@ -1,366 +1,364 @@
-<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 v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 150px;">
-        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
-      </el-select>
-      <el-select v-model="getdataListParm.parammaps.status" placeholder="检验预警状态" class="filter-item" style="width: 150px;">
-        <el-option v-for="item in warningStatus" :key="item.id" :label="item.name" :value="item.name" />
-      </el-select>
-      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
-    </div>
-    <div class="app-btn">
-      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
-      <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
-      <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
-        <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
-      </el-upload>
-      <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
-    </div>
-
-    <el-table
-      :key="tableKey"
-      v-loading="listLoading"
-      element-loading-text="给我一点时间"
-      :data="list"
-      border
-      fit
-      highlight-current-row
-      style="width: 100%;"
-      :row-class-name="tableRowClassName"
-      :row-style="selectedHighlight"
-      :cell-style="cellStyle"
-      class="elTable table-fixed"
-      :max-height="myHeight"
-    >
-      <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="140px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.warnName }}</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="100px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.level }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="公称压力MPa" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.measureRange }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="工作压力MPa" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.factoryNumber }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="整定压力MPa" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.amount }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="起跳压力MPa" min-width="100px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.unit }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="回座压力MPa" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.cycle }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="使用位置" min-width="110px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.warnUnit }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="使用部门" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.departmentName }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="检验日期" min-width="110px" align="center" sortable prop="lastCheckDate" />
-      <el-table-column label="有效日期" min-width="110px" align="center" sortable prop="validityDate" />
-      <el-table-column label="管理责任人" min-width="110px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.empName }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
-        <template slot-scope="{row}">
-          <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
-          <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
-          <el-button type="danger" size="mini" @click="form_delete(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" width="80%">
-      <div class="app-add">
-        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="115px" style="width: 90%;margin:0 auto 30px">
-          <el-row>
-            <el-col :span="8">
-              <el-form-item ref="pastureId" label="牧场:" prop="pastureId">
-                <el-select v-model="createTemp.pastureId " placeholder="请输入牧场" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changePasture">
-                  <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="warnName">
-                <el-input ref="warnName" v-model="createTemp.warnName" placeholder="请输入安全阀类型" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="安全阀型号:" prop="specification">
-                <el-input ref="specification" v-model="createTemp.specification" placeholder="请输入安全阀型号" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="公称通径:" prop="level">
-                <el-input ref="level" v-model="createTemp.level" placeholder="请输入公称通径" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="公称压力MPa:" prop="measureRange">
-                <el-input ref="measureRange" v-model="createTemp.measureRange" placeholder="请输入公称压力MPa" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="工作压力MPa:" prop="factoryNumber">
-                <el-input ref="factoryNumber" v-model="createTemp.factoryNumber" placeholder="请输入工作压力MPa" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="整定压力MPa:" prop="amount">
-                <el-input ref="amount" v-model="createTemp.amount" placeholder="请输入整定压力MPa" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="起跳压力MPa:" prop="unit">
-                <el-input ref="unit" v-model="createTemp.unit" placeholder="请输入起跳压力MPa" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="回座压力MPa:" prop="cycle">
-                <el-input ref="cycle" v-model="createTemp.cycle" placeholder="请输入回座压力MPa" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="使用位置:" prop="warnUnit">
-                <el-input ref="warnUnit" v-model="createTemp.warnUnit" placeholder="请输入使用位置" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="使用部门:" prop="departmentName">
-                <el-select v-model="createTemp.departmentName" placeholder="请输入使用部门" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changeDepartment">
-                  <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.name" />
-                </el-select>
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="检验日期:" prop="lastCheckDate">
-                <el-date-picker v-model="createTemp.lastCheckDate" type="date" :picker-options="pickerOptions1" placeholder="请输入检验日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="有效日期:" prop="validityDate">
-                <el-date-picker v-model="createTemp.validityDate" type="date" :picker-options="pickerOptions2" placeholder="请输入有效日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="管理责任人:" prop="empName">
-                <el-select ref="empName" v-model="createTemp.empName" filterable placeholder="请输入管理责任人" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changeEmp">
-                  <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.name" />
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
-        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
-          <el-button v-if="dialogStatus==='create' || dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
-          <el-button @click="dialogFormVisible = false; getdataListParm.parammaps.inputDatetime = ''">取消并关闭</el-button>
-        </div>
-      </div>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-import waves from '@/directive/waves'
-import { GetDataByNames, GetDataByName, PostDataByName, failproccess, GetAccount } from '@/api/common'
-import Cookies from 'js-cookie'
-import { json2excel } from '@/utils/index.js'
-import { MessageBox } from 'element-ui'
-import { getToken } from '@/utils/auth'
-import { parseTime } from '@/utils/index.js'
-import Pagination from '@/components/Pagination'
-export default {
-  name: 'SafetyValve',
-  directives: { waves },
-  components: { Pagination },
-  data() {
-    return {
-      myHeight:document.documentElement.clientHeight - 85- 250,
-      warningStatus: [{ id: 0, name: '全部' }, { id: 1, name: '正常' }, { id: 2, name: '预警期' }],
-      findAllPasture: [],
-      findAllDepart: [],
-      findAllEmploye: [],
-      requestParams: [
-        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
-        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
-        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
-      ],
-      rules: {
-        pastureId: [{ required: true, message: '必填', trigger: 'blur' }],
-        warnName: [{ required: true, message: '必填', trigger: 'blur' }],
-        specification: [{ required: true, message: '必填', trigger: 'blur' }],
-        lastCheckDate: [{ required: true, message: '必填', trigger: 'blur' }],
-        validityDate: [{ required: true, message: '必填', trigger: 'blur' }]
-      },
-      getdataListParm: {
-        name: 'getExaminewarningList',
-        page: 1,
-        offset: 1,
-        pagecount: 10,
-        returntype: 'Map',
-        parammaps: {
-          pastureName: Cookies.get('pasturename'),
-          warningType: '安全阀'
-        }
-      },
-      tableKey: 0,
-      listLoading: false,
-      total: 0,
-      list: [],
-      getIndexList: [],
-      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
-      cellStyle: { padding: 0 + 'px' },
-      pickerOptions1: {
-        disabledDate: (time) => {
-          if (this.createTemp.validityDate !== '') {
-            return parseTime(time.getTime(), '{y}-{m}-{d}') >= this.createTemp.validityDate
-          } else {
-            return ''
-          }
-        }
-      },
-      pickerOptions2: {
-        disabledDate: (time) => {
-          return parseTime(time.getTime(), '{y}-{m}-{d}') <= this.createTemp.lastCheckDate
-        }
-      },
-      createTemp: {
-        pastureId: this.$store.state.user.pastureid,
-        pastureName: this.$store.state.user.pasturename,
-        departmentName: this.$store.state.user.departmentname,
-        departmentId: this.$store.state.user.departmentid,
-        warnName: '',
-        specification: '',
-        level: '',
-        measureRange: '',
-        factoryNumber: '',
-        amount: '',
-        unit: '',
-        cycle: '',
-        warnUnit: '',
-        lastCheckDate: '',
-        validityDate: '',
-        empName: '',
-        empId: ''
-      },
-      dialogFormVisible: false,
-      dialogStatus: '',
-      textMap: {
-        create: '新增',
-        update: '编辑',
-        see: '查看'
-      },
-      isokDisable: false,
-      postDataPramas: {},
-      downLoadParm: {},
-      isPercentage: false,
-      percentage: 1
-    }
-  },
-  computed: {
-    headers() {
-      return {
-        token: getToken()
-      }
-    },
-    uploadData() {
-      return {
-        name: 'uploadExaminewarnAQF',
-        importParams: '牧场,安全阀类型,安全阀型号,公称通径,公称压力MPa,工作压力MPa,整定压力MPa,起跳压力MPa,回座压力MPa,使用位置,使用部门,本次检验日期,下次检验日期,管理责任人',
-        sheetname: 'SheetJS'
-      }
-    },
-    // 设置上传地址
-    uploadExcelUrl() {
-      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
-    }
-  },
-  created() {
-    this.get_select_list()
-    this.get_table_data()
-  },
-
-  // 设置变量
-
-  methods: {
-    get_select_list() {
-      GetDataByNames(this.requestParams).then(response => {
-        this.findAllPasture = response.data.findAllPasture.list
-        this.findAllDepart = response.data.findAllDepart.list
-        this.findAllEmploye = response.data.findAllEmploye.list
-      })
-    },
-    getNextDate(date, day) {
-      var dd = new Date(date)
-      dd.setDate(dd.getDate() + day)
-      var y = dd.getFullYear()
-      var m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1
-      var d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
-      return y + '-' + m + '-' + d
-    },
-    tableRowClassName({ row, rowIndex }) {
-      // 把每一行的索引放进row
-      row.index = rowIndex
-    },
-    get_table_data() {
-      this.listLoading = true
-      GetDataByName(this.getdataListParm).then(response => {
-        if (response.data.list !== null || response.data !== null) {
-          this.list = []
-        } else {
+<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 v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 150px;">
+        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
+      </el-select>
+      <el-select v-model="getdataListParm.parammaps.status" placeholder="检验预警状态" class="filter-item" style="width: 150px;">
+        <el-option v-for="item in warningStatus" :key="item.id" :label="item.name" :value="item.name" />
+      </el-select>
+      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
+    </div>
+    <div class="app-btn">
+      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
+      <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
+      <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
+        <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
+      </el-upload>
+      <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
+    </div>
+
+    <el-table
+      :key="tableKey"
+      v-loading="listLoading"
+      element-loading-text="给我一点时间"
+      :data="list"
+      border
+      fit
+      highlight-current-row
+      style="width: 100%;"
+      :row-class-name="tableRowClassName"
+      :row-style="selectedHighlight"
+      :cell-style="cellStyle"
+      class="elTable table-fixed"
+      :max-height="myHeight"
+    >
+      <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="140px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.warnName }}</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="100px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.level }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="公称压力MPa" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.measureRange }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="工作压力MPa" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.factoryNumber }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="整定压力MPa" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.amount }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="起跳压力MPa" min-width="100px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.unit }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="回座压力MPa" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.cycle }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="使用位置" min-width="110px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.warnUnit }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="使用部门" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.departmentName }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="检验日期" min-width="110px" align="center" sortable prop="lastCheckDate" />
+      <el-table-column label="有效日期" min-width="110px" align="center" sortable prop="validityDate" />
+      <el-table-column label="管理责任人" min-width="110px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.empName }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
+        <template slot-scope="{row}">
+          <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
+          <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
+          <el-button type="danger" size="mini" @click="form_delete(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" width="80%">
+      <div class="app-add">
+        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="115px" style="width: 90%;margin:0 auto 30px">
+          <el-row>
+            <el-col :span="8">
+              <el-form-item ref="pastureId" label="牧场:" prop="pastureId">
+                <el-select v-model="createTemp.pastureId " placeholder="请输入牧场" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changePasture">
+                  <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="warnName">
+                <el-input ref="warnName" v-model="createTemp.warnName" placeholder="请输入安全阀类型" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="安全阀型号:" prop="specification">
+                <el-input ref="specification" v-model="createTemp.specification" placeholder="请输入安全阀型号" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="公称通径:" prop="level">
+                <el-input ref="level" v-model="createTemp.level" placeholder="请输入公称通径" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="公称压力MPa:" prop="measureRange">
+                <el-input ref="measureRange" v-model="createTemp.measureRange" placeholder="请输入公称压力MPa" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="工作压力MPa:" prop="factoryNumber">
+                <el-input ref="factoryNumber" v-model="createTemp.factoryNumber" placeholder="请输入工作压力MPa" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="整定压力MPa:" prop="amount">
+                <el-input ref="amount" v-model="createTemp.amount" placeholder="请输入整定压力MPa" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="起跳压力MPa:" prop="unit">
+                <el-input ref="unit" v-model="createTemp.unit" placeholder="请输入起跳压力MPa" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="回座压力MPa:" prop="cycle">
+                <el-input ref="cycle" v-model="createTemp.cycle" placeholder="请输入回座压力MPa" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="使用位置:" prop="warnUnit">
+                <el-input ref="warnUnit" v-model="createTemp.warnUnit" placeholder="请输入使用位置" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="使用部门:" prop="departmentName">
+                <el-select v-model="createTemp.departmentName" placeholder="请输入使用部门" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changeDepartment">
+                  <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.name" />
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="检验日期:" prop="lastCheckDate">
+                <el-date-picker v-model="createTemp.lastCheckDate" type="date" :picker-options="pickerOptions1" placeholder="请输入检验日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="有效日期:" prop="validityDate">
+                <el-date-picker v-model="createTemp.validityDate" type="date" :picker-options="pickerOptions2" placeholder="请输入有效日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="管理责任人:" prop="empName">
+                <el-select ref="empName" v-model="createTemp.empName" filterable placeholder="请输入管理责任人" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changeEmp">
+                  <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.name" />
+                </el-select>
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
+          <el-button v-if="dialogStatus==='create' || dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
+          <el-button @click="dialogFormVisible = false; getdataListParm.parammaps.inputDatetime = ''">取消并关闭</el-button>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import waves from '@/directive/waves'
+import { GetDataByNames, GetDataByName, PostDataByName, failproccess, GetAccount } from '@/api/common'
+import Cookies from 'js-cookie'
+import { json2excel } from '@/utils/index.js'
+import { MessageBox } from 'element-ui'
+import { getToken } from '@/utils/auth'
+import { parseTime } from '@/utils/index.js'
+import Pagination from '@/components/Pagination'
+export default {
+  name: 'SafetyValve',
+  directives: { waves },
+  components: { Pagination },
+  data() {
+    return {
+      myHeight:document.documentElement.clientHeight - 85- 250,
+      warningStatus: [{ id: 0, name: '全部' }, { id: 1, name: '正常' }, { id: 2, name: '预警期' }],
+      findAllPasture: [],
+      findAllDepart: [],
+      findAllEmploye: [],
+      requestParams: [
+        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
+        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
+        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
+      ],
+      rules: {
+        pastureId: [{ required: true, message: '必填', trigger: 'blur' }],
+        warnName: [{ required: true, message: '必填', trigger: 'blur' }],
+        specification: [{ required: true, message: '必填', trigger: 'blur' }],
+        lastCheckDate: [{ required: true, message: '必填', trigger: 'blur' }],
+        validityDate: [{ required: true, message: '必填', trigger: 'blur' }]
+      },
+      getdataListParm: {
+        name: 'getExaminewarningList',
+        page: 1,
+        offset: 1,
+        pagecount: 10,
+        returntype: 'Map',
+        parammaps: {
+          pastureName: Cookies.get('pasturename'),
+          warningType: '安全阀'
+        }
+      },
+      tableKey: 0,
+      listLoading: false,
+      total: 0,
+      list: [],
+      getIndexList: [],
+      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
+      cellStyle: { padding: 0 + 'px' },
+      pickerOptions1: {
+        disabledDate: (time) => {
+          if (this.createTemp.validityDate !== '') {
+            return parseTime(time.getTime(), '{y}-{m}-{d}') >= this.createTemp.validityDate
+          } else {
+            return ''
+          }
+        }
+      },
+      pickerOptions2: {
+        disabledDate: (time) => {
+          return parseTime(time.getTime(), '{y}-{m}-{d}') <= this.createTemp.lastCheckDate
+        }
+      },
+      createTemp: {
+        pastureId: this.$store.state.user.pastureid,
+        pastureName: this.$store.state.user.pasturename,
+        departmentName: this.$store.state.user.departmentname,
+        departmentId: this.$store.state.user.departmentid,
+        warnName: '',
+        specification: '',
+        level: '',
+        measureRange: '',
+        factoryNumber: '',
+        amount: '',
+        unit: '',
+        cycle: '',
+        warnUnit: '',
+        lastCheckDate: '',
+        validityDate: '',
+        empName: '',
+        empId: ''
+      },
+      dialogFormVisible: false,
+      dialogStatus: '',
+      textMap: {
+        create: '新增',
+        update: '编辑',
+        see: '查看'
+      },
+      isokDisable: false,
+      postDataPramas: {},
+      downLoadParm: {},
+      isPercentage: false,
+      percentage: 1
+    }
+  },
+  computed: {
+    headers() {
+      return {
+        token: getToken()
+      }
+    },
+    uploadData() {
+      return {
+        name: 'uploadExaminewarnAQF',
+        importParams: '牧场,安全阀类型,安全阀型号,公称通径,公称压力MPa,工作压力MPa,整定压力MPa,起跳压力MPa,回座压力MPa,使用位置,使用部门,本次检验日期,下次检验日期,管理责任人',
+        sheetname: 'SheetJS'
+      }
+    },
+    // 设置上传地址
+    uploadExcelUrl() {
+      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
+    }
+  },
+  created() {
+    this.get_select_list()
+    this.get_table_data()
+  },
+
+  // 设置变量
+
+  methods: {
+    get_select_list() {
+      GetDataByNames(this.requestParams).then(response => {
+        this.findAllPasture = response.data.findAllPasture.list
+        this.findAllDepart = response.data.findAllDepart.list
+        this.findAllEmploye = response.data.findAllEmploye.list
+      })
+    },
+    getNextDate(date, day) {
+      var dd = new Date(date)
+      dd.setDate(dd.getDate() + day)
+      var y = dd.getFullYear()
+      var m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1
+      var d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
+      return y + '-' + m + '-' + d
+    },
+    tableRowClassName({ row, rowIndex }) {
+      // 把每一行的索引放进row
+      row.index = rowIndex
+    },
+    get_table_data() {
+      this.listLoading = true
+      GetDataByName(this.getdataListParm).then(response => {
+        if (response.data.list !== null || response.data !== null) {
           console.log('table数据', response.data.list)
           this.getIndexList = []
           for (let i = 0; i < response.data.list.length; i++) {
@@ -372,294 +370,296 @@ export default {
           this.list = response.data.list
           this.pageNum = response.data.pageNum
           this.pageSize = response.data.pageSize
-          this.total = response.data.total
-        }
-        setTimeout(() => {
-          this.listLoading = false
-        }, 100)
-      })
-    },
-    selectedHighlight({ row, rowIndex }) {
-      for (let i = 0; i < this.getIndexList.length; i++) {
-        if (this.getIndexList[i].myindex === rowIndex) {
-          return {
-            color: 'red'
-          }
-        }
-      }
-    },
-
-    form_search() {
-      console.log('点击了搜索')
-      this.getdataListParm.offset = 1
-      this.get_table_data()
-    },
-    resetCreateTemp() {
-      this.createTemp.pastureId = this.$store.state.user.pastureid
-      this.createTemp.pastureName = this.$store.state.user.pasturename
-      this.createTemp.departmentName = this.$store.state.user.departmentname
-      this.createTemp.departmentId = this.$store.state.user.departmentid
-      this.createTemp.warnName = ''
-      this.createTemp.specification = ''
-      this.createTemp.level = ''
-      this.createTemp.measureRange = ''
-      this.createTemp.factoryNumber = ''
-      this.createTemp.amount = ''
-      this.createTemp.unit = ''
-      this.createTemp.cycle = ''
-      this.createTemp.warnUnit = ''
-      this.createTemp.lastCheckDate = ''
-      this.createTemp.validityDate = ''
-      this.createTemp.empName = ''
-      this.createTemp.empId = ''
-    },
-    form_add() {
-      console.log('点击了新增')
-      this.resetCreateTemp()
-      this.dialogStatus = 'create'
-      this.dialogFormVisible = true
-    },
-    changePasture(item) {
-      this.createTemp.pastureName = this.findAllPasture.find(obj => obj.id === item).name
-    },
-    changeDepartment(item) {
-      this.createTemp.departmentId = this.findAllDepart.find(obj => obj.name === item).id
-    },
-    changeEmp(item) {
-      this.createTemp.empId = this.findAllEmploye.find(obj => obj.name === item).id
-    },
-    add_dialog_save() {
-      console.log('点击了保存')
-      this.isokDisable = true
-      setTimeout(() => {
-        this.isokDisable = false
-      }, 1000)
-      this.$refs['createTemp'].validate(valid => {
-        if (valid) {
-          this.postDataPramas.name = 'insertExaminewarning'
-          this.postDataPramas.parammaps = {}
-          this.postDataPramas.parammaps = this.createTemp
-          this.postDataPramas.parammaps.warningType = '安全阀'
-          PostDataByName(this.postDataPramas).then(response => {
-            console.log('新增保存发送参数', this.postDataPramas)
-            if (response.msg !== 'fail') {
-              this.dialogFormVisible = false
-              this.get_table_data()
-              this.$notify({
-                title: '成功',
-                message: '新增成功',
-                type: 'success',
-                duration: 2000
-              })
-            } else {
-              failproccess(response, this.$notify)
-            }
-          })
-        }
-      })
-    },
-    form_edit(row) {
-      console.log('点击了编辑')
-      this.dialogStatus = 'update'
-      this.dialogFormVisible = true
-      this.createTemp = Object.assign({}, row)
-      this.createTemp.pastureId = parseFloat(row.pastureId)
-      this.createTemp.departmentId = parseFloat(row.departmentId)
-      this.createTemp.empId = parseFloat(row.empId)
-    },
-    edit_dialog_save() {
-      console.log('点击了编辑保存')
-      this.isokDisable = true
-      setTimeout(() => {
-        this.isokDisable = false
-      }, 1000)
-      this.$refs['createTemp'].validate(valid => {
-        if (valid) {
-          this.postDataPramas.name = 'updateExaminewarning'
-          this.postDataPramas.parammaps = {}
-          this.postDataPramas.parammaps = this.createTemp
-          this.postDataPramas.parammaps.id = this.createTemp.id
-          this.postDataPramas.parammaps.warningType = '安全阀'
-          PostDataByName(this.postDataPramas).then(response => {
-            console.log('编辑保存发送参数', this.postDataPramas)
-            if (response.msg !== 'fail') {
-              this.dialogFormVisible = false
-              this.get_table_data()
-              this.$notify({
-                title: '成功',
-                message: '保存成功',
-                type: 'success',
-                duration: 2000
-              })
-            } else {
-              failproccess(response, this.$notify)
-            }
-          })
-        }
-      })
-    },
-    form_see(row) {
-      console.log('点击了查看', row)
-      this.dialogStatus = 'see'
-      this.dialogFormVisible = true
-      this.createTemp = Object.assign({}, row)
-      this.createTemp.pastureId = parseFloat(row.pastureId)
-      this.createTemp.departmentId = parseFloat(row.departmentId)
-      this.createTemp.empId = parseFloat(row.empId)
-    },
-    form_delete(row) {
-      MessageBox.confirm('确认删除此信息?', {
-        confirmButtonText: '确认',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        console.log('点击了删除', row)
-        this.postDataPramas.name = 'deleteExaminewarning'
-        this.postDataPramas.parammaps = {}
-        this.postDataPramas.parammaps.id = row.id
-        this.postDataPramas.parammaps.warningType = '安全阀'
-        PostDataByName(this.postDataPramas).then(response => {
-          console.log('删除保存发送参数', this.postDataPramas)
-          if (response.msg !== 'fail') {
-            this.dialogFormVisible = false
-            this.get_table_data()
-            this.$notify({
-              title: '成功',
-              message: '删除成功',
-              type: 'success',
-              duration: 2000
-            })
-          } else {
-            failproccess(response, this.$notify)
-          }
-        })
-      })
-    },
-    handleDownloadTemp() {
-      console.log('点击了模板')
-      import('@/vendor/Export2Excel').then(excel => {
-        const list1 = []
-        const tHeader = [
-          '牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人'
-        ]
-        const filterVal = [
-          '牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人'
-        ]
-        const data1 = this.formatJson(filterVal, list1)
-        excel.export_json_to_excel({
-          header: tHeader,
-          data: data1,
-          filename: '安全阀模板',
-          autoWidth: true,
-          bookType: 'xlsx'
-        })
-      })
-    },
-    beforeImportExcel(file) {
-      const isLt2M = file.size / 1024 / 1024 < 6
-      if (!isLt2M) {
-        this.$message.error('上传文件大小不能超过 6MB!')
-      }
-      return isLt2M
-    },
-    handleImportExcelSuccess(res, file) {
-      this.get_table_data()
-      if (res.msg === 'ok') {
-        this.$message({
-          title: '成功',
-          message: '导入成功:' + res.data.success + '条!',
-          type: 'success',
-          duration: 2000
-        })
-        if (res.data.err_count > 0) {
-          this.$notify({
-            title: '失败',
-            message: '导入失败:' + res.data.err_count + '条!',
-            type: 'danger',
-            duration: 2000
-          })
-           import('@/vendor/Export2Excel').then(excel => {
-             const list1 = res.data.result
-             const tHeader = [
-               '牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人', '报错信息'
-             ]
-             const filterVal = [
-               '牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人', 'error_msg'
-             ]
-             const data1 = this.formatJson(filterVal, list1)
-             excel.export_json_to_excel({
-               header: tHeader,
-               data: data1,
-               filename: '安全阀报错信息',
-               autoWidth: true,
-               bookType: 'xlsx'
-             })
-           })
-        }
-      } else {
-        this.$notify({
-          title: '失败',
-          message: '上传失败',
-          type: 'danger',
-          duration: 2000
-        })
-      }
-    },
-    formatJson(filterVal, jsonData) {
-      return jsonData.map(v =>
-        filterVal.map(j => {
-          if (j === 'timestamp') {
-            return parseTime(v[j])
-          } else {
-            return v[j]
-          }
-        })
-      )
-    },
-    handleDownload() {
-      console.log('点击了导出')
-      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 = 'getExaminewarningList'
-      this.downLoadParm.parammaps = this.getdataListParm.parammaps
-      GetAccount(this.downLoadParm).then(response => {
-        if (response.data.list !== '') {
-          this.percentage = 99
-          setTimeout(() => {
-            this.isPercentage = false
-          }, 2000)
-        }
-        this.$nextTick(() => {
-          this.downLoadList = response.data.list
-          console.log('导出table数据', this.downLoadList)
-          const ExcelDatas = [
-            {
-              tHeader: ['牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人'],
-              filterVal: ['pastureName', 'warnName', 'specification', 'level', 'measureRange', 'factoryNumber', 'amount', 'unit', 'cycle', 'warnUnit', 'departmentName', 'lastCheckDate', 'validityDate', 'empName'],
-              tableDatas: this.downLoadList,
-              sheetName: '安全阀'
-            }
-          ]
-          json2excel(ExcelDatas, '安全阀', true, 'xlsx')
-        })
-      })
-    }
-
-  }
-}
-</script>
-<style lang="scss" scoped>
-.app-btn {
-  margin-bottom: 10px;
-}
-</style>
-
+          this.total = response.data.total
+        } else {
+          this.list = []
+        }
+        setTimeout(() => {
+          this.listLoading = false
+        }, 100)
+      })
+    },
+    selectedHighlight({ row, rowIndex }) {
+      for (let i = 0; i < this.getIndexList.length; i++) {
+        if (this.getIndexList[i].myindex === rowIndex) {
+          return {
+            color: 'red'
+          }
+        }
+      }
+    },
+
+    form_search() {
+      console.log('点击了搜索')
+      this.getdataListParm.offset = 1
+      this.get_table_data()
+    },
+    resetCreateTemp() {
+      this.createTemp.pastureId = this.$store.state.user.pastureid
+      this.createTemp.pastureName = this.$store.state.user.pasturename
+      this.createTemp.departmentName = this.$store.state.user.departmentname
+      this.createTemp.departmentId = this.$store.state.user.departmentid
+      this.createTemp.warnName = ''
+      this.createTemp.specification = ''
+      this.createTemp.level = ''
+      this.createTemp.measureRange = ''
+      this.createTemp.factoryNumber = ''
+      this.createTemp.amount = ''
+      this.createTemp.unit = ''
+      this.createTemp.cycle = ''
+      this.createTemp.warnUnit = ''
+      this.createTemp.lastCheckDate = ''
+      this.createTemp.validityDate = ''
+      this.createTemp.empName = ''
+      this.createTemp.empId = ''
+    },
+    form_add() {
+      console.log('点击了新增')
+      this.resetCreateTemp()
+      this.dialogStatus = 'create'
+      this.dialogFormVisible = true
+    },
+    changePasture(item) {
+      this.createTemp.pastureName = this.findAllPasture.find(obj => obj.id === item).name
+    },
+    changeDepartment(item) {
+      this.createTemp.departmentId = this.findAllDepart.find(obj => obj.name === item).id
+    },
+    changeEmp(item) {
+      this.createTemp.empId = this.findAllEmploye.find(obj => obj.name === item).id
+    },
+    add_dialog_save() {
+      console.log('点击了保存')
+      this.isokDisable = true
+      setTimeout(() => {
+        this.isokDisable = false
+      }, 1000)
+      this.$refs['createTemp'].validate(valid => {
+        if (valid) {
+          this.postDataPramas.name = 'insertExaminewarning'
+          this.postDataPramas.parammaps = {}
+          this.postDataPramas.parammaps = this.createTemp
+          this.postDataPramas.parammaps.warningType = '安全阀'
+          PostDataByName(this.postDataPramas).then(response => {
+            console.log('新增保存发送参数', this.postDataPramas)
+            if (response.msg !== 'fail') {
+              this.dialogFormVisible = false
+              this.get_table_data()
+              this.$notify({
+                title: '成功',
+                message: '新增成功',
+                type: 'success',
+                duration: 2000
+              })
+            } else {
+              failproccess(response, this.$notify)
+            }
+          })
+        }
+      })
+    },
+    form_edit(row) {
+      console.log('点击了编辑')
+      this.dialogStatus = 'update'
+      this.dialogFormVisible = true
+      this.createTemp = Object.assign({}, row)
+      this.createTemp.pastureId = parseFloat(row.pastureId)
+      this.createTemp.departmentId = parseFloat(row.departmentId)
+      this.createTemp.empId = parseFloat(row.empId)
+    },
+    edit_dialog_save() {
+      console.log('点击了编辑保存')
+      this.isokDisable = true
+      setTimeout(() => {
+        this.isokDisable = false
+      }, 1000)
+      this.$refs['createTemp'].validate(valid => {
+        if (valid) {
+          this.postDataPramas.name = 'updateExaminewarning'
+          this.postDataPramas.parammaps = {}
+          this.postDataPramas.parammaps = this.createTemp
+          this.postDataPramas.parammaps.id = this.createTemp.id
+          this.postDataPramas.parammaps.warningType = '安全阀'
+          PostDataByName(this.postDataPramas).then(response => {
+            console.log('编辑保存发送参数', this.postDataPramas)
+            if (response.msg !== 'fail') {
+              this.dialogFormVisible = false
+              this.get_table_data()
+              this.$notify({
+                title: '成功',
+                message: '保存成功',
+                type: 'success',
+                duration: 2000
+              })
+            } else {
+              failproccess(response, this.$notify)
+            }
+          })
+        }
+      })
+    },
+    form_see(row) {
+      console.log('点击了查看', row)
+      this.dialogStatus = 'see'
+      this.dialogFormVisible = true
+      this.createTemp = Object.assign({}, row)
+      this.createTemp.pastureId = parseFloat(row.pastureId)
+      this.createTemp.departmentId = parseFloat(row.departmentId)
+      this.createTemp.empId = parseFloat(row.empId)
+    },
+    form_delete(row) {
+      MessageBox.confirm('确认删除此信息?', {
+        confirmButtonText: '确认',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        console.log('点击了删除', row)
+        this.postDataPramas.name = 'deleteExaminewarning'
+        this.postDataPramas.parammaps = {}
+        this.postDataPramas.parammaps.id = row.id
+        this.postDataPramas.parammaps.warningType = '安全阀'
+        PostDataByName(this.postDataPramas).then(response => {
+          console.log('删除保存发送参数', this.postDataPramas)
+          if (response.msg !== 'fail') {
+            this.dialogFormVisible = false
+            this.get_table_data()
+            this.$notify({
+              title: '成功',
+              message: '删除成功',
+              type: 'success',
+              duration: 2000
+            })
+          } else {
+            failproccess(response, this.$notify)
+          }
+        })
+      })
+    },
+    handleDownloadTemp() {
+      console.log('点击了模板')
+      import('@/vendor/Export2Excel').then(excel => {
+        const list1 = []
+        const tHeader = [
+          '牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人'
+        ]
+        const filterVal = [
+          '牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人'
+        ]
+        const data1 = this.formatJson(filterVal, list1)
+        excel.export_json_to_excel({
+          header: tHeader,
+          data: data1,
+          filename: '安全阀模板',
+          autoWidth: true,
+          bookType: 'xlsx'
+        })
+      })
+    },
+    beforeImportExcel(file) {
+      const isLt2M = file.size / 1024 / 1024 < 6
+      if (!isLt2M) {
+        this.$message.error('上传文件大小不能超过 6MB!')
+      }
+      return isLt2M
+    },
+    handleImportExcelSuccess(res, file) {
+      this.get_table_data()
+      if (res.msg === 'ok') {
+        this.$message({
+          title: '成功',
+          message: '导入成功:' + res.data.success + '条!',
+          type: 'success',
+          duration: 2000
+        })
+        if (res.data.err_count > 0) {
+          this.$notify({
+            title: '失败',
+            message: '导入失败:' + res.data.err_count + '条!',
+            type: 'danger',
+            duration: 2000
+          })
+           import('@/vendor/Export2Excel').then(excel => {
+             const list1 = res.data.result
+             const tHeader = [
+               '牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人', '报错信息'
+             ]
+             const filterVal = [
+               '牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人', 'error_msg'
+             ]
+             const data1 = this.formatJson(filterVal, list1)
+             excel.export_json_to_excel({
+               header: tHeader,
+               data: data1,
+               filename: '安全阀报错信息',
+               autoWidth: true,
+               bookType: 'xlsx'
+             })
+           })
+        }
+      } else {
+        this.$notify({
+          title: '失败',
+          message: '上传失败',
+          type: 'danger',
+          duration: 2000
+        })
+      }
+    },
+    formatJson(filterVal, jsonData) {
+      return jsonData.map(v =>
+        filterVal.map(j => {
+          if (j === 'timestamp') {
+            return parseTime(v[j])
+          } else {
+            return v[j]
+          }
+        })
+      )
+    },
+    handleDownload() {
+      console.log('点击了导出')
+      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 = 'getExaminewarningList'
+      this.downLoadParm.parammaps = this.getdataListParm.parammaps
+      GetAccount(this.downLoadParm).then(response => {
+        if (response.data.list !== '') {
+          this.percentage = 99
+          setTimeout(() => {
+            this.isPercentage = false
+          }, 2000)
+        }
+        this.$nextTick(() => {
+          this.downLoadList = response.data.list
+          console.log('导出table数据', this.downLoadList)
+          const ExcelDatas = [
+            {
+              tHeader: ['牧场', '安全阀类型', '安全阀型号', '公称通径', '公称压力MPa', '工作压力MPa', '整定压力MPa', '起跳压力MPa', '回座压力MPa', '使用位置', '使用部门', '本次检验日期', '下次检验日期', '管理责任人'],
+              filterVal: ['pastureName', 'warnName', 'specification', 'level', 'measureRange', 'factoryNumber', 'amount', 'unit', 'cycle', 'warnUnit', 'departmentName', 'lastCheckDate', 'validityDate', 'empName'],
+              tableDatas: this.downLoadList,
+              sheetName: '安全阀'
+            }
+          ]
+          json2excel(ExcelDatas, '安全阀', true, 'xlsx')
+        })
+      })
+    }
+
+  }
+}
+</script>
+<style lang="scss" scoped>
+.app-btn {
+  margin-bottom: 10px;
+}
+</style>
+

+ 650 - 650
src/views/special/earlyWarning/components/thermometer.vue

@@ -1,650 +1,650 @@
-<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 v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 150px;">
-        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
-      </el-select>
-      <el-select v-model="getdataListParm.parammaps.status" placeholder="检验预警状态" class="filter-item" style="width: 150px;">
-        <el-option v-for="item in warningStatus" :key="item.id" :label="item.name" :value="item.name" />
-      </el-select>
-      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
-    </div>
-    <div class="app-btn">
-      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
-      <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
-      <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
-        <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
-      </el-upload>
-      <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
-    </div>
-    <el-table
-      :key="tableKey"
-      v-loading="listLoading"
-      element-loading-text="给我一点时间"
-      :data="list"
-      border
-      fit
-      highlight-current-row
-      style="width: 100%;"
-      :row-class-name="tableRowClassName"
-      :row-style="selectedHighlight"
-      :cell-style="cellStyle"
-      class="elTable table-fixed"
-      :max-height="myHeight"
-    >
-      <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="140px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.warnName }}</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="150px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.level }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="测量范围" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.measureRange }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="出厂编号" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.factoryNumber }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="数量" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.amount }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="制造单位" min-width="100px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.unit }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="检定周期" min-width="80px" align="center" sortable prop="cycle" />
-      <el-table-column label="检验日期" min-width="80px" align="center" sortable prop="lastCheckDate" />
-      <el-table-column label="有效日期" min-width="110px" align="center" sortable prop="validityDate" />
-      <el-table-column label="检定单位" min-width="80px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.warnUnit }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="计量器具用途" min-width="110px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.purpose }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="安装使用地点" min-width="110px" align="center">
-        <template slot-scope="scope">
-          <span>{{ scope.row.location }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
-        <template slot-scope="{row}">
-          <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
-          <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
-          <el-button type="danger" size="mini" @click="form_delete(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" width="80%">
-      <div class="app-add">
-        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="145px" style="width: 90%;margin:0 auto 30px">
-          <el-row>
-            <el-col :span="8">
-              <el-form-item ref="pastureId" label="牧场:" prop="pastureId">
-                <el-select v-model="createTemp.pastureId " placeholder="请输入牧场" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changePasture">
-                  <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="warnName">
-                <el-input ref="warnName" v-model="createTemp.warnName" placeholder="请输入计量器具名称" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="规格型号:" prop="specification">
-                <el-input ref="specification" v-model="createTemp.specification" placeholder="请输入规格型号" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="准确度等级、不确定度或最大允许误差:" prop="level">
-                <el-input ref="level" v-model="createTemp.level" placeholder="请输入准确度等级、不确定度或最大允许误差" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="测量范围:" prop="measureRange">
-                <el-input ref="measureRange" v-model="createTemp.measureRange" placeholder="请输入测量范围" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="出厂编号:" prop="factoryNumber">
-                <el-input ref="factoryNumber" v-model="createTemp.factoryNumber" placeholder="请输入出厂编号" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="数量:" prop="amount">
-                <el-input ref="amount" v-model="createTemp.amount" placeholder="请输入数量" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="制造单位:" prop="unit">
-                <el-input ref="unit" v-model="createTemp.unit" placeholder="请输入制造单位" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="检定周期:" prop="cycle">
-                <el-input ref="cycle" v-model="createTemp.cycle" placeholder="请输入检定周期" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="检验日期:" prop="lastCheckDate">
-                <el-date-picker v-model="createTemp.lastCheckDate" :picker-options="pickerOptions1" type="date" placeholder="请输入检验日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="有效日期:" prop="validityDate">
-                <el-date-picker v-model="createTemp.validityDate" :picker-options="pickerOptions2" type="date" placeholder="请输入有效日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="检定单位:" prop="warnUnit">
-                <el-input ref="warnUnit" v-model="createTemp.warnUnit" placeholder="请输入检定单位" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row>
-            <el-col :span="8">
-              <el-form-item label="计量器具用途:" prop="purpose">
-                <el-input ref="purpose" v-model="createTemp.purpose" placeholder="请输入计量器具用途" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="8">
-              <el-form-item label="安装使用地点:" prop="location">
-                <el-input ref="location" v-model="createTemp.location" placeholder="请输入安装使用地点" :disabled="dialogStatus==='see'" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
-        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
-          <el-button v-if="dialogStatus==='create' || dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
-          <el-button @click="dialogFormVisible = false; getdataListParm.parammaps.inputDatetime = ''">取消并关闭</el-button>
-        </div>
-      </div>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-import waves from '@/directive/waves'
-import { GetDataByNames, GetDataByName, PostDataByName, failproccess, GetAccount } from '@/api/common'
-import Cookies from 'js-cookie'
-import { json2excel } from '@/utils/index.js'
-import { MessageBox } from 'element-ui'
-import { getToken } from '@/utils/auth'
-import { parseTime } from '@/utils/index.js'
-import Pagination from '@/components/Pagination'
-export default {
-  name: 'Thermometer',
-  directives: { waves },
-  components: { Pagination },
-  data() {
-    return {
-      myHeight:document.documentElement.clientHeight - 85- 250,
-      warningStatus: [{ id: 0, name: '全部' }, { id: 1, name: '正常' }, { id: 2, name: '预警期' }],
-      findAllPasture: [],
-      findAllDepart: [],
-      findAllEmploye: [],
-      requestParams: [
-        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
-        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
-        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
-      ],
-      rules: {
-        pastureId: [{ required: true, message: '必填', trigger: 'blur' }],
-        warnName: [{ required: true, message: '必填', trigger: 'blur' }],
-        specification: [{ required: true, message: '必填', trigger: 'blur' }],
-        lastCheckDate: [{ required: true, message: '必填', trigger: 'blur' }],
-        validityDate: [{ required: true, message: '必填', trigger: 'blur' }]
-      },
-      getdataListParm: {
-        name: 'getExaminewarningList',
-        page: 1,
-        offset: 1,
-        pagecount: 10,
-        returntype: 'Map',
-        parammaps: {
-          pastureName: Cookies.get('pasturename'),
-          warningType: '温度计'
-        }
-      },
-      tableKey: 0,
-      listLoading: false,
-      total: 0,
-      list: [],
-      getIndexList: [],
-      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
-      cellStyle: { padding: 0 + 'px' },
-      pickerOptions1: {
-        disabledDate: (time) => {
-          if (this.createTemp.validityDate !== '') {
-            return parseTime(time.getTime(), '{y}-{m}-{d}') >= this.createTemp.validityDate
-          } else {
-            return ''
-          }
-        }
-      },
-      pickerOptions2: {
-        disabledDate: (time) => {
-          return parseTime(time.getTime(), '{y}-{m}-{d}') <= this.createTemp.lastCheckDate
-        }
-      },
-      createTemp: {
-        pastureId: this.$store.state.user.pastureid,
-        pastureName: this.$store.state.user.pasturename,
-        // departmentName: this.$store.state.user.departmentname,
-        // departmentId: this.$store.state.user.departmentid,
-        warnName: '',
-        specification: '',
-        level: '',
-        measureRange: '',
-        factoryNumber: '',
-        amount: '',
-        unit: '',
-        cycle: '',
-        lastCheckDate: '',
-        validityDate: '',
-        warnUnit: '',
-        purpose: '',
-        location: ''
-      },
-      dialogFormVisible: false,
-      dialogStatus: '',
-      textMap: {
-        create: '新增',
-        update: '编辑',
-        see: '查看'
-      },
-      isokDisable: false,
-      postDataPramas: {},
-      downLoadParm: {},
-      isPercentage: false,
-      percentage: 1
-    }
-  },
-  computed: {
-    headers() {
-      return {
-        token: getToken()
-      }
-    },
-    uploadData() {
-      return {
-        name: 'uploadExaminewarnWDJ',
-        importParams: '牧场,器具名称,规格型号,准确度等级、不确定度或最大允许误差,测量范围,出厂编号,数量,制造单位,检定周期,上次检定日期,有效期至,检定单位,计量器具用途,安装使用地点',
-        sheetname: 'SheetJS'
-      }
-    },
-    // 设置上传地址
-    uploadExcelUrl() {
-      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
-    }
-  },
-  created() {
-    this.get_select_list()
-    this.get_table_data()
-  },
-
-  // 设置变量
-
-  methods: {
-    get_select_list() {
-      GetDataByNames(this.requestParams).then(response => {
-        this.findAllPasture = response.data.findAllPasture.list
-        this.findAllDepart = response.data.findAllDepart.list
-        this.findAllEmploye = response.data.findAllEmploye.list
-      })
-    },
-    getNextDate(date, day) {
-      var dd = new Date(date)
-      dd.setDate(dd.getDate() + day)
-      var y = dd.getFullYear()
-      var m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1
-      var d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
-      return y + '-' + m + '-' + d
-    },
-    tableRowClassName({ row, rowIndex }) {
-      // 把每一行的索引放进row
-      row.index = rowIndex
-    },
-    get_table_data() {
-      this.listLoading = true
-      GetDataByName(this.getdataListParm).then(response => {
-        if (response.data.list !== null || response.data !== null) {
-          this.list = []
-        } else {
-          console.log('table数据', response.data.list)
-          this.getIndexList = []
-          for (let i = 0; i < response.data.list.length; i++) {
-            response.data.list[i].index = i
-            if (this.getNextDate(response.data.list[i].validityDate, -30) <= parseTime(new Date(), '{y}-{m}-{d}')) {
-              this.getIndexList.push({ 'myindex': response.data.list[i].index })
-            }
-          }
-          this.list = response.data.list
-          this.pageNum = response.data.pageNum
-          this.pageSize = response.data.pageSize
-          this.total = response.data.total
-        }
-        setTimeout(() => {
-          this.listLoading = false
-        }, 100)
-      })
-    },
-    selectedHighlight({ row, rowIndex }) {
-      for (let i = 0; i < this.getIndexList.length; i++) {
-        if (this.getIndexList[i].myindex === rowIndex) {
-          return {
-            color: 'red'
-          }
-        }
-      }
-    },
-
-    form_search() {
-      console.log('点击了搜索')
-      this.getdataListParm.offset = 1
-      this.get_table_data()
-    },
-    resetCreateTemp() {
-      this.createTemp.pastureId = this.$store.state.user.pastureid
-      this.createTemp.pastureName = this.$store.state.user.pasturename
-      // this.createTemp.departmentName = this.$store.state.user.departmentname
-      // this.createTemp.departmentId = this.$store.state.user.departmentid
-      this.createTemp.warnName = ''
-      this.createTemp.specification = ''
-      this.createTemp.level = ''
-      this.createTemp.measureRange = ''
-      this.createTemp.factoryNumber = ''
-      this.createTemp.amount = ''
-      this.createTemp.unit = ''
-      this.createTemp.cycle = ''
-      this.createTemp.lastCheckDate = ''
-      this.createTemp.validityDate = ''
-      this.createTemp.warnUnit = ''
-      this.createTemp.purpose = ''
-      this.createTemp.location = ''
-    },
-    form_add() {
-      console.log('点击了新增')
-      this.resetCreateTemp()
-      this.dialogStatus = 'create'
-      this.dialogFormVisible = true
-    },
-    changePasture(item) {
-      this.createTemp.pastureName = this.findAllPasture.find(obj => obj.id === item).name
-    },
-    add_dialog_save() {
-      console.log('点击了保存')
-      this.isokDisable = true
-      setTimeout(() => {
-        this.isokDisable = false
-      }, 1000)
-      this.$refs['createTemp'].validate(valid => {
-        if (valid) {
-          this.postDataPramas.name = 'insertExaminewarning'
-          this.postDataPramas.parammaps = {}
-          this.postDataPramas.parammaps = this.createTemp
-          this.postDataPramas.parammaps.warningType = '温度计'
-          PostDataByName(this.postDataPramas).then(response => {
-            console.log('新增保存发送参数', this.postDataPramas)
-            if (response.msg !== 'fail') {
-              this.dialogFormVisible = false
-              this.get_table_data()
-              this.$notify({
-                title: '成功',
-                message: '新增成功',
-                type: 'success',
-                duration: 2000
-              })
-            } else {
-              failproccess(response, this.$notify)
-            }
-          })
-        }
-      })
-    },
-    form_edit(row) {
-      console.log('点击了编辑')
-      this.dialogStatus = 'update'
-      this.dialogFormVisible = true
-      this.createTemp = Object.assign({}, row)
-      this.createTemp.pastureId = parseFloat(row.pastureId)
-      this.createTemp.departmentId = parseFloat(row.departmentId)
-      this.createTemp.empId = parseFloat(row.empId)
-    },
-    edit_dialog_save() {
-      console.log('点击了编辑保存')
-      this.isokDisable = true
-      setTimeout(() => {
-        this.isokDisable = false
-      }, 1000)
-      this.$refs['createTemp'].validate(valid => {
-        if (valid) {
-          this.postDataPramas.name = 'updateExaminewarning'
-          this.postDataPramas.parammaps = {}
-          this.postDataPramas.parammaps = this.createTemp
-          this.postDataPramas.parammaps.id = this.createTemp.id
-          this.postDataPramas.parammaps.warningType = '温度计'
-          PostDataByName(this.postDataPramas).then(response => {
-            console.log('编辑保存发送参数', this.postDataPramas)
-            if (response.msg !== 'fail') {
-              this.dialogFormVisible = false
-              this.get_table_data()
-              this.$notify({
-                title: '成功',
-                message: '保存成功',
-                type: 'success',
-                duration: 2000
-              })
-            } else {
-              failproccess(response, this.$notify)
-            }
-          })
-        }
-      })
-    },
-    form_see(row) {
-      console.log('点击了查看', row)
-      this.dialogStatus = 'see'
-      this.dialogFormVisible = true
-      this.createTemp = Object.assign({}, row)
-      this.createTemp.pastureId = parseFloat(row.pastureId)
-      this.createTemp.departmentId = parseFloat(row.departmentId)
-      this.createTemp.empId = parseFloat(row.empId)
-    },
-    form_delete(row) {
-      MessageBox.confirm('确认删除此信息?', {
-        confirmButtonText: '确认',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        console.log('点击了删除', row)
-        this.postDataPramas.name = 'deleteExaminewarning'
-        this.postDataPramas.parammaps = {}
-        this.postDataPramas.parammaps.id = row.id
-        this.postDataPramas.parammaps.warningType = '温度计'
-        PostDataByName(this.postDataPramas).then(response => {
-          console.log('删除保存发送参数', this.postDataPramas)
-          if (response.msg !== 'fail') {
-            this.dialogFormVisible = false
-            this.get_table_data()
-            this.$notify({
-              title: '成功',
-              message: '删除成功',
-              type: 'success',
-              duration: 2000
-            })
-          } else {
-            failproccess(response, this.$notify)
-          }
-        })
-      })
-    },
-    handleDownloadTemp() {
-      console.log('点击了模板')
-      import('@/vendor/Export2Excel').then(excel => {
-        const list1 = []
-        const tHeader = [
-          '牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'
-        ]
-        const filterVal = [
-          '牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'
-        ]
-        const data1 = this.formatJson(filterVal, list1)
-        excel.export_json_to_excel({
-          header: tHeader,
-          data: data1,
-          filename: '温度计模板',
-          autoWidth: true,
-          bookType: 'xlsx'
-        })
-      })
-    },
-    beforeImportExcel(file) {
-      const isLt2M = file.size / 1024 / 1024 < 6
-      if (!isLt2M) {
-        this.$message.error('上传文件大小不能超过 6MB!')
-      }
-      return isLt2M
-    },
-    handleImportExcelSuccess(res, file) {
-      this.get_table_data()
-      if (res.msg === 'ok') {
-        this.$message({
-          title: '成功',
-          message: '导入成功:' + res.data.success + '条!',
-          type: 'success',
-          duration: 2000
-        })
-        if (res.data.err_count > 0) {
-          this.$notify({
-            title: '失败',
-            message: '导入失败:' + res.data.err_count + '条!',
-            type: 'danger',
-            duration: 2000
-          })
-           import('@/vendor/Export2Excel').then(excel => {
-             const list1 = res.data.result
-             const tHeader = [
-               '牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点', '报错信息'
-             ]
-             const filterVal = [
-               '牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点', 'error_msg'
-             ]
-             const data1 = this.formatJson(filterVal, list1)
-             excel.export_json_to_excel({
-               header: tHeader,
-               data: data1,
-               filename: '温度计报错信息',
-               autoWidth: true,
-               bookType: 'xlsx'
-             })
-           })
-        }
-      } else {
-        this.$notify({
-          title: '失败',
-          message: '上传失败',
-          type: 'danger',
-          duration: 2000
-        })
-      }
-    },
-    formatJson(filterVal, jsonData) {
-      return jsonData.map(v =>
-        filterVal.map(j => {
-          if (j === 'timestamp') {
-            return parseTime(v[j])
-          } else {
-            return v[j]
-          }
-        })
-      )
-    },
-    handleDownload() {
-      console.log('点击了导出')
-      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 = 'getExaminewarningList'
-      this.downLoadParm.parammaps = this.getdataListParm.parammaps
-      GetAccount(this.downLoadParm).then(response => {
-        if (response.data.list !== '') {
-          this.percentage = 99
-          setTimeout(() => {
-            this.isPercentage = false
-          }, 2000)
-        }
-        this.$nextTick(() => {
-          this.downLoadList = response.data.list
-          console.log('导出table数据', this.downLoadList)
-          const ExcelDatas = [
-            {
-              tHeader: ['牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'],
-              filterVal: ['pastureName', 'warnName', 'specification', 'level', 'measureRange', 'factoryNumber', 'amount', 'unit', 'cycle', 'lastCheckDate', 'validityDate', 'warnUnit', 'purpose', 'location'],
-              tableDatas: this.downLoadList,
-              sheetName: '温度计'
-            }
-          ]
-          json2excel(ExcelDatas, '温度计', true, 'xlsx')
-        })
-      })
-    }
-
-  }
-}
-</script>
-<style lang="scss" scoped>
-.app-btn {
-  margin-bottom: 10px;
-}
-</style>
-
+<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 v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 150px;">
+        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
+      </el-select>
+      <el-select v-model="getdataListParm.parammaps.status" placeholder="检验预警状态" class="filter-item" style="width: 150px;">
+        <el-option v-for="item in warningStatus" :key="item.id" :label="item.name" :value="item.name" />
+      </el-select>
+      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
+    </div>
+    <div class="app-btn">
+      <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
+      <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
+      <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
+        <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
+      </el-upload>
+      <el-button class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
+    </div>
+    <el-table
+      :key="tableKey"
+      v-loading="listLoading"
+      element-loading-text="给我一点时间"
+      :data="list"
+      border
+      fit
+      highlight-current-row
+      style="width: 100%;"
+      :row-class-name="tableRowClassName"
+      :row-style="selectedHighlight"
+      :cell-style="cellStyle"
+      class="elTable table-fixed"
+      :max-height="myHeight"
+    >
+      <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="140px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.warnName }}</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="150px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.level }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="测量范围" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.measureRange }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="出厂编号" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.factoryNumber }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="数量" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.amount }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="制造单位" min-width="100px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.unit }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="检定周期" min-width="80px" align="center" sortable prop="cycle" />
+      <el-table-column label="检验日期" min-width="80px" align="center" sortable prop="lastCheckDate" />
+      <el-table-column label="有效日期" min-width="110px" align="center" sortable prop="validityDate" />
+      <el-table-column label="检定单位" min-width="80px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.warnUnit }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="计量器具用途" min-width="110px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.purpose }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="安装使用地点" min-width="110px" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.location }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
+        <template slot-scope="{row}">
+          <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
+          <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
+          <el-button type="danger" size="mini" @click="form_delete(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" width="80%">
+      <div class="app-add">
+        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="145px" style="width: 90%;margin:0 auto 30px">
+          <el-row>
+            <el-col :span="8">
+              <el-form-item ref="pastureId" label="牧场:" prop="pastureId">
+                <el-select v-model="createTemp.pastureId " placeholder="请输入牧场" class="filter-item" style="width:100%" :disabled="dialogStatus==='see'" @change="changePasture">
+                  <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="warnName">
+                <el-input ref="warnName" v-model="createTemp.warnName" placeholder="请输入计量器具名称" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="规格型号:" prop="specification">
+                <el-input ref="specification" v-model="createTemp.specification" placeholder="请输入规格型号" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="准确度等级、不确定度或最大允许误差:" prop="level">
+                <el-input ref="level" v-model="createTemp.level" placeholder="请输入准确度等级、不确定度或最大允许误差" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="测量范围:" prop="measureRange">
+                <el-input ref="measureRange" v-model="createTemp.measureRange" placeholder="请输入测量范围" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="出厂编号:" prop="factoryNumber">
+                <el-input ref="factoryNumber" v-model="createTemp.factoryNumber" placeholder="请输入出厂编号" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="数量:" prop="amount">
+                <el-input ref="amount" v-model="createTemp.amount" placeholder="请输入数量" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="制造单位:" prop="unit">
+                <el-input ref="unit" v-model="createTemp.unit" placeholder="请输入制造单位" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="检定周期:" prop="cycle">
+                <el-input ref="cycle" v-model="createTemp.cycle" placeholder="请输入检定周期" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="检验日期:" prop="lastCheckDate">
+                <el-date-picker v-model="createTemp.lastCheckDate" :picker-options="pickerOptions1" type="date" placeholder="请输入检验日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="有效日期:" prop="validityDate">
+                <el-date-picker v-model="createTemp.validityDate" :picker-options="pickerOptions2" type="date" placeholder="请输入有效日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="检定单位:" prop="warnUnit">
+                <el-input ref="warnUnit" v-model="createTemp.warnUnit" placeholder="请输入检定单位" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="计量器具用途:" prop="purpose">
+                <el-input ref="purpose" v-model="createTemp.purpose" placeholder="请输入计量器具用途" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="安装使用地点:" prop="location">
+                <el-input ref="location" v-model="createTemp.location" placeholder="请输入安装使用地点" :disabled="dialogStatus==='see'" />
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+        <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
+          <el-button v-if="dialogStatus==='create' || dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
+          <el-button @click="dialogFormVisible = false; getdataListParm.parammaps.inputDatetime = ''">取消并关闭</el-button>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import waves from '@/directive/waves'
+import { GetDataByNames, GetDataByName, PostDataByName, failproccess, GetAccount } from '@/api/common'
+import Cookies from 'js-cookie'
+import { json2excel } from '@/utils/index.js'
+import { MessageBox } from 'element-ui'
+import { getToken } from '@/utils/auth'
+import { parseTime } from '@/utils/index.js'
+import Pagination from '@/components/Pagination'
+export default {
+  name: 'Thermometer',
+  directives: { waves },
+  components: { Pagination },
+  data() {
+    return {
+      myHeight:document.documentElement.clientHeight - 85- 250,
+      warningStatus: [{ id: 0, name: '全部' }, { id: 1, name: '正常' }, { id: 2, name: '预警期' }],
+      findAllPasture: [],
+      findAllDepart: [],
+      findAllEmploye: [],
+      requestParams: [
+        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
+        { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
+        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
+      ],
+      rules: {
+        pastureId: [{ required: true, message: '必填', trigger: 'blur' }],
+        warnName: [{ required: true, message: '必填', trigger: 'blur' }],
+        specification: [{ required: true, message: '必填', trigger: 'blur' }],
+        lastCheckDate: [{ required: true, message: '必填', trigger: 'blur' }],
+        validityDate: [{ required: true, message: '必填', trigger: 'blur' }]
+      },
+      getdataListParm: {
+        name: 'getExaminewarningList',
+        page: 1,
+        offset: 1,
+        pagecount: 10,
+        returntype: 'Map',
+        parammaps: {
+          pastureName: Cookies.get('pasturename'),
+          warningType: '温度计'
+        }
+      },
+      tableKey: 0,
+      listLoading: false,
+      total: 0,
+      list: [],
+      getIndexList: [],
+      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
+      cellStyle: { padding: 0 + 'px' },
+      pickerOptions1: {
+        disabledDate: (time) => {
+          if (this.createTemp.validityDate !== '') {
+            return parseTime(time.getTime(), '{y}-{m}-{d}') >= this.createTemp.validityDate
+          } else {
+            return ''
+          }
+        }
+      },
+      pickerOptions2: {
+        disabledDate: (time) => {
+          return parseTime(time.getTime(), '{y}-{m}-{d}') <= this.createTemp.lastCheckDate
+        }
+      },
+      createTemp: {
+        pastureId: this.$store.state.user.pastureid,
+        pastureName: this.$store.state.user.pasturename,
+        // departmentName: this.$store.state.user.departmentname,
+        // departmentId: this.$store.state.user.departmentid,
+        warnName: '',
+        specification: '',
+        level: '',
+        measureRange: '',
+        factoryNumber: '',
+        amount: '',
+        unit: '',
+        cycle: '',
+        lastCheckDate: '',
+        validityDate: '',
+        warnUnit: '',
+        purpose: '',
+        location: ''
+      },
+      dialogFormVisible: false,
+      dialogStatus: '',
+      textMap: {
+        create: '新增',
+        update: '编辑',
+        see: '查看'
+      },
+      isokDisable: false,
+      postDataPramas: {},
+      downLoadParm: {},
+      isPercentage: false,
+      percentage: 1
+    }
+  },
+  computed: {
+    headers() {
+      return {
+        token: getToken()
+      }
+    },
+    uploadData() {
+      return {
+        name: 'uploadExaminewarnWDJ',
+        importParams: '牧场,器具名称,规格型号,准确度等级、不确定度或最大允许误差,测量范围,出厂编号,数量,制造单位,检定周期,上次检定日期,有效期至,检定单位,计量器具用途,安装使用地点',
+        sheetname: 'SheetJS'
+      }
+    },
+    // 设置上传地址
+    uploadExcelUrl() {
+      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
+    }
+  },
+  created() {
+    this.get_select_list()
+    this.get_table_data()
+  },
+
+  // 设置变量
+
+  methods: {
+    get_select_list() {
+      GetDataByNames(this.requestParams).then(response => {
+        this.findAllPasture = response.data.findAllPasture.list
+        this.findAllDepart = response.data.findAllDepart.list
+        this.findAllEmploye = response.data.findAllEmploye.list
+      })
+    },
+    getNextDate(date, day) {
+      var dd = new Date(date)
+      dd.setDate(dd.getDate() + day)
+      var y = dd.getFullYear()
+      var m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1
+      var d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
+      return y + '-' + m + '-' + d
+    },
+    tableRowClassName({ row, rowIndex }) {
+      // 把每一行的索引放进row
+      row.index = rowIndex
+    },
+    get_table_data() {
+      this.listLoading = true
+      GetDataByName(this.getdataListParm).then(response => {
+        if (response.data.list !== null || response.data !== null) {
+          console.log('table数据', response.data.list)
+          this.getIndexList = []
+          for (let i = 0; i < response.data.list.length; i++) {
+            response.data.list[i].index = i
+            if (this.getNextDate(response.data.list[i].validityDate, -30) <= parseTime(new Date(), '{y}-{m}-{d}')) {
+              this.getIndexList.push({ 'myindex': response.data.list[i].index })
+            }
+          }
+          this.list = response.data.list
+          this.pageNum = response.data.pageNum
+          this.pageSize = response.data.pageSize
+          this.total = response.data.total
+        } else {
+          this.list = []
+        }
+        setTimeout(() => {
+          this.listLoading = false
+        }, 100)
+      })
+    },
+    selectedHighlight({ row, rowIndex }) {
+      for (let i = 0; i < this.getIndexList.length; i++) {
+        if (this.getIndexList[i].myindex === rowIndex) {
+          return {
+            color: 'red'
+          }
+        }
+      }
+    },
+
+    form_search() {
+      console.log('点击了搜索')
+      this.getdataListParm.offset = 1
+      this.get_table_data()
+    },
+    resetCreateTemp() {
+      this.createTemp.pastureId = this.$store.state.user.pastureid
+      this.createTemp.pastureName = this.$store.state.user.pasturename
+      // this.createTemp.departmentName = this.$store.state.user.departmentname
+      // this.createTemp.departmentId = this.$store.state.user.departmentid
+      this.createTemp.warnName = ''
+      this.createTemp.specification = ''
+      this.createTemp.level = ''
+      this.createTemp.measureRange = ''
+      this.createTemp.factoryNumber = ''
+      this.createTemp.amount = ''
+      this.createTemp.unit = ''
+      this.createTemp.cycle = ''
+      this.createTemp.lastCheckDate = ''
+      this.createTemp.validityDate = ''
+      this.createTemp.warnUnit = ''
+      this.createTemp.purpose = ''
+      this.createTemp.location = ''
+    },
+    form_add() {
+      console.log('点击了新增')
+      this.resetCreateTemp()
+      this.dialogStatus = 'create'
+      this.dialogFormVisible = true
+    },
+    changePasture(item) {
+      this.createTemp.pastureName = this.findAllPasture.find(obj => obj.id === item).name
+    },
+    add_dialog_save() {
+      console.log('点击了保存')
+      this.isokDisable = true
+      setTimeout(() => {
+        this.isokDisable = false
+      }, 1000)
+      this.$refs['createTemp'].validate(valid => {
+        if (valid) {
+          this.postDataPramas.name = 'insertExaminewarning'
+          this.postDataPramas.parammaps = {}
+          this.postDataPramas.parammaps = this.createTemp
+          this.postDataPramas.parammaps.warningType = '温度计'
+          PostDataByName(this.postDataPramas).then(response => {
+            console.log('新增保存发送参数', this.postDataPramas)
+            if (response.msg !== 'fail') {
+              this.dialogFormVisible = false
+              this.get_table_data()
+              this.$notify({
+                title: '成功',
+                message: '新增成功',
+                type: 'success',
+                duration: 2000
+              })
+            } else {
+              failproccess(response, this.$notify)
+            }
+          })
+        }
+      })
+    },
+    form_edit(row) {
+      console.log('点击了编辑')
+      this.dialogStatus = 'update'
+      this.dialogFormVisible = true
+      this.createTemp = Object.assign({}, row)
+      this.createTemp.pastureId = parseFloat(row.pastureId)
+      this.createTemp.departmentId = parseFloat(row.departmentId)
+      this.createTemp.empId = parseFloat(row.empId)
+    },
+    edit_dialog_save() {
+      console.log('点击了编辑保存')
+      this.isokDisable = true
+      setTimeout(() => {
+        this.isokDisable = false
+      }, 1000)
+      this.$refs['createTemp'].validate(valid => {
+        if (valid) {
+          this.postDataPramas.name = 'updateExaminewarning'
+          this.postDataPramas.parammaps = {}
+          this.postDataPramas.parammaps = this.createTemp
+          this.postDataPramas.parammaps.id = this.createTemp.id
+          this.postDataPramas.parammaps.warningType = '温度计'
+          PostDataByName(this.postDataPramas).then(response => {
+            console.log('编辑保存发送参数', this.postDataPramas)
+            if (response.msg !== 'fail') {
+              this.dialogFormVisible = false
+              this.get_table_data()
+              this.$notify({
+                title: '成功',
+                message: '保存成功',
+                type: 'success',
+                duration: 2000
+              })
+            } else {
+              failproccess(response, this.$notify)
+            }
+          })
+        }
+      })
+    },
+    form_see(row) {
+      console.log('点击了查看', row)
+      this.dialogStatus = 'see'
+      this.dialogFormVisible = true
+      this.createTemp = Object.assign({}, row)
+      this.createTemp.pastureId = parseFloat(row.pastureId)
+      this.createTemp.departmentId = parseFloat(row.departmentId)
+      this.createTemp.empId = parseFloat(row.empId)
+    },
+    form_delete(row) {
+      MessageBox.confirm('确认删除此信息?', {
+        confirmButtonText: '确认',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        console.log('点击了删除', row)
+        this.postDataPramas.name = 'deleteExaminewarning'
+        this.postDataPramas.parammaps = {}
+        this.postDataPramas.parammaps.id = row.id
+        this.postDataPramas.parammaps.warningType = '温度计'
+        PostDataByName(this.postDataPramas).then(response => {
+          console.log('删除保存发送参数', this.postDataPramas)
+          if (response.msg !== 'fail') {
+            this.dialogFormVisible = false
+            this.get_table_data()
+            this.$notify({
+              title: '成功',
+              message: '删除成功',
+              type: 'success',
+              duration: 2000
+            })
+          } else {
+            failproccess(response, this.$notify)
+          }
+        })
+      })
+    },
+    handleDownloadTemp() {
+      console.log('点击了模板')
+      import('@/vendor/Export2Excel').then(excel => {
+        const list1 = []
+        const tHeader = [
+          '牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'
+        ]
+        const filterVal = [
+          '牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'
+        ]
+        const data1 = this.formatJson(filterVal, list1)
+        excel.export_json_to_excel({
+          header: tHeader,
+          data: data1,
+          filename: '温度计模板',
+          autoWidth: true,
+          bookType: 'xlsx'
+        })
+      })
+    },
+    beforeImportExcel(file) {
+      const isLt2M = file.size / 1024 / 1024 < 6
+      if (!isLt2M) {
+        this.$message.error('上传文件大小不能超过 6MB!')
+      }
+      return isLt2M
+    },
+    handleImportExcelSuccess(res, file) {
+      this.get_table_data()
+      if (res.msg === 'ok') {
+        this.$message({
+          title: '成功',
+          message: '导入成功:' + res.data.success + '条!',
+          type: 'success',
+          duration: 2000
+        })
+        if (res.data.err_count > 0) {
+          this.$notify({
+            title: '失败',
+            message: '导入失败:' + res.data.err_count + '条!',
+            type: 'danger',
+            duration: 2000
+          })
+           import('@/vendor/Export2Excel').then(excel => {
+             const list1 = res.data.result
+             const tHeader = [
+               '牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点', '报错信息'
+             ]
+             const filterVal = [
+               '牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点', 'error_msg'
+             ]
+             const data1 = this.formatJson(filterVal, list1)
+             excel.export_json_to_excel({
+               header: tHeader,
+               data: data1,
+               filename: '温度计报错信息',
+               autoWidth: true,
+               bookType: 'xlsx'
+             })
+           })
+        }
+      } else {
+        this.$notify({
+          title: '失败',
+          message: '上传失败',
+          type: 'danger',
+          duration: 2000
+        })
+      }
+    },
+    formatJson(filterVal, jsonData) {
+      return jsonData.map(v =>
+        filterVal.map(j => {
+          if (j === 'timestamp') {
+            return parseTime(v[j])
+          } else {
+            return v[j]
+          }
+        })
+      )
+    },
+    handleDownload() {
+      console.log('点击了导出')
+      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 = 'getExaminewarningList'
+      this.downLoadParm.parammaps = this.getdataListParm.parammaps
+      GetAccount(this.downLoadParm).then(response => {
+        if (response.data.list !== '') {
+          this.percentage = 99
+          setTimeout(() => {
+            this.isPercentage = false
+          }, 2000)
+        }
+        this.$nextTick(() => {
+          this.downLoadList = response.data.list
+          console.log('导出table数据', this.downLoadList)
+          const ExcelDatas = [
+            {
+              tHeader: ['牧场', '器具名称', '规格型号', '准确度等级、不确定度或最大允许误差', '测量范围', '出厂编号', '数量', '制造单位', '检定周期', '上次检定日期', '有效期至', '检定单位', '计量器具用途', '安装使用地点'],
+              filterVal: ['pastureName', 'warnName', 'specification', 'level', 'measureRange', 'factoryNumber', 'amount', 'unit', 'cycle', 'lastCheckDate', 'validityDate', 'warnUnit', 'purpose', 'location'],
+              tableDatas: this.downLoadList,
+              sheetName: '温度计'
+            }
+          ]
+          json2excel(ExcelDatas, '温度计', true, 'xlsx')
+        })
+      })
+    }
+
+  }
+}
+</script>
+<style lang="scss" scoped>
+.app-btn {
+  margin-bottom: 10px;
+}
+</style>
+

Some files were not shown because too many files changed in this diff