fix: hostId 变更类型和字段名
This commit is contained in:
@@ -21,8 +21,8 @@ const props = defineProps({
|
||||
},
|
||||
/**记录ID */
|
||||
editId: {
|
||||
type: String,
|
||||
default: '',
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
/**分组可选网元 */
|
||||
neGroup: {
|
||||
@@ -62,7 +62,7 @@ let modalState: ModalStateType = reactive({
|
||||
openByEdit: false,
|
||||
title: '信息',
|
||||
from: {
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'ssh',
|
||||
groupId: '0',
|
||||
title: '',
|
||||
@@ -149,7 +149,7 @@ function fnModalOk() {
|
||||
.validate(validateArr)
|
||||
.then(() => {
|
||||
modalState.confirmLoading = true;
|
||||
const neHost = form.hostId ? updateNeHost(form) : addNeHost(form);
|
||||
const neHost = form.id > 0 ? updateNeHost(form) : addNeHost(form);
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
neHost
|
||||
.then(res => {
|
||||
@@ -194,7 +194,7 @@ function fnModalCancel() {
|
||||
* 对话框弹出显示为 ID编辑
|
||||
* @param id id
|
||||
*/
|
||||
function fnModalVisibleById(id: string) {
|
||||
function fnModalVisibleById(id: number) {
|
||||
if (modalState.confirmLoading) return;
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
modalState.confirmLoading = true;
|
||||
@@ -322,7 +322,7 @@ onMounted(() => {
|
||||
v-model:value="modalState.from.hostType"
|
||||
default-value="ssh"
|
||||
:options="dict.neHostType"
|
||||
:disabled="!!modalState.from.hostId"
|
||||
:disabled="modalState.from.id > 0"
|
||||
>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
@@ -333,7 +333,7 @@ onMounted(() => {
|
||||
v-model:value="modalState.from.groupId"
|
||||
default-value="0"
|
||||
:options="dict.neHostGroupId"
|
||||
:disabled="!!modalState.from.hostId"
|
||||
:disabled="modalState.from.id > 0"
|
||||
>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { delNeHost, listNeHost } from '@/api/ne/neHost';
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { number } from 'echarts';
|
||||
const { getDict } = useDictStore();
|
||||
const { t } = useI18n();
|
||||
const EditModal = defineAsyncComponent(
|
||||
@@ -82,7 +83,7 @@ let tableState: TabeStateType = reactive({
|
||||
let tableColumns: ColumnsType = [
|
||||
{
|
||||
title: t('common.rowId'),
|
||||
dataIndex: 'hostId',
|
||||
dataIndex: 'id',
|
||||
align: 'center',
|
||||
width: 50,
|
||||
},
|
||||
@@ -142,7 +143,7 @@ let tableColumns: ColumnsType = [
|
||||
},
|
||||
{
|
||||
title: t('common.operate'),
|
||||
key: 'hostId',
|
||||
key: 'id',
|
||||
align: 'left',
|
||||
},
|
||||
];
|
||||
@@ -210,7 +211,7 @@ type ModalStateType = {
|
||||
/**新增框或修改框是否显示 */
|
||||
openByEdit: boolean;
|
||||
/**记录ID */
|
||||
hostId: string;
|
||||
id: number | undefined;
|
||||
/**确定按钮 loading */
|
||||
confirmLoading: boolean;
|
||||
};
|
||||
@@ -218,7 +219,7 @@ type ModalStateType = {
|
||||
/**对话框对象信息状态 */
|
||||
let modalState: ModalStateType = reactive({
|
||||
openByEdit: false,
|
||||
hostId: '',
|
||||
id: undefined,
|
||||
confirmLoading: false,
|
||||
});
|
||||
|
||||
@@ -226,12 +227,8 @@ let modalState: ModalStateType = reactive({
|
||||
* 对话框弹出显示为 新增或者修改
|
||||
* @param roleId 角色编号ID, 不传为新增
|
||||
*/
|
||||
function fnModalVisibleByEdit(roleId?: string) {
|
||||
if (!roleId) {
|
||||
modalState.hostId = '';
|
||||
} else {
|
||||
modalState.hostId = roleId;
|
||||
}
|
||||
function fnModalVisibleByEdit(id?: undefined) {
|
||||
modalState.id = id;
|
||||
modalState.openByEdit = true;
|
||||
}
|
||||
|
||||
@@ -250,20 +247,20 @@ function fnModalOk() {
|
||||
*/
|
||||
function fnModalCancel() {
|
||||
modalState.openByEdit = false;
|
||||
modalState.hostId = '';
|
||||
modalState.id = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* 网元主机删除
|
||||
* @param hostId 网元主机编号ID
|
||||
* @param id 网元主机编号ID
|
||||
*/
|
||||
function fnRecordDelete(hostId: string) {
|
||||
function fnRecordDelete(id: number) {
|
||||
Modal.confirm({
|
||||
title: t('common.tipTitle'),
|
||||
content: t('views.ne.neHost.delTip', { num: hostId }),
|
||||
content: t('views.ne.neHost.delTip', { num: id }),
|
||||
onOk() {
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
delNeHost(hostId).then(res => {
|
||||
delNeHost(id).then(res => {
|
||||
hide();
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
@@ -420,7 +417,7 @@ onMounted(() => {
|
||||
<!-- 表格列表 -->
|
||||
<a-table
|
||||
class="table"
|
||||
row-key="hostId"
|
||||
row-key="id"
|
||||
:columns="tableColumns"
|
||||
:loading="tableState.loading"
|
||||
:data-source="tableState.data"
|
||||
@@ -435,13 +432,13 @@ onMounted(() => {
|
||||
<template v-if="column.key === 'authMode'">
|
||||
<DictTag :options="dict.neHostAuthMode" :value="record.authMode" />
|
||||
</template>
|
||||
<template v-if="column.key === 'hostId'">
|
||||
<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.hostId)"
|
||||
@click.prevent="fnModalVisibleByEdit(record.id)"
|
||||
>
|
||||
<template #icon><FormOutlined /></template>
|
||||
</a-button>
|
||||
@@ -450,7 +447,7 @@ onMounted(() => {
|
||||
<template #title>{{ t('common.deleteText') }}</template>
|
||||
<a-button
|
||||
type="link"
|
||||
@click.prevent="fnRecordDelete(record.hostId)"
|
||||
@click.prevent="fnRecordDelete(record.id)"
|
||||
>
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
</a-button>
|
||||
@@ -463,7 +460,7 @@ onMounted(() => {
|
||||
<!-- 新增框或修改框 -->
|
||||
<EditModal
|
||||
v-model:open="modalState.openByEdit"
|
||||
:edit-id="modalState.hostId"
|
||||
:edit-id="modalState.id"
|
||||
@ok="fnModalOk"
|
||||
@cancel="fnModalCancel"
|
||||
></EditModal>
|
||||
|
||||
@@ -118,7 +118,7 @@ let modalState: ModalStateType = reactive({
|
||||
// 主机
|
||||
hosts: [
|
||||
{
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'ssh',
|
||||
groupId: '1',
|
||||
title: 'SSH_NE_22',
|
||||
@@ -132,7 +132,7 @@ let modalState: ModalStateType = reactive({
|
||||
remark: '',
|
||||
},
|
||||
{
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'telnet',
|
||||
groupId: '1',
|
||||
title: 'Telnet_NE_4100',
|
||||
@@ -292,7 +292,7 @@ function fnNeTypeChange(v: any) {
|
||||
// UPF标准版本可支持5002
|
||||
if (hostsLen === 2 && v === 'UPF') {
|
||||
modalState.from.hosts.push({
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'telnet',
|
||||
groupId: '1',
|
||||
title: 'Telnet_NE_5002',
|
||||
@@ -307,7 +307,7 @@ function fnNeTypeChange(v: any) {
|
||||
// UDM可支持6379
|
||||
if (hostsLen === 2 && v === 'UDM') {
|
||||
modalState.from.hosts.push({
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'redis',
|
||||
groupId: '1',
|
||||
title: 'REDIS_NE_6379',
|
||||
|
||||
@@ -58,7 +58,7 @@ let modalState: ModalStateType = reactive({
|
||||
// 主机
|
||||
hosts: [
|
||||
{
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'ssh',
|
||||
groupId: '1',
|
||||
title: 'SSH_NE_22',
|
||||
@@ -72,7 +72,7 @@ let modalState: ModalStateType = reactive({
|
||||
remark: '',
|
||||
},
|
||||
{
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'telnet',
|
||||
groupId: '1',
|
||||
title: 'Telnet_NE_4100',
|
||||
@@ -154,8 +154,8 @@ function fnModalOk() {
|
||||
from.hostIds = res.data.hostIds;
|
||||
const hostIds = res.data.hostIds.split(',');
|
||||
if (hostIds.length == 2) {
|
||||
from.hosts[0].hostId = hostIds[0];
|
||||
from.hosts[1].hostId = hostIds[1];
|
||||
from.hosts[0].id = parseInt(hostIds[0]);
|
||||
from.hosts[1].id = parseInt(hostIds[1]);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@@ -163,7 +163,7 @@ function fnModalOk() {
|
||||
from.id = undefined;
|
||||
from.hostIds = '';
|
||||
for (let index = 0; index < from.hosts.length; index++) {
|
||||
from.hosts[index].hostId = undefined;
|
||||
from.hosts[index].id = undefined;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ function fnModalOk() {
|
||||
from.id = undefined;
|
||||
from.hostIds = '';
|
||||
for (let index = 0; index < from.hosts.length; index++) {
|
||||
from.hosts[index].hostId = undefined;
|
||||
from.hosts[index].id = undefined;
|
||||
}
|
||||
},
|
||||
onOk: () => {
|
||||
@@ -237,7 +237,7 @@ function fnNeTypeChange(v: any) {
|
||||
// UPF标准版本可支持5002
|
||||
if (hostsLen === 2 && v === 'UPF') {
|
||||
modalState.from.hosts.push({
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'telnet',
|
||||
groupId: '1',
|
||||
title: 'Telnet_NE_5002',
|
||||
@@ -252,7 +252,7 @@ function fnNeTypeChange(v: any) {
|
||||
// UDM可支持6379
|
||||
if (hostsLen === 2 && v === 'UDM') {
|
||||
modalState.from.hosts.push({
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'redis',
|
||||
groupId: '1',
|
||||
title: 'REDIS_NE_6379',
|
||||
|
||||
@@ -43,7 +43,7 @@ let state: StateType = reactive({
|
||||
sudo: false,
|
||||
},
|
||||
from: {
|
||||
hostId: undefined,
|
||||
id: undefined,
|
||||
hostType: 'ssh',
|
||||
groupId: '1',
|
||||
title: 'SSH_NE_22',
|
||||
|
||||
Reference in New Issue
Block a user