<script setup lang="ts">
import { reactive, onMounted, toRaw, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { PageContainer } from 'antdv-pro-layout';
import { ProModal } from 'antdv-pro-modal';
import { Form, message, Modal } from 'ant-design-vue/es';
import { SizeType } from 'ant-design-vue/es/config-provider';
import { MenuInfo } from 'ant-design-vue/es/menu/src/interface';
import { ColumnsType } from 'ant-design-vue/es/table';
import { parseDateToStr } from '@/utils/date-utils';
import { MENU_PATH_INLINE } from '@/constants/menu-constants';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import useI18n from '@/hooks/useI18n';
import useNeInfoStore from '@/store/modules/neinfo';
import {
  addTraceTask,
  delTraceTask,
  getTraceTask,
  listTraceTask,
  updateTraceTask,
} from '@/api/trace/task';
import useDictStore from '@/store/modules/dict';
import { regExpIPv4 } from '@/utils/regular-utils';
import dayjs, { Dayjs } from 'dayjs';
import { parseObjHumpToLine } from '@/utils/parse-utils';
const neInfoStore = useNeInfoStore();
const { getDict } = useDictStore();
const { t } = useI18n();
const router = useRouter();
const route = useRoute();

/**字典数据 */
let dict: {
  /**跟踪类型 */
  traceType: DictType[];
  /**跟踪接口 */
  traceInterfaces: DictType[];
} = reactive({
  traceType: [],
  traceInterfaces: [],
});

/**网元类型_多neId */
let neCascaderOptions = ref<Record<string, any>[]>([]);

/**查询参数 */
let queryParams = reactive({
  /**网元类型 */
  neType: '',
  /**记录时间 */
  startTime: '',
  endTime: '',
  /**排序字段 */
  sortField: 'start_time',
  /**排序方式 */
  sortOrder: 'asc',
  /**当前页数 */
  pageNum: 1,
  /**每页条数 */
  pageSize: 20,
});

/**查询参数重置 */
function fnQueryReset() {
  queryParams = Object.assign(queryParams, {
    neType: '',
    startTime: '',
    endTime: '',
    sortField: 'start_time',
    sortOrder: 'asc',
    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.traceManage.task.traceId'),
    dataIndex: 'traceId',
    align: 'left',
    width: 150,
  },
  {
    title: t('views.traceManage.task.trackType'),
    dataIndex: 'traceType',
    key: 'traceType',
    align: 'left',
    width: 150,
  },
  {
    title: t('views.traceManage.task.startTime'),
    dataIndex: 'startTime',
    align: 'left',
    width: 200,
    customRender(opt) {
      if (!opt.value) return '';
      return parseDateToStr(opt.value);
    },
  },
  {
    title: t('views.traceManage.task.endTime'),
    dataIndex: 'endTime',
    align: 'left',
    customRender(opt) {
      if (!opt.value) return '';
      return parseDateToStr(opt.value);
    },
    width: 200,
  },
  {
    title: t('common.operate'),
    key: 'id',
    align: 'left',
  },
];

/**表格分页器参数 */
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;
}

/**表格多选 */
function fnTableSelectedRowKeys(keys: (string | number)[]) {
  tableState.selectedRowKeys = keys;
}

/**表格分页、排序、筛选变化时触发操作, 排序方式，取值为 ascend descend */
function fnTableChange(pagination: any, filters: any, sorter: any, extra: any) {
  const { field, order } = sorter;
  if (order) {
    queryParams.sortField = parseObjHumpToLine(field);
    queryParams.sortOrder = order.replace('end', '');
  } else {
    queryParams.sortOrder = 'asc';
  }
  fnGetList(1);
}

/**
 * 记录删除
 * @param id  编号
 */
function fnRecordDelete(id: string) {
  if (!id || modalState.confirmLoading) return;
  let msg = t('views.traceManage.task.delTaskTip', { id: id });
  if (id === '0') {
    const mun = `...${tableState.selectedRowKeys.length}`;
    msg = `${t('views.traceManage.task.delTaskTip', { id: mun })} `;
    id = tableState.selectedRowKeys.join(',');
  }

  Modal.confirm({
    title: t('common.tipTitle'),
    content: msg,
    onOk() {
      modalState.confirmLoading = true;
      const hide = message.loading(t('common.loading'), 0);
      delTraceTask(id)
        .then(res => {
          if (res.code === RESULT_CODE_SUCCESS) {
            message.success(t('common.operateOk'), 3);
            fnGetList();
          } else {
            message.error({
              content: `${res.msg}`,
              duration: 3,
            });
          }
        })
        .finally(() => {
          hide();
          modalState.confirmLoading = false;
        });
    },
  });
}

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

/**对话框对象信息状态类型 */
type ModalStateType = {
  /**新增框或修改框是否显示 */
  openByEdit: boolean;
  /**标题 */
  title: string;
  /**网元类型设备对象 */
  neType: any[] | undefined;
  /**网元类型设备对象接口 */
  neTypeInterface: string[];
  /**任务开始结束时间 */
  timeRangePicker: [Dayjs, Dayjs] | undefined;
  /**表单数据 */
  from: {
    id?: string;
    neList: string; // 网元列表 neType_neId 例如 UDM_001,AMF_001
    /**1-Interface,2-Device,3-User */
    traceType: string;
    startTime?: number;
    endTime?: number;
    remark?: string;
    /**1接口跟踪 */
    interfaces?: string;
    /**2设备跟踪 */
    srcIp?: string;
    dstIp?: string;
    signalPort?: number;
    /**3用户跟踪 */
    imsi?: string;
    msisdn?: string;
  };
  /**确定按钮 loading */
  confirmLoading: boolean;
};

/**对话框对象信息状态 */
let modalState: ModalStateType = reactive({
  openByView: false,
  openByEdit: false,
  title: '',
  neType: [],
  neTypeInterface: [],
  timeRangePicker: undefined,
  from: {
    id: undefined,
    neList: '',
    traceId: undefined,
    traceType: '3',
    startTime: undefined,
    endTime: undefined,
    remark: '',
    /**1接口跟踪 */
    interfaces: '',
    /**2设备跟踪 */
    srcIp: '',
    dstIp: '',
    signalPort: undefined,
    /**3用户跟踪 */
    imsi: undefined,
    // msisdn: undefined,
  },
  confirmLoading: false,
});

/**对话框内表单属性和校验规则 */
const modalStateFrom = Form.useForm(
  modalState.from,
  reactive({
    traceType: [
      {
        required: true,
        message: t('views.traceManage.task.trackTypePlease'),
      },
    ],
    neList: [
      {
        required: true,
        message: t('views.ne.common.neTypePlease'),
      },
    ],
    endTime: [
      {
        required: true,
        message: t('views.traceManage.task.rangePickerPlease'),
      },
    ],
    // 用户跟踪
    imsi: [
      {
        required: true,
        message: t('views.traceManage.task.imsiPlease'),
      },
    ],
    msisdn: [
      {
        required: false,
        message: t('views.traceManage.task.msisdnPlease'),
      },
    ],
    // 接口跟踪
    interfaces: [
      {
        required: true,
        message: t('views.traceManage.task.interfacesPlease'),
      },
    ],
    // 数据跟踪
    srcIp: [
      {
        required: true,
        pattern: regExpIPv4,
        message: t('views.traceManage.task.srcIpPlease'),
      },
    ],
    dstIp: [
      {
        required: true,
        pattern: regExpIPv4,
        message: t('views.traceManage.task.dstIpPlease'),
      },
    ],
  })
);

/**网元类型选择对应修改 */
function fnNeChange(p: any, c: any) {
  let neList: string[] = [];
  for (let i = 0; i < p.length; i++) {
    const v = p[i];
    if (v.length === 1) {
      c[i][0].children.forEach((item: any) => {
        neList.push(`${item.neType}_${item.neId}`);
      });
    } else if (v.length === 2) {
      neList.push(`${v[0]}_${v[1]}`);
    }
  }
  if (neList.length > 0) {
    modalState.from.neList = neList.join(',');
  } else {
    modalState.from.neList = '';
  }
}

/**开始结束时间选择对应修改 */
function fnRangePickerChange(item: any, _: any) {
  if (!item || item.length !== 2) {
    modalState.from.startTime = undefined;
    modalState.from.endTime = undefined;
    return;
  }
  // 获取当前时间
  const now = dayjs();
  // 如果开始时间小于当前时间，则设置为当前时间
  const startTime = item[0].isBefore(now) ? now : item[0];
  const endTime = item[1].isBefore(now) ? now : item[1];
  modalState.timeRangePicker = [startTime, endTime];

  modalState.from.startTime = startTime.valueOf();
  modalState.from.endTime = endTime.valueOf();
}
function fnRangePickerDisabledDate(current: Dayjs) {
  return current && current < dayjs().startOf('day');
}

/**信令接口选择对应修改 */
function fnSelectInterface(s: any, _: any) {
  modalState.from.interfaces = s.join(',');
}

/**
 * 对话框弹出显示为 新增或者修改
 * @param noticeId 网元id, 不传为新增
 */
function fnModalOpenByEdit(id?: string) {
  if (!id) {
    fnModalCancel();
    modalState.title = t('views.traceManage.task.addTask');
    modalState.openByEdit = true;
  } else {
    if (modalState.confirmLoading) return;
    const hide = message.loading(t('common.loading'), 0);
    modalState.confirmLoading = true;
    getTraceTask(id).then(res => {
      modalState.confirmLoading = false;
      hide();
      if (res.code === RESULT_CODE_SUCCESS && res.data) {
        // 回显网元类型
        const neType: any[] = [];
        const neList = res.data.neList.split(',');
        const neListMap: any = {};
        for (const v of neList) {
          const item: string[] = v.split('_');
          if (!neListMap[item[0]]) {
            neListMap[item[0]] = [];
          }
          neListMap[item[0]].push(item[1]);
        }
        for (const op of neCascaderOptions.value) {
          const arr = neListMap[op.value];
          if (!arr) {
            continue;
          }
          const all = op.children.every((c: any) => {
            return arr.includes(c.neId);
          });
          if (all) {
            neType.push([op.value]);
          } else {
            arr.forEach((v: string) => {
              neType.push([op.value, v]);
            });
          }
        }
        modalState.neType = neType;
        // 回显时间
        modalState.timeRangePicker = [
          dayjs(res.data.startTime),
          dayjs(res.data.endTime),
        ];
        // 回显接口
        if (res.data.traceType === '1') {
          modalState.neTypeInterface = res.data.interfaces.split(',');
        }
        modalState.from = Object.assign(modalState.from, res.data);
        modalState.title = t('views.traceManage.task.viewTask');
        modalState.openByEdit = true;
      } else {
        message.error(t('views.traceManage.task.errorTaskInfo'), 3);
      }
    });
  }
}

/**
 * 对话框弹出确认执行函数
 * 进行表达规则校验
 */
function fnModalOk() {
  const from = toRaw(modalState.from);
  let valids = ['traceType', 'neList', 'endTime'];
  if (from.traceType === '1') {
    valids = valids.concat(['interfaces']);
  }
  if (from.traceType === '2') {
    valids = valids.concat(['srcIp', 'dstIp']);
  }
  if (from.traceType === '3') {
    valids = valids.concat(['imsi']);
  }

  modalStateFrom
    .validate(valids)
    .then(e => {
      modalState.confirmLoading = true;
      const traceTask = from.id ? updateTraceTask(from) : addTraceTask(from);
      const hide = message.loading(t('common.loading'), 0);
      traceTask
        .then(res => {
          if (res.code === RESULT_CODE_SUCCESS) {
            message.success({
              content: t('common.msgSuccess', { msg: modalState.title }),
              duration: 3,
            });
            fnModalCancel();
          } 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 fnModalCancel() {
  modalState.openByEdit = false;
  modalState.confirmLoading = false;
  modalStateFrom.resetFields();
  modalState.neType = [];
  modalState.neTypeInterface = [];
  modalState.timeRangePicker = undefined;
}

/**跳转内嵌详情页面 */
function fnRecordView(traceId: any, type: 'analyze' | 'data') {
  router.push({
    path: `${route.path}${MENU_PATH_INLINE}/${type}`,
    query: { traceId },
  });
}

onMounted(() => {
  // 初始字典数据
  Promise.allSettled([getDict('trace_type'), getDict('trace_interfaces')]).then(
    resArr => {
      if (resArr[0].status === 'fulfilled') {
        dict.traceType = resArr[0].value;
      }
      if (resArr[1].status === 'fulfilled') {
        dict.traceInterfaces = resArr[1].value;
      }
    }
  );

  // 获取网元网元列表
  useNeInfoStore()
    .fnNelist()
    .then(res => {
      if (res.code === RESULT_CODE_SUCCESS) {
        if (res.data.length > 0) {
          // 过滤不可用的网元
          neCascaderOptions.value = neInfoStore.getNeSelectOtions.filter(
            (item: any) => {
              return ['AMF', 'AUSF', 'SMF', 'UDM', 'PCF'].includes(item.value);
            }
          );
          if (neCascaderOptions.value.length === 0) {
            message.warning({
              content: t('common.noData'),
              duration: 3,
            });
            return;
          }
        }
      } else {
        message.warning({
          content: t('common.noData'),
          duration: 3,
        });
      }
    })
    .finally(() => {
      // 获取列表数据
      fnGetList();
    });
});
</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.ne.common.neType')" name="neType ">
              <a-auto-complete
                v-model:value="queryParams.neType"
                :options="neCascaderOptions"
                allow-clear
                :placeholder="t('views.ne.common.neTypePlease')"
              />
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :xs="24">
            <a-form-item
              :label="t('views.traceManage.task.startTime')"
              name="startTime"
            >
              <a-date-picker
                show-time
                v-model:value="queryParams.startTime"
                format="YYYY-MM-DD HH:mm:ss"
                value-format="x"
                :placeholder="t('views.traceManage.task.startTime')"
                style="width: 100%"
              />
            </a-form-item>
          </a-col>
          <a-col :lg="6" :md="12" :xs="24">
            <a-form-item
              :label="t('views.traceManage.task.endTime')"
              name="endTime"
            >
              <a-date-picker
                show-time
                v-model:value="queryParams.endTime"
                format="YYYY-MM-DD HH:mm:ss"
                value-format="x"
                :placeholder="t('views.traceManage.task.endTime')"
                style="width: 100%"
              />
            </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="fnModalOpenByEdit()">
            <template #icon><PlusOutlined /></template>
            {{ t('common.addText') }}
          </a-button>

          <a-button
            type="default"
            danger
            :disabled="tableState.selectedRowKeys.length <= 0"
            :loading="modalState.confirmLoading"
            @click.prevent="fnRecordDelete('0')"
          >
            <template #icon><DeleteOutlined /></template>
            {{ t('common.deleteText') }}
          </a-button>
        </a-space>
      </template>

      <!-- 插槽-卡片右侧 -->
      <template #extra>
        <a-space :size="8" align="center">
          <a-tooltip placement="topRight">
            <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 placement="topRight">
            <template #title>{{ t('common.reloadText') }}</template>
            <a-button type="text" @click.prevent="fnGetList()">
              <template #icon><ReloadOutlined /></template>
            </a-button>
          </a-tooltip>
          <a-tooltip placement="topRight">
            <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: true }"
        @change="fnTableChange"
        :row-selection="{
          type: 'checkbox',
          columnWidth: '48px',
          selectedRowKeys: tableState.selectedRowKeys,
          onChange: fnTableSelectedRowKeys,
        }"
      >
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'traceType'">
            <DictTag :options="dict.traceType" :value="record.traceType" />
          </template>
          <template v-if="column.key === 'id'">
            <a-space :size="8" align="center">
              <div v-perms:has="['traceManage:task:data']">
                <a-tooltip placement="topRight">
                  <template #title>
                    {{ t('views.traceManage.task.dataView') }}
                  </template>
                  <a-button
                    type="link"
                    @click.prevent="fnRecordView(record.traceId, 'data')"
                  >
                    <template #icon><ContainerOutlined /></template>
                  </a-button>
                </a-tooltip>
              </div>
              <div v-perms:has="['traceManage:task:analyze']">
                <a-tooltip placement="topRight">
                  <template #title>
                    {{ t('views.traceManage.task.pcapView') }}
                  </template>
                  <a-button
                    type="link"
                    @click.prevent="fnRecordView(record.traceId, 'analyze')"
                  >
                    <template #icon><BarsOutlined /></template>
                  </a-button>
                </a-tooltip>
              </div>

              <a-tooltip placement="topRight">
                <template #title>{{ t('common.viewText') }}</template>
                <a-button
                  type="link"
                  @click.prevent="fnModalOpenByEdit(record.id)"
                >
                  <template #icon><ProfileOutlined /></template>
                </a-button>
              </a-tooltip>
              <a-tooltip placement="topRight">
                <template #title>{{ t('common.deleteText') }}</template>
                <a-button
                  type="link"
                  danger
                  @click.prevent="fnRecordDelete(record.id)"
                >
                  <template #icon><DeleteOutlined /></template>
                </a-button>
              </a-tooltip>
            </a-space>
          </template>
        </template>
      </a-table>
    </a-card>

    <!-- 新增框或修改框 -->
    <ProModal
      :drag="true"
      :width="800"
      :destroyOnClose="true"
      :keyboard="false"
      :mask-closable="false"
      :open="modalState.openByEdit"
      :title="modalState.title"
      :confirm-loading="modalState.confirmLoading"
      @ok="fnModalOk"
      @cancel="fnModalCancel"
      :footer="modalState.from.id ? null : undefined"
    >
      <a-form
        name="modalStateFrom"
        layout="horizontal"
        :label-col="{ span: 4 }"
        :label-wrap="true"
        :disabled="!!modalState.from.id"
      >
        <a-row>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.ne.common.neType')"
              :label-col="{ span: 8 }"
              name="neType"
              v-bind="modalStateFrom.validateInfos.neList"
            >
              <a-cascader
                v-model:value="modalState.neType"
                :options="neCascaderOptions"
                @change="fnNeChange"
                multiple
                :allow-clear="false"
                :placeholder="t('views.ne.common.neTypePlease')"
              />
            </a-form-item>
          </a-col>
          <a-col :lg="12" :md="12" :xs="24">
            <a-form-item
              :label="t('views.traceManage.task.trackType')"
              :label-col="{ span: 8 }"
              name="traceType"
              v-bind="modalStateFrom.validateInfos.traceType"
            >
              <a-select
                v-model:value="modalState.from.traceType"
                :options="dict.traceType"
                :allow-clear="false"
                :placeholder="t('views.traceManage.task.trackTypePlease')"
              >
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>

        <a-form-item
          :label="t('views.traceManage.task.rangePicker')"
          name="endTime"
          v-bind="modalStateFrom.validateInfos.endTime"
        >
          <a-range-picker
            v-model:value="modalState.timeRangePicker"
            @change="fnRangePickerChange"
            bordered
            :show-time="{ format: 'HH:mm:ss' }"
            format="YYYY-MM-DD HH:mm:ss"
            style="width: 100%"
            :disabled-date="fnRangePickerDisabledDate"
            :placeholder="[
              t('views.traceManage.task.startTime'),
              t('views.traceManage.task.endTime'),
            ]"
          ></a-range-picker>
        </a-form-item>
        <a-form-item :label="t('views.traceManage.task.remark')" name="remark">
          <a-textarea
            v-model:value="modalState.from.remark"
            :auto-size="{ minRows: 1, maxRows: 6 }"
            :maxlength="450"
            :show-count="true"
            :placeholder="t('views.traceManage.task.remarkPlease')"
          />
        </a-form-item>

        <!-- 接口跟踪 -->
        <template v-if="modalState.from.traceType === '1'">
          <a-form-item
            :label="t('views.traceManage.task.interfaces')"
            name="interfaces"
            v-bind="modalStateFrom.validateInfos.interfaces"
          >
            <a-select
              mode="multiple"
              :placeholder="t('views.traceManage.task.interfacesPlease')"
              v-model:value="modalState.neTypeInterface"
              :options="dict.traceInterfaces"
              @change="fnSelectInterface"
            >
            </a-select>
          </a-form-item>
        </template>

        <!-- 设备跟踪 -->
        <template v-if="modalState.from.traceType === '2'">
          <a-row>
            <a-col :lg="12" :md="12" :xs="24">
              <a-form-item
                :label="t('views.traceManage.task.srcIp')"
                :label-col="{ span: 8 }"
                name="srcIp"
                v-bind="modalStateFrom.validateInfos.srcIp"
              >
                <a-input
                  v-model:value="modalState.from.srcIp"
                  allow-clear
                  :placeholder="t('views.traceManage.task.srcIpPlease')"
                >
                  <template #prefix>
                    <a-tooltip placement="topLeft">
                      <template #title>
                        <div>{{ t('views.traceManage.task.srcIpTip') }}</div>
                      </template>
                      <InfoCircleOutlined
                        style="opacity: 0.45; color: inherit"
                      />
                    </a-tooltip>
                  </template>
                </a-input>
              </a-form-item>
            </a-col>
            <a-col :lg="12" :md="12" :xs="24">
              <a-form-item
                :label="t('views.traceManage.task.dstIp')"
                :label-col="{ span: 8 }"
                name="dstIp"
                v-bind="modalStateFrom.validateInfos.dstIp"
              >
                <a-input
                  v-model:value="modalState.from.dstIp"
                  allow-clear
                  :placeholder="t('views.traceManage.task.dstIpPlease')"
                >
                  <template #prefix>
                    <a-tooltip placement="topLeft">
                      <template #title>
                        <div>{{ t('views.traceManage.task.dstIpTip') }}</div>
                      </template>
                      <InfoCircleOutlined
                        style="opacity: 0.45; color: inherit"
                      />
                    </a-tooltip>
                  </template>
                </a-input>
              </a-form-item>
            </a-col>
          </a-row>
        </template>

        <!-- 用户跟踪 -->
        <template v-if="modalState.from.traceType === '3'">
          <a-form-item
            :label="t('views.traceManage.task.imsi')"
            name="imsi"
            v-bind="modalStateFrom.validateInfos.imsi"
          >
            <a-input
              v-model:value="modalState.from.imsi"
              allow-clear
              :placeholder="t('views.traceManage.task.imsiPlease')"
            >
              <template #prefix>
                <a-tooltip placement="topLeft">
                  <template #title>
                    <div>{{ t('views.traceManage.task.imsiTip') }}</div>
                  </template>
                  <InfoCircleOutlined style="opacity: 0.45; color: inherit" />
                </a-tooltip>
              </template>
            </a-input>
          </a-form-item>
          <!-- <a-form-item
            :label="t('views.traceManage.task.msisdn')"
            name="msisdn"
            v-bind="modalStateFrom.validateInfos.msisdn"
          >
            <a-input
              v-model:value="modalState.from.msisdn"
              allow-clear
              :placeholder="t('views.traceManage.task.msisdnPlease')"
            >
              <template #prefix>
                <a-tooltip placement="topLeft">
                  <template #title>
                    <div>{{ t('views.traceManage.task.msisdnTip') }}</div>
                  </template>
                  <InfoCircleOutlined style="opacity: 0.45; color: inherit" />
                </a-tooltip>
              </template>
            </a-input>
          </a-form-item> -->
        </template>
      </a-form>
    </ProModal>
  </PageContainer>
</template>

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