From c6a03b46079bf8fd68bf8840850afab32c68a4b8 Mon Sep 17 00:00:00 2001 From: wjh-home Date: Tue, 26 May 2026 11:48:57 +0800 Subject: [PATCH 1/8] feat(api): add mobile CI detail endpoint with attribute alias map - Add CIMobileDetailView at /ci//mobile - Return core attributes, parent/child relations, and recent history - Include attribute_alias_map for frontend alias display" --- cmdb-api/api/views/cmdb/ci.py | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/cmdb-api/api/views/cmdb/ci.py b/cmdb-api/api/views/cmdb/ci.py index b53f0c6dc..566de07df 100644 --- a/cmdb-api/api/views/cmdb/ci.py +++ b/cmdb-api/api/views/cmdb/ci.py @@ -276,3 +276,54 @@ def post(self, ci_id): return self.jsonify(**CIManager().rollback(ci_id, before_date)) return self.get(ci_id) + + +class CIMobileDetailView(APIView): + url_prefix = "/ci//mobile" + + def get(self, ci_id): + ci = CIManager.get_ci_by_id_from_db(ci_id, ret_key=RetKey.NAME, fields=None, valid=True) + + ci_type = CITypeCache.get(ci.get("_type", 0)) if ci.get("_type") else None + type_info = {"id": ci_type.id, "name": ci_type.name, "alias": ci_type.alias} if ci_type else {} + + attribute_alias_map = {} + if ci_type: + from api.lib.cmdb.ci_type import CITypeAttributeManager + attrs = CITypeAttributeManager.get_attr_names_by_type_id(ci_type.id) + if attrs: + from api.lib.cmdb.cache import AttributeCache + for attr_name in attrs: + attr_obj = AttributeCache.get(attr_name) + if attr_obj: + attribute_alias_map[attr_obj.name] = attr_obj.alias or attr_obj.name + + relations = {"parents": [], "children": []} + try: + from api.lib.cmdb.ci import CIRelationManager + children = CIRelationManager.get_children(ci_id, ret_key=RetKey.NAME) + for type_name, cis in children.items(): + for c in cis: + c["_type_name"] = type_name + relations["children"].append(c) + + parent_ids = CIRelationManager.get_parent_ids([ci_id]) + if ci_id in parent_ids: + for p_id, p_type_id in parent_ids[ci_id]: + parent_ci = CIManager.get_cis_by_ids([str(p_id)], ret_key=RetKey.NAME) + if parent_ci: + for p in parent_ci: + p["_type_name"] = CITypeCache.get(p_type_id).name if p_type_id else "" + relations["parents"].append(p) + except Exception: + pass + + from api.lib.cmdb.history import AttributeHistoryManger + try: + history = AttributeHistoryManger.get_by_ci_id(ci_id) + history = history[:10] + except Exception: + history = [] + + return self.jsonify(ci=ci, type=type_info, relations=relations, history=history, + attribute_alias_map=attribute_alias_map) From af5b8b613ef793b21c121ed29312d866ae4334bc Mon Sep 17 00:00:00 2001 From: wjh-home Date: Tue, 26 May 2026 11:53:46 +0800 Subject: [PATCH 2/8] feat(ui): add QR code button, batch QR export and mobile detail page - Add QRCodeButton component for single CI QR code generation/download - Add QRCodeBatchExport component for batch QR code download/print - Add CIMobileDetail mobile-optimized detail page - Add /cmdb/mobile/:typeId/:ciId route in constant router" --- cmdb-ui/package.json | 8 +- .../cmdb/components/QRCodeBatchExport.vue | 232 +++++++++ .../modules/cmdb/components/QRCodeButton.vue | 141 +++++ .../cmdb/views/mobile/CIMobileDetail.vue | 491 ++++++++++++++++++ cmdb-ui/src/router/config.js | 7 + 5 files changed, 875 insertions(+), 4 deletions(-) create mode 100644 cmdb-ui/src/modules/cmdb/components/QRCodeBatchExport.vue create mode 100644 cmdb-ui/src/modules/cmdb/components/QRCodeButton.vue create mode 100644 cmdb-ui/src/modules/cmdb/views/mobile/CIMobileDetail.vue diff --git a/cmdb-ui/package.json b/cmdb-ui/package.json index 5780a57d0..982969888 100644 --- a/cmdb-ui/package.json +++ b/cmdb-ui/package.json @@ -23,6 +23,7 @@ "axios": "0.18.0", "babel-eslint": "^8.2.2", "butterfly-dag": "^4.3.26", + "codemirror": "^5.65.13", "core-js": "^3.31.0", "echarts": "^5.3.2", "element-ui": "^2.15.10", @@ -37,18 +38,17 @@ "lodash.pick": "^4.4.0", "md5": "^2.2.1", "moment": "^2.24.0", - "monaco-editor": "^0.28.1", - "monaco-editor-webpack-plugin": "^4.2.0", - "monaco-vim": "^0.4.4", "nprogress": "^0.2.0", + "qrcode": "^1.5.4", "relation-graph": "^2.1.42", "snabbdom": "^3.5.1", "sortablejs": "1.9.0", "style-resources-loader": "^1.5.0", "viser-vue": "^2.4.8", "vue": "2.6.11", - "vue-clipboard2": "^0.3.3", "vue-cli-plugin-style-resources-loader": "^0.1.5", + "vue-clipboard2": "^0.3.3", + "vue-codemirror": "^4.0.6", "vue-cropper": "^0.6.2", "vue-grid-layout": "2.3.12", "vue-i18n": "8.28.2", diff --git a/cmdb-ui/src/modules/cmdb/components/QRCodeBatchExport.vue b/cmdb-ui/src/modules/cmdb/components/QRCodeBatchExport.vue new file mode 100644 index 000000000..bf228709c --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/components/QRCodeBatchExport.vue @@ -0,0 +1,232 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/components/QRCodeButton.vue b/cmdb-ui/src/modules/cmdb/components/QRCodeButton.vue new file mode 100644 index 000000000..ae096a646 --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/components/QRCodeButton.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/views/mobile/CIMobileDetail.vue b/cmdb-ui/src/modules/cmdb/views/mobile/CIMobileDetail.vue new file mode 100644 index 000000000..af182f203 --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/views/mobile/CIMobileDetail.vue @@ -0,0 +1,491 @@ + + + + + diff --git a/cmdb-ui/src/router/config.js b/cmdb-ui/src/router/config.js index 0be7e6020..c8e3a0f5a 100644 --- a/cmdb-ui/src/router/config.js +++ b/cmdb-ui/src/router/config.js @@ -103,6 +103,13 @@ export const constantRouterMap = [ redirect: appConfig.redirectTo, // redirect: () => { return store.getters.appRoutes[0] }, }, + { + path: '/cmdb/mobile/:typeId/:ciId', + name: 'cmdb_mobile_detail', + hidden: true, + meta: { title: 'cmdb.ci.mobileDetail' }, + component: () => import(/* webpackChunkName: "mobile" */ '@/modules/cmdb/views/mobile/CIMobileDetail.vue') + }, { path: '/user/login', name: 'login', From 27019c6981a1406c55b288ead97b238e6a8133f9 Mon Sep 17 00:00:00 2001 From: wjh-home Date: Tue, 26 May 2026 12:00:51 +0800 Subject: [PATCH 3/8] feat(ui): integrate QR code into CI detail page and batch export with Excel - Add QR code button in ciDetailTab tab bar - Add QR export option in batch download modal (batchDownload.vue) - Export QR code images embedded in Excel cells via ExcelJS - Add batch QR export entry in instanceList action bar and dropdown menu" --- cmdb-ui/src/modules/cmdb/api/ci.js | 8 ++ .../batchDownload/batchDownload.vue | 5 + .../modules/cmdb/views/ci/instanceList.vue | 128 +++++++++++++++++- .../cmdb/views/ci/modules/ciDetailTab.vue | 15 +- 4 files changed, 147 insertions(+), 9 deletions(-) diff --git a/cmdb-ui/src/modules/cmdb/api/ci.js b/cmdb-ui/src/modules/cmdb/api/ci.js index 71b07ef8f..579f1a9ff 100644 --- a/cmdb-ui/src/modules/cmdb/api/ci.js +++ b/cmdb-ui/src/modules/cmdb/api/ci.js @@ -52,6 +52,14 @@ export function getCIById(ciId) { }) } +// 获取移动端CI详情 +export function getCIMobileDetail(ciId) { + return axios({ + url: urlPrefix + `/ci/${ciId}/mobile`, + method: 'GET' + }) +} + // 获取自动发现占比 export function getCIAdcStatistics() { return axios({ diff --git a/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue b/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue index 16eaf3f8c..3e7200409 100644 --- a/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue +++ b/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue @@ -27,6 +27,11 @@ {{ item.label }} + + + {{ $t('cmdb.ci.qrcodeExport') }} + +
{{ $t('cmdb.menu.citypeManage') }} + + + {{ $t('cmdb.ci.qrcodeExportAll') }} + @@ -76,6 +83,8 @@
{{ $t('update') }} + {{ $t('cmdb.ci.qrcodeExport') }} + {{ $t('download') }} {{ $t('delete') }} @@ -141,6 +150,7 @@ /> +
@@ -151,6 +161,9 @@