<!--
   *@description: 危险工程
   *@author: yh Fu
   *@date: 2024-01-03 14:17:43
   *@version: V1.0.5
   -->

<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="110px">
      <el-form-item label="作业基本信息" prop="basicInformation">
        <el-input
          v-model="queryParams.basicInformation"
          placeholder="请输入作业基本信息"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工程名称" prop="enginName">
        <el-input
          v-model="queryParams.enginName"
          placeholder="请输入工程名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工程地点" prop="enginAddre">
        <el-input
          v-model="queryParams.enginAddre"
          placeholder="请输入工程地点"
          clearable
          @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="['zdsz:engineeringDangerous: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="['zdsz:engineeringDangerous: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="['zdsz:engineeringDangerous:remove']"
        >删除
        </el-button>
      </el-col>
<!--      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['zdsz:engineeringDangerous:export']"
        >导出
        </el-button>
      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="engineeringDangerousList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <!--      <el-table-column label="" align="center" prop="id" v-if="true"/>-->
      <el-table-column label="作业基本信息" align="center" prop="basicInformation"/>
      <el-table-column label="工程名称" align="center" prop="enginName"/>
      <el-table-column label="工程地点" align="center" prop="enginAddre"/>
      <el-table-column label="工程时间" align="center" prop="enginTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.enginTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column label="管径" align="center" prop="pipeDiameter"/>
            <el-table-column label="管材" align="center" prop="tubularProduct"/>
            <el-table-column label="是否存在套管" align="center" prop="casingPresent"/>
            <el-table-column label="管道压力" align="center" prop="pipePressure"/>
            <el-table-column label="气源方向" align="center" prop="gasSourceDirection"/>
            <el-table-column label="作业位置" align="center" prop="taskPosition"/>
            <el-table-column label="与作业相关阀门位置" align="center" prop="valvePosition"/>
            <el-table-column label="压力报告" align="center" prop="stressReport"/>
            <el-table-column label="监理旁站记录" align="center" prop="supervision record"/>
            <el-table-column label="工作联系单" align="center" prop="workContactForm"/>
            <el-table-column label="巡线确认单" align="center" prop="linePatrolConfirmationForm"/>
            <el-table-column label="危险作业坑大小(长)" align="center" prop="hazardousWorkPitsLong"/>
            <el-table-column label="危险作业坑大小(宽)" align="center" prop="hazardousWorkPitsWide"/>
            <el-table-column label="危险作业坑大小(深)" align="center" prop="hazardousWorkPitsDeep"/>
            <el-table-column label="是否需要支护" align="center" prop="needSupport"/>
            <el-table-column label="作业坑内其他管道情况" align="center" prop="otherPipelineConditionsWorkPit"/>
            <el-table-column label="现场负责人" align="center" prop="siteHead"/>
            <el-table-column label="现场负责人电话" align="center" prop="siteHeadPhone"/>
            <el-table-column label="作业人员信息" align="center" prop="operatorInformation"/>
            <el-table-column label="检口" align="center" prop="inspectionPort"/>
            <el-table-column label="管道刷油" align="center" prop="pipelinePainting"/>
            <el-table-column label="管道支护" align="center" prop="pipelineSupport"/>
            <el-table-column label="管道防腐" align="center" prop="pipelineCorrosionProtection"/>
            <el-table-column label="砌筑阀门井" align="center" prop="masonryValveWell"/>
            <el-table-column label="保护井" align="center" prop="protectionWell"/>
            <el-table-column label="管件保护井砌筑" align="center" prop="pipeProtectionWelMasonry"/>
            <el-table-column label="回填" align="center" prop="backfill"/>
            <el-table-column label="夯实" align="center" prop="tamp"/>
            <el-table-column label="平整场地" align="center" prop="levelingTheSite"/>
            <el-table-column label="备注" align="center" prop="remark"/>-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['zdsz:engineeringDangerous:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['zdsz:engineeringDangerous:remove']"
          >删除
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="addNewPipe(scope.row)"
          >新增顶管工程
          </el-button>
<!--          <el-button
            type="text"
            icon="el-icon-edit"
            size="mini"
            @click="viewSource(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="title" :visible.sync="open" append-to-body customClass="appendElDialog">
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="作业基本信息" prop="basicInformation">
              <el-input v-model="form.basicInformation" placeholder="请填写作业基本信息" maxlength="200"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工程名称" prop="enginName">
              <el-input v-model="form.enginName" placeholder="请填写作业基本信息" maxlength="200"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工程地点" prop="enginAddre">
              <el-input v-model="form.enginAddre" placeholder="请填写工程地点" maxlength="200"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-col :span="6">
              <el-form-item label="工程时间" prop="enginTime">
                <el-date-picker
                  v-model="form.enginTime"
                  value-format="yyyy-MM-dd hh:mm:ss"
                  type="datetime"
                  placeholder="请选择工程时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="8">
            <el-form-item label="现场负责人" prop="siteHead">
              <el-input v-model="form.siteHead" placeholder="请填写现场负责人" maxlength="16"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="现场负责人电话" prop="siteHeadPhone">
              <el-input v-model="form.siteHeadPhone" placeholder="请填写现场负责人电话" maxlength="11"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="作业人员信息" prop="operatorInformation">
              <el-input v-model="form.operatorInformation" placeholder="请填写作业人员信息" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="监理旁站记录" prop="supervisionRecord">
              <el-input v-model="form.supervisionRecord" placeholder="请填写监理旁站记录" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工作联系单" prop="workContactForm">
              <el-input v-model="form.workContactForm" placeholder="请填写工作联系单" maxlength="200"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="巡线确认单" prop="linePatrolConfirmationForm">
              <el-input v-model="form.linePatrolConfirmationForm" placeholder="请填写巡线确认单" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="作业位置" prop="taskPosition">
              <el-input v-model="form.taskPosition" placeholder="请填写作业位置" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="相关阀门位置" prop="valvePosition">
              <el-input v-model="form.valvePosition" placeholder="请填写与作业相关阀门位置" maxlength="200"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="是否存在套管" prop="casingPresent">
              <el-select v-model="form.casingPresent" placeholder="请选择是否存在套管">
                <el-option
                  v-for="e in segmentedCompressionQualifiedOption"
                  :key="e.value"
                  :label="e.label"
                  :value="e.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管径" prop="pipeDiameter">
              <el-input v-model="form.pipeDiameter" placeholder="请填写管径" maxlength="200"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管材" prop="tubularProduct">
              <el-input v-model="form.tubularProduct" placeholder="请填写管材" maxlength="200"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="管道压力" prop="pipePressure">
              <el-input v-model="form.pipePressure" placeholder="请填写管道压力" maxlength="200"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="压力报告" prop="stressReport">
              <el-input v-model="form.stressReport" placeholder="请填写压力报告" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="气流方向" prop="gasSourceDirection">
              <el-input v-model="form.gasSourceDirection" placeholder="请填写气流方向" maxlength="200"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="是否需要支护" prop="casingPresent">
              <el-select v-model="form.needSupport" placeholder="请选择是否需要支护">
                <el-option
                  v-for="e in segmentedCompressionQualifiedOption"
                  :key="e.value"
                  :label="e.label"
                  :value="e.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管道支护" prop="pipelineSupport">
              <el-input v-model="form.pipelineSupport" placeholder="请填写管道支护" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检口" prop="inspectionPort">
              <el-input v-model="form.inspectionPort" placeholder="请填写检口" maxlength="200"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="管道刷油" prop="pipelinePainting">
              <el-input v-model="form.pipelinePainting" placeholder="请填写管道刷油" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管道防腐" prop="pipelineCorrosionProtection">
              <el-input v-model="form.pipelineCorrosionProtection" placeholder="请填写管道防腐" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="其他管道情况" prop="otherPipelineConditionsWorkPit">
              <el-input v-model="form.otherPipelineConditionsWorkPit" placeholder="请填写其他管道情况" maxlength="200"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="保护井" prop="protectionWell">
              <el-input v-model="form.protectionWell" placeholder="请填写保护井" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管件保护井砌筑" prop="pipeProtectionWelMasonry">
              <el-input v-model="form.pipeProtectionWelMasonry" placeholder="请填写管件保护井砌筑" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="砌筑阀门井" prop="masonryValveWell">
              <el-input v-model="form.masonryValveWell" placeholder="请填写砌筑阀门井" maxlength="200"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="作业坑(长)(米)" prop="hazardousWorkPitsLong">
              <el-input v-model="form.hazardousWorkPitsLong" placeholder="请填写危险作业坑大小(长)" maxlength="11"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="作业坑(宽)(米)" prop="hazardousWorkPitsWide">
              <el-input v-model="form.hazardousWorkPitsWide" placeholder="请填写危险作业坑大小(宽)" maxlength="11"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="作业坑(深)(米)" prop="hazardousWorkPitsDeep">
              <el-input v-model="form.hazardousWorkPitsDeep" placeholder="请填写危险作业坑大小(深)" maxlength="11"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="回填" prop="backfill">
              <el-input v-model="form.backfill" placeholder="请填写回填" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="夯实" prop="tamp">
              <el-input v-model="form.tamp" placeholder="请填写夯实" maxlength="200"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="平整场地" prop="levelingTheSite">
              <el-input v-model="form.levelingTheSite" placeholder="请填写平整场地" maxlength="200"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark" style="width: 42.7%;">
              <el-input
                v-model="form.remark"
                type="textarea"
                placeholder="请输入内容"
                class="remark_input"
                maxlength="200"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="附件" prop="" v-if="currentType==='put'">
              <ObsFileUpload ref="obsFileUpload" :file-size="100"
                             :file-type="['dwg','dwt','doc','docx','xls','xlsx','png', 'jpg', 'jpeg']" :limit="9999"
                             :value="form.pics"
              ></ObsFileUpload>
            </el-form-item>
            <el-form-item label="附件" prop="" v-if="currentType==='add'">
              <ObsFileUpload ref="obsFileUpload" :file-size="100"
                             :file-type="['dwg','dwt','doc','docx','xls','xlsx','png', 'jpg', 'jpeg']" :limit="9999"
                             :value="form.files"
              ></ObsFileUpload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 20%;">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">提交</el-button>
<!--         <el-button :loading="buttonLoading" type="primary" @click="openNode">填写节点信息</el-button>-->
<!--        <el-button :loading="buttonLoading" type="primary" @click="toNodeDetail">填写节点信息</el-button>-->
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 节点信息dialog -->
<!--    <el-dialog :visible="openNodeForm" :rules="nodesRule" title="节点信息" append-to-body customClass="appendElNodeDialog" width="70% !important">
    <el-form ref="nodeForm" :model="zEngineeringInfoBo" :rules="nodeRules" label-width="200px">
      <el-form-item label="施工时间" prop="constructTime">
        <el-date-picker
          v-model="zEngineeringInfoBo.constructTime"
          value-format="yyyy-MM-dd hh:mm:ss"
          type="datetime"
          placeholder="请选择施工时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="照片" prop="zEngiineeringPhotoBoList" style="width: 100%;">
        <ObsImageUpload ref="obsImageUpload" :limit="9999" :fileType="['png', 'jpg', 'jpeg']" :value="zEngineeringInfoBo.zEngiineeringPhotoBoList"
                        @input="getUrl"></ObsImageUpload>
      </el-form-item>
      <div style="display: flex;margin-top: 3%;">
        <div style="width: 80%;"></div>
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">提交</el-button>
        <el-button @click="nodeCancel">取 消</el-button>
      </div>
    </el-form>
    </el-dialog>-->
<!--    <enginee-node
      ref="childNode"
      @closeToSucceed="closeToSucceed"
    />-->
    <EngineePipe ref="enginPipe"/>
    <ConstructionDetails
      ref="ConstructionDetails"
      :currentCollapses="currentCollapses"
    />
  </div>
</template>

<script>
import {
  listEngineeringDangerous,
  getEngineeringDangerous,
  delEngineeringDangerous, queryEngineeringDangerous, updateEngineeringDangerous, addEngineeringDangerous,
} from "@/api/zdsz/engineeringDangerous";
import EngineeNode from "@/components/EngineeNode/index";
import data from "@/views/system/dict/data.vue";
import EngineePipe from '@/components/EngineePipe'
import ConstructionDetails from "@/components/ConstructionDetails/index.vue";
import {validPhoneMobile, checkPositiveDecimal} from "@/api/rules";



export default {
  name: "EngineeringDangerous",
  computed: {
    data() {
      return data
    }
  },
  components: {
    EngineePipe, EngineeNode, ConstructionDetails
  },
  data() {
    return {
      //备用
     // openNodeForm:false,
      //备用
      currentCollapses: [],
      nodeType: "危险作业工程",
      nodeDetailVisible: false,
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 危险工程表格数据
      engineeringDangerousList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        files: [],
        pageNum: 1,
        pageSize: 10,
        basicInformation: undefined,
        enginName: undefined,
        enginAddre: undefined,
        enginTime: undefined,
        pipeDiameter: undefined,
        tubularProduct: undefined,
        casingPresent: undefined,
        pipePressure: undefined,
        gasSourceDirection: undefined,
        taskPosition: undefined,
        valvePosition: undefined,
        stressReport: undefined,
        supervisionRecord: undefined,
        workContactForm: undefined,
        linePatrolConfirmationForm: undefined,
        hazardousWorkPitsLong: undefined,
        hazardousWorkPitsWide: undefined,
        hazardousWorkPitsDeep: undefined,
        needSupport: undefined,
        otherPipelineConditionsWorkPit: undefined,
        siteHead: undefined,
        siteHeadPhone: undefined,
        operatorInformation: undefined,
        inspectionPort: undefined,
        pipelinePainting: undefined,
        pipelineSupport: undefined,
        pipelineCorrosionProtection: undefined,
        masonryValveWell: undefined,
        protectionWell: undefined,
        pipeProtectionWelMasonry: undefined,
        backfill: undefined,
        tamp: undefined,
        levelingTheSite: undefined,
      /*  zEngineeringNodeBo: {
          type: "危险作业工程",
          zEngineeringInfoBo: {}  //节点信息
        }*/
      },
      zEngineeringInfoBo: {
        constructAddre: '',        // 施工地址
        constructPhone: '',        // 施工人电话
        constructUser: '',         // 施工人
        headName: '',              // 负责人
        headPhone: '',             // 负责人电话
        constructAccordingDrawings: '', // 是否按图纸施工
        segmentedCompressionQualified: '', // 分段打压是否合格
        selfClosingValveType: '',          // 自闭阀类型
        visitType: '',                     // 上门类型
        backfillTime: '',                  // 回填时间
        constructTime: '',                  // 施工时间
        zEngiineeringPhotoBoList: []             // 图片列表

      },
      constructAccordingDrawingsOption: [
        {
          value: '1',
          label: '是'
        },
        {
          value: '0',
          label: '否'
        }
      ],
      segmentedCompressionQualifiedOption: [
        {
          value: '1',
          label: '是'
        },
        {
          value: '0',
          label: '否'
        }
      ],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        basicInformation: [
          {required: true, message: "作业基本信息不能为空", trigger: "blur"}
        ],
        enginName: [
          {required: true, message: "工程名称不能为空", trigger: "blur"}
        ],
        enginAddre: [
          {required: true, message: "工程地点不能为空", trigger: "blur"}
        ],
        enginTime: [
          {required: true, message: "工程时间不能为空", trigger: "blur"}
        ],
        hazardousWorkPitsLong: [
          //{required: true, message: "危险作业坑大小(长)不能为空", trigger: "blur"},
          {validator: checkPositiveDecimal, trigger: 'blur'},
        ],
        hazardousWorkPitsWide: [
          //{required: true, message: "危险作业坑大小(宽)不能为空", trigger: "blur"},
          {validator: checkPositiveDecimal, trigger: 'blur'},
        ],
        hazardousWorkPitsDeep: [
          //{required: true, message: "危险作业坑大小(深)不能为空", trigger: "blur"},
          {validator: checkPositiveDecimal, trigger: 'blur'},
        ],
        siteHeadPhone: [
          // {required: true, message: "现场负责人电话不能为空", trigger: "blur"}
          {validator: validPhoneMobile, trigger: 'blur'},
        ],
        /*   pipeDiameter: [
             {required: true, message: "管径不能为空", trigger: "blur"}
           ],
           tubularProduct: [
             {required: true, message: "管材不能为空", trigger: "blur"}
           ],
           casingPresent: [
             {required: true, message: "是否存在套管不能为空", trigger: "blur"}
           ],
           pipePressure: [
             {required: true, message: "管道压力不能为空", trigger: "blur"}
           ],
           gasSourceDirection: [
             {required: true, message: "气源方向不能为空", trigger: "blur"}
           ],
           taskPosition: [
             {required: true, message: "作业位置不能为空", trigger: "blur"}
           ],
           valvePosition: [
             {required: true, message: "与作业相关阀门位置不能为空", trigger: "blur"}
           ],
           stressReport: [
             {required: true, message: "压力报告不能为空", trigger: "blur"}
           ],
           supervisionRecord: [
             {required: true, message: "监理旁站记录不能为空", trigger: "blur"}
           ],
           workContactForm: [
             {required: true, message: "工作联系单不能为空", trigger: "blur"}
           ],
           linePatrolConfirmationForm: [
             {required: true, message: "巡线确认单不能为空", trigger: "blur"}
           ],
           hazardousWorkPitsLong: [
             {required: true, message: "危险作业坑大小(长)不能为空", trigger: "blur"}
           ],
           hazardousWorkPitsWide: [
             {required: true, message: "危险作业坑大小(宽)不能为空", trigger: "blur"}
           ],
           hazardousWorkPitsDeep: [
             {required: true, message: "危险作业坑大小(深)不能为空", trigger: "blur"}
           ],
           needSupport: [
             {required: true, message: "是否需要支护不能为空", trigger: "blur"}
           ],
           otherPipelineConditionsWorkPit: [
             {required: true, message: "作业坑内其他管道情况不能为空", trigger: "blur"}
           ],
           siteHead: [
             {required: true, message: "现场负责人不能为空", trigger: "blur"}
           ],
           siteHeadPhone: [
             {required: true, message: "现场负责人电话不能为空", trigger: "blur"}
           ],
           operatorInformation: [
             {required: true, message: "作业人员信息不能为空", trigger: "blur"}
           ],
           inspectionPort: [
             {required: true, message: "检口不能为空", trigger: "blur"}
           ],
           pipelinePainting: [
             {required: true, message: "管道刷油不能为空", trigger: "blur"}
           ],
           pipelineSupport: [
             {required: true, message: "管道支护不能为空", trigger: "blur"}
           ],
           pipelineCorrosionProtection: [
             {required: true, message: "管道防腐不能为空", trigger: "blur"}
           ],
           masonryValveWell: [
             {required: true, message: "砌筑阀门井不能为空", trigger: "blur"}
           ],
           protectionWell: [
             {required: true, message: "保护井不能为空", trigger: "blur"}
           ],
           pipeProtectionWelMasonry: [
             {required: true, message: "管件保护井砌筑不能为空", trigger: "blur"}
           ],
           backfill: [
             {required: true, message: "回填不能为空", trigger: "blur"}
           ],
           tamp: [
             {required: true, message: "夯实不能为空", trigger: "blur"}
           ],
           levelingTheSite: [
             {required: true, message: "平整场地不能为空", trigger: "blur"}
           ],*/
      },
      // 节点规则校验
     /* nodeRules: {
        type: [
          {required: true, message: "节点类型不能为空", trigger: 'blur'}
        ],
        constructAddre: [
          {required: true, message: "施工地址不能为空", trigger: 'blur'}
        ],
        constructPhone: [
          {required: true, message: "施工人电话不能为空", trigger: 'blur'}
        ],
        constructUser: [
          {required: true, message: "施工人不能为空", trigger: 'blur'}
        ],
        headName: [
          {required: true, message: "负责人不能为空", trigger: 'blur'}
        ],
        headPhone: [
          {required: true, message: "负责人电话不能为空", trigger: 'blur'}
        ],

      },*/
      //备用
  /*    nodesRule:{
        zEngiineeringPhotoBoList: [
          {required: true, message: "图片不能为空", trigger: 'blur'}
        ],
        constructTime: [
          {required: true, message: "施工时间不能为空", trigger: 'blur'}
        ],
      },*/
      //备用
      currentType: null, // 组件类型 put修改 add新增
    };
  },
  created() {
    this.getList();
  },
  methods: {
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            this.form.files = this.$refs.obsFileUpload.fileList
            updateEngineeringDangerous(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          } else {
            this.form.files = this.$refs.obsFileUpload.fileList
            addEngineeringDangerous(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          }
        }
      });
    },
    //备用
   /* openNode(){
      this.$refs["form"].validate(valid => {
        if (valid){
          this.openNodeForm=true
          console.log(this.form.id)
          if (this.form.id !== undefined){
            getEngineeringDangerous(this.form.id).then((res)=>{
              console.log(res.data)
              this.zEngineeringInfoBo = res.data.zEngineeringNodeBoList[0].zEngineeringInfoBoList[0]
              this.nodeType = res.data.zEngineeringNodeBoList[0].type
            })
          }
        }

      })
    },
    nodeCancel(){
      this.resetNodeForm()
      this.openNodeForm = false
    },
    resetNodeForm(){
      this.$refs['nodeForm'].resetFields()
      this.resetForm("nodeForm");
    },

    submitForm() {
      this.$refs["nodeForm"].validate(valid => {
        if (valid) {
          if (this.form.id == null) {
            this.form.zEngineeringNodeBo = {}
            this.form.zEngineeringNodeBo.zEngineeringInfoBo = this.zEngineeringInfoBo
            this.form.zEngineeringNodeBo.type = this.nodeType
            this.form.files = this.$refs.obsFileUpload.fileList
            this.form.zEngineeringNodeBo.zEngineeringInfoBo.zEngineeringMaterialBo = []
            console.log(this.form)
            addEngineeringDangerous(this.form).then(res => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.openNodeForm = false
              this.getList();
            })
          } else {
            // 危险修改
            this.form.zEngineeringNodeBo = {}
            this.form.zEngineeringNodeBo.zEngineeringInfoBo = this.zEngineeringInfoBo
            this.form.zEngineeringNodeBo.type = this.nodeType
            this.form.files = this.$refs.obsFileUpload.fileList
            this.form.zEngineeringNodeBo.zEngineeringInfoBo.zEngineeringMaterialBo = []
            updateEngineeringDangerous(this.form).then(res => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.openNodeForm = false
              this.getList();
            })
          }
        }
      });
    },*/
    //备用
    viewSource(e) {
      this.currentId = e.id
      this.$refs.ConstructionDetails.open(_, "危险作业工程")
    },
    viewNodeSource(e) {
      // todo: 获取数据
      queryEngineeringDangerous({
        id: this.currentId
      }).then(res => {
        try {
          this.currentCollapses = res.data.zEngineeringNodeBoList[0].zEngineeringInfoBoList
        } catch (error) {
          this.currentCollapses = [];
        }
      })
    },
    closeToSucceed() {
      this.open = false;
      this.getList()
    },
    toNodeDetail() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.currentType === 'put') {
            this.form.files = this.$refs.obsFileUpload.fileList
            this.$refs.childNode.open(this.form, 37, [{name: "危险作业工程"}])
            return
          }
          if (this.currentType === 'add') {
            this.form.files = this.$refs.obsFileUpload.fileList
            this.$refs.childNode.open(this.form, 3, [{name: "危险作业工程"}])
            return
          }
        }
      })


  /*    return
      this.$refs['form'].validate(e => {
        if (e) {
          this.nodeDetailVisible = true
        }
      })*/

    },
    // 新增顶管工程
    addNewPipe(data) {
      this.$refs.enginPipe.openDialog({
        id: data.id,
        type: "危险作业工程"
      }, 'add')
    },
    getUrl(url) {
      this.zEngineeringInfoBo.zEngiineeringPhotoBoList = this.$refs.obsImageUpload.fileList ? this.$refs.obsImageUpload.fileList.map(e => e.url) : [];
    },
    /** 查询危险工程列表 */
   /* getList() {
      this.loading = true;
      listEngineeringDangerous({
        basicInformation: this.queryParams.basicInformation,
        enginName: this.queryParams.enginName,
        enginAddre: this.queryParams.enginAddre,
        params: this.queryParams
      }).then(res => {
        this.engineeringDangerousList = res.rows;
        this.total = res.total;
        this.loading = false;
      });
    },*/
    getList() {
      this.loading = true;
      listEngineeringDangerous(this.queryParams).then(response => {
        this.engineeringDangerousList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        basicInformation: undefined,
        enginName: undefined,
        enginAddre: undefined,
        enginTime: undefined,
        pipeDiameter: undefined,
        tubularProduct: undefined,
        casingPresent: undefined,
        pipePressure: undefined,
        gasSourceDirection: undefined,
        taskPosition: undefined,
        valvePosition: undefined,
        stressReport: undefined,
        supervisionRecord: undefined,
        workContactForm: undefined,
        linePatrolConfirmationForm: undefined,
        hazardousWorkPitsLong: undefined,
        hazardousWorkPitsWide: undefined,
        hazardousWorkPitsDeep: undefined,
        needSupport: undefined,
        otherPipelineConditionsWorkPit: undefined,
        siteHead: undefined,
        siteHeadPhone: undefined,
        operatorInformation: undefined,
        inspectionPort: undefined,
        pipelinePainting: undefined,
        pipelineSupport: undefined,
        pipelineCorrosionProtection: undefined,
        masonryValveWell: undefined,
        protectionWell: undefined,
        pipeProtectionWelMasonry: undefined,
        backfill: undefined,
        tamp: undefined,
        levelingTheSite: undefined,
        version: undefined,
        remark: undefined,
        delFlag: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.currentType = "add"
      this.open = true;
      this.title = "添加危险工程";

    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids
      getEngineeringDangerous(id).then(response => {
        this.loading = false;
        this.form = response.data;
        this.currentType = "put"
        this.open = true;
        this.title = "修改危险工程";
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除所选的数据项？').then(() => {
        this.loading = true;
        return delEngineeringDangerous(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('zdsz/engineeringDangerous/export', {
        ...this.queryParams
      }, `engineeringDangerous_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>


<style lang="scss" scoped>
::v-deep .appendElDialog {
  width: 70%;
  height: 80%;
  overflow: hidden;
  overflow-y: scroll;

  .el-dialog__body {
    height: 100%;
  }

  //.el-form-item {
  //  margin-bottom: 22px;
  //  width: 30%;
  //  display: inline-block;
  //}

  // .el-form-item:nth-child(2n+2){
  //   margin-left: 5%;
  // }
  .el-form-item:not(:nth-child(1):nth-child(2)) {
    margin-top: 0.5%;
  }
  .el-form-item__error{
    width: 200px;
    color: #ff4949;
    font-size: 12px;
    line-height: 1;
    padding-top: 4px;
    position: absolute;
    top: 100%;
    left: 0;
  }
  .remark_input {
    .el-textarea__inner {
      width: 238%;
      height: 190px;
    }
  }

  .otherSituation {
    width: 60%;

    .el-form-item__label {
      width: 170px;
    }

    .el-form-item__content {
      margin-left: 173px;
    }
  }

  .dialog-footer {
  }
}
</style>
