<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="隐患名称" prop="hiddenTroubleName">
        <el-input
          v-model="queryParams.hiddenTroubleName"
          placeholder="请输入隐患名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="上报人" prop="reportPerson">
        <el-input
          v-model="queryParams.reportPerson"
          placeholder="请输入上报人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:info:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:info:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:info:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
		  :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['system:info:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="隐患名称" align="center" prop="hiddenTroubleName" >
        <span slot-scope="scope" v-if="scope.row.hiddenTroubleName">{{scope.row.hiddenTroubleName}}</span>
        <span v-else>-</span>
      </el-table-column>
      <el-table-column label="隐患等级" align="center" prop="hiddenTroubleLevel">
        <template slot-scope="scope">
          <span v-if="scope.row.hiddenTroubleLevel == 1">I级</span>
          <span v-if="scope.row.hiddenTroubleLevel == 2">II级</span>
          <span v-if="scope.row.hiddenTroubleLevel == 3">III级</span>
        </template>
      </el-table-column>
      <el-table-column label="隐患类型" align="center" prop="hiddenTroubleType">
        <template slot-scope="scope">
          <span v-if="scope.row.hiddenTroubleType == 1">漏气</span>
          <span v-if="scope.row.hiddenTroubleType == 2">腐蚀</span>
          <span v-if="scope.row.hiddenTroubleType == 3">裂缝</span>
          <span v-if="scope.row.hiddenTroubleType == 4">设备故障</span>
          <span v-if="scope.row.hiddenTroubleType == 5">安全距离不足</span>
          <span v-if="scope.row.hiddenTroubleType == 6">管道承重</span>
          <span v-if="scope.row.hiddenTroubleType == 7">其他</span>
        </template>

      </el-table-column>
<!--      <el-table-column label="经度" align="center" prop="longitude" />-->
<!--      <el-table-column label="纬度" align="center" prop="latitude" />-->
      <el-table-column label="隐患描述" align="center" prop="hiddenTroubleDescribe" >
        <span slot-scope="scope" v-if="scope.row.hiddenTroubleDescribe">{{scope.row.hiddenTroubleDescribe}}</span>
        <span v-else>-</span>
      </el-table-column>
      <el-table-column label="照片" align="center"  >
        <template scope="List">
          <img  :src="List.row.pictureUrl" width="100px">
        </template>
      </el-table-column>
      <el-table-column label="上报时间" align="center" prop="reportTime" width="180">
        <template slot-scope="scope" >
          <span v-if="scope.row.reportTime">{{scope.row.reportTime}}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column label="上报人" align="center" prop="reportPerson" >
        <span slot-scope="scope" v-if="scope.row.reportPerson">{{scope.row.reportPerson}}</span>
        <span v-else>-</span>
      </el-table-column>
      <el-table-column label="隐患处理状态" align="center" prop="hiddenTroubleDealStatus">
        <template slot-scope="scope">
          <span v-if="scope.row.hiddenTroubleDealStatus == 1" style="color: #ff7272">待处理</span>
          <span v-if="scope.row.hiddenTroubleDealStatus == 2" style="color: #ffba00">处理中</span>
          <span v-if="scope.row.hiddenTroubleDealStatus == 3" style="color: #30B46B">已完成</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="隐患处理情况" align="center" prop="hiddenTroubleDealCondition" >-->
<!--        <span slot-scope="scope" v-if="scope.row.hiddenTroubleDealCondition">{{scope.row.hiddenTroubleDealCondition}}</span>-->
<!--        <span v-else>-</span>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="隐患处理完成时间" align="center" prop="hiddenTroubleDealFinishTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span v-if="scope.row.hiddenTroubleDealFinishTime">{{ parseTime(scope.row.hiddenTroubleDealFinishTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>-->
<!--          <span v-else>-</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="备注" align="center" prop="remarks" >-->
<!--        <span slot-scope="scope" v-if="scope.row.remarks">{{scope.row.remarks}}</span>-->
<!--        <span v-else>-</span>-->
<!--      </el-table-column>-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-if="scope.row.hiddenTroubleDealStatus == 3"
                     size="mini"
                     type="text"
                     icon="el-icon-edit"
                     @click="details(scope.row)"
          >详情</el-button>
          <el-button v-if="scope.row.hiddenTroubleDealStatus != 3"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:info:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:info:remove']"
          >删除</el-button>
          <el-button v-if="scope.row.hiddenTroubleDealStatus != 3"
            size="mini"
            type="text"
            icon="el-icon-news"
            @click="handlingHiddenDangers(scope.row)"
          >处理隐患</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 处理隐患对话框 -->
    <el-dialog :title="hiddenDangertitle" :visible.sync="hiddenDanger"  width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="hiddenDangerRules" label-width="140px">

        <el-row>
          <el-col :span="11">
            <el-form-item label="隐患处理状态"  prop="hiddenTroubleDealStatus">
              <el-select v-model="form.hiddenTroubleDealStatus" placeholder="请选择隐患处理状态" style="width: 100%;">
<!--                <el-option label="待处理" value="1" />-->
                <el-option label="处理中" value="2" />
                <el-option label="已完成" value="3" />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="11" >
            <el-form-item label="隐患处理完成时间" v-if="form.hiddenTroubleDealStatus==3" prop="hiddenTroubleDealFinishTime">
              <el-date-picker clearable size="small"
                              v-model="form.hiddenTroubleDealFinishTime"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="选择隐患处理完成时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="22">
            <el-form-item label="隐患处理情况" v-if="form.hiddenTroubleDealStatus==3"  prop="hiddenTroubleDealCondition">
              <el-input v-model="form.hiddenTroubleDealCondition" type="textarea" placeholder="请输入隐患处理情况" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormHiddenDanger">确 定</el-button>
        <el-button @click="hiddenDangerCancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 燃气隐患详情对话框 -->
    <el-dialog :title="detailsTitle" :visible.sync="detailsOpen"  width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="hiddenDangerRules" label-width="150px">

        <el-row>
          <el-col :span="22">
            <el-form-item label="隐患名称" prop="hiddenTroubleName">
              <el-input v-model="form.hiddenTroubleName" placeholder="请输入隐患名称" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="11">
            <el-form-item label="隐患等级" prop="hiddenTroubleLevel">
              <el-select v-model="form.hiddenTroubleLevel" placeholder="请选择隐患等级" style="width: 100%;":disabled="true">
                <el-option label="I级" value="1" />
                <el-option label="II级" value="2" />
                <el-option label="III级" value="3" />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="11">
            <el-form-item label="隐患类型" prop="hiddenTroubleType">
              <el-select v-model="form.hiddenTroubleType" placeholder="请选择隐患类型" style="width: 100%;":disabled="true">
                <el-option label="漏气" value="1" />
                <el-option label="腐蚀" value="2" />
                <el-option label="裂缝" value="3" />
                <el-option label="设备故障" value="4" />
                <el-option label="安全距离不足" value="5" />
                <el-option label="管道承重" value="6" />
                <el-option label="其他" value="7" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="22">
            <el-form-item label="隐患描述" prop="hiddenTroubleDescribe">
              <el-input v-model="form.hiddenTroubleDescribe" type="textarea" placeholder="请输入隐患描述" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="25">
            <el-form-item label="经纬度坐标" prop="longitude" :disabled="true">
              <el-col :span="9">
                <el-input v-model="form.longitude" placeholder="请输入经度" :disabled="true"/>
              </el-col>
              <el-col :span="9" style="margin-left: 13px">
                <el-input v-model="form.latitude" placeholder="请输入纬度" :disabled="true"/>
              </el-col>
              <el-col :span="4" style="margin-left: 30px">
                <el-button type="primary" plain @click="MapdialogFun" :disabled="true">选择经纬度</el-button>
              </el-col>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="23">
            <el-form-item label="上传照片" :disabled="true">
              <FileUpload
                :disabled="true"
                listType="picture"
                @resFun="getFileInfo"
                @remove="listRemove"
                :fileArr="fileList">
              </FileUpload>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="11">
            <el-form-item label="隐患处理状态"  prop="hiddenTroubleDealStatus">
              <el-select v-model="form.hiddenTroubleDealStatus" placeholder="请选择隐患处理状态" :disabled="true">
                <el-option label="待处理" value="1" />
                <el-option label="处理中" value="2" />
                <el-option label="已完成" value="3" />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="11">
            <el-form-item label="隐患处理完成时间" v-if="form.hiddenTroubleDealStatus==3" prop="hiddenTroubleDealFinishTime">
              <el-date-picker clearable size="small" :disabled="true"
                              v-model="form.hiddenTroubleDealFinishTime"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="选择隐患处理完成时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="22">
            <el-form-item label="隐患处理情况" v-if="form.hiddenTroubleDealStatus==3" prop="hiddenTroubleDealCondition" >
              <el-input v-model="form.hiddenTroubleDealCondition" type="textarea" placeholder="请输入隐患处理情况" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>

<!--        <el-row>-->
<!--          <el-col :span="22">-->
<!--            <el-form-item label="备注" prop="remarks">-->
<!--              <el-input v-model="form.remarks" type="textarea" placeholder="请输入备注" />-->
<!--            </el-form-item>-->
<!--          </el-col>-->
<!--        </el-row>-->

      </el-form>


      <div slot="footer" class="dialog-footer">
        <el-button @click="detailsCancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 添加或修改燃气隐患对话框 -->
    <el-dialog :title="title" :visible.sync="open"  width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">

        <el-row>
          <el-col :span="22">
            <el-form-item label="隐患名称" prop="hiddenTroubleName">
              <el-input v-model="form.hiddenTroubleName" placeholder="请输入隐患名称" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="11">
            <el-form-item label="隐患等级" prop="hiddenTroubleLevel">
              <el-select v-model="form.hiddenTroubleLevel" placeholder="请选择隐患等级" style="width: 100%;">
                <el-option label="I级" value="1" />
                <el-option label="II级" value="2" />
                <el-option label="III级" value="3" />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="11">
            <el-form-item label="隐患类型" prop="hiddenTroubleType">
              <el-select v-model="form.hiddenTroubleType" placeholder="请选择隐患类型" style="width: 100%;">
                <el-option label="漏气" value="1" />
                <el-option label="腐蚀" value="2" />
                <el-option label="裂缝" value="3" />
                <el-option label="设备故障" value="4" />
                <el-option label="安全距离不足" value="5" />
                <el-option label="管道承重" value="6" />
                <el-option label="其他" value="7" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="22">
            <el-form-item label="隐患描述" prop="hiddenTroubleDescribe">
              <el-input v-model="form.hiddenTroubleDescribe" type="textarea" placeholder="请输入隐患描述" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="25">
            <el-form-item label="经纬度坐标" prop="longitude">
              <el-col :span="9">
                <el-input v-model="form.longitude" placeholder="请输入经度" />
              </el-col>
              <el-col :span="9" style="margin-left: 13px">
                <el-input v-model="form.latitude" placeholder="请输入纬度"/>
              </el-col>
              <el-col :span="4" style="margin-left: 30px">
                <el-button type="primary" plain @click="MapdialogFun">选择经纬度</el-button>
              </el-col>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="23">
            <el-form-item label="上传照片">
              <FileUpload
                listType="picture"
                @resFun="getFileInfo"
                @remove="listRemove"
                :fileArr="fileList">
              </FileUpload>
            </el-form-item>
          </el-col>
        </el-row>

        <!--        <el-row>-->
        <!--          <el-col :span="11">-->
        <!--           <el-form-item label="上报时间" prop="reportTime">-->
        <!--            <el-date-picker clearable size="small"-->
        <!--            v-model="form.reportTime"-->
        <!--            type="date"-->
        <!--            value-format="yyyy-MM-dd"-->
        <!--            placeholder="选择上报时间">-->
        <!--            </el-date-picker>-->
        <!--           </el-form-item>-->
        <!--          </el-col>-->

        <!--          <el-col :span="11">-->
        <!--        <el-form-item label="上报人" prop="reportPerson">-->
        <!--          <el-input v-model="form.reportPerson" placeholder="请输入上报人" />-->
        <!--        </el-form-item>-->
        <!--          </el-col>-->
        <!--        </el-row>-->

        <el-row>
          <el-col :span="11">
            <el-form-item label="隐患处理状态"  prop="hiddenTroubleDealStatus">
              <el-select v-model="form.hiddenTroubleDealStatus" placeholder="请选择隐患处理状态" style="width: 100%;":disabled="true">
                <el-option label="待处理" value="1" />
                <el-option label="处理中" value="2" />
                <el-option label="已完成" value="3" />
              </el-select>
            </el-form-item>
          </el-col>

          <!--          <el-col :span="11">-->
          <!--            <el-form-item label="隐患处理完成时间" v-if="form.hiddenTroubleDealStatus==3" prop="hiddenTroubleDealFinishTime">-->
          <!--              <el-date-picker clearable size="small"-->
          <!--                              v-model="form.hiddenTroubleDealFinishTime"-->
          <!--                              type="datetime"-->
          <!--                              value-format="yyyy-MM-dd HH:mm:ss"-->
          <!--                              placeholder="选择隐患处理完成时间">-->
          <!--              </el-date-picker>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
        </el-row>

        <!--        <el-row>-->
        <!--          <el-col :span="22">-->
        <!--            <el-form-item label="隐患处理情况" v-if="form.hiddenTroubleDealStatus==3" prop="hiddenTroubleDealCondition">-->
        <!--              <el-input v-model="form.hiddenTroubleDealCondition" type="textarea" placeholder="请输入隐患处理情况" />-->
        <!--            </el-form-item>-->
        <!--          </el-col>-->
        <!--        </el-row>-->

        <!--        <el-row>-->
        <!--          <el-col :span="22">-->
        <!--            <el-form-item label="备注" prop="remarks">-->
        <!--              <el-input v-model="form.remarks" type="textarea" placeholder="请输入备注" />-->
        <!--            </el-form-item>-->
        <!--          </el-col>-->
        <!--        </el-row>-->

      </el-form>


      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <GetPos
      :dialogVisible.sync="dialogTableVisibles"
      device=""
      :devicePos="devicePos"
      @close="dialogcancelFun"
      @getPath="getPath"
    />
  </div>
</template>

<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo } from "@/api/system/info";
import GetPos from '@/components/GetPos';
import FileUpload from '@/components/FileSuperviseUpload';
export default {
  name: "Info",
  components: {
    FileUpload,
    GetPos,
  },
  data() {
    return {
      //头像
      fileList: [],
      /**--------------地图使用数据---------------*/
      dialogTableVisibles: false,
      devicePos: [],
      /**--------------地图使用数据---------------*/
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 燃气隐患表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      //处理隐患弹出层标题
      hiddenDangertitle:"",
      //详情弹出层标题
      detailsTitle:"",
      // 是否显示弹出层
      open: false,
      // 是否显示处理隐患弹出层
      hiddenDanger:false,
      //详情弹出层
      detailsOpen:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        hiddenTroubleName: null,
        reportPerson: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        hiddenTroubleLevel: [
          { required: true, message: "请选择隐患等级", trigger: "blur" },
        ],
        hiddenTroubleName: [
          { required: true, message: "请输入隐患名称", trigger: "blur" },
        ],
        hiddenTroubleType: [
          { required: true, message: "请选择隐患类型", trigger: "blur" },
        ],
      },
      //隐患处理表单效验
      hiddenDangerRules: {
        hiddenTroubleDealFinishTime: [
          { required: true, message: "请选择隐患处理完成时间", trigger: "blur" },
        ],
        hiddenTroubleDealCondition: [
          { required: true, message: "请输入隐患处理情况", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /**上传头像*/
    getFileInfo(res){
      this.form.dealPlan = res.fileName;
      this.form.pictureUrl = res.url;
      this.form.burl=res.burl;
      this.fileList.push({
        name: res.fileName,
        url: uploadfile,
        burl:res.burl,
      });
    },
    listRemove(e) {
      this.form.dealPlan = "";
      this.fileList = [];
    },
    /**
     * 经纬度 选择
     * @param res
     */
    getPath(res){
      //确认选择经纬度
      this.form.longitude = res[0];
      this.form.latitude = res[1];
    },
    /**
     * 地图关闭方法
     */
    dialogcancelFun() {
      this.dialogTableVisibles = false;
    },
    /**
     * 经纬度坐标方法
     */
    MapdialogFun() {
      this.dialogTableVisibles = true;
    },
    /**
     * 经纬度 选择
     * @param res
     */
    getPath(res){
      //确认选择经纬度
      this.form.longitude = res[0];
      this.form.latitude = res[1];
    },

    /** 查询燃气隐患列表 */
    getList() {
      this.loading = true;
      listInfo(this.queryParams).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
      this.fileList = [];
    },
    //详情燃气框关闭
    detailsCancel(){
      this.detailsOpen = false;
      this.reset();
      this.fileList = [];
    },
    // 处理隐患表单取消按钮
    hiddenDangerCancel() {
     this.hiddenDanger=false;
      this.reset();
      this.fileList = [];
    },
    // 表单重置
    reset() {
      this.form = {
        hiddenTroubleId: null,
        workId: null,
        hiddenTroubleName: null,
        hiddenTroubleLevel: null,
        hiddenTroubleType: null,
        longitude: null,
        latitude: null,
        pictureUrl: null,
        hiddenTroubleDescribe: null,
        reportTime: null,
        reportPerson: null,
        hiddenTroubleDealStatus: '1',
        hiddenTroubleDealCondition: null,
        hiddenTroubleDealFinishTime: null,
        isDel: null,
        remarks: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.hiddenTroubleId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加隐患信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.fileList=[]
      this.reset();
      const hiddenTroubleId = row.hiddenTroubleId || this.ids
      getInfo(hiddenTroubleId).then(response => {
        this.form = response.data;
        this.open = true;
        //图片回显
        if (this.form.pictureUrl) {
          this.fileList.push({
            name: '照片',
            url: this.form.pictureUrl,
          });
        }
        this.title = "修改燃气隐患";
        this.devicePos = [response.data.longitude, response.data.latitude];
      });
    },
    /**处理隐患按钮操作*/
    handlingHiddenDangers(row){
      const hiddenTroubleId = row.hiddenTroubleId || this.ids
      getInfo(hiddenTroubleId).then(response => {
        this.form = response.data;
        this.form.hiddenTroubleDealStatus='2';
        this.hiddenDanger=true;
        this.hiddenDangertitle = "处理隐患信息";
      });
    },
    /**详情按钮操作*/
    details(row){
      this.fileList=[]
      this.reset();
      const hiddenTroubleId = row.hiddenTroubleId || this.ids
      getInfo(hiddenTroubleId).then(response => {
        this.form = response.data;
        this.detailsOpen = true;
        //图片回显
        if (this.form.pictureUrl) {
          this.fileList.push({
            name: '照片',
            url: this.form.pictureUrl,
          });
        }
        this.detailsTitle = "燃气隐患详情";
        this.devicePos = [response.data.longitude, response.data.latitude];
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.hiddenTroubleId != null) {
            updateInfo(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            this.form.hiddenTroubleDealStatus='1'
            addInfo(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /**处理隐患提交按钮*/
    submitFormHiddenDanger(){
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.hiddenTroubleId != null) {
            // this.form.hiddenTroubleDealStatus = '3';
            updateInfo(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.hiddenDanger = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const hiddenTroubleIds = row.hiddenTroubleId || this.ids;
      this.$confirm('是否确认删除隐患名称为"' + row.hiddenTroubleName + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delInfo(hiddenTroubleIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有燃气隐患数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportInfo(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
