<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div class="app-container">
    <el-card class="box-carde">
      <div slot="header" class="clearfix">
        <span>通道管理</span>
        <el-button style="float: right;padding:3px 10px 3px 3px;" type="text" :loading="btnLonding"
                   @click="uploadinfoShow">参考信息
        </el-button>

        <!--          <el-button style="margin-left: 300px" type="text">参考信息</el-button>-->
      </div>

      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="上报对象" name="first" :disabled="btnLonding">
          <el-button type="primary" round @click="insertEventUploadObject" style="width: 15%;margin-bottom: 10px"
                     :loading="btnLonding">新增上报对象
          </el-button>

          <vxe-table
            align="center"
            :loading="loading"
            ref="xTable"
            auto-resize
            border
            resizable
            highlight-current-row
            show-overflow
            :data="tableData"
            v-show="showTable"
            :expand-config="{labelField: 'channelNo', expandAll: false}"
          >
            <vxe-table-column title="上报对象信息">
              <vxe-table-column field="uploadObjectName" title="上报对象名称"></vxe-table-column>
              <vxe-table-column field="objectNo" title="上报对象编号"></vxe-table-column>
              <vxe-table-column field="uploadFileType" title="上报文件类型"></vxe-table-column>
              <vxe-table-column field="uploadFileCharSetEnum" title="上报文件字符集"></vxe-table-column>
              <vxe-table-column field="uploadProtocolEnum" title="上报协议"></vxe-table-column>
              <vxe-table-column field="uploadObjectRemarks" title="上报对象备注"></vxe-table-column>
              <!--<vxe-table-column field="uploadObjectName" title="上报对象名称" width="15%"></vxe-table-column>
              <vxe-table-column field="objectNo" title="上报对象编号" width="8%"></vxe-table-column>
              <vxe-table-column field="uploadFileType" title="上报文件类型" width="15%"></vxe-table-column>
              <vxe-table-column field="uploadFileCharSetEnum" title="上报文件字符集" width="10%"></vxe-table-column>
              <vxe-table-column field="uploadProtocolEnum" title="上报协议" width="12%"></vxe-table-column>
              <vxe-table-column field="uploadD5000" title="上报D5000" :formatter="formateuploadD5000" width="6%"></vxe-table-column>
              <vxe-table-column field="uploadObjectRemarks" title="上报对象备注" width="10%"></vxe-table-column>-->
              <vxe-table-column width="150px" align="center" title="操作">
                <template v-slot="{ row }">
                  <el-button
                    style="padding: 3px 4px 3px 4px;margin: 2px"
                    size="mini"
                    icon="el-icon-edit"
                    @click="editRowEventUploadObject(row)">编辑
                  </el-button>
                  <el-button
                    type="danger"
                    style="padding: 3px 4px 3px 4px;margin: 2px"
                    size="mini"
                    icon="el-icon-delete"
                    @click="removeUploadObject(row)">删除
                  </el-button>
                </template>
              </vxe-table-column>
            </vxe-table-column>
          </vxe-table>
        </el-tab-pane>
        <el-tab-pane label="通道配置" name="secend" :disabled="btnLonding">
          <el-button type="primary" round @click="insertEvent" style="width: 15%;margin-bottom: 10px"
                     :loading="btnLonding" :disabled="disabledBtn">新增通道
          </el-button>
          <vxe-table
            align="center"
            :loading="loading"
            ref="sTable"
            auto-resize
            border
            resizable
            highlight-current-row
            show-overflow
            :data="channelData"
            v-show="showTable"
          >
            <vxe-table-column title="上报通道信息">
              <vxe-table-column type="expand" title="查看更多" width="8%">
                <template v-slot:content="{ row, rowIndex }">
                  <table style="width: 100%;text-align: left"
                         v-show="row.uploadObjectId.uploadProtocolEnum == '102服务端' || row.uploadObjectId.uploadProtocolEnum == '102山东客户端' || row.uploadObjectId.uploadProtocolEnum == '102山东服务端'||row.uploadObjectId.uploadProtocolEnum == '102浙江客户端'">
                    <tr>
                      <td>本地IP：{{ row.localIp }}</td>
                      <td>本地端口：{{ row.localPort }}</td>
                      <td>名称长度：{{ row.uploadFileNameLengthEnum }}</td>
                    </tr>
                    <tr>
                      <td>远端IP：{{ row.remoteIp }}</td>
                      <td>远端端口：{{ row.remotePort }}</td>
                      <td>单次传输字节：{{ row.uploadFileSingleByteEnum }}</td>
                    </tr>
                  </table>
                  <table style="width: 100%;text-align: left;" v-show="row.uploadObjectId.uploadProtocolEnum=='ftp'">
                    <tr>
                      <td>远端IP：{{ row.remoteIp }}</td>
                      <td>远端端口：{{ row.remotePort }}</td>
                      <td v-if="row.backupC!=1">服务端路径：{{ row.pathService }}</td>
                    </tr>
                    <tr>
                      <td>用户名：{{ row.uploadUserName }}</td>
                      <td>密码：{{ row.uploadPassword }}</td>
                      <td>FTP模式：{{ row.ftpPassiveModeEnum }}</td>
                    </tr>

                    <tr v-if="row.backupC==1" v-for="item in row.backupA">
                      <td>{{ item.label }}：{{ item.url }}</td>
                    </tr>

                  </table>
                  <table style="width: 100%;text-align: left" v-show="row.uploadObjectId.uploadProtocolEnum=='sftp'">
                    <tr>
                      <td>远端IP：{{ row.remoteIp }}</td>
                      <td>远端端口：{{ row.remotePort }}</td>
                      <td>用户名：{{ row.uploadUserName }}</td>
                      <!--<td>FTP模式：{{row.ftpPassiveModeEnum}}</td>-->
                    </tr>
                    <tr>
                      <td>sftp上报方式：{{ row.sftpConnectModeEnum == 'E1' ? "密码连接" : "密钥连接" }}</td>
                      <td v-if="row.backupC!=1">服务端路径：{{ row.pathService }}</td>
                      <!--<td>FTP/SFTP密码：{{row.uploadPassword}}</td>-->
                    </tr>
                    <tr v-if="row.backupC==1" v-for="item in row.backupA">
                      <td>{{ item.label }}：{{ item.url }}</td>
                    </tr>
                    <tr>
                      <td v-show="row.sftpConnectModeEnum == 'E1'">密码：{{ row.uploadPassword }}</td>
                      <td v-show="row.sftpConnectModeEnum == 'E2'">SFTP秘钥路径：{{ row.keyFilePath }}</td>
                      <td v-show="row.sftpConnectModeEnum == 'E2'">SFPT秘钥密码：{{ row.passPhrase }}</td>
                    </tr>
                  </table>
                </template>
              </vxe-table-column>
              <vxe-table-column field="uploadObjectId.uploadObjectName" title="上报对象"></vxe-table-column>
              <vxe-table-column field="channelName" title="通道名称"></vxe-table-column>
              <vxe-table-column field="channelStatusEnum" title="通道状态" :formatter="formatechannelStatusEnum"
                                width="200px"></vxe-table-column>
              <vxe-table-column field="channelRemarks" title="通道备注"></vxe-table-column>
              <vxe-table-column width="15%" align="center" title="操作">
                <template v-slot="{ row }">
                  <template>
                    <el-button
                      style="padding: 3px 4px 3px 4px;margin: 2px"
                      size="mini"
                      icon="el-icon-edit"
                      @click="editRowEvent(row)">编辑
                    </el-button>
                    <el-button
                      type="danger"
                      style="padding: 3px 4px 3px 4px;margin: 2px"
                      size="mini"
                      icon="el-icon-delete"
                      @click="removeEvent(row)">删除
                    </el-button>
                  </template>
                </template>
              </vxe-table-column>
            </vxe-table-column>
          </vxe-table>
        </el-tab-pane>

        <!--9.1-->
        <el-tab-pane label="文件类型配置" name="third" :disabled="btnLonding">
          <el-button type="primary" round @click="insertEventCode" style="width: 15%;margin-bottom: 10px"
                     :loading="btnLonding" :disabled="disabledBtn">新增
          </el-button>
          <el-button type="primary" round @click="refreshCode" style="width: 15%;margin-bottom: 10px"
                     :loading="btnLonding" :disabled="disabledBtn">同步基础code码
          </el-button>
          <vxe-table
            highlight-current-row
            :keep-source="true"
            align="center"
            export-config
            :loading="loading"
            ref="cTable"
            auto-resize
            border
            resizable
            show-overflow
            :edit-rules="rulesCode"
            :data="uploadFileCodeData"
            v-show="showTable"
            :edit-config="{trigger: 'manual', mode: 'row',autoClear: false,icon:'none'}"
          >
            <vxe-table-column title="文件类型Code码配置">
              <vxe-table-column field="fileTypeEnum" title="上报文件类型"
                                :edit-render="{name: '$select', options: uploadFileTypeList}"></vxe-table-column>
              <vxe-table-column field="fileTypeCode" title="102文件code码"
                                :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
              <vxe-table-column width="15%" align="center" title="操作">
                <template v-slot="{ row }">
                  <template v-if="$refs.cTable.isActiveByRow(row)">
                    <el-button
                      style="padding: 3px 4px 3px 4px;margin: 2px"
                      size="mini"
                      icon="el-icon-edit"
                      @click="saveRowEventCode(row)"
                      :loading="saveLoding">保存
                    </el-button>
                    <el-button
                      style="padding: 3px 4px 3px 4px;margin: 2px"
                      size="mini"
                      icon="el-icon-edit"
                      @click="cancelRowEventCode(row)">取消
                    </el-button>
                  </template>
                  <template v-else>
                    <el-button
                      style="padding: 3px 4px 3px 4px;margin: 2px"
                      size="mini"
                      icon="el-icon-edit"
                      @click="editRowEventCode(row)"
                      :loading="btnLonding">编辑
                    </el-button>
                    <el-button
                      type="danger"
                      style="padding: 3px 4px 3px 4px;margin: 2px"
                      size="mini"
                      icon="el-icon-delete"
                      @click="removeEventCode(row)"
                      :loading=btnLonding>删除
                    </el-button>
                  </template>
                </template>
              </vxe-table-column>
            </vxe-table-column>
          </vxe-table>
        </el-tab-pane>
        <!--9.1-->

      </el-tabs>
    </el-card>
    <div>
      <el-dialog :visible.sync="addVisible" :close-on-click-modal='false' :before-close="closeDialogAdd" width="70%">
        <el-form v-loading="saveChannelLoding" ref="form" :model="form" :rules="rules">
          <fieldset>
            <legend>通道基本信息</legend>
            <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
              <el-col :span="10" :offset="1">
                <el-form-item label="上报对象：" prop="uploadObjectId" label-width="150px" style="min-width: 110px">
                  <el-select v-model="form.uploadObjectId" placeholder="请选择" @change="change"
                             style="width: 100%">
                    <el-option
                      v-for="item in this.tableData"
                      :key="item.id"
                      :label="item.uploadObjectName"
                      :value="item.id"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="1">
                <el-form-item label="通道名称：" prop="channelName" label-width="150px" style="min-width: 110px">
                  <el-input v-model="form.channelName" placeholder="必填项"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="10" :offset="1">
                <el-form-item label="通道状态：" prop="channelStatusEnum" label-width="150px" style="min-width: 110px">
                  <el-select v-model="form.channelStatusEnum" placeholder="请选择"
                             style="width: 100%">
                    <el-option
                      v-for="item in this.channelStatusEnumList"
                      :key="item.key"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="1">
                <el-form-item label="通道备注：" label-width="150px" prop="channelRemarks">
                  <el-input v-model="form.channelRemarks" placeholder="选填项"/>
                </el-form-item>
              </el-col>
            </el-row>
          </fieldset>
          <div id="102Mode" ref="Mode102" style="display: none">
            <fieldset>
              <legend>102s/102m</legend>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                <el-col :span="10" :offset="1">
                  <el-form-item label="本地IP：" prop="localIp" label-width="150px">
                    <el-input v-model="form.localIp" :maxlength="16" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                  <el-form-item label="本地端口：" prop="localPort" label-width="150px">
                    <el-input v-model="form.localPort" :maxlength="11" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                <el-col :span="10" :offset="1">
                  <el-form-item label="远端IP：" prop="remoteIp" label-width="150px">
                    <el-input v-model="form.remoteIp" :maxlength="16" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                  <el-form-item label="远端端口：" prop="remotePort" label-width="150px">
                    <el-input v-model="form.remotePort" :maxlength="11" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <template v-if="this.type=='102山东服务端'||this.type=='102山东客户端'">
                <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                  <el-col :span="10" :offset="1">
                    <el-form-item label="用户名：" prop="uploadUserName" label-width="150px">
                      <el-input v-model="form.uploadUserName" placeholder="必填项"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="10" :offset="1">
                    <el-form-item label="密码：" prop="uploadPassword" label-width="150px">
                      <el-input v-model="form.uploadPassword" placeholder="必填项"/>
                    </el-form-item>
                  </el-col>
                </el-row>
              </template>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                <el-col :span="10" :offset="1">
                  <el-form-item label="上报文件名称长度：" label-width="150px" prop="uploadFileNameLengthEnum">
                    <el-select v-model="form.uploadFileNameLengthEnum" placeholder="请选择"
                               style="width: 100%">
                      <el-option
                        v-for="item in this.uploadFileNameLengthEnumList"
                        :key="item.key"
                        :label="item.label"
                        :value="item.value"/>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                  <el-form-item label="上报文件单次传输字节：" label-width="200px" prop="uploadFileSingleByteEnum">
                    <el-select v-model="form.uploadFileSingleByteEnum" placeholder="请选择"
                               style="width: 100%">
                      <el-option
                        v-for="item in this.uploadFileSingleByteEnumList"
                        :key="item.key"
                        :label="item.label"
                        :value="item.value"/>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
            </fieldset>
          </div>
          <div id="ftpMode" ref="ftpMode" style="display: none">
            <fieldset>
              <legend>ftp</legend>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                <el-col :span="10" :offset="1">
                  <el-form-item label="远端IP：" prop="remoteIp" label-width="150px">
                    <el-input v-model="form.remoteIp" :maxlength="16" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                  <el-form-item label="远端端口：" prop="remotePort" label-width="150px">
                    <el-input v-model="form.remotePort" :maxlength="11" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                <el-col :span="10" :offset="1">
                  <el-form-item label="用户名：" prop="uploadUserName" label-width="150px">
                    <el-input v-model="form.uploadUserName" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                  <el-form-item label="密码：" prop="uploadPassword" label-width="150px">
                    <el-input v-model="form.uploadPassword" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                <el-col :span="10" :offset="1">
                  <el-form-item label="ftp模式：" prop="ftpPassiveModeEnum" label-width="150px">
                    <el-select v-model="form.ftpPassiveModeEnum" placeholder="请选择" filterable
                               style="width: 100%">
                      <el-option
                        v-for="item in this.ftpPassiveModeEnumList"
                        :key="item.key"
                        :label="item.label"
                        :value="item.value"/>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                  <el-form-item label="是否多路径：" label-width="150px" prop="backupC">
                    <el-select v-model="form.backupC" placeholder="请选择" filterable
                               style="width: 100%">
                      <el-option
                        v-for="item in this.isMoreURL"
                        :key="item.key"
                        :label="item.label"
                        :value="item.value"/>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between" v-show="form.backupC!=1">
                <el-col :span="10" :offset="1">
                  <el-form-item label="服务端路径：" label-width="150px" prop="pathService">
                    <el-input v-model="form.pathService" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between" v-show="form.backupC==1">
                <el-col :span="10" :offset="1" v-for="(item,i) in this.fileTypeListForUrl">
                  <el-form :model="item" label-width="100px" class="demo-dynamic">
                    <el-form-item :label="item.label" prop="url"
                                  :rules=" { required: true, message: '地址不能为空', trigger: 'blur' }" label-width="150px">
                      <el-input v-model="item.url" placeholder="必填项"/>
                    </el-form-item>
                  </el-form>
                </el-col>
              </el-row>
            </fieldset>
          </div>
          <div id="sftp" ref="sftp" style="display: none">
            <fieldset>
              <legend>sftp</legend>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                <el-col :span="10" :offset="1">
                  <el-form-item label="远端IP：" prop="remoteIp" label-width="150px">
                    <el-input v-model="form.remoteIp" :maxlength="16" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                  <el-form-item label="远端端口：" prop="remotePort" label-width="150px">
                    <el-input v-model="form.remotePort" :maxlength="11" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
                <el-col :span="10" :offset="1">
                  <el-form-item label="用户名：" prop="uploadUserName" label-width="150px">
                    <el-input v-model="form.uploadUserName" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
                <el-col :span="10" :offset="1">
                  <el-form-item label="SFTP上报方式：" prop="sftpConnectModeEnum" label-width="150px">
                    <el-select v-model="form.sftpConnectModeEnum" placeholder="请选择" filterable
                               style="width: 100%" @change="changeConnectModEnum">
                      <el-option
                        v-for="item in sftpConnectModeEnum"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"/>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="10" :offset="1">
                  <el-form-item label="是否多路径：" label-width="150px" prop="backupC">
                    <el-select v-model="form.backupC" placeholder="请选择" filterable
                               style="width: 100%">
                      <el-option
                        v-for="item in this.isMoreURL"
                        :key="item.key"
                        :label="item.label"
                        :value="item.value"/>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between" v-show="form.backupC!=1">
                <el-col :span="10" :offset="1">
                  <el-form-item label="服务端路径：" label-width="150px" prop="pathService">
                    <el-input v-model="form.pathService" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between" v-show="form.backupC==1">
                <el-col :span="10" :offset="1" v-for="(item,i) in this.fileTypeListForUrl">
                  <el-form :model="item" label-width="100px" class="demo-dynamic">
                    <el-form-item :label="item.label" prop="url"
                                  :rules=" { required: true, message: '地址不能为空', trigger: 'blur' }" label-width="150px">
                      <el-input v-model="item.url" placeholder="必填项"/>
                    </el-form-item>
                  </el-form>
                </el-col>
              </el-row>
              <el-row v-show="sftpPassword">
                <el-col :span="10" :offset="1">
                  <el-form-item label="密码：" prop="uploadPassword" label-width="150px" ref="password">
                    <el-input v-model="form.uploadPassword" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between" v-show="sftpKey">
                <el-col :span="20" :offset="1"><!--style="display: none"-->
                  <el-form-item label="SFTP密钥路径：" label-width="150px" prop="keyFilePath">
                    <el-input v-model="form.keyFilePath" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between" v-show="sftpKey">
                <el-col :span="20" :offset="1">
                  <el-form-item label="SFTP密钥密码：" label-width="150px" prop="passPhrase">
                    <el-input v-model="form.passPhrase" placeholder="必填项"/>
                  </el-form-item>
                </el-col>
              </el-row>
            </fieldset>

          </div>
        </el-form>
        <span slot="footer" class="dialog-footer">
              <el-button :loading="saveChannelLoding" type="primary"
                         @click="save('form')">保 存</el-button>
          <!--              <el-button v-loading="tableLoading" @click="resetForm1('form')" v-show="this.add">重 置</el-button>-->
        </span>
      </el-dialog>
    </div>
    <div>
      <el-dialog :visible.sync="addVisibleUploadObject" :close-on-click-modal='false'
                 :before-close="closeDialogAddUpload" width="70%">
        <el-form v-loading="tableLoading" ref="rulesObject" :model="form" :rules="rulesObject">
          <fieldset>
            <legend>上报对象基本信息</legend>
            <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
              <el-col :span="10" :offset="1">
                <el-form-item label="上报对象名称：" prop="uploadObjectName" label-width="150px" style="min-width: 100px">
                  <el-input v-model="form.uploadObjectName" placeholder="必填项" maxlength="32"/>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="1">
                <el-form-item label="上报对象编号：" prop="objectNo" label-width="150px" style="min-width: 110px">
                  <el-input v-model="form.objectNo" placeholder="必填项" maxlength="32"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
              <el-col :span="10" :offset="1">
                <el-form-item label="上报文件类型：" prop="uploadFileType" label-width="150px" style="min-width: 110px">
                  <el-select v-model="form.uploadFileType" multiple filterable placeholder="请选择" style="width: 100%">
                    <el-option
                      v-for="item in this.uploadFileTypeList"
                      :key="item.key"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="1">
                <el-form-item label="上报文件字符集：" prop="uploadFileCharSetEnum" label-width="150px"
                              style="min-width: 110px">
                  <el-select v-model="form.uploadFileCharSetEnum" placeholder="请选择" filterable style="width: 100%">
                    <el-option
                      v-for="item in this.uploadFileCharSetEnumList"
                      :key="item.key"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row style="gutter:30" class="row-bg el-row-two" justify="space-between">
              <el-col :span="10" :offset="1">
                <el-form-item label="上报协议：" prop="uploadProtocolEnum" label-width="150px">
                  <el-select v-model="form.uploadProtocolEnum" placeholder="请选择" filterable style="width: 100%"
                             @change="updateTypeWarning(form.id,form.uploadProtocolEnum)">
                    <el-option
                      v-for="item in this.uploadProtocolEnumList"
                      :key="item.key"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="10" :offset="1">
                <el-form-item label="上报对象备注：" prop="uploadObjectRemarks" label-width="150px" style="min-width: 110px">
                  <el-input v-model="form.uploadObjectRemarks" placeholder="选填项" maxlength="85"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row >
              <el-col :span="10" :offset="1">
                <el-form-item label="上报嘉越D5000：" prop="uploadD5000" label-width="150px" :style="{'display':'none'}">
                  <el-select v-model="form.uploadD5000" placeholder="请选择" filterable style="width: 100%">
                    <el-option
                      v-for="item in uploadD5000List"
                      :key="item.key"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </fieldset>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button :loading="saveObjectLoding" type="primary"
                       @click="saveUploadObject('rulesObject')">保 存</el-button>
          <!--            <el-button v-loading="tableLoading" @click="resetForm('rulesObject')" v-show="this.add">重 置</el-button>-->
        </span>
      </el-dialog>
    </div>
    <div>
      <el-dialog :visible.sync="uploadInfoVisible" :close-on-click-modal='false' :before-close="uploadInfoCloseDialog"
                 width="70%">
        <fieldset>
          <legend>上报信息</legend>
          <div style="min-height: 500px;float: left">
            <el-cascader-panel style="width: 90%;height: 600px" size="medium" :options="provinceData" v-model="province"
                               @change="getUploadInfoData"></el-cascader-panel>
          </div>
          <div style="float: right;width: 85%">
            <vxe-table
              align="center"
              :loading="loading"
              ref="iTable"
              auto-resize
              border
              resizable
              highlight-current-row
              show-overflow
              :data="uploadInfoData"
              v-show="showTable"
              :expand-config="{expandAll: false}"
              max-height="600px"
            >
              <vxe-table-column field="elName" title="场站名称"></vxe-table-column>
              <vxe-table-column field="uploadObjectName" title="对象名称"></vxe-table-column>
              <vxe-table-column field="uploadProtocolEnum" title="上报协议"></vxe-table-column>
              <vxe-table-column field="fileType" title="上报文件类型"></vxe-table-column>
              <vxe-table-column field="uploadFileCharSetEnum" title="字符集"></vxe-table-column>
              <vxe-table-column field="channelName" title="通道名称"></vxe-table-column>
              <vxe-table-column field="uploadFileNameLengthEnum" title="文件名称长度"></vxe-table-column>
              <vxe-table-column field="uploadFileSingleByteEnum" title="文件单次传输字节"></vxe-table-column>
            </vxe-table>
          </div>

        </fieldset>
      </el-dialog>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    const checkObjectNo = (rule, value, callback) => {
      var v6 = this.tableData
      if (this.form.objectNo == null || this.form.objectNo === '') {
        callback(new Error('不许为空'))
      }
      for (let i = 0; i < v6.length; i++) {
        if (this.form.id == '' || this.form.id == undefined) {
          // 新增
          if ((this.form.objectNo == v6[i].objectNo)) {
            callback(new Error('上报对象编号不能重复'))
          }
        } else {
          // 修改
          if (this.objectId != v6[i].id) {
            if (this.form.objectNo == v6[i].objectNo) {
              callback(new Error('上报对象编号不能重复'))
            }
          }
        }
      }
      callback()
    }
    const checkObjectName = (rule, value, callback) => {
      var s6 = this.tableData
      if (this.form.uploadObjectName == null || this.form.uploadObjectName === '') {
        callback(new Error('不许为空'))
      }
      for (let i = 0; i < s6.length; i++) {
        if (this.form.id == '' || this.form.id == undefined) {
          // 新增
          if ((this.form.uploadObjectName == s6[i].uploadObjectName)) {
            callback(new Error('上报对象名称不能重复'))
          }
        } else {
          // 修改
          if (this.objectId != s6[i].id) {
            if ((this.form.uploadObjectName == s6[i].uploadObjectName)) {
              callback(new Error('上报对象名称不能重复'))
            }
          }
        }
      }
      callback()
    }
    const checkChannelNo = (rule, value, callback) => {
      var v6 = this.channelData
      if (this.form.channelNo == null || this.form.channelNo === '') {
        callback(new Error('不许为空'))
      }
      for (let i = 0; i < v6.length; i++) {
        if (this.form.id == '' || this.form.id == undefined) {
          // 新增
          if ((this.form.channelNo == v6[i].channelNo)) {
            callback(new Error('通道号不能重复'))
          }
        } else {
          // 修改
          if (this.channelId != v6[i].id) {
            if (this.form.channelNo == v6[i].channelNo) {
              callback(new Error('通道号不能重复'))
            }
          }
        }
      }
      callback()
    }
    const checkChannelName = (rule, value, callback) => {
      var s6 = this.channelData
      if (this.form.channelName == null || this.form.channelName === '') {
        callback(new Error('不许为空'))
      }
      for (let i = 0; i < s6.length; i++) {
        if (this.form.id == '' || this.form.id == undefined) {
          // 新增
          if ((this.form.channelName == s6[i].channelName)) {
            callback(new Error('通道名称不能重复'))
          }
        } else {
          // 修改
          if (this.channelId != s6[i].id) {
            if ((this.form.channelName == s6[i].channelName)) {
              callback(new Error('通道名称不能重复'))
            }
          }
        }
      }
      callback()
    }
    const checklocalIp = (rule, value, callback) => {
      var v6 = this.channelData
      if (this.form.localIp == null || this.form.localIp === '') {
        callback(new Error('不许为空'))
      }
      var reg = /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/;
      if (!reg.test(this.form.localIp)) {
        callback(new Error('请填写正确的ip'))
      }
      for (let i = 0; i < v6.length; i++) {
        if (this.form.id == '' || this.form.id == undefined) {
          // 新增
          if ((this.form.localIp == v6[i].localIp)) {
            callback(new Error('本机Ip不能重复'))
          }
        } else {
          // 修改
          if (this.channelId != v6[i].id) {
            if (this.form.localIp == v6[i].localIp) {
              callback(new Error('本机Ip不能重复'))
            }
          }
        }
      }
      callback()
    }
    const checklocalPort = (rule, value, callback) => {
      var v6 = this.channelData
      if (this.form.localPort == null || this.form.localPort === '') {
        callback(new Error('不许为空'))
      }
      var reg = /^[0-9]*$/;
      if (!reg.test(this.form.localPort)) {
        callback(new Error('请填写正确的端口号'))
      }
      for (let i = 0; i < v6.length; i++) {
        if (this.form.id == '' || this.form.id == undefined) {
          // 新增
          if ((this.form.localPort == v6[i].localPort)) {
            callback(new Error('本机端口不能重复'))
          }
        } else {
          // 修改
          if (this.channelId != v6[i].id) {
            if (this.form.localPort == v6[i].localPort) {
              callback(new Error('本机端口不能重复'))
            }
          }
        }
      }
      callback()
    }
    const checkRemoteIp = (rule, value, callback) => {
      var v6 = this.channelData
      if (this.form.remoteIp == null || this.form.remoteIp === '') {
        callback(new Error('不许为空'))
      }
      var reg = /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/;
      if (!reg.test(this.form.remoteIp)) {
        callback(new Error('请填写正确的ip'))
      }
      callback()
    }
    const checkRemotePort = (rule, value, callback) => {
      var v6 = this.channelData
      if (this.form.remotePort == null || this.form.remotePort === '') {
        callback(new Error('不许为空'))
      }
      var reg = /^[0-9]*$/;
      if (!reg.test(this.form.remotePort)) {
        callback(new Error('请填写正确的端口号'))
      }
      for (let i = 0; i < v6.length; i++) {
        if (this.form.id == '' || this.form.id == undefined) {
          // 新增
          if ((this.form.remotePort == v6[i].remotePort)) {
            callback(new Error('远端端口不能重复'))
          }
        } else {
          // 修改
          if (this.channelId != v6[i].id) {
            if (this.form.remotePort == v6[i].remotePort) {
              callback(new Error('远端端口不能重复'))
            }
          }
        }
      }
      callback()
    }
    const checkObjectFileType = async (rule, value, callback) => {
      var v6 = this.uploadFileCodeData
      if (this.form.uploadFileType == null || this.form.uploadFileType == '') {
        callback(new Error('不许为空'))
      }
      if (this.form.uploadProtocolEnum == 'E1' || this.form.uploadProtocolEnum == 'E2' || this.form.uploadProtocolEnum == 'E3' || this.form.uploadProtocolEnum == 'E6' || this.form.uploadProtocolEnum == '102服务端' || this.form.uploadProtocolEnum == '102山东客户端' || this.form.uploadProtocolEnum == '102山东服务端' || this.form.uploadProtocolEnum == '102浙江客户端') {
        var arr = this.form.uploadFileType.toString().split(",")
        var arr1 = []
        for (let i = 0; i < v6.length; i++) {
          arr1.push(v6[i].fileTypeEnum)
        }

        for (let i = 0; i < arr.length; i++) {
          if (arr1.indexOf(arr[i]) == -1) {
            for (let j = 0; j < this.uploadFileTypeList.length; j++) {
              if (arr[i] == this.uploadFileTypeList[j]["value"]) {
                callback(new Error(this.uploadFileTypeList[j]["label"] + '未维护code值'))
              }
            }

          }
        }
      }

      if (this.form.uploadFileType.indexOf("E402") != -1) {
        const result = await this.checkE402()
          if (!result.data) {
            callback(new Error("单机转发文件未配置有效单机信息，不能保存"))
          }
      }
      callback()
    }

    const checkFileTypeEnum = (rule, value, callback) => {
      var s6 = this.uploadFileCodeData
      if (value == null || value === '') {
        callback(new Error('请填写文件类型'))
      }
      for (let i = 0; i < s6.length; i++) {
        if (this.id == '' || this.id == undefined) {
          // 新增
          if ((value == s6[i].fileTypeEnum)) {
            callback(new Error('该文件类型已经添加'))
          }
        } else {
          // 修改
          if (this.id != s6[i].id) {
            if ((value == s6[i].fileTypeEnum)) {
              callback(new Error('该文件类型已经添加'))
            }
          }
        }
      }
      callback()
    }

    const checkFileTypeCode = (rule, value, callback) => {
      var s6 = this.uploadFileCodeData
      if (value == null || value === '') {
        callback(new Error('请填写code值'))
      }
      // for (let i = 0; i < s6.length; i++) {
      //   if (this.id == '' || this.id == undefined) {
      //     // 新增
      //     if ((value == s6[i].fileTypeCode)) {
      //       callback(new Error('该code值已经被使用'))
      //     }
      //   } else {
      //     // 修改
      //     if (this.id != s6[i].id) {
      //       if ((value == s6[i].fileTypeCode)) {
      //         callback(new Error('该code值已经被使用'))
      //       }
      //     }
      //   }
      // }
      callback()
    }

    const checkBackupC = (rule, value, callback) => {
      var s6 = this.form.backupC
      if (s6 != 1) {
        if (value == null || value === '') {
          callback(new Error('路径不能为空'))
        }
      }
      callback()
    }
    return {
      fromUploadProtocolEnum: '',
      province: '',
      uploadInfoData: [],
      provinceData: [],
      uploadInfoVisible: false,
      //9.1
      uploadFileCodeData: [],
      id: '',
      //9.1
      sftpPassword: true,
      sftpKey: false,
      disabledBtn: false,
      activeName: 'first',
      type: '',
      objectId: '',
      channelId: '',
      channelData: [],
      tablePage2: {
        currentPage: 1,
        pageSize: 5,
        totalResult: 0
      },
      selectTab: 'tab1',
      checkFlag: 0,
      add: true,
      tableLoading: false,
      addVisible: false,
      addVisibleUploadObject: false,
      loading: true,
      saveLoding: false,
      saveChannelLoding: false,
      saveObjectLoding: false,
      showTable: true,
      btnLonding: false,
      tableData: [],
      currentPage: 1,
      pageSize: 5,
      total: null,
      form: {},
      uploadFileTypeList: [],
      channelFileRuleEnumList: [],
      channelStatusEnumList: [],
      uploadProtocolEnumList: [],
      uploadFileCharSetEnumList: [],
      uploadFileNameLengthEnumList: [],
      uploadFileSingleByteEnumList: [],
      ftpPassiveModeEnumList: [],
      sftpsaveForm: [],
      ftpsaveForm: [],
      sftpConnectModeEnum: [{value: 'E1', label: '密码连接'}, {value: 'E2', label: '密钥连接'}],
      uploadD5000List: [{value: '0', label: '否'}, {value: '1', label: '是'}],
      rulesObject: {
        uploadObjectName: [{required: true, validator: checkObjectName, trigger: 'blur'}],
        objectNo: [{required: true, trigger: 'blur', validator: checkObjectNo},
          {pattern: /^\+?[1-9][0-9]*$/, message: '请填写正整数作为上报对象编号'}],
        channelFileRuleEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadFileType: [{required: true, validator: checkObjectFileType, trigger: 'blur'}],
        uploadFileCharSetEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadProtocolEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
      },
      rules102: {
        uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
        channelNo: [{required: true, trigger: 'blur', validator: checkChannelNo},
          {pattern: /^\+?[1-9][0-9]*$/, message: '请填写正整数作为通道号'}],
        channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
        channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        localIp: [{required: true, trigger: 'blur', message: '不能为空'},
          {
            pattern: /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/,
            message: '请填写正确的ip'
          }],
        localPort: [{required: true, trigger: 'blur', message: '不能为空'}],
        remoteIp: [{required: true, trigger: 'blur', validator: checkRemoteIp}],
        // remoteIp: [{required: true, message: '不能为空', trigger: 'blur'},
        //   {
        //     pattern: /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/,
        //     message: '请填写正确的ip'
        //   }],
        // remotePort: [{required: true, message: '不能为空', trigger: 'blur'},
        //   {pattern: /^[0-9]*$/, message: '请填写正确的端口'}],
        uploadFileNameLengthEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadFileSingleByteEnum: [{required: true, message: '不能为空', trigger: 'blur'}]
      },
      zj102: {
        uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
        channelNo: [{required: true, trigger: 'blur', validator: checkChannelNo},
          {pattern: /^\+?[1-9][0-9]*$/, message: '请填写正整数作为通道号'}],
        channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
        channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        localIp: [{required: true, trigger: 'blur', message: '不能为空'},
          {
            pattern: /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/,
            message: '请填写正确的ip'
          }],
        localPort: [{required: true, trigger: 'blur', message: '不能为空'}],
        remoteIp: [{required: true, trigger: 'blur', validator: checkRemoteIp}],
        // remoteIp: [{required: true, message: '不能为空', trigger: 'blur'},
        //   {
        //     pattern: /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/,
        //     message: '请填写正确的ip'
        //   }],
        remotePort: [{required: true, message: '不能为空', trigger: 'blur'},
          {pattern: /^[0-9]*$/, message: '请填写正确的端口'}],
        uploadFileNameLengthEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadFileSingleByteEnum: [{required: true, message: '不能为空', trigger: 'blur'}]
      },
      rules102ser: {
        uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
        channelNo: [{required: true, trigger: 'blur', validator: checkChannelNo},
          {pattern: /^\+?[1-9][0-9]*$/, message: '请填写正整数作为通道号'}],
        channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
        channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        localIp: [{required: true, trigger: 'blur', message: '不能为空'},
          {
            pattern: /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/,
            message: '请填写正确的ip'
          }],
        localPort: [{required: true, trigger: 'blur', message: '不能为空'}],
        remoteIp: [{required: true, trigger: 'blur', validator: checkRemoteIp}],
        uploadUserName: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadPassword: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadFileNameLengthEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadFileSingleByteEnum: [{required: true, message: '不能为空', trigger: 'blur'}]
      },
      rules102sdk: {
        uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
        channelNo: [{required: true, trigger: 'blur', validator: checkChannelNo},
          {pattern: /^\+?[1-9][0-9]*$/, message: '请填写正整数作为通道号'}],
        channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
        channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        localIp: [{required: true, message: '不能为空', trigger: 'blur'},
          {
            pattern: /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/,
            message: '请填写正确的ip'
          }],
        localPort: [{required: true, message: '不能为空', trigger: 'blur'},
          {pattern: /^[0-9]*$/, message: '请填写正确的端口'}],
        remoteIp: [{required: true, trigger: 'blur', validator: checkRemoteIp}],
        remotePort: [{required: true, trigger: 'blur', validator: checkRemotePort}],
        uploadUserName: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadPassword: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadFileNameLengthEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadFileSingleByteEnum: [{required: true, message: '不能为空', trigger: 'blur'}]
      },
      rulesFtp: {
        uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
        channelNo: [{required: true, trigger: 'blur', validator: checkChannelNo},
          {pattern: /^\+?[1-9][0-9]*$/, message: '请填写正整数作为通道号'}],
        channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
        channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        remoteIp: [{required: true, message: '不能为空', trigger: 'blur'},
          {
            pattern: /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/,
            message: '请填写正确的ip'
          }],
        remotePort: [{required: true, message: '不能为空', trigger: 'blur'},
          {pattern: /^[0-9]*$/, message: '请填写正确的端口'}],
        pathService: [{required: true, trigger: 'blur', validator: checkBackupC}],
        uploadUserName: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadPassword: [{required: true, message: '不能为空', trigger: 'blur'}],
        ftpPassiveModeEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        // backupC:[{required: true, message: '不能为空', trigger: 'blur'}],
      },
      rulesSftp: {
        uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
        channelNo: [{required: true, trigger: 'blur', validator: checkChannelNo},
          {pattern: /^\+?[1-9][0-9]*$/, message: '请填写正整数作为通道号'}],
        channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
        channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        remoteIp: [{required: true, message: '不能为空', trigger: 'blur'},
          {
            pattern: /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))/,
            message: '请填写正确的ip'
          }],
        remotePort: [{required: true, message: '不能为空', trigger: 'blur'},
          {pattern: /^[0-9]*$/, message: '请填写正确的端口'}],
        pathService: [{required: true, trigger: 'blur', validator: checkBackupC}],
        uploadUserName: [{required: true, message: '不能为空', trigger: 'blur'}],
        sftpConnectModeEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        uploadPassword: [{required: true, message: '不能为空', trigger: 'blur'}],
        // backupC:[{required: true, message: '不能为空', trigger: 'blur'}],
        // ftpPassiveModeEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
        /*keyFilePath: [{required: true, message: '不能为空', trigger: 'blur'}],
        passPhrase: [{required: true, message: '不能为空', trigger: 'blur'}],*/
      },
      rules: {
        uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
        channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
        channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
      },
      rulesCode: {
        fileTypeEnum: [{required: true, validator: checkFileTypeEnum, trigger: 'blur'}],
        fileTypeCode: [{required: true, validator: checkFileTypeCode, trigger: 'blur'}]
      },
      isMoreURL: [{value: null, label: '否'}, {value: '1', label: '是'}],
      fileTypeListForUrl: [],
      b:false
    }
  },
  created() {
    this.get()
  },
  methods: {
    updateTypeWarning(id, uploadProtocolEnum) {
      if (!this.add) {
        this.$confirm('切换上报协议会删除对应的所有通道，是否继续？？？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$axios.delete("/uploadFileChannel/deleteByObjId/" + id).then(res => {
            this.form.uploadProtocolEnum = uploadProtocolEnum
            this.fromUploadProtocolEnum = uploadProtocolEnum
            this.$message({
              type: 'success',
              message: '删除名下通道成功!'
            });
          }).catch((error) => {
            this.form.uploadProtocolEnum = this.fromUploadProtocolEnum
            this.$message.error('删除名下通道出错' + error)
          })
        }).catch(() => {
          this.form.uploadProtocolEnum = this.fromUploadProtocolEnum
          this.$message({
            type: 'info',
            message: '已取消名下通道删除，上报协议无法切换！'
          });
        });
      }

    },
    get() {
      Promise.all([this.getChannelStatusEnum(), this.getUploadProtocolEnum(), this.getUploadFileCharSetEnum(), this.getUploadFileNameLengthEnum(), this.getUploadFileSingleByteEnum(), this.getFtpPassiveModeEnum(), this.getChannelFileRuleEnum(), this.getFileType()]).then((results) => {
        this.disabledBtn = false
        this.loading = true
        this.channelStatusEnumList = results[0]
        // this.form.channelStatusEnum = this.channelStatusEnumList[0].value
        this.uploadProtocolEnumList = results[1]
        this.uploadFileCharSetEnumList = results[2]
        this.uploadFileNameLengthEnumList = results[3]
        this.uploadFileSingleByteEnumList = results[4]
        this.ftpPassiveModeEnumList = results[5]
        this.channelFileRuleEnumList = results[6]
        this.uploadFileTypeList = results[7]
        this.getAll()
      })
    },
    handleClick(tab, event) {
      if (tab.name === 'secend') {
        this.getAllChannel()
        //  9.1
      } else if (tab.name == 'third') {
        this.getAllUploadFileCode()
        //  9.1
      } else {
        this.getAll()
      }
    },
    //9.1
    getAllUploadFileCode() {
      this.$axios.get("/uploadFileCode/").then(res => {
        this.uploadFileCodeData = res.data
      })
    },
    refreshCode() {
      this.$XModal.confirm('同步后您的新增或修改将会消失，是否继续？?').then(type => {
        if (type === 'confirm') {
          this.$axios.get("/uploadFileTypeIntoUploadCode/").then(res => {
            if (res.data) {
              this.$XModal.message({status: 'warning', message: "同步成功！"})
              this.getAllUploadFileCode()
            } else {
              this.$XModal.message({status: 'warning', message: "同步失败o(╥﹏╥)o"})
            }
          })
        }
      })

    },
    insertEventCode() {
      this.id = ''
      this.add = true
      this.addType = true
      this.showTable = true
      this.btnLonding = true

      this.$refs.cTable.insert()
        .then(({row}) => this.$refs.cTable.setActiveRow(row))
    },
    cancelRowEventCode(row) {
      this.addType = false
      this.saveLoding = false
      this.btnLonding = false
      const cTable = this.$refs.cTable
      if (this.add) {
        cTable.clearActived().then(() => {
          cTable.remove(row)
          this.add = false
        })
      } else {
        cTable.clearActived().then(() => {
          // 还原行数据
          cTable.revertData(row)
        })
      }
    },
    editRowEventCode(row) {
      this.id = row.id
      this.add = false
      this.btnLonding = true
      this.$refs.cTable.setActiveRow(row)
    },
    saveRowEventCode(row) {
      this.saveLoding = true

      this.$refs.cTable.validate(this.$refs.cTable.getCurrentRecord(), valid => {
        if (valid) {
          if (row.id == undefined) {
            this.$axios.post('/uploadFileCode/', row).then(response => {
              this.getAllUploadFileCode()
              this.btnLonding = false
              this.saveLoding = false
              this.$XModal.message({status: 'warning', message: response.message})
            })
          } else {
            this.$axios.put('/uploadFileCode/', row).then(response => {
              this.getAllUploadFileCode()
              this.$XModal.message({status: 'warning', message: response.message})
              this.btnLonding = false
              this.saveLoding = false
            })
          }
        } else {
          this.$XModal.message({status: 'error', message: '校验不通过！'})
          this.saveLoding = false
        }

      })

    },
    removeEventCode(row) {
      this.$XModal.confirm('您确定要删除该数据?').then(type => {
        if (type === 'confirm') {
          this.$axios.delete('/uploadFileCode/' + row.id).then(response => {
            this.$refs.cTable.remove(row)
            this.$XModal.message({status: 'warning', message: response.message})
            this.getAllUploadFileCode()
          })
        }
      })
    },
    //9.1
    getAllChannel() {
      this.$axios.get("/uploadFileChannel/").then(res => {
        this.channelData = res.data
        for (let i = 0; i < this.channelData.length; i++) {

          /*for (let j = 0; j < this.channelStatusEnumList.length; j++) {
            if (this.channelData[i].channelStatusEnum == this.channelStatusEnumList[j]["value"]) {
              this.channelData[i].channelStatusEnum = this.channelStatusEnumList[j]["label"]
            }
          }*/
          for (let j = 0; j < this.uploadFileNameLengthEnumList.length; j++) {
            if (this.channelData[i].uploadFileNameLengthEnum == this.uploadFileNameLengthEnumList[j]["value"]) {
              this.channelData[i].uploadFileNameLengthEnum = this.uploadFileNameLengthEnumList[j]["label"]
            }
          }

          for (let j = 0; j < this.uploadFileSingleByteEnumList.length; j++) {
            if (this.channelData[i].uploadFileSingleByteEnum == this.uploadFileSingleByteEnumList[j]["value"]) {
              this.channelData[i].uploadFileSingleByteEnum = this.uploadFileSingleByteEnumList[j]["label"]
            }
          }
          for (let j = 0; j < this.ftpPassiveModeEnumList.length; j++) {
            if (this.channelData[i].ftpPassiveModeEnum == this.ftpPassiveModeEnumList[j]["value"]) {
              this.channelData[i].ftpPassiveModeEnum = this.ftpPassiveModeEnumList[j]["label"]
            }
          }
          for (let j = 0; j < this.channelFileRuleEnumList.length; j++) {
            if (this.channelData[i].channelFileRuleEnum == this.channelFileRuleEnumList[j]["value"]) {
              this.channelData[i].channelFileRuleEnum = this.channelFileRuleEnumList[j]["label"]
            }
          }
          for (let j = 0; j < this.tableData.length; j++) {
            if (this.channelData[i].uploadObjectId == this.tableData[j].id) {
              this.channelData[i].uploadObjectId = this.tableData[j]
            }
          }

          if (this.channelData[i].uploadObjectId.uploadProtocolEnum == "ftp" || this.channelData[i].uploadObjectId.uploadProtocolEnum == "sftp") {
            let data1 = []
            this.$axios.get("/uploadURL/" + this.channelData[i].id).then(res => {
              for (let x = 0; x < this.tableData.length; x++) {
                if (this.tableData[x].id == this.channelData[i].uploadObjectId.id) {
                  var data = this.tableData[x].uploadFileType.split(",")
                  for (let n = 0; n < data.length; n++) {
                    for (let j = 0; j < this.uploadFileTypeList.length; j++) {
                      if (data[n] == this.uploadFileTypeList[j]["label"]) {
                        var data2 = {
                          label: this.uploadFileTypeList[j]["label"] + "路径:",
                          value: this.uploadFileTypeList[j]["value"],
                          url: ""
                        }
                        for (let y = 0; y < res.data.length; y++) {

                          if (res.data[y].fileTypeEnum == this.uploadFileTypeList[j]["value"]) {
                            data2.url = res.data[y].uploadURL
                          }
                        }
                        data1.push(data2)
                      }
                    }
                  }
                }
              }
            })
            this.channelData[i].backupA = data1
          }
        }
        //console.log("获取通道信息成功")
      }).catch(error => {
        this.$message.error('获取通道信息出错' + error)
      })
    },
    getAll() {
      this.$axios.get("/uploadObject/").then(res => {
        this.tableData = res.data
        // console.log(this.tableData)
        this.loading = false
        for (let i = 0; i < this.tableData.length; i++) {
          //添加编辑标识
          this.$set(this.tableData, 'edit', false)
          //添加省调枚举标识转换
          for (let j = 0; j < this.uploadProtocolEnumList.length; j++) {
            if (this.tableData[i].uploadProtocolEnum == this.uploadProtocolEnumList[j]["value"]) {
              this.tableData[i].uploadProtocolEnum = this.uploadProtocolEnumList[j]["label"]
            }
          }
          for (let j = 0; j < this.uploadFileCharSetEnumList.length; j++) {
            if (this.tableData[i].uploadFileCharSetEnum == this.uploadFileCharSetEnumList[j]["value"]) {
              this.tableData[i].uploadFileCharSetEnum = this.uploadFileCharSetEnumList[j]["label"]
            }
          }
          const data = this.tableData[i].uploadFileType.split(",");
          let data1 = "";
          for (let n = 0; n < data.length; n++) {
            for (let j = 0; j < this.uploadFileTypeList.length; j++) {
              if (data[n] == this.uploadFileTypeList[j]["value"]) {
                data1 = data1 + this.uploadFileTypeList[j]["label"] + ","
              }
            }
          }
          data1 = data1.substr(0, data1.length - 1)
          this.tableData[i].uploadFileType = data1
        }
        this.getAllUploadFileCode()
        // console.log("获取通道对象信息成功")
      }).catch(error => {
        this.$message.error('获取通道对象信息出错' + error)
      })
    },
    getChannelStatusEnum() {
      const a = this.$axios
      return new Promise(function (resolve, reject) {
        a.get("/uploadFileChannel/getChannelStatusEnum").then(res => {
          resolve(res.data)
          // console.log("获取通道状态枚举类型成功")
        }).catch((error) => {
          this.$message.error('获取通道状态枚举类型出错' + error)
        })

      });
    },
    getUploadProtocolEnum() {
      const a = this.$axios
      return new Promise(function (resolve, reject) {
        a.get("/uploadFileChannel/getUploadProtocolEnum").then(res => {
          resolve(res.data)
          // console.log("获取上报协议枚举类型成功")
        }).catch((error) => {
          this.$message.error('获取上报协议枚举类型出错' + error)
        })
      });
    },
    getUploadFileCharSetEnum() {
      const a = this.$axios
      return new Promise(function (resolve, reject) {
        a.get("/uploadFileChannel/getUploadFileCharSetEnum").then(res => {
          resolve(res.data)
          // console.log("获取上报文件字符集类型成功")
        }).catch((error) => {
          this.$message.error('获取上报文件字符集类型出错' + error)
        })
      });
    },
    getUploadFileNameLengthEnum() {
      const a = this.$axios
      return new Promise(function (resolve, reject) {
        a.get("/uploadFileChannel/getUploadFileNameLengthEnum").then(res => {
          resolve(res.data)
          // console.log("获取上报文件名称长度枚举类型成功")
        }).catch((error) => {
          this.$message.error('获取上报文件名称长度枚举出错' + error)
        })
      });
    },
    getUploadFileSingleByteEnum() {
      const a = this.$axios
      return new Promise(function (resolve, reject) {
        a.get("/uploadFileChannel/getUploadFileSingleByteEnum").then(res => {
          resolve(res.data)
          // console.log("获取上报文件单次传输字节枚举类型成功")
        }).catch((error) => {
          this.$message.error('获取上报文件单次传输字节枚举类型出错' + error)
        })
      });
    },
    getFtpPassiveModeEnum() {
      const a = this.$axios
      return new Promise(function (resolve, reject) {
        a.get("/uploadFileChannel/getFtpPassiveModeEnum").then(res => {
          resolve(res.data)
          // console.log("获取ftp模式成功")
        }).catch((error) => {
          this.$message.error('获取ftp模式出错' + error)
        })
      });
    },
    getChannelFileRuleEnum() {
      const a = this.$axios
      return new Promise(function (resolve, reject) {
        a.get("/uploadFileChannel/getChannelFileRuleEnum").then(res => {
          resolve(res.data)
          // console.log("获取ftp模式成功")
        }).catch((error) => {
          this.$message.error('获取ftp模式出错' + error)
        })
      });
    },
    getFileType() {
      const a = this.$axios
      return new Promise(function (resolve, reject) {
        a.get("/uploadObject/getFileTypeByProvince").then(res => {
          resolve(res.data)
          // console.log("获取上报文件类型成功")
        }).catch((error) => {
          this.$message.error('获取上报文件类型出错' + error)
        })
      });
    },
    closeDialogAddUpload() {
      // this.rules =  {
      //   uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
      //   channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
      //   channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
      // }
      this.form = {}
      this.add = true
      this.addVisibleUploadObject = false
      this.saveChannelLoding = false
      this.saveObjectLoding = false
      // this.$nextTick(function () {
      //   this.$refs['form'].clearValidate();
      // })
    },
    closeDialog() {
      this.add = true
      this.form = {}
      // this.rules =  {
      //   uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
      //   channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
      //   channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
      // }
      // this.$nextTick(function () {
      //   this.$refs['form'].clearValidate();
      // })
      this.$refs.Mode102.style.display = 'none'
      this.$refs.ftpMode.style.display = 'none'
      this.$refs.ftp.style.display = 'none'
      this.$refs.sftp.style.display = 'none'
      this.saveChannelLoding = false
      this.saveObjectLoding = false
    },
    closeDialogAdd() {
      // this.rules =  {
      //   uploadObjectId: [{required: true, message: '不能为空', trigger: 'blur'}],
      //   channelName: [{required: true, trigger: 'blur', validator: checkChannelName}],
      //   channelStatusEnum: [{required: true, message: '不能为空', trigger: 'blur'}],
      // }
      this.$nextTick(function () {
        this.$refs['form'].clearValidate();
      })
      this.form = {}
      this.add = true
      this.addVisible = false
      // this.form.channelStatusEnum = this.channelStatusEnumList[0].value
      this.$refs.Mode102.style.display = 'none'
      this.$refs.ftpMode.style.display = 'none'
      // this.$refs.ftp.style.display = 'none'
      this.$refs.sftp.style.display = 'none'
      this.saveChannelLoding = false
      this.saveObjectLoding = false
    },
    // 添加上报对象
    insertEventUploadObject() {
      this.checkFlag = 2
      this.form = {
        'uploadD5000': '0'
      }
      // this.form.uploadD5000 = '0'
      this.addVisibleUploadObject = true
    },
    // 添加通道
    insertEvent(row) {
      // this.form = {
      //   // 'remotePort': 21,
      //   'remotePort': 22,
      //   'channelStatusEnum':'E1',
      //   'sftpConnectModeEnum':'E1'
      // }

      this.sftpPassword = true
      this.sftpKey = false
      this.checkFlag = 2
      this.addVisible = true
      // this.form.uploadObjectId = ''
      // this.form.channelName = ''
      // this.form.channelStatusEnum = this.channelStatusEnumList[0].value
    },
    // 保存上报对象
    saveUploadObject(fromName) {

      const a = this.$axios
      this.$refs[fromName].validate((valid) => {
        if (valid) {
          this.saveObjectLoding = true
          const data = this.form.uploadFileType
          let data1 = "";
          for (let n = 0; n < data.length; n++) {
            for (let j = 0; j < this.uploadFileTypeList.length; j++) {
              if (data[n] == this.uploadFileTypeList[j]["value"]) {
                data1 = data1 + this.uploadFileTypeList[j]["value"] + ","
              }
            }
          }
          data1 = data1.substr(0, data1.length - 1)
          this.form.uploadFileType = data1
          for (let j = 0; j < this.uploadProtocolEnumList.length; j++) {
            if (this.form.uploadProtocolEnum == this.uploadProtocolEnumList[j]["label"]) {
              this.form.uploadProtocolEnum = this.uploadProtocolEnumList[j]["value"]
            }
          }
          // for (let j = 0; j < this.channelFileRuleEnumList.length; j++) {
          //   if (this.form.channelFileRuleEnum == this.channelFileRuleEnumList[j]["label"]) {
          //     this.form.channelFileRuleEnum = this.channelFileRuleEnumList[j]["value"]
          //   }
          // }
          for (let j = 0; j < this.uploadFileCharSetEnumList.length; j++) {
            if (this.form.uploadFileCharSetEnum == this.uploadFileCharSetEnumList[j]["label"]) {
              this.form.uploadFileCharSetEnum = this.uploadFileCharSetEnumList[j]["value"]
            }
          }
          if (this.form.id == undefined) {
            a.post("/uploadObject/", this.form).then(res => {
              this.$message({
                message: '添加成功',
                type: 'success'
              })
              this.addVisible = false
              this.tableLoading = false
              this.addVisibleUploadObject = false
              this.saveObjectLoding = false
              this.getAll()
            }).catch((error) => {
              this.$message.error('添加上报对象信息出错' + error)
              this.tableLoading = false
            })
          } else {
            a.put("/uploadObject/", this.form).then(res => {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.addVisible = false
              this.tableLoading = false
              this.addVisibleUploadObject = false
              this.saveObjectLoding = false
              this.getAll()
            }).catch((error) => {
              this.$message.error('修改上报对象信息出错' + error)
              this.tableLoading = false
            })
          }
        } else {
          this.$message.error('校验未通过，请重新检查')
          return false;
        }
      })

    },
    getUploadFileType() {
      return this.form.uploadFileType

    },
    // 通道保存
    save(formName) {
      /*for (let j = 0; j < this.channelStatusEnumList.length; j++) {
        if (this.form.channelStatusEnum == this.channelStatusEnumList[j]["label"]) {
          this.form.channelStatusEnum = this.channelStatusEnumList[j]["value"]
        }
      }*/

      if (this.type === 'sftp') {
        //console.log(this.form.id)
        this.sftpsaveForm = {
          uploadObjectId: this.form.uploadObjectId,
          channelName: this.form.channelName,
          channelStatusEnum: this.form.channelStatusEnum,
          channelRemarks: this.form.channelRemarks,
          remoteIp: this.form.remoteIp,
          remotePort: this.form.remotePort,
          uploadUserName: this.form.uploadUserName,
          uploadPassword: this.form.uploadPassword,
          pathService: this.form.pathService,
          keyFilePath: this.form.keyFilePath,
          passPhrase: this.form.passPhrase,
          sftpConnectModeEnum: this.form.sftpConnectModeEnum,
          backupC: this.form.backupC
        }

        if (this.form.id !== undefined) {
          this.sftpsaveForm.id = this.form.id
        }
        this.form = this.sftpsaveForm
      }
      if (this.type === 'ftp') {
        this.ftpsaveForm = {
          uploadObjectId: this.form.uploadObjectId,
          channelName: this.form.channelName,
          channelStatusEnum: this.form.channelStatusEnum,
          channelRemarks: this.form.channelRemarks,
          remoteIp: this.form.remoteIp,
          remotePort: this.form.remotePort,
          uploadUserName: this.form.uploadUserName,
          uploadPassword: this.form.uploadPassword,
          pathService: this.form.pathService,
          ftpPassiveModeEnum: this.form.ftpPassiveModeEnum,
          backupC: this.form.backupC
        }
        if (this.form.id !== undefined) {
          this.ftpsaveForm.id = this.form.id
        }
        this.form = this.ftpsaveForm
      }
      for (let j = 0; j < this.uploadFileCharSetEnumList.length; j++) {
        if (this.form.uploadFileCharSetEnum == this.uploadFileCharSetEnumList[j]["label"]) {
          this.form.uploadFileCharSetEnum = this.uploadFileCharSetEnumList[j]["value"]
        }
      }
      for (let j = 0; j < this.uploadFileNameLengthEnumList.length; j++) {
        if (this.form.uploadFileNameLengthEnum == this.uploadFileNameLengthEnumList[j]["label"]) {
          this.form.uploadFileNameLengthEnum = this.uploadFileNameLengthEnumList[j]["value"]
        }
      }
      for (let j = 0; j < this.uploadFileSingleByteEnumList.length; j++) {
        if (this.form.uploadFileSingleByteEnum == this.uploadFileSingleByteEnumList[j]["label"]) {
          this.form.uploadFileSingleByteEnum = this.uploadFileSingleByteEnumList[j]["value"]
        }
      }
      for (let j = 0; j < this.ftpPassiveModeEnumList.length; j++) {
        if (this.form.ftpPassiveModeEnum == this.ftpPassiveModeEnumList[j]["label"]) {
          this.form.ftpPassiveModeEnum = this.ftpPassiveModeEnumList[j]["value"]
        }
      }
      for (let j = 0; j < this.uploadFileTypeList.length; j++) {
        if (this.form.ftpPassiveModeEnum == this.uploadFileTypeList[j]["label"]) {
          this.form.ftpPassiveModeEnum = this.uploadFileTypeList[j]["value"]
        }
      }
      for (let j = 0; j < this.tableData.length; j++) {
        if (this.form.uploadObjectId == this.tableData[j].uploadObjectName) {
          this.form.uploadObjectId = this.tableData[j].id
        }
      }
      const a = this.$axios
      this.tableLoading = true

      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.saveChannelLoding = true
          if (this.form.id == undefined) {
            a.post("/uploadFileChannel/", this.form).then(res => {
              this.$message({
                message: '添加成功',
                type: 'success'
              })
              //判断如果是ftp模式，并且为多路径
              if (this.type == 'ftp' || this.type == "sftp") {
                if (this.form.backupC == 1) {
                  this.saveUrl(res.data.id, res.data.uploadObjectId)
                } else {
                  this.getAllChannel()
                }
              } else {
                this.getAllChannel()
              }
              this.addVisible = false
              this.tableLoading = false

              this.closeDialogAdd()
              this.saveChannelLoding = false
            }).catch((error) => {
              this.$message.error('添加通道信息出错' + error)
              this.tableLoading = false
            })
          } else {
            a.put("/uploadFileChannel/", this.form).then(res => {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.addVisible = false
              this.tableLoading = false
              if (this.type == 'ftp' || this.type == "sftp") {
                if (this.form.backupC == 1) {
                  this.saveUrl(this.form.id, this.form.uploadObjectId)
                } else {
                  this.getAllChannel()
                }
              } else {
                this.getAllChannel()
              }
              this.closeDialogAdd()
              this.saveChannelLoding = false
            }).catch((error) => {
              this.$message.error('修改通道信息出错' + error)
              this.tableLoading = false
            })
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
      this.checkFlag = 0
    },
    saveUrl(id, uploadObjectId) {
      this.$axios.delete("/uploadURL/" + id).then(res => {
        var data1 = []
        for (let i = 0; i < this.fileTypeListForUrl.length; i++) {
          if (this.fileTypeListForUrl[i].url != "") {
            var data = {
              id: "",
              uploadURL: this.fileTypeListForUrl[i].url,
              uploadChannelId: id,
              uploadObjectId: uploadObjectId,
              fileTypeEnum: this.fileTypeListForUrl[i].value
            }
            this.$axios.post("/uploadURL", data).then(res => {
            })
          }
        }
        this.getAllChannel()
      })
    },
    // 通道删除
    removeEvent(row) {
      this.$XModal.confirm('您确定要删除该数据?').then(type => {
        if (type === 'confirm') {
          this.$axios.delete('/uploadFileChannel/' + row.id).then(response => {
            this.$XModal.message({status: 'warning', message: response.message})
            this.getAllChannel()
          })
        }
      })
    },
    // 上报对象删除
    removeUploadObject(row) {
      this.$XModal.confirm(`${row.uploadObjectName}下通道信息将被全部删除。您确定要删除该上报对象?`).then(type => {
        if (type === 'confirm') {
          this.$axios.delete('/uploadObject/' + row.id).then(response => {
            this.$XModal.message({status: 'warning', message: response.message})
            this.getAll()
          })
        }
      })
    },
    editRowEvent(row) {


      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].uploadObjectName == row.uploadObjectId.uploadObjectName) {
          this.type = this.tableData[i].uploadProtocolEnum
          if (row.backupA != null) {
            var data = this.tableData[i].uploadFileType.split(",")
            let data1 = []
            for (let n = 0; n < data.length; n++) {
              for (let j = 0; j < this.uploadFileTypeList.length; j++) {
                for (let y = 0; y < row.backupA.length; y++) {
                  if (data[n] == this.uploadFileTypeList[j]["label"] && row.backupA[y].value == this.uploadFileTypeList[j]["value"]) {
                    var data2 = {
                      label: this.uploadFileTypeList[j]["label"] + "路径:",
                      value: this.uploadFileTypeList[j]["value"],
                      url: row.backupA[y].url
                    }
                    data1.push(data2)
                  }
                }
              }
            }
            this.fileTypeListForUrl = data1
          }
        }

      }


      this.channelId = row.id
      this.checkFlag = 1
      this.add = false
      this.addVisible = true

      this.$nextTick(function () {
        if (this.type == "102服务端") {
          this.form = JSON.parse(JSON.stringify(row))
          // console.log(row)
          this.form.uploadObjectId = row.uploadObjectId.uploadObjectName
          this.rules = this.rules102
          this.$refs.Mode102.style.display = ''
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = 'none'
        }
        if (this.type == "102山东服务端") {
          this.form = JSON.parse(JSON.stringify(row))
          // console.log(row)
          this.form.uploadObjectId = row.uploadObjectId.uploadObjectName
          this.rules = this.rules102ser
          this.$refs.Mode102.style.display = ''
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = 'none'
        }
        if (this.type == "102山东客户端") {
          this.form = JSON.parse(JSON.stringify(row))
          // console.log(row)
          this.form.uploadObjectId = row.uploadObjectId.uploadObjectName
          this.rules = this.rules102sdk
          this.$refs.Mode102.style.display = ''
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = 'none'
        }
        if (this.type == "102浙江客户端") {
          this.form = JSON.parse(JSON.stringify(row))
          // console.log(row)
          this.form.uploadObjectId = row.uploadObjectId.uploadObjectName
          this.rules = this.zj102
          this.$refs.Mode102.style.display = ''
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = 'none'
        }
        if (this.type == 'ftp') {
          this.$refs.Mode102.style.display = 'none'
          this.$refs.ftpMode.style.display = ''
          this.$refs.sftp.style.display = 'none'
          this.form = {
            id: row.id,
            uploadObjectId: row.uploadObjectId.uploadObjectName,
            channelName: row.channelName,
            channelStatusEnum: row.channelStatusEnum,
            channelRemarks: row.channelRemarks,
            remoteIp: row.remoteIp,
            remotePort: row.remotePort,
            uploadUserName: row.uploadUserName,
            uploadPassword: row.uploadPassword,
            pathService: row.pathService,
            ftpPassiveModeEnum: row.ftpPassiveModeEnum,
            backupC: row.backupC
          }
          this.rules = this.rulesFtp
        }
        if (this.type == 'sftp') {
          this.form = {
            id: row.id,
            uploadObjectId: row.uploadObjectId.uploadObjectName,
            channelName: row.channelName,
            channelStatusEnum: row.channelStatusEnum,
            channelRemarks: row.channelRemarks,
            remoteIp: row.remoteIp,
            remotePort: row.remotePort,
            uploadUserName: row.uploadUserName,
            uploadPassword: row.uploadPassword,
            pathService: row.pathService,
            keyFilePath: row.keyFilePath,
            passPhrase: row.passPhrase,
            sftpConnectModeEnum: row.sftpConnectModeEnum,
            backupC: row.backupC
          }
          this.$refs.Mode102.style.display = 'none'
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = ''
          this.rules = this.rulesSftp
          this.changeConnectModEnum()
        }
      })
    },
    //SFTP上报方式改变
    changeConnectModEnum() {
      if (this.form.sftpConnectModeEnum === 'E1') {
        // alert('E1')
        this.sftpPassword = true
        this.sftpKey = false
        this.rulesSftp.uploadPassword = [{required: true, message: '不能为空', trigger: 'blur'}]
      } else {
        // alert('E2')
        this.sftpPassword = false
        this.sftpKey = true
        this.rulesSftp.uploadPassword = []
      }
    },
    // 上报对象编辑
    editRowEventUploadObject(row) {
      // console.log(row)
      this.objectId = row.id
      const data = row.uploadFileType.split(",");
      const data1 = [];
      for (let n = 0; n < data.length; n++) {
        for (let j = 0; j < this.uploadFileTypeList.length; j++) {
          if (data[n] == this.uploadFileTypeList[j]["label"]) {
            data1.push(this.uploadFileTypeList[j]["value"])
          }
        }
      }
      this.checkFlag = 1
      this.add = false
      this.addVisibleUploadObject = true
      this.fromUploadProtocolEnum = row.uploadProtocolEnum
      this.form = JSON.parse(JSON.stringify(row))
      this.form.uploadFileType = data1
    },
    // 上报对象下拉框改变时
    change(row) {
      // console.log(row)
      // this.form.uploadObjectId = row
      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].id == row) {
          this.type = this.tableData[i].uploadProtocolEnum
          var data = this.tableData[i].uploadFileType.split(",")
          let data1 = []
          for (let n = 0; n < data.length; n++) {
            for (let j = 0; j < this.uploadFileTypeList.length; j++) {
              if (data[n] == this.uploadFileTypeList[j]["label"]) {
                var data2 = {
                  label: this.uploadFileTypeList[j]["label"] + "路径:",
                  value: this.uploadFileTypeList[j]["value"],
                  url: ""
                }
                data1.push(data2)
              }
            }
          }
          this.fileTypeListForUrl = data1
        }
      }
      this.$nextTick(function () {
        if (this.type == "102服务端") {
          this.rules = this.rules102
          this.$refs.Mode102.style.display = ''
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = 'none'
          this.form = {
            'uploadObjectId': row,
            'channelStatusEnum': 'E1',
          }
        }
        if (this.type == "102山东服务端") {
          this.form = JSON.parse(JSON.stringify(row))
          // console.log(row)
          this.form.uploadObjectId = row.uploadObjectId.uploadObjectName
          this.rules = this.rules102ser
          this.$refs.Mode102.style.display = ''
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = 'none'
        }
        if (this.type == "102山东客户端") {
          this.rules = this.rules102sdk
          this.$refs.Mode102.style.display = ''
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = 'none'
          this.form = {
            'uploadObjectId': row,
            'channelStatusEnum': 'E1',
          }
        }
        if (this.type == "102浙江客户端") {
          this.rules = this.zj102
          this.$refs.Mode102.style.display = ''
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = 'none'
          this.form = {
            'uploadObjectId': row,
            'channelStatusEnum': 'E1',
          }
        }
        if (this.type == 'ftp') {
          this.rules = this.rulesFtp
          this.$refs.Mode102.style.display = 'none'
          this.$refs.ftpMode.style.display = ''
          this.$refs.sftp.style.display = 'none'
          this.form = {
            'uploadObjectId': row,
            'remotePort': 21,
            // 'remotePort': 22,
            'channelStatusEnum': 'E1',
            // 'sftpConnectModeEnum':'E1'
          }
        }
        if (this.type == 'sftp') {
          this.form.sftpConnectModeEnum = 'E1'
          this.rules = this.rulesSftp
          this.$refs.Mode102.style.display = 'none'
          this.$refs.ftpMode.style.display = 'none'
          this.$refs.sftp.style.display = ''
          this.form = {
            // 'remotePort': 21,
            'uploadObjectId': row,
            'remotePort': 22,
            'channelStatusEnum': 'E1',
            'sftpConnectModeEnum': 'E1'
          }
        }
        this.$nextTick(function () {
          this.$refs['form'].clearValidate();
        })
      })
    },
    // 重置表单
    resetForm(formName) {
      // this.form = {}
      this.$refs[formName].resetFields();
      this.$nextTick(function () {
        this.$refs['form'].clearValidate();
      })
      // if(this.form.uploadObjectId)
      this.form.uploadD5000 = '0'

    },
    //转换通道状态
    formatechannelStatusEnum({cellValue}) {
      const item = this.channelStatusEnumList.find(item => item.value === cellValue)
      return item ? item.label : ''
    },
    //转上报D5000
    formateuploadD5000({cellValue}) {
      const item = this.uploadD5000List.find(item => item.value === cellValue)
      return item ? item.label : ''
    },
    timestampToTime(time) {
      const date = new Date(time) // 时间戳为10位需*1000，时间戳为13位的话不需乘1000
      const Y = date.getFullYear() + '-'
      const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
      const D = date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()
      return Y + M + D
    },
    exportDataEvent() {
      this.$refs.xTable.openExport({types: ['csv']})
    },
    uploadinfoShow() {
      this.$axios.get("/electricField/getProvince").then(res => {
        this.provinceData = res.data
      })
      this.uploadInfoVisible = true
    },
    uploadInfoCloseDialog() {
      this.uploadInfoVisible = false
    },
    getUploadInfoData() {
      this.$axios.get("uploadInfo/getByProvinceEnum/" + this.province).then(res => {

        this.uploadInfoData = res.data

        if (this.uploadInfoData.length > 0) {
          for (let i = 0; i < this.uploadInfoData.length; i++) {
            const data = this.uploadInfoData[i].fileType.split(",");
            let data1 = "";
            for (let n = 0; n < data.length; n++) {
              for (let j = 0; j < this.uploadFileTypeList.length; j++) {
                if (data[n] == this.uploadFileTypeList[j]["value"]) {
                  data1 = data1 + this.uploadFileTypeList[j]["label"] + ","
                }
              }
            }
            data1 = data1.substr(0, data1.length - 1)
            this.uploadInfoData[i].fileType = data1

            for (let j = 0; j < this.uploadFileCharSetEnumList.length; j++) {
              if (this.uploadInfoData[i].uploadFileCharSetEnum == this.uploadFileCharSetEnumList[j]["value"]) {
                this.uploadInfoData[i].uploadFileCharSetEnum = this.uploadFileCharSetEnumList[j]["label"]
              }
            }
            for (let j = 0; j < this.uploadFileNameLengthEnumList.length; j++) {
              if (this.uploadInfoData[i].uploadFileNameLengthEnum == this.uploadFileNameLengthEnumList[j]["value"]) {
                this.uploadInfoData[i].uploadFileNameLengthEnum = this.uploadFileNameLengthEnumList[j]["label"]
              }
            }

            for (let j = 0; j < this.uploadFileSingleByteEnumList.length; j++) {
              if (this.uploadInfoData[i].uploadFileSingleByteEnum == this.uploadFileSingleByteEnumList[j]["value"]) {
                this.uploadInfoData[i].uploadFileSingleByteEnum = this.uploadFileSingleByteEnumList[j]["label"]
              }
            }

            for (let j = 0; j < this.uploadProtocolEnumList.length; j++) {
              if (this.uploadInfoData[i].uploadProtocolEnum == this.uploadProtocolEnumList[j]["value"]) {
                this.uploadInfoData[i].uploadProtocolEnum = this.uploadProtocolEnumList[j]["label"]
              }
            }

          }
        }

      })
    },

    //单机设备检查
    checkE402() {
      return this.$axios.get("uploadObject/checkE402")
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  /*left: 0;*/
  /*width: 100%;*/
  /*min-height: 100%;*/
  /*height: auto;*/
  /*background-image: linear-gradient(25deg, #05362d, #145d44, #24875d, #35b477)*/
}

.pagination {
  margin: 20px 0;
  text-align: right;
}

td {
  width: 33%;
  height: 30px;
}

</style>
