From 7186bdac9c32bb491f4ae8b644e202246a97a9df Mon Sep 17 00:00:00 2001 From: simontigers <47096077+simontigers@users.noreply.github.com> Date: Wed, 3 Jan 2024 12:29:49 +0800 Subject: [PATCH 1/8] fix(api): common_i18n wide (#350) --- cmdb-api/api/lib/common_setting/department.py | 2 ++ .../api/lib/common_setting/resp_format.py | 4 +++- .../translations/zh/LC_MESSAGES/messages.mo | Bin 16386 -> 16425 bytes .../translations/zh/LC_MESSAGES/messages.po | 6 +++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmdb-api/api/lib/common_setting/department.py b/cmdb-api/api/lib/common_setting/department.py index f068b53..d63d43b 100644 --- a/cmdb-api/api/lib/common_setting/department.py +++ b/cmdb-api/api/lib/common_setting/department.py @@ -101,6 +101,7 @@ class DepartmentTree(object): employees = self.get_employees_by_d_id(department_id) top_d['employees'] = employees + top_d['department_name'] = ErrFormat.company_wide if len(sub_deps) == 0: top_d[sub_departments_column_name] = [] d_list.append(top_d) @@ -313,6 +314,7 @@ class DepartmentCRUD(object): tree_list = [] for top_d in top_deps: + top_d['department_name'] = ErrFormat.company_wide tree = Tree() identifier_root = top_d['department_id'] tree.create_node( diff --git a/cmdb-api/api/lib/common_setting/resp_format.py b/cmdb-api/api/lib/common_setting/resp_format.py index 12973ab..676e17b 100644 --- a/cmdb-api/api/lib/common_setting/resp_format.py +++ b/cmdb-api/api/lib/common_setting/resp_format.py @@ -66,7 +66,7 @@ class ErrFormat(CommonErrFormat): notice_platform_existed = _l("Notice platform {} existed") # {} 已存在 notice_not_existed = _l("Notice {} not existed") # {} 配置项不存在 notice_please_config_messenger_first = _l("Notice please config messenger first") # 请先配置messenger URL - notice_bind_err_with_empty_mobile = _l("Notice bind err with empty mobile") # 绑定错误,手机号为空 + notice_bind_err_with_empty_mobile = _l("Notice bind err with empty mobile") # 绑定错误,手机号为空 notice_bind_failed = _l("Notice bind failed: {}") # 绑定失败: {} notice_bind_success = _l("Notice bind success") # 绑定成功 notice_remove_bind_success = _l("Notice remove bind success") # 解绑成功 @@ -78,3 +78,5 @@ class ErrFormat(CommonErrFormat): ldap_test_unknown_error = _l("LDAP test unknown error: {}") # LDAP测试未知错误: {} common_data_not_support_auth_type = _l("Common data not support auth type: {}") # 通用数据不支持auth类型: {} ldap_test_username_required = _l("LDAP test username required") # LDAP测试用户名必填 + + company_wide = _l("Company wide") # 全公司 diff --git a/cmdb-api/api/translations/zh/LC_MESSAGES/messages.mo b/cmdb-api/api/translations/zh/LC_MESSAGES/messages.mo index a02d5eb49fa4e3204377eb0864e2041f8f3bc127..8620fafd5bd7abaccfcc6ff3767e122c9e60c697 100644 GIT binary patch delta 3265 zcmYM#dra0<9LMo53QY|Z@d3FBkD1~H@IgQXM4y~w>NHI)?=6Rx7X(vl*z#vhyya2@ zGF{q=nmAE6m}Xv@4b3?dYq~5`%0JX(|@Be>`BF(zfEp=96D*YW8kH=8Y{fLQp51+=)QD(82jT#?~ zy|Dy);08=F^Q?|WfPqsu1zT}2j_+*N6Dys&P#c{_EpQ#vFuY61bR0>4GIqdi7=xc- zAs)a!co(0-_-Hd9`&%K6ZVXI71yX{!ScBT&45|Y6Fae+J8p@D%OT7wU39jZXPPoNvL(^#!`PRfD05Z2M6g zUU1$-Z5YmA0s1iyXW&4rLZ(<#cj`}&c8LL<-ECCnZKw#NsG~}m<_x07r=bE~idv`! zDW27%DtR0g*e|ZHhseQ_P!-9-;W*i&F@i=l>XKYUUAhODg{iEj2PR@)T!yN^4piVr zP?zd^EW%sJqc(u_RoP+;URvEl$BJn2Xtdv;H_ARmp1CKZ>fv4b=MaWI0gpe-RCRnMzR$RG~IFjan#z@(jZO zvWJ!7aNLAr@f?o9B{L*XDfqG@& z5Y&4=5A`-IN4*_ukgu~F z1w796XFI(muCW@m@K)5qjc)uqcrEH^4!iM-sDiwTcLmAFSJ-AqZz;&q7)wuCJIF$ZL%*S@Qp%2nf)ay4Bx!C5R*4cxq zQWSYCtV`&iMz%(r=#^$|M0*`u?a27NgF3 zmK%S|jem$f#`n4LrabE3oq-lN;l7*Dc}Qr3UdV;EeAJP=hN-v-dG&2SsuGtl9({C% zV+InVm7?ZHO*Srf9AeXoZsE~@<9N=Y6YnaQ>Ch8Pi(>>@cX;L^F zW`=ZeQZZ~IYbJJqGAC|jx#hfKjhwo&IhJ!vq`p7iv&HoNoO7P@obx~bbI$W=RnX3= zAg{~!c%AWgn*XEupFL2u|NmADF^i(Q(zyl4QhyUi;!)IlXD|l4aRT;X1dbmXXwSfj z)Jt#-zKXGCo*kf&NW%$SjJGijbB39X!!6EtP!pX*4R8@B8_dY9$e&{VT96RA9?d8L33| z+l$InlY4&7wcm2>K}0u-`E4A9@i+suvQj-j50%3Akbl;~PdJ`-^~=au_NS}&p#lhH zHQI`47>NZKhbvGStwvIBP3Wm(Ck0LTJF>X`S;(q|GMfVMqgIrLdU27n9Lc7=g?ZS3 z%G3>1iXWiHjbRW4nuZ!@E^3@r5#(PH?Vv#&4?DkcUd88We}Kx&5|$%3qYl|V)PyIT z=TYO_!b}Y2VLImE(^!E#vPL8}`znh3b5QL94O;mPRD}0XsT|CY9M6y1vrz#rK@GGO zNt)H7GI=#aFb4%-z>!p9g*FQniUT#8zG6)N%u z)S+v|8Tb?OstsfLO6?R(#5t(5wbfaV>er4M-@8IVd-Djjvf+#>lhBXF&do>{t8=!X zR{8^yEbBoHJeVj|pMY9$n)(F%={IoOoP-%4DUhzmLkqIn?+MQD?!=DktjxFQT9UDo_(NqXxQ-IT%Ks zn8S)N7dPR2JdTCfhg#u0@=VccQ2`&vS$GxM9gAglWhetxFUB#A9O825B{1}zmFR>7BqTWyBL@BjPof}d8_qh58NHVPrwSXI_ zj0DA#f2}YzKCt3hNN`q+3TQhjfP<(nT?;BR9jJa6P-mwXHE=R%K_Mis*#Q7~oP``#+Ne?RZ!Rdjs5sTXEG*o+uYcI!e z>bqTgy=y<=JfBYf)!`NmnxGds$mV+{uq885D}EWd>Q;@)L@SQOyO@guX(T3l7S(?{ zs{bL>H9dOG&ov5w3j_jHZVjnpMmV?A#n^5C5dlW`fID>49bz=-h6K*7?U=+?rP4psaEg6;Ki?(*>x7Ek_+fZv%ye6sl0E`w{iU`U_*xM}8GZ68dp2 zDnn&B2>0L+taJ5`T)i3f{z+6omr#MyfxmS1YX7G4*2*Ei0j>K(zl$6?Js~MM YAvw*Tn30*1)cVqtngOl72?@Uc0FKg7-v9sr diff --git a/cmdb-api/api/translations/zh/LC_MESSAGES/messages.po b/cmdb-api/api/translations/zh/LC_MESSAGES/messages.po index c27bf1a..1eeb467 100644 --- a/cmdb-api/api/translations/zh/LC_MESSAGES/messages.po +++ b/cmdb-api/api/translations/zh/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-12-26 09:41+0800\n" +"POT-Creation-Date: 2024-01-03 11:39+0800\n" "PO-Revision-Date: 2023-12-25 20:21+0800\n" "Last-Translator: FULL NAME \n" "Language: zh\n" @@ -688,6 +688,10 @@ msgstr "通用数据不支持auth类型: {}" msgid "LDAP test username required" msgstr "LDAP测试用户名必填" +#: api/lib/common_setting/resp_format.py:82 +msgid "Company wide" +msgstr "全公司" + #: api/lib/perm/acl/resp_format.py:9 msgid "login successful" msgstr "登录成功" From 9ee2776bdd158212e1591ecd1434e6cfe33765ee Mon Sep 17 00:00:00 2001 From: simontigers <47096077+simontigers@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:26:58 +0800 Subject: [PATCH 2/8] fix(api): common i18n wide (#351) * fix(api): common_i18n wide * fix(api): department i18n --- cmdb-api/api/lib/common_setting/department.py | 3 +++ cmdb-api/api/lib/common_setting/employee.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/cmdb-api/api/lib/common_setting/department.py b/cmdb-api/api/lib/common_setting/department.py index d63d43b..9d11785 100644 --- a/cmdb-api/api/lib/common_setting/department.py +++ b/cmdb-api/api/lib/common_setting/department.py @@ -385,6 +385,9 @@ class DepartmentCRUD(object): d['employee_count'] = len(list(filter(lambda e: e['department_id'] in d_ids, all_employee_list))) + if int(department_parent_id) == -1: + d['department_name'] = ErrFormat.company_wide + return all_departments, department_id_list @staticmethod diff --git a/cmdb-api/api/lib/common_setting/employee.py b/cmdb-api/api/lib/common_setting/employee.py index 804c514..2836919 100644 --- a/cmdb-api/api/lib/common_setting/employee.py +++ b/cmdb-api/api/lib/common_setting/employee.py @@ -296,6 +296,8 @@ class EmployeeCRUD(object): for r in pagination.items: d = r.Employee.to_dict() d['department_name'] = r.Department.department_name if r.Department else '' + if r.Employee.department_id == 0: + d['department_name'] = ErrFormat.company_wide employees.append(d) return { From ec884c92e117aee4f1fe6fc2a39c1b3a99ac92e0 Mon Sep 17 00:00:00 2001 From: wang-liang0615 <53748875+wang-liang0615@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:29:38 +0800 Subject: [PATCH 3/8] feat(ui):i18n (#352) --- .../src/components/CustomCodeMirror/index.vue | 17 +- .../src/components/CustomIconSelect/index.vue | 2 +- cmdb-ui/src/components/Menu/menu.js | 22 +- cmdb-ui/src/components/tools/UserMenu.vue | 4 +- cmdb-ui/src/lang/en.js | 6 +- cmdb-ui/src/lang/zh.js | 6 +- .../cmdb/components/httpSnmpAD/index.vue | 6 +- .../views/custom_dashboard/customLayout.vue | 2 +- .../modules/cmdb/views/preference/index.vue | 4 +- cmdb-ui/src/utils/request.js | 9 +- .../setting/companyStructure/BatchModal.vue | 14 +- .../setting/companyStructure/BatchUpload.vue | 53 +- .../views/setting/companyStructure/index.vue | 2 - .../setting/components/employeeTable.vue | 708 +----------------- cmdb-ui/src/views/setting/lang/en.js | 2 +- 15 files changed, 62 insertions(+), 795 deletions(-) diff --git a/cmdb-ui/src/components/CustomCodeMirror/index.vue b/cmdb-ui/src/components/CustomCodeMirror/index.vue index 17b9635..4c41281 100644 --- a/cmdb-ui/src/components/CustomCodeMirror/index.vue +++ b/cmdb-ui/src/components/CustomCodeMirror/index.vue @@ -89,20 +89,23 @@ export default { }, }, data() { - const keyMapList = [ - { value: 'default', label: '默认' }, - { value: 'vim', label: 'vim' }, - { value: 'emacs', label: 'emacs' }, - { value: 'sublime', label: 'sublime' }, - ] return { - keyMapList, coder: null, fontSize: 14, keyMap: 'default', fullscreenExitVisible: false, } }, + computed: { + keyMapList() { + return [ + { value: 'default', label: this.$t('default') }, + { value: 'vim', label: 'vim' }, + { value: 'emacs', label: 'emacs' }, + { value: 'sublime', label: 'sublime' }, + ] + }, + }, mounted() {}, methods: { initCodeMirror(codeContent) { diff --git a/cmdb-ui/src/components/CustomIconSelect/index.vue b/cmdb-ui/src/components/CustomIconSelect/index.vue index b056614..292b5d2 100644 --- a/cmdb-ui/src/components/CustomIconSelect/index.vue +++ b/cmdb-ui/src/components/CustomIconSelect/index.vue @@ -92,7 +92,7 @@ :show-upload-list="false" accept=".svg,.png,.jpg,.jpeg" > - 暂无自定义图标,点击此处上传 + {{ $t('customIconSelect.nodata') }} diff --git a/cmdb-ui/src/components/Menu/menu.js b/cmdb-ui/src/components/Menu/menu.js index 2efc86b..5fd203a 100644 --- a/cmdb-ui/src/components/Menu/menu.js +++ b/cmdb-ui/src/components/Menu/menu.js @@ -81,25 +81,23 @@ export default { }, inject: ['reload'], methods: { - // 取消订阅 cancelAttributes(e, menu) { const that = this e.preventDefault() e.stopPropagation() this.$confirm({ - title: '警告', - content: `确认取消订阅 ${menu.meta.title}?`, + title: this.$t('alert'), + content: this.$t('cmdb.preference.confirmcancelSub2', { name: menu.meta.title }), onOk() { const citypeId = menu.meta.typeId const unsubCIType = subscribeCIType(citypeId, '') const unsubTree = subscribeTreeView(citypeId, '') Promise.all([unsubCIType, unsubTree]).then(() => { - that.$message.success('取消订阅成功') + that.$message.success(that.$t('cmdb.preference.cancelSubSuccess')) const lastTypeId = window.localStorage.getItem('ops_ci_typeid') || undefined if (Number(citypeId) === Number(lastTypeId)) { localStorage.setItem('ops_ci_typeid', '') } - // 删除路由 const href = window.location.href const hrefSplit = href.split('/') if (Number(hrefSplit[hrefSplit.length - 1]) === Number(citypeId)) { @@ -119,12 +117,10 @@ export default { }, // select menu item onOpenChange(openKeys) { - // 在水平模式下时执行,并且不再执行后续 if (this.mode === 'horizontal') { this.openKeys = openKeys return } - // 非水平模式时 const latestOpenKey = openKeys.find(key => !this.openKeys.includes(key)) if (!this.rootSubmenuKeys.includes(latestOpenKey)) { this.openKeys = openKeys @@ -162,6 +158,9 @@ export default { return null }, renderI18n(title) { + if (Object.prototype.toString.call(this.$t(`${title}`)) === '[object Object]') { + return title + } return this.$t(`${title}`) }, renderMenuItem(menu) { @@ -173,9 +172,6 @@ export default { const attrs = { href: menu.meta.targetHref || menu.path, target: menu.meta.target } if (menu.children && menu.hideChildrenInMenu) { - // 把有子菜单的 并且 父菜单是要隐藏子菜单的 - // 都给子菜单增加一个 hidden 属性 - // 用来给刷新页面时, selectedKeys 做控制用 menu.children.forEach(item => { item.meta = Object.assign(item.meta, { hidden: true }) }) @@ -196,8 +192,8 @@ export default { getPopupContainer={(trigger) => trigger} content={() =>
-
this.handlePerm(e, menu, 'CIType')} class="custom-menu-extra-submenu-item">授权
-
this.cancelAttributes(e, menu)} class="custom-menu-extra-submenu-item">取消订阅
+
this.handlePerm(e, menu, 'CIType')} class="custom-menu-extra-submenu-item">{ this.renderI18n('grant') }
+
this.cancelAttributes(e, menu)} class="custom-menu-extra-submenu-item">{ this.renderI18n('cmdb.preference.cancelSub') }
} > @@ -287,7 +283,7 @@ export default { this.$refs.cmdbGrantRelationView.open({ name: menu.meta.name, cmdbGrantType: 'relation_view' }) } } else { - this.$message.error('权限不足!') + this.$message.error(this.$t('noPermission')) } }) } diff --git a/cmdb-ui/src/components/tools/UserMenu.vue b/cmdb-ui/src/components/tools/UserMenu.vue index 74bf2ec..ed7e6b4 100644 --- a/cmdb-ui/src/components/tools/UserMenu.vue +++ b/cmdb-ui/src/components/tools/UserMenu.vue @@ -68,8 +68,8 @@ export default { const that = this this.$confirm({ - title: '提示', - content: '真的要注销登录吗 ?', + title: this.$t('tip'), + content: this.$t('topMenu.confirmLogout'), onOk() { // localStorage.removeItem('ops_cityps_currentId') localStorage.clear() diff --git a/cmdb-ui/src/lang/en.js b/cmdb-ui/src/lang/en.js index 63e2f3f..feba7ea 100644 --- a/cmdb-ui/src/lang/en.js +++ b/cmdb-ui/src/lang/en.js @@ -104,12 +104,15 @@ export default { max: 'Max', min: 'Min', visual: 'Visual', + default: 'default', + tip: 'Tip', pagination: { total: '{range0}-{range1} of {total} items' }, topMenu: { personalCenter: 'Personal Center', logout: 'logout', + confirmLogout: 'Are you sure to log out?' }, cmdbFilterComp: { conditionFilter: 'Conditional filtering', @@ -139,7 +142,8 @@ export default { multicolor: 'Multicolor', custom: 'Custom', preview: 'Preview', - sizeLimit: 'The image size cannot exceed 2MB!' + sizeLimit: 'The image size cannot exceed 2MB!', + nodata: 'There are currently no custom icons available. Click here to upload' }, cmdb: cmdb_en, cs: cs_en, diff --git a/cmdb-ui/src/lang/zh.js b/cmdb-ui/src/lang/zh.js index e0f722f..b31e555 100644 --- a/cmdb-ui/src/lang/zh.js +++ b/cmdb-ui/src/lang/zh.js @@ -104,12 +104,15 @@ export default { max: '最大值', min: '最小值', visual: '虚拟', + default: '默认', + tip: '提示', pagination: { total: '当前展示 {range0}-{range1} 条数据, 共 {total} 条' }, topMenu: { personalCenter: '个人中心', logout: '退出登录', + confirmLogout: '确认退出登录吗?' }, cmdbFilterComp: { conditionFilter: '条件过滤', @@ -139,7 +142,8 @@ export default { multicolor: '多色', custom: '自定义', preview: '预览', - sizeLimit: '图片大小不可超过2MB!' + sizeLimit: '图片大小不可超过2MB!', + nodata: '暂无自定义图标,点击此处上传' }, cmdb: cmdb_zh, cs: cs_zh, diff --git a/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue b/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue index a369162..2e19fa4 100644 --- a/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue +++ b/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue @@ -103,9 +103,9 @@ export default { }, httpMap() { return { - [this.$t('cmdb.components.aliyun')]: { name: 'aliyun' }, - [this.$t('cmdb.components.tencentcloud')]: { name: 'tencentcloud' }, - [this.$t('cmdb.components.huaweicloud')]: { name: 'huaweicloud' }, + 阿里云: { name: 'aliyun' }, + 腾讯云: { name: 'tencentcloud' }, + 华为云: { name: 'huaweicloud' }, AWS: { name: 'aws' }, } }, diff --git a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue index 63e75a2..58b2237 100644 --- a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue +++ b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue @@ -114,7 +114,7 @@ type="primary" icon="plus" > - 定制仪表盘 + {{ $t('cmdb.menu.customDashboard') }} {{ $t('cmdb.custom_dashboard.noCustomDashboard') }} diff --git a/cmdb-ui/src/modules/cmdb/views/preference/index.vue b/cmdb-ui/src/modules/cmdb/views/preference/index.vue index 8fd2003..da08e2a 100644 --- a/cmdb-ui/src/modules/cmdb/views/preference/index.vue +++ b/cmdb-ui/src/modules/cmdb/views/preference/index.vue @@ -16,7 +16,7 @@ height: '23px', fontSize: '14px', }" - />个
diff --git a/cmdb-ui/src/utils/request.js b/cmdb-ui/src/utils/request.js index 3ac2dfb..ba09e46 100644 --- a/cmdb-ui/src/utils/request.js +++ b/cmdb-ui/src/utils/request.js @@ -1,4 +1,4 @@ -/* eslint-dsiable */ + /* eslint-dsiable */ import Vue from 'vue' import axios from 'axios' import { VueAxios } from './axios' @@ -6,20 +6,22 @@ import message from 'ant-design-vue/es/message' import notification from 'ant-design-vue/es/notification' import { ACCESS_TOKEN } from '@/store/global/mutation-types' import router from '@/router' +import store from '@/store' // 创建 axios 实例 const service = axios.create({ baseURL: process.env.VUE_APP_API_BASE_URL, // api base_url timeout: 6000, // 请求超时时间 withCredentials: true, - crossDomain: true + crossDomain: true, }) const err = (error) => { console.log(error) const reg = /5\d{2}/g if (error.response && reg.test(error.response.status)) { - message.error('服务端未知错误, 请联系管理员!') + const errorMsg = ((error.response || {}).data || {}).message || '服务端未知错误, 请联系管理员!' + message.error(errorMsg) } else if (error.response.status === 412) { let seconds = 5 notification.warning({ @@ -64,6 +66,7 @@ service.interceptors.request.use(config => { if (token) { config.headers['Access-Token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改 } + config.headers['Accept-Language'] = store?.state?.locale ?? 'zh' return config }, err) diff --git a/cmdb-ui/src/views/setting/companyStructure/BatchModal.vue b/cmdb-ui/src/views/setting/companyStructure/BatchModal.vue index 69b55f1..25d3f2d 100644 --- a/cmdb-ui/src/views/setting/companyStructure/BatchModal.vue +++ b/cmdb-ui/src/views/setting/companyStructure/BatchModal.vue @@ -25,18 +25,6 @@ - - - - - @@ -75,7 +63,7 @@ export default { const validatePass = (rule, value, callback) => { console.log(this.batchForm) if (this.batchForm.value === '') { - callback(new Error(this.$t('cs.companyStructure.password_placeholder'))) + callback(new Error(this.$t('cs.companyStructure.passwordPlaceholder'))) } else { this.$refs.batchForm.validateField('repeatPassword') callback() diff --git a/cmdb-ui/src/views/setting/companyStructure/BatchUpload.vue b/cmdb-ui/src/views/setting/companyStructure/BatchUpload.vue index ccff2c4..d0b938c 100644 --- a/cmdb-ui/src/views/setting/companyStructure/BatchUpload.vue +++ b/cmdb-ui/src/views/setting/companyStructure/BatchUpload.vue @@ -20,19 +20,24 @@
- 导入总数据{{ allCount }}条, 导入成功 {{ allCount - errorCount }} 条, - {{ $t('cs.companyStructure.importSuccess', {allCount: allCount}) }}{{ allCount - errorCount }} - {{ $t('cs.companyStructure.count')}}, - {{ $t('cs.companyStructure.importError') }}{{ errorCount }}{{ $t('cs.companyStructure.count')}} + {{ $t('cs.companyStructure.importSuccess', { allCount: allCount }) + }} {{ allCount - errorCount }} {{ $t('cs.companyStructure.count') }}, + {{ $t('cs.companyStructure.importFailed') }} {{ errorCount }} {{ $t('cs.companyStructure.count') }}
{{ $t('cs.companyStructure.editPosition') }} - {{ $t('cs.companyStructure.editAnnualLeave') }} - {{ $t('cs.companyStructure.resetPassword') }} {{ $t('cs.companyStructure.block') }} diff --git a/cmdb-ui/src/views/setting/components/employeeTable.vue b/cmdb-ui/src/views/setting/components/employeeTable.vue index 85cd9e8..ad40758 100644 --- a/cmdb-ui/src/views/setting/components/employeeTable.vue +++ b/cmdb-ui/src/views/setting/components/employeeTable.vue @@ -92,6 +92,10 @@ {{ $t('cs.companyStructure.sex') }} + - - - - - - - - - - - - - - - I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Date: Wed, 3 Jan 2024 13:58:35 +0800 Subject: [PATCH 4/8] docs: update install (#354) --- docker-compose.yml | 1 + docs/local.md | 6 +++--- docs/local_en.md | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f9ac50b..2c7831c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: - db-data:/var/lib/mysql - ./docs/mysqld.cnf:/etc/mysql/conf.d/mysqld.cnf - ./docs/cmdb.sql:/docker-entrypoint-initdb.d/cmdb.sql + command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci networks: new: aliases: diff --git a/docs/local.md b/docs/local.md index 9879dbd..56093a4 100644 --- a/docs/local.md +++ b/docs/local.md @@ -1,16 +1,16 @@ ## 本地搭建: 环境和依赖 - 存储: mysql, redis -- python 版本: >=python3.7 +- python 版本: 3.8 <= python <= 3.11 ## Install - 启动 mysql 服务, redis 服务 > mysql一定要设置sql_mode, root进入mysql执行: > -> `set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';` +> `set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';` > -> `set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';` +> `set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';` - 创建数据库 cmdb - 拉取代码 diff --git a/docs/local_en.md b/docs/local_en.md index 6c78203..bfbe1ee 100644 --- a/docs/local_en.md +++ b/docs/local_en.md @@ -1,11 +1,14 @@ ### Install +- python version: 3.8 <= python <= 3.11 + + - Start mysql, redis > mysql must set sql_mode, and root enters mysql to execute: > -> `set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';` +> `set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';` > -> `set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';` +> `set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';` - Create mysql database: cmdb - Pull code From 995e581315120e58f69e8d4071839bb6027a1d4e Mon Sep 17 00:00:00 2001 From: simontigers <47096077+simontigers@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:26:40 +0800 Subject: [PATCH 5/8] fix(api): common department edit method (#355) --- cmdb-api/api/lib/common_setting/department.py | 10 +++++++++- cmdb-api/api/views/common_setting/department.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmdb-api/api/lib/common_setting/department.py b/cmdb-api/api/lib/common_setting/department.py index 9d11785..fe8c782 100644 --- a/cmdb-api/api/lib/common_setting/department.py +++ b/cmdb-api/api/lib/common_setting/department.py @@ -24,7 +24,15 @@ def get_all_department_list(to_dict=True): *criterion ).order_by(Department.department_id.asc()) results = query.all() - return [r.to_dict() for r in results] if to_dict else results + if to_dict: + datas = [] + for r in results: + d = r.to_dict() + if r.department_id == 0: + d['department_name'] = ErrFormat.company_wide + datas.append(d) + return datas + return results def get_all_employee_list(block=0, to_dict=True): diff --git a/cmdb-api/api/views/common_setting/department.py b/cmdb-api/api/views/common_setting/department.py index 9a8dd4a..7e3d4c8 100644 --- a/cmdb-api/api/views/common_setting/department.py +++ b/cmdb-api/api/views/common_setting/department.py @@ -85,7 +85,7 @@ class DepartmentIDView(APIView): class DepartmentParentView(APIView): url_prefix = (f'{prefix}/allow_parent',) - def get(self): + def put(self): department_id = request.args.get('department_id', None) if department_id is None: abort(400, ErrFormat.department_id_is_required) From 82ea1ddc791fa62a1b00a23aac3fa5e7f0264d4e Mon Sep 17 00:00:00 2001 From: simontigers <47096077+simontigers@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:31:54 +0800 Subject: [PATCH 6/8] fix(api): common department edit method (#356) * fix(api): common department edit method * fix(api): common department edit method --- cmdb-api/api/views/common_setting/department.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmdb-api/api/views/common_setting/department.py b/cmdb-api/api/views/common_setting/department.py index 7e3d4c8..c35538e 100644 --- a/cmdb-api/api/views/common_setting/department.py +++ b/cmdb-api/api/views/common_setting/department.py @@ -62,7 +62,7 @@ class DepartmentView(APIView): class DepartmentIDView(APIView): url_prefix = (f'{prefix}/',) - def get(self, _id): + def put(self, _id): form = DepartmentForm(MultiDict(request.json)) if not form.validate(): abort(400, ','.join(['{}: {}'.format(filed, ','.join(msg)) From c98199e98e2bd6833e8676d1927e239b7ba61ae0 Mon Sep 17 00:00:00 2001 From: wang-liang0615 <53748875+wang-liang0615@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:58:47 +0800 Subject: [PATCH 7/8] feat(ui):i18n (#357) * feat(ui):i18n * i18n --- .../acl/views/module/permissionForm.vue | 2 +- .../acl/views/module/resourceTypeForm.vue | 2 +- .../views/module/resourceTypeHistoryTable.vue | 2 +- .../modules/acl/views/module/triggerForm.vue | 20 +- .../modules/resourceTypeHistoryTable.vue | 2 +- .../src/modules/acl/views/resource_types.vue | 2 +- cmdb-ui/src/views/setting/auth/ldap.vue | 2 +- .../setting/companyStructure/BatchUpload.vue | 2 +- .../companyStructure/EmployeeModal.vue | 236 +----------------- .../views/setting/companyStructure/index.vue | 60 ----- cmdb-ui/src/views/setting/lang/en.js | 1 + cmdb-ui/src/views/setting/lang/zh.js | 1 + 12 files changed, 28 insertions(+), 304 deletions(-) diff --git a/cmdb-ui/src/modules/acl/views/module/permissionForm.vue b/cmdb-ui/src/modules/acl/views/module/permissionForm.vue index 8768117..6c1eb6e 100644 --- a/cmdb-ui/src/modules/acl/views/module/permissionForm.vue +++ b/cmdb-ui/src/modules/acl/views/module/permissionForm.vue @@ -1,7 +1,7 @@