diff --git a/cmdb-ui/src/api/company.js b/cmdb-ui/src/api/company.js
index 2b80af0..cae4bde 100644
--- a/cmdb-ui/src/api/company.js
+++ b/cmdb-ui/src/api/company.js
@@ -20,13 +20,7 @@ export function putCompanyInfo(id, parameter) {
data: parameter,
})
}
-export function postImageFile(parameter) {
- return axios({
- url: '/common-setting/v1/file',
- method: 'post',
- data: parameter,
- })
-}
+
export function getDepartmentList(params) {
// ?department_parent_id=-1 查询第一级部门,下面的id根据实际的传
return axios({
diff --git a/cmdb-ui/src/api/file.js b/cmdb-ui/src/api/file.js
new file mode 100644
index 0000000..e53e681
--- /dev/null
+++ b/cmdb-ui/src/api/file.js
@@ -0,0 +1,31 @@
+import { axios } from '@/utils/request'
+
+export function postImageFile(parameter) {
+ return axios({
+ url: '/common-setting/v1/file',
+ method: 'post',
+ data: parameter,
+ })
+}
+
+export function getFileData(data_type) {
+ return axios({
+ url: `/common-setting/v1/data/${data_type}`,
+ method: 'get',
+ })
+}
+
+export function addFileData(data_type, data) {
+ return axios({
+ url: `/common-setting/v1/data/${data_type}`,
+ method: 'post',
+ data,
+ })
+}
+
+export function deleteFileData(data_type, id) {
+ return axios({
+ url: `/common-setting/v1/data/${data_type}/${id}`,
+ method: 'delete',
+ })
+}
diff --git a/cmdb-ui/src/components/CustomIconSelect/index.vue b/cmdb-ui/src/components/CustomIconSelect/index.vue
index beac81f..dceaa8f 100644
--- a/cmdb-ui/src/components/CustomIconSelect/index.vue
+++ b/cmdb-ui/src/components/CustomIconSelect/index.vue
@@ -15,31 +15,117 @@
>
{{ item.label }}
+
+
@@ -56,6 +142,8 @@ import {
fillIconList,
multicolorIconList,
} from './constants'
+import { postImageFile, getFileData, addFileData, deleteFileData } from '@/api/file'
+
export default {
name: 'CustomIconSelect',
components: { ElColorPicker: ColorPicker },
@@ -77,13 +165,18 @@ export default {
},
data() {
return {
+ form: this.$form.createForm(this),
iconTypeList,
commonIconList,
linearIconList,
fillIconList,
multicolorIconList,
visible: false,
- currentIconType: '1',
+ currentIconType: '3',
+ customIconList: [],
+ formVisible: false,
+ formImg: null,
+ file: null,
}
},
computed: {
@@ -97,18 +190,30 @@ export default {
return this.fillIconList
case '3': // 多色
return this.multicolorIconList
+ case '4': // 自定义
+ return this.customIconList
default:
return this.linearIconList
}
},
+ fileName() {
+ const splitFileName = this.file.name.split('.')
+ return splitFileName.splice(0, splitFileName.length - 1).join('')
+ },
},
mounted() {
document.addEventListener('click', this.eventListener)
+ this.getFileData()
},
beforeDestroy() {
document.removeEventListener('click', this.eventListener)
},
methods: {
+ getFileData() {
+ getFileData('ops-custom-icon').then((res) => {
+ this.customIconList = res
+ })
+ },
eventListener(e) {
if (this.visible) {
const dom = document.getElementById(`custom-icon-select-popover`)
@@ -137,25 +242,87 @@ export default {
})
}
},
+ clickCustomIcon(icon) {
+ if (icon.id === this.value.id) {
+ this.$emit('change', {
+ name: '',
+ color: '',
+ })
+ } else {
+ this.$emit('change', { name: icon.data.name, id: icon.id, url: icon.data.url })
+ }
+ },
showSelect() {
this.visible = true
+ console.log(this.value)
if (!this.value.name) {
- this.currentIconType = '1'
+ this.currentIconType = '3'
return
}
+ // changyong已废弃
if (this.value.name.startsWith('changyong-')) {
this.currentIconType = '0'
} else if (this.value.name.startsWith('icon-xianxing')) {
this.currentIconType = '1'
} else if (this.value.name.startsWith('icon-shidi')) {
this.currentIconType = '2'
- } else {
+ } else if (this.value.name.startsWith('caise')) {
this.currentIconType = '3'
+ } else {
+ this.currentIconType = '4'
}
},
handleChangeIconType(value) {
this.currentIconType = value
},
+ beforeUpload(file) {
+ const isLt2M = file.size / 1024 / 1024 < 2
+ if (!isLt2M) {
+ this.$message.error('图片大小不可超过2MB!')
+ return false
+ }
+
+ const reader = new FileReader()
+ reader.readAsDataURL(file)
+ reader.onload = () => {
+ this.formVisible = true
+ this.$nextTick(() => {
+ this.file = file
+ this.formImg = reader.result
+ this.form.setFieldsValue({ name: this.fileName })
+ })
+ }
+ return false
+ },
+ handleCancel() {
+ this.formVisible = false
+ this.form.setFieldsValue({ name: '' })
+ this.formImg = null
+ },
+ handleOk() {
+ const fm = new FormData()
+ fm.append('file', this.file)
+ postImageFile(fm).then((res) => {
+ this.form.validateFields((err, values) => {
+ if (!err) {
+ addFileData('ops-custom-icon', { data: { name: values.name, url: res.file_name } }).then(() => {
+ this.$message.success('上传成功!')
+ this.handleCancel()
+ this.getFileData()
+ })
+ }
+ })
+ })
+ },
+ deleteIcon(e, icon) {
+ e.stopPropagation()
+ e.preventDefault()
+ deleteFileData('ops-custom-icon', icon.id).then(() => {
+ this.$message.success('删除成功!')
+ this.handleCancel()
+ this.getFileData()
+ })
+ },
},
}
@@ -176,7 +343,7 @@ export default {
padding: 4px 6px;
}
.custom-icon-select-popover-content {
- max-height: 400px;
+ height: 400px;
overflow: auto;
.category {
font-size: 14px;
@@ -197,12 +364,43 @@ export default {
padding: 5px 5px 2px 5px;
margin: 0 2px 6px;
color: #666;
+ position: relative;
.custom-icon-select-popover-item-label {
margin-top: 6px;
font-size: 11px;
+ width: 100%;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ text-align: center;
}
&:hover {
background-color: #eeeeee;
+ .custom-icon-select-popover-content-img-box > i {
+ display: inline;
+ }
+ }
+ .custom-icon-select-popover-content-img-box {
+ width: 26px;
+ height: 26px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ > img {
+ max-width: 26px;
+ max-height: 26px;
+ }
+
+ > i {
+ display: none;
+ position: absolute;
+ top: 2px;
+ right: 2px;
+ font-size: 12px;
+ &:hover {
+ color: #2f54eb;
+ }
+ }
}
}
.selected {
@@ -212,6 +410,8 @@ export default {
}
.custom-icon-select-popover-icon-type {
display: inline-block;
+ width: 100%;
+ position: relative;
> div {
cursor: pointer;
display: inline-block;
@@ -224,6 +424,16 @@ export default {
.selected {
border-color: #2f54eb;
}
+ .ant-btn {
+ position: absolute;
+ right: 0;
+ top: 50%;
+ transform: translateY(-50%);
+ }
+ }
+
+ .custom-icon-select-confirm-popover .ant-popover-inner-content {
+ width: 150px;
}
}
@@ -234,15 +444,39 @@ export default {
width: 28px;
height: 28px;
border-radius: 4px;
- border: 1px solid #eeeeee;
+ border: 1px solid #d9d9d9;
display: inline-block;
cursor: pointer;
- > i {
+ > i,
+ > img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
+ }
+ > img {
+ max-width: 26px;
+ max-height: 26px;
+ }
+ > i {
font-size: 18px;
}
}
+.custom-icon-select-form {
+ .custom-icon-select-form-img {
+ width: 28px;
+ height: 28px;
+ border-radius: 4px;
+ border: 1px solid #d9d9d9;
+ display: inline-flex;
+ margin-top: 5px;
+ justify-content: center;
+ align-items: center;
+ overflow: hidden;
+ img {
+ max-width: 26px;
+ max-height: 26px;
+ }
+ }
+}
diff --git a/cmdb-ui/src/components/Menu/menu.js b/cmdb-ui/src/components/Menu/menu.js
index db7cdd6..dd959df 100644
--- a/cmdb-ui/src/components/Menu/menu.js
+++ b/cmdb-ui/src/components/Menu/menu.js
@@ -222,6 +222,9 @@ export default {
renderIcon({ icon, selectedIcon, customIcon = undefined, name = undefined, typeId = undefined, routeName }) {
if (typeId) {
if (customIcon) {
+ if (customIcon.split('$$')[2]) {
+ return
[3]}`})
+ }
return
-
-
+
+
+
+
+
{{ choice[0] }}
@@ -152,10 +161,18 @@
padding: '1px 5px',
margin: '2px',
...getChoiceValueStyle(col, value),
+ display: 'inline-flex',
+ alignItems: 'center',
}"
>
+
{{ value }}
@@ -167,10 +184,18 @@
padding: '1px 5px',
margin: '2px 0',
...getChoiceValueStyle(col, row[col.field]),
+ display: 'inline-flex',
+ alignItems: 'center',
}"
>
+
{{ row[col.field] }}`)
+ if (opts.options.icon.split('$$')[2]) {
+ icon = $(`
`)
+ } else {
+ icon = $(``)
+ }
} else {
icon = $(`${opts.options.name[0].toUpperCase()}`)
}
diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/createInstanceFormByGroup.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/createInstanceFormByGroup.vue
index 0b4c5be..0d53c3a 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci/modules/createInstanceFormByGroup.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/createInstanceFormByGroup.vue
@@ -1,6 +1,6 @@
- {{ group.name || '其他' }}
+ {{ group.name || '其他' }}
-
-
+
+
+
+
+
{{ choice[0] }}
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/index.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/index.vue
index 8bb5dfc..bdca475 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci_types/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/index.vue
@@ -113,14 +113,20 @@
style="width: 17px; height: 17px; display: none; position: absolute; left: 15px; top: 5px"
/>
-
+
+
+
+
{{ ci.name[0].toUpperCase() }}
@@ -204,7 +210,7 @@
:label="item.alias || item.name"
>
@@ -235,7 +241,7 @@
:label="item.alias || item.name"
>
{{ item.alias || item.name }}
-
{{ item.name }}
+
{{ item.name }}
@@ -533,21 +539,20 @@ export default {
e.preventDefault()
this.form.validateFields(async (err, values) => {
if (!err) {
- // eslint-disable-next-line no-console
- console.log('Received values of form: ', values)
- const icon = this.$refs.iconArea.getIcon()
this.loading = true
if (values.default_order_attr && this.default_order_asc === '2') {
values.default_order_attr = `-${values.default_order_attr}`
}
+ const _icon = this.$refs.iconArea.getIcon()
+ const icon =
+ _icon && _icon.name ? `${_icon.name}$$${_icon.color || ''}$$${_icon.id || ''}$$${_icon.url || ''}` : ''
if (values.id) {
await this.updateCIType(values.id, {
...values,
- icon: icon && icon.name ? `${icon.name}$$${icon.color || ''}` : '',
+ icon,
})
} else {
- await this.createCIType({ ...values, icon: icon && icon.name ? `${icon.name}$$${icon.color || ''}` : '' })
- // todo 把改ci 类型绑定在当前group下
+ await this.createCIType({ ...values, icon })
}
}
})
@@ -731,6 +736,8 @@ export default {
? {
name: record.icon.split('$$')[0] || '',
color: record.icon.split('$$')[1] || '',
+ id: record.icon.split('$$')[2] ? Number(record.icon.split('$$')[2]) : null,
+ url: record.icon.split('$$')[3] || '',
}
: {}
)
@@ -828,7 +835,7 @@ export default {
margin-left: auto;
}
.ci-types-left-detail-icon {
- display: inline-flex;
+ display: flex;
align-items: center;
justify-content: center;
width: 20px;
@@ -837,6 +844,10 @@ export default {
box-shadow: 0px 1px 2px rgba(47, 84, 235, 0.2);
margin-right: 6px;
background-color: #fff;
+ img {
+ max-height: 20px;
+ max-width: 20px;
+ }
}
&:hover {
background-color: #e1efff;
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/preValueTag.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/preValueTag.vue
index 91e1b2e..d3e1b81 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci_types/preValueTag.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/preValueTag.vue
@@ -102,8 +102,17 @@
"
>
-
- {{ item[0] }}
+
+
+ {{ item[0] }}
span {
+ display: flex;
+ align-items: center;
+ }
&:hover .pre-value-tag-dropdown-icon {
display: inline !important;
}
diff --git a/cmdb-ui/src/modules/cmdb/views/discovery/discoveryCard.vue b/cmdb-ui/src/modules/cmdb/views/discovery/discoveryCard.vue
index 96195a7..3139dd0 100644
--- a/cmdb-ui/src/modules/cmdb/views/discovery/discoveryCard.vue
+++ b/cmdb-ui/src/modules/cmdb/views/discovery/discoveryCard.vue
@@ -10,7 +10,12 @@
diff --git a/cmdb-ui/src/modules/cmdb/views/discoveryCI/index.vue b/cmdb-ui/src/modules/cmdb/views/discoveryCI/index.vue
index 0018b75..581e46b 100644
--- a/cmdb-ui/src/modules/cmdb/views/discoveryCI/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/discoveryCI/index.vue
@@ -13,14 +13,17 @@
@click="clickSidebar(type.id)"
>
-
+
+
+
+
{{ type.name[0].toUpperCase() }}
{{ type.alias || type.name }}
@@ -57,7 +60,7 @@
@checkbox-change="onSelectChange"
@checkbox-all="onSelectChange"
@checkbox-range-end="onSelectChange"
- :checkbox-config="{reserve: true, highlight: true, range: true}"
+ :checkbox-config="{ reserve: true, highlight: true, range: true }"
:sort-config="{ remote: false, trigger: 'cell' }"
>
@@ -316,7 +319,7 @@ export default {
align-items: center;
justify-content: center;
.cmdb-adc-side-icon {
- display: inline-flex;
+ display: flex;
align-items: center;
justify-content: center;
width: 20px;
@@ -325,6 +328,10 @@ export default {
box-shadow: 0px 1px 2px rgba(47, 84, 235, 0.2);
margin-right: 6px;
background-color: #fff;
+ img {
+ max-height: 20px;
+ max-width: 20px;
+ }
}
.cmdb-adc-side-name {
display: inline-block;
diff --git a/cmdb-ui/src/modules/cmdb/views/preference/index.vue b/cmdb-ui/src/modules/cmdb/views/preference/index.vue
index 1b53679..71e1436 100644
--- a/cmdb-ui/src/modules/cmdb/views/preference/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/preference/index.vue
@@ -47,15 +47,21 @@
}"
:style="{ width: '30px', height: '30px', marginRight: '10px' }"
>
-
+
+
+
+
{{ ciType.name[0].toUpperCase() }}
{{ ciType.alias || ciType.name }}
@@ -96,11 +102,21 @@
'cmdb-preference-avatar-noicon-is_subscribed': !item.icon && item.is_subscribed,
}"
>
-
+
+
+
+
{{ item.name[0].toUpperCase() }}