<template>
  <div class="agencyinfo">
    <el-form
      ref="formData"
      :model="formData"
      :rules="rules"
      label-width="130px"
    >
      <div style="z-index: 999; position: relative">
        <el-button
          type="primary"
          @click="submit"
          class="float-r"
          v-if="isShowSubmit"
          >提交</el-button
        >
        <el-button
          type="primary"
          @click="publishProxyService"
          class="float-r mr-15"
          v-if="currentRow.id"
          >发布</el-button
        >
        <!-- <el-button type="primary" @click="versionBackup" class="float-r mr-15" v-if="currentRow.id">恢复</el-button>
        <el-button type="primary" @click="versionBackups" class="float-r mr-15" v-if="currentRow.id">恢复并激活</el-button> -->
        <!-- <el-button type="primary" @click="debugs" class="float-r mr-15" v-if="currentRow.id">debug</el-button> -->
        <!-- <el-button type="primary" @click="isshowdepend" class="float-r mr-15" v-if="currentRow.id">依赖检测</el-button> -->
      </div>
      <!-- 信息tab页 -->
      <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
        <el-tab-pane label="一般信息" name="first">
          <div class="formGroup">
            <el-row :gutter="20">
              <el-col :span="20">
                <el-form-item label="名称：" prop="name">
                  <el-input v-model="formData.name"></el-input>
                </el-form-item>
                <el-form-item label="说明：">
                  <el-input
                    type="textarea"
                    v-model="formData.description"
                  ></el-input>
                </el-form-item>
                <el-form-item label="目标：" prop="targetService.name">
                  <el-input
                    v-model="formData.targetService.name"
                    suffix-icon="el-icon-search"
                    @click.native="chooseTarget"
                    readonly
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="分组：" prop="domainName">
                  <el-input
                    v-model="formData.domainName"
                    suffix-icon="el-icon-search"
                    @click.native="areaDialog = true"
                    readonly
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="最终服务地址：">
                  <p>
                    {{
                      formData.callingAddress ? formData.callingAddress[0] : ''
                    }}
                  </p>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-tab-pane>
        <el-tab-pane label="消息定义" name="second">
          <div class="formGroup">
            <el-row :gutter="20">
              <el-col :span="20">
                <el-form-item label="消息类型：" prop="messageType">
                  <el-select
                    v-model="formData.messageType"
                    clearable
                    placeholder="请选择"
                    @change="messageTypeChange"
                    style="width: 100%"
                  >
                    <el-option
                      v-for="item in messageList"
                      :key="item.name"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="报文格式："
                  prop="payloadType"
                  v-if="formData.messageType"
                >
                  <el-radio-group
                    v-model="formData.payloadType"
                    @change="payloadTypeChange"
                  >
                    <el-radio
                      v-for="item in payloadTypeList"
                      :label="item.value"
                      :key="item.value"
                      v-show="item.isShow"
                    >
                      {{ item.name }}
                    </el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item
                  label="定义文件类型："
                  prop="defineFileType"
                  v-if="formData.messageType"
                >
                  <el-select
                    v-model="formData.defineFileType"
                    disabled
                    placeholder="请选择"
                    style="width: 100%"
                  >
                    <el-option
                      v-for="item in defineFileTypeList"
                      :key="item.name"
                      :label="item.name"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="请求报文："
                  prop="defineFile"
                  v-if="formData.defineFileType"
                >
                  <span v-if="formData.objname || formData.defineFileInfo">{{
                    formData.objname || formData.defineFileInfo.name
                  }}</span>
                  <span v-else style="color: #d3d3d3">选择请求报文</span>
                  <el-button
                    @click="chooseDefineFile"
                    type="primary"
                    style="margin-left: 60px"
                    >选择文件</el-button
                  >
                </el-form-item>
                <!-- 选择是xml展示的 -->
                <!-- <el-form-item v-if="formData.payloadType === 'xml'">
                  <div>
                    <el-button v-for="(item, index) in typeList" :key="index" @click="changgeType(item)">{{ item.type }}</el-button>
                  </div>
                 <div>字段名</div>
                 <el-tree :data="fileList1" :props="defaultProps" @node-click="handleNodeClick">
                   <div style="margin-top:5px;display: flex;width: 100%;justify-content: space-between;" slot-scope="{ node, data }">
                     <div>{{ data.name }}</div>
                   </div>
                 </el-tree>
               </el-form-item> -->
                <!-- // 选择是json是展示的 -->
                <!-- <el-form-item v-if="fileList1.length > 0 && formData.payloadType === 'json'">
                  <div>字段名</div>
                  <el-tree :data="fileList1" :props="defaultProps" @node-click="handleNodeClick">
                    <div style="margin-top:5px;display: flex;width: 100%;justify-content: space-between;" slot-scope="{ node, data }">
                      <div>{{ data.name }}</div>
                    </div>
                  </el-tree>
                </el-form-item> -->
                <!--                <el-form-item label="定义文件类型2：" prop="secondDefineFileType"  v-if="formData.messageType " >-->
                <!--                  <el-select v-model="formData.secondDefineFileType" disabled placeholder="请选择" style="width: 100%;">-->
                <!--                    <el-option v-for="item in defineFileTypeList" :key="item.name" :label="item.name" :value="item.value">-->
                <!--                    </el-option>-->
                <!--                  </el-select>-->
                <!--                </el-form-item>-->
                <el-form-item
                  label="响应报文："
                  prop="secondDefineFile"
                  v-if="formData.defineFileType === 'jsd'"
                >
                  <!-- <el-input v-model="formData.objname1" suffix-icon="el-icon-search" @focus="chooseDefineFile2"> -->
                  <span
                    v-if="formData.objname1 || formData.secondDefineFileInfo"
                    >{{
                      formData.objname1 || formData.secondDefineFileInfo.name
                    }}</span
                  >
                  <span v-else style="color: #d3d3d3">选择响应报文</span>
                  <el-button
                    @click="chooseDefineFile2"
                    type="primary"
                    style="margin-left: 60px"
                    >选择文件</el-button
                  >
                  <!-- </el-input> -->
                </el-form-item>
                <!-- <el-form-item  v-if="fileList2.length > 0 && formData.payloadType === 'json'">
                  <div>字段名</div>
                 <el-tree :data="fileList2" :props="defaultProps" @node-click="handleNodeClick">
                   <div style="margin-top:5px;display: flex;width: 100%;justify-content: space-between;" slot-scope="{ node, data }">
                     <div>{{ data.name }}</div>
                   </div>
                 </el-tree>
               </el-form-item> -->
                <el-form-item
                  label="端点："
                  prop="serviceParamsMap.binding"
                  v-if="formData.messageType === 'SOAP'"
                >
                  <el-select
                    v-model="formData.serviceParamsMap.binding"
                    clearable
                    placeholder="请选择"
                    style="width: 100%"
                  >
                    <el-option
                      v-for="item in ports"
                      :key="item.name"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-tab-pane>
        <el-tab-pane
          v-if="
            formData.objname || formData.objname1 || formData.defineFileInfo
          "
          label="服务参数"
          name="seven"
        >
          <div v-if="formData.payloadType === 'json'">
            <div>
              <el-row :gutter="20">
                <el-col :span="20">
                  <el-form-item label="请求报文：">
                    <div>字段名</div>
                    <el-tree
                      :data="fileList1"
                      :props="defaultProps"
                      @node-click="handleNodeClick"
                    >
                      <div
                        style="
                          margin-top: 5px;
                          display: flex;
                          width: 100%;
                          justify-content: space-between;
                        "
                        slot-scope="{ node, data }"
                      >
                        <div>{{ data.name }}</div>
                        <!-- <div style="margin-left:24%;"><el-select v-model="data.type">
                               {{ data.type }}
                           </el-select></div> -->
                      </div>
                    </el-tree>
                  </el-form-item>
                  <el-form-item label="响应报文：">
                    <div>字段名</div>
                    <el-tree
                      :data="fileList2"
                      :props="defaultProps"
                      @node-click="handleNodeClick"
                    >
                      <div
                        style="
                          margin-top: 5px;
                          display: flex;
                          width: 100%;
                          justify-content: space-between;
                        "
                        slot-scope="{ node, data }"
                      >
                        <div>{{ data.name }}</div>
                      </div>
                    </el-tree>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
          </div>
          <div v-if="formData.payloadType === 'xml'">
            <el-tabs
              v-model="activeNamesss"
              type="card"
              @tab-click="handleClicks"
            >
              <el-tab-pane
                v-for="(it, indx) in typeList"
                :key="indx"
                :label="it.type"
                :name="it.type"
              />
            </el-tabs>
            <el-form-item>
              <div>字段名</div>
              <el-tree
                :data="fileList1"
                :props="defaultProps"
                @node-click="handleNodeClick"
              >
                <div
                  style="
                    margin-top: 5px;
                    display: flex;
                    width: 100%;
                    justify-content: space-between;
                  "
                  slot-scope="{ node, data }"
                >
                  <div>{{ data.name }}</div>
                </div>
              </el-tree>
            </el-form-item>
          </div>
        </el-tab-pane>
        <el-tab-pane label="传输" name="fourth">
          <div class="formGroup">
            <el-row :gutter="20">
              <el-col :span="20">
                <el-form-item label="协议：" prop="protocol">
                  <el-select
                    v-model="formData.protocol"
                    clearable
                    placeholder="请选择"
                    @change="protocolChange"
                    style="width: 100%"
                  >
                    <el-option
                      v-for="item in protocolList"
                      :key="item.type"
                      :label="item.type"
                      :value="item.type"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="适配器："
                  prop="connector.name"
                  v-if="formData.protocol && !isSimple"
                >
                  <el-input
                    v-model="formData.connector.name"
                    suffix-icon="el-icon-search"
                    @focus="chooseConnector"
                  >
                  </el-input>
                </el-form-item>
                <el-form-item
                  label="端点uri："
                  prop="uri"
                  v-if="formData.protocol && isSimple"
                >
                  <el-input v-model="formData.uri"></el-input>
                </el-form-item>
                <!-- <el-form-item label="字符编码：">
                  <el-input v-model="formData.encoding"></el-input>
                </el-form-item> -->
              </el-col>
            </el-row>
            <el-tabs
              v-model="transActive"
              type="card"
              @tab-click="transTabClick"
              v-if="formData.protocol && formData.protocol !== 'File'"
              style="margin: 10px 50px"
            >
              <el-tab-pane
                label="基础配置"
                name="1"
                v-if="
                  formData.protocol === 'DB' ||
                  formData.protocol === 'Ftp' ||
                  formData.protocol === 'http' ||
                  formData.protocol === 'Mail' ||
                  formData.protocol === 'Kafka'
                "
              >
                <div class="formGroup">
                  <el-row :gutter="20" v-if="formData.protocol === 'DB'">
                    <el-col :span="20">
                      <!-- <el-radio v-model="radio" class="radios" label="1"> -->
                      <el-form-item label="sql:">
                        <a
                          v-if="formData.connectorSrvParamsMap.name"
                          style="
                            padding-right: 60px;
                            font-weight: 500;
                            color: #1e91d2;
                            text-decoration: underline;
                          "
                          @click="editSqlBuilderVisible = true"
                          >{{ formData.connectorSrvParamsMap.name }}</a
                        >
                        <span v-else style="color: #d3d3d3; padding-right: 60px"
                          >;请选择sql</span
                        >
                        <el-button @click="isClick = true" type="primary"
                          >sql构建器</el-button
                        >
                        <!-- <el-input type="textarea" @input="changeSql"
                                  v-model="formData.connectorSrvParamsMap.sql"></el-input> -->
                      </el-form-item>
                      <!-- </el-radio> -->
                      <!-- <el-radio v-model="radio" class="radios" label="2">
                        <el-form-item label="sql文件：" :required="radio === '2'">
                          <span style="margin-right:10px;" v-if="filename">{{ filename }}.sql</span>
                          <el-button @click="resourceVisible = true" size="mini" type="primary">选择</el-button>
                        </el-form-item>
                      </el-radio> -->
                      <!-- <el-form-item label="">
                        <el-button size="mini" @click="testSqlFun(1)" plain>测试</el-button>
                        <i class="el-icon-check" v-show="ispass=='true'"></i>
                        <i class="el-icon-close" v-show="ispass=='false'"></i>
                      </el-form-item> -->
                      <!-- <el-form-item label="">
                        <el-button size="mini" plain>解析结构</el-button>
                      </el-form-item> -->
                      <!-- <el-form-item label="变量结构："> -->
                      <!-- <el-tabs type="border-card"> -->
                      <!-- <el-tab-pane label="请求"> -->
                      <!-- <div>{{ analysisData }}</div> -->
                      <!-- <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree> -->
                      <!-- </el-tab-pane> -->
                      <!-- <el-tab-pane label="响应">
                        <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
                      </el-tab-pane> -->
                      <!-- </el-tabs> -->
                      <!-- </el-form-item> -->
                    </el-col>
                  </el-row>
                  <el-row :gutter="20" v-if="formData.protocol == 'Ftp'">
                    <el-col :span="20">
                      <el-form-item
                        label="目录路径："
                        prop="connectorSrvParamsMap.path"
                      >
                        <el-input
                          v-model="formData.connectorSrvParamsMap.path"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="文件编码：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.charset"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="自动创建文件目录：">
                        <el-checkbox
                          v-model="formData.connectorSrvParamsMap.autoCreate"
                        ></el-checkbox>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20" v-if="formData.protocol == 'http'">
                    <el-col :span="20">
                      <el-form-item
                        label="请求方法："
                        prop="connectorSrvParamsMap.httpMethod"
                        v-if="formData.messageType === 'REST'"
                      >
                        <el-checkbox-group v-model="httpMethod">
                          <el-checkbox
                            v-for="item in httpMethodList"
                            :label="item.value"
                            :key="item.value"
                            >{{ item.name }}
                          </el-checkbox>
                        </el-checkbox-group>
                      </el-form-item>
                      <el-form-item label="压缩：">
                        <el-checkbox v-model="formData.compress"></el-checkbox>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <!-- 邮件适配器mail-->
                  <el-row :gutter="20" v-if="formData.protocol === 'Mail'">
                    <el-col :span="20">
                      <el-form-item label="内容类型：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.contentType"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20" v-if="formData.protocol === 'Kafka'">
                    <template v-for="(item, i) in kafkaParams">
                      <el-col v-if="item.type === 'input'" :span="20" :key="i">
                        <el-form-item
                          :label="item.label"
                          :prop="'connectorSrvParamsMap.' + item.name"
                        >
                          <el-input
                            v-model="formData.connectorSrvParamsMap[item.name]"
                            :disabled="item.disabled"
                          ></el-input>
                        </el-form-item>
                      </el-col>

                      <el-col v-if="item.type === 'select'" :span="20" :key="i">
                        <el-form-item
                          :label="item.label"
                          :prop="'connectorSrvParamsMap.' + item.name"
                        >
                          <el-select
                            v-model="formData.connectorSrvParamsMap[item.name]"
                            clearable
                            placeholder="请选择"
                            style="width: 100%"
                            :disabled="item.disabled"
                          >
                            <el-option
                              v-for="(option, index) in item.options"
                              :key="index"
                              :label="option"
                              :value="option"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </template>
                  </el-row>
                </div>
              </el-tab-pane>
              <el-tab-pane
                label="基础配置"
                name="1"
                v-if="formData.protocol === 'Jms'"
              >
                <el-row :gutter="20" v-if="formData.protocol === 'Jms'">
                  <el-col :span="20">
                    <el-form-item
                      label="类型："
                      prop="connectorSrvParamsMap.destinationType"
                    >
                      <el-radio-group
                        v-model="formData.connectorSrvParamsMap.destinationType"
                      >
                        <el-radio label="queue">队列</el-radio>
                        <el-radio label="topic">主题</el-radio>
                      </el-radio-group>
                    </el-form-item>
                    <el-form-item
                      label="目标名称："
                      prop="connectorSrvParamsMap.destinationName"
                    >
                      <el-input
                        v-model="formData.connectorSrvParamsMap.destinationName"
                      ></el-input>
                    </el-form-item>
                    <el-form-item>
                      <el-checkbox
                        v-model="formData.connectorSrvParamsMap.transacted"
                        label="启用事务"
                      ></el-checkbox>
                    </el-form-item>
                    <el-form-item
                      v-if="formData.connectorSrvParamsMap.transacted"
                    >
                      <el-checkbox
                        label="将事务用于响应"
                        v-model="formData.connectorSrvParamsMap.transactedInOut"
                      ></el-checkbox>
                    </el-form-item>
                    <el-form-item
                      label="事务超时时间："
                      v-if="formData.connectorSrvParamsMap.transacted"
                    >
                      <el-input
                        type="number"
                        v-model="
                          formData.connectorSrvParamsMap.transactionTimeout
                        "
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-tab-pane>
              <el-tab-pane
                label="轮询配置"
                v-if="formData.protocol === 'DB' || formData.protocol === 'Ftp'"
                name="2"
              >
                <div class="formGroup">
                  <el-row :gutter="20">
                    <el-col :span="20">
                      <el-form-item
                        label="轮询策略："
                        prop="connectorSrvParamsMap.pollType"
                      >
                        <el-select
                          v-model="formData.connectorSrvParamsMap.pollType"
                          clearable
                          placeholder="请选择"
                          style="width: 100%"
                        >
                          <el-option
                            v-for="item in options1"
                            :key="item.value"
                            :label="item.key"
                            :value="item.value"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item
                        label="间隔执行："
                        v-if="
                          formData.connectorSrvParamsMap.pollType === 'delay'
                        "
                      >
                        <el-input
                          v-model="formData.connectorSrvParamsMap.delay"
                        ></el-input>
                      </el-form-item>
                      <el-form-item
                        label="执行计划："
                        v-if="
                          formData.connectorSrvParamsMap.pollType === 'cron'
                        "
                      >
                        <el-input
                          v-model="formData.connectorSrvParamsMap.cron"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="延迟启动：">
                        <el-input
                          v-model.number="
                            formData.connectorSrvParamsMap.initialDelay
                          "
                          type="number"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20" v-if="formData.protocol === 'DB'">
                    <el-col :span="20">
                      <el-form-item label="模式：">
                        <el-checkbox
                          label="贪婪模式"
                          v-model="formData.connectorSrvParamsMap.greedy"
                          >贪婪模式</el-checkbox
                        >
                        <el-checkbox
                          label="出错时中断"
                          v-model="
                            formData.connectorSrvParamsMap
                              .breakBatchOnConsumeFail
                          "
                        >
                          出错时中断
                        </el-checkbox>
                        <el-checkbox
                          label="启用事务"
                          v-model="formData.connectorSrvParamsMap.transacted"
                          >启用事务</el-checkbox
                        >
                      </el-form-item>
                      <el-form-item
                        label="每次轮询数量："
                        prop="connectorSrvParamsMap.maxMessagesPerPoll"
                      >
                        <el-input
                          v-model.number="
                            formData.connectorSrvParamsMap.maxMessagesPerPoll
                          "
                          type="number"
                        ></el-input>
                      </el-form-item>
                      <el-form-item
                        label="成功后处理："
                        prop="connectorSrvParamsMap.onConsume"
                      >
                        <el-input
                          type="textarea"
                          style="width: 77%; margin-right: 10px"
                          v-model="formData.connectorSrvParamsMap.onConsume"
                        ></el-input>
                        <el-button size="mini" @click="testSqlFun(2)" plain
                          >测试</el-button
                        >
                        <i class="el-icon-check" v-show="ispass1 == 'true'"></i>
                        <i
                          class="el-icon-close"
                          v-show="ispass1 == 'false'"
                        ></i>
                      </el-form-item>
                      <el-form-item
                        label="失败后处理："
                        prop="connectorSrvParamsMap.onConsumeFailed"
                      >
                        <el-input
                          type="textarea"
                          style="width: 77%; margin-right: 10px"
                          v-model="
                            formData.connectorSrvParamsMap.onConsumeFailed
                          "
                        ></el-input>
                        <el-button size="mini" @click="testSqlFun(3)" plain
                          >测试</el-button
                        >
                        <i class="el-icon-check" v-show="ispass2 == 'true'"></i>
                        <i
                          class="el-icon-close"
                          v-show="ispass2 == 'false'"
                        ></i>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20" v-if="formData.protocol == 'Ftp'">
                    <el-col :span="20">
                      <el-form-item label="">
                        <el-checkbox
                          v-model="formData.connectorSrvParamsMap.greedy"
                          >贪婪模式</el-checkbox
                        >
                        <el-checkbox
                          v-model="formData.connectorSrvParamsMap.recursive"
                          >递归子目录</el-checkbox
                        >
                        <el-checkbox
                          v-model="formData.connectorSrvParamsMap.delete"
                          >完成后删除</el-checkbox
                        >
                      </el-form-item>
                      <el-form-item label="包含文件：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.antInclude"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="排除文件：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.antExclude"
                        ></el-input>
                      </el-form-item>
                      <el-form-item
                        label="锁策略："
                        prop="connectorSrvParamsMap.readLock"
                      >
                        <el-select
                          v-model="formData.connectorSrvParamsMap.readLock"
                          clearable
                          placeholder="请选择"
                          style="width: 100%"
                        >
                          <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.key"
                            :value="item.value"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item label="失败目录：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.moveFailed"
                        ></el-input>
                      </el-form-item>
                      <el-form-item
                        label="完成目录："
                        v-if="!formData.connectorSrvParamsMap.delete"
                      >
                        <el-input
                          v-model="formData.connectorSrvParamsMap.move"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="预处理目录：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.preMove"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </div>
              </el-tab-pane>
              <el-tab-pane
                label="轮询配置"
                v-if="formData.protocol === 'Mail'"
                name="2"
              >
                <div class="formGroup">
                  <el-row :gutter="20">
                    <el-col :span="20">
                      <el-form-item
                        label="轮询策略："
                        prop="connectorSrvParamsMap.pollType"
                      >
                        <el-select
                          v-model="formData.connectorSrvParamsMap.pollType"
                          clearable
                          placeholder="请选择"
                          style="width: 100%"
                        >
                          <el-option
                            v-for="item in options1"
                            :key="item.value"
                            :label="item.key"
                            :value="item.value"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item
                        label="间隔执行："
                        v-if="
                          formData.connectorSrvParamsMap.pollType === 'delay'
                        "
                        prop="connectorSrvParamsMap.delay"
                      >
                        <el-input
                          v-model="formData.connectorSrvParamsMap.delay"
                        ></el-input>
                      </el-form-item>
                      <el-form-item
                        label="执行计划："
                        v-if="
                          formData.connectorSrvParamsMap.pollType === 'cron'
                        "
                        prop="connectorSrvParamsMap.cron"
                      >
                        <el-input
                          v-model="formData.connectorSrvParamsMap.cron"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="延迟启动：">
                        <el-input
                          v-model.number="
                            formData.connectorSrvParamsMap.initialDelay
                          "
                          type="number"
                        ></el-input>
                      </el-form-item>
                      <el-form-item
                        label="每次轮询数量："
                        prop="connectorSrvParamsMap.maxMessagesPerPoll"
                      >
                        <el-input
                          v-model.number="
                            formData.connectorSrvParamsMap.maxMessagesPerPoll
                          "
                          type="number"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="">
                        <el-checkbox
                          v-model="formData.connectorSrvParamsMap.greedy"
                          >贪婪模式</el-checkbox
                        >
                      </el-form-item>
                      <el-form-item label="读取后删除：">
                        <el-checkbox
                          v-model="formData.connectorSrvParamsMap.delete"
                        ></el-checkbox>
                      </el-form-item>
                      <el-form-item label="读取完成后断开连接：">
                        <el-checkbox
                          v-model="formData.connectorSrvParamsMap.disconnect"
                        ></el-checkbox>
                      </el-form-item>
                      <el-form-item label="读取后移动：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.moveTo"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="偷窥：">
                        <el-checkbox
                          v-model="formData.connectorSrvParamsMap.peek"
                        ></el-checkbox>
                      </el-form-item>
                      <el-form-item label="异常时跳过当前邮件：">
                        <el-checkbox
                          v-model="
                            formData.connectorSrvParamsMap.skipFailedMessage
                          "
                        ></el-checkbox>
                      </el-form-item>
                      <!--          <el-form-item label="每次读取数量：">
                                  <el-input v-model="formData.connectorSrvParamsMap.fetchSize"></el-input>
                                </el-form-item> -->
                      <el-form-item label="指定邮箱目录：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.folderName"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="过滤器：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.searchTerm"
                        ></el-input>
                      </el-form-item>
                      <el-form-item label="排序规则：">
                        <el-input
                          v-model="formData.connectorSrvParamsMap.sortTerm"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </div>
              </el-tab-pane>
              <el-tab-pane
                label="轮询配置"
                v-if="formData.protocol === 'Jms'"
                name="2"
              >
                <el-row :gutter="20">
                  <el-col :span="20">
                    <el-form-item>
                      <el-checkbox
                        label="立即获取下一条消息"
                        v-model="formData.connectorSrvParamsMap.asyncConsumer"
                      ></el-checkbox>
                    </el-form-item>
                    <el-form-item label="监听并发数：">
                      <el-input
                        type="number"
                        v-model="
                          formData.connectorSrvParamsMap.concurrentConsumers
                        "
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="最大监听并发数：">
                      <el-input
                        type="number"
                        v-model="
                          formData.connectorSrvParamsMap.maxConcurrentConsumers
                        "
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="消息过滤器：">
                      <el-input
                        type="number"
                        v-model="formData.connectorSrvParamsMap.selector"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-tab-pane>

              <el-tab-pane
                label="安全验证"
                name="2"
                v-if="formData.protocol === 'http'"
              >
                <el-row :gutter="20">
                  <el-col :span="20">
                    <el-form-item label="安全验证">
                      <el-checkbox
                        v-model="formData.securityConf.enableSecurity"
                        :checked="
                          formData.securityConf &&
                          formData.securityConf.enableSecurity
                        "
                        >启用安全验证
                      </el-checkbox>
                    </el-form-item>
                    <el-form-item
                      label="验证策略："
                      prop="securityConf.authStrategy"
                      v-show="formData.securityConf.enableSecurity"
                    >
                      <el-select
                        v-model="formData.securityConf.authStrategy"
                        clearable
                        placeholder="请选择"
                        style="width: 200px"
                      >
                        <el-option
                          v-for="(item, index) in strategyList"
                          :key="index"
                          :label="item.name"
                          :value="item.key"
                        ></el-option>
                      </el-select>
                      <el-button
                        type="text"
                        style="margin-left: 15px"
                        @click="userListVisible = true"
                        >授权</el-button
                      >
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-tab-pane>

              <el-tab-pane
                label="黑白名单"
                name="3"
                v-if="formData.protocol === 'http'"
              >
                <el-row :gutter="20">
                  <el-col :span="20">
                    <el-form-item label="是否开启：">
                      <el-radio-group
                        v-model="httpLL.isEnableWhiteList"
                        label="false"
                      >
                        <el-radio label="true">是</el-radio>
                        <el-radio label="false">否</el-radio>
                      </el-radio-group>
                    </el-form-item>
                    <el-form-item
                      label="名单类型："
                      v-show="httpLL.isEnableWhiteList === 'true'"
                    >
                      <el-radio-group v-model="httpLL.whiteListType">
                        <el-radio label="allow">白名单</el-radio>
                        <el-radio label="deny">黑名单</el-radio>
                      </el-radio-group>
                    </el-form-item>
                    <el-form-item
                      label="ip地址清单："
                      v-show="httpLL.isEnableWhiteList === 'true'"
                    >
                      <el-input v-model="httpLL.whiteList"></el-input>
                      <p style="color: red">多个请用','(英文逗号)隔开</p>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-tab-pane>
              <el-tab-pane
                label="流量限制"
                name="4"
                v-if="formData.protocol === 'http'"
              >
                <el-row>
                  <el-col :span="12">
                    <el-checkbox v-model="httpLL.isEnableRequestSizeLimiting"
                      >启用报文大小限流</el-checkbox
                    >
                  </el-col>
                </el-row>
                <el-row
                  :gutter="20"
                  v-show="httpLL.isEnableRequestSizeLimiting"
                >
                  <el-col :span="10">
                    <el-form-item label="有效负载大小：">
                      <el-input v-model="httpLL.allowedPayloadSize"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="14">
                    <el-select
                      v-model="httpLL.sizeUnit"
                      clearable
                      placeholder="请选择"
                      style="width: 100%"
                    >
                      <el-option
                        v-for="item in sizeOption"
                        :key="item.value"
                        :label="item.name"
                        :value="item.name"
                      >
                      </el-option>
                    </el-select>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-checkbox v-model="httpLL.isEnableRateLimiting"
                      >启用调用次数限流</el-checkbox
                    >
                  </el-col>
                </el-row>
                <el-row :gutter="20" v-show="httpLL.isEnableRateLimiting">
                  <el-col :span="10">
                    <el-form-item label="限流次数：">
                      <el-input
                        type="number"
                        v-model="httpLL.rateLimitingNumber"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="14">
                    <el-select
                      v-model="httpLL.rateLimitingType"
                      clearable
                      placeholder="请选择"
                      style="width: 100%"
                    >
                      <el-option
                        v-for="item in LimiOption"
                        :key="item.value"
                        :label="item.name"
                        :value="item.name"
                      >
                      </el-option>
                    </el-select>
                  </el-col>
                </el-row>
              </el-tab-pane>
            </el-tabs>
          </div>
        </el-tab-pane>
        <el-tab-pane label="通用配置" name="third">
          <div class="formGroup">
            <el-row :gutter="20">
              <el-col :span="20">
                <el-form-item label="">
                  <el-checkbox
                    v-model="formData.disable"
                    :checked="formData.disable"
                    >禁用</el-checkbox
                  >
                </el-form-item>
                <el-form-item label="">
                  <el-checkbox
                    v-model="formData.commonConf.enableMonitor"
                    :checked="
                      formData.commonConf && formData.commonConf.enableMonitor
                    "
                    >启用监控
                  </el-checkbox>
                </el-form-item>
                <el-form-item
                  label=""
                  v-show="formData.commonConf.enableMonitor"
                >
                  <el-checkbox
                    v-model="formData.commonConf.logRequestBody"
                    :checked="
                      formData.commonConf &&
                      formData.commonConf.logRequestBody &&
                      formData.commonConf.logRequestBody != undefined
                    "
                  >
                    记录请求报文
                  </el-checkbox>
                </el-form-item>
                <el-form-item
                  label=""
                  v-show="formData.commonConf.enableMonitor"
                >
                  <el-checkbox
                    v-model="formData.commonConf.logResponseBody"
                    :checked="
                      formData.commonConf &&
                      formData.commonConf.logResponseBody &&
                      formData.commonConf.logResponseBody != undefined
                    "
                  >
                    记录响应报文
                  </el-checkbox>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-tab-pane>
        <!--        <el-tab-pane label="基础配置" name="fifth" v-if="formData.protocol === 'DB' || formData.protocol === 'Ftp' || formData.protocol === 'http' || formData.protocol === 'Mail'|| formData.protocol === 'Kafka'">-->
        <!--          <div class="formGroup">-->
        <!--            <el-row :gutter="20" v-if="formData.protocol === 'DB'">-->
        <!--              <el-col :span="20">-->
        <!--                <el-radio v-model="radio" class="radios" label="1">-->
        <!--                  <el-form-item label="sql：" :required="radio === '1'">-->
        <!--                    <el-input type="textarea" @input="changeSql" v-model="formData.connectorSrvParamsMap.sql"></el-input>-->
        <!--                  </el-form-item>-->
        <!--                </el-radio>-->
        <!--                &lt;!&ndash; <el-radio v-model="radio" class="radios" label="2">-->
        <!--                  <el-form-item label="sql文件：" :required="radio === '2'">-->
        <!--                    <span style="margin-right:10px;" v-if="filename">{{ filename }}.sql</span>-->
        <!--                    <el-button @click="resourceVisible = true" size="mini" type="primary">选择</el-button>-->
        <!--                  </el-form-item>-->
        <!--                </el-radio> &ndash;&gt;-->
        <!--                <el-form-item label="">-->
        <!--                  <el-button size="mini" @click="testSqlFun(1)" plain>测试</el-button>-->
        <!--                  <i class="el-icon-check" v-show="ispass=='true'"></i>-->
        <!--                  <i class="el-icon-close" v-show="ispass=='false'"></i>-->
        <!--                </el-form-item>-->
        <!--                &lt;!&ndash; <el-form-item label="">-->
        <!--                  <el-button size="mini" plain>解析结构</el-button>-->
        <!--                </el-form-item> &ndash;&gt;-->
        <!--                <el-form-item label="变量结构：">-->
        <!--                  <el-tabs type="border-card">-->
        <!--                    <el-tab-pane label="请求">-->
        <!--                      <div>{{analysisData}}</div>-->
        <!--                      &lt;!&ndash; <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree> &ndash;&gt;-->
        <!--                    </el-tab-pane>-->
        <!--                    &lt;!&ndash; <el-tab-pane label="响应">-->
        <!--                      <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>-->
        <!--                    </el-tab-pane> &ndash;&gt;-->
        <!--                  </el-tabs>-->
        <!--                </el-form-item>-->
        <!--              </el-col>-->
        <!--            </el-row>-->
        <!--            <el-row :gutter="20" v-if="formData.protocol=='Ftp'">-->
        <!--              <el-col :span="20">-->
        <!--                <el-form-item label="目录路径：" prop="connectorSrvParamsMap.path">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.path"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="文件编码：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.charset"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="自动创建文件目录：">-->
        <!--                  <el-checkbox v-model="formData.connectorSrvParamsMap.autoCreate"></el-checkbox>-->
        <!--                </el-form-item>-->
        <!--              </el-col>-->
        <!--            </el-row>-->
        <!--            <el-row :gutter="20" v-if="formData.protocol=='http'">-->
        <!--              <el-col :span="20">-->
        <!--                <el-form-item label="请求方法：" prop="connectorSrvParamsMap.httpMethod" v-if="formData.messageType === 'rest'">-->
        <!--                  <el-checkbox-group v-model="httpMethod">-->
        <!--                    <el-checkbox v-for="item in httpMethodList" :label="item.value" :key="item.value">{{ item.name }}-->
        <!--                    </el-checkbox>-->
        <!--                  </el-checkbox-group>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="压缩：">-->
        <!--                  <el-checkbox v-model="formData.compress"></el-checkbox>-->
        <!--                </el-form-item>-->
        <!--              </el-col>-->
        <!--            </el-row>-->
        <!--            &lt;!&ndash; 邮件适配器mail&ndash;&gt;-->
        <!--          <el-row :gutter="20" v-if="formData.protocol === 'Mail'">-->
        <!--                <el-col :span="20">-->
        <!--                  <el-form-item label="内容类型：" >-->
        <!--                    <el-input v-model="formData.connectorSrvParamsMap.contentType"></el-input>-->
        <!--                  </el-form-item>-->
        <!--                </el-col>-->
        <!--            </el-row>-->
        <!--            <el-row :gutter="20" v-if="formData.protocol==='Kafka'">-->
        <!--              <template v-for="(item,i) in kafkaParams"  >-->
        <!--                <el-col v-if="item.type==='input'" :span="20" :key="i">-->
        <!--                  <el-form-item :label="item.label" :prop="'connectorSrvParamsMap.'+item.name">-->
        <!--                    <el-input v-model="formData.connectorSrvParamsMap[item.name]" :disabled="item.disabled"></el-input>-->
        <!--                  </el-form-item>-->
        <!--                </el-col>-->

        <!--                <el-col v-if="item.type==='select'" :span="20" :key="i">-->
        <!--                  <el-form-item :label="item.label" :prop="'connectorSrvParamsMap.'+item.name">-->
        <!--                    <el-select v-model="formData.connectorSrvParamsMap[item.name]" clearable placeholder="请选择" style="width: 100%;" :disabled="item.disabled">-->
        <!--                      <el-option v-for="(option,index) in item.options" :key="index" :label="option" :value="option">-->
        <!--                      </el-option>-->
        <!--                    </el-select>-->
        <!--                  </el-form-item>-->
        <!--                </el-col>-->

        <!--              </template>-->
        <!--            </el-row>-->
        <!--          </div>-->
        <!--        </el-tab-pane>-->
        <!--        <el-tab-pane label="基础配置" name="fifths" v-if="formData.protocol === 'Jms'">-->
        <!--          <el-row :gutter="20" v-if="formData.protocol === 'Jms' ">-->
        <!--            <el-col :span="20">-->
        <!--              <el-form-item label="类型：" prop="connectorSrvParamsMap.destinationType">-->
        <!--                <el-radio-group v-model="formData.connectorSrvParamsMap.destinationType">-->
        <!--                  <el-radio label="queue">队列</el-radio>-->
        <!--                  <el-radio label="topic">主题</el-radio>-->
        <!--                </el-radio-group>-->
        <!--              </el-form-item>-->
        <!--              <el-form-item label="目标名称：" prop="connectorSrvParamsMap.destinationName">-->
        <!--                <el-input v-model="formData.connectorSrvParamsMap.destinationName"></el-input>-->
        <!--              </el-form-item>-->
        <!--              <el-form-item>-->
        <!--                <el-checkbox v-model="formData.connectorSrvParamsMap.transacted" label="启用事务"></el-checkbox>-->
        <!--              </el-form-item>-->
        <!--              <el-form-item v-if="formData.connectorSrvParamsMap.transacted">-->
        <!--                <el-checkbox label="将事务用于响应" v-model="formData.connectorSrvParamsMap.transactedInOut"></el-checkbox>-->
        <!--              </el-form-item>-->
        <!--              <el-form-item label="事务超时时间：" v-if="formData.connectorSrvParamsMap.transacted">-->
        <!--                <el-input type="number" v-model="formData.connectorSrvParamsMap.transactionTimeout"></el-input>-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--          </el-row>-->
        <!--        </el-tab-pane>-->
        <!--        <el-tab-pane label="安全验证" name="fifthss" v-if="formData.protocol=='http'">-->
        <!--          <el-row :gutter="20">-->
        <!--            <el-col :span="20">-->
        <!--              <el-form-item label="安全验证">-->
        <!--                <el-checkbox v-model="formData.securityConf.enableSecurity" :checked="formData.securityConf && formData.securityConf.enableSecurity">启用安全验证</el-checkbox>-->
        <!--              </el-form-item>-->
        <!--              <el-form-item label="验证策略：" prop="securityConf.authStrategy" v-show="formData.securityConf.enableSecurity">-->
        <!--                <el-select v-model="formData.securityConf.authStrategy" clearable placeholder="请选择"-->
        <!--                  style="width: 200px;">-->
        <!--                  <el-option v-for="(item,index) in strategyList" :key="index" :label="item.name" :value="item.key"></el-option>-->
        <!--                </el-select>-->
        <!--                <el-button type="text" style="margin-left:15px" @click="userListVisible = true">授权</el-button>-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--          </el-row>-->
        <!--        </el-tab-pane>-->
        <!--        <el-tab-pane label="轮询配置"  v-if="formData.protocol === 'DB' || formData.protocol === 'Ftp'" name="sixth">-->
        <!--          <div class="formGroup">-->
        <!--            <el-row :gutter="20">-->
        <!--              <el-col :span="20">-->
        <!--                <el-form-item label="轮询策略：" prop="connectorSrvParamsMap.pollType">-->
        <!--                  <el-select v-model="formData.connectorSrvParamsMap.pollType" clearable placeholder="请选择"-->
        <!--                    style="width: 100%;">-->
        <!--                    <el-option v-for="item in options1" :key="item.value" :label="item.key" :value="item.value">-->
        <!--                    </el-option>-->
        <!--                  </el-select>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="间隔执行：" v-if="formData.connectorSrvParamsMap.pollType === 'delay'">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.delay"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="执行计划：" v-if="formData.connectorSrvParamsMap.pollType === 'cron'">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.cron"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="延迟启动：">-->
        <!--                  <el-input v-model.number="formData.connectorSrvParamsMap.initialDelay" type="number"></el-input>-->
        <!--                </el-form-item>-->
        <!--              </el-col>-->
        <!--            </el-row>-->
        <!--            <el-row :gutter="20" v-if="formData.protocol === 'DB'">-->
        <!--              <el-col :span="20">-->
        <!--                <el-form-item label="模式：">-->
        <!--                  <el-checkbox label="贪婪模式" v-model="formData.connectorSrvParamsMap.greedy">贪婪模式</el-checkbox>-->
        <!--                  <el-checkbox label="出错时中断" v-model="formData.connectorSrvParamsMap.breakBatchOnConsumeFail">出错时中断-->
        <!--                  </el-checkbox>-->
        <!--                  <el-checkbox label="启用事务" v-model="formData.connectorSrvParamsMap.transacted">启用事务</el-checkbox>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="每次轮询数量：" prop="connectorSrvParamsMap.maxMessagesPerPoll">-->
        <!--                  <el-input v-model.number="formData.connectorSrvParamsMap.maxMessagesPerPoll" type="number"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="成功后处理：" prop="connectorSrvParamsMap.onConsume">-->
        <!--                  <el-input type="textarea" style="width: 77%;margin-right: 10px;"-->
        <!--                    v-model="formData.connectorSrvParamsMap.onConsume"></el-input>-->
        <!--                  <el-button size="mini" @click="testSqlFun(2)" plain>测试</el-button>-->
        <!--                  <i class="el-icon-check" v-show="ispass1=='true'"></i>-->
        <!--                  <i class="el-icon-close" v-show="ispass1=='false'"></i>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="失败后处理：" prop="connectorSrvParamsMap.onConsumeFailed">-->
        <!--                  <el-input type="textarea" style="width: 77%;margin-right: 10px;"-->
        <!--                    v-model="formData.connectorSrvParamsMap.onConsumeFailed"></el-input>-->
        <!--                  <el-button size="mini" @click="testSqlFun(3)" plain>测试</el-button>-->
        <!--                  <i class="el-icon-check" v-show="ispass2=='true'"></i>-->
        <!--                  <i class="el-icon-close" v-show="ispass2=='false'"></i>-->
        <!--                </el-form-item>-->
        <!--              </el-col>-->
        <!--            </el-row>-->
        <!--            <el-row :gutter="20" v-if="formData.protocol=='Ftp'">-->
        <!--              <el-col :span="20">-->
        <!--                <el-form-item label="">-->
        <!--                  <el-checkbox v-model="formData.connectorSrvParamsMap.greedy">贪婪模式</el-checkbox>-->
        <!--                  <el-checkbox v-model="formData.connectorSrvParamsMap.recursive">递归子目录</el-checkbox>-->
        <!--                  <el-checkbox v-model="formData.connectorSrvParamsMap.delete">完成后删除</el-checkbox>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="包含文件：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.antInclude"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="排除文件：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.antExclude"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="锁策略：" prop="connectorSrvParamsMap.readLock">-->
        <!--                  <el-select v-model="formData.connectorSrvParamsMap.readLock" clearable placeholder="请选择"-->
        <!--                    style="width: 100%;">-->
        <!--                    <el-option v-for="item in options" :key="item.value" :label="item.key" :value="item.value">-->
        <!--                    </el-option>-->
        <!--                  </el-select>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="失败目录：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.moveFailed"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="完成目录：" v-if="!formData.connectorSrvParamsMap.delete">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.move"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="预处理目录：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.preMove"></el-input>-->
        <!--                </el-form-item>-->
        <!--              </el-col>-->
        <!--            </el-row>-->
        <!--          </div>-->
        <!--        </el-tab-pane>-->
        <!--        <el-tab-pane label="轮询配置"  v-if="formData.protocol === 'Mail'" name="seventh">-->
        <!--          <div class="formGroup">-->
        <!--            <el-row :gutter="20">-->
        <!--              <el-col :span="20">-->
        <!--                <el-form-item label="轮询策略：" prop="connectorSrvParamsMap.pollType">-->
        <!--                  <el-select v-model="formData.connectorSrvParamsMap.pollType" clearable placeholder="请选择"-->
        <!--                    style="width: 100%;">-->
        <!--                    <el-option v-for="item in options1" :key="item.value" :label="item.key" :value="item.value">-->
        <!--                    </el-option>-->
        <!--                  </el-select>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="间隔执行：" v-if="formData.connectorSrvParamsMap.pollType === 'delay'" prop="connectorSrvParamsMap.delay">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.delay"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="执行计划：" v-if="formData.connectorSrvParamsMap.pollType === 'cron'" prop="connectorSrvParamsMap.cron">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.cron"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="延迟启动：">-->
        <!--                  <el-input v-model.number="formData.connectorSrvParamsMap.initialDelay" type="number"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="每次轮询数量：" prop="connectorSrvParamsMap.maxMessagesPerPoll">-->
        <!--                  <el-input v-model.number="formData.connectorSrvParamsMap.maxMessagesPerPoll" type="number"></el-input>-->
        <!--                </el-form-item>-->
        <!--              <el-form-item label="">-->
        <!--                <el-checkbox v-model="formData.connectorSrvParamsMap.greedy">贪婪模式</el-checkbox>-->
        <!--              </el-form-item>-->
        <!--                <el-form-item label="读取后删除：">-->
        <!--                  <el-checkbox v-model="formData.connectorSrvParamsMap.delete"></el-checkbox>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="读取完成后断开连接：">-->
        <!--                  <el-checkbox v-model="formData.connectorSrvParamsMap.disconnect"></el-checkbox>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="读取后移动：" >-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.moveTo"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="偷窥：">-->
        <!--                  <el-checkbox v-model="formData.connectorSrvParamsMap.peek"></el-checkbox>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="异常时跳过当前邮件：" >-->
        <!--                  <el-checkbox v-model="formData.connectorSrvParamsMap.skipFailedMessage"></el-checkbox>-->
        <!--                </el-form-item>-->
        <!--      &lt;!&ndash;          <el-form-item label="每次读取数量：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.fetchSize"></el-input>-->
        <!--                </el-form-item> &ndash;&gt;-->
        <!--                <el-form-item label="指定邮箱目录：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.folderName"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="过滤器：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.searchTerm"></el-input>-->
        <!--                </el-form-item>-->
        <!--                <el-form-item label="排序规则：">-->
        <!--                  <el-input v-model="formData.connectorSrvParamsMap.sortTerm"></el-input>-->
        <!--                </el-form-item>-->
        <!--              </el-col>-->
        <!--            </el-row>-->
        <!--          </div>-->
        <!--        </el-tab-pane>-->
        <!--        <el-tab-pane label="轮询配置"  v-if="formData.protocol === 'Jms'" name="sevenths">-->
        <!--          <el-row :gutter="20">-->
        <!--            <el-col :span="20">-->
        <!--              <el-form-item>-->
        <!--                <el-checkbox label="立即获取下一条消息" v-model="formData.connectorSrvParamsMap.asyncConsumer"></el-checkbox>-->
        <!--              </el-form-item>-->
        <!--              <el-form-item label="监听并发数：">-->
        <!--                <el-input type="number" v-model="formData.connectorSrvParamsMap.concurrentConsumers"></el-input>-->
        <!--              </el-form-item>-->
        <!--              <el-form-item label="最大监听并发数：">-->
        <!--                <el-input type="number" v-model="formData.connectorSrvParamsMap.maxConcurrentConsumers"></el-input>-->
        <!--              </el-form-item>-->
        <!--              <el-form-item label="消息过滤器：">-->
        <!--                <el-input type="number" v-model="formData.connectorSrvParamsMap.selector"></el-input>-->
        <!--              </el-form-item>-->
        <!--            </el-col>-->
        <!--          </el-row>-->
        <!--        </el-tab-pane>-->
        <el-tab-pane v-if="currentRow.id" label="部署信息" name="deployment">
          <el-row type="flex" justify="space-between">
            <el-col :span="5">部署信息</el-col>
            <el-col :span="19" style="width: auto !important">
              批量操作:
              <el-button type="primary" @click="deployAction('start')"
                >启动</el-button
              >
              <el-button type="primary" @click="deployAction('pause')"
                >暂停</el-button
              >
              <el-button type="primary" @click="deployAction('restore')"
                >恢复</el-button
              >
              <el-button type="primary" @click="deployAction('stop')"
                >停止</el-button
              >
              <el-button type="primary" @click="deployAction('reboot')"
                >重启</el-button
              >
            </el-col>
          </el-row>
          <el-row style="margin-top: 20px">
            <el-table
              :data="deploymentData"
              border
              @selection-change="deploySelectionChange"
              style="width: 100%"
            >
              <el-table-column fixed type="selection" label="选择" width="150">
              </el-table-column>
              <el-table-column prop="serverName" label="节点">
              </el-table-column>
              <el-table-column prop="status" label="运行状态">
                <template slot-scope="scope">
                  <p>{{ STATUS[scope.row.status] }}</p>
                </template>
              </el-table-column>
              <el-table-column prop="result" label="操作结果">
                <p>{{ statusTab }}</p>
              </el-table-column>
              <el-table-column fixed="right" label="操作" width="120">
                <template slot-scope="scope">
                  <el-button
                    @click="deployActionStart(scope.row)"
                    type="text"
                    size="small"
                    >启动</el-button
                  >
                  <el-button
                    @click="deployActionPause(scope.row)"
                    type="text"
                    size="small"
                    >暂停</el-button
                  >
                  <el-button
                    @click="deployActionRestore(scope.row)"
                    type="text"
                    size="small"
                    >恢复</el-button
                  >
                  <el-button
                    @click="deployActionStop(scope.row)"
                    type="text"
                    size="small"
                    >停止</el-button
                  >
                  <el-button
                    @click="deployActionReboot(scope.row)"
                    type="text"
                    size="small"
                    >重启</el-button
                  >
                  <!-- <el-button @click="deployAction('reboot',scope)" type="text" size="small">重启</el-button> -->
                </template>
              </el-table-column>
            </el-table>
          </el-row>
        </el-tab-pane>
        <el-tab-pane v-if="currentRow.id" label="依赖检测" name="thirds">
          <depend-onthe-test
            type="agency"
            :formData="formData"
            :titleName="titleName"
            :dialogVisible="dialogVisible"
          />
        </el-tab-pane>
      </el-tabs>
      <choose-connector-dialog
        v-model="connectorVisible"
        :connectorId="formData.connectorId"
        :connectorType="formData.protocol"
        @confirm="handleConnector"
      />
      <choose-target-dialog
        v-model="targetVisible"
        :targetId="formData.targetId"
        :targetType="formData.targetType"
        :targetIncludes="['business', 'flow']"
        @confirm="handleTarget"
      />
      <choose-resourcefile-dialog
        v-model="resourcefileVisible"
        :seletedId="chickId1 || formData.chickId1"
        :defineFileType="defineFileType"
        @confirm="handleResourcefile(arguments)"
      />
      <choose-resourcefile-dialog
        v-model="resourceFileVisible2"
        :seleted-id="chickId2"
        :defineFileType="defineFileType"
        @confirm="handleResourceFile2(arguments)"
      />
      <TestSql
        v-model="testSqlVisible"
        :sqlData="sqlData"
        :sqlFormData="sqlFormData"
        @confirm="getStatus"
      />
      <choose-resource-dialog
        v-model="resourceVisible"
        resourceType="sql"
        @confirm="handleResource"
      />
      <SelectArea
        v-model="areaDialog"
        :connectorId="formData.domainId"
        @confirm="getArea"
      />
    </el-form>
    <div>
      <!-- <depend-onthe-test v-model="dependVisible" type="agency" :formData="formData" :titleName="titleName">
      </depend-onthe-test> -->
    </div>
    <!-- 构建器列表弹框 -->
    <el-dialog
      class="scrollbar-dialog"
      :visible.sync="isClick"
      width="900px"
      top="5vh"
      append-to-body
    >
      <sql-list @getSqlData="getSql" />
    </el-dialog>
    <!-- 构建器列表 -->
    <sql-details
      v-model="editSqlBuilderVisible"
      :buildId="this.formData.connectorSrvParamsMap.id"
      @closeEditDialog="closeEditDialog"
      :porjectId="sqlObj.perjectId"
      @confirmEdit="confirmEdit"
    />
    <user-list-dialog
      v-model="userListVisible"
      :userListOld="userList"
      @getCheckeduserList="getCheckeduserList"
      :id="currentRow.id"
      @closeUserList="closeUserList"
    />
    <editOldVersionVue
      :visibles="editOldVersionDailog"
      :ruleForm="ruleForm"
      :rowData="currentRow"
      @confirm="publishProxyServices"
    />
  </div>
</template>

<script>
import editOldVersionVue from './editOldVersion.vue'
import ChooseConnectorDialog from '@/components/connector/ChooseConnectorDialog'
import ChooseTargetDialog from '@/components/target/ChooseTargetDialog'
import ChooseResourcefileDialog from '@/components/resourcefile/ChooseResourcefileDialog'
import ChooseResourceDialog from '@/components/resource/ChooseResourceDialog'
import SelectArea from '../node_manage/SelectArea'
import userListDialog from './userListDialog'
import sqlList from '../sql_builder/sqlList' // 获取sql列表
import sqlDetails from '../sql_builder/sqldatil'
import { versionSave, versionBackup, versionQuery } from '@/api/system_manage'
import DependOntheTest from '@/components/Dependonthetest/Dependonthetest'

import TestSql from './TestSql'
import {
  saveProxyService,
  getProxyServiceDetail,
  publishProxyService,
  saveSql,
  scriptValidate,
  getRuntimeInfo,
  // getPublish, startService, stopService, suspendService, resumeService, restartService, getResourceFile,
  getPublish,
  startService,
  stopService,
  suspendService,
  resumeService,
  restartService,
  generateSql,
  kongInfoSave,
  kongInfosGet,
  kongInfoGet
} from '@/api/esb_service'
import { checkFormData } from '@/utils/common'
import EsbServiceInfoMixins from '@/mixins/esb_service_info_mixins'
import { createNamespacedHelpers } from 'vuex'

const { mapGetters } = createNamespacedHelpers('app')
export default {
  mixins: [EsbServiceInfoMixins],
  components: {
    editOldVersionVue,
    ChooseConnectorDialog,
    ChooseTargetDialog,
    ChooseResourcefileDialog,
    TestSql,
    ChooseResourceDialog,
    DependOntheTest,
    SelectArea,
    userListDialog,
    sqlList,
    sqlDetails
  },
  data() {
    return {
      editOldVersionDailog: false,
      httpLL: {},
      statusTab: '',
      tabName: '',
      LimiOption: [
        { value: 'second', name: '秒' },
        { value: 'minute', name: '分钟' },
        { value: 'hour', name: '小时' },
        { value: 'day', name: '日' },
        { value: 'month', name: '月' },
        { value: 'year', name: '年' }
      ],
      sizeOption: [
        { value: 'bytes', name: 'bytes' },
        { value: 'kilobytes', name: 'kilobytes' },
        { value: 'megabytes', name: 'megabytes' }
      ],
      STATUS: { 1: '运行中', 2: '异常', 3: '未知', 4: '部分异常' },
      deploymentData: [
        {
          id: '10001',
          name: '测试节点1',
          status: '运行中',
          result: 'OK'
        }
      ],
      verson: [],
      editSqlBuilderVisible: false, // 打开详情页面
      deploymentMultipleSelection: [],
      sqlObj: {}, // 构建器名字
      ruleForm: {},
      isClick: false,
      // jms
      rules: {
        isEnableRequestSizeLimiting: [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        isEnableRateLimiting: [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        isEnableWhiteList: [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        'connectorSrvParamsMap.destinationType': [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        'connectorSrvParamsMap.destinationName': [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        'connectorSrvParamsMap.cron': [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        'connectorSrvParamsMap.delay': [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        'securityConf.authStrategy': [
          {
            required: true,
            message: '验证策略不能为空',
            trigger: ['change', 'blur']
          }
        ],
        'connectorSrvParamsMap.topic': [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        'connectorSrvParamsMap.groupId': [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ],
        'connectorSrvParamsMap.brokers': [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ]
      },
      areaDialog: false,
      formData: {
        serviceParamsMap: {},
        connector: {},
        targetService: {},
        connectorSrvParamsMap: {
          initialDelay: 1000
        },
        commonConf: {
          enableMonitor: false,
          // "id": "",
          logRequestBody: false,
          logResponseBody: false
          // "serviceId": "",
          // "serviceType": ""
        },
        disable: false,
        securityConf: {
          id: '',
          enableSecurity: false, // 是否启用安全验证
          authStrategy: '' // 验证策略
        },
        authAccountsMap: {}
      },
      ispass: '',
      ispass1: '',
      ispass2: '',
      debugVisible: false,
      targetVisible: false,
      testSqlVisible: false,
      resourceVisible: false,
      sqlData: [],
      sqlFormData: {},
      activeType: '',
      analysisData: '',
      dependVisible: false,
      options: [
        { key: 'none', value: 'none' },
        { key: 'markerFile', value: 'markerFile' },
        { key: 'fileLock', value: 'fileLock' },
        { key: 'rename', value: 'rename' }
      ],
      options1: [
        { key: '间隔执行', value: 'delay' },
        { key: '执行计划', value: 'cron' }
      ],
      titleName: '代理服务',
      userListVisible: false,
      userList: {},
      activeName: 'first',
      dialogVisible: false,
      transActive: '1', // ['1','2']
      id_list: []
    }
  },
  created: function () {
    const _this = this
    this.kafkaParams.forEach(function (item) {
      if (item.isrequired) {
        _this.rules['connectorSrvParamsMap.' + item.name] = [
          { required: true, message: '不能为空', trigger: ['change', 'blur'] }
        ]
      }
    })
  },
  props: {
    value: {
      type: Boolean,
      default: false
    },
    currentRow: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    value: {
      immediate: true,
      handler: function (val) {
        this.dialogVisible = val
        if (val) {
          this.$nextTick(() => {
            this.$refs.formData.clearValidate()
          })
          this.ispass = ''
          this.ispass1 = ''
          this.ispass2 = ''
          this.httpLL = {
            isEnableWhiteList: 'false',
            isEnableRateLimiting: false,
            isEnableRequestSizeLimiting: false,
            sizeUnit: 'megabytes',
            allowedPayloadSize: '128'
          }
          this.formData = {
            id: '',
            messageType: 'REST',
            payloadType: 'json',
            protocol: 'http',
            serviceParamsMap: {},
            connector: {},
            targetService: {},
            connectorSrvParamsMap: {
              sql: '',
              maxMessagesPerPoll: '',
              delay: '',
              cron: '',
              pollType: this.radio1 === '1' ? 'delay' : 'cron',
              initialDelay: 0,
              onConsume: '',
              onConsumeFailed: '',
              greedy: false,
              breakBatchOnConsumeFail: false,
              transacted: false
            },
            commonConf: {
              enableMonitor: false,
              // "id": "",
              logRequestBody: false,
              logResponseBody: false
              // "serviceId": "",
              // "serviceType": ""
            },
            disable: false,
            securityConf: {
              id: '',
              enableSecurity: false, // 是否启用安全验证
              authStrategy: '' // 验证策略
            },
            authAccountsMap: {}
          }
          console.log('你变了', this.formData.connectorSrvParamsMap)
          // this.httpMethod = ['POST']
          // this.formData.connectorSrvParamsMap.httpMethod = ['POST']

          this.analysisData = ''
        }
        this.$set(this.currentRow, 'changetime', Date.parse(new Date()))
      },
      deep: true
    },
    dialogVisible(val) {
      this.$emit('input', val)
    },
    currentRow: {
      immediate: true,
      handler: function (val) {
        console.log('打印watch数据监听', val, val.id)
        if (val && val.id) {
          this.getProxyServiceDetail(val.id)
        }
      },
      deep: true
    }
  },
  computed: {
    ...mapGetters(['projectID'])
  },
  methods: {
    // debug打开
    debugs() {
      this.debugVisible = true
    },
    // 切换表格
    handleClicks(tab) {
      this.fileList1 = []
      this.typeList.map((item) => {
        if (item.type === tab.name) {
          this.fileList1.push(item.content)
        }
      })
    },
    // 切换类型
    // 发布调用的接口
    getPublish(id) {
      getPublish(id).then((res) => {
        this.statusTab = res.status
      })
    },
    // 获取信息部署
    getRuntimeInfo() {
      getRuntimeInfo(this.currentRow.id).then((res) => {
        this.deploymentData = res.data
      })
    },
    confirmEdit(val) {
      this.$set(this.sqlObj, 'name', val)
      this.formData.connectorSrvParamsMap.sql = val.customSql
      this.getResourceFile(this.sqlObj.id, this.sqlObj.perjectId)
      this.editSqlBuilderVisible = false
    },
    closeEditDialog(val) {
      this.editSqlBuilderVisible = val
    },
    getArea(data) {
      // console.log(data, 'domain')
      this.$set(this.formData, 'domainId', data.id)
      this.$set(this.formData, 'domainName', data.name)
    },
    /* 部署信息的多选 */
    deploySelectionChange(rows) {
      // console.log(rows, '选中')
      this.deploymentMultipleSelection = rows
    },
    // 启动获取
    startServices(id1, id) {
      startService({
        id: id1,
        servers: id
      }).then((res) => {
        this.statusTab = res.status === '500' ? '服务异常' : '正常'
        if (res.status === '200') {
          this.$message({
            message: '启动指定服务成功',
            type: 'success'
          })
        } else {
          this.$message({
            message: '启动指定服务失败',
            type: 'error'
          })
        }
      })
    },
    // 停止启动服务
    stopService(id1, id) {
      stopService({
        id: id1,
        servers: id
      }).then((res) => {
        this.statusTab = res.status === '500' ? '服务异常' : '正常'
        if (res.status === '200') {
          this.$message({
            message: '停止启动服务成功',
            type: 'success'
          })
        } else {
          this.$message({
            message: '停止启动服务失败',
            type: 'error'
          })
        }
      })
    },
    // 部署信息恢复指定服务
    resumeService(id1, id) {
      resumeService({
        id: id1,
        servers: id
      }).then((res) => {
        this.statusTab = res.status === '500' ? '服务异常' : '正常'
        if (res.status === '200') {
          this.$message({
            message: '恢复指定服务成功',
            type: 'success'
          })
        } else {
          this.$message({
            message: '恢复指定服务失败',
            type: 'error'
          })
        }
      })
    },
    // 部署信息暂停指定服务
    suspendService(id1, id) {
      suspendService({
        id: id1,
        servers: id
      }).then((res) => {
        this.statusTab = res.status === '500' ? '服务异常' : '正常'
        if (res.status === '200') {
          this.$message({
            message: '暂停指定服务成功',
            type: 'success'
          })
        } else {
          this.$message({
            message: '暂停指定服务失败',
            type: 'error'
          })
        }
      })
    },
    // 部署信息重启指定服务
    restartService(id1, id) {
      restartService({
        id: id1,
        servers: id
      }).then((res) => {
        this.statusTab = res.status === '500' ? '服务异常' : '正常'
        if (res.status === '200') {
          this.$message({
            message: '重启指定服务成功',
            type: 'success'
          })
        } else {
          this.$message({
            message: '重启指定服务失败',
            type: 'error'
          })
        }
      })
    },
    /* 部署信息的操作 -> 批量操作*/
    deployAction(actionType, singleItem) {
      if (this.deploymentMultipleSelection.length === 0) {
        this.$message.warning('请先选择节点！')
        return false
      }
      // console.log(actionType, singleItem, '1111111111111111111111')
      var str = ''
      this.deploymentMultipleSelection.forEach(function (e) {
        str += e.serverId + ','
      })
      str = str.substring(0, str.length - 1)
      this.id_list = str.split(',')
      switch (actionType) {
        // 启动
        case 'start':
          // this.startServices(this.deploymentMultipleSelection[0].serverId)
          this.startServices(this.formData.id, this.id_list)
          this.id_list = []
          break
        // 暂停
        case 'pause':
          this.suspendService(this.formData.id, this.id_list)
          this.id_list = []
          break
        //  恢复
        case 'restore':
          this.resumeService(this.formData.id, this.id_list)
          this.id_list = []
          break
        //  停止
        case 'stop':
          this.stopService(this.formData.id, this.id_list)
          this.id_list = []
          break
        //  重启
        case 'reboot':
          this.restartService(this.formData.id, this.id_list)
          this.id_list = []
          break
        default:
          break
      }
      // if (singleItem) {
      //   // TODO 这里进行单个操作
      //   switch (actionType) {
      //     // 启动
      //     case 'start':
      //       startService(this.deploymentMultipleSelection.id).then(res => {
      //         console.log(res, '11')
      //       })
      //       break
      //     // 暂停
      //     case 'pause':
      //       break
      //     //  恢复
      //     case 'restore':
      //       break
      //     //  停止
      //     case 'stop':
      //       break
      //     //  重启
      //     case 'reboot':
      //       break
      //     default:
      //       break
      //   }
      // } else {
      //   // TODO 这里进行批量操作
      //   if (this.deploymentMultipleSelection && this.deploymentMultipleSelection.length > 0) {

      //   } else {
      //     this.$message({ message: '请选择需要操作的节点', type: 'error' })
      //   }
      // }
    },
    /* 部署信息的操作 -> 启动*/
    deployActionStart(item) {
      let str = ''
      str = item.serverId
      // console.log(str, 'mmmm')
      str = str.substring(0, str.length)
      this.id_list = str.split()
      // console.log('qqq', this.id_list)
      this.startServices(this.formData.id, this.id_list)
      this.id_list = []
    },
    /* 部署信息的操作 -> 暂停*/
    deployActionPause(item) {
      let str = ''
      str = item.serverId
      str = str.substring(0, str.length)
      this.id_list = str.split()
      this.suspendService(this.formData.id, this.id_list)
      this.id_list = []
    },
    /* 部署信息的操 作 -> 恢复*/
    deployActionRestore(item) {
      let str = ''
      str = item.serverId
      str = str.substring(0, str.length)
      this.id_list = str.split()
      this.resumeService(this.formData.id, this.id_list)
      this.id_list = []
    },
    /* 部署信息的操作 -> 停止*/
    deployActionStop(item) {
      let str = ''
      str = item.serverId
      str = str.substring(0, str.length)
      this.id_list = str.split()
      this.stopService(this.formData.id, this.id_list)
      this.id_list = []
    },
    /* 部署信息的操作 -> 重启*/
    deployActionReboot(item) {
      let str = ''
      str = item.serverId
      str = str.substring(0, str.length)
      this.id_list = str.split()
      this.restartService(this.formData.id, this.id_list)
      this.id_list = []
    },
    handleClick(tab, event) {
      this.tabName = tab.label
      if (tab.label === '部署信息') {
        this.getRuntimeInfo()
      }
    },
    transTabClick(tab, event) {
      this.transActive = '1'
    },
    getSql(data) {
      // console.log(data, '11')
      this.sqlObj = data
      this.isClick = false
      this.generateSql(data.id, data.name)
    },
    // 获取sql
    generateSql(id, name) {
      // console.log('name', name)
      generateSql({
        id: id
      }).then((res) => {
        // console.log(res, '1')
        if (res.status === '200') {
          this.formData.connectorSrvParamsMap.sql = res.data.sql
          this.$set(this.formData.connectorSrvParamsMap, 'name', name)
          this.formData.connectorSrvParamsMap.name = name
          this.formData.connectorSrvParamsMap.id = id
        }
      })
    },
    // 获取默认的配置文件
    // getResourceFile (id, pid) {
    //   getResourceFile(id, pid).then(res => {
    //     if (res.data.length > 0) {

    //     }
    //   })
    // },
    changeSql() {
      this.analysisData = ''
      this.ispass = ''
    },
    getProxyServiceDetail(id) {
      // console.log('kkkkkkkkkkkkk')
      kongInfosGet(id).then((res) => {
        if (res.status === '200') {
          if (res.data.hasOwnProperty('isEnableWhiteList')) {
            this.httpLL = res.data
          }
          if (
            !this.httpLL.hasOwnProperty('isEnableWhiteList') ||
            !this.httpLL.isEnableWhiteList
          ) {
            this.httpLL.isEnableWhiteList = 'false'
            this.httpLL.whiteListType = 'allow'
          }
          if (
            !this.httpLL.hasOwnProperty('isEnableRequestSizeLimiting') ||
            !this.httpLL.isEnableRequestSizeLimiting
          ) {
            this.httpLL.isEnableRequestSizeLimiting = false
          }
          if (
            !this.httpLL.hasOwnProperty('isEnableRateLimiting') ||
            !this.httpLL.isEnableRateLimiting
          ) {
            this.httpLL.isEnableRateLimiting = false
          }
          this.httpLL.isEnableRequestSizeLimiting = JSON.parse(
            this.httpLL.isEnableRequestSizeLimiting
          )
          this.httpLL.isEnableRateLimiting = JSON.parse(
            this.httpLL.isEnableRateLimiting
          )
        }
      })
      // kongInfoGet(id).then(res => {
      //   console.log(res)
      // })
      getProxyServiceDetail(id)
        .then((rt) => {
          if (rt.status === '200' && rt.data) {
            // 注释掉
            // rt.data.connectorSrvParamsMap = rt.data.connectorSrvParams
            this.formData = rt.data
            this.ruleForm = rt.data
            console.log(this.ruleForm, 'nishihuiadasd')
            // console.log(8888888, this.formData)
            // 文件的id
            if (this.formData.gateAwayDtoInfo) {
              this.httpLL = this.formData.gateAwayDtoInfo
            }
            if (!this.formData.chickId1) {
              this.formData.chickId1 = this.formData.defineFileInfo
                ? this.formData.defineFileInfo.id
                : ''
            }
            if (!this.formData.serviceParamsMap) {
              this.$set(this.formData, 'serviceParamsMap', {})
            }
            if (!this.formData.connector) {
              this.$set(this.formData, 'connector', {})
            }
            if (!this.formData.commonConf) {
              this.$set(this.formData, 'commonConf', {
                enableMonitor: false,
                logRequestBody: false,
                logResponseBody: false
              })
            }
            if (!this.formData.securityConf) {
              this.$set(this.formData, 'securityConf', {
                id: this.formData.securityConfId,
                enableSecurity: false,
                authStrategy: ''
              })
            }
            if (!this.formData.authAccountsMap) {
              this.$set(this.formData, 'authAccountsMap', {})
            }
            // 默认不禁用,有默认值，不需要添加
            // this.$set(this.formData, 'disable',false)

            if (!this.formData.targetService) {
              this.$set(this.formData, 'targetService', {})
            }
            // console.log('llllll')
            if (!this.formData.connectorSrvParamsMap) {
              // console.log('jjjjj', this.formData)
              this.$set(this.formData, 'connectorSrvParamsMap', {})
            } else {
              // console.log(11111111)
              this.httpMethod = this.formData.connectorSrvParamsMap.httpMethod
                ? this.formData.connectorSrvParamsMap.httpMethod.split(',')
                : []
            }
            // console.log(2222222)
            this.formData.messageType = rt.data.messageType.toUpperCase()
            if (this.formData.protocol === 'DB') {
              if (
                this.formData.connectorId &&
                this.formData.connectorSrvParamsMap.sql
              ) {
                saveSql({
                  id: this.formData.connectorId,
                  script: this.formData.connectorSrvParamsMap.sql
                })
                  .then((rt) => {
                    if (rt.status === '200') {
                      this.analysisData = rt.data
                      if (this.analysisData) {
                        this.ispass = 'true'
                      }
                    }
                  })
                  .catch(() => {})
              }
            }
          }
        })
        .catch(() => {})
    },
    chooseTarget() {
      this.targetVisible = true
    },
    handleTarget(data) {
      // 先清空
      this.$set(this.formData, 'messageType', '')
      this.$set(this.formData, 'payloadType', '')
      this.$set(this.formData, 'defineFile', '')
      this.$set(this.formData, 'defineFileId', '')
      this.$set(this.formData, 'defineFileType', '')
      this.$set(this.formData, 'secondDefineFileId', '')
      this.$set(this.formData, 'secondDefineFile', '')
      this.$set(this.formData.serviceParamsMap, 'binding', '')
      this.$set(this.formData.connectorSrvParamsMap, 'httpMethod', '')

      this.$set(this.formData, 'commonConf', '')
      this.$set(this.formData, 'disable', false)
      this.$set(this.formData, 'securityConf', '')
      this.$set(this.formData, 'authAccountsMap', {})

      // this.$set(this.formData.connectorSrvParamsMap, 'sql', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'maxMessagesPerPoll', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'delay', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'cron', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'pollType', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'initialDelay', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'maxMessagesPerPoll', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'onConsume', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'onConsumeFailed', '')
      // this.$set(this.formData.connectorSrvParamsMap, 'greedy', false)
      // this.$set(this.formData.connectorSrvParamsMap, 'breakBatchOnConsumeFail', false)
      // this.$set(this.formData.connectorSrvParamsMap, 'transacted', false)
      // this.httpMethod = []
      this.$set(this.formData.targetService, 'name', data.name)
      this.$set(this.formData, 'targetType', data.type)
      this.$set(this.formData, 'targetId', data.id)
      // 再添加
      this.$set(this.formData, 'messageType', data.messageType.toUpperCase())
      this.$set(this.formData, 'payloadType', data.payloadType)
      this.$set(this.formData, 'defineFile', data.defineFile)
      this.$set(this.formData, 'defineFileId', data.defineFileId)
      this.$set(this.formData, 'secondDefineFileId', data.secondDefineFileId)
      this.$set(this.formData, 'defineFileType', data.defineFileType)
      this.$set(this.formData, 'secondDefineFile', data.secondDefineFile)
      if (data.commonConf === undefined) {
        // 新增
        this.$set(this.formData, 'commonConf', {
          enableMonitor: false,
          logRequestBody: false,
          logResponseBody: false
        })
      } else {
        this.$set(this.formData, 'commonConf', data.commonConf)
      }
      if (data.securityConf === undefined) {
        // 新增
        this.$set(this.formData, 'securityConf', {
          id: this.formData.securityConfId,
          enableSecurity: false,
          authStrategy: ''
        })
      } else {
        this.$set(this.formData, 'securityConf', data.securityConf)
      }
      if (data.authAccountsMap === undefined) {
        // 新增
        this.$set(this.formData, 'authAccountsMap', {})
      } else {
        this.$set(this.formData, 'authAccountsMap', data.authAccountsMap)
      }
      this.$set(this.formData, 'disable', data.disable)

      if (data.serviceParamsMap) {
        this.$set(
          this.formData.serviceParamsMap,
          'binding',
          data.serviceParamsMap.binding
        )
        if (data.serviceParamsMap.httpMethod) {
          this.httpMethod = []
        }
        this.$set(
          this.formData.connectorSrvParamsMap,
          'httpMethod',
          data.serviceParamsMap.httpMethod
        )
        this.httpMethod = this.formData.connectorSrvParamsMap.httpMethod
          ? this.formData.connectorSrvParamsMap.httpMethod.split(',')
          : this.httpMethod
      }
    },
    publishProxyService() {
      // this.editOldVersionDailog = true
      publishProxyService(this.currentRow.id)
          .then((rt) => {
            if (rt.status === '200') {
              let ind = true
              let inds = ''
              rt.data.forEach((item) => {
                if (!item.success) {
                  ind = false
                  inds += item.message
                }
              })
              if (ind) {
                this.$message({
                  message: '发布成功',
                  type: 'success'
                })
                this.$emit('confirm')
              } else {
                this.$message({
                  message: inds,
                  type: 'error'
                })
              }
            }
          })
          .catch(() => {})
    },
    versionBackup() {
      console.log(this.currentRow, 'this.verson')
      const filters = [
        {
          key: 'proxy_service_id',
          opt: 'LIKE',
          type: 'S',
          value: 1
        }
      ]
      versionQuery({
        filters: filters,
        orderby: 'updateon',
        pageNum: 1,
        pageSize: 1000,
        sort: 'desc'
      }).then((res) => {
        this.tableData = res.data.list
      })
      versionBackup({
        id: this.currentRow.id,
        versionNo: 'v1'
      }).then((res) => {})
    },

    publishProxyServices(data) {
      this.editOldVersionDailog = false
      if (!data) {
        return
      }
      if (this.tabName === '部署信息') {
        this.getPublish(this.deploymentMultipleSelection.serverId)
        return
      }
      versionSave({
        proxyServiceId: this.currentRow.id,
        versionDesc: data.intro,
        versionNo: data.versionNoOld
      }).then((res) => {
        publishProxyService(this.currentRow.id)
          .then((rt) => {
            if (rt.status === '200') {
              let ind = true
              let inds = ''
              rt.data.forEach((item) => {
                if (!item.success) {
                  ind = false
                  inds += item.message
                }
              })
              if (ind) {
                this.$message({
                  message: '发布成功',
                  type: 'success'
                })
                this.$emit('confirm')
              } else {
                this.$message({
                  message: inds,
                  type: 'error'
                })
              }
            }
          })
          .catch(() => {})
      })
    },
    async submit() {
      // 'securityConf.authStrategy': [
      //     { required: true, message: '验证策略不能为空', trigger: ['change', 'blur'] }
      //   ],
      if (this.formData.isEnableWhiteList === 'true') {
        if (!this.formData.whiteListType && !this.formData.whiteList) {
          this.$message.warning('ip和名单类型不能为空')
          this.activeName = 'fourth'
          return
        }
      }
      if (this.formData.securityConf.enableSecurity) {
        this.rules['securityConf.authStrategy'] = [
          {
            required: true,
            message: '验证策略不能为空',
            trigger: ['change', 'blur']
          }
        ]
      } else {
        this.rules['securityConf.authStrategy'] = [
          {
            required: false,
            message: '验证策略不能为空',
            trigger: ['change', 'blur']
          }
        ]
      }
      this.$refs['formData'].validate((valid, obj) => {
        // console.log('valid', valid)
        // console.log(222, this.formData)
        if (valid) {
          if (this.formData.messageType === 'db') {
            this.$message.warning('消息定义中消息类型不能为db')
            this.activeName = 'fourth'
            return
          }
          if (this.formData.protocol === 'DB') {
            if (!this.formData.connectorSrvParamsMap.sql) {
              this.$message.warning('基础配置中请输入sql语句')
              this.activeName = 'fourth'
              return
            }
            if (
              !this.formData.connectorSrvParamsMap.delay &&
              !this.formData.connectorSrvParamsMap.cron
            ) {
              this.$message.warning('轮询配置中请输入轮询间隔或者使用cron')
              this.activeName = 'fourth'
              return
            }
            // if (!this.analysisData) {
            //   this.$message.warning('基础配置中请测试sql，sql有效方可提交')
            //   return
            // }
          }

          let forms = {}
          forms.serviceParamsMap = {}
          forms.connector = this.formData.connector
          forms.targetService = this.formData.targetService
          forms.connectorSrvParamsMap = {}
          forms.commonConf = this.formData.commonConf
          forms.disable = this.formData.disable
          forms.securityConf = this.formData.securityConf
          forms.authAccountsMap = this.formData.authAccountsMap

          if (this.formData.protocol === 'Jms') {
            forms = {
              id: this.formData.id,
              name: this.formData.name,
              description: this.formData.description,
              messageType: this.formData.messageType,
              payloadType: this.formData.payloadType,
              defineFileType: this.formData.defineFileType,
              defineFile: this.formData.defineFile,
              secondDefineFile: this.formData.secondDefineFile,
              protocol: this.formData.protocol,
              uri: this.formData.uri,
              compress: this.formData.compress,
              type: this.formData.type,
              encoding: this.formData.encoding,
              connectorType: this.formData.connectorType,
              connectorId: this.formData.connectorId,
              defineFileId: this.formData.defineFileId,
              secondDefineFileId: this.formData.secondDefineFileId,
              domainId: this.formData.domainId,
              domainName: this.formData.domainName,
              targetId: this.formData.targetId,
              targetType: this.formData.targetType,
              serviceParamsMap: {
                binding: this.formData.serviceParamsMap.binding
              },
              connector: {
                name: this.formData.connector.name
              },
              targetService: {
                name: this.formData.targetService.name
                // 'defineFile': this.formData.targetService.defineFile,
                // 'defineFileId' :this.formData.targetService.defineFileId
              },
              connectorSrvParamsMap: {
                destinationType:
                  this.formData.connectorSrvParamsMap.destinationType,
                destinationName:
                  this.formData.connectorSrvParamsMap.destinationName,
                transacted: this.formData.connectorSrvParamsMap.transacted,
                transactedInOut:
                  this.formData.connectorSrvParamsMap.transactedInOut,
                transactionTimeout:
                  this.formData.connectorSrvParamsMap.transactionTimeout,
                concurrentConsumers:
                  this.formData.connectorSrvParamsMap.concurrentConsumers,
                maxConcurrentConsumers:
                  this.formData.connectorSrvParamsMap.maxConcurrentConsumers,
                selector: this.formData.connectorSrvParamsMap.selector,
                asyncConsumer: this.formData.connectorSrvParamsMap.asyncConsumer
                // 'httpMethod': this.formData.connectorSrvParamsMap.httpMethod
              },
              commonConf: {
                enableMonitor: this.formData.commonConf.enableMonitor,
                logRequestBody: this.formData.commonConf.logRequestBody,
                logResponseBody: this.formData.commonConf.logResponseBody
              },
              disable: this.formData.disable
            }
          }
          // http
          let httpForm = {}
          httpForm.serviceParamsMap = {}
          httpForm.connector = this.formData.connector
          httpForm.targetService = this.formData.targetService
          httpForm.connectorSrvParamsMap = {}
          httpForm.commonConf = this.formData.commonConf
          httpForm.disable = this.formData.disable
          httpForm.securityConf = this.formData.securityConf
          httpForm.authAccountsMap = this.formData.authAccountsMap

          if (this.formData.protocol === 'http') {
            if (this.httpLL.isEnableWhiteList === 'true') {
              var reg =
                /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-4][0-9])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/
              let regI = 0
              if (!this.httpLL.whiteList) {
                this.httpLL.whiteList = ''
              }
              this.httpLL.whiteList.split(',').forEach((item) => {
                if (
                  item.split('.').length !== 4 &&
                  !reg.test(item.split('/')[0])
                ) {
                  regI = 1
                }
              })
              // if (regI === 1) {
              //   this.$message.warning('你的IP不符合规格')
              //   return
              // }
            }
            if (this.httpLL.isEnableWhiteList === 'false') {
              this.httpLL.whiteList = ''
            }
            if (this.formData.id) {
              this.httpLL.serviceId = this.formData.id
            }
            this.httpLL.isEnableRequestSizeLimiting =
              this.httpLL.isEnableRequestSizeLimiting.toString()
            this.httpLL.isEnableRateLimiting =
              this.httpLL.isEnableRateLimiting.toString()

            httpForm = {
              id: this.formData.id,
              name: this.formData.name,
              description: this.formData.description,
              messageType: this.formData.messageType,
              payloadType: this.formData.payloadType,
              defineFileType: this.formData.defineFileType,
              defineFile: this.formData.defineFile,
              secondDefineFile: this.formData.secondDefineFile,
              protocol: this.formData.protocol,
              uri: this.formData.uri,
              compress: this.formData.compress,
              type: this.formData.type,
              encoding: this.formData.encoding,
              connectorType: this.formData.connectorType,
              connectorId: this.formData.connectorId,
              defineFileId: this.formData.defineFileId,
              secondDefineFileId: this.formData.secondDefineFileId,
              domainId: this.formData.domainId,
              domainName: this.formData.domainName,
              targetId: this.formData.targetId,
              targetType: this.formData.targetType,
              // 'whiteList': this.formData.whiteList,
              // 'whiteListType': this.formData.whiteListType,
              // 'isEnableWhiteList': this.formData.isEnableWhiteList,
              // 'isEnableRateLimiting': this.formData.isEnableRateLimiting,
              // 'isEnableRequestSizeLimiting': this.formData.isEnableRequestSizeLimiting,
              // 'sizeUnit': this.formData.sizeUnit,
              // 'rateLimitingType': this.formData.rateLimitingType,
              // 'rateLimitingNumber': this.formData.rateLimitingNumber,
              // 'allowedPayloadSize': this.formData.allowedPayloadSize,
              // 'compress': this.formData.compress,
              gateAwayDtoInfo: JSON.stringify(this.httpLL),
              connectorSrvParamsMap: {
                httpMethod: this.formData.connectorSrvParamsMap.httpMethod
              },
              serviceParamsMap: {
                binding: this.formData.serviceParamsMap.binding,
                httpMethod: this.formData.serviceParamsMap.httpMethod
              },
              commonConf: {
                enableMonitor: this.formData.commonConf.enableMonitor,
                logRequestBody: this.formData.commonConf.logRequestBody,
                logResponseBody: this.formData.commonConf.logResponseBody
              },
              disable: this.formData.disable,
              securityConf: {
                id: this.formData.securityConfId,
                enableSecurity: this.formData.securityConf.enableSecurity,
                authStrategy: this.formData.securityConf.authStrategy
              },
              authAccountsMap: this.formData.authAccountsMap
            }
          }

          // Ftp
          let ftpForm = {}
          ftpForm.serviceParamsMap = this.formData.serviceParamsMap
          ftpForm.connector = this.formData.connector
          ftpForm.targetService = this.formData.targetService
          ftpForm.connectorSrvParamsMap = {}
          ftpForm.commonConf = this.formData.commonConf
          ftpForm.disable = this.formData.disable
          if (this.formData.protocol === 'Ftp') {
            ftpForm = {
              id: this.formData.id,
              name: this.formData.name,
              description: this.formData.description,
              messageType: this.formData.messageType,
              payloadType: this.formData.payloadType,
              defineFileType: this.formData.defineFileType,
              defineFile: this.formData.defineFile,
              secondDefineFile: this.formData.secondDefineFile,
              protocol: this.formData.protocol,
              uri: this.formData.uri,
              compress: this.formData.compress,
              type: this.formData.type,
              encoding: this.formData.encoding,
              connectorType: this.formData.connectorType,
              connectorId: this.formData.connectorId,
              defineFileId: this.formData.defineFileId,
              secondDefineFileId: this.formData.secondDefineFileId,
              domainId: this.formData.domainId,
              domainName: this.formData.domainName,
              targetId: this.formData.targetId,
              targetType: this.formData.targetType,
              // 'compress': this.formData.compress,
              resourceType: this.formData.resourceType,
              publishStatus: this.formData.publishStatus,
              connectorSrvParamsMap: {
                antExclude: this.formData.connectorSrvParamsMap.antExclude,
                antInclude: this.formData.connectorSrvParamsMap.antInclude,
                autoCreate: this.formData.connectorSrvParamsMap.autoCreate,
                charset: this.formData.connectorSrvParamsMap.charset,
                cron: this.formData.connectorSrvParamsMap.cron,
                delay: this.formData.connectorSrvParamsMap.delay,
                greedy: this.formData.connectorSrvParamsMap.greedy,
                // 'httpMethod': this.formData.connectorSrvParamsMap.httpMethod,
                initialDelay: this.formData.connectorSrvParamsMap.initialDelay,
                move: this.formData.connectorSrvParamsMap.move,
                recursive: this.formData.connectorSrvParamsMap.recursive,
                delete: this.formData.connectorSrvParamsMap.delete,
                moveFailed: this.formData.connectorSrvParamsMap.moveFailed,
                path: this.formData.connectorSrvParamsMap.path,
                pollType: this.formData.connectorSrvParamsMap.pollType,
                preMove: this.formData.connectorSrvParamsMap.preMove,
                readLock: this.formData.connectorSrvParamsMap.readLock
              },
              serviceParamsMap: {
                binding: this.formData.serviceParamsMap.binding,
                httpMethod: this.formData.serviceParamsMap.httpMethod
              },
              commonConf: {
                enableMonitor: this.formData.commonConf.enableMonitor,
                logRequestBody: this.formData.commonConf.logRequestBody,
                logResponseBody: this.formData.commonConf.logResponseBody
              },
              disable: this.formData.disable
            }
          }
          // File
          let fileForm = {}
          fileForm.serviceParamsMap = this.formData.serviceParamsMap
          fileForm.connector = this.formData.connector
          fileForm.connectorSrvParamsMap = this.formData.connectorSrvParamsMap
          fileForm.commonConf = this.formData.commonConf
          fileForm.disable = this.formData.disable
          if (this.formData.protocol === 'File') {
            fileForm = {
              id: this.formData.id,
              name: this.formData.name,
              description: this.formData.description,
              messageType: this.formData.messageType,
              payloadType: this.formData.payloadType,
              defineFileType: this.formData.defineFileType,
              defineFile: this.formData.defineFile,
              secondDefineFile: this.formData.secondDefineFile,
              protocol: this.formData.protocol,
              uri: this.formData.uri,
              compress: this.formData.compress,
              type: this.formData.type,
              encoding: this.formData.encoding,
              connectorType: this.formData.connectorType,
              connectorId: this.formData.connectorId,
              defineFileId: this.formData.defineFileId,
              secondDefineFileId: this.formData.secondDefineFileId,
              domainId: this.formData.domainId,
              domainName: this.formData.domainName,
              targetId: this.formData.targetId,
              targetType: this.formData.targetType,
              resourceType: this.formData.resourceType,
              publishStatus: this.formData.publishStatus,
              serviceParamsMap: {
                binding: this.formData.serviceParamsMap.binding,
                httpMethod: this.formData.serviceParamsMap.httpMethod
              },
              commonConf: {
                enableMonitor: this.formData.commonConf.enableMonitor,
                logRequestBody: this.formData.commonConf.logRequestBody,
                logResponseBody: this.formData.commonConf.logResponseBody
              },
              disable: this.formData.disable
            }
          }
          forms.projectId = this.projectID
          httpForm.projectId = this.projectID
          ftpForm.projectId = this.projectID
          fileForm.projectId = this.projectID
          this.formData.projectId = this.projectID
          if (this.formData.protocol === 'File') {
            fileForm.messageType = fileForm.messageType.toLowerCase()
            saveProxyService(fileForm)
              .then((rt) => {
                if (rt.status === '200') {
                  this.$message({
                    message: '提交成功',
                    type: 'success'
                  })
                  this.$emit('confirm')
                }
              })
              .catch((err) => {
                const data = err.data || []
                const hint = [
                  { fieName: '名称', field: 'name' },
                  { fieName: '说明', field: 'description' },
                  { fieName: '目标', field: 'targetService.name' },
                  { fieName: '消息类型', field: 'messageType' },
                  {
                    fieName: 'Http Method',
                    field: 'connectorSrvParamsMap.httpMethod'
                  },
                  { fieName: '报文格式', field: 'payloadType' },
                  { fieName: '定义文件类型', field: 'defineFileType' },
                  { fieName: '请求报文', field: 'defineFile' },
                  { fieName: '响应报文', field: 'secondDefineFile' },
                  { fieName: '端点', field: 'serviceParamsMap.binding' },
                  { fieName: '协议', field: 'protocol' },
                  { fieName: '适配器', field: 'connector.name' },
                  { fieName: '端点uri', field: 'uri' },
                  { fieName: 'sql', field: 'connectorSrvParamsMap.sql' },
                  { fieName: '轮询间隔', field: 'connectorSrvParamsMap.delay' },
                  { fieName: '使用cron', field: 'connectorSrvParamsMap.cron' },
                  {
                    fieName: '轮询类型',
                    field: 'connectorSrvParamsMap.pollType'
                  },
                  {
                    fieName: '延迟启动',
                    field: 'connectorSrvParamsMap.initialDelay'
                  },
                  {
                    fieName: '每次轮询数量',
                    field: 'connectorSrvParamsMap.maxMessagesPerPoll'
                  },
                  {
                    fieName: '成功后处理',
                    field: 'connectorSrvParamsMap.onConsume'
                  },
                  {
                    fieName: '失败后处理',
                    field: 'connectorSrvParamsMap.onConsumeFailed'
                  },
                  {
                    fieName: '贪婪模式',
                    field: 'connectorSrvParamsMap.greedy'
                  },
                  {
                    fieName: '出错时中断',
                    field: 'connectorSrvParamsMap.breakBatchOnConsumeFail'
                  },
                  {
                    fieName: '启用事务',
                    field: 'connectorSrvParamsMap.transacted'
                  }
                ]
                checkFormData(data, hint)
              })
          } else if (this.formData.protocol === 'http') {
            httpForm.messageType = httpForm.messageType.toLowerCase()
            saveProxyService(httpForm)
              .then((rt) => {
                if (rt.status === '200') {
                  // this.httpLL.serviceId = rt.data.id
                  // if (!this.httpLL.id) {
                  //   this.httpLL.id = ''
                  // }
                  // kongInfoSave(this.httpLL).then(res => {
                  //   console.log(res)
                  // })
                  this.$message({
                    message: '提交成功',
                    type: 'success'
                  })
                  this.$emit('confirm')
                } else {
                  this.$message({
                    message: '存在重复的uri',
                    type: 'error'
                  })
                }
              })
              .catch((err) => {
                const data = err.data || []
                this.httpLL.isEnableRequestSizeLimiting = JSON.parse(
                  this.httpLL.isEnableRequestSizeLimiting
                )
                this.httpLL.isEnableRateLimiting = JSON.parse(
                  this.httpLL.isEnableRateLimiting
                )
                const hint = [
                  { fieName: '名称', field: 'name' },
                  { fieName: '说明', field: 'description' },
                  { fieName: '目标', field: 'targetService.name' },
                  { fieName: '消息类型', field: 'messageType' },
                  {
                    fieName: 'Http Method',
                    field: 'connectorSrvParamsMap.httpMethod'
                  },
                  { fieName: '报文格式', field: 'payloadType' },
                  { fieName: '定义文件类型', field: 'defineFileType' },
                  { fieName: '请求报文', field: 'defineFile' },
                  { fieName: '响应报文', field: 'secondDefineFile' },
                  { fieName: '端点', field: 'serviceParamsMap.binding' },
                  { fieName: '协议', field: 'protocol' },
                  { fieName: '适配器', field: 'connector.name' },
                  { fieName: '端点uri', field: 'uri' },
                  { fieName: 'sql', field: 'connectorSrvParamsMap.sql' },
                  { fieName: '轮询间隔', field: 'connectorSrvParamsMap.delay' },
                  { fieName: '使用cron', field: 'connectorSrvParamsMap.cron' },
                  {
                    fieName: '轮询类型',
                    field: 'connectorSrvParamsMap.pollType'
                  },
                  {
                    fieName: '延迟启动',
                    field: 'connectorSrvParamsMap.initialDelay'
                  },
                  {
                    fieName: '每次轮询数量',
                    field: 'connectorSrvParamsMap.maxMessagesPerPoll'
                  },
                  {
                    fieName: '成功后处理',
                    field: 'connectorSrvParamsMap.onConsume'
                  },
                  {
                    fieName: '失败后处理',
                    field: 'connectorSrvParamsMap.onConsumeFailed'
                  },
                  {
                    fieName: '贪婪模式',
                    field: 'connectorSrvParamsMap.greedy'
                  },
                  {
                    fieName: '出错时中断',
                    field: 'connectorSrvParamsMap.breakBatchOnConsumeFail'
                  },
                  {
                    fieName: '启用事务',
                    field: 'connectorSrvParamsMap.transacted'
                  },
                  { fieName: '验证策略', field: 'securityConf.authStrategy' }
                ]
                checkFormData(data, hint)
              })
          } else if (this.formData.protocol === 'Ftp') {
            ftpForm.messageType = ftpForm.messageType.toLowerCase()
            saveProxyService(ftpForm)
              .then((rt) => {
                if (rt.status === '200') {
                  this.$message({
                    message: '提交成功',
                    type: 'success'
                  })
                  this.$emit('confirm')
                }
              })
              .catch((err) => {
                const data = err.data || []
                const hint = [
                  { fieName: '名称', field: 'name' },
                  { fieName: '说明', field: 'description' },
                  { fieName: '目标', field: 'targetService.name' },
                  { fieName: '消息类型', field: 'messageType' },
                  {
                    fieName: 'Http Method',
                    field: 'connectorSrvParamsMap.httpMethod'
                  },
                  { fieName: '报文格式', field: 'payloadType' },
                  { fieName: '定义文件类型', field: 'defineFileType' },
                  { fieName: '请求报文', field: 'defineFile' },
                  { fieName: '响应报文', field: 'secondDefineFile' },
                  { fieName: '端点', field: 'serviceParamsMap.binding' },
                  { fieName: '协议', field: 'protocol' },
                  { fieName: '适配器', field: 'connector.name' },
                  { fieName: '端点uri', field: 'uri' },
                  { fieName: 'sql', field: 'connectorSrvParamsMap.sql' },
                  { fieName: '轮询间隔', field: 'connectorSrvParamsMap.delay' },
                  { fieName: '使用cron', field: 'connectorSrvParamsMap.cron' },
                  {
                    fieName: '轮询类型',
                    field: 'connectorSrvParamsMap.pollType'
                  },
                  {
                    fieName: '延迟启动',
                    field: 'connectorSrvParamsMap.initialDelay'
                  },
                  {
                    fieName: '每次轮询数量',
                    field: 'connectorSrvParamsMap.maxMessagesPerPoll'
                  },
                  {
                    fieName: '成功后处理',
                    field: 'connectorSrvParamsMap.onConsume'
                  },
                  {
                    fieName: '失败后处理',
                    field: 'connectorSrvParamsMap.onConsumeFailed'
                  },
                  {
                    fieName: '贪婪模式',
                    field: 'connectorSrvParamsMap.greedy'
                  },
                  {
                    fieName: '出错时中断',
                    field: 'connectorSrvParamsMap.breakBatchOnConsumeFail'
                  },
                  {
                    fieName: '启用事务',
                    field: 'connectorSrvParamsMap.transacted'
                  }
                ]
                checkFormData(data, hint)
              })
          } else if (this.formData.protocol === 'Jms') {
            forms.messageType = forms.messageType.toLowerCase()
            saveProxyService(forms)
              .then((rt) => {
                if (rt.status === '200') {
                  this.$message({
                    message: '提交成功',
                    type: 'success'
                  })
                  this.$emit('confirm')
                }
              })
              .catch((err) => {
                const data = err.data || []
                const hint = [
                  { fieName: '名称', field: 'name' },
                  { fieName: '说明', field: 'description' },
                  { fieName: '目标', field: 'targetService.name' },
                  { fieName: '消息类型', field: 'messageType' },
                  {
                    fieName: 'Http Method',
                    field: 'connectorSrvParamsMap.httpMethod'
                  },
                  { fieName: '报文格式', field: 'payloadType' },
                  { fieName: '定义文件类型', field: 'defineFileType' },
                  { fieName: '请求报文', field: 'defineFile' },
                  { fieName: '响应报文', field: 'secondDefineFile' },
                  { fieName: '端点', field: 'serviceParamsMap.binding' },
                  { fieName: '协议', field: 'protocol' },
                  { fieName: '适配器', field: 'connector.name' },
                  { fieName: '端点uri', field: 'uri' },
                  { fieName: 'sql', field: 'connectorSrvParamsMap.sql' },
                  { fieName: '轮询间隔', field: 'connectorSrvParamsMap.delay' },
                  { fieName: '使用cron', field: 'connectorSrvParamsMap.cron' },
                  {
                    fieName: '轮询类型',
                    field: 'connectorSrvParamsMap.pollType'
                  },
                  {
                    fieName: '延迟启动',
                    field: 'connectorSrvParamsMap.initialDelay'
                  },
                  {
                    fieName: '每次轮询数量',
                    field: 'connectorSrvParamsMap.maxMessagesPerPoll'
                  },
                  {
                    fieName: '成功后处理',
                    field: 'connectorSrvParamsMap.onConsume'
                  },
                  {
                    fieName: '失败后处理',
                    field: 'connectorSrvParamsMap.onConsumeFailed'
                  },
                  {
                    fieName: '贪婪模式',
                    field: 'connectorSrvParamsMap.greedy'
                  },
                  {
                    fieName: '出错时中断',
                    field: 'connectorSrvParamsMap.breakBatchOnConsumeFail'
                  },
                  {
                    fieName: '启用事务',
                    field: 'connectorSrvParamsMap.transacted'
                  }
                ]
                checkFormData(data, hint)
              })
          } else {
            this.formData.messageType = this.formData.messageType.toLowerCase()
            saveProxyService(this.formData)
              .then((rt) => {
                if (rt.status === '200') {
                  this.$message({
                    message: '提交成功',
                    type: 'success'
                  })
                  this.$emit('confirm')
                }
              })
              .catch((err) => {
                const data = err.data || []
                const hint = [
                  { fieName: '名称', field: 'name' },
                  { fieName: '说明', field: 'description' },
                  { fieName: '目标', field: 'targetService.name' },
                  // { fieName: '消息类型', field: 'messageType' },
                  {
                    fieName: 'Http Method',
                    field: 'connectorSrvParamsMap.httpMethod'
                  },
                  { fieName: '报文格式', field: 'payloadType' },
                  { fieName: '定义文件类型', field: 'defineFileType' },
                  { fieName: '请求报文', field: 'defineFile' },
                  { fieName: '响应报文', field: 'secondDefineFile' },
                  { fieName: '端点', field: 'serviceParamsMap.binding' },
                  { fieName: '协议', field: 'protocol' },
                  { fieName: '适配器', field: 'connector.name' },
                  { fieName: '端点uri', field: 'uri' },
                  { fieName: 'sql', field: 'connectorSrvParamsMap.sql' },
                  { fieName: '轮询间隔', field: 'connectorSrvParamsMap.delay' },
                  { fieName: '使用cron', field: 'connectorSrvParamsMap.cron' },
                  {
                    fieName: '轮询类型',
                    field: 'connectorSrvParamsMap.pollType'
                  },
                  {
                    fieName: '延迟启动',
                    field: 'connectorSrvParamsMap.initialDelay'
                  },
                  {
                    fieName: '每次轮询数量',
                    field: 'connectorSrvParamsMap.maxMessagesPerPoll'
                  },
                  {
                    fieName: '成功后处理',
                    field: 'connectorSrvParamsMap.onConsume'
                  },
                  {
                    fieName: '失败后处理',
                    field: 'connectorSrvParamsMap.onConsumeFailed'
                  },
                  {
                    fieName: '贪婪模式',
                    field: 'connectorSrvParamsMap.greedy'
                  },
                  {
                    fieName: '出错时中断',
                    field: 'connectorSrvParamsMap.breakBatchOnConsumeFail'
                  },
                  {
                    fieName: '启用事务',
                    field: 'connectorSrvParamsMap.transacted'
                  }
                ]
                checkFormData(data, hint)
              })
          }
        } else {
          // console.log('validFaild', obj)
          // console.log('validFaild111', Object.values(obj)[0][0].message)
          this.$message.warning(
            Object.values(obj)[0][0].message || '请将信息填写完整。'
          )
          if (
            Object.values(obj)[0][0].message.indexOf('目标') !== -1 ||
            Object.values(obj)[0][0].message.indexOf('名称') !== -1 ||
            Object.values(obj)[0][0].message.indexOf('分组') !== -1
          ) {
            this.activeName = 'first'
          }
          if (
            Object.values(obj)[0][0].message.indexOf('端点uri') !== -1 ||
            Object.values(obj)[0][0].message.indexOf('请求方法') !== -1 ||
            Object.values(obj)[0][0].message.indexOf('分组') !== -1
          ) {
            this.activeName = 'fourth'
          }
        }
      })
    },
    // sql测试
    testSqlFun(type) {
      this.activeType = type
      if (!this.formData.connectorId) {
        this.$message.warning('请先选择适配器！')
        return
      }
      let sqlstr = ''
      if (type === 1) {
        if (!this.formData.connectorSrvParamsMap.sql) {
          this.$message.warning('请输入sql语句！')
          return
        }
        sqlstr = this.formData.connectorSrvParamsMap.sql
      }
      if (type === 2) {
        if (!this.formData.connectorSrvParamsMap.onConsume) {
          this.$message.warning('成功后处理不能为空！')
          return
        }
        sqlstr = this.formData.connectorSrvParamsMap.onConsume
      }
      if (type === 3) {
        if (!this.formData.connectorSrvParamsMap.onConsumeFailed) {
          this.$message.warning('失败后处理不能为空！')
          return
        }
        sqlstr = this.formData.connectorSrvParamsMap.onConsumeFailed
      }
      this.sqlFormData = {
        id: this.formData.connectorId,
        script: sqlstr
      }
      // console.log(this.sqlFormData, '适配器Sql')
      saveSql({
        id: this.formData.connectorId,
        script: sqlstr
      })
        .then((rt) => {
          if (rt.status === '200') {
            this.sqlData = Object.keys(rt.data)
            if (type === 1) {
              this.analysisData = rt.data
            }
            if (this.sqlData.length > 0) {
              this.testSqlVisible = true
            } else {
              scriptValidate({
                id: this.formData.connectorId,
                script: sqlstr,
                params: {}
              })
                .then((res) => {
                  if (type === 1) {
                    this.ispass = res.status === '200' ? 'true' : 'false'
                  }
                  if (type === 2) {
                    this.ispass1 = res.status === '200' ? 'true' : 'false'
                  }
                  if (type === 3) {
                    this.ispass2 = res.status === '200' ? 'true' : 'false'
                  }
                })
                .catch(() => {})
            }
          }
        })
        .catch(() => {})
    },
    handleResource(data) {
      this.filename = data.name
    },
    getStatus(data) {
      if (this.activeType === 1) {
        this.ispass = data
      }
      if (this.activeType === 2) {
        this.ispass1 = data
      }
      if (this.activeType === 3) {
        this.ispass2 = data
      }
    },
    // tree事件
    handleNodeClick(data) {},

    // 显示
    isshowdepend() {
      this.dependVisible = true
    },

    // 用户列表
    closeUserList(val) {
      this.userListVisible = val
    },
    getCheckeduserList(val, val2) {
      // console.log(val)
      var that = this
      that.userListVisible = false
      this.userList = {
        authUsers: val,
        authRoles: val2
      }
      that.formData.authAccountsMap = {
        authUsers: [],
        authRoles: []
      }
      val.map(function (item) {
        that.formData.authAccountsMap.authUsers.push(item.id)
      })
      val2.map(function (item) {
        that.formData.authAccountsMap.authRoles.push(item.id)
      })
      // console.log(that.formData.authAccountsMap)
    }
  }
}
</script>

<style type="text/scss" lang="scss" scoped>
.radios {
  position: relative;
  width: 100%;

  /deep/ .el-radio__input {
    position: relative;
    top: 22px;
    left: 18px;
  }
}

.el-icon-check {
  color: #67c23a;
  font-size: 20px;
  font-weight: 600;
  margin: 0 10px;
}

.el-icon-close {
  color: #f56c6c;
  font-size: 20px;
  font-weight: 600;
  margin: 0 10px;
}

.changgename {
  cursor: pointer;
}
</style>
