<template>
  <!-- // kd 保留了初版矿山添加、编辑的功能，隐藏了功能入口。后续需要时添加enterpriseId参数即可使用（具体是应急局直管矿山还是为其他公司编辑矿山）-->
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div>
        <el-input v-model="searchParam.code" clearable size="small" placeholder="尾矿库编号" style="width: 200px;" class="filter-item" />
        <el-input v-model="searchParam.nameLike" clearable size="small" placeholder="尾矿库名称" style="width: 200px;" class="filter-item" />
        <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="searchSubmit">搜索</el-button>
        <el-button class="filter-item" size="mini" type="warning" icon="el-icon-refresh-left" @click="searchParamReset">重置</el-button>
        <el-tooltip class="item" effect="dark" content="按当前查询条件导出" placement="top">
          <el-button :loading="exporting" class="filter-item" size="mini" type="info" plain icon="el-icon-download" @click="exportSubmit">导出</el-button>
        </el-tooltip>
      </div>
      <!-- <el-button class="filter-item" size="mini" type="primary" icon="el-icon-plus" @click="beginAdd">新增</el-button> -->
    </div>
    <!--详情窗口-->
    <el-dialog append-to-body :close-on-click-modal="true" :visible.sync="dialog1Show" :title="(editState==1?'新增':editState==2?'修改':'查看')+'尾矿库'" width="1160px">
      <el-form ref="dialog1Form" :hide-required-asterisk="!editing" :model="dialog1Data" size="mini" :rules="dialog1FormRules" label-width="220px" style="margin-right: 80px;">
        <el-divider content-position="left">基础信息</el-divider>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="尾矿库名称：" prop="name">
              <span v-show="!editing">{{ dialog1Data.name }}</span>
              <el-input v-show="editing" v-model="dialog1Data.name" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾矿库编号：" prop="code">
              <span v-show="!editing">{{ dialog1Data.code }}</span>
              <el-input v-show="editing" v-model="dialog1Data.code" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="所属行政区划：" prop="_administrativeAreaCascade">
              <span v-show="!editing">{{ dialog1Data.administrativeAreaName }}</span>
              <el-cascader v-show="editing" v-model="dialog1Data._administrativeAreaCascade" style="width: 100%;" :options="administrativeAreaList" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾矿库地址：" prop="address">
              <span v-show="!editing">{{ dialog1Data.address }}</span>
              <el-input v-show="editing" v-model="dialog1Data.address" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="尾矿库类型：" prop="dict18">
              <span v-show="!editing">{{ dialog1Data.dict18Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict18" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict18List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾矿库等级：" prop="dict19">
              <span v-show="!editing">{{ dialog1Data.dict19Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict19" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict19List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="现状等级：" prop="dict20">
              <span v-show="!editing">{{ dialog1Data.dict20Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict20" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict20List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设计服务年限：" prop="designUseYear">
              <span v-show="!editing">{{ dialog1Data.designUseYear }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.designUseYear" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="left">技术参数</el-divider>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="设计总库容（立方米）：" prop="designCapacity">
              <span v-show="!editing">{{ dialog1Data.designCapacity }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.designCapacity" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际总库容（立方米）：" prop="capacity">
              <span v-show="!editing">{{ dialog1Data.capacity }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.capacity" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="设计坝高（米）：" prop="designDamMeter">
              <span v-show="!editing">{{ dialog1Data.designDamMeter }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.designDamMeter" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际坝高（米）：" prop="damMeter">
              <span v-show="!editing">{{ dialog1Data.damMeter }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.damMeter" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="投入使用日期：" prop="productionDate">
              <span v-show="!editing">{{ dialog1Data.productionDate }}</span>
              <el-date-picker v-show="editing" v-model="dialog1Data.productionDate" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="停止使用日期：" prop="productionStopDate">
              <span v-show="!editing">{{ dialog1Data.productionStopDate }}</span>
              <el-date-picker v-show="editing" v-model="dialog1Data.productionStopDate" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="所属行业：" prop="dict21">
              <span v-show="!editing">{{ dialog1Data.dict21Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict21" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict21List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属矿种：" prop="dict22">
              <span v-show="!editing">{{ dialog1Data.dict22Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict22" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict22List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="筑坝方式：" prop="dict23">
              <span v-show="!editing">{{ dialog1Data.dict23Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict23" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict23List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="堆存方式：" prop="dict24">
              <span v-show="!editing">{{ dialog1Data.dict24Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict24" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict24List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="湿式放矿位置：" prop="dict25">
              <span v-show="!editing">{{ dialog1Data.dict25Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict25" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict25List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="上游式尾矿库筑坝方式：" prop="dict26">
              <span v-show="!editing">{{ dialog1Data.dict26Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict26" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict26List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="干式堆存方式：" prop="dict27">
              <span v-show="!editing">{{ dialog1Data.dict27Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict27" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict27List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="堆积坝已堆积标高（米）：" prop="stackMarkMeter">
              <span v-show="!editing">{{ dialog1Data.stackMarkMeter }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.stackMarkMeter" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="设计堆积坝平局外坡坡比：" prop="designOutSlopeRatio">
              <span v-show="!editing">{{ dialog1Data.designOutSlopeRatio }}</span>
              <el-input v-show="editing" v-model="dialog1Data.designOutSlopeRatio" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际堆积坝平局外坡坡比：" prop="outSlopeRatio">
              <span v-show="!editing">{{ dialog1Data.outSlopeRatio }}</span>
              <el-input v-show="editing" v-model="dialog1Data.outSlopeRatio" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="初期坝类型：" prop="dict28">
              <span v-show="!editing">{{ dialog1Data.dict28Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict28" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict28List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="初期坝坝型：" prop="dict29">
              <span v-show="!editing">{{ dialog1Data.dict29Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict29" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict29List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="目前堆积坝高（米）：" prop="stackMeter">
              <span v-show="!editing">{{ dialog1Data.stackMeter }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.stackMeter" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="安全标准化等级：" prop="dict30">
              <span v-show="!editing">{{ dialog1Data.dict30Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict30" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict30List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="left">规模信息</el-divider>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="主要负责人：" prop="liablePerson">
              <span v-show="!editing">{{ dialog1Data.liablePerson }}</span>
              <el-input v-show="editing" v-model="dialog1Data.liablePerson" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="主要负责人联系方式：" prop="liablePersonPhone">
              <span v-show="!editing">{{ dialog1Data.liablePersonPhone }}</span>
              <el-input v-show="editing" v-model="dialog1Data.liablePersonPhone" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="分管安全负责人：" prop="safetyPerson">
              <span v-show="!editing">{{ dialog1Data.safetyPerson }}</span>
              <el-input v-show="editing" v-model="dialog1Data.safetyPerson" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="分管安全负责人联系方式：" prop="safetyPersonPhone">
              <span v-show="!editing">{{ dialog1Data.safetyPersonPhone }}</span>
              <el-input v-show="editing" v-model="dialog1Data.safetyPersonPhone" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="从业人数：" prop="employeesNumber">
              <span v-show="!editing">{{ dialog1Data.employeesNumber }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.employeesNumber" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="值班电话：" prop="dutyPhone">
              <span v-show="!editing">{{ dialog1Data.dutyPhone }}</span>
              <el-input v-show="editing" v-model="dialog1Data.dutyPhone" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="工程地质条件：" prop="dict31">
              <span v-show="!editing">{{ dialog1Data.dict31Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict31" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict31List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="水文地质条件：" prop="dict32">
              <span v-show="!editing">{{ dialog1Data.dict32Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict32" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict32List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="环境地质条件：" prop="dict33">
              <span v-show="!editing">{{ dialog1Data.dict33Name }}</span>
              <el-select v-show="editing" v-model="dialog1Data.dict33" placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in dict33List" :key="item.id" :label="item.value" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="抗震设防烈度（度）：" prop="seismicIntensity">
              <span v-show="!editing">{{ dialog1Data.seismicIntensity }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.seismicIntensity" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="占地面积（平方千米）：" prop="measureArea">
              <span v-show="!editing">{{ dialog1Data.measureArea }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.measureArea" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="目前堆积坝高（平方千米）：" prop="measureWaterArea">
              <span v-show="!editing">{{ dialog1Data.measureWaterArea }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.measureWaterArea" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="堆存总尾矿量（吨）：" prop="mineNumber">
              <span v-show="!editing">{{ dialog1Data.mineNumber }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.mineNumber" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否为头顶库：" prop="hasHeadMine">
              <span v-show="!editing">
                {{ dialog1Data.hasHeadMine === true ? '是' : '' }}
                {{ dialog1Data.hasHeadMine === false ? '否' : '' }}
              </span>
              <el-radio-group v-show="editing" v-model="dialog1Data.hasHeadMine" size="mini">
                <el-radio-button :label="true">是</el-radio-button>
                <el-radio-button :label="false">否</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="尾矿设计粒度：" prop="designTailingsParticleSize">
              <span v-show="!editing">{{ dialog1Data.designTailingsParticleSize }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.designTailingsParticleSize" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾矿目前粒度：" prop="tailingsParticleSize">
              <span v-show="!editing">{{ dialog1Data.tailingsParticleSize }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.tailingsParticleSize" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="尾矿设计比重：" prop="designTailingsRatio">
              <span v-show="!editing">{{ dialog1Data.designTailingsRatio }}</span>
              <el-input v-show="editing" v-model="dialog1Data.designTailingsRatio" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾矿目前比重：" prop="tailingsRatio">
              <span v-show="!editing">{{ dialog1Data.tailingsRatio }}</span>
              <el-input v-show="editing" v-model="dialog1Data.tailingsRatio" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="尾矿设计产出比率（%）：" prop="designTailingsOutRatio">
              <span v-show="!editing">{{ dialog1Data.designTailingsOutRatio }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.designTailingsOutRatio" :precision="10" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾矿目前产出比率（%）：" prop="tailingsOutRatio">
              <span v-show="!editing">{{ dialog1Data.tailingsOutRatio }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.tailingsOutRatio" :precision="10" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="堆积坝设计上升速率（米/年）：" prop="designStackSpeed">
              <span v-show="!editing">{{ dialog1Data.designStackSpeed }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.designStackSpeed" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="堆积坝实际上升速率（米/年）：" prop="stackSpeed">
              <span v-show="!editing">{{ dialog1Data.stackSpeed }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.stackSpeed" :precision="4" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="left">其他信息</el-divider>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="下游一公里内居民人数（头顶库）：" prop="people1000Number" label-width="260px">
              <span v-show="!editing">{{ dialog1Data.people1000Number }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.people1000Number" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下游一公里内建筑物数量：" prop="building1000Number">
              <span v-show="!editing">{{ dialog1Data.building1000Number }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.building1000Number" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="下游一公里内重要设施情况：" prop="important1000Note">
              <span v-show="!editing">{{ dialog1Data.important1000Note }}</span>
              <el-input v-show="editing" v-model="dialog1Data.important1000Note" type="textarea" :rows="3" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="下游一公里内江、河湖、水库以及居民水源地情况：" prop="resources1000Note">
              <span v-show="!editing">{{ dialog1Data.resources1000Note }}</span>
              <el-input v-show="editing" v-model="dialog1Data.resources1000Note" type="textarea" :rows="3" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="是否安装在线监测系统：" prop="hasOnlineSystem" label-width="260px">
              <span v-show="!editing">
                {{ dialog1Data.hasOnlineSystem === true ? '有' : '' }}
                {{ dialog1Data.hasOnlineSystem === false ? '无' : '' }}
              </span>
              <el-radio-group v-show="editing" v-model="dialog1Data.hasOnlineSystem" size="mini">
                <el-radio-button :label="true">是</el-radio-button>
                <el-radio-button :label="false">否</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="应急预案是否备案：" prop="hasEmergencyPlanRecord" label-width="260px">
              <span v-show="!editing">
                {{ dialog1Data.hasEmergencyPlanRecord === true ? '是' : '' }}
                {{ dialog1Data.hasEmergencyPlanRecord === false ? '否' : '' }}
              </span>
              <el-radio-group v-show="editing" v-model="dialog1Data.hasEmergencyPlanRecord" size="mini">
                <el-radio-button :label="true">是</el-radio-button>
                <el-radio-button :label="false">否</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="运行状况：" prop="runState">
              <span v-for="item in mineApi.runStates()" v-show="!editing && item.key==dialog1Data.runState" :key="item.key">
                {{ item.value }}
              </span>
              <el-select v-show="editing" v-model="dialog1Data.runState" placeholder="请选择" style="width: 100%;">
                <el-option label="基建" :value="1" />
                <el-option label="生产" :value="3" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾矿库平面图：" prop="floorPlanPath">
              <el-link v-for="file in dialog1Data._fileList" :key="file.url" @click="openFile(file)">{{ file.name }}</el-link>
              <el-upload
                v-show="editing"
                class="upload-demo"
                action="/api/file/upload"
                multiple
                :headers="httpHeaders"
                :limit="1"
                :on-success="upFloorPlanSuccess"
                :on-remove="upFloorPlanRemove"
                :on-error="upFloorPlanError"
                :on-exceed="upFloorPlanExceed"
                :before-upload="upFloorPlanBefore"
                :on-preview="openFile"
                :file-list="dialog1Data._fileList"
              >
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过20M</div>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="left">位置</el-divider>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="经度：" prop="longitude">
              <span v-show="!editing">{{ dialog1Data.longitude }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.longitude" :precision="6" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="纬度：" prop="latitude">
              <span v-show="!editing">{{ dialog1Data.latitude }}</span>
              <el-input-number v-show="editing" v-model="dialog1Data.latitude" :precision="6" :controls="false" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item v-show="editing || dialog1Data.longitude && dialog1Data.latitude" label="位置地图：">
              <AMapSearchPoint :is-search="editing" :point="mapPoint" @choosePoint="choosePoint" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-show="editing" type="text" @click="dialog1Show=false">取消</el-button>
        <el-button v-show="editing" :loading="dialog1Saving" type="primary" @click="dialog1Submit">保存</el-button>
      </div>
    </el-dialog>
    <!--表格-->
    <el-table ref="table" v-loading="searching" :data="tableData" row-key="id">
      <!-- <el-table-column type="selection" width="55" /> -->
      <el-table-column :show-overflow-tooltip="true" label="编号" prop="id" width="100px" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="所属企业" prop="enterpriseName" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="尾矿库名称" prop="name" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="尾矿库编号" prop="code" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="尾矿库地址" prop="address" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="尾矿库等级" prop="dict19Name" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="运行状态" prop="runState" align="center">
        <template slot-scope="scope">
          <span v-for="item in mineApi.runStates()" v-show="item.key==scope.row.runState" :key="item.key">
            {{ item.value }}
          </span>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" label="主要负责人" prop="liablePerson" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="联系方式" prop="liablePersonPhone" align="center" />
      <el-table-column label="操作" width="200px" align="center" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" round @click="beginLook(scope.row.id)">查看</el-button>
          <!-- <el-button size="mini" round @click="beginEdit(scope.row.id)">编辑</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <el-pagination
      :page-sizes="[10, 20, 50, 100]"
      :current-page.sync="searchParam.page"
      :page-size.sync="searchParam.count"
      :total="searchResult.total"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="searchSubmit"
      @current-change="searchSubmit"
    />
  </div>
</template>

<script>
import mineApi from '@/api/kd/mine'
import dictionaryApi from '@/api/kd/dictionary'
import administrativeAreaApi from '@/api/kd/administrativeArea'
import AMapSearchPoint from '@/components/AMap/AMapSearchPoint'
import { getToken } from '@/utils/auth'
import { mapGetters } from 'vuex'
import { downloadFile } from '@/utils'

const searchParam = {// 默认搜索条件
  page: 1,
  count: 10,
  searchCount: true
}
export default {
  name: 'ETailings', // 本页面名
  components: { AMapSearchPoint },
  data() {
    return {
      httpHeaders: {
        'Authorization': getToken()
      },
      administrativeAreaList: [],
      dict18List: [],
      dict19List: [],
      dict20List: [],
      dict21List: [],
      dict22List: [],
      dict23List: [],
      dict24List: [],
      dict25List: [],
      dict26List: [],
      dict27List: [],
      dict28List: [],
      dict29List: [],
      dict30List: [],
      dict31List: [],
      dict32List: [],
      dict33List: [],
      mineApi: mineApi,
      editing: true,
      searching: false,
      exporting: false,
      searchParam: {},
      searchResult: {
        total: 0,
        results: [] // 搜索结果
      },
      dialog1Show: false,
      dialog1Saving: false,
      dialog1Data: {},
      dialog1FormRules: {
        name: [{ required: true, message: '请输入' }],
        code: [{ required: true, message: '请输入' }],
        address: [{ required: true, message: '请输入' }],
        designUseYear: [{ required: true, message: '请输入' }]
      },
      editState: 0, // （刚打开窗口时）记录了上次窗口作用；（保存编辑时）记录了当前窗口作用； 0无 1新增 2修改 3查看
      addingData: {} // 上次正在新增时的内容，下次打开dialog1窗口时记录下来
    }
  },
  computed: {
    ...mapGetters([
      'baseApi'
    ]),
    tableData() {
      // 将返回结果转换为可展示文本
      return this.searchResult.results
    },
    mapPoint() {
      if (this.dialog1Data.longitude && this.dialog1Data.latitude) {
        return [this.dialog1Data.longitude * 1, this.dialog1Data.latitude * 1]
      }
      return null
    }
  },
  mounted() {
    administrativeAreaApi.cascadeElementUI().then(response => {
      this.administrativeAreaList = response.results
    })
    const dictGroups = [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
    dictGroups.forEach(i => {
      dictionaryApi.getList({ 'groupCode': i }).then(response => {
        this['dict' + i + 'List'] = response.results
      })
    })
    this.searchParamReset()
    this.searchSubmit()
  },
  methods: {
    searchParamReset() {
      this.searchParam = JSON.parse(JSON.stringify(searchParam))
    },
    beforeDialog1Open() { // 窗口打开前的统一操作
      if (this.editState === 1) {
        this.addingData = this.dialog1Data
      }
    },
    dialog1DataInit() { // 窗口赋值dialog1Data后的data初始化操作
      this.$set(this.dialog1Data, 'longitude', this.dialog1Data.longitude)
      if (this.dialog1Data) {
        if (this.dialog1Data.administrativeAreaCode) {
          administrativeAreaApi.cascadeUpElementUI(this.dialog1Data.administrativeAreaCode).then(response => {
            this.$set(this.dialog1Data, '_administrativeAreaCascade', response.cascade)
            this.$set(this.dialog1Data, '_administrativeAreaAreaCode', response.areaCode)
          })
        }
        if (this.dialog1Data.floorPlanPath) {
          this.dialog1Data._fileList = JSON.parse(this.dialog1Data.floorPlanPath)
        }
      }
    },
    beginAdd() {
      this.beforeDialog1Open()
      this.editState = 1
      this.dialog1Data = this.addingData // 初始值：上次编辑的内容
      this.dialog1DataInit()
      this.editing = true
      this.dialog1Show = true
      this.$nextTick(() => {
        this.$refs['dialog1Form'].clearValidate()
      })
    },
    beginEdit(id) {
      this.beforeDialog1Open()
      this.editState = 2
      mineApi.getTailingsById(id).then(response => { // 初始值：从服务器查询到的内容
        this.dialog1Data = response
        this.dialog1DataInit()
        this.editing = true
        this.dialog1Show = true
        this.$nextTick(() => {
          this.$refs['dialog1Form'].clearValidate()
        })
      })
    },
    beginLook(id) {
      this.beforeDialog1Open()
      this.editState = 3
      mineApi.getTailingsById(id).then(response => { // 初始值：从服务器查询到的内容
        this.dialog1Data = response
        this.dialog1DataInit()
        this.editing = false
        this.dialog1Show = true
        this.$nextTick(() => {
          this.$refs['dialog1Form'].clearValidate()
        })
      })
    },
    searchSubmit() {
      this.searching = true
      mineApi.getTailingsPage(this.searchParam).then(response => {
        this.searchResult = response
        this.searching = false
      }).catch(() => {
        this.searching = false
      })
    },
    exportSubmit() {
      this.exporting = true
      mineApi.exportTailings(this.searchParam).then(response => {
        downloadFile(response, '尾矿库', 'xlsx')
        this.exporting = false
      }).catch(() => {
        this.exporting = false
      })
    },
    dialog1Submit() {
      this.$refs['dialog1Form'].validate(valid => {
        if (!valid) {
          this.$message.error('填写不满足要求，请检查')
          return
        } else {
          this.dialog1Saving = true
          if (this.dialog1Data._administrativeAreaCascade && this.dialog1Data._administrativeAreaCascade.length > 0) {
            this.dialog1Data.administrativeAreaCode = this.dialog1Data._administrativeAreaCascade[this.dialog1Data._administrativeAreaCascade.length - 1]
          }
          if (this.dialog1Data._fileList) {
            this.dialog1Data.floorPlanPath = JSON.stringify(this.dialog1Data._fileList)
          }
          if (this.editState === 1) { // 新增
            mineApi.addTailings(this.dialog1Data).then(() => {
              this.dialog1Saving = false
              this.$message.success('保存成功')
              this.dialog1Show = false
              this.dialog1Data = {}
              this.searchSubmit()
            }).catch(() => {
              this.dialog1Saving = false
            })
          } else if (this.editState === 2) { // 修改
            mineApi.setTailings(this.dialog1Data).then(() => {
              this.dialog1Saving = false
              this.$message.success('保存成功')
              this.dialog1Show = false
              this.dialog1Data = {}
              this.searchSubmit()
            }).catch(() => {
              this.dialog1Saving = false
            })
          } else {
            this.dialog1Saving = false
            this.$message.success('出错啦，请刷新页面重试')
          }
        }
      })
    },
    upFloorPlanSuccess(response, file, fileList) {
      if (!this.dialog1Data._fileList) {
        this.dialog1Data._fileList = []
      }
      this.dialog1Data._fileList.push({
        name: file.name,
        url: response.result
      })
    },
    upFloorPlanError() {
      this.$message.error('上传失败，请稍后再试')
    },
    upFloorPlanRemove() {
      this.$set(this.dialog1Data, '_fileList', [])
    },
    upFloorPlanBefore(file) {
      const isIMG = file.type === 'image/jpeg' || file.type === 'image/png'
      const isLtSize = file.size / 1024 / 1024 < 20
      if (!isIMG) {
        this.$message.error('上传图片只能是 JPG/JPEG/PNG 格式')
        return false
      }
      if (!isLtSize) {
        this.$message.error('上传图片大小不能超过 20MB')
        return false
      }
      return true
    },
    upFloorPlanExceed() {
      this.$message.error('您已经上传了一张图，请删除后重新上传')
    },
    openFile(file) {
      if (file.url) {
        window.open(this.baseApi + '/file' + file.url)
      } else if (file.response && file.response.result) {
        window.open(this.baseApi + '/file' + file.response.result)
      }
    },
    choosePoint(lnglat) {
      if (lnglat) {
        this.$set(this.dialog1Data, 'longitude', lnglat[0])
        this.$set(this.dialog1Data, 'latitude', lnglat[1])
      } else {
        this.$set(this.dialog1Data, 'longitude', null)
        this.$set(this.dialog1Data, 'latitude', null)
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  ::v-deep .el-input-number .el-input__inner {
    text-align: left;
  }
  ::v-deep .vue-treeselect__control,::v-deep .vue-treeselect__placeholder,::v-deep .vue-treeselect__single-value {
    height: 30px;
    line-height: 30px;
  }
</style>
