<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 v-if="List1">
      <div class="filter-container">
        <el-select v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" style="width:120px" class="filter-item">
          <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
        </el-select>
        <el-date-picker ref="inputDatetime" v-model="getdataListParm.parammaps.inputDatetime" class="inputDatetime" type="datetimerange" style="width: 250px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />

        <el-select ref="statue" v-model="judgetypeARR" style="width:300px" class="filter-item" clearable  multiple >
             <el-option v-for="item in getAssessmentList" :key="item.statue" :label="item.statue" :value="item.statue" />
        </el-select>


        <el-input
          v-model="getdataListParm.parammaps.empName"
          placeholder="评估人"
          clearable
          style="width: 200px;"
          class="filter-item"
        />




        <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>

        <el-button  class="filter-item" style="margin-left: 10px;" type="success" icon="el-icon-upload2" @click="handleDownload">导出</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="warning" @click="handleInspectionStandard">检查标准管理</el-button>
      </div>
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        element-loading-text="给我一点时间"
        :data="list"
        border
        fit
        highlight-current-row
        style="width: 100%;"
        :row-style="rowStyle"
        :cell-style="cellStyle"
        class="elTable table-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="牧场" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.pastureName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="评估时间" min-width="130px" align="center" sortable prop="batime" />
        <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="120px" align="center" sortable prop="scores" />
        <el-table-column label="操作" align="center" width="300px" 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="dialogFormVisibleAdd" :close-on-click-modal="false" width="80%">
        <div class="app-add">
          <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="110px" style="width:80%;margin:0 auto;">
            <el-row>
              <el-col :span="8">
                <el-form-item label="牧场：" prop="pastureId">
                  <el-select v-model="createTemp.pastureId" style="width:100%" class="filter-item" :disabled="dialogStatus === 'update'">
                    <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="empId">
                  <el-select v-model="createTemp.empId" placeholder="录入人" class="filter-item" style="width:100%">
                    <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.id" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="评估日期：" prop="batime">
                  <el-date-picker v-model="createTemp.batime" :clearable="false" type="date" placeholder="选择日期" style="top:-3px;width:100%" format="yyyy-MM-dd" value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-if="dialogStatus==='assessment'">
              <el-col :span="8">
                <el-form-item label="检查类别：" prop="createTemp.statue">
                  <el-select ref="statue" v-model="createTemp.statue" style="width:100%" class="filter-item" @change="changeStatue">
                    <el-option v-for="item in list2" :key="item.id" :label="item.statue" :value="item.id" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <el-table
            :key="tableKeyAdd"
            v-loading="listLoadingAdd"
            element-loading-text="给我一点时间"
            :data="listAdd"
            border
            fit
            highlight-current-row
            style="width: 100%;"
            :row-style="rowStyle"
            :cell-style="cellStyle"
            class="elTable table-fixed"
          >
            <el-table-column label="序号" type="index" width="50" align="center" />
            <el-table-column label="检查类别" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.judgetype }}</span>
              </template>
            </el-table-column>
            <el-table-column label="检查标准" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.statue }}</span>
              </template>
            </el-table-column>
            <el-table-column label="检查结果" min-width="130px" align="center">
              <template slot-scope="scope">
                <el-select v-model="scope.row.score" filterable placeholder="检查结果">
                  <el-option
                    v-for="item in inspectionResultsList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                  />
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="问题描述" min-width="100px" align="center">
              <template slot-scope="scope">
                <el-form :model="scope.row" :rules="rules">
                  <el-form-item prop="note">
                    <el-input v-model="scope.row.note" autosize type="textarea" style="width:90%;height:25px" />
                    <!-- <el-input v-model="scope.row.note" style="width:100px;margin-top:25px;height:10px" /> -->
                  </el-form-item>
                </el-form>
              </template>
            </el-table-column>
            <el-table-column label="问题照片" width="280px" align="center">
              <template slot-scope="{row}">
                <el-upload
                  id="uploadPic"
                  ref="upload"
                  :limit="3"
                  list-type="picture-card"
                  :file-list="row.fileList"
                  :headers="headers"
                  :action="uploadImageUrl"
                  :auto-upload="true"
                  :on-preview="handlePicPreview"
                  :before-remove="beforeRemove"
                  :class="{hide:row.showUpload}"
                  :on-change="(file,fileList)=>{ return handlePicChange(file, fileList,row) }"
                  :on-success="(response,file, fileList)=>{ return handlePicSuccess(response,file, fileList,row) }"
                  :on-remove="(file, fileList)=>{ return handlePicRemove(file, fileList,row) }"
                >
                  <i class="el-icon-plus" />
                </el-upload>
                <el-dialog :visible.sync="dialogVisible" append-to-body :width="width">
                  <img :src="dialogImageUrl" alt="" @load="onLoad">
                </el-dialog>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div slot="footer" class="dialog-footer" style="bottom:5px">
          <!-- <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='assessment'?add_dialog_saveAdd():edit_dialog_save()">保存并关闭</el-button> -->
          <el-button v-if="dialogStatus==='assessment'" type="primary" :disabled="isokDisable" @click="add_dialog_saveAdd()">保存并关闭</el-button>
          <el-button v-if="dialogStatus==='update'" type="primary" :disabled="isokDisable" @click="edit_dialog_save()">保存并关闭</el-button>
          <el-button @click="dialogFormVisibleAdd = false;">取消并关闭</el-button>
        </div>
      </el-dialog>
      <!-- 查看 -->
      <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisibleSee" :close-on-click-modal="false" width="80%">
        <div class="app-see">
          <el-form ref="seeTemp" :rules="rules" :model="seeTemp" label-position="right" label-width="110px" style="width:80%;margin:0 auto;">
            <el-row>
              <el-col :span="8">
                <el-form-item label="牧场：" prop="pastureName">
                  <el-input ref="pastureName" v-model="seeTemp.pastureName" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="评估人：" prop="empName">
                  <el-input ref="empName" v-model="seeTemp.empName" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="评估日期：" prop="batime">
                  <el-input ref="batime" v-model="seeTemp.batime" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <el-table
            :key="tableKeySee"
            v-loading="listLoadingSee"
            element-loading-text="给我一点时间"
            :data="listSee"
            border
            fit
            highlight-current-row
            style="width: 100%;"
            :row-style="rowStyle"
            :cell-style="cellStyle"
            class="elTable table-fixed"
          >
            <el-table-column label="序号" align="center" type="index" width="50px">
              <template slot-scope="scope">
                <span>{{ scope.$index + (pageNumSee-1) * pageSizeSee + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column label="检查类别" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.judgetype }}</span>
              </template>
            </el-table-column>
            <el-table-column label="检查标准" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.statue }}</span>
              </template>
            </el-table-column>
            <el-table-column label="检查结果" min-width="130px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.score }}</span>
              </template>
            </el-table-column>
            <el-table-column label="问题描述" min-width="100px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.note }}</span>
              </template>
            </el-table-column>
            <el-table-column label="问题照片" min-width="200px" align="center">
              <template slot-scope="{row}">
                <el-upload
                  id="uploadPicSee"
                  ref="upload"
                  list-type="picture-card"
                  :file-list="row.fileList"
                  :action="uploadImageUrl"
                  :on-preview="handlePicPreview"
                  :class="{hide:row.showUpload}"
                >
                  <i class="el-icon-plus" />
                </el-upload>
                <el-dialog :visible.sync="dialogVisible" append-to-body :width="width">
                  <img :src="dialogImageUrl" alt="" @load="onLoad">
                </el-dialog>
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="totalSee>0" :total="totalSee" :page.sync="getdataListParmSee.offset" :limit.sync="getdataListParmSee.pagecount" @pagination="get_table_dataSee" />
        </div>
        <div slot="footer" class="dialog-footer" style="bottom:5px">
          <el-button class="filter-item" type="success" icon="el-icon-upload2" @click="handleDownloadSee">导出</el-button>
          <el-button @click="dialogFormVisibleSee = false;">关闭</el-button>
        </div>
      </el-dialog>
    </div>

    <!-- 检查标准管理 -->
    <div v-if="List2">
      <div class="title2">
        <b class="title2-l">检查标准管理</b>
        <a class="title2-l" style="margin-left: 20px;" @click="goBack">&lt;返回</a>
      </div>
      <div class="app-btn">
        <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="form_add2">新增</el-button>
        <el-button class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp2">模板</el-button>
        <el-upload style="display: inline-block;" :headers="headers2" :data="uploadData2" :action="uploadExcelUrl2" :show-file-list="false" :before-upload="beforeImportExcel2" :on-success="handleImportExcelSuccess2">
          <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
        </el-upload>
      </div>
      <el-table
        :key="tableKey2"
        v-loading="listLoading2"
        element-loading-text="给我一点时间"
        :data="list2"
        border
        fit
        highlight-current-row
        style="width: 100%;"
        :row-style="rowStyle"
        :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 + (pageNum2-1) * pageSize2 + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="检查类别" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.statue }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="300px" class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="{row}">
            <el-button type="success" size="mini" @click="form_see2(row)">查看</el-button>
            <el-button type="success" size="mini" @click="form_edit2(row)">编辑</el-button>
            <el-button type="danger" size="mini" @click="form_delete2(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total2>0" :total="total2" :page.sync="getdataListParm2.offset" :limit.sync="getdataListParm2.pagecount" @pagination="get_table_data2" />
      <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="110px" style="width:80%;margin:0 auto;">
            <el-row>
              <el-col :span="10">
                <el-form-item label="检查类别：" prop="statue">
                  <el-input v-model="createTemp.statue" placeholder="请输入检查类别" :disabled="dialogStatus=='see'" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-button v-if="dialogStatus==='update' || dialogStatus==='create'" class="filter-item" type="primary" @click="handleAddStandard">添加标准</el-button>
              </el-col>
            </el-row>
          </el-form>
          <el-table
            :key="tableKey3"
            v-loading="listLoading3"
            element-loading-text="给我一点时间"
            :data="list3"
            border
            fit
            highlight-current-row
            style="width: 90%;margin: 0 auto 50px;"
            :row-style="rowStyle"
            :cell-style="cellStyle"
            class="elTable table-fixed"
          >
            <el-table-column label="序号" align="center" type="index" width="50px" />
            <el-table-column label="检查标准" min-width="110px" align="center">
              <template slot-scope="scope">
                <el-form v-if="dialogStatus==='update' || dialogStatus==='create'" :model="scope.row">
                  <el-form-item prop="statue">
                    <el-input v-model="scope.row.statue" autosize type="textarea" style="width:90%;height:25px" :disabled="dialogStatus=='see'" />
                  </el-form-item>
                </el-form>
                <span v-if="dialogStatus==='see'">{{ scope.row.statue }}</span>
              </template>
            </el-table-column>
            <el-table-column v-if="dialogStatus==='update' || dialogStatus==='create'" label="操作" align="center" width="300px" class-name="small-padding fixed-width" fixed="right">
              <template slot-scope="{row}">
                <el-button type="danger" size="mini" @click="form_delete3(row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
          <div slot="footer" class="dialog-footer">
            <el-button v-if="dialogStatus==='update' || dialogStatus==='create'" type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save2():edit_dialog_save2()">保存并关闭</el-button>
            <el-button @click="dialogFormVisible = false;get_table_data2();">取消并关闭</el-button>
          </div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>

// import { getToken } from '@/utils/auth'
import { GetDataByNames, GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetAccount } from '@/api/common'
import waves from '@/directive/waves'
import Cookies from 'js-cookie'
import Pagination from '@/components/Pagination'
import { MessageBox } from 'element-ui'
import { parseTime, sortChange, json2excel  } from '@/utils/index.js'
import { getToken } from '@/utils/auth'
import table2excel from 'js-table2excel'

export default {
  name: 'Assessment',
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      myHeight:document.documentElement.clientHeight - 85- 200,
      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
      cellStyle: { padding: 0 + 'px' },
      findAllPasture: [],
      findAllEmploye: [],
      inspectionResultsList: [{ id: 1, name: 1 }, { id: 2, name: 2 }, { id: 3, name: 3 }, { id: 4, name: 4 }, { id: 5, name: 5 }],
      requestParams: [
        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
        { name: 'getAssessmentList', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
      ],
      isokDisable: false,
      List1: true,
      List2: false, // 评估检查管理
      getAssessmentList:[],
      rules: {
        statue: [{ required: true, message: '必填', trigger: 'blur' }]
      },
      dialogFormVisibleAdd: false,
      getdataListParm: {
        name: 'getbigjudgeList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          pastureName: Cookies.get('pasturename'),
          judgetype: '',
          empName:'',
          startTime: '',
          stopTime: '',
          inputDatetime: ''
        }
      },
      judgetypeARR: [],
      list: [],
      tableKey: 0,
      total: 0,
      listLoading: true,

      dialogFormVisibleSee: false,
      getdataListParmSee: {
        name: 'getjudgeListBybig',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      getDownloadSeeParm: {
        name: 'getjudgeListBybig',
        returntype: 'Map',
        parammaps: {}
      },
      listSee: [],
      listSee2: [],
      tableKeySee: 0,
      totalSee: 0,
      listLoadingSee: true,
      seeTemp: {},
      listAdd: [],
      tableKeyAdd: 0,
      listLoadingAdd: false,

      dialogImageUrl: '',
      dialogVisible: false,
      fileList: [],
      headers: {
        optname: 'insertcustompic',
        id: 1,
        token: getToken() // 从cookie里获取token，并赋值token
      },
      uploadImageUrl: process.env.VUE_APP_BASE_API + 'authdata/uploaderimage',
      width: '',

      postDataPramas: {},
      getdataListParmUpdate: {
        name: 'getjudgeListBybig',
        returntype: 'Map',
        parammaps: {}
      },

      getdataListParm2: {
        name: 'getAssessmentList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },

      getdataListParm3: {
        name: 'getAssessmentList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      list2: [],
      tableKey2: 0,
      total2: 0,
      listLoading2: true,
      judgetype: '',
      dialogStatus: '',
      dialogFormVisible: false,
      textMap: {
        update: '编辑',
        create: '新增',
        see: '查看',
        assessment: '评估'
      },
      tableKey3: 0,
      listLoading3: false,
      list3: [],
      getdataListParmSee2: {
        name: 'getAssessmentListBybigid',
        returntype: 'Map',
        parammaps: {}
      },
      createTemp: {
        statue: '',
        pastureId: this.$store.state.user.pastureid,
        batime: parseTime(new Date(), '{y}-{m}-{d}'),
        empId: this.$store.state.user.employeid
      },
      postDataParam: {},
      isPercentage: false,
      percentage: 1
    }
  },
  computed: {
    headers2() {
      return {
        token: getToken()
      }
    },
    uploadData2() {
      return {
        name: 'uploadAssessment',
        importParams: '检查类别,检查标准',
        sheetname: 'SheetJS'
      }
    },
    // 设置上传地址
    uploadExcelUrl2() {
      return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
    }
  },
  created() {
    this.get_select_list()
    this.get_table_data()
    console.log(this.uploadImageUrl)
  },
  methods: {
    get_select_list() {
      GetDataByNames(this.requestParams).then(response => {
        this.findAllPasture = response.data.findAllPasture.list
        this.findAllEmploye = response.data.findAllEmploye.list
        this.getAssessmentList =  response.data.getAssessmentList.list
      })
    },
    get_table_data() {
      console.log(this.$refs['inputDatetime'], '------------------')
      if (this.$refs['inputDatetime'] !== undefined && this.$refs['inputDatetime'].value !== null) {
        this.getdataListParm.parammaps.startTime = this.$refs['inputDatetime'].value[0]
        this.getdataListParm.parammaps.stopTime = this.$refs['inputDatetime'].value[1]
      } else {
        this.getdataListParm.parammaps.startTime = ''
        this.getdataListParm.parammaps.stopTime = ''
      }
      this.listLoading = true

      console.log(this.getdataListParm.parammaps, '------------------')


      if(this.judgetypeARR.length !== 0){
        this.getdataListParm.parammaps.judgetype = this.judgetypeARR.join(",")
      }else{
        this.getdataListParm.parammaps.judgetype = ""
      }
      GetDataByName(this.getdataListParm).then(response => {
        this.list = response.data.list
        this.pageNum = response.data.pageNum
        this.pageSize = response.data.pageSize
        if (response.data.total) {
          this.total = response.data.total
        }
        setTimeout(() => {
          this.listLoading = false
        }, 300)
      })
    },
    form_search() {
      console.log('点击了搜索')
      this.listLoading = true
      if (this.getdataListParm.parammaps.inputDatetime === null) {
        this.getdataListParm.parammaps.inputDatetime = ''
      }
      this.getdataListParm.offset = 1
      this.get_table_data()
    },

    form_see(row) {
      console.log('查看')
      this.seeTemp = Object.assign(row, {})
      this.dialogStatus = 'see'
      this.dialogFormVisibleSee = true
      this.get_table_dataSee()
    },
    get_table_dataSee() {
      this.listLoadingSee = true
      this.getdataListParmSee.parammaps.id = this.seeTemp.id
      GetDataByName(this.getdataListParmSee).then(response => {
        this.listSee = response.data.list
        if (response.data.list !== null) {
          for (var i = 0; i < response.data.list.length; i++) {
            console.log(response.data.list[i])
            const urlArray = []
            const fileList = []
            if (response.data.list[i].picpath1 == undefined && response.data.list[i].picpath2 == undefined && response.data.list[i].picpath3 == undefined) {
              urlArray.push()
            } else if (response.data.list[i].picpath1 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath2, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            } else if (response.data.list[i].picpath2 == undefined && response.data.list[i].picpath3 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1)
            } else if (response.data.list[i].picpath2 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            } else if (response.data.list[i].picpath3 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath2)
            } else {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath2, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            }
            for (let i = 0; i < urlArray.length; i++) {
              const urlObj = {}
              this.$set(urlObj, 'url', urlArray[i])
              fileList.push(urlObj)
            }
            this.$set(this.listSee[i], 'fileList', fileList)
            console.log(this.listSee)

            this.listSee[i].showUpload = true
          }
        }
        this.pageNumSee = response.data.pageNum
        this.pageSizeSee = response.data.pageSize
        if (response.data.total) {
          this.totalSee = response.data.total
        }
        setTimeout(() => {
          this.listLoadingSee = false
        }, 300)
      })
    },
    handleDownloadSee() {
      this.listLoadingSee = true
      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.getDownloadSeeParm.parammaps.id = this.seeTemp.id
      GetAccount(this.getDownloadSeeParm).then(response => {
        this.listSee = response.data.list
        if (response.data.list !== null) {
          this.percentage = 99
          setTimeout(() => {
            this.isPercentage = false
          }, 2000)
          for (var i = 0; i < response.data.list.length; i++) {
            const urlArray = []
            const fileList = []
            if (response.data.list[i].picpath1 == undefined && response.data.list[i].picpath2 == undefined && response.data.list[i].picpath3 == undefined) {
              urlArray.push()
            } else if (response.data.list[i].picpath1 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath2, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            } else if (response.data.list[i].picpath2 == undefined && response.data.list[i].picpath3 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1)
            } else if (response.data.list[i].picpath2 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            } else if (response.data.list[i].picpath3 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath2)
            } else {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath2, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            }
            for (let i = 0; i < urlArray.length; i++) {
              const urlObj = {}
              this.$set(urlObj, 'url', urlArray[i])
              fileList.push(urlObj)
            }
            this.$set(this.listSee[i], 'fileList', fileList)
            console.log(this.listSee)

            this.listSee[i].showUpload = true
          }
          console.log(this.listSee)
          var downloadseeArray = []
          for (let i = 0; i < this.listSee.length; i++) {
            var downloadseeObj = {}
            this.$set(downloadseeObj, 'pastureName', this.seeTemp.pastureName)
            this.$set(downloadseeObj, 'empName', this.seeTemp.empName)
            this.$set(downloadseeObj, 'batime', this.seeTemp.batime)
            this.$set(downloadseeObj, 'judgetype', this.listSee[i].judgetype)
            this.$set(downloadseeObj, 'statue', this.listSee[i].statue)
            this.$set(downloadseeObj, 'score', this.listSee[i].score)
            this.$set(downloadseeObj, 'note', this.listSee[i].note)
            this.$set(downloadseeObj, 'mypic1', process.env.VUE_APP_BASE_API + this.listSee[i].picpath1)
            this.$set(downloadseeObj, 'mypic2', process.env.VUE_APP_BASE_API + this.listSee[i].picpath2)
            this.$set(downloadseeObj, 'mypic3', process.env.VUE_APP_BASE_API + this.listSee[i].picpath3)
            downloadseeArray.push(downloadseeObj)
          }
          console.log('downloadseeArray', downloadseeArray)
          const column = [
            { title: '牧场', key: 'pastureName', type: 'text' },
            { title: '评估人', key: 'empName', type: 'text' },
            { title: '评估日期', key: 'batime', type: 'text' },
            { title: '检查类别', key: 'judgetype', type: 'text' },
            { title: '检查标准', key: 'statue', type: 'text' },
            { title: '检查结果', key: 'score', type: 'text' },
            { title: '问题描述', key: 'note', type: 'text' },
            { title: '问题图片', key: 'mypic1', type: 'image', width: 80, height: 60 },
            { title: '问题图片', key: 'mypic2', type: 'image', width: 80, height: 60 },
            { title: '问题图片', key: 'mypic3', type: 'image', width: 80, height: 60 }
          ]
          const data = downloadseeArray
          const excelName = '评估验证'
          table2excel(column, data, excelName)
        }
        setTimeout(() => {
          this.listLoadingSee = false
        }, 300)
      })
    },
    form_add() {
      console.log('点击了评估')
      this.createTemp.statue = ''
      this.createTemp.empId = this.$store.state.user.employeid
      this.createTemp.pastureId = this.$store.state.user.pastureid
      this.createTemp.batime = parseTime(new Date(), '{y}-{m}-{d}')
      this.dialogStatus = 'assessment'
      this.dialogFormVisibleAdd = true
      this.listAdd = []
      this.get_table_data2()
    },
    changeStatue(val) {
      // this.createTemp.statue = parseInt(val)
      // console.log(val)
      this.listAdd = []
      this.getdataListParmSee2.parammaps.id = val
      this.get_table_dataSee2()
      if (this.list2.find(obj => obj.id == val)) {
        console.log(this.list2.find(obj => obj.id == val).statue)
        this.judgetype = this.list2.find(obj => obj.id == val).statue
      }
      console.log(this.listAdd)
    },
    handlePicChange(file, fileList, row) {
      // console.log(response, '文件状态改变时的钩子response')
      console.log(file, '文件状态改变时的钩子file')
      console.log(fileList, '文件状态改变时的钩子fileList------------')
      console.log(row, '文件状态改变时的钩子row')
      console.log(row.showUpload, '文件状态改变时的钩子row')

      if (fileList.length > 2) {
        this.$nextTick(() => {
          this.$set(row, 'showUpload', true)
        })
      } else {
        this.$nextTick(() => {
          row.showUpload = false
        })
      }
      console.log(row)
    },
    handlePicSuccess(response, file, fileList, row) {
      // console.log(response, '文件上传成功时的钩子response')
      // console.log(file, '文件上传成功时的钩子file')
      // console.log(fileList, '文件上传成功时的钩子fileList')
      // console.log(row, '文件上传成功时的钩子row')

      // console.log(response.execresult.LastInsertId, '文件上传成功时的钩子response')
      // console.log(fileList.length, 'fileList.length')
      if (fileList.length > 2) {
        this.$nextTick(() => {
          row.showUpload = true
        })
      } else {
        this.$nextTick(() => {
          row.showUpload = false
        })
      }
      if (row.pic1 === undefined || row.pic1 == -1) {
        this.$set(row, 'pic1', response.execresult.LastInsertId)
      } else if (row.pic2 === undefined || row.pic2 == -1) {
        this.$set(row, 'pic2', response.execresult.LastInsertId)
      } else if (row.pic3 === undefined || row.pic3 == -1) {
        this.$set(row, 'pic3', response.execresult.LastInsertId)
      }
      console.log(row, '文件上传成功时的钩子row')
    },
    handlePicRemove(file, fileList, row) {
      console.log(file, '文件列表移除文件时的钩子file---')
      console.log(fileList, '文件列表移除文件时的钩子fileList--')
      console.log(row, '文件列表移除文件时的钩子row---')
      // console.log(this.dialogStatus)update
      if (this.dialogStatus === 'assessment') {
        if (fileList.length < 3) {
          this.$set(row, 'showUpload', false)
          // row.showUpload = false
        }
        for (const key in row) {
          if (row[key] === file.response.execresult.LastInsertId) {
            this.$delete(row, key)
          }
        }
      } else if (this.dialogStatus === 'update') {
        if (fileList.length < 3) {
          row.showUpload = false
        }
        const url = 'uploads' + file.url.split('uploads')[1]
        for (const key in row) {
          if (row[key] === url) {
            console.log(key)
            if (key === 'picpath1') {
              this.$delete(row, 'pic1')
            } else if (key === 'picpath2') {
              this.$delete(row, 'pic2')
            } else if (key === 'picpath3') {
              this.$delete(row, 'pic3')
            }
          }
        }
      }
      console.log(row, '文件列表移除文件时的钩子row')
    },
    handlePicPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    onLoad(e) {
      const img = e.target
      let width = 0
      if (img.fileSize > 0 || (img.width > 1 && img.height > 1)) {
        width = img.width + 40
      }
      this.width = width + 'px'
    },
    add_dialog_saveAdd() {
      console.log('点击了保存')
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['createTemp'].validate(valid => {
        if (valid) {
          for (var i = 0; i < this.listAdd.length; i++) {
            if (this.listAdd[i].score == null) {
              this.$message({
                type: 'warning',
                message: '请检查检查结果是否为空',
                duration: 2000
              })
              return false
            }
            console.log(this.listAdd[i].pic1)
            if (this.listAdd[i].pic1 == undefined) {
              this.listAdd[i].pic1 = -1
            }
            if (this.listAdd[i].pic2 == undefined) {
              this.listAdd[i].pic2 = -1
            }
            if (this.listAdd[i].pic3 == undefined) {
              this.listAdd[i].pic3 = -1
            }
          }
          this.postDataPramas.common = { 'returnmap': '0' }
          this.postDataPramas.data = []
          this.postDataPramas.data[0] = { 'name': 'insertBigjudge', 'type': 'e', 'parammaps': {
            pastureId: this.createTemp.pastureId,
            batime: this.createTemp.batime,
            empId: this.createTemp.empId
          }}
          this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
          this.postDataPramas.data[1].children = []
          this.postDataPramas.data[1].children[0] = { 'name': 'insertjudge', 'type': 'e', 'parammaps': {
            bigId: '@insertBigjudge.LastInsertId',
            judgetype: '@insertSpotList.judgetype',
            statue: '@insertSpotList.statue',
            score: '@insertSpotList.score',
            note: '@insertSpotList.note',
            pic1: '@insertSpotList.pic1',
            pic2: '@insertSpotList.pic2',
            pic3: '@insertSpotList.pic3'
          }}
          ExecDataByConfig(this.postDataPramas).then(response => {
            console.log('新增保存发送参数', this.postDataPramas)
            if (response.msg === 'fail') {
              this.$notify({
                title: '保存失败',
                message: response.data,
                type: 'warning',
                duration: 2000
              })
            } else {
              this.getdataListParm.parammaps.inputDatetime = ''
              this.get_table_data()
              this.dialogFormVisibleAdd = false
              this.createTemp.providerName = ''
              this.$notify({
                title: '',
                message: '保存成功',
                type: 'success',
                duration: 2000
              })
            }
          })
        }
      })
    },
    beforeRemove(file, fileList) {
      console.log(file.response, '删除文件之前的钩子，参数为上传的文件和文件列表')
      return this.$confirm('删除当前图片, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
    },
    form_edit(row) {
      console.log('编辑', row)
      this.dialogStatus = 'update'
      this.dialogFormVisibleAdd = true
      this.createTemp = Object.assign(row, {})
      this.get_table_dataUpdate()
      this.get_table_data2()
    },
    get_table_dataUpdate() {
      this.listLoadingAdd = true
      this.getdataListParmUpdate.parammaps.id = this.createTemp.id
      GetDataByName(this.getdataListParmUpdate).then(response => {
        this.listAdd = response.data.list
        console.log(this.listAdd, 'this,listAdd')
        if (response.data.list !== null) {
          for (let i = 0; i < response.data.list.length; i++) {
            // this.$set(this.listAdd[0].file.response.execresult.LastInsertId)
            console.log(response.data.list[i])
            const urlArray = []
            const fileList = []
            if (response.data.list[i].picpath1 == undefined && response.data.list[i].picpath2 == undefined && response.data.list[i].picpath3 == undefined) {
              urlArray.push()
            } else if (response.data.list[i].picpath1 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath2, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            } else if (response.data.list[i].picpath2 == undefined && response.data.list[i].picpath3 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1)
            } else if (response.data.list[i].picpath2 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            } else if (response.data.list[i].picpath3 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath2)
            } else {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath2, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            }
            for (let i = 0; i < urlArray.length; i++) {
              const urlObj = {}
              this.$set(urlObj, 'url', urlArray[i])
              fileList.push(urlObj)
            }
            this.$set(this.listAdd[i], 'fileList', fileList)
            console.log(this.listAdd)
            if (this.listAdd[i].fileList.length > 2) {
              this.listAdd[i].showUpload = true
            } else {
              this.listAdd[i].showUpload = false
            }
            // if (this.listAdd[i].fileList.length > 2) {
            //   this.$nextTick(() => {
            //     this.$set(this.listAdd[i], 'showUpload', false)
            //   })
            // } else {
            //   this.$nextTick(() => {
            //     this.$set(this.listAdd[i], 'showUpload', false)
            //   })
            // }
          }
        }
        // console.log(this.listAdd)
        setTimeout(() => {
          this.listLoadingAdd = false
        }, 300)
      })
    },
    edit_dialog_save() {
      console.log('点击了编辑保存', this.listAdd)
      console.log('点击了保存')
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['createTemp'].validate(valid => {
        if (valid) {
          for (var i = 0; i < this.listAdd.length; i++) {
            if (this.listAdd[i].score == null) {
              this.$message({
                type: 'warning',
                message: '请检查检查结果是否为空',
                duration: 2000
              })
              return false
            }
            console.log(this.listAdd[i].pic1)
            if (this.listAdd[i].pic1 == undefined) {
              this.listAdd[i].pic1 = -1
            }
            if (this.listAdd[i].pic2 == undefined) {
              this.listAdd[i].pic2 = -1
            }
            if (this.listAdd[i].pic3 == undefined) {
              this.listAdd[i].pic3 = -1
            }
          }
          this.postDataPramas.common = { 'returnmap': '0' }
          this.postDataPramas.data = []
          // this.postDataPramas.data[0] = { 'name': 'deletejudge', 'type': 'e', 'parammaps': {
          //   bigId: this.createTemp.id
          // }}
          this.postDataPramas.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
          this.postDataPramas.data[0].children = []
          this.postDataPramas.data[0].children[0] = { 'name': 'updatejudge', 'type': 'e', 'parammaps': {
            bigId: this.createTemp.id,
            judgetype: '@insertSpotList.judgetype',
            statue: '@insertSpotList.statue',
            score: '@insertSpotList.score',
            note: '@insertSpotList.note',
            pic1: '@insertSpotList.pic1',
            pic2: '@insertSpotList.pic2',
            pic3: '@insertSpotList.pic3',
            id: '@insertSpotList.id'
          }}
          ExecDataByConfig(this.postDataPramas).then(response => {
            console.log('新增保存发送参数', this.postDataPramas)
            if (response.msg === 'fail') {
              this.$notify({
                title: '保存失败',
                message: response.data,
                type: 'warning',
                duration: 2000
              })
            } else {
              this.getdataListParm.parammaps.inputDatetime = ''
              this.get_table_data()
              this.dialogFormVisibleAdd = false
              this.createTemp.providerName = ''
              this.$notify({
                title: '',
                message: '保存成功',
                type: 'success',
                duration: 2000
              })
            }
          })
        }
      })
    },
    form_delete(row) {
      console.log('删除')
      MessageBox.confirm('确认删除？', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.postDataPramas.common = { 'returnmap': '0' }
          this.postDataPramas.data = []
          this.postDataPramas.data[0] = { 'name': 'deleteBigjudge', 'type': 'e', 'parammaps': {
            id: row.id
          }}
          this.postDataPramas.data[1] = { 'name': 'deletejudge', 'type': 'e', 'parammaps': {
            bigId: row.id
          }}
          ExecDataByConfig(this.postDataPramas).then(response => {
            console.log('删除发送参数', this.postDataPramas)
            if (response.msg === 'fail') {
              this.$notify({
                title: '删除失败',
                message: response.data,
                type: 'warning',
                duration: 2000
              })
            } else {
              this.getdataListParm.parammaps.inputDatetime = ''
              this.get_table_data()
              this.$notify({
                title: '',
                message: '删除成功',
                type: 'success',
                duration: 2000
              })
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },

    get_table_data2() {
      this.listLoading2 = true
      // this.listLoadingAdd = true
      GetDataByName(this.getdataListParm2).then(response => {
        if (response.data.list !== null) {
          this.list2 = response.data.list
          // this.listAdd = response.data.list
          // for (var i = 0; i < this.listAdd.length; i++) {
          //   this.$set(this.listAdd[i], 'showUpload', false)
          // }
        } else {
          this.list2 = []
          // this.listAdd = []
        }
        this.pageNum2 = response.data.pageNum
        this.pageSize2 = response.data.pageSize
        if (response.data.total) {
          this.total2 = response.data.total
        }
        setTimeout(() => {
          this.listLoading2 = false
          // this.listLoadingAdd = false
        }, 300)
      })
    },


    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)

      var send_data =   {
        name: 'getjudgeListByExcel',   page: 1,  offset: 1,  pagecount: 0,
        returntype: 'Map',
        parammaps: {
          formType:'评估验证信息',
          pastureName: this.getdataListParm.parammaps.pastureName,
          judgetype:this.getdataListParm.parammaps.judgetype,
          startTime:this.getdataListParm.parammaps.startTime,
          stopTime: this.getdataListParm.parammaps.stopTime,
          empName: this.getdataListParm.parammaps.empName,

        }
      }

      GetAccount(send_data).then(response => {
        this.listSee2 = response.data.list
        if (response.data.list !== null) {
          this.percentage = 99
          setTimeout(() => {
            this.isPercentage = false
          }, 2000)
          for (var i = 0; i < response.data.list.length; i++) {
            const urlArray = []
            const fileList = []
            if (response.data.list[i].picpath1 == undefined && response.data.list[i].picpath2 == undefined && response.data.list[i].picpath3 == undefined) {
              urlArray.push()
            } else if (response.data.list[i].picpath1 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath2, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            } else if (response.data.list[i].picpath2 == undefined && response.data.list[i].picpath3 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1)
            } else if (response.data.list[i].picpath2 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            } else if (response.data.list[i].picpath3 == undefined) {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath2)
            } else {
              urlArray.push(process.env.VUE_APP_BASE_API + response.data.list[i].picpath1, process.env.VUE_APP_BASE_API + response.data.list[i].picpath2, process.env.VUE_APP_BASE_API + response.data.list[i].picpath3)
            }
            for (let i = 0; i < urlArray.length; i++) {
              const urlObj = {}
              this.$set(urlObj, 'url', urlArray[i])
              fileList.push(urlObj)
            }
            this.$set(this.listSee2[i], 'fileList', fileList)
            console.log(this.listSee2)

            this.listSee2[i].showUpload = true
          }
          console.log(this.listSee2)
          var downloadseeArray = []
          for (let i = 0; i < this.listSee2.length; i++) {
            var downloadseeObj = {}
            this.$set(downloadseeObj, 'pastureName', this.listSee2[i].pastureName)
            this.$set(downloadseeObj, 'empName', this.listSee2[i].empName)
            this.$set(downloadseeObj, 'batime', this.listSee2[i].batime)
            this.$set(downloadseeObj, 'judgetype', this.listSee2[i].judgetype)
            this.$set(downloadseeObj, 'statue', this.listSee2[i].statue)
            this.$set(downloadseeObj, 'score', this.listSee2[i].score)
            this.$set(downloadseeObj, 'note', this.listSee2[i].note)
            this.$set(downloadseeObj, 'mypic1', process.env.VUE_APP_BASE_API + this.listSee2[i].picpath1)
            this.$set(downloadseeObj, 'mypic2', process.env.VUE_APP_BASE_API + this.listSee2[i].picpath2)
            this.$set(downloadseeObj, 'mypic3', process.env.VUE_APP_BASE_API + this.listSee2[i].picpath3)
            downloadseeArray.push(downloadseeObj)
          }
          console.log('downloadseeArray', downloadseeArray)
          const column = [
            { title: '牧场', key: 'pastureName', type: 'text' },
            { title: '评估人', key: 'empName', type: 'text' },
            { title: '评估日期', key: 'batime', type: 'text' },
            { title: '检查类别', key: 'judgetype', type: 'text' },
            { title: '检查标准', key: 'statue', type: 'text' },
            { title: '检查结果', key: 'score', type: 'text' },
            { title: '问题描述', key: 'note', type: 'text' },
            { title: '问题图片', key: 'mypic1', type: 'image', width: 80, height: 60 },
            { title: '问题图片', key: 'mypic2', type: 'image', width: 80, height: 60 },
            { title: '问题图片', key: 'mypic3', type: 'image', width: 80, height: 60 }
          ]
          const data = downloadseeArray
          const excelName = '评估验证'
          table2excel(column, data, excelName)
        }

      })




    },





    handleInspectionStandard() {
      console.log('点击了检查标准管理')
      // table1隐藏/table2显示
      this.List1 = false
      this.List2 = true
      this.get_table_data2()
    },
    goBack() {
      // table1显示/table2隐藏
      this.List1 = true
      this.List2 = false
      this.get_table_data()
    },
    form_add2() {
      console.log('点击了检查标准管理-新增')
      this.createTemp.statue = ''
      this.list3 = []
      this.dialogStatus = 'create'
      this.dialogFormVisible = true
    },
    handleDownloadTemp2() {
      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'
        })
      })
    },
    beforeImportExcel2(file) {
      const isLt2M = file.size / 1024 / 1024 < 6
      if (!isLt2M) {
        this.$message.error('上传文件大小不能超过 6MB!')
      }
      return isLt2M
    },
    handleImportExcelSuccess2(res, file) {
      this.get_table_data2()
      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]
          }
        })
      )
    },
    // console.log('点击了检查标准管理-新增-添加标准')
    handleAddStandard() {
      console.log('点击了检查标准管理-新增-添加标准')
      this.list3.push({ 'myid': (new Date()).valueOf(), 'statue': '' })
    },
    form_delete3(row) {
      console.log(row)
      if (row.id !== undefined) {
        this.$set(row, 'myid', row.id)
      }
      MessageBox.confirm('确认删除？', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        for (var i = 0; i < this.list3.length; i++) {
          console.log(this.list3[i])
          if (this.list3[i].myid == row.myid) {
            var list3Index = this.list3.indexOf(this.list3[i])
          }
          if (list3Index > -1) {
            this.list3.splice(list3Index, 1)
            return
          }
        }
      })
    },
    add_dialog_save2() {
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['createTemp'].validate(valid => {
        if (valid) {
          if (this.list3.length !== 0) {
            for (let i = 0; i < this.list3.length; i++) {
              if (this.list3[i].statue == '') {
                this.$message({
                  type: 'warning',
                  message: '请检查检查标准是否未填写',
                  duration: 2000
                })
                return false
              } else {
                this.postDataParam.common = { 'returnmap': '0' }
                this.postDataParam.data = []
                this.postDataParam.data[0] = { 'name': 'inserBigAssessment', 'type': 'e', 'parammaps': {
                  'statue': this.createTemp.statue
                }}
                this.postDataParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.list3 }}
                this.postDataParam.data[1].children = []
                this.postDataParam.data[1].children[0] = { 'name': 'insertAssessment', 'type': 'e', 'parammaps': {
                  statue: '@insertSpotList.statue',
                  bigId: '@inserBigAssessment.LastInsertId'
                }}
              }
            }
            ExecDataByConfig(this.postDataParam).then(response => {
              console.log('保存发送参数', this.postDataParam)
              if (response.msg === 'fail') {
                this.$notify({
                  title: '保存失败',
                  message: response.data,
                  type: 'warning',
                  duration: 2000
                })
              } else {
                this.get_table_data2()
                this.dialogFormVisible = false
                this.$notify({
                  title: '',
                  message: '保存成功',
                  type: 'success',
                  duration: 2000
                })
              }
            })
          } else {
            this.$message({
              title: '',
              message: '请选择添加标准',
              type: 'warning',
              duration: 2000
            })
            return false
          }
        }
      })
    },
    form_see2(row) {
      this.list3 = []
      this.createTemp = Object.assign(row, {})
      this.dialogStatus = 'see'
      this.dialogFormVisible = true
      this.getdataListParmSee2.parammaps.id = row.id
      this.get_table_dataSee2()
    },
    get_table_dataSee2() {
      GetDataByName(this.getdataListParmSee2).then(response => {
        if (response.data.list !== null) {
          this.listAdd = response.data.list
          this.list3 = response.data.list
          for (var i = 0; i < this.listAdd.length; i++) {
            this.$set(this.listAdd[i], 'showUpload', false)
            this.$set(this.listAdd[i], 'judgetype', this.judgetype)
          }
        } else {
          this.list3 = []
          this.listAdd = []
        }
        setTimeout(() => {
          this.listLoading3 = false
        }, 300)
      })
    },
    form_edit2(row) {
      this.createTemp.statue = ''
      this.list3 = []
      this.createTemp = Object.assign(row, {})
      this.dialogStatus = 'update'
      this.dialogFormVisible = true
      this.getdataListParmSee2.parammaps.id = row.id
      this.get_table_dataSee2()
    },
    edit_dialog_save2() {
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['createTemp'].validate(valid => {
        if (valid) {
          if (this.list3.length !== 0) {
            for (let i = 0; i < this.list3.length; i++) {
              if (this.list3[i].statue == '') {
                this.$message({
                  type: 'warning',
                  message: '请检查检查标准是否未填写',
                  duration: 2000
                })
                return false
              } else {
                this.postDataParam.common = { 'returnmap': '0' }
                this.postDataParam.data = []
                this.postDataParam.data[0] = { 'name': 'updateBigAssessment', 'type': 'e', 'parammaps': {
                  'id': this.createTemp.id,
                  'statue': this.createTemp.statue
                }}
                this.postDataParam.data[1] = { 'name': 'deleteAssessmentListBybigid', 'type': 'e', 'parammaps': {
                  'id': this.createTemp.id
                }}
                this.postDataParam.data[2] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.list3 }}
                this.postDataParam.data[2].children = []
                this.postDataParam.data[2].children[0] = { 'name': 'insertAssessment', 'type': 'e', 'parammaps': {
                  statue: '@insertSpotList.statue',
                  bigId: this.createTemp.id
                }}
              }
            }
            ExecDataByConfig(this.postDataParam).then(response => {
              console.log('保存发送参数', this.postDataParam)
              if (response.msg === 'fail') {
                this.$notify({
                  title: '保存失败',
                  message: response.data,
                  type: 'warning',
                  duration: 2000
                })
              } else {
                this.get_table_data2()
                this.dialogFormVisible = false
                this.$notify({
                  title: '',
                  message: '保存成功',
                  type: 'success',
                  duration: 2000
                })
              }
            })
          } else {
            this.$message({
              title: '',
              message: '请选择添加标准',
              type: 'warning',
              duration: 2000
            })
            return false
          }
        }
      })
    },
    form_delete2(row) {
      console.log('检查标准管理-删除')
      MessageBox.confirm('确认删除此信息?', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.postDataParam.name = 'deleteAssessmentList'
        this.postDataParam.parammaps = {}
        this.postDataParam.parammaps.id = row.id
        PostDataByName(this.postDataParam).then(() => {
          this.get_table_data2()
          this.dialogFormVisible = false
          this.$notify({
            title: '成功',
            message: '删除成功',
            type: 'success',
            duration: 2000
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }

  }
}
</script>
<style lang="scss" scoped>
.app-btn{
  margin-bottom: 10px;
}
.title2{
  height: 50px;
  line-height: 50px;
  font:700 18px/50px '';
  .title2-l{
    float: left;
  }
  .title2-r{
    float: right;
  }
}
</style>
<style lang="scss">
#uploadPic{
  height: 70px;
}
#uploadPic .el-upload-list--picture-card .el-upload-list__item{
  width: 70px;
  height: 70px;
}
#uploadPic .el-upload--picture-card{
  width: 70px;
  height: 70px;
  line-height: 70px;
}
 #uploadPic .hide .el-upload--picture-card {
  display: none;
}
// 查看 隐藏删除
#uploadPicSee{
  height: 70px;
}
#uploadPicSee .el-upload-list--picture-card .el-upload-list__item{
  width: 70px;
  height: 70px;
}
#uploadPicSee .el-upload--picture-card{
  width: 70px;
  height: 70px;
  line-height: 70px;
}
#uploadPicSee .el-upload-list--picture-card .el-upload-list__item-actions .el-upload-list__item-delete{
  display: none;
}
</style>
