<script setup lang="ts">
import { reactive, onMounted, toRaw } from 'vue';
import { PageContainer } from 'antdv-pro-layout';
import { message, Modal, Form } from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
import { ColumnsType } from 'ant-design-vue/lib/table';
import {
  listNeInfo,
  getNeInfo,
  addNeInfo,
  updateNeInfo,
  delNeInfo,
  exportSet,
  startNf,
  restartNf,
  stopNf,
  importFile,
  listServerFile,
} from '@/api/configManage/neManage';
import { updateNeConfigReload } from '@/api/configManage/configParam';
import useI18n from '@/hooks/useI18n';
import { FileType } from 'ant-design-vue/lib/upload/interface';
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import useNeInfoStore from '@/store/modules/neinfo';
const { t } = useI18n();

/**表格所需option */
const neManageOption = reactive({
  importType: [
    { label: t('views.configManage.neManage.server'), value: 'server' },
    { label: t('views.configManage.neManage.local'), value: 'local' },
  ],
  serverFileName: <any[]>[],
});

/**查询参数 */
let queryParams = reactive({
  /**网元类型 */
  neType: '',
  /**当前页数 */
  pageNum: 1,
  /**每页条数 */
  pageSize: 20,
});

/**查询参数重置 */
function fnQueryReset() {
  queryParams = Object.assign(queryParams, {
    neType: '',
    pageNum: 1,
    pageSize: 20,
  });
  tablePagination.current = 1;
  tablePagination.pageSize = 20;
  fnGetList();
}

/**表格状态类型 */
type TabeStateType = {
  /**加载等待 */
  loading: boolean;
  /**紧凑型 */
  size: SizeType;
  /**搜索栏 */
  seached: boolean;
  /**记录数据 */
  data: object[];
  /**勾选记录 */
  selectedRowKeys: (string | number)[];
};

/**表格状态 */
let tableState: TabeStateType = reactive({
  loading: false,
  size: 'middle',
  seached: true,
  data: [],
  selectedRowKeys: [],
});

/**表格字段列 */
let tableColumns: ColumnsType = [
  {
    title: t('views.configManage.neManage.neType'),
    dataIndex: 'neType',
    align: 'center',
    width: 3,
  },
  {
    title: t('views.configManage.neManage.neId'),
    dataIndex: 'neId',
    align: 'center',
    width: 3,
  },
  {
    title: t('views.configManage.neManage.uid'),
    dataIndex: 'rmUid',
    align: 'center',
    width: 5,
  },
  {
    title: t('views.configManage.neManage.neName'),
    dataIndex: 'neName',
    align: 'center',
    width: 5,
  },
  {
    title: t('views.configManage.neManage.ip'),
    dataIndex: 'ip',
    align: 'center',
    width: 5,
  },
  {
    title: t('views.configManage.neManage.port'),
    dataIndex: 'port',
    align: 'center',
    width: 3,
  },
  {
    title: t('views.configManage.neManage.pvflag'),
    dataIndex: 'pvFlag',
    align: 'center',
    width: 5,
  },
  {
    title: t('views.configManage.neManage.province'),
    dataIndex: 'province',
    align: 'center',
    width: 5,
  },
  {
    title: t('views.configManage.neManage.vendorName'),
    dataIndex: 'vendorName',
    align: 'center',
    width: 5,
  },
  {
    title: t('views.configManage.neManage.dn'),
    dataIndex: 'dn',
    align: 'center',
    width: 5,
  },
  {
    title: t('common.operate'),
    key: 'id',
    align: 'center',
    fixed: 'right',
    width: 5,
  },
];

/**表格分页器参数 */
let tablePagination = reactive({
  /**当前页数 */
  current: 1,
  /**每页条数 */
  pageSize: 20,
  /**默认的每页条数 */
  defaultPageSize: 20,
  /**指定每页可以显示多少条 */
  pageSizeOptions: ['10', '20', '50', '100'],
  /**只有一页时是否隐藏分页器 */
  hideOnSinglePage: false,
  /**是否可以快速跳转至某页 */
  showQuickJumper: true,
  /**是否可以改变 pageSize */
  showSizeChanger: true,
  /**数据总数 */
  total: 0,
  showTotal: (total: number) => t('common.tablePaginationTotal', { total }),
  onChange: (page: number, pageSize: number) => {
    tablePagination.current = page;
    tablePagination.pageSize = pageSize;
    queryParams.pageNum = page;
    queryParams.pageSize = pageSize;
    fnGetList();
  },
});

/**表格紧凑型变更操作 */
function fnTableSize({ key }: MenuInfo) {
  tableState.size = key as SizeType;
}

/**对话框对象信息状态类型 */
type ModalStateType = {
  /**详情框是否显示 */
  visibleByView: boolean;
  /**新增框或修改框是否显示 */
  visibleByEdit: boolean;
  /**导入是否显示 */
  visibleByImport: boolean;
  /**标题 */
  title: string;
  /**表单数据 */
  from: Record<string, any>;
  /**导入表单数据 */
  importFrom: Record<string, any>;
  /**确定按钮 loading */
  confirmLoading: boolean;
};

/**对话框对象信息状态 */
let modalState: ModalStateType = reactive({
  visibleByView: false,
  visibleByEdit: false,
  visibleByImport: false,
  title: '网元',
  from: {
    dn: '',
    ip: '',
    neAddress: '',
    neId: '',
    neName: '',
    neType: '',
    port: '',
    province: '',
    pvFlag: '',
    rmUid: '',
    vendorName: '',
    sync: true,
  },
  importFrom: {
    neId: '',
    neType: '',
    importType: '',
    file: undefined,
    fileList: [],
    fileName: '',
  },
  confirmLoading: false,
});

/**对话框内表单属性和校验规则 */
const modalStateFrom = Form.useForm(
  modalState.from,
  reactive({
    neType: [
      {
        required: true,
        message:
          t('views.configManage.neManage.neType') + t('common.unableNull'),
      },
    ],
    neId: [
      {
        required: true,
        message: t('views.configManage.neManage.neId') + t('common.unableNull'),
      },
    ],
    rmUid: [
      {
        required: true,
        message: t('views.configManage.neManage.uid') + t('common.unableNull'),
      },
    ],
    ip: [
      {
        required: true,
        message: t('views.configManage.neManage.ip') + t('common.unableNull'),
      },
    ],
    port: [
      {
        required: true,
        message: t('views.configManage.neManage.port') + t('common.unableNull'),
      },
    ],
    pvFlag: [
      {
        required: true,
        message:
          t('views.configManage.neManage.pvflag') + t('common.unableNull'),
      },
    ],
    neName: [
      {
        required: true,
        message:
          t('views.configManage.neManage.neName') + t('common.unableNull'),
      },
    ],
  })
);

/**导入对话框内表单属性和校验规则 */
const importStateFrom = Form.useForm(
  modalState.importFrom,
  reactive({
    file: [
      {
        required: true,
        message: t('views.configManage.softwareManage.updateFilePlease'),
      },
    ],
    importType: [
      {
        required: true,
        message: t('views.configManage.neManage.selectPlease'),
      },
    ],
    fileName: [
      {
        required: true,
        message: t('views.configManage.neManage.fileSelect'),
      },
    ],
  })
);

/**
 * 对话框弹出显示为 新增或者修改
 * @param noticeId 网元id, 不传为新增
 */
function fnModalVisibleByEdit(row?: Record<string, any>) {
  if (!row) {
    modalStateFrom.resetFields();
    modalState.title = t('views.configManage.neManage.addNe');
    modalState.visibleByEdit = true;
  } else {
    if (modalState.confirmLoading) return;
    const hide = message.loading(t('common.loading'), 0);
    modalState.confirmLoading = true;
    getNeInfo(row.id).then(res => {
      modalState.confirmLoading = false;
      hide();
      if (res.code === RESULT_CODE_SUCCESS) {
        modalState.from = Object.assign(modalState.from, res.data);
        modalState.title = t('views.configManage.neManage.editNe');
        modalState.visibleByEdit = true;
      } else {
        message.error(t('views.configManage.neManage.getInfo'), 2);
      }
    });
  }
}

/**
 * 对话框弹出确认执行函数
 * 进行表达规则校验
 */
function fnModalOk() {
  modalStateFrom
    .validate()
    .then(e => {
      modalState.confirmLoading = true;
      const from = toRaw(modalState.from);
      const result = from.id ? updateNeInfo(from) : addNeInfo(from);
      const hide = message.loading(t('common.loading'), 0);
      result
        .then(res => {
          if (res.code === RESULT_CODE_SUCCESS) {
            if (res.data?.error || res.data?.affectedRows === 0) {
              message.error({
                content: `${t('views.configManage.neManage.operFail')}`,
                duration: 3,
              });
            } else {
              message.success({
                content: t('common.msgSuccess', { msg: modalState.title }),
                duration: 3,
              });
              modalState.visibleByEdit = false;
              modalStateFrom.resetFields();
              fnGetList(1);
            }
          } else {
            message.error({
              content: `${t('views.configManage.neManage.operFail')}`,
              duration: 3,
            });
          }
        })
        .finally(() => {
          hide();
          modalState.confirmLoading = false;
          // 刷新缓存的网元信息
          useNeInfoStore().fnRefreshNelist();
        });
    })
    .catch(e => {
      message.error(t('common.errorFields', { num: e.errorFields.length }), 3);
    });
}

/**
 * 导入对话框弹出确认执行函数
 * 进行表达规则校验
 */
function fnImportModalOk() {
  const from = toRaw(modalState.importFrom);
  let validateName = ['importType'];
  if (from.file) {
    validateName.push('file');
  } else {
    validateName.push('fileName');
  }

  importStateFrom
    .validate(validateName)
    .then(e => {
      modalState.confirmLoading = true;
      const hide = message.loading(t('common.loading'), 0);
      importFile(from)
        .then(res => {
          if (res.code === RESULT_CODE_SUCCESS) {
            message.success({
              content: t('common.msgSuccess', { msg: modalState.title }),
              duration: 3,
            });
            modalState.visibleByEdit = false;
            modalStateFrom.resetFields();
          } else {
            message.error({
              content: `${res.msg}`,
              duration: 3,
            });
          }
        })
        .finally(() => {
          hide();
          modalState.confirmLoading = false;
          // 获取列表数据
          fnGetList(1);
        });
    })
    .catch(e => {
      message.error(t('common.errorFields', { num: e.errorFields.length }), 3);
    });
}

/**
 * 导入对话框弹出关闭执行函数
 * 进行表达规则校验
 */
function fnImportModalCancel() {
  modalState.visibleByView = false;
  modalState.visibleByImport = false;
  importStateFrom.resetFields();
}

/**
 * 对话框弹出关闭执行函数
 * 进行表达规则校验
 */
function fnModalCancel() {
  modalState.visibleByEdit = false;
  modalState.visibleByView = false;
  modalStateFrom.resetFields();
}

/**
 * 网元删除
 * @param row 网元编号ID
 */
function fnRecordDelete(row: Record<string, any>) {
  Modal.confirm({
    title: t('common.tipTitle'),
    content: t('views.configManage.neManage.delSure', { msg: row.neName }),
    onOk() {
      tableState.loading = true;
      const key = 'delNotice';
      message.loading({ content: t('common.loading'), key });
      delNeInfo(row)
        .then(res => {
          if (res.code === RESULT_CODE_SUCCESS) {
            if (res.data.data && res.data.data.affectedRows) {
              message.success({
                content: t('common.msgSuccess', {
                  msg: t('common.deleteText'),
                }),
                key,
                duration: 2,
              });
              tableState.loading = false;
              fnGetList();
              // 刷新缓存的网元信息
              useNeInfoStore().fnRefreshNelist();
            }
          } else {
            message.error({
              content: `${res.msg}`,
              key: key,
              duration: 2,
            });
          }
        })
        .finally(() => {
          tableState.loading = false;
        });
    },
  });
}

/**
 * 网元导出配置
 * @param row 网元编号ID
 */
function fnRecordExport(row: Record<string, any>) {
  Modal.confirm({
    title: t('common.tipTitle'),
    content: t('views.configManage.neManage.exportSure', { msg: row.neName }),
    onOk() {
      const key = 'exportSet';
      message.loading({ content: t('common.loading'), key });
      exportSet(row).then(res => {
        if (res.code === RESULT_CODE_SUCCESS) {
          message.success({
            content: t('views.configManage.neManage.exportTip'),
            key,
            duration: 2,
          });
        } else {
          message.error({
            content: `${res.msg}`,
            key: key,
            duration: 2,
          });
        }
      });
    },
  });
}

/**
 * 网元重启
 * @param row 网元编号ID
 */
function fnRecordRestart(row: Record<string, any>) {
  Modal.confirm({
    title: t('common.tipTitle'),
    content: t('views.configManage.neManage.totalSure', {
      msg: row.neName,
      oper: t('views.configManage.neManage.restart'),
    }),
    onOk() {
      const hide = message.loading(t('common.loading'), 0);
      restartNf(row)
        .then(res => {
          if (res.code === RESULT_CODE_SUCCESS) {
            message.success({
              content: t('common.msgSuccess', {
                msg: t('views.configManage.neManage.restart'),
              }),
              duration: 3,
            });
          } else {
            message.error({
              content: `${res.msg}`,
              duration: 3,
            });
          }
        })
        .finally(() => {
          hide();
        });
    },
  });
}

/**
 * 网元启动
 * @param row 网元编号ID
 */
function fnRecordStart(row: Record<string, any>) {
  Modal.confirm({
    title: t('common.tipTitle'),
    content: t('views.configManage.neManage.totalSure', {
      msg: row.neName,
      oper: t('views.configManage.neManage.start'),
    }),
    onOk() {
      const key = 'startNf';
      message.loading({ content: t('common.loading'), key });
      startNf(row).then(res => {
        if (res.code === RESULT_CODE_SUCCESS) {
          message.success({
            content: t('common.msgSuccess', {
              msg: t('views.configManage.neManage.start'),
            }),
            key,
            duration: 2,
          });
        } else {
          message.error({
            content: `${res.msg}`,
            key: key,
            duration: 2,
          });
        }
      });
    },
  });
}

/**
 * 网元停止
 * @param row 网元编号ID
 */
function fnRecordStop(row: Record<string, any>) {
  Modal.confirm({
    title: t('common.tipTitle'),
    content: t('views.configManage.neManage.totalSure', {
      msg: row.neName,
      oper: t('views.configManage.neManage.stop'),
    }),
    onOk() {
      const key = 'stopNf';
      message.loading({ content: t('common.loading'), key });
      stopNf(row).then(res => {
        if (res.code === RESULT_CODE_SUCCESS) {
          message.success({
            content: t('common.msgSuccess', {
              msg: t('views.configManage.neManage.stop'),
            }),
            key,
            duration: 2,
          });
        } else {
          message.error({
            content: `${res.msg}`,
            key: key,
            duration: 2,
          });
        }
      });
    },
  });
}

/**网元重新加载 */
function fnNeReload(row: Record<string, any>) {
  Modal.confirm({
    title: t('common.tipTitle'),
    content: t('views.configManage.neManage.totalSure', {
      msg: row.neName,
      oper: t('views.configManage.neManage.reload'),
    }),
    onOk() {
      const key = 'stopNf';
      message.loading({ content: t('common.loading'), key });
      updateNeConfigReload(row.neType, row.neId).then(res => {
        if (res.code === RESULT_CODE_SUCCESS) {
          message.success({
            content: t('common.msgSuccess', {
              msg: t('views.configManage.neManage.reload'),
            }),
            key,
            duration: 2,
          });
        } else {
          message.error({
            content: `${res.msg}`,
            key: key,
            duration: 2,
          });
        }
      });
    },
  });
}

/**
 * 记录多项选择
 */
function fnRecordMore(type: string | number, row: Record<string, any>) {
  if (type === 'delete') {
    fnRecordDelete(row);
    return;
  }

  if (type === 'export') {
    fnRecordExport(row);
  }

  if (type === 'start') {
    fnRecordStart(row);
  }

  if (type === 'restart') {
    fnRecordRestart(row);
  }

  if (type === 'stop') {
    fnRecordStop(row);
  }

  if (type === 'reload') {
    fnNeReload(row);
  }

  if (type === 'import') {
    modalState.importFrom = Object.assign(modalState.importFrom, row);
    modalState.title = t('views.configManage.neManage.import');
    modalState.visibleByImport = true;
  }
}

/**查询网元列表, pageNum初始页数 */
function fnGetList(pageNum?: number) {
  if (tableState.loading) return;
  tableState.loading = true;
  if (pageNum) {
    queryParams.pageNum = pageNum;
  }
  listNeInfo(toRaw(queryParams)).then(res => {
    if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
      // 取消勾选
      if (tableState.selectedRowKeys.length > 0) {
        tableState.selectedRowKeys = [];
      }
      tablePagination.total = res.total;
      tableState.data = res.rows;
      if (
        tablePagination.total <=
          (queryParams.pageNum - 1) * tablePagination.pageSize &&
        queryParams.pageNum !== 1
      ) {
        tableState.loading = false;
        fnGetList(queryParams.pageNum - 1);
      }
    }
    tableState.loading = false;
  });
}

/**查询网元远程服务器备份文件 */
function typeChange(value: any) {
  if (value === 'server') {
    listServerFile(modalState.importFrom).then(res => {
      if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
        neManageOption.serverFileName = [];
        res.data.forEach((item: any) => {
          neManageOption.serverFileName.push({
            label: item.fileName,
            value: item.fileName,
          });
        });
      }
    });
  }
}

/**上传前检查或转换压缩 */
function fnBeforeUploadFile(file: FileType) {
  if (modalState.confirmLoading) return false;
  // const fileName = file.name;
  // const suff = fileName.substring(fileName.lastIndexOf('.'));
  return true;
}

/**上传文件 */
function fnUploadFile(up: UploadRequestOption) {
  // 改为完成状态
  const file = modalState.importFrom.fileList[0];
  file.percent = 100;
  file.status = 'done';
  // 预置到表单
  modalState.importFrom.file = up.file;
}

onMounted(() => {
  // 获取列表数据
  fnGetList();
  // 刷新缓存的网元信息
  useNeInfoStore().fnRefreshNelist();
});
</script>

<template>
  <PageContainer>
    <a-card
      v-show="tableState.seached"
      :bordered="false"
      :body-style="{ marginBottom: '24px', paddingBottom: 0 }"
    >
      <!-- 表格搜索栏 -->
      <a-form :model="queryParams" name="queryParams" layout="horizontal">
        <a-row :gutter="16">
          <a-col :lg="6" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.neType')"
              name="neType "
            >
              <a-input
                v-model:value="queryParams.neType"
                allow-clear
                :placeholder="t('views.configManage.neManage.neTypePlease')"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :xs="24">
            <a-form-item>
              <a-space :size="8">
                <a-button type="primary" @click.prevent="fnGetList(1)">
                  <template #icon><SearchOutlined /></template>
                  {{ t('common.search') }}
                </a-button>
                <a-button type="default" @click.prevent="fnQueryReset">
                  <template #icon><ClearOutlined /></template>
                  {{ t('common.reset') }}
                </a-button>
              </a-space>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-card>

    <a-card :bordered="false" :body-style="{ padding: '0px' }">
      <!-- 插槽-卡片左侧侧 -->
      <template #title>
        <a-space :size="8" align="center">
          <a-button type="primary" @click.prevent="fnModalVisibleByEdit()">
            <template #icon><PlusOutlined /></template>
            {{ t('common.addText') }}
          </a-button>
        </a-space>
      </template>

      <!-- 插槽-卡片右侧 -->
      <template #extra>
        <a-space :size="8" align="center">
          <a-tooltip>
            <template #title>{{ t('common.searchBarText') }}</template>
            <a-switch
              v-model:checked="tableState.seached"
              :checked-children="t('common.switch.show')"
              :un-checked-children="t('common.switch.hide')"
              size="small"
            />
          </a-tooltip>
          <a-tooltip>
            <template #title>{{ t('common.reloadText') }}</template>
            <a-button type="text" @click.prevent="fnGetList()">
              <template #icon><ReloadOutlined /></template>
            </a-button>
          </a-tooltip>
          <a-tooltip>
            <template #title>{{ t('common.sizeText') }}</template>
            <a-dropdown trigger="click" placement="bottomRight">
              <a-button type="text">
                <template #icon><ColumnHeightOutlined /></template>
              </a-button>
              <template #overlay>
                <a-menu
                  :selected-keys="[tableState.size as string]"
                  @click="fnTableSize"
                >
                  <a-menu-item key="default"
                    >{{ t('common.size.default') }}
                  </a-menu-item>
                  <a-menu-item key="middle"
                    >{{ t('common.size.middle') }}
                  </a-menu-item>
                  <a-menu-item key="small"
                    >{{ t('common.size.small') }}
                  </a-menu-item>
                </a-menu>
              </template>
            </a-dropdown>
          </a-tooltip>
        </a-space>
      </template>

      <!-- 表格列表 -->
      <a-table
        class="table"
        row-key="id"
        :columns="tableColumns"
        :loading="tableState.loading"
        :data-source="tableState.data"
        :size="tableState.size"
        :pagination="tablePagination"
        :scroll="{ x: 2000, y: 480 }"
      >
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'id'">
            <a-space :size="8" align="center">
              <a-tooltip>
                <template #title>{{ t('common.editText') }}</template>
                <a-button
                  type="link"
                  @click.prevent="fnModalVisibleByEdit(record)"
                >
                  <template #icon><FormOutlined /></template>
                </a-button>
              </a-tooltip>
              <a-tooltip>
                <template #title>{{
                  t('views.configManage.neManage.restart')
                }}</template>
                <a-button
                  type="link"
                  @click.prevent="fnRecordMore('restart', record)"
                >
                  <template #icon><UndoOutlined /></template>
                </a-button>
              </a-tooltip>
              <a-tooltip placement="left">
                <template #title>{{ t('common.moreText') }}</template>
                <a-dropdown
                  placement="bottomRight"
                  :trigger="['hover', 'click']"
                >
                  <a-button type="link">
                    <template #icon><EllipsisOutlined /> </template>
                  </a-button>
                  <template #overlay>
                    <a-menu @click="({ key }:any) => fnRecordMore(key, record)">
                      <a-menu-item key="export">
                        <ExportOutlined />
                        {{ t('views.configManage.neManage.export') }}
                      </a-menu-item>
                      <a-menu-item key="import">
                        <ImportOutlined />
                        {{ t('views.configManage.neManage.import') }}
                      </a-menu-item>
                      <a-menu-item key="start">
                        <thunderbolt-outlined />
                        {{ t('views.configManage.neManage.start') }}
                      </a-menu-item>
                      <a-menu-item key="stop">
                        <pause-outlined />
                        {{ t('views.configManage.neManage.stop') }}
                      </a-menu-item>
                      <a-menu-item
                        key="reload"
                        v-if="
                          !['OMC', 'PCF', 'IMS', 'MME'].includes(record.neType)
                        "
                      >
                        <SyncOutlined />
                        {{ t('views.configManage.neManage.reload') }}
                      </a-menu-item>
                      <a-menu-item key="delete">
                        <DeleteOutlined />
                        {{ t('common.deleteText') }}
                      </a-menu-item>
                    </a-menu>
                  </template>
                </a-dropdown>
              </a-tooltip>
            </a-space>
          </template>
        </template>
      </a-table>
    </a-card>

    <!-- 新增框或修改框 -->
    <DraggableModal
      width="800px"
      :keyboard="false"
      :mask-closable="false"
      :visible="modalState.visibleByEdit"
      :title="modalState.title"
      :confirm-loading="modalState.confirmLoading"
      @ok="fnModalOk"
      @cancel="fnModalCancel"
    >
      <a-form
        name="modalStateFrom"
        layout="horizontal"
        :label-col="{ span: 6 }"
        :labelWrap="true"
      >
        <a-row :gutter="16">
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.neType')"
              name="neType"
              v-bind="modalStateFrom.validateInfos.neType"
            >
              <a-input
                v-model:value="modalState.from.neType"
                allow-clear
                :placeholder="t('views.configManage.neManage.neTypePlease')"
              >
                <template #prefix>
                  <a-tooltip placement="topLeft">
                    <template #title>{{
                      t('views.configManage.neManage.neTypeTip')
                    }}</template>
                    <InfoCircleOutlined style="color: rgba(0, 0, 0, 0.45)" />
                  </a-tooltip>
                </template>
              </a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.neId')"
              name="neId"
              v-bind="modalStateFrom.validateInfos.neId"
            >
              <a-input
                v-model:value="modalState.from.neId"
                allow-clear
              ></a-input>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="16">
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.uid')"
              name="rmUid"
              v-bind="modalStateFrom.validateInfos.rmUid"
            >
              <a-input
                v-model:value="modalState.from.rmUid"
                allow-clear
                :placeholder="t('views.configManage.neManage.uidTip')"
              >
              </a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.pvflag')"
              name="pvFlag"
              v-bind="modalStateFrom.validateInfos.pvFlag"
            >
              <a-select
                v-model:value="modalState.from.pvFlag"
                default-value="PNF"
              >
                <a-select-opt-group
                  :label="t('views.configManage.neManage.pnf')"
                >
                  <a-select-option value="PNF">PNF</a-select-option>
                </a-select-opt-group>
                <a-select-opt-group
                  :label="t('views.configManage.neManage.vnf')"
                >
                  <a-select-option value="VNF">VNF</a-select-option>
                </a-select-opt-group>
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="16">
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.ip')"
              name="ip"
              v-bind="modalStateFrom.validateInfos.ip"
            >
              <a-input v-model:value="modalState.from.ip" allow-clear></a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.port')"
              name="port"
              v-bind="modalStateFrom.validateInfos.port"
            >
              <a-input v-model:value="modalState.from.port" allow-clear>
                <template #prefix>
                  <a-tooltip placement="topLeft">
                    <template #title>
                      <div>{{ t('views.configManage.neManage.portTip') }}</div>
                    </template>
                    <InfoCircleOutlined style="color: rgba(0, 0, 0, 0.45)" />
                  </a-tooltip>
                </template>
              </a-input>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="16">
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.neName')"
              name="neName"
              v-bind="modalStateFrom.validateInfos.neName"
            >
              <a-input v-model:value="modalState.from.neName" allow-clear>
              </a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.mac')"
              name="neAddress"
            >
              <a-input v-model:value="modalState.from.neAddress" allow-clear
                ><template #prefix>
                  <a-tooltip placement="topLeft">
                    <template #title>
                      <div>{{ t('views.configManage.neManage.macTip') }}</div>
                    </template>
                    <InfoCircleOutlined style="color: rgba(0, 0, 0, 0.45)" />
                  </a-tooltip> </template
              ></a-input>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="16">
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.vendorName')"
              name="vendorName"
            >
              <a-input v-model:value="modalState.from.vendorName" allow-clear>
              </a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item :label="t('views.configManage.neManage.dn')" name="dn">
              <a-input v-model:value="modalState.from.dn" allow-clear></a-input>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row :gutter="16">
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.province')"
              name="province"
            >
              <a-input
                v-model:value="modalState.from.province"
                allow-clear
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.sync')"
              name="province"
            >
              <a-switch
                v-model:checked="modalState.from.sync"
                :checked-children="t('views.configManage.neManage.open')"
                :un-checked-children="t('views.configManage.neManage.close')"
              />
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </DraggableModal>

    <!-- 导入框 -->
    <a-modal
      width="800px"
      :keyboard="false"
      :mask-closable="false"
      :visible="modalState.visibleByImport"
      :title="modalState.title"
      :confirm-loading="modalState.confirmLoading"
      @ok="fnImportModalOk"
      @cancel="fnImportModalCancel"
    >
      <a-form name="importStateFrom" layout="horizontal">
        <a-row :gutter="16">
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.neType')"
              name="neType"
              v-bind="importStateFrom.validateInfos.neType"
            >
              <a-input
                v-model:value="modalState.importFrom.neType"
                disabled
                allow-clear
              >
              </a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.configManage.neManage.neId')"
              name="neId"
              v-bind="importStateFrom.validateInfos.neId"
            >
              <a-input
                v-model:value="modalState.importFrom.neId"
                disabled
              ></a-input>
            </a-form-item>
          </a-col>
        </a-row>

        <a-form-item
          :label="t('views.configManage.neManage.fileForm')"
          name="importType"
          v-bind="importStateFrom.validateInfos.importType"
        >
          <a-select
            v-model:value="modalState.importFrom.importType"
            default-value="server"
            :options="neManageOption.importType"
            @change="typeChange"
          >
          </a-select>
        </a-form-item>

        <a-form-item
          :label="t('views.configManage.neManage.server')"
          name="fileName"
          v-bind="importStateFrom.validateInfos.fileName"
          v-show="modalState.importFrom.importType === 'server'"
        >
          <a-select
            v-model:value="modalState.importFrom.fileName"
            :options="neManageOption.serverFileName"
          >
          </a-select>
        </a-form-item>

        <a-form-item
          :label="t('views.configManage.neManage.local')"
          name="file"
          v-bind="importStateFrom.validateInfos.file"
          v-show="modalState.importFrom.importType === 'local'"
        >
          <a-upload
            name="file"
            v-model:file-list="modalState.importFrom.fileList"
            list-type="text"
            :max-count="1"
            :show-upload-list="true"
            :before-upload="fnBeforeUploadFile"
            :custom-request="fnUploadFile"
          >
            <a-button type="default" :loading="modalState.confirmLoading">
              {{ t('views.configManage.neManage.fileSelect') }}
            </a-button>
          </a-upload>
        </a-form-item>
      </a-form>
    </a-modal>
  </PageContainer>
</template>

<style lang="less" scoped>
.table :deep(.ant-pagination) {
  padding: 0 24px;
}
</style>
