<template>
  <div class="app-container">
    <h3 class="title">同步信息</h3>
    <div class="info-box">
      <el-descriptions>
        <el-descriptions-item
          v-for="v in dataInfo"
          :label="v.label"
          :key="v.key"
          >{{ v.value }}</el-descriptions-item
        >
        <!-- <el-descriptions-item label="机构类型">一级机构</el-descriptions-item> -->
      </el-descriptions>
    </div>

    <h3 class="title">补充基础信息</h3>
    <div class="info-box">
      <el-form
        inline
        class="demo-form-inline"
        label-position="left"
        label-width="120px"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item label="机构类型">
              <el-select v-model="orgType" placeholder="机构类型">
                <el-option
                  v-for="(orgTyp, key) in orgTypes"
                  :key="key"
                  :label="orgTyp.label"
                  :value="orgTyp.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item v-if="!orgType" label="天气区域编码">
              <el-input
                v-model="weatherAreaCode"
                placeholder="天气区域编码"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item v-if="!orgType" label="营业场所面积">
              <el-input
                v-model="premisesArea"
                placeholder="营业场所面积"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              v-if="orgType"
              label="建设时间"
              prop="constructionTime"
            >
              <el-date-picker
                clearable
                v-model="constructionTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择建设时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              v-if="orgType"
              label="最近一次更新"
              prop="lastUpdateTime"
            >
              <el-date-picker
                clearable
                v-model="lastUpdateTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择更新日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item v-if="orgType" label="平台品牌">
              <el-select v-model="platformBrand" placeholder="平台品牌">
                <el-option
                  v-for="(platformB, key) in platformBrands"
                  :key="key"
                  :label="platformB.label"
                  :value="platformB.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item v-if="orgType" label="平台供应商品牌">
              <el-select
                v-model="platformSupplierBrand"
                placeholder="平台供应商品牌"
              >
                <el-option
                  v-for="(platformSupplierB, key) in platformSupplierBrands"
                  :key="key"
                  :label="platformSupplierB.label"
                  :value="platformSupplierB.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div v-if="!orgType" class="info-box">
      <!--  下拉框选择    -->
      <div>
        <el-switch
          v-model="ownership"
          active-text
          inactive-text="是否自有产权"
          :active-value="1"
          :inactive-value="0"
        ></el-switch>
        <el-switch
          style="margin-left: 50px"
          v-model="outsideArea"
          active-text
          inactive-text="是否区域外"
          :active-value="1"
          :inactive-value="0"
        ></el-switch>
      </div>
      <!--  表格   -->
      <div style="margin-top: 30px">
        <el-button
          style="margin-bottom: 20px"
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleOrgAdd"
          v-hasPermi="['system:construction:add']"
          >新增</el-button
        >
        <el-table
          border
          size="small"
          v-loading="orgloading"
          :data="constructionList"
          @selection-change="handleOrgSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="序号" align="center" prop="id" />
          <el-table-column label="标准" align="center" prop="standard" />
          <el-table-column
            label="达标日期"
            align="center"
            prop="dateOfCompliance"
            width="180"
          >
            <template slot-scope="scope">
              <span>{{ formatTime(scope.row.dateOfCompliance) }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column
            label="证书佐证"
            align="center"
            prop="certificateEvidence"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.certificateEvidence > 0">是</span>
              <span v-else>否</span>
            </template></el-table-column
          > -->
          <!-- <el-table-column label="证书" align="center" prop="certificate" />
          <el-table-column label="佐证" align="center" prop="evidence" /> -->
          <el-table-column
            v-if="false"
            label="机构id"
            align="center"
            prop="orgId"
          />
          <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="handleOrgUpdate(scope.row)"
                v-hasPermi="['system:construction:edit']"
                >查看证书</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleOrgUpdate(scope.row)"
                v-hasPermi="['system:construction:edit']"
                >修改</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleOrgDelete(scope.row)"
                v-hasPermi="['system:construction:remove']"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--   上传   -->
      <div style="margin-top: 30px">
        <el-switch
          v-model="askari"
          active-text
          inactive-text="是否有保安"
          :active-value="1"
          :inactive-value="0"
        ></el-switch>
        <div>

        </div>
        <el-row v-if="askari">
          <el-col :span="12" :xs="24">
            <p style="font-size: 12px; color: #999;">上传保安证正面</p>
            <image-upload :fileSize="2" :type="'alone'"></image-upload>

            <!--            <el-image class="zoom-image border-color-change" :src="uploadp" fit="contain" @click="triggerFileInput"></el-image>-->
            <!--            <input type="file"-->
            <!--                   ref="fileInput"-->
            <!--                   @change="handleFileChange"-->
            <!--                   style="display: none;"/>-->
          </el-col>
          <el-col :span="12">
            <p style="font-size: 12px; color: #999">上传保安证反面</p>
            <image-upload :fileSize="2" :type="'alone'"></image-upload>
            <!--            <el-image class="zoom-image border-color-change" :src="uplp" fit="contain"></el-image>-->
          </el-col>
        </el-row>
      </div>
    </div>

    <div v-if="!orgType">
      <h3 class="title">业务库设置</h3>
      <div class="info-box">
        <el-form inline label-position="left" label-width="100px">
          <el-row>
            <el-col :span="7">
              <el-form-item label="业务库类型">
                <el-select v-model="businessLibraryType" placeholder="活动区域">
                  <el-option
                    v-for="(businessLibraryTy, key) in businessLibraryTypes"
                    :key="key"
                    :label="businessLibraryTy.label"
                    :value="businessLibraryTy.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="值守方式">
                <el-radio-group v-model="dutyMode">
                  <el-radio :label="0">同楼异地值守</el-radio>
                  <el-radio :label="1">远程值守</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="业务库出入口远程控制" label-width="150">
                <el-switch
                  v-model="remoteControl"
                  active-text
                  inactive-text
                  :active-value="1"
                  :inactive-value="0"
                ></el-switch>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="info-box">
        <el-button
          style="margin-bottom: 20px"
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleBusinessAdd"
          v-hasPermi="['system:BankPhysicalDefenseConstruction:add']"
          >新增</el-button
        >
        <el-table
          border
          size="small"
          v-loading="businessloading"
          :data="BusinessPhysicalDefenseConstructionList"
          @selection-change="handleBusinessSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="序号" align="center" prop="id" />
          <el-table-column label="标准" align="center" prop="standard" />
          <el-table-column
            label="达标日期"
            align="center"
            prop="dateOfCompliance"
            width="180"
          >
            <template slot-scope="scope">
              <span>{{ formatTime(scope.row.dateOfCompliance) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="证书佐证"
            align="center"
            prop="certificateEvidence"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.certificateEvidence > 0">是</span>
              <span v-else>否</span>
            </template></el-table-column
          >
          <!-- <el-table-column label="证书" align="center" prop="certificate">
          </el-table-column>
          <el-table-column label="佐证" align="center" prop="evidence" /> -->
          <el-table-column
            v-if="false"
            label="机构id"
            align="center"
            prop="orgId"
          />
          <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="handleBusinessUpdate(scope.row)"
                v-hasPermi="['system:construction:edit']"
                >查看证书</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleBusinessUpdate(scope.row)"
                v-hasPermi="['system:BankPhysicalDefenseConstruction:edit']"
                >修改</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleBusinessDelete(scope.row)"
                v-hasPermi="['system:BankPhysicalDefenseConstruction:remove']"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>

      <h3 class="title">在行自助银行设置</h3>
      <div class="info-box">
        <el-switch
          v-model="selfServiceBank"
          active-text
          inactive-text="是否有在行自助银行"
          :active-value="1"
          :inactive-value="0"
        ></el-switch>
        <span style="margin-left: 50px">在行式大堂设备</span>
        <div style="display: inline-block; width: 200px">
          <el-input-number
            style="margin-left: 10px"
            v-model="lobbyEquipment"
            controls-position="right"
            @change="handleChange"
            :min="1"
            :max="10"
          ></el-input-number>
        </div>
        <span style="margin-left: 50px">在行式穿墙设备</span>
        <div style="display: inline-block; width: 200px">
          <el-input-number
            style="margin-left: 10px"
            v-model="wallPenetratingEquipment"
            controls-position="right"
            @change="handleChange"
            :min="1"
            :max="10"
          ></el-input-number>
        </div>
      </div>
      <div class="info-box">
        <el-button
          style="margin-bottom: 20px"
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleBankAdd"
          v-hasPermi="['system:BankPhysicalDefenseConstruction:add']"
          >新增</el-button
        >
        <el-table
          border
          size="small"
          v-loading="bankloading"
          :data="BankPhysicalDefenseConstructionList"
          @selection-change="handleBankSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="序号" align="center" prop="id" />
          <el-table-column label="标准" align="center" prop="standard" />
          <el-table-column
            label="达标日期"
            align="center"
            prop="dateOfCompliance"
            width="180"
          >
            <template slot-scope="scope">
              <span>{{ formatTime(scope.row.dateOfCompliance) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="证书佐证"
            align="center"
            prop="certificateEvidence"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.certificateEvidence > 0">是</span>
              <span v-else>否</span>
            </template></el-table-column
          >
          <!-- <el-table-column label="证书" align="center" prop="certificate" />
          <el-table-column label="佐证" align="center" prop="evidence" /> -->
          <el-table-column
            v-if="false"
            label="机构id"
            align="center"
            prop="orgId"
          />
          <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="handleBankUpdate(scope.row)"
                v-hasPermi="['system:construction:edit']"
                >查看证书</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleBankUpdate(scope.row)"
                v-hasPermi="['system:BankPhysicalDefenseConstruction:edit']"
                >修改</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleBankDelete(scope.row)"
                v-hasPermi="['system:BankPhysicalDefenseConstruction:remove']"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>

    <div style="margin-top: 50px; margin-left: 42%">
      <el-button type="primary" @click="saveExtend" size="small"
        >提交</el-button
      >
      <el-button type="primary" @click="nosaveExtend" size="small"
        >取消</el-button
      >
    </div>
    <!-- 添加或修改业务库物防建设对话框 -->
    <el-dialog
      :title="Businesstitle"
      :visible.sync="Businessopen"
      width="500px"
      append-to-body
    >
      <el-form ref="Businessform" :model="Businessform" label-width="80px">
        <el-form-item label="标准" prop="standard">
          <el-input v-model="Businessform.standard" placeholder="请输入标准" />
        </el-form-item>
        <el-form-item label="达标日期" prop="dateOfCompliance">
          <el-date-picker
            clearable
            v-model="Businessform.dateOfCompliance"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择达标日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="证书佐证" prop="certificateEvidence">
          <el-switch
            v-model="Businessform.certificateEvidence"
            active-text
            :active-value="1"
            :inactive-value="0"
          ></el-switch>
        </el-form-item>
        <el-form-item v-if="Businessform.certificateEvidence" label="证书" prop="certificate">
          <el-input
            v-if="false"
            v-model="Businessform.certificate"
            placeholder="请输入证书"
          />
          <div class="image-container" style="margin-left: 20px">
            <p style="font-size: 12px; color: #999">上传证书</p>
            <image-upload :limit="1" :fileSize="2"></image-upload>

            <!--            <el-image class="zoom-image border-color-change" :src="uploadp" fit="contain" @click="triggerFileInput"></el-image>-->
            <!--            <input type="file"-->
            <!--                   ref="fileInput"-->
            <!--                   @change="handleFileChange"-->
            <!--                   style="display: none;"/>-->
          </div>
        </el-form-item>
        <el-form-item v-if="false" label="佐证" prop="evidence">
          <el-input v-model="Businessform.evidence" placeholder="请输入佐证" />
        </el-form-item>
        <el-form-item v-if="false" label="机构id" prop="orgId">
          <el-input v-model="Businessform.orgId" placeholder="请输入机构id" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitBusinessForm">确 定</el-button>
        <el-button @click="Businesscancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改银行物防建设对话框 -->
    <el-dialog
      :title="Banktitle"
      :visible.sync="Bankopen"
      width="500px"
      append-to-body
    >
      <el-form ref="Bankform" :model="Bankform" label-width="80px">
        <el-form-item label="标准" prop="standard">
          <el-input v-model="Bankform.standard" placeholder="请输入标准" />
        </el-form-item>
        <el-form-item label="达标日期" prop="dateOfCompliance">
          <el-date-picker
            clearable
            v-model="Bankform.dateOfCompliance"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择达标日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="证书佐证" prop="certificateEvidence">
          <!-- <el-input
            v-model="Bankform.certificateEvidence"
            placeholder="请输入证书佐证"
          /> -->
          <el-switch
            v-model="Bankform.certificateEvidence"
            active-text
            :active-value="1"
            :inactive-value="0"
          ></el-switch>
        </el-form-item>
        <el-form-item v-if="Bankform.certificateEvidence" label="证书" prop="certificate">
          <el-input
            v-if="false"
            v-model="Bankform.certificate"
            placeholder="请输入证书"
          />
          <div class="image-container" style="margin-left: 20px">
            <p style="font-size: 12px; color: #999">上传证书</p>
            <image-upload :limit="1" :fileSize="2"></image-upload>

            <!--            <el-image class="zoom-image border-color-change" :src="uploadp" fit="contain" @click="triggerFileInput"></el-image>-->
            <!--            <input type="file"-->
            <!--                   ref="fileInput"-->
            <!--                   @change="handleFileChange"-->
            <!--                   style="display: none;"/>-->
          </div>
        </el-form-item>
        <el-form-item v-if="false" label="佐证" prop="evidence">
          <el-input v-model="Bankform.evidence" placeholder="请输入佐证" />
        </el-form-item>
        <el-form-item v-if="false" label="机构id" prop="orgId">
          <el-input v-model="Bankform.orgId" placeholder="请输入机构id" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitBankForm">确 定</el-button>
        <el-button @click="Bankcancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :title="orgtitle"
      :visible.sync="orgopen"
      width="500px"
      append-to-body
    >
      <el-form ref="orgform" :model="orgform" label-width="80px">
        <el-form-item label="标准" prop="standard">
          <el-input v-model="orgform.standard" placeholder="请输入标准" />
        </el-form-item>
        <el-form-item label="达标日期" prop="dateOfCompliance">
          <el-date-picker
            clearable
            v-model="orgform.dateOfCompliance"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择达标日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="证书佐证" prop="certificateEvidence">
          <el-switch
            v-model="orgform.certificateEvidence"
            active-text
            :active-value="1"
            :inactive-value="0"
          ></el-switch>
        </el-form-item>
        <el-form-item v-if="orgform.certificateEvidence" label="证书" prop="certificate">
          <el-input v-if="false"  v-model="orgform.certificate" placeholder="请输入证书" />
          <div class="image-container" style="margin-left: 20px">
            <p style="font-size: 12px; color: #999">上传证书</p>
            <image-upload :limit="1" :fileSize="2"></image-upload>
          </div>
        </el-form-item>
        <el-form-item v-if="false" label="佐证" prop="evidence">
          <el-input v-model="orgform.evidence" placeholder="请输入佐证" />
        </el-form-item>
        <el-form-item v-if="false" label="机构id" prop="orgId">
          <el-input v-model="orgform.orgId" placeholder="请输入机构id" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitOrgForm">确 定</el-button>
        <el-button @click="orgcancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import uploadpng from "@/assets/images/upload.png";
import uplpng from "@/assets/images/upl.png";
import request from "@/utils/request";
import {
  listExtend,
  getExtend,
  addExtend,
  updateExtend,
  delExtend,
  getExtendByOrgId,
  uploadFile,
} from "@/api/system/extend";
import {
  listDept,
  getDept,
  delDept,
  addDept,
  updateDept,
  listDeptExcludeChild,
} from "@/api/system/dept";

import {
  listOrgPhysicalDefenseConstruction,
  getOrgPhysicalDefenseConstruction,
  addOrgPhysicalDefenseConstruction,
  updateOrgPhysicalDefenseConstruction,
  delOrgPhysicalDefenseConstruction,
} from "@/api/system/OrgPhysicalDefenseConstruction";

export default {
  props: [],
  components: {},
  data() {
    return {
      //基础信息key
      infoKeys: [
        { label: "机构名称", key: "name" },
        { label: "机构组织类型", key: "type" },
        { label: "部门机构电话", key: "phone" },
        { label: "部门机构地址", key: "address" },
        { label: "排序号", key: "sort" },
        { label: "是否可用", key: "isLock" },
        { label: "更新时间", key: "updateTime" },
        { label: "同步时间", key: "createTime" },
      ],
      dataInfo: [],
      //机构补充信息
      extendId: null,
      orgType: 1,
      weatherAreaCode: null,
      premisesArea: null,
      ownership: null,
      outsideArea: null,
      askari: 1,
      businessLibraryType: 1,
      dutyMode: 0,
      remoteControl: null,
      selfServiceBank: null,
      lobbyEquipment: 1,
      wallPenetratingEquipment: 2,
      platformBrand: null,
      platformSupplierBrand: null,
      constructionTime: null,
      lastUpdateTime: null,
      //机构建设数据

      // 遮罩层
      orgloading: true,
      businessloading: true,
      // 选中数组
      orgids: [],
      // 选中数组
      Bankids: [],
      Businessids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 机构物防建设表格数据
      constructionList: [],
      // 银行物防建设表格数据
      BankPhysicalDefenseConstructionList: [],
      BusinessPhysicalDefenseConstructionList: [],
      // 弹出层标题
      orgtitle: "",
      Businesstitle: "",
      // 弹出层标题
      Banktitle: "",
      // 是否显示弹出层
      Bankopen: false,
      Businessopen: false,
      // 表单参数
      Bankform: {},
      Businessform: {},
      // 是否显示弹出层
      Businessopen: false,
      orgopen: false,
      // 表单参数
      orgform: {},
      //2个图片信息
      uploadp: uploadpng,
      uplp: uplpng,
      //下拉框生成信息
      orgTypes: {
        orgTyp1: { label: "营业网点", value: 0 },
        orgTyp2: { label: "监控中心", value: 1 },
      },
      businessLibraryTypes: {
        businessLibraryTyp1: { label: "1类业务库", value: 1 },
        businessLibraryTyp2: { label: "2类业务库", value: 2 },
        businessLibraryTyp3: { label: "3类业务库", value: 3 },
      },
      platformBrands: {
        platformBrand1: { label: "品牌1", value: 0 },
        platformBrand2: { label: "品牌2", value: 1 },
      },
      platformSupplierBrands: {
        platformSupplierBrand1: { label: "品牌1", value: 0 },
        platformSupplierBrand2: { label: "品牌2", value: 1 },
      },
      prop: "",
      propItem: "",

      row: "",
    };
  },
  watch: {},
  computed: {
    switchModel: {
      get() {
        return this.switchValue === 1; // 将0转换为false，1转换为true
      },
      set(value) {
        this.switchValue = value ? 1 : 0; // 将false转换为0，true转换为1
      },
    },
  },
  created() {
    this.getOrgInfo();
    this.getExtendInfo();
    this.getOrgPhysicalDefenseConstructionInfo();
    this.getBankPhysicalDefenseConstructionInfo();
    this.getBusinessPhysicalDefenseConstructionInfo();
  },
  mounted() {},
  methods: {
    request() {},
    handleChange(value) {},
    getOrgInfo() {
      getDept(this.$route.params.id).then((data) => {
        // console.log(data.data);
        if (!data.data) return;
        let res = data.data;
        this.dataInfo = this.infoKeys.map((v, i) => {
          console.log(v, res[v.key], "vvvvv");
          v.value = res[v.key];
          return v;
        });
        console.log(this.dataInfo, "info");
      });
    },

    getExtendInfo() {
      getExtendByOrgId(this.$route.params.id).then((data) => {
        console.log(data.data);
        if (data.data != null) {
          this.orgType = data.data.orgType;
          this.weatherAreaCode = data.data.weatherAreaCode;
          this.premisesArea = data.data.premisesArea;
          this.ownership = data.data.ownership;
          this.outsideArea = data.data.outsideArea;
          this.askari = data.data.askari;
          this.remoteControl = data.data.remoteControl;
          this.selfServiceBank = data.data.selfServiceBank;
          this.lobbyEquipment = data.data.lobbyEquipment;
          this.wallPenetratingEquipment = data.data.wallPenetratingEquipment;
          this.extendId = data.data.id;
        }
      });
    },
    getOrgPhysicalDefenseConstructionInfo() {
      this.orgloading = true;
      let dat = { orgId: this.$route.params.id, type: 1 };
      listOrgPhysicalDefenseConstruction(dat).then((data) => {
        console.log("机构信息获取成功");
        this.constructionList = data.rows;
        this.orgloading = false;
      });
    },
    getBankPhysicalDefenseConstructionInfo() {
      this.bankloading = true;
      let dat = { orgId: this.$route.params.id, type: 3 };
      listOrgPhysicalDefenseConstruction(dat).then((data) => {
        // console.log(data);
        this.BankPhysicalDefenseConstructionList = data.rows;
        this.bankloading = false;
      });
    },
    getBusinessPhysicalDefenseConstructionInfo() {
      this.businessloading = true;
      let dat = { orgId: this.$route.params.id, type: 2 };
      listOrgPhysicalDefenseConstruction(dat).then((data) => {
        // console.log(data);
        this.BusinessPhysicalDefenseConstructionList = data.rows;
        this.businessloading = false;
      });
    },
    // 取消按钮
    Businesscancel() {
      this.Businessopen = false;
      this.Businessreset();
    },
    // 表单重置
    Businessreset() {
      this.Businessform = {
        id: null,
        standard: null,
        dateOfCompliance: null,
        certificateEvidence: null,
        certificate: null,
        evidence: null,
        createTime: null,
        updateTime: null,
        createBy: null,
        updateBy: null,
        orgId: null,
      };
      this.resetForm("Businessform");
    },
    // 多选框选中数据
    handleBusinessSelectionChange(selection) {
      this.Businessids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleBusinessAdd() {
      this.Businessreset();
      this.Businessopen = true;
      this.Businesstitle = "添加业务库物防建设";
    },
    /** 修改按钮操作 */
    handleBusinessUpdate(row) {
      this.Businessreset();
      const id = row.id || this.Businessids;
      getOrgPhysicalDefenseConstruction(id).then((response) => {
        this.Businessform = response.data;
        this.Businessopen = true;
        this.Businesstitle = "修改业务库物防建设";
      });
    },
    /** 提交按钮 */
    submitBusinessForm() {
      this.Businessform.orgId = this.$route.params.id;
      this.$refs["Businessform"].validate((valid) => {
        if (valid) {
          this.Businessform.type = 2;
          if (this.Businessform.id != null) {
            updateOrgPhysicalDefenseConstruction(this.Businessform).then(
              (response) => {
                this.$modal.msgSuccess("修改成功");
                this.Businessopen = false;
                this.getBusinessPhysicalDefenseConstructionInfo();
              }
            );
          } else {
            addOrgPhysicalDefenseConstruction(this.Businessform).then(
              (response) => {
                this.$modal.msgSuccess("新增成功");
                this.Businessopen = false;
                this.getBusinessPhysicalDefenseConstructionInfo();
              }
            );
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleBusinessDelete(row) {
      const Businessids = row.id || this.Businessids;
      this.$modal
        .confirm(
          '是否确认删除银行物防建设编号为"' + Businessids + '"的数据项？'
        )
        .then(function () {
          return delOrgPhysicalDefenseConstruction(Businessids);
        })
        .then(() => {
          this.getBusinessPhysicalDefenseConstructionInfo();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },

    // 取消按钮
    Bankcancel() {
      this.Bankopen = false;
      this.Bankreset();
    },
    // 表单重置
    Bankreset() {
      this.Bankform = {
        id: null,
        standard: null,
        dateOfCompliance: null,
        certificateEvidence: null,
        certificate: null,
        evidence: null,
        createTime: null,
        updateTime: null,
        createBy: null,
        updateBy: null,
        orgId: null,
      };
      this.resetForm("Bankform");
    },
    // 多选框选中数据
    handleBankSelectionChange(selection) {
      this.Bankids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleBankAdd() {
      this.Bankreset();
      this.Bankopen = true;
      this.Banktitle = "添加银行物防建设";
    },
    /** 修改按钮操作 */
    handleBankUpdate(row) {
      this.Bankreset();
      const id = row.id || this.Bankids;
      getOrgPhysicalDefenseConstruction(id).then((response) => {
        this.Bankform = response.data;
        this.Bankopen = true;
        this.Banktitle = "修改银行物防建设";
      });
    },
    /** 提交按钮 */
    submitBankForm() {
      this.Bankform.orgId = this.$route.params.id;
      this.$refs["Bankform"].validate((valid) => {
        if (valid) {
          this.Bankform.type = 3;
          if (this.Bankform.id != null) {
            updateOrgPhysicalDefenseConstruction(this.Bankform).then(
              (response) => {
                this.$modal.msgSuccess("修改成功");
                this.Bankopen = false;
                this.getBankPhysicalDefenseConstructionInfo();
              }
            );
          } else {
            addOrgPhysicalDefenseConstruction(this.Bankform).then(
              (response) => {
                this.$modal.msgSuccess("新增成功");
                this.Bankopen = false;
                this.getBankPhysicalDefenseConstructionInfo();
              }
            );
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleBankDelete(row) {
      const Bankids = row.id || this.Bankids;
      this.$modal
        .confirm('是否确认删除银行物防建设编号为"' + Bankids + '"的数据项？')
        .then(function () {
          return delOrgPhysicalDefenseConstruction(Bankids);
        })
        .then(() => {
          this.getBankPhysicalDefenseConstructionInfo();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    // 表单重置
    orgreset() {
      this.orgform = {
        id: null,
        standard: null,
        dateOfCompliance: null,
        certificateEvidence: null,
        certificate: null,
        evidence: null,
        createTime: null,
        updateTime: null,
        createBy: null,
        updateBy: null,
        orgId: null,
      };
      this.resetForm("orgform");
    },
    // 取消按钮
    orgcancel() {
      this.orgopen = false;
      this.orgreset();
    },
    // 多选框选中数据
    handleOrgSelectionChange(selection) {
      this.orgids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleOrgAdd() {
      this.orgreset();
      this.orgopen = true;
      this.orgtitle = "添加机构物防建设";
    },
    /** 修改按钮操作 */
    handleOrgUpdate(row) {
      this.orgreset();
      const id = row.id || this.orgids;
      getOrgPhysicalDefenseConstruction(id).then((response) => {
        // console.log(response)
        this.orgform = response.data;
        this.orgopen = true;
        this.orgtitle = "修改机构物防建设";
      });
    },
    /** 提交按钮 */
    submitOrgForm() {
      this.orgform.orgId = this.$route.params.id;
      this.$refs["orgform"].validate((valid) => {
        if (valid) {
          this.orgform.type = 1;
          if (this.orgform.id != null) {
            updateOrgPhysicalDefenseConstruction(this.orgform).then(
              (response) => {
                this.$modal.msgSuccess("修改成功");
                this.orgopen = false;
                this.getOrgPhysicalDefenseConstructionInfo();
              }
            );
          } else {
            addOrgPhysicalDefenseConstruction(this.orgform).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.orgopen = false;
              this.getOrgPhysicalDefenseConstructionInfo();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleOrgDelete(row) {
      const orgids = row.id || this.orgids;
      this.$modal
        .confirm('是否确认删除机构物防建设编号为"' + orgids + '"的数据项？')
        .then(function () {
          return delOrgPhysicalDefenseConstruction(orgids);
        })
        .then(() => {
          this.getOrgPhysicalDefenseConstructionInfo();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    saveExtend() {
      let dat = {
        orgType: this.orgType,
        weatherAreaCode: this.weatherAreaCode,
        premisesArea: this.premisesArea,
        ownership: this.ownership ? 1 : 0,
        outsideArea: this.outsideArea ? 1 : 0,
        askari: this.askari ? 1 : 0,
        businessLibraryType: this.businessLibraryType,
        dutyMode: this.dutyMode,
        remoteControl: this.remoteControl ? 1 : 0,
        selfServiceBank: this.selfServiceBank ? 1 : 0,
        lobbyEquipment: this.lobbyEquipment,
        wallPenetratingEquipment: this.wallPenetratingEquipment,
        platformBrand: this.platformBrand,
        platformSupplierBrand: this.platformSupplierBrand,
        constructionTime: this.constructionTime,
        lastUpdateTime: this.lastUpdateTime,
        orgId: this.$route.params.id,
        id: this.extendId,
      };
      if (this.extendId) {
        updateExtend(dat).then((res) => {
          this.$modal.msgSuccess("保存成功");
          this.$router.go(-1);
        });
      } else {
        addExtend(dat).then((res) => {
          this.$modal.msgSuccess("保存成功");
          this.$router.go(-1);
        });
      }
    },
    nosaveExtend() {
      this.$router.go(-1);
    },
    triggerFileInput() {
      this.$refs.fileInput.click();
    },
    async handleFileChange(event) {
      const file = event.target.files[0];
      if (!file) return;

      // 创建 FormData 对象并添加文件
      const formData = new FormData();
      formData.append("file", file);

      // // 发送文件到您的文件上传 API
      try {
        uploadFile(formData).then((res) => {
          console.log(res);
          // this.orgform.certificateEvidence = res.data;
        });
        // 处理上传成功的逻辑
        console.log("上传成功");
      } catch (error) {
        // 处理上传失败的逻辑
        console.log("上传失败");
      }
      // try {
      //   const response = await request.post('http://localhost:9527/dev-api/file/file/upload', formData, {
      //     headers: {
      //       'Content-Type': 'multipart/form-data',
      //     },
      //   });
      //   // 处理上传成功的逻辑
      //   console.log('上传成功', response);
      // } catch (error) {
      //   // 处理上传失败的逻辑
      //   console.log('上传失败', error);
      // }
      // 重置 input 元素，以便下次选择相同文件时仍能触发 change 事件
      event.target.value = "";
    },
  },
  fillter: {},
};
</script>

<style scoped lang="scss">
.title {
  font-size: 18px;
  text-align: left;
  background: #008CD6bd;
  color: #fff;
  height: 36px;
  line-height: 36px;
  padding-left: 8px;
  margin: 0;
}
.info-box {
  margin: 30px;
}
.demo-form-inline {
}
.dialog-footer {
}
.container {
}
.zoom-image {
  transition: transform 0.3s ease;
}

.zoom-image:hover {
  transform: scale(1.02);
}
.border-color-change {
  border: 1px solid #ccc;
  transition: border-color 0.3s ease;
}

.border-color-change:hover {
  border-color: #1ea8e9; /* 您可以将此颜色更改为所需的颜色 */
}
</style>
