From f273e44b63795dd154a4a1ca44126e5bf81b6dfc Mon Sep 17 00:00:00 2001 From: vapao Date: Tue, 27 Jul 2021 11:18:48 +0800 Subject: [PATCH] fix issues --- spug_web/src/components/index.module.less | 1 + spug_web/src/libs/functools.js | 9 ++++--- spug_web/src/pages/host/Group.js | 1 + spug_web/src/pages/host/Table.js | 33 ++++++++++++----------- spug_web/src/pages/host/store.js | 8 +++--- spug_web/src/pages/system/role/codes.js | 1 - 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/spug_web/src/components/index.module.less b/spug_web/src/components/index.module.less index 7a6d9d2..16442a7 100644 --- a/spug_web/src/components/index.module.less +++ b/spug_web/src/components/index.module.less @@ -69,6 +69,7 @@ font-weight: 500; font-size: 16px; opacity: 0.8; + margin-right: 24px; } .option { diff --git a/spug_web/src/libs/functools.js b/spug_web/src/libs/functools.js index 191c710..9411726 100644 --- a/spug_web/src/libs/functools.js +++ b/spug_web/src/libs/functools.js @@ -36,10 +36,13 @@ export function hasPermission(strCode) { export function includes(s, key) { key = key.toLowerCase(); - if (s) { - return s.toLowerCase().includes(key) - } else { + if (Array.isArray(s)) { + for (let i of s) { + if (i && i.toLowerCase().includes(key)) return true + } return false + } else { + return s && s.toLowerCase().includes(key) } } diff --git a/spug_web/src/pages/host/Group.js b/spug_web/src/pages/host/Group.js index 39ed96b..101bed4 100644 --- a/spug_web/src/pages/host/Group.js +++ b/spug_web/src/pages/host/Group.js @@ -148,6 +148,7 @@ export default observer(function () { return ( diff --git a/spug_web/src/pages/host/Table.js b/spug_web/src/pages/host/Table.js index 6643205..600f35c 100644 --- a/spug_web/src/pages/host/Table.js +++ b/spug_web/src/pages/host/Table.js @@ -5,8 +5,8 @@ */ import React from 'react'; import { observer } from 'mobx-react'; -import { Table, Modal, Dropdown, Button, Menu, Avatar, Tooltip, Space, Tag, Radio, message } from 'antd'; -import { PlusOutlined, DownOutlined, SyncOutlined } from '@ant-design/icons'; +import { Table, Modal, Dropdown, Button, Menu, Avatar, Tooltip, Space, Tag, Radio, Input, message } from 'antd'; +import { PlusOutlined, DownOutlined, SyncOutlined, FormOutlined } from '@ant-design/icons'; import { Action, TableCard, AuthButton, AuthFragment } from 'components'; import { http, hasPermission } from 'libs'; import store from './store'; @@ -30,6 +30,8 @@ function ComTable() { function handleImport(menu) { if (menu.key === 'excel') { store.importVisible = true + } else if (menu.key === 'form') { + store.showForm() } else { store.cloudImport = menu.key } @@ -48,24 +50,20 @@ function ComTable() { return ( store[k] = v}/>} + title={ store.f_word = e.target.value}/>} loading={store.isFetching} dataSource={store.dataSource} onReload={store.fetchRecords} actions={[ - } - onClick={() => store.showForm()}>新建, - } - onClick={() => store.showSync()}>批量验证, - + + + + + 新建主机 + + @@ -86,9 +84,14 @@ function ComTable() { )}> - + , + } + onClick={() => store.showSync()}>验证, store.f_status = e.target.value}> 全部 未验证 diff --git a/spug_web/src/pages/host/store.js b/spug_web/src/pages/host/store.js index ae5dfe5..c6401bf 100644 --- a/spug_web/src/pages/host/store.js +++ b/spug_web/src/pages/host/store.js @@ -5,7 +5,7 @@ */ import { observable, computed } from 'mobx'; import { message } from 'antd'; -import http from 'libs/http'; +import { http, includes } from 'libs'; import lds from 'lodash'; class Store { @@ -26,15 +26,13 @@ class Store { @observable detailVisible = false; @observable selectorVisible = false; - @observable f_name; - @observable f_host; + @observable f_word; @observable f_status = ''; @computed get dataSource() { let records = []; if (this.group.all_host_ids) records = this.records ? this.records.filter(x => this.group.all_host_ids.includes(x.id)) : []; - if (this.f_name) records = records.filter(x => x.name.toLowerCase().includes(this.f_name.toLowerCase())); - if (this.f_host) records = records.filter(x => x.hostname.toLowerCase().includes(this.f_host.toLowerCase())); + if (this.f_word) records = records.filter(x => includes(x.name, this.f_word) || includes(x.public_ip_address, this.f_word) || includes(x.private_ip_address, this.f_word)); if (this.f_status !== '') records = records.filter(x => this.f_status === x.is_verified); return records } diff --git a/spug_web/src/pages/system/role/codes.js b/spug_web/src/pages/system/role/codes.js index 4ac8f7e..0b61512 100644 --- a/spug_web/src/pages/system/role/codes.js +++ b/spug_web/src/pages/system/role/codes.js @@ -22,7 +22,6 @@ export default [{ perms: [ {key: 'view', label: '查看主机'}, {key: 'add', label: '新建主机'}, - {key: 'import', label: '批量导入'}, {key: 'edit', label: '编辑主机'}, {key: 'del', label: '删除主机'}, ]