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 @@
+
+
+
+
+
+ {{ getRowSeq(row) }}
+
+
+
+
+
+
+ {{ col.title }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ choice[0] }}
+
+
+
+
+
+ {{ row[col.field] }}
+
+
+ {{ item }}
+
+
+
+
+
+
+
+ {{ value }}
+
+
+
+
+
+
+ {{ $t('operation') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ loadingTip || $t('loading') }}
+
+
+
![]()
+
{{ $t('noData') }}
+
+
+
+ {{ loadingTip || $t('loading') }}
+
+
+
+
+
+
+
+
+
+
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 @@
-
-
-
- {{ getRowSeq(row) }}
-
-
-
-
-
-
- {{ col.title }}
-
-
-
-
-
-
-
-
-
-
-
- {{ choice[0] }}
-
-
-
-
-
- {{ row[col.field] }}
-
-
- {{ item }}
-
-
-
-
-
-
-
- {{ value }}
-
-
-
-
-
- {{ row[col.field] }}
-
-
-
-
-
-
- {{ $t('operation') }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ $t('loading') }}
-
-
![]()
-
{{ $t('noData') }}
-
-
-
+ @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 @@
-