diff --git a/cmdb-ui/src/modules/cmdb/components/ciTable/index.vue b/cmdb-ui/src/modules/cmdb/components/ciTable/index.vue new file mode 100644 index 0000000..7e425be --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/components/ciTable/index.vue @@ -0,0 +1,393 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/views/ci/index.vue b/cmdb-ui/src/modules/cmdb/views/ci/index.vue index d4e7fe6..d0810cd 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci/index.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci/index.vue @@ -74,205 +74,24 @@ - - - - - - - - - - - - - - - + @openDetail="openDetail" + @deleteCI="deleteCI" + /> +
- @@ -324,7 +142,6 @@ import SearchForm from '../../components/searchForm/SearchForm.vue' import CreateInstanceForm from './modules/CreateInstanceForm' import CiDetailDrawer from './modules/ciDetailDrawer.vue' import EditAttrsPopover from './modules/editAttrsPopover' -import JsonEditor from '../../components/JsonEditor/jsonEditor.vue' import { searchCI, updateCI, deleteCI } from '@/modules/cmdb/api/ci' import { getSubscribeAttributes, subscribeCIType, subscribeTreeView } from '@/modules/cmdb/api/preference' import { getCITypeAttributesById } from '@/modules/cmdb/api/CITypeAttr' @@ -332,15 +149,14 @@ import { roleHasPermissionToGrant } from '@/modules/acl/api/permission' import { searchResourceType } from '@/modules/acl/api/resource' import { getCITableColumns } from '../../utils/helper' import { intersection } from '@/utils/functions/set' -import PasswordField from '../../components/passwordField/index.vue' import BatchDownload from '../../components/batchDownload/batchDownload.vue' import PreferenceSearch from '../../components/preferenceSearch/preferenceSearch.vue' import MetadataDrawer from './modules/MetadataDrawer.vue' import CMDBGrant from '../../components/cmdbGrant' -import { ops_move_icon as OpsMoveIcon } from '@/core/icons' import { getAttrPassword } from '../../api/CITypeAttr' import CiRollbackForm from './modules/ciRollbackForm.vue' import { CIBaselineRollback } from '../../api/history' +import CITable from '@/modules/cmdb/components/ciTable/index.vue' export default { name: 'InstanceList', @@ -348,24 +164,18 @@ export default { SearchForm, CreateInstanceForm, CiDetailDrawer, - JsonEditor, - PasswordField, EditAttrsPopover, BatchDownload, PreferenceSearch, MetadataDrawer, CMDBGrant, - OpsMoveIcon, CiRollbackForm, + CITable }, computed: { windowHeight() { return this.$store.state.windowHeight }, - isCheckboxFixed() { - const idx = this.columns.findIndex((item) => item.is_fixed) - return idx > -1 - }, tableHeight() { // if (this.selectedRowKeys && this.selectedRowKeys.length) { // return this.windowHeight - 246 @@ -551,12 +361,7 @@ export default { const subscribed = await getSubscribeAttributes(this.typeId) this.preferenceAttrList = subscribed.attributes // All columns that have been subscribed }, - onSelectChange() { - const xTable = this.$refs.xTable.getVxetableRef() - const records = [...xTable.getCheckboxRecords(), ...xTable.getCheckboxReserveRecords()] - this.selectedRowKeys = records.map((i) => i.ci_id || i._id) - }, - onSelectRangeEnd({ records }) { + onSelectChange(records) { this.selectedRowKeys = records.map((i) => i.ci_id || i._id) }, reloadData() { @@ -820,28 +625,6 @@ export default { await this.loadPreferenceAttrList() await this.loadTableData() }, - getColumnsEditRender(col) { - const _editRender = { - ...col.editRender, - } - if (col.value_type === '6') { - _editRender.events = { focus: this.handleFocusJson } - } - return _editRender - }, - handleFocusJson({ column, row }) { - this.$refs.jsonEditor.open(column, row) - }, - jsonEditorOk(row, column, jsonData) { - // The backend writes data at different speeds. You can modify the table data directly without pulling the interface. - // this.reloadData() - this.instanceList.forEach((item) => { - if (item._id === row._id) { - item[column.property] = JSON.stringify(jsonData) - } - }) - this.$refs.xTable.getVxetableRef().refreshColumn() - }, onShowSizeChange(current, pageSize) { this.pageSize = pageSize if (this.currentPage === 1) { @@ -903,23 +686,6 @@ export default { ) }) }, - // tableFilterChangeEvent({ column, property, values, datas, filterList, $event }) { - // console.log(111) - // }, - getChoiceValueStyle(col, colValue) { - const _find = col.filters.find((item) => String(item[0]) === String(colValue)) - if (_find) { - return _find[1]?.style || {} - } - return {} - }, - getChoiceValueIcon(col, colValue) { - const _find = col.filters.find((item) => String(item[0]) === String(colValue)) - if (_find) { - return _find[1]?.icon || {} - } - return {} - }, handleEditActived() { this.isEditActive = true const passwordCol = this.columns.filter((col) => col.is_password) @@ -945,19 +711,6 @@ export default { this.lastEditCiId = row._id }) }, - getCellStyle({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex }) { - const { property } = column - const _find = this.preferenceAttrList.find((attr) => attr.name === property) - if ( - _find && - _find.option && - _find.option.fontOptions && - row[`${property}`] !== undefined && - row[`${property}`] !== null - ) { - return { ..._find.option.fontOptions } - } - }, getQAndSort() { const fuzzySearch = this.$refs['search'].fuzzySearch || '' const expression = this.$refs['search'].expression || '' @@ -1055,8 +808,8 @@ export default { this.visible = false } }, - getRowSeq(row) { - return this.$refs.xTable.getVxetableRef().getRowSeq(row) + openDetail(id, activeTabKey, ciDetailRelationKey) { + this.$refs.detail.create(id, activeTabKey, ciDetailRelationKey) } }, } @@ -1075,33 +828,4 @@ export default { overflow: auto; margin-bottom: -24px; } -.checkbox-hover-table { - /deep/ .vxe-table--body-wrapper { - .vxe-checkbox--label { - display: inline; - padding-left: 0px !important; - color: #bfbfbf; - } - - .vxe-icon-checkbox-unchecked { - display: none; - } - - .vxe-icon-checkbox-checked ~ .vxe-checkbox--label { - display: none; - } - - .vxe-cell--checkbox { - &:hover { - .vxe-icon-checkbox-unchecked { - display: inline; - } - - .vxe-checkbox--label { - display: none; - } - } - } - } -} diff --git a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chartOptions.js b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chartOptions.js index 45fe798..7f2607f 100644 --- a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chartOptions.js +++ b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chartOptions.js @@ -73,6 +73,7 @@ export const category_1_bar_options = (data, options) => { type: 'bar', stack: options?.barStack ?? 'total', barGap: 0, + barMaxWidth: '16px', emphasis: { focus: 'series' }, @@ -242,6 +243,7 @@ export const category_2_bar_options = (data, options, chartType) => { label: { show: false, }, + barMaxWidth: '16px', areaStyle: chartType === 'line' && options?.isShadow ? { opacity: 0.5, color: { diff --git a/cmdb-ui/src/modules/cmdb/views/relation_views/index.vue b/cmdb-ui/src/modules/cmdb/views/relation_views/index.vue index f04c2d0..a87ec37 100644 --- a/cmdb-ui/src/modules/cmdb/views/relation_views/index.vue +++ b/cmdb-ui/src/modules/cmdb/views/relation_views/index.vue @@ -163,204 +163,26 @@ - - - - - - - - - - - - - - - + @openDetail="openDetail" + @deleteCI="deleteCI" + /> +
- @@ -440,16 +261,14 @@ import SplitPane from '@/components/SplitPane' import EditAttrsPopover from '../ci/modules/editAttrsPopover.vue' import CiDetailDrawer from '../ci/modules/ciDetailDrawer.vue' import CreateInstanceForm from '../ci/modules/CreateInstanceForm' -import JsonEditor from '../../components/JsonEditor/jsonEditor.vue' import BatchDownload from '../../components/batchDownload/batchDownload.vue' -import PasswordField from '../../components/passwordField/index.vue' import PreferenceSearch from '../../components/preferenceSearch/preferenceSearch.vue' import CMDBGrant from '../../components/cmdbGrant' import GrantModal from '../../components/cmdbGrant/grantModal.vue' -import { ops_move_icon as OpsMoveIcon } from '@/core/icons' import { getAttrPassword } from '../../api/CITypeAttr' import ReadPermissionsModal from './modules/ReadPermissionsModal.vue' import RevokeModal from '../../components/cmdbGrant/revokeModal.vue' +import CITable from '@/modules/cmdb/components/ciTable/index.vue' export default { name: 'RelationViews', @@ -464,13 +283,11 @@ export default { EditAttrsPopover, CiDetailDrawer, CreateInstanceForm, - JsonEditor, BatchDownload, - PasswordField, PreferenceSearch, - OpsMoveIcon, ReadPermissionsModal, RevokeModal, + CITable }, data() { return { @@ -635,7 +452,7 @@ export default { refreshTable() { this.selectedRowKeys = [] this.sortByTable = undefined - const xTable = this.$refs.xTable + const xTable = this.$refs.xTable.getVxetableRef() if (xTable) { xTable.clearCheckboxRow() xTable.clearCheckboxReserve() @@ -815,8 +632,8 @@ export default { }, changeCIType(typeId) { - this.$refs.xTable.clearCheckboxRow() - this.$refs.xTable.clearCheckboxReserve() + this.$refs.xTable.getVxetableRef().clearCheckboxRow() + this.$refs.xTable.getVxetableRef().clearCheckboxReserve() this.$refs.search.reset() this.selectedRowKeys = [] this.currentTypeId = [typeId] @@ -983,8 +800,8 @@ export default { if (keys) { const _tempKeys = keys.split('@^@').filter((item) => item !== '') if (_tempKeys.length === this.levels.length) { - this.$refs.xTable.clearCheckboxRow() - this.$refs.xTable.clearCheckboxReserve() + this.$refs.xTable.getVxetableRef().clearCheckboxRow() + this.$refs.xTable.getVxetableRef().clearCheckboxReserve() this.selectedRowKeys = [] } this.treeKeys = _tempKeys @@ -1073,7 +890,10 @@ export default { this.currentView = `${this.viewId}` this.typeId = this.levels[0][0] this.viewOption = this.relationViews.views[this.viewName].option ?? {} - this.refreshTable() + + this.$nextTick(() => { + this.refreshTable() + }) } }) }, @@ -1097,7 +917,7 @@ export default { } }) this.$nextTick(() => { - this.$refs.xTable.refreshColumn() + this.$refs.xTable.getVxetableRef().refreshColumn() }) }, calculateParamsFromTreeKey(treeKey, menuKey) { @@ -1167,23 +987,8 @@ export default { } } }, - onSelectChange({ records, reserves }) { - this.selectedRowKeys = [...records, ...reserves] - }, - checkboxRangeStart(e) { - const xTable = this.$refs.xTable - const lastSelected = xTable.getCheckboxRecords() - const selectedReserve = xTable.getCheckboxReserveRecords() - this.lastSelected = [...lastSelected, ...selectedReserve] - }, - checkboxRangeChange(e) { - const xTable = this.$refs.xTable - xTable.setCheckboxRow(this.lastSelected, true) - }, - checkboxRangeEnd(e) { - const xTable = this.$refs.xTable - this.lastSelected = [] - this.selectedRowKeys = [...xTable.getCheckboxRecords(), ...xTable.getCheckboxReserveRecords()] + onSelectChange(records) { + this.selectedRowKeys = records }, batchDeleteCIRelation() { const currentShowType = this.showTypes.find((item) => item.id === Number(this.currentTypeId[0])) @@ -1214,8 +1019,8 @@ export default { [first_ci_id], ancestor_ids ).then((res) => { - that.$refs.xTable.clearCheckboxRow() - that.$refs.xTable.clearCheckboxReserve() + that.$refs.xTable.getVxetableRef().clearCheckboxRow() + that.$refs.xTable.getVxetableRef().clearCheckboxReserve() that.selectedRowKeys = [] that.loadData({ parameter: {}, refreshType: 'refreshNumber' }) }) @@ -1273,7 +1078,7 @@ export default { }, columnDrop() { this.$nextTick(() => { - const xTable = this.$refs.xTable + const xTable = this.$refs.xTable.getVxetableRef() this.sortable = Sortable.create( xTable.$el.querySelector('.body--wrapper>.vxe-table--header .vxe-header--row'), { @@ -1305,49 +1110,13 @@ export default { ) }) }, - getChoiceValueStyle(col, colValue) { - const _find = col.filters.find((item) => String(item[0]) === String(colValue)) - if (_find) { - return _find[1]?.style || {} - } - return {} - }, - getChoiceValueIcon(col, colValue) { - const _find = col.filters.find((item) => String(item[0]) === String(colValue)) - if (_find) { - return _find[1]?.icon || {} - } - return {} - }, - getCellStyle({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex }) { - const { property } = column - const _find = this.preferenceAttrList.find((attr) => attr.name === property) - if ( - _find && - _find.option && - _find.option.fontOptions && - row[`${property}`] !== undefined && - row[`${property}`] !== null - ) { - return { ..._find.option.fontOptions } - } - }, refreshAfterEditAttrs() { this.loadColumns() }, - getColumnsEditRender(col) { - const _editRender = { - ...col.editRender, - } - if (col.value_type === '6') { - _editRender.events = { focus: this.handleFocusJson } - } - return _editRender - }, handleEditActived() { const passwordCol = this.columns.filter((col) => col.is_password) this.$nextTick(() => { - const editRecord = this.$refs.xTable.getEditRecord() + const editRecord = this.$refs.xTable.getVxetableRef().getEditRecord() const { row, column } = editRecord if (passwordCol.length && this.lastEditCiId !== row._id) { this.$nextTick(async () => { @@ -1358,10 +1127,10 @@ export default { }) } this.isContinueCloseEdit = false - await this.$refs.xTable.clearEdit() + await this.$refs.xTable.getVxetableRef().clearEdit() this.isContinueCloseEdit = true this.$nextTick(() => { - this.$refs.xTable.setEditCell(row, column.field) + this.$refs.xTable.getVxetableRef().setEditCell(row, column.field) }) }) } @@ -1372,7 +1141,7 @@ export default { if (!this.isContinueCloseEdit) { return } - const $table = this.$refs['xTable'] + const $table = this.$refs['xTable'].getVxetableRef() const data = {} this.columns.forEach((item) => { if ( @@ -1501,10 +1270,10 @@ export default { if (_find && _find.value_type === '6') jsonAttrList.push(key) }) const data = _.cloneDeep([ - ...this.$refs.xTable.getCheckboxReserveRecords(), - ...this.$refs.xTable.getCheckboxRecords(true), + ...this.$refs.xTable.getVxetableRef().getCheckboxReserveRecords(), + ...this.$refs.xTable.getVxetableRef().getCheckboxRecords(true), ]) - this.$refs.xTable.exportData({ + this.$refs.xTable.getVxetableRef().exportData({ filename, type, columnFilterMethod({ column }) { @@ -1518,8 +1287,8 @@ export default { ], }) this.selectedRowKeys = [] - this.$refs.xTable.clearCheckboxRow() - this.$refs.xTable.clearCheckboxReserve() + this.$refs.xTable.getVxetableRef().clearCheckboxRow() + this.$refs.xTable.getVxetableRef().clearCheckboxReserve() }, batchDelete() { const that = this @@ -1543,25 +1312,13 @@ export default { .finally(() => { that.loading = false that.selectedRowKeys = [] - that.$refs.xTable.clearCheckboxRow() - that.$refs.xTable.clearCheckboxReserve() + that.$refs.xTable.getVxetableRef().clearCheckboxRow() + that.$refs.xTable.getVxetableRef().clearCheckboxReserve() that.loadData({ parameter: {}, refreshType: 'refreshNumber' }) }) }, }) }, - handleFocusJson({ column, row }) { - this.$refs.jsonEditor.open(column, row) - }, - jsonEditorOk(row, column, jsonData) { - // 后端写数据有快慢,不拉接口直接修改table的数据 - this.instanceList.forEach((item) => { - if (item._id === row._id) { - item[column.property] = JSON.stringify(jsonData) - } - }) - this.$refs.xTable.refreshColumn() - }, relationViewRefreshNumber() { this.loadData({ parameter: {}, refreshType: 'refreshNumber' }) }, @@ -1585,7 +1342,9 @@ export default { }) }, setPreferenceSearchCurrent(id = null) { - this.$refs.preferenceSearch.currentPreferenceSearch = id + this.$nextTick(() => { + this.$refs.preferenceSearch.currentPreferenceSearch = id + }) }, copyExpression() { const expression = this.$refs['search'].expression || '' @@ -1846,8 +1605,8 @@ export default { return array }, - getRowSeq(row) { - return this.$refs.xTable.getRowSeq(row) + openDetail(id, activeTabKey, ciDetailRelationKey) { + this.$refs.detail.create(id, activeTabKey, ciDetailRelationKey) } }, } @@ -1916,36 +1675,6 @@ export default { background-color: #fff; padding: 20px; border-radius: @border-radius-box; - - .checkbox-hover-table { - .vxe-table--body-wrapper { - .vxe-checkbox--label { - display: inline; - padding-left: 0px !important; - color: #bfbfbf; - } - - .vxe-icon-checkbox-unchecked { - display: none; - } - - .vxe-icon-checkbox-checked ~ .vxe-checkbox--label { - display: none; - } - - .vxe-cell--checkbox { - &:hover { - .vxe-icon-checkbox-unchecked { - display: inline; - } - - .vxe-checkbox--label { - display: none; - } - } - } - } - } } } diff --git a/cmdb-ui/src/modules/cmdb/views/tree_views/index.vue b/cmdb-ui/src/modules/cmdb/views/tree_views/index.vue index 3883c5b..47268d3 100644 --- a/cmdb-ui/src/modules/cmdb/views/tree_views/index.vue +++ b/cmdb-ui/src/modules/cmdb/views/tree_views/index.vue @@ -144,209 +144,25 @@
- - - - - - - - - - - - - - - - + @sort-change="handleSortCol" + @openDetail="openDetail" + @deleteCI="deleteCI" + /> +
-
@@ -420,38 +235,36 @@ import { getCITypes } from '@/modules/cmdb/api/CIType' import { getCITableColumns } from '../../utils/helper' import SearchForm from '../../components/searchForm/SearchForm.vue' import SubscribeSetting from '../../components/subscribeSetting/subscribeSetting' -import PasswordField from '../../components/passwordField/index.vue' import SplitPane from '@/components/SplitPane' import TreeViewsNode from './modules/treeViewsNode.vue' import EditAttrsPopover from '../ci/modules/editAttrsPopover.vue' import CiDetailDrawer from '../ci/modules/ciDetailDrawer.vue' import CreateInstanceForm from '../ci/modules/CreateInstanceForm' import { getCITypeAttributesById } from '@/modules/cmdb/api/CITypeAttr' -import JsonEditor from '../../components/JsonEditor/jsonEditor.vue' import BatchDownload from '../../components/batchDownload/batchDownload.vue' import PreferenceSearch from '../../components/preferenceSearch/preferenceSearch.vue' import MetadataDrawer from '../ci/modules/MetadataDrawer.vue' import { intersection } from '@/utils/functions/set' import { ops_move_icon as OpsMoveIcon } from '@/core/icons' import { getAttrPassword } from '../../api/CITypeAttr' +import CITable from '@/modules/cmdb/components/ciTable/index.vue' export default { name: 'TreeViews', components: { SearchForm, SubscribeSetting, - PasswordField, SplitPane, TreeViewsNode, EditAttrsPopover, CiDetailDrawer, CreateInstanceForm, - JsonEditor, BatchDownload, PreferenceSearch, MetadataDrawer, OpsMoveIcon, draggable, + CITable }, data() { return { @@ -516,10 +329,6 @@ export default { const _find = this.subscribeTreeViewCiTypes.find((item) => item.type_id === Number(this.typeId)) return _find?.id }, - isCheckboxFixed() { - const idx = this.columns.findIndex((item) => item.is_fixed) - return idx > -1 - }, currentCiTypeName() { const _find = this.citypes.find((item) => Number(item.id) === Number(this.typeId)) return _find?.alias || _find?.name || '' @@ -858,33 +667,6 @@ export default { this.currentPage = 1 this.handleLoadInstance({ sortByTable }) }, - getChoiceValueStyle(col, colValue) { - const _find = col.filters.find((item) => String(item[0]) === String(colValue)) - if (_find) { - return _find[1]?.style || {} - } - return {} - }, - getChoiceValueIcon(col, colValue) { - const _find = col.filters.find((item) => String(item[0]) === String(colValue)) - if (_find) { - return _find[1]?.icon || {} - } - return {} - }, - getCellStyle({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex }) { - const { property } = column - const _find = this.currentAttrList.find((attr) => attr.name === property) - if ( - _find && - _find.option && - _find.option.fontOptions && - row[`${property}`] !== undefined && - row[`${property}`] !== null - ) { - return { ..._find.option.fontOptions } - } - }, onNodeClick(keys, type) { console.log(keys) if (keys) { @@ -921,9 +703,7 @@ export default { }, }) }, - onSelectChange(e) { - const xTable = this.$refs.xTable.getVxetableRef() - const records = [...xTable.getCheckboxRecords(), ...xTable.getCheckboxReserveRecords()] + onSelectChange(records) { this.selectedRowKeys = records.map((i) => i.ci_id || i._id) }, setSelectRows() { @@ -942,9 +722,6 @@ export default { this.$refs['xTable'].getVxetableRef().setCheckboxRow(rows, true) } }, - onSelectRangeEnd({ records }) { - this.selectedRowKeys = records.map((i) => i.ci_id || i._id) - }, handleEditActived() { const passwordCol = this.columns.filter((col) => col.is_password) this.$nextTick(() => { @@ -1023,28 +800,6 @@ export default { } }) }, - jsonEditorOk(row, column, jsonData) { - // 后端写数据有快慢,不拉接口直接修改table的数据 - // this.reloadData() - this.instanceList.forEach((item) => { - if (item._id === row._id) { - item[column.property] = JSON.stringify(jsonData) - } - }) - this.$refs.xTable.getVxetableRef().refreshColumn() - }, - getColumnsEditRender(col) { - const _editRender = { - ...col.editRender, - } - if (col.value_type === '6') { - _editRender.events = { focus: this.handleFocusJson } - } - return _editRender - }, - handleFocusJson({ column, row }) { - this.$refs.jsonEditor.open(column, row) - }, async openBatchDownload() { this.$refs.batchDownload.open({ preferenceAttrList: this.currentAttrList, ciTypeName: this.currentCiTypeName }) }, @@ -1237,8 +992,8 @@ export default { } ) }, - getRowSeq(row) { - return this.$refs.xTable.getVxetableRef().getRowSeq(row) + openDetail(id, activeTabKey, ciDetailRelationKey) { + this.$refs.detail.create(id, activeTabKey, ciDetailRelationKey) } }, } @@ -1348,36 +1103,6 @@ export default { overflow: auto; width: 100%; border-radius: @border-radius-box; - - .checkbox-hover-table { - .vxe-table--body-wrapper { - .vxe-checkbox--label { - display: inline; - padding-left: 0px !important; - color: #bfbfbf; - } - - .vxe-icon-checkbox-unchecked { - display: none; - } - - .vxe-icon-checkbox-checked ~ .vxe-checkbox--label { - display: none; - } - - .vxe-cell--checkbox { - &:hover { - .vxe-icon-checkbox-unchecked { - display: inline; - } - - .vxe-checkbox--label { - display: none; - } - } - } - } - } } }