feat(cmdb-ui):i18n

This commit is contained in:
wang-liang0615 2024-01-02 17:37:28 +08:00
parent 3401cf4a1e
commit 420106ae65
88 changed files with 15822 additions and 14685 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 143 KiB

View File

@ -63,7 +63,7 @@ export default {
updateCI(this.row.ci_id || this.row._id, { updateCI(this.row.ci_id || this.row._id, {
[`${this.column.property}`]: this.default_value_json_right ? this.jsonData : {}, [`${this.column.property}`]: this.default_value_json_right ? this.jsonData : {},
}).then(() => { }).then(() => {
this.$message.success('保存成功!') this.$message.success(this.$t('saveSuccess'))
this.handleCancel() this.handleCancel()
this.$emit('jsonEditorOk', this.row, this.column, this.default_value_json_right ? this.jsonData : {}) this.$emit('jsonEditorOk', this.row, this.column, this.default_value_json_right ? this.jsonData : {})
}) })

View File

@ -7,7 +7,7 @@
width: '200px', width: '200px',
height: `${height}px`, height: `${height}px`,
}" }"
:titles="['未选属性', '已选属性']" :titles="[$t('cmdb.components.unselectAttributes'), $t('cmdb.components.selectAttributes')]"
:render="(item) => item.title" :render="(item) => item.title"
:targetKeys="targetKeys" :targetKeys="targetKeys"
@change="handleChange" @change="handleChange"
@ -16,7 +16,7 @@
:filterOption="filterOption" :filterOption="filterOption"
class="cmdb-transfer" class="cmdb-transfer"
> >
<span slot="notFoundContent">暂无数据</span> <span slot="notFoundContent">{{ $t('noData') }}</span>
<template slot="children" slot-scope="{ props: { direction, filteredItems } }"> <template slot="children" slot-scope="{ props: { direction, filteredItems } }">
<div class="ant-transfer-list-content" v-if="direction === 'right'"> <div class="ant-transfer-list-content" v-if="direction === 'right'">
<draggable :value="targetKeys" animation="300" @end="dragEnd" :disabled="!isSortable"> <draggable :value="targetKeys" animation="300" @end="dragEnd" :disabled="!isSortable">
@ -27,10 +27,11 @@
:style="{ height: '38px' }" :style="{ height: '38px' }"
> >
<li <li
:class="{ :class="
'ant-transfer-list-content-item': true, `ant-transfer-list-content-item ${
'ant-transfer-list-content-item-selected': selectedKeys.includes(item.key), selectedKeys.includes(item.key) ? 'ant-transfer-list-content-item-selected' : ''
}" }`
"
@click="setSelectedKeys(item)" @click="setSelectedKeys(item)"
> >
<OpsMoveIcon class="move-icon" /> <OpsMoveIcon class="move-icon" />
@ -62,9 +63,11 @@
:style="{ height: '38px' }" :style="{ height: '38px' }"
> >
<li <li
:class="`ant-transfer-list-content-item ${ :class="
`ant-transfer-list-content-item ${
selectedKeys.includes(item.key) ? 'ant-transfer-list-content-item-selected' : '' selectedKeys.includes(item.key) ? 'ant-transfer-list-content-item-selected' : ''
}`" }`
"
@click="setSelectedKeys(item)" @click="setSelectedKeys(item)"
> >
<div class="ant-transfer-list-content-item-text" style="display: inline"> <div class="ant-transfer-list-content-item-text" style="display: inline">
@ -83,7 +86,7 @@
</template> </template>
</a-transfer> </a-transfer>
<div v-if="hasFooter" :style="{ marginTop: '5px', height: '20px' }"> <div v-if="hasFooter" :style="{ marginTop: '5px', height: '20px' }">
<a-button :style="{ float: 'right' }" size="small" @click="handleSubmit" type="primary">确定</a-button> <a-button :style="{ float: 'right' }" size="small" @click="handleSubmit" type="primary">{{ $t('confirm') }}</a-button>
</div> </div>
</div> </div>
</template> </template>
@ -110,12 +113,12 @@ export default {
default: true, default: true,
}, },
isSortable: { isSortable: {
// 右侧是否可排序 // Is the right side sortable?
type: Boolean, type: Boolean,
default: true, default: true,
}, },
isFixable: { isFixable: {
// 右侧是否可固定 // Can the right side be fixed?
type: Boolean, type: Boolean,
default: true, default: true,
}, },

View File

@ -1,21 +1,30 @@
<template> <template>
<a-modal :visible="visible" title="导出数据" @cancel="handleCancel" okText="导出" @ok="handleOk"> <a-modal
:visible="visible"
:title="$t('cmdb.components.downloadCI')"
@cancel="handleCancel"
@ok="handleOk"
width="700px"
>
<a-form :form="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }"> <a-form :form="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
<a-form-item label="文件名"> <a-form-item :label="$t('cmdb.components.filename')">
<a-input <a-input
placeholder="请输入文件名" :placeholder="$t('cmdb.components.filenameInputTips')"
v-decorator="['filename', { rules: [{ required: true, message: '请输入文件名' }] }]" v-decorator="['filename', { rules: [{ required: true, message: $t('cmdb.components.filenameInputTips') }] }]"
/> />
</a-form-item> </a-form-item>
<a-form-item label="保存类型"> <a-form-item :label="$t('cmdb.components.saveType')">
<a-select <a-select
placeholder="请选择保存类型" :placeholder="$t('cmdb.components.saveTypeTips')"
v-decorator="['type', { rules: [{ required: true, message: '请选择保存类型' }], initialValue: 'xlsx' }]" v-decorator="[
'type',
{ rules: [{ required: true, message: $t('cmdb.components.saveTypeTips') }], initialValue: 'xlsx' },
]"
> >
<a-select-option v-for="item in typeList" :key="item.id" :values="item.id">{{ item.label }}</a-select-option> <a-select-option v-for="item in typeList" :key="item.id" :values="item.id">{{ item.label }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="选择字段"> <a-form-item :label="$t('cmdb.ciType.selectAttributes')">
<div <div
:style="{ :style="{
paddingLeft: '26px', paddingLeft: '26px',
@ -29,7 +38,7 @@
:checked="checkAll" :checked="checkAll"
@change="onCheckAllChange" @change="onCheckAllChange"
:style="{ marginRight: '10px' }" :style="{ marginRight: '10px' }"
/>全选 />{{ $t('checkAll') }}
</div> </div>
<div <div
:style="{ :style="{
@ -76,30 +85,7 @@ export default {
}, },
}, },
data() { data() {
const typeList = [
{
id: 'xlsx',
label: 'Excel工作簿(*.xlsx)',
},
{
id: 'csv',
label: 'CSV(逗号分隔)(*.csv)',
},
{
id: 'html',
label: '网页(*.html)',
},
{
id: 'xml',
label: 'XML数据(*.xml)',
},
{
id: 'txt',
label: '文本文件(制表符分隔)(*.txt)',
},
]
return { return {
typeList,
visible: false, visible: false,
form: this.$form.createForm(this), form: this.$form.createForm(this),
preferenceAttrList: [], preferenceAttrList: [],
@ -109,6 +95,32 @@ export default {
defaultChecked: [], defaultChecked: [],
} }
}, },
computed: {
typeList() {
return [
{
id: 'xlsx',
label: this.$t('cmdb.components.xlsx'),
},
{
id: 'csv',
label: this.$t('cmdb.components.csv'),
},
{
id: 'html',
label: this.$t('cmdb.components.html'),
},
{
id: 'xml',
label: this.$t('cmdb.components.xml'),
},
{
id: 'txt',
label: this.$t('cmdb.components.txt'),
},
]
},
},
methods: { methods: {
...mapMutations('cmdbStore', ['SET_IS_TABLE_LOADING']), ...mapMutations('cmdbStore', ['SET_IS_TABLE_LOADING']),
open({ preferenceAttrList, ciTypeName = undefined }) { open({ preferenceAttrList, ciTypeName = undefined }) {

View File

@ -25,17 +25,17 @@
</vxe-column> </vxe-column>
<template #empty> <template #empty>
<div v-if="loading()" style="height: 200px; line-height: 200px;color:#2F54EB"> <div v-if="loading()" style="height: 200px; line-height: 200px;color:#2F54EB">
<a-icon type="loading" /> 加载中... <a-icon type="loading" /> {{ $t('loading') }}
</div> </div>
<div v-else> <div v-else>
<img :style="{ width: '100px' }" :src="require('@/assets/data_empty.png')" /> <img :style="{ width: '100px' }" :src="require('@/assets/data_empty.png')" />
<div>暂无数据</div> <div>{{ $t('noData') }}</div>
</div> </div>
</template> </template>
</vxe-table> </vxe-table>
<a-space> <a-space>
<span class="grant-button" @click="grantDepart">授权用户/部门</span> <span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
<span class="grant-button" @click="grantRole">授权角色</span> <span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
</a-space> </a-space>
</div> </div>
</template> </template>
@ -95,10 +95,8 @@ export default {
} }
return (this.windowHeight - 104) / 2 - 116 return (this.windowHeight - 104) / 2 - 116
}, },
}, permMap() {
data() { return permMap()
return {
permMap,
} }
}, },
methods: { methods: {
@ -131,8 +129,8 @@ export default {
} else { } else {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确认删除 ${row.name} 授权 权限`, content: that.$t('cmdb.components.confirmRevoke', { name: `${row.name}` }),
onOk() { onOk() {
that.handleChange({ target: { checked: false } }, col, row) that.handleChange({ target: { checked: false } }, col, row)
const _idx = that.tableData.findIndex((item) => item.rid === row.rid) const _idx = that.tableData.findIndex((item) => item.rid === row.rid)

View File

@ -1,11 +1,15 @@
export const permMap = { import i18n from '@/lang'
read: '查看',
add: '新增', export const permMap = () => {
create: '新增', return {
update: '修改', read: i18n.t('view'),
delete: '删除', add: i18n.t('new'),
config: '配置', create: i18n.t('new'),
grant: '授权', update: i18n.t('update'),
'read_attr': '查看字段', delete: i18n.t('delete'),
'read_ci': '查看实例' config: i18n.t('cmdb.components.config'),
grant: i18n.t('grant'),
'read_attr': i18n.t('cmdb.components.readAttribute'),
'read_ci': i18n.t('cmdb.components.readCI')
}
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="cmdb-grant" :style="{ maxHeight: `${windowHeight - 104}px` }"> <div class="cmdb-grant" :style="{ maxHeight: `${windowHeight - 104}px` }">
<template v-if="cmdbGrantType.includes('ci_type')"> <template v-if="cmdbGrantType.includes('ci_type')">
<div class="cmdb-grant-title">模型权限</div> <div class="cmdb-grant-title">{{ $t('cmdb.components.ciTypeGrant') }}</div>
<CiTypeGrant <CiTypeGrant
:CITypeId="CITypeId" :CITypeId="CITypeId"
:tableData="tableData" :tableData="tableData"
@ -18,7 +18,7 @@
cmdbGrantType.includes('ci_type,ci') || (cmdbGrantType.includes('ci') && !cmdbGrantType.includes('ci_type')) cmdbGrantType.includes('ci_type,ci') || (cmdbGrantType.includes('ci') && !cmdbGrantType.includes('ci_type'))
" "
> >
<div class="cmdb-grant-title">实例权限</div> <div class="cmdb-grant-title">{{ $t('cmdb.components.ciGrant') }}</div>
<CiTypeGrant <CiTypeGrant
:CITypeId="CITypeId" :CITypeId="CITypeId"
:tableData="tableData" :tableData="tableData"
@ -32,7 +32,7 @@
/> />
</template> </template>
<template v-if="cmdbGrantType.includes('type_relation')"> <template v-if="cmdbGrantType.includes('type_relation')">
<div class="cmdb-grant-title">关系权限</div> <div class="cmdb-grant-title">{{ $t('cmdb.components.relationGrant') }}</div>
<TypeRelationGrant <TypeRelationGrant
:typeRelationIds="typeRelationIds" :typeRelationIds="typeRelationIds"
:tableData="tableData" :tableData="tableData"
@ -45,7 +45,7 @@
/> />
</template> </template>
<template v-if="cmdbGrantType.includes('relation_view')"> <template v-if="cmdbGrantType.includes('relation_view')">
<div class="cmdb-grant-title">{{ resourceTypeName }}权限</div> <div class="cmdb-grant-title">{{ resourceTypeName }}{{ $t('cmdb.components.perm') }}</div>
<RelationViewGrant <RelationViewGrant
:resourceTypeName="resourceTypeName" :resourceTypeName="resourceTypeName"
:tableData="tableData" :tableData="tableData"
@ -116,7 +116,7 @@ export default {
attrGroup: [], attrGroup: [],
filerPerimissions: {}, filerPerimissions: {},
loading: false, loading: false,
addedRids: [], // 本次新增的rid addedRids: [], // added rid this time
} }
}, },
computed: { computed: {
@ -203,12 +203,12 @@ export default {
this.tableData = perms this.tableData = perms
this.loading = false this.loading = false
}, },
// 授权common-setting中的部门 从中拿到roleid // Grant the department in common-setting and get the roleid from it
grantDepart(grantType) { grantDepart(grantType) {
this.$refs.grantModal.open('depart') this.$refs.grantModal.open('depart')
this.grantType = grantType this.grantType = grantType
}, },
// 授权最古老的角色权限 // Grant the oldest role permissions
grantRole(grantType) { grantRole(grantType) {
this.$refs.grantModal.open('role') this.$refs.grantModal.open('role')
this.grantType = grantType this.grantType = grantType

View File

@ -26,9 +26,9 @@ export default {
computed: { computed: {
title() { title() {
if (this.type === 'depart') { if (this.type === 'depart') {
return '授权用户/部门' return this.$t('cmdb.components.grantUser')
} }
return '授权角色' return this.$t('cmdb.components.grantRole')
}, },
}, },
methods: { methods: {

View File

@ -2,9 +2,9 @@
<a-modal :width="680" :title="title" :visible="visible" @ok="handleOk" @cancel="handleCancel"> <a-modal :width="680" :title="title" :visible="visible" @ok="handleOk" @cancel="handleCancel">
<CustomRadio <CustomRadio
:radioList="[ :radioList="[
{ value: 1, label: '全部' }, { value: 1, label: $t('cmdb.components.all') },
{ value: 2, label: '自定义', layout: 'vertical' }, { value: 2, label: $t('cmdb.components.customize'), layout: 'vertical' },
{ value: 3, label: '' }, { value: 3, label: $t('cmdb.components.none') },
]" ]"
v-model="radioValue" v-model="radioValue"
> >
@ -16,7 +16,7 @@
:clearable="true" :clearable="true"
searchable searchable
:options="attrGroup" :options="attrGroup"
placeholder="请选择属性字段" :placeholder="$t('cmdb.ciType.selectAttributes')"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
:limit="10" :limit="10"
:limitText="(count) => `+ ${count}`" :limitText="(count) => `+ ${count}`"
@ -24,8 +24,8 @@
(node) => { (node) => {
return { return {
id: node.name || -1, id: node.name || -1,
label: node.alias || node.name || '其他', label: node.alias || node.name || $t('other'),
title: node.alias || node.name || '其他', title: node.alias || node.name || $t('other'),
children: node.attributes, children: node.attributes,
} }
} }
@ -42,7 +42,7 @@
:wrapperCol="{ span: 10 }" :wrapperCol="{ span: 10 }"
ref="form" ref="form"
> >
<a-form-model-item label="名称" prop="name"> <a-form-model-item :label="$t('name')" prop="name">
<a-input v-model="form.name" /> <a-input v-model="form.name" />
</a-form-model-item> </a-form-model-item>
<FilterComp <FilterComp
@ -99,16 +99,16 @@ export default {
name: '', name: '',
}, },
rules: { rules: {
name: [{ required: true, message: '请输入自定义筛选条件名' }], name: [{ required: true, message: this.$t('cmdb.components.customizeFilterName') }],
}, },
} }
}, },
computed: { computed: {
title() { title() {
if (this.colType === 'read_attr') { if (this.colType === 'read_attr') {
return '字段权限' return this.$t('cmdb.components.attributeGrant')
} }
return '实例权限' return this.$t('cmdb.components.ciGrant')
}, },
attrGroup() { attrGroup() {
return this.provide_attrGroup() return this.provide_attrGroup()

View File

@ -17,8 +17,8 @@
</vxe-column> </vxe-column>
</vxe-table> </vxe-table>
<a-space> <a-space>
<span class="grant-button" @click="grantDepart">授权用户/部门</span> <span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
<span class="grant-button" @click="grantRole">授权角色</span> <span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
</a-space> </a-space>
</div> </div>
</template> </template>
@ -51,7 +51,6 @@ export default {
}, },
data() { data() {
return { return {
permMap,
columns: ['read', 'grant'], columns: ['read', 'grant'],
} }
}, },
@ -65,6 +64,9 @@ export default {
} }
return (this.windowHeight - 104) / 2 - 116 return (this.windowHeight - 104) / 2 - 116
}, },
permMap() {
return permMap()
}
}, },
methods: { methods: {
getCurrentRowStyle, getCurrentRowStyle,

View File

@ -17,8 +17,8 @@
</vxe-column> </vxe-column>
</vxe-table> </vxe-table>
<a-space> <a-space>
<span class="grant-button" @click="grantDepart">授权用户/部门</span> <span class="grant-button" @click="grantDepart">{{ $t('cmdb.components.grantUser') }}</span>
<span class="grant-button" @click="grantRole">授权角色</span> <span class="grant-button" @click="grantRole">{{ $t('cmdb.components.grantRole') }}</span>
</a-space> </a-space>
</div> </div>
</template> </template>
@ -51,7 +51,6 @@ export default {
}, },
data() { data() {
return { return {
permMap,
columns: ['create', 'grant', 'delete'], columns: ['create', 'grant', 'delete'],
} }
}, },
@ -65,6 +64,9 @@ export default {
} }
return (this.windowHeight - 104) / 2 - 116 return (this.windowHeight - 104) / 2 - 116
}, },
permMap() {
return permMap()
}
}, },
methods: { methods: {
getCurrentRowStyle, getCurrentRowStyle,

View File

@ -132,7 +132,7 @@ export default {
} else if (color.indexOf('rgb') !== -1) { } else if (color.indexOf('rgb') !== -1) {
hsvObj = this.rgbToHSV(color) hsvObj = this.rgbToHSV(color)
} else { } else {
throw new Error('初始化颜色格式错误,使用#fff或rgb格式') throw new Error(this.$t('cmdb.components.colorPickerError'))
// this.$message.error('颜色格式错误使用16进制格式') // this.$message.error('颜色格式错误使用16进制格式')
} }
if (hsvObj) { if (hsvObj) {

View File

@ -15,19 +15,19 @@
:edit-config="isEdit ? { trigger: 'click', mode: 'cell' } : {}" :edit-config="isEdit ? { trigger: 'click', mode: 'cell' } : {}"
> >
<template v-if="isEdit"> <template v-if="isEdit">
<vxe-colgroup title="自动发现"> <vxe-colgroup :title="$t('cmdb.ciType.autoDiscovery')">
<vxe-column field="name" title="名称" width="100"> </vxe-column> <vxe-column field="name" :title="$t('name')" width="100"> </vxe-column>
<vxe-column field="type" title="类型" width="80"> </vxe-column> <vxe-column field="type" :title="$t('type')" width="80"> </vxe-column>
<vxe-column field="example" title="示例值"> <vxe-column field="example" :title="$t('cmdb.components.example')">
<template #default="{row}"> <template #default="{row}">
<span v-if="row.type === 'json'">{{ JSON.stringify(row.example) }}</span> <span v-if="row.type === 'json'">{{ JSON.stringify(row.example) }}</span>
<span v-else>{{ row.example }}</span> <span v-else>{{ row.example }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="desc" title="描述"> </vxe-column> <vxe-column field="desc" :title="$t('desc')"> </vxe-column>
</vxe-colgroup> </vxe-colgroup>
<vxe-colgroup title="模型属性"> <vxe-colgroup :title="$t('cmdb.ciType.attributes')">
<vxe-column field="attr" title="名称" :edit-render="{}"> <vxe-column field="attr" :title="$t('name')" :edit-render="{}">
<template #default="{row}"> <template #default="{row}">
{{ row.attr }} {{ row.attr }}
</template> </template>
@ -45,15 +45,15 @@
</vxe-colgroup> </vxe-colgroup>
</template> </template>
<template v-else> <template v-else>
<vxe-column field="name" title="名称" width="100"> </vxe-column> <vxe-column field="name" :title="$t('name')" width="100"> </vxe-column>
<vxe-column field="type" title="类型" width="80"> </vxe-column> <vxe-column field="type" :title="$t('type')" width="80"> </vxe-column>
<vxe-column field="example" title="示例值"> <vxe-column field="example" :title="$t('cmdb.components.example')">
<template #default="{row}"> <template #default="{row}">
<span v-if="row.type === 'object'">{{ JSON.stringify(row.example) }}</span> <span v-if="row.type === 'object'">{{ JSON.stringify(row.example) }}</span>
<span v-else>{{ row.example }}</span> <span v-else>{{ row.example }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="desc" title="描述"> </vxe-column> <vxe-column field="desc" :title="$t('desc')"> </vxe-column>
</template> </template>
</vxe-table> </vxe-table>
</div> </div>
@ -61,12 +61,6 @@
<script> <script>
import { getHttpCategories, getHttpAttributes, getSnmpAttributes } from '../../api/discovery' import { getHttpCategories, getHttpAttributes, getSnmpAttributes } from '../../api/discovery'
const httpMap = {
阿里云: { name: 'aliyun' },
腾讯云: { name: 'tencentcloud' },
华为云: { name: 'huaweicloud' },
AWS: { name: 'aws' },
}
export default { export default {
name: 'HttpSnmpAD', name: 'HttpSnmpAD',
props: { props: {
@ -107,13 +101,21 @@ export default {
const { ruleType, ruleName } = this const { ruleType, ruleName } = this
return { ruleType, ruleName } return { ruleType, ruleName }
}, },
httpMap() {
return {
[this.$t('cmdb.components.aliyun')]: { name: 'aliyun' },
[this.$t('cmdb.components.tencentcloud')]: { name: 'tencentcloud' },
[this.$t('cmdb.components.huaweicloud')]: { name: 'huaweicloud' },
AWS: { name: 'aws' },
}
},
}, },
watch: { watch: {
currentCate: { currentCate: {
immediate: true, immediate: true,
handler(newVal) { handler(newVal) {
if (newVal) { if (newVal) {
getHttpAttributes(httpMap[`${this.ruleName}`].name, { category: newVal }).then((res) => { getHttpAttributes(this.httpMap[`${this.ruleName}`].name, { category: newVal }).then((res) => {
if (this.isEdit) { if (this.isEdit) {
this.formatTableData(res) this.formatTableData(res)
} else { } else {
@ -139,7 +141,7 @@ export default {
}) })
} }
if (ruleType === 'http' && ruleName) { if (ruleType === 'http' && ruleName) {
getHttpCategories(httpMap[`${this.ruleName}`].name).then((res) => { getHttpCategories(this.httpMap[`${this.ruleName}`].name).then((res) => {
this.categories = res this.categories = res
if (res && res.length) { if (res && res.length) {
this.currentCate = res[0] this.currentCate = res[0]

View File

@ -19,7 +19,7 @@
<Editor class="notice-content-editor" :defaultConfig="editorConfig" mode="simple" @onCreated="onCreated" /> <Editor class="notice-content-editor" :defaultConfig="editorConfig" mode="simple" @onCreated="onCreated" />
<div class="notice-content-sidebar"> <div class="notice-content-sidebar">
<template v-if="needOld"> <template v-if="needOld">
<div class="notice-content-sidebar-divider">变更前</div> <div class="notice-content-sidebar-divider">{{ $t('cmdb.components.beforeChange') }}</div>
<div <div
@dblclick="dblclickSidebar(`old_${attr.name}`, attr.alias || attr.name)" @dblclick="dblclickSidebar(`old_${attr.name}`, attr.alias || attr.name)"
class="notice-content-sidebar-item" class="notice-content-sidebar-item"
@ -29,7 +29,7 @@
> >
{{ attr.alias || attr.name }} {{ attr.alias || attr.name }}
</div> </div>
<div class="notice-content-sidebar-divider">变更后</div> <div class="notice-content-sidebar-divider">{{ $t('cmdb.components.afterChange') }}</div>
</template> </template>
<div <div
@dblclick="dblclickSidebar(attr.name, attr.alias || attr.name)" @dblclick="dblclickSidebar(attr.name, attr.alias || attr.name)"
@ -65,7 +65,7 @@ export default {
data() { data() {
return { return {
editor: null, editor: null,
editorConfig: { placeholder: '请输入通知内容', readOnly: this.readOnly }, editorConfig: { placeholder: this.$t('cmdb.components.noticeContentTips'), readOnly: this.readOnly },
content: '', content: '',
defaultParams: [], defaultParams: [],
value2LabelMap: {}, value2LabelMap: {},
@ -74,11 +74,11 @@ export default {
beforeDestroy() { beforeDestroy() {
const editor = this.editor const editor = this.editor
if (editor == null) return if (editor == null) return
editor.destroy() // 组件销毁时及时销毁编辑器 editor.destroy() // When the component is destroyed, destroy the editor in time
}, },
methods: { methods: {
onCreated(editor) { onCreated(editor) {
this.editor = Object.seal(editor) // 一定要用 Object.seal() 否则会报错 this.editor = Object.seal(editor) // Be sure to use Object.seal(), otherwise an error will be reported
}, },
getContent() { getContent() {
const html = _.cloneDeep(this.editor.getHtml()) const html = _.cloneDeep(this.editor.getHtml())

View File

@ -11,7 +11,7 @@
@blur="handleInputConfirm" @blur="handleInputConfirm"
@keyup.enter="handleInputConfirm" @keyup.enter="handleInputConfirm"
/> />
<a-button v-else type="primary" size="small" ghost @click="showInput">保存筛选条件</a-button> <a-button v-else type="primary" size="small" ghost @click="showInput">{{ $t('cmdb.components.saveQuery') }}</a-button>
</span> </span>
<template v-for="(item, index) in preferenceSearchList.slice(0, 3)"> <template v-for="(item, index) in preferenceSearchList.slice(0, 3)">
<span <span
@ -26,7 +26,7 @@
<a-tooltip :title="item.name"> <a-tooltip :title="item.name">
<span @click="clickPreferenceSearch(item)">{{ `${item.name.slice(0, 6)}...` }}</span> <span @click="clickPreferenceSearch(item)">{{ `${item.name.slice(0, 6)}...` }}</span>
</a-tooltip> </a-tooltip>
<a-popconfirm title="确认删除?" @confirm="deletePreferenceSearch(item)"> <a-popconfirm :title="$t('cmdb.ciType.confirmDelete2')" @confirm="deletePreferenceSearch(item)">
<a-icon type="close" /> <a-icon type="close" />
</a-popconfirm> </a-popconfirm>
</span> </span>
@ -40,7 +40,7 @@
}" }"
> >
<span @click="clickPreferenceSearch(item)">{{ item.name }}</span> <span @click="clickPreferenceSearch(item)">{{ item.name }}</span>
<a-popconfirm title="确认删除?" @confirm="deletePreferenceSearch(item)"> <a-popconfirm :title="$t('cmdb.ciType.confirmDelete2')" @confirm="deletePreferenceSearch(item)">
<a-icon type="close" /> <a-icon type="close" />
</a-popconfirm> </a-popconfirm>
</span> </span>
@ -73,7 +73,7 @@
{{ item.name }} {{ item.name }}
</div> </div>
<a-popconfirm <a-popconfirm
title="确认删除?" :title="$t('cmdb.ciType.confirmDelete2')"
:getPopupContainer="(trigger) => trigger.parentElement" :getPopupContainer="(trigger) => trigger.parentElement"
placement="left" placement="left"
@confirm=" @confirm="

View File

@ -15,7 +15,7 @@
:limit="1" :limit="1"
:limitText="(count) => `+ ${count}`" :limitText="(count) => `+ ${count}`"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
placeholder="模型" :placeholder="$t('cmdb.ciType.ciType')"
@close="closeCiTypeGroup" @close="closeCiTypeGroup"
@open="openCiTypeGroup" @open="openCiTypeGroup"
@input="inputCiTypeGroup" @input="inputCiTypeGroup"
@ -23,8 +23,8 @@
(node) => { (node) => {
return { return {
id: node.id || -1, id: node.id || -1,
label: node.alias || node.name || '其他', label: node.alias || node.name || $t('other'),
title: node.alias || node.name || '其他', title: node.alias || node.name || $t('other'),
children: node.ci_types, children: node.ci_types,
} }
} }
@ -42,7 +42,7 @@
<a-input <a-input
v-model="fuzzySearch" v-model="fuzzySearch"
:style="{ display: 'inline-block', width: '244px' }" :style="{ display: 'inline-block', width: '244px' }"
placeholder="请查找" :placeholder="$t('cmdb.components.pleaseSearch')"
@pressEnter="emitRefresh" @pressEnter="emitRefresh"
class="ops-input ops-input-radius" class="ops-input ops-input-radius"
> >
@ -54,7 +54,7 @@
/> />
<a-tooltip slot="prefix" placement="bottom" :overlayStyle="{ maxWidth: '550px' }"> <a-tooltip slot="prefix" placement="bottom" :overlayStyle="{ maxWidth: '550px' }">
<template slot="title"> <template slot="title">
1json属性不能搜索<br />2搜索内容包括逗号则需转义 \,<br />3只搜索索引属性非索引属性使用条件过滤 {{ $t('cmdb.components.ciSearchTips') }}
</template> </template>
<a><a-icon type="question-circle"/></a> <a><a-icon type="question-circle"/></a>
</a-tooltip> </a-tooltip>
@ -68,7 +68,7 @@
> >
<div slot="popover_item" class="search-form-bar-filter"> <div slot="popover_item" class="search-form-bar-filter">
<a-icon class="search-form-bar-filter-icon" type="filter" /> <a-icon class="search-form-bar-filter-icon" type="filter" />
条件过滤 {{ $t('cmdb.components.conditionFilter') }}
<a-icon class="search-form-bar-filter-icon" type="down" /> <a-icon class="search-form-bar-filter-icon" type="down" />
</div> </div>
</FilterComp> </FilterComp>
@ -97,8 +97,8 @@
</a-space> </a-space>
</div> </div>
<a-space> <a-space>
<a-button @click="reset" size="small">重置</a-button> <a-button @click="reset" size="small">{{ $t('reset') }}</a-button>
<a-tooltip title="属性说明" v-if="type === 'relationView'"> <a-tooltip :title="$t('cmdb.components.attributeDesc')" v-if="type === 'relationView'">
<a <a
@click=" @click="
() => { () => {
@ -149,7 +149,7 @@ export default {
}, },
data() { data() {
return { return {
// 高级搜索 展开/关闭 // Advanced Search Expand/Close
advanced: false, advanced: false,
queryParam: {}, queryParam: {},
isFocusExpression: false, isFocusExpression: false,
@ -163,7 +163,7 @@ export default {
computed: { computed: {
placeholder() { placeholder() {
return this.isFocusExpression ? 'q=hostname:*0.0.0.0*' : '表达式' return this.isFocusExpression ? this.$t('cmdb.components.ciSearchTips2') : this.$t('cmdb.ciType.expr')
}, },
width() { width() {
return '200px' return '200px'

View File

@ -11,13 +11,13 @@
> >
<a-tabs v-model="activeKey"> <a-tabs v-model="activeKey">
<a-tab-pane key="1"> <a-tab-pane key="1">
<span slot="tab"><ops-icon type="cmdb-ci" />资源数据</span> <span slot="tab"><ops-icon type="cmdb-ci" />{{ $t('cmdb.menu.ciTable') }}</span>
<div class="cmdb-subscribe-drawer-container" :style="{ height: `${windowHeight - 60}px` }"> <div class="cmdb-subscribe-drawer-container" :style="{ height: `${windowHeight - 60}px` }">
<div class="cmdb-subscribe-drawer-container-title"> <div class="cmdb-subscribe-drawer-container-title">
<span>订阅模型{{ ciType.alias || ciType.name }}</span> <span>{{ $t('cmdb.components.subCIType') }}: {{ ciType.alias || ciType.name }}</span>
<span :style="{ fontWeight: 500, color: instanceSubscribed ? 'green' : 'red' }">{{ <span :style="{ fontWeight: 500, color: instanceSubscribed ? 'green' : 'red' }">{{
`${instanceSubscribed ? '' : ''}订阅` `${instanceSubscribed ? $t('cmdb.components.already') : $t('cmdb.components.not')}`
}}</span> }}{{ $t('cmdb.components.sub') }})</span>
</div> </div>
<template> <template>
<AttributesTransfer <AttributesTransfer
@ -31,22 +31,22 @@
:height="windowHeight - 170" :height="windowHeight - 170"
/> />
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button @click="subInstanceSubmit" type="primary">订阅</a-button> <a-button @click="subInstanceSubmit" type="primary">{{ $t('cmdb.preference.sub') }}</a-button>
</div> </div>
</template> </template>
</div> </div>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" force-render> <a-tab-pane key="2" force-render>
<span slot="tab"><ops-icon type="cmdb-tree" />资源层级</span> <span slot="tab"><ops-icon type="cmdb-tree" />{{ $t('cmdb.menu.ciTree') }}</span>
<div class="cmdb-subscribe-drawer-container" :style="{ height: `${windowHeight - 60}px` }"> <div class="cmdb-subscribe-drawer-container" :style="{ height: `${windowHeight - 60}px` }">
<div class="cmdb-subscribe-drawer-container-title"> <div class="cmdb-subscribe-drawer-container-title">
<span>订阅模型{{ ciType.alias || ciType.name }}</span> <span>{{ $t('cmdb.components.subCIType') }}: {{ ciType.alias || ciType.name }}</span>
<span :style="{ fontWeight: 500, color: treeSubscribed ? 'green' : 'red' }">{{ <span :style="{ fontWeight: 500, color: treeSubscribed ? 'green' : 'red' }">{{
`${treeSubscribed ? '' : ''}订阅` `${treeSubscribed ? $t('cmdb.components.already') : $t('cmdb.components.not')}`
}}</span> }}{{ $t('cmdb.components.sub') }})</span>
</div> </div>
<div class="cmdb-subscribe-drawer-tree-header" :style="{ maxHeight: `${(windowHeight - 170) / 3 - 20}px` }"> <div class="cmdb-subscribe-drawer-tree-header" :style="{ maxHeight: `${(windowHeight - 170) / 3 - 20}px` }">
<span v-if="!treeViews.length">请在下方进行选择</span> <span v-if="!treeViews.length">{{ $t('cmdb.components.selectBelow') }}</span>
<div <div
class="cmdb-subscribe-drawer-tree-header-selected" class="cmdb-subscribe-drawer-tree-header-selected"
:style="{ marginLeft: `${18 * index}px` }" :style="{ marginLeft: `${18 * index}px` }"
@ -70,7 +70,7 @@
</div> </div>
</div> </div>
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button @click="subTreeSubmit" type="primary">订阅</a-button> <a-button @click="subTreeSubmit" type="primary">{{ $t('cmdb.preference.sub') }}</a-button>
</div> </div>
</div> </div>
</a-tab-pane> </a-tab-pane>
@ -179,7 +179,7 @@ export default {
}, },
subTreeSubmit() { subTreeSubmit() {
subscribeTreeView(this.ciType.type_id, this.treeViews).then((res) => { subscribeTreeView(this.ciType.type_id, this.treeViews).then((res) => {
this.$message.success('订阅成功') this.$message.success(this.$t('cmdb.components.subSuccess'))
if (this.treeViews.length > 0) { if (this.treeViews.length > 0) {
this.treeSubscribed = true this.treeSubscribed = true
} else { } else {
@ -194,7 +194,7 @@ export default {
return [item, !!this.fixedList.includes(item)] return [item, !!this.fixedList.includes(item)]
}) })
).then((res) => { ).then((res) => {
this.$message.success('订阅成功') this.$message.success(this.$t('cmdb.components.subSuccess'))
this.resetRoute() this.resetRoute()
if (this.selectedAttrList.length > 0) { if (this.selectedAttrList.length > 0) {
this.instanceSubscribed = true this.instanceSubscribed = true

View File

@ -25,10 +25,10 @@
<div style="margin-top:10px"> <div style="margin-top:10px">
<table v-if="authorizationType === 'BasicAuth'"> <table v-if="authorizationType === 'BasicAuth'">
<tr> <tr>
<td><a-input class="authorization-input" v-model="BasicAuth.username" placeholder="用户名" /></td> <td><a-input class="authorization-input" v-model="BasicAuth.username" :placeholder="$t('cmdb.ciType.username')" /></td>
</tr> </tr>
<tr> <tr>
<td><a-input class="authorization-input" v-model="BasicAuth.password" placeholder="密码" /></td> <td><a-input class="authorization-input" v-model="BasicAuth.password" :placeholder="$t('cmdb.ciType.password')" /></td>
</tr> </tr>
</table> </table>
@ -87,7 +87,7 @@
}" }"
> >
<img slot="image" :src="require('@/assets/data_empty.png')" /> <img slot="image" :src="require('@/assets/data_empty.png')" />
<span slot="description"> 暂无请求认证 </span> <span slot="description"> {{ $t('cmdb.components.noAuthRequest') }} </span>
</a-empty> </a-empty>
</div> </div>
</div> </div>

View File

@ -1,9 +1,9 @@
<template> <template>
<div> <div>
<div class="headers-header"> <div class="headers-header">
<span>请求参数</span> <span>{{ $t('cmdb.components.requestParam') }}</span>
<a-space> <a-space>
<a-tooltip title="清空"> <a-tooltip :title="$t('cmdb.components.clear')">
<ops-icon <ops-icon
type="icon-xianxing-delete" type="icon-xianxing-delete"
@click=" @click="
@ -19,7 +19,7 @@
" "
/> />
</a-tooltip> </a-tooltip>
<a-tooltip title="新增"> <a-tooltip :title="$t('new')">
<a-icon type="plus" @click="add" /> <a-icon type="plus" @click="add" />
</a-tooltip> </a-tooltip>
</a-space> </a-space>
@ -27,8 +27,8 @@
<div class="headers-box"> <div class="headers-box">
<table> <table>
<tr v-for="(item, index) in headers" :key="item.id"> <tr v-for="(item, index) in headers" :key="item.id">
<td><a-input class="headers-input" v-model="item.key" :placeholder="`参数${index + 1}`" /></td> <td><a-input class="headers-input" v-model="item.key" :placeholder="$t('cmdb.components.param', { param: `${index + 1}` })" /></td>
<td><a-input class="headers-input" v-model="item.value" :placeholder="`${index + 1}`" /></td> <td><a-input class="headers-input" v-model="item.value" :placeholder="$t('cmdb.components.value', { value: `${index + 1}` })" /></td>
<td> <td>
<a style="color:red"> <a style="color:red">
<ops-icon type="icon-xianxing-delete" @click="deleteParam(index)" /> <ops-icon type="icon-xianxing-delete" @click="deleteParam(index)" />

View File

@ -18,7 +18,7 @@
searchable searchable
:options="methodList" :options="methodList"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
placeholder="请选择方式" :placeholder="$t('cmdb.components.selectMethods')"
> >
</treeselect> </treeselect>
<a-input :style="{ display: 'inline-block', width: 'calc(100% - 100px)' }" v-model="url" /> <a-input :style="{ display: 'inline-block', width: 'calc(100% - 100px)' }" v-model="url" />

View File

@ -1,9 +1,9 @@
<template> <template>
<div> <div>
<div class="parameters-header"> <div class="parameters-header">
<span>请求参数</span> <span>{{ $t('cmdb.components.requestParam') }}</span>
<a-space> <a-space>
<a-tooltip title="清空"> <a-tooltip :title="$t('cmdb.components.clear')">
<ops-icon <ops-icon
type="icon-xianxing-delete" type="icon-xianxing-delete"
@click=" @click="
@ -13,7 +13,7 @@
" "
/> />
</a-tooltip> </a-tooltip>
<a-tooltip title="新增"> <a-tooltip :title="$t('new')">
<a-icon type="plus" @click="add" /> <a-icon type="plus" @click="add" />
</a-tooltip> </a-tooltip>
</a-space> </a-space>
@ -21,8 +21,8 @@
<div class="parameters-box" v-if="parameters && parameters.length"> <div class="parameters-box" v-if="parameters && parameters.length">
<table> <table>
<tr v-for="(item, index) in parameters" :key="item.id"> <tr v-for="(item, index) in parameters" :key="item.id">
<td><a-input class="parameters-input" v-model="item.key" :placeholder="`参数${index + 1}`" /></td> <td><a-input class="parameters-input" v-model="item.key" :placeholder="$t('cmdb.components.param', { param: `${index + 1}` })" /></td>
<td><a-input class="parameters-input" v-model="item.value" :placeholder="`${index + 1}`" /></td> <td><a-input class="parameters-input" v-model="item.value" :placeholder="$t('cmdb.components.value', { value: `${index + 1}` })" /></td>
<td> <td>
<a style="color:red"> <a style="color:red">
<ops-icon type="icon-xianxing-delete" @click="deleteParam(index)" /> <ops-icon type="icon-xianxing-delete" @click="deleteParam(index)" />
@ -38,9 +38,9 @@
}" }"
> >
<img slot="image" :src="require('@/assets/data_empty.png')" /> <img slot="image" :src="require('@/assets/data_empty.png')" />
<span slot="description"> 暂无请求参数 </span> <span slot="description"> {{ $t('cmdb.components.noParamRequest') }} </span>
<a-button @click="add" type="primary" size="small" icon="plus" class="ops-button-primary"> <a-button @click="add" type="primary" size="small" icon="plus" class="ops-button-primary">
添加 {{ $t('add') }}
</a-button> </a-button>
</a-empty> </a-empty>
</div> </div>

View File

@ -0,0 +1,483 @@
const cmdb_en = {
relation: 'Relation',
attribute: 'Attributes',
menu: {
views: 'Views',
config: 'Configuration',
backend: 'Management',
ciTable: 'Resource Views',
ciTree: 'Tree Views',
ciSearch: 'Search',
adCIs: 'AutoDiscovery Pool',
preference: 'Preference',
batchUpload: 'Batch Import',
citypeManage: 'Modeling',
backendManage: 'Backend',
customDashboard: 'Custom Dashboard',
serviceTreeDefine: 'Service Tree',
citypeRelation: 'CIType Relation',
operationHistory: 'Operation Audit',
relationType: 'Relation Type',
ad: 'AutoDiscovery',
},
ciType: {
ciType: 'CIType',
attributes: 'Attributes',
relation: 'Relation',
trigger: 'Triggers',
attributeAD: 'Attributes AutoDiscovery',
relationAD: 'Relation AutoDiscovery',
grant: 'Grant',
addGroup: 'New Group',
editGroup: 'Edit Group',
group: 'Group',
attributeLibray: 'Attribute Library',
addCITypeInGroup: 'Add a new CIType to the group',
addCIType: 'Add CIType',
editGroupName: 'Edit group name',
deleteGroup: 'Delete this group',
CITypeName: 'Name(English)',
English: 'English',
inputAttributeName: 'Please enter the attribute name',
attributeNameTips: 'It cannot start with a number, it can be English numbers and underscores (_)',
editCIType: 'Edit CIType',
defaultSort: 'Default sort',
selectDefaultOrderAttr: 'Select default sorting attributes',
asec: 'Forward order',
desc: 'Reverse order',
uniqueKey: 'Uniquely Identifies',
uniqueKeySelect: 'Please select a unique identifier',
notfound: 'Can\'t find what you want?',
cannotDeleteGroupTips: 'There is data under this group and cannot be deleted!',
confirmDeleteGroup: 'Are you sure you want to delete group [{groupName}]?',
confirmDeleteCIType: 'Are you sure you want to delete model [{typeName}]?',
uploading: 'Uploading',
uploadFailed: 'Upload failed, please try again later',
addPlugin: 'New plugin',
deletePlugin: 'Delete plugin',
confirmDeleteADT: 'Do you confirm to delete [{pluginName}]',
attributeMap: 'Attribute mapping',
autoDiscovery: 'AutoDiscovery',
node: 'Node',
adExecConfig: 'Execute configuration',
adExecTarget: 'Execute targets',
oneagentIdTips: 'Please enter the hexadecimal OneAgent ID starting with 0x',
selectFromCMDBTips: 'Select from CMDB ',
adAutoInLib: 'Save as CI auto',
adInterval: 'Collection frequency',
byInterval: 'by interval',
allNodes: 'All nodes',
specifyNodes: 'Specify Node',
specifyNodesTips: 'Please fill in the specify node!',
username: 'Username',
password: 'Password',
link: 'Link',
list: 'List',
listTips: 'The value of the field is one or more, and the type of the value returned by the interface is list.',
computeForAllCITips: 'All CI trigger computes',
confirmcomputeForAllCITips: 'Confirm triggering computes for all CIs?',
isUnique: 'Is it unique',
unique: 'Unique',
isChoice: 'Choiced',
defaultShow: 'Default Display',
defaultShowTips: 'The CI instance table displays this field by default',
isSortable: 'Sortable',
isIndex: 'Indexed',
index: 'Index',
indexTips: 'Fields can be used for retrieval to speed up queries',
confirmDelete: 'Confirm to delete [{name}]?',
confirmDelete2: 'Confirm to delete?',
computeSuccess: 'Triggered successfully!',
basicConfig: 'Basic Settings',
AttributeName: 'Name(English)',
DataType: 'Data Type',
defaultValue: 'Default value',
autoIncID: 'Auto-increment ID',
customTime: 'Custom time',
advancedSettings: 'Advanced Settings',
font: 'Font',
color: 'Color',
choiceValue: 'Predefined value',
computedAttribute: 'Computed Attribute',
computedAttributeTips: 'The value of this attribute is calculated through an expression constructed from other attributes of the CIType or by executing a piece of code. The reference method of the attribute is: {{ attribute name }}',
addAttribute: 'New attribute',
existedAttributes: 'Already have attributes',
editAttribute: 'Edit attribute',
addAttributeTips1: 'If sorting is selected, it must also be selected!',
uniqueConstraint: 'Unique Constraint',
up: 'Move up',
down: 'Move down',
selectAttribute: 'Select Attribute',
groupExisted: 'Group name already exists',
attributeSortedTips: 'Attributes in other groups cannot be sorted. If you need to sort, please drag them to a custom group first!',
buildinAttribute: 'built-in attributes',
expr: 'Expression',
code: 'Code',
apply: 'apply',
continueAdd: 'Keep adding',
filter: 'Filter',
choiceOther: 'Other CIType Attributes',
choiceWebhookTips: 'The returned results are filtered by fields, and the hierarchical nesting is separated by ##, such as k1##k2. The web request returns {k1: [{k2: 1}, {k2: 2}]}, and the parsing result is [1, 2 ]',
selectCIType: 'Please select a CMDB CIType',
selectCITypeAttributes: 'Please select CIType attributes',
selectAttributes: 'Please select attributes',
choiceScriptDemo: 'class ChoiceValue(object):\n @staticmethod\n def values():\n """\n Execution entry, returns predefined value\n :return: Returns a list, the type of the value is the same as the type of the attribute\n For example:\n return ["online", "offline"]\n """\n return []',
valueExisted: 'The current value already exists!',
addRelation: 'Add Relation',
sourceCIType: 'Source CIType',
sourceCITypeTips: 'Please select Source CIType',
dstCIType: 'Target CIType',
dstCITypeTips: 'Please select target CIType',
relationType: 'Relation Type',
relationTypeTips: 'Please select relation type',
isParent: 'is parent',
relationConstraint: 'Constraints',
relationConstraintTips: 'please select a relationship constraint',
one2Many: 'One to Many',
one2One: 'One to One',
many2Many: 'Many to Many',
basicInfo: 'Basic Information',
nameInputTips: 'Please enter name',
triggerDataChange: 'Data changes',
triggerDate: 'Date attribute',
triggerEnable: 'Turn on',
descInput: 'Please enter remarks',
triggerCondition: 'Triggering conditions',
addInstance: 'Add new instance',
deleteInstance: 'Delete instance',
changeInstance: 'Instance changes',
selectMutipleAttributes: 'Please select attributes (multiple selections)',
selectSingleAttribute: 'Please select an attribute (single choice)',
beforeDays: 'ahead of time',
days: 'Days',
notifyAt: 'Send time',
notify: 'Notify',
triggerAction: 'Trigger action',
receivers: 'Recipients',
emailTips: 'Please enter your email address, separate multiple email addresses with ;',
customEmail: 'Custom recipients',
notifySubject: 'Notification title',
notifySubjectTips: 'Please enter notification title',
notifyContent: 'Content',
notifyMethod: 'Notify methods',
botSelect: 'Please select a robot',
refAttributeTips: 'The title and content can reference the attribute value of the CIType. The reference method is: {{ attr_name }}',
webhookRefAttributeTips: 'Request parameters can reference the attribute value of the model. The reference method is: {{ attr_name }}',
newTrigger: 'Add trigger',
editTriggerTitle: 'Edit trigger {name}',
newTriggerTitle: 'Add trigger {name}',
confirmDeleteTrigger: 'Are you sure to delete this trigger?',
int: 'Integer',
float: 'Float',
text: 'Text',
datetime: 'DateTime',
date: 'Date',
time: 'Time',
json: 'JSON',
event: 'Event'
},
components: {
unselectAttributes: 'Unselected',
selectAttributes: 'Selected',
downloadCI: 'Export data',
filename: 'Filename',
filenameInputTips: 'Please enter filename',
saveType: 'Save type',
saveTypeTips: 'Please select save type',
xlsx: 'Excel workbook (*.xlsx)',
csv: 'CSV (comma separated) (*.csv)',
html: 'Web page (*.html)',
xml: 'XML data (*.xml)',
txt: 'Text file (tab delimited) (*.txt)',
grantUser: 'Grant User/Department',
grantRole: 'Grant Role',
confirmRevoke: 'Confirm to delete the [Authorization] permission of [{name}]?',
readAttribute: 'View Attributes',
readCI: 'View CIs',
config: 'Configuration',
ciTypeGrant: 'Grant CIType',
ciGrant: 'Grant CI',
attributeGrant: 'Grant Attribute',
relationGrant: 'Grant Relation',
perm: 'Permissions',
all: 'All',
customize: 'Customize',
none: 'None',
customizeFilterName: 'Please enter a custom filter name',
colorPickerError: 'Initialization color format error, use #fff or rgb format',
example: 'Example value',
aliyun: 'aliyun',
tencentcloud: 'Tencent Cloud',
huaweicloud: 'Huawei Cloud',
beforeChange: 'Before change',
afterChange: 'After change',
noticeContentTips: 'Please enter notification content',
saveQuery: 'Save Filters',
pleaseSearch: 'Please search',
conditionFilter: 'Conditional filtering',
attributeDesc: 'Attribute Description',
ciSearchTips: '1. JSON attributes cannot be searched<br />2. If the search content includes commas, they need to be escaped,<br />3. Only index attributes are searched, non-index attributes use conditional filtering',
ciSearchTips2: 'For example: q=hostname:*0.0.0.0*',
subCIType: 'Subscription CIType',
already: 'already',
not: 'not',
sub: 'subscription',
selectBelow: 'Please select below',
subSuccess: 'Subscription successful',
selectMethods: 'Please select a method',
noAuthRequest: 'No certification requested yet',
noParamRequest: 'No parameter certification yet',
requestParam: 'Request parameters',
param: 'Parameter{param}',
value: 'Value{value}',
clear: 'Clear',
},
batch: {
downloadFailed: 'Download failed',
unselectCIType: 'No CIType selected yet',
pleaseUploadFile: 'Please upload files',
batchUploadCanceled: 'Batch upload canceled',
selectCITypeTips: 'Please select CIType',
downloadTemplate: 'Download Template',
drawTips: 'Click or drag files here to upload!',
supportFileTypes: 'Supported file types: xls, xlsx',
uploadResult: 'Upload results',
total: 'total',
successItems: 'items, succeeded',
failedItems: 'items, failed',
items: 'items',
errorTips: 'Error message',
requestFailedTips: 'An error occurred with the request, please try again later',
requestSuccessTips: 'Upload completed',
},
preference: {
mySub: 'My Subscription',
sub: 'Subscribe',
cancelSub: 'Unsubscribe',
editSub: 'Edit subscription',
peopleSub: ' people subscribed',
noSub: 'No subscribed',
cancelSubSuccess: 'Unsubscribe successfully',
confirmcancelSub: 'Are you sure to cancel your subscription?',
confirmcancelSub2: 'Are you sure you want to unsubscribe {name}?',
of: 'of',
hoursAgo: 'hours ago',
daysAgo: 'days ago',
monthsAgo: 'month ago',
yearsAgo: 'years ago',
just: 'just now',
},
custom_dashboard: {
charts: 'Chart',
newChart: 'Add Chart',
editChart: 'Edit Chart',
title: 'Title',
titleTips: 'Please enter a chart title',
calcIndicators: 'Counter',
dimensions: 'Dimensions',
selectDimensions: 'Please select a dimension',
quantity: 'Quantity',
childCIType: 'Relational CIType',
level: 'Level',
levelTips: 'Please enter the relationship level',
preview: 'Preview',
showIcon: 'Display icon',
chartType: 'Chart Type',
dataFilter: 'Data Filtering',
format: 'Formats',
fontColor: 'Font Color',
backgroundColor: 'Background',
chartColor: 'Chart Color',
chartLength: 'Length',
barType: 'Bar Type',
stackedBar: 'Stacked Bar',
multipleSeriesBar: 'Multiple Series Bar ',
axis: 'Axis',
direction: 'Direction',
lowerShadow: 'Lower Shadow',
count: 'Indicator',
bar: 'Bar',
line: 'Line',
pie: 'Pie',
table: 'Table',
default: 'default',
relation: 'Relation',
noCustomDashboard: 'The administrator has not customized the dashboard yet',
},
preference_relation: {
newServiceTree: 'Add ServiceTree',
serviceTreeName: 'Name',
public: 'Public',
saveLayout: 'Save Layout',
childNodesNotFound: 'There are no child nodes and no business relationship can be formed. Please select again!',
tips1: 'Cannot form a view with the currently selected node, please select again!',
tips2: 'Please enter the new serviceTree name!',
tips3: 'Please select at least two nodes!',
},
history: {
ciChange: 'CI',
relationChange: 'Relation',
ciTypeChange: 'CIType',
triggerHistory: 'Triggers',
opreateTime: 'Operate Time',
user: 'User',
userTips: 'Enter filter username',
filter: 'Search',
filterOperate: 'fitler operation',
attribute: 'Attribute',
old: 'Old',
new: 'New',
noUpdate: 'No update',
itemsPerPage: '/page',
triggerName: 'Name',
event: 'Event',
action: 'Actoin',
status: 'Status',
done: 'Done',
undone: 'Undone',
triggerTime: 'Trigger Time',
totalItems: '{total} records in total',
pleaseSelect: 'Please select',
startTime: 'Start Time',
endTime: 'End Time',
deleteCIType: 'Delete CIType',
addCIType: 'Add CIType',
updateCIType: 'Update CIType',
addAttribute: 'Add Attribute',
updateAttribute: 'Update Attribute',
deleteAttribute: 'Delete Attribute',
addTrigger: 'Add Trigger',
updateTrigger: 'Update Trigger',
deleteTrigger: 'Delete Trigger',
addUniqueConstraint: 'Add Unique Constraint',
updateUniqueConstraint: 'Update Unique Constraint',
deleteUniqueConstraint: 'Delete Unique Constraint',
addRelation: 'Add Relation',
deleteRelation: 'Delete Relation',
noModifications: 'No Modifications',
attr: 'attribute',
attrId: 'attribute id',
changeDescription: 'attribute id: {attr_id}, {before_days} day(s) in advance, Subject: {subject}\nContent: {body}\nNotify At: {notify_at}'
},
relation_type: {
addRelationType: 'New',
nameTips: 'Please enter a type name',
},
ad: {
upload: 'Import',
download: 'Export',
accpet: 'Accept',
accpetBy: 'Accept By',
acceptTime: 'Accept Time',
confirmAccept: 'Confirm Accept?',
accpetSuccess: 'Accept successfully',
isAccpet: 'Is accept',
deleteADC: 'Confirm to delete this data?',
batchDelete: 'Confirm to delete this data?',
agent: 'Built-in & Plug-ins',
snmp: 'Network Devices',
http: 'Public Clouds',
rule: 'AutoDiscovery Rules',
timeout: 'Timeout error',
mode: 'Mode',
collectSettings: 'Collection Settings',
updateFields: 'Update Field',
pluginScript: `# -*- coding:utf-8 -*-
import json
class AutoDiscovery(object):
@property
def unique_key(self):
"""
:return: Returns the name of a unique attribute
"""
return
@staticmethod
def attributes():
"""
Define attribute fields
:return: Returns a list of attribute fields. The list items are (name, type, description). The name must be in English.
type: String Integer Float Date DateTime Time JSON
For example:
return [
("ci_type", "String", "CIType name"),
("private_ip", "String", "Internal IP, multiple values separated by commas")
]
"""
return []
@staticmethod
def run():
"""
Execution entry, returns collected attribute values
:return:
Returns a list, the list item is a dictionary, the dictionary key is the attribute name, and the value is the attribute value
For example:
return [dict(ci_type="server", private_ip="192.168.1.1")]
"""
return []
if __name__ == "__main__":
result = AutoDiscovery().run()
if isinstance(result, list):
print("AutoDiscovery::Result::{}".format(json.dumps(result)))
else:
print("ERROR: The collection return must be a list")
`,
server: 'Server',
vserver: 'VServer',
nic: 'NIC',
disk: 'harddisk',
},
ci: {
attributeDesc: 'Attribute Description',
selectRows: 'Select: {rows} items',
addRelation: 'Add Relation',
all: 'All',
batchUpdate: 'Batch Update',
batchUpdateConfirm: 'Are you sure you want to make batch updates?',
batchUpdateInProgress: 'Currently being updated in batches',
batchUpdateInProgress2: 'Updating in batches, {total} in total, {successNum} successful, {errorNum} failed',
batchDeleting: 'Deleting...',
batchDeleting2: 'Deleting {total} items in total, {successNum} items successful, {errorNum} items failed',
copyFailed: 'Copy failed',
noLevel: 'No hierarchical relationship!',
batchAddRelation: 'Batch Add Relation',
history: 'History',
topo: 'Topology',
table: 'Table',
m2mTips: 'The current CIType relationship is many-to-many, please go to the SerivceTree(relation view) to add or delete',
confirmDeleteRelation: 'Confirm to delete the relationship?',
tips1: 'Use commas to separate multiple values',
tips2: 'The field can be modified as needed. When the value is empty, the field will be left empty.',
tips3: 'Please select the fields that need to be modified',
tips4: 'At least one field must be selected',
tips5: 'Search name | alias',
tips6: 'Speed up retrieval, full-text search possible, no need to use conditional filtering\n\n json currently does not support indexing \n\nText characters longer than 190 cannot be indexed',
tips7: 'The form of expression is a drop-down box, and the value must be in the predefined value',
tips8: 'Multiple values, such as intranet IP',
tips9: 'For front-end only',
tips10: 'Other attributes of the CIType are computed using expressions\n\nA code snippet computes the returned value.',
newUpdateField: 'Add a Attribute',
attributeSettings: 'Attribute Settings',
},
serviceTree: {
deleteNode: 'Delete Node',
tips1: 'For example: q=os_version:centos&sort=os_version',
tips2: 'Expression search',
alert1: 'The administrator has not configured the ServiceTree(relation view), or you do not have permission to access it!',
copyFailed: 'Copy failed',
deleteRelationConfirm: 'Confirm to remove selected {name} from current relationship?',
},
tree: {
tips1: 'Please go to Preference page first to complete your subscription!',
subSettings: 'Settings',
}
}
export default cmdb_en

View File

@ -0,0 +1,482 @@
const cmdb_zh = {
relation: '关系',
attribute: '属性',
menu: {
views: '视图',
config: '配置',
backend: '管理端',
ciTable: '资源数据',
ciTree: '资源层级',
ciSearch: '资源搜索',
adCIs: '自动发现池',
preference: '我的订阅',
batchUpload: '批量导入',
citypeManage: '模型配置',
backendManage: '后台管理',
customDashboard: '定制仪表盘',
serviceTreeDefine: '服务树定义',
citypeRelation: '模型关系',
operationHistory: '操作审计',
relationType: '关系类型',
ad: '自动发现',
},
ciType: {
ciType: '模型',
attributes: '模型属性',
relation: '模型关联',
trigger: '触发器',
attributeAD: '属性自动发现',
relationAD: '关系自动发现',
grant: '权限配置',
addGroup: '新增分组',
editGroup: '修改分组',
group: '分组',
attributeLibray: '属性库',
addCITypeInGroup: '在该组中新增CI模型',
addCIType: '新增CI模型',
editGroupName: '编辑组名称',
deleteGroup: '删除该组',
CITypeName: '模型名(英文)',
English: '英文',
inputAttributeName: '请输入属性名',
attributeNameTips: '不能以数字开头,可以是英文 数字以及下划线 (_)',
editCIType: '编辑模型',
defaultSort: '默认排序',
selectDefaultOrderAttr: '选择默认排序属性',
asec: '正序',
desc: '倒序',
uniqueKey: '唯一标识',
uniqueKeySelect: '请选择唯一标识',
notfound: '找不到想要的?',
cannotDeleteGroupTips: '该分组下有数据, 不能删除!',
confirmDeleteGroup: '确定要删除分组 【{groupName}】 吗?',
confirmDeleteCIType: '确定要删除模型 【{typeName}】 吗?',
uploading: '正在导入中',
uploadFailed: '导入失败,请稍后重试',
addPlugin: '新建plugin',
deletePlugin: '删除plugin',
confirmDeleteADT: '确认删除 【{pluginName}】',
attributeMap: '字段映射',
autoDiscovery: '自动发现',
node: '节点',
adExecConfig: '执行配置',
adExecTarget: '执行机器',
oneagentIdTips: '请输入以0x开头的16进制OneAgent ID',
selectFromCMDBTips: '从CMDB中选择 ',
adAutoInLib: '自动入库',
adInterval: '采集频率',
byInterval: '按间隔',
allNodes: '所有节点',
specifyNodes: '指定节点',
specifyNodesTips: '请填写指定节点!',
username: '用户名',
password: '密码',
link: '链接',
list: '多值',
listTips: '字段的值是1个或者多个接口返回的值的类型是list',
computeForAllCITips: '所有CI触发计算',
confirmcomputeForAllCITips: '确认触发所有CI的计算',
isUnique: '是否唯一',
unique: '唯一',
isChoice: '是否选择',
defaultShow: '默认显示',
defaultShowTips: 'CI实例表格默认展示该字段',
isSortable: '可排序',
isIndex: '是否索引',
index: '索引',
indexTips: '字段可被用于检索,加速查询',
confirmDelete: '确认删除【{name}】?',
confirmDelete2: '确认删除?',
computeSuccess: '触发成功!',
basicConfig: '基础设置',
AttributeName: '属性名(英文)',
DataType: '数据类型',
defaultValue: '默认值',
autoIncID: '自增ID',
customTime: '自定义时间',
advancedSettings: '高级设置',
font: '字体',
color: '颜色',
choiceValue: '预定义值',
computedAttribute: '计算属性',
computedAttributeTips: '该属性的值是通过模型的其它属性构建的表达式或者执行一段代码的方式计算而来,属性的引用方法为: {{ 属性名 }}',
addAttribute: '新增属性',
existedAttributes: '已有属性',
editAttribute: '编辑属性',
addAttributeTips1: '选中排序,则必须也要选中!',
uniqueConstraint: '唯一校验',
up: '上移',
down: '下移',
selectAttribute: '添加属性',
groupExisted: '分组名称已存在',
attributeSortedTips: '其他分组中的属性不能进行排序,如需排序请先拖至自定义的分组!',
buildinAttribute: '内置字段',
expr: '表达式',
code: '代码',
apply: '应用',
continueAdd: '继续添加',
filter: '过滤',
choiceOther: '其他模型属性',
choiceWebhookTips: '返回的结果按字段来过滤,层级嵌套用##分隔比如k1##k2web请求返回{k1: [{k2: 1}, {k2: 2}]}, 解析结果为[1, 2]',
selectCIType: '请选择CMDB模型',
selectCITypeAttributes: '请选择模型属性',
selectAttributes: '请选择属性',
choiceScriptDemo: 'class ChoiceValue(object):\n @staticmethod\n def values():\n """\n 执行入口, 返回预定义值\n :return: 返回一个列表, 值的类型同属性的类型\n 例如:\n return ["在线", "下线"]\n """\n return []',
valueExisted: '当前值已存在!',
addRelation: '新增关系',
sourceCIType: '源模型',
sourceCITypeTips: '请选择源模型',
dstCIType: '目标模型名',
dstCITypeTips: '请选择目标模型',
relationType: '关联类型',
relationTypeTips: '请选择关联类型',
isParent: '被',
relationConstraint: '关系约束',
relationConstraintTips: '请选择关系约束',
one2Many: '一对多',
one2One: '一对一',
many2Many: '多对多',
basicInfo: '基本信息',
nameInputTips: '请输入名称',
triggerDataChange: '数据变更',
triggerDate: '日期属性',
triggerEnable: '开启',
descInput: '请输入备注',
triggerCondition: '触发条件',
addInstance: '新增实例',
deleteInstance: '删除实例',
changeInstance: '实例变更',
selectMutipleAttributes: '请选择属性(多选)',
selectSingleAttribute: '请选择属性(单选)',
beforeDays: '提前',
days: '天',
notifyAt: '发送时间',
notify: '通知',
triggerAction: '触发动作',
receivers: '收件人',
emailTips: '请输入邮箱,多个邮箱用;分隔',
customEmail: '自定义收件人',
notifySubject: '通知标题',
notifySubjectTips: '请输入通知标题',
notifyContent: '内容',
notifyMethod: '通知方式',
botSelect: '请选择机器人',
refAttributeTips: '标题、内容可以引用该模型的属性值,引用方法为: {{ attr_name }}',
webhookRefAttributeTips: '请求参数可以引用该模型的属性值,引用方法为: {{ attr_name }}',
newTrigger: '新增触发器',
editTriggerTitle: '编辑触发器 {name}',
newTriggerTitle: '新增触发器 {name}',
confirmDeleteTrigger: '确认删除该触发器吗?',
int: '整数',
float: '浮点数',
text: '文本',
datetime: '日期时间',
date: '日期',
time: '时间',
json: 'JSON',
event: '事件'
},
components: {
unselectAttributes: '未选属性',
selectAttributes: '已选属性',
downloadCI: '导出数据',
filename: '文件名',
filenameInputTips: '请输入文件名',
saveType: '保存类型',
saveTypeTips: '请选择保存类型',
xlsx: 'Excel工作簿(*.xlsx)',
csv: 'CSV(逗号分隔)(*.csv)',
html: '网页(*.html)',
xml: 'XML数据(*.xml)',
txt: '文本文件(制表符分隔)(*.txt)',
grantUser: '授权用户/部门',
grantRole: '授权角色',
confirmRevoke: '确认删除 【{name}】 的 【授权】 权限?',
readAttribute: '查看字段',
readCI: '查看实例',
config: '配置',
ciTypeGrant: '模型权限',
ciGrant: '实例权限',
attributeGrant: '字段权限',
relationGrant: '关系权限',
perm: '权限',
all: '全部',
customize: '自定义',
none: '无',
customizeFilterName: '请输入自定义筛选条件名',
colorPickerError: '初始化颜色格式错误,使用#fff或rgb格式',
example: '示例值',
aliyun: '阿里云',
tencentcloud: '腾讯云',
huaweicloud: '华为云',
beforeChange: '变更前',
afterChange: '变更后',
noticeContentTips: '请输入通知内容',
saveQuery: '保存筛选条件',
pleaseSearch: '请查找',
conditionFilter: '条件过滤',
attributeDesc: '属性说明',
ciSearchTips: '1. json属性不能搜索<br />2. 搜索内容包括逗号, 则需转义 ,<br />3. 只搜索索引属性, 非索引属性使用条件过滤',
ciSearchTips2: '例: q=hostname:*0.0.0.0*',
subCIType: '订阅模型',
already: '已',
not: '未',
sub: '订阅',
selectBelow: '请在下方进行选择',
subSuccess: '订阅成功',
selectMethods: '请选择方式',
noAuthRequest: '暂无请求认证',
noParamRequest: '暂无参数认证',
requestParam: '请求参数',
param: '参数{param}',
value: '值{value}',
clear: '清空',
},
batch: {
downloadFailed: '失败下载',
unselectCIType: '尚未选择模板类型',
pleaseUploadFile: '请上传文件',
batchUploadCanceled: '批量上传已取消',
selectCITypeTips: '请选择模板类型',
downloadTemplate: '下载模板',
drawTips: '点击或拖拽文件至此上传!',
supportFileTypes: '支持文件类型xlsxlsx',
uploadResult: '上传结果',
total: '共',
successItems: '条,已成功',
failedItems: '条,失败',
items: '条',
errorTips: '错误信息',
requestFailedTips: '请求出现错误,请稍后再试',
requestSuccessTips: '批量上传已完成',
},
preference: {
mySub: '我的订阅',
sub: '订阅',
cancelSub: '取消订阅',
editSub: '编辑订阅',
peopleSub: '位同事已订阅',
noSub: '暂无同事订阅',
cancelSubSuccess: '取消订阅成功',
confirmcancelSub: '确认取消订阅',
confirmcancelSub2: '确认取消订阅 {name} 吗?',
of: '的',
hoursAgo: '小时前',
daysAgo: '天前',
monthsAgo: '月前',
yearsAgo: '年前',
just: '刚刚',
},
custom_dashboard: {
charts: '图表',
newChart: '新增图表',
editChart: '编辑图表',
title: '标题',
titleTips: '请输入图表标题',
calcIndicators: '计算指标',
dimensions: '维度',
selectDimensions: '请选择维度',
quantity: '数量',
childCIType: '关系模型',
level: '层级',
levelTips: '请输入关系层级',
preview: '预览',
showIcon: '是否显示icon',
chartType: '图表类型',
dataFilter: '数据筛选',
format: '格式',
fontColor: '字体颜色',
backgroundColor: '背景颜色',
chartColor: '图表颜色',
chartLength: '图表长度',
barType: '柱状图类型',
stackedBar: '堆积柱状图',
multipleSeriesBar: '多系列柱状图',
axis: '轴',
direction: '方向',
lowerShadow: '下方阴影',
count: '指标',
bar: '柱状图',
line: '折线图',
pie: '饼状图',
table: '表格',
default: '默认',
relation: '关系',
noCustomDashboard: '管理员暂未定制仪表盘',
},
preference_relation: {
newServiceTree: '新增服务树',
serviceTreeName: '服务树名',
public: '公开',
saveLayout: '保存布局',
childNodesNotFound: '不存在子节点,不能形成业务关系,请重新选择!',
tips1: '不能与当前选中节点形成视图,请重新选择!',
tips2: '请输入新增服务树名!',
tips3: '请选择至少两个节点!',
},
history: {
ciChange: 'CI变更',
relationChange: '关系变更',
ciTypeChange: '模型变更',
triggerHistory: '触发历史',
opreateTime: '操作时间',
user: '用户',
userTips: '输入筛选用户名',
filter: '筛选',
filterOperate: '筛选操作',
attribute: '属性',
old: '旧',
new: '新',
noUpdate: '没有修改',
itemsPerPage: '/页',
triggerName: '触发器名称',
event: '事件',
action: '动作',
status: '状态',
done: '已完成',
undone: '未完成',
triggerTime: '触发时间',
totalItems: '共 {total} 条记录',
pleaseSelect: '请选择',
startTime: '开始时间',
endTime: '结束时间',
deleteCIType: '删除模型',
addCIType: '新增模型',
updateCIType: '修改模型',
addAttribute: '新增属性',
updateAttribute: '修改属性',
deleteAttribute: '删除属性',
addTrigger: '新增触发器',
updateTrigger: '修改触发器',
deleteTrigger: '删除触发器',
addUniqueConstraint: '新增联合唯一',
updateUniqueConstraint: '修改联合唯一',
deleteUniqueConstraint: '删除联合唯一',
addRelation: '新增关系',
deleteRelation: '删除关系',
noModifications: '没有修改',
attr: '属性名',
attrId: '属性ID',
changeDescription: '属性ID{attr_id},提前:{before_days}天,主题:{subject}\n内容{body}\n通知时间{notify_at}'
},
relation_type: {
addRelationType: '新增关系类型',
nameTips: '请输入类型名',
},
ad: {
upload: '规则导入',
download: '规则导出',
accpet: '入库',
accpetBy: '入库人',
acceptTime: '入库时间',
confirmAccept: '确认入库?',
accpetSuccess: '入库成功',
isAccpet: '是否入库',
deleteADC: '确认删除该条数据?',
batchDelete: '确认删除这些数据?',
agent: '内置 & 插件',
snmp: '网络设备',
http: '公有云资源',
rule: '自动发现规则',
timeout: '超时错误',
mode: '模式',
collectSettings: '采集设置',
updateFields: '更新字段',
pluginScript: `# -*- coding:utf-8 -*-
import json
class AutoDiscovery(object):
@property
def unique_key(self):
"""
:return: 返回唯一属性的名字
"""
return
@staticmethod
def attributes():
"""
定义属性字段
:return: 返回属性字段列表, 列表项是(名称, 类型, 描述), 名称必须是英文
类型: String Integer Float Date DateTime Time JSON
例如:
return [
("ci_type", "String", "模型名称"),
("private_ip", "String", "内网IP, 多值逗号分隔")
]
"""
return []
@staticmethod
def run():
"""
执行入口, 返回采集的属性值
:return: 返回一个列表, 列表项是字典, 字典key是属性名称, value是属性值
例如:
return [dict(ci_type="server", private_ip="192.168.1.1")]
"""
return []
if __name__ == "__main__":
result = AutoDiscovery().run()
if isinstance(result, list):
print("AutoDiscovery::Result::{}".format(json.dumps(result)))
else:
print("ERROR: 采集返回必须是列表")
`,
server: '物理机',
vserver: '虚拟机',
nic: '网卡',
disk: '硬盘',
},
ci: {
attributeDesc: '属性说明',
selectRows: '选取:{rows} 项',
addRelation: '添加关系',
all: '全部',
batchUpdate: '批量修改',
batchUpdateConfirm: '确认要批量修改吗?',
batchUpdateInProgress: '正在批量修改',
batchUpdateInProgress2: '正在批量修改,共{total}个,成功{successNum}个,失败{errorNum}个',
batchDeleting: '正在删除...',
batchDeleting2: '正在删除,共{total}个,成功{successNum}个,失败{errorNum}个',
copyFailed: '复制失败!',
noLevel: '无层级关系!',
batchAddRelation: '批量添加关系',
history: '操作历史',
topo: '拓扑',
table: '表格',
m2mTips: '当前模型关系为多对多,请前往关系视图进行增删操作',
confirmDeleteRelation: '确认删除关系?',
tips1: '多个值使用,分割',
tips2: '可根据需要修改字段,当值为 空 时,则该字段 置空',
tips3: '请选择需要修改的字段',
tips4: '必须至少选择一个字段',
tips5: '搜索 名称 | 别名',
tips6: '加快检索, 可以全文搜索, 无需使用条件过滤\n\n json目前不支持建索引 \n\n文本字符长度超过190不能建索引',
tips7: '表现形式是下拉框, 值必须在预定义值里',
tips8: '多值, 比如内网IP',
tips9: '仅针对前端',
tips10: '模型的其他属性通过表达式的方式计算出来\n\n一个代码片段计算返回的值',
newUpdateField: '新增修改字段',
attributeSettings: '字段设置',
},
serviceTree: {
deleteNode: '删除节点',
tips1: '例q=os_version:centos&sort=os_version',
tips2: '表达式搜索',
alert1: '管理员 还未配置业务关系, 或者你无权限访问!',
copyFailed: '复制失败',
deleteRelationConfirm: '确认将选中的 {name} 从当前关系中删除?',
},
tree: {
tips1: '请先到 我的订阅 页面完成订阅!',
subSettings: '订阅设置',
}
}
export default cmdb_zh

View File

@ -13,19 +13,19 @@ const genCmdbRoutes = async () => {
{ {
path: '/cmdb/dashboard', path: '/cmdb/dashboard',
name: 'cmdb_dashboard', name: 'cmdb_dashboard',
meta: { title: '仪表盘', icon: 'ops-cmdb-dashboard', selectedIcon: 'ops-cmdb-dashboard-selected', keepAlive: false }, meta: { title: 'dashboard', icon: 'ops-cmdb-dashboard', selectedIcon: 'ops-cmdb-dashboard-selected', keepAlive: false },
component: () => import('../views/dashboard/index_v2.vue') component: () => import('../views/dashboard/index_v2.vue')
}, },
{ {
path: '/cmdb/disabled1', path: '/cmdb/disabled1',
name: 'cmdb_disabled1', name: 'cmdb_disabled1',
meta: { title: '视图', disabled: true }, meta: { title: 'cmdb.menu.views', disabled: true },
}, },
{ {
path: '/cmdb/resourceviews', path: '/cmdb/resourceviews',
name: 'cmdb_resource_views', name: 'cmdb_resource_views',
component: RouteView, component: RouteView,
meta: { title: '资源数据', icon: 'ops-cmdb-resource', selectedIcon: 'ops-cmdb-resource-selected', keepAlive: true }, meta: { title: 'cmdb.menu.ciTable', icon: 'ops-cmdb-resource', selectedIcon: 'ops-cmdb-resource-selected', keepAlive: true },
hideChildrenInMenu: false, hideChildrenInMenu: false,
children: [] children: []
}, },
@ -33,108 +33,108 @@ const genCmdbRoutes = async () => {
path: '/cmdb/tree_views', path: '/cmdb/tree_views',
component: () => import('../views/tree_views'), component: () => import('../views/tree_views'),
name: 'cmdb_tree_views', name: 'cmdb_tree_views',
meta: { title: '资源层级', icon: 'ops-cmdb-tree', selectedIcon: 'ops-cmdb-tree-selected', keepAlive: false }, meta: { title: 'cmdb.menu.ciTree', icon: 'ops-cmdb-tree', selectedIcon: 'ops-cmdb-tree-selected', keepAlive: false },
hideChildrenInMenu: true, hideChildrenInMenu: true,
children: [ children: [
{ {
path: '/cmdb/tree_views/:typeId', path: '/cmdb/tree_views/:typeId',
name: 'cmdb_tree_views_item', name: 'cmdb_tree_views_item',
component: () => import('../views/tree_views'), component: () => import('../views/tree_views'),
meta: { title: '资源层级', keepAlive: false }, meta: { title: 'cmdb.menu.ciTree', keepAlive: false },
hidden: true hidden: true
}] }]
}, },
{ {
path: '/cmdb/resourcesearch', path: '/cmdb/resourcesearch',
name: 'cmdb_resource_search', name: 'cmdb_resource_search',
meta: { title: '资源搜索', icon: 'ops-cmdb-search', selectedIcon: 'ops-cmdb-search-selected', keepAlive: false }, meta: { title: 'cmdb.menu.ciSearch', icon: 'ops-cmdb-search', selectedIcon: 'ops-cmdb-search-selected', keepAlive: false },
component: () => import('../views/resource_search/index.vue') component: () => import('../views/resource_search/index.vue')
}, },
{ {
path: '/cmdb/adc', path: '/cmdb/adc',
name: 'cmdb_auto_discovery_ci', name: 'cmdb_auto_discovery_ci',
meta: { title: '自动发现池', icon: 'ops-cmdb-adc', selectedIcon: 'ops-cmdb-adc-selected', keepAlive: false }, meta: { title: 'cmdb.menu.adCIs', icon: 'ops-cmdb-adc', selectedIcon: 'ops-cmdb-adc-selected', keepAlive: false },
component: () => import('../views/discoveryCI/index.vue') component: () => import('../views/discoveryCI/index.vue')
}, },
{ {
path: '/cmdb/disabled2', path: '/cmdb/disabled2',
name: 'cmdb_disabled2', name: 'cmdb_disabled2',
meta: { title: '配置', disabled: true, }, meta: { title: 'cmdb.menu.config', disabled: true, },
}, },
{ {
path: '/cmdb/preference', path: '/cmdb/preference',
component: () => import('../views/preference/index'), component: () => import('../views/preference/index'),
name: 'cmdb_preference', name: 'cmdb_preference',
meta: { title: '我的订阅', icon: 'ops-cmdb-preference', selectedIcon: 'ops-cmdb-preference-selected', keepAlive: false } meta: { title: 'cmdb.menu.preference', icon: 'ops-cmdb-preference', selectedIcon: 'ops-cmdb-preference-selected', keepAlive: false }
}, },
{ {
path: '/cmdb/batch', path: '/cmdb/batch',
component: () => import('../views/batch'), component: () => import('../views/batch'),
name: 'cmdb_batch', name: 'cmdb_batch',
meta: { 'title': '批量导入', icon: 'ops-cmdb-batch', selectedIcon: 'ops-cmdb-batch-selected', keepAlive: false } meta: { 'title': 'cmdb.menu.batchUpload', icon: 'ops-cmdb-batch', selectedIcon: 'ops-cmdb-batch-selected', keepAlive: false }
}, },
{ {
path: '/cmdb/ci_types', path: '/cmdb/ci_types',
name: 'ci_type', name: 'ci_type',
component: () => import('../views/ci_types/index'), component: () => import('../views/ci_types/index'),
meta: { title: '模型配置', icon: 'ops-cmdb-citype', selectedIcon: 'ops-cmdb-citype-selected', keepAlive: false, permission: ['cmdb_admin', 'admin'] } meta: { title: 'cmdb.menu.citypeManage', icon: 'ops-cmdb-citype', selectedIcon: 'ops-cmdb-citype-selected', keepAlive: false, permission: ['cmdb_admin', 'admin'] }
}, },
{ {
path: '/cmdb/disabled3', path: '/cmdb/disabled3',
name: 'cmdb_disabled3', name: 'cmdb_disabled3',
meta: { title: '管理端', disabled: true, permission: ['cmdb_admin', 'OneOPS_Application_Admin', 'admin'], }, meta: { title: 'cmdb.menu.backend', disabled: true, permission: ['cmdb_admin', 'OneOPS_Application_Admin', 'admin'], },
}, },
{ {
path: '/cmdb/citypes', path: '/cmdb/citypes',
name: 'cmdb_ci_type', name: 'cmdb_ci_type',
component: RouteView, component: RouteView,
redirect: '/cmdb/ci_type', redirect: '/cmdb/ci_type',
meta: { title: '后台管理', icon: 'setting', permission: ['cmdb_admin', 'OneOPS_Application_Admin', 'admin'], }, meta: { title: 'cmdb.menu.backendManage', icon: 'setting', permission: ['cmdb_admin', 'OneOPS_Application_Admin', 'admin'], },
children: [ children: [
{ {
path: '/cmdb/customdashboard', path: '/cmdb/customdashboard',
name: 'cmdb_custom_dashboard', name: 'cmdb_custom_dashboard',
component: () => import('../views/custom_dashboard/index'), component: () => import('../views/custom_dashboard/index'),
meta: { title: '定制仪表盘', keepAlive: false, icon: 'ops-cmdb-customdashboard', selectedIcon: 'ops-cmdb-customdashboard-selected' } meta: { title: 'cmdb.menu.customDashboard', keepAlive: false, icon: 'ops-cmdb-customdashboard', selectedIcon: 'ops-cmdb-customdashboard-selected' }
}, },
{ {
path: '/cmdb/preferencerelation', path: '/cmdb/preferencerelation',
name: 'preference_relation', name: 'preference_relation',
component: () => import('../views/preference_relation/index'), component: () => import('../views/preference_relation/index'),
meta: { title: '业务关系定义', keepAlive: false, icon: 'ops-cmdb-preferencerelation', selectedIcon: 'ops-cmdb-preferencerelation-selected' } meta: { title: 'cmdb.menu.serviceTreeDefine', keepAlive: false, icon: 'ops-cmdb-preferencerelation', selectedIcon: 'ops-cmdb-preferencerelation-selected' }
}, },
{ {
path: '/cmdb/modelrelation', path: '/cmdb/modelrelation',
name: 'model_relation', name: 'model_relation',
hideChildrenInMenu: true, hideChildrenInMenu: true,
component: () => import('../views/model_relation/index'), component: () => import('../views/model_relation/index'),
meta: { title: '模型关系', keepAlive: false, icon: 'ops-cmdb-modelrelation', selectedIcon: 'ops-cmdb-modelrelation-selected' } meta: { title: 'cmdb.menu.citypeRelation', keepAlive: false, icon: 'ops-cmdb-modelrelation', selectedIcon: 'ops-cmdb-modelrelation-selected' }
}, },
{ {
path: '/cmdb/operationhistory', path: '/cmdb/operationhistory',
name: 'operation_history', name: 'operation_history',
hideChildrenInMenu: true, hideChildrenInMenu: true,
component: () => import('../views/operation_history/index'), component: () => import('../views/operation_history/index'),
meta: { title: '操作审计', keepAlive: false, icon: 'ops-cmdb-operation', selectedIcon: 'ops-cmdb-operation-selected' } meta: { title: 'cmdb.menu.operationHistory', keepAlive: false, icon: 'ops-cmdb-operation', selectedIcon: 'ops-cmdb-operation-selected' }
}, },
{ {
path: '/cmdb/relationtype', path: '/cmdb/relationtype',
name: 'relation_type', name: 'relation_type',
hideChildrenInMenu: true, hideChildrenInMenu: true,
component: () => import('../views/relation_type/index'), component: () => import('../views/relation_type/index'),
meta: { title: '关系类型', keepAlive: false, icon: 'ops-cmdb-relationtype', selectedIcon: 'ops-cmdb-relationtype-selected' } meta: { title: 'cmdb.menu.relationType', keepAlive: false, icon: 'ops-cmdb-relationtype', selectedIcon: 'ops-cmdb-relationtype-selected' }
}, },
{ {
path: '/cmdb/discovery', path: '/cmdb/discovery',
name: 'discovery', name: 'discovery',
component: () => import('../views/discovery/index'), component: () => import('../views/discovery/index'),
meta: { title: '自动发现', keepAlive: false, icon: 'ops-cmdb-adr', selectedIcon: 'ops-cmdb-adr-selected' } meta: { title: 'cmdb.menu.ad', keepAlive: false, icon: 'ops-cmdb-adr', selectedIcon: 'ops-cmdb-adr-selected' }
}, },
] ]
} }
] ]
} }
// 动态添加订阅的条目及业务关系 // Dynamically add subscription items and business relationships
const [preference, relation] = await Promise.all([getPreference(), getRelationView()]) const [preference, relation] = await Promise.all([getPreference(), getRelationView()])
preference.forEach(item => { preference.forEach(item => {
@ -143,7 +143,7 @@ const genCmdbRoutes = async () => {
component: () => import(`../views/ci/index`), component: () => import(`../views/ci/index`),
name: `cmdb_${item.id}`, name: `cmdb_${item.id}`,
meta: { title: item.alias, keepAlive: false, typeId: item.id, name: item.name, customIcon: item.icon }, meta: { title: item.alias, keepAlive: false, typeId: item.id, name: item.name, customIcon: item.icon },
// hideChildrenInMenu: true // 强制显示 MenuItem 而不是 SubMenu // hideChildrenInMenu: true // Force display of MenuItem instead of SubMenu
}) })
}) })
const lastTypeId = window.localStorage.getItem('ops_ci_typeid') || undefined const lastTypeId = window.localStorage.getItem('ops_ci_typeid') || undefined

View File

@ -1,13 +1,17 @@
export const valueTypeMap = { import i18n from '@/lang'
'0': '整数',
'1': '浮点数', export const valueTypeMap = () => {
'2': '文本', return {
'3': '日期时间', '0': i18n.t('cmdb.ciType.int'),
'4': '日期', '1': i18n.t('cmdb.ciType.float'),
'5': '时间', '2': i18n.t('cmdb.ciType.text'),
'3': i18n.t('cmdb.ciType.datetime'),
'4': i18n.t('cmdb.ciType.date'),
'5': i18n.t('cmdb.ciType.time'),
'6': 'JSON', '6': 'JSON',
'7': '密码', '7': i18n.t('cmdb.ciType.password'),
'8': '链接' '8': i18n.t('cmdb.ciType.link')
}
} }
export const defautValueColor = [ export const defautValueColor = [

View File

@ -16,9 +16,9 @@
<CiUploadTable :ciTypeAttrs="ciTypeAttrs" ref="ciUploadTable" :uploadData="uploadData"></CiUploadTable> <CiUploadTable :ciTypeAttrs="ciTypeAttrs" ref="ciUploadTable" :uploadData="uploadData"></CiUploadTable>
<div class="cmdb-batch-upload-action"> <div class="cmdb-batch-upload-action">
<a-space size="large"> <a-space size="large">
<a-button type="primary" ghost @click="handleCancel">取消</a-button> <a-button type="primary" ghost @click="handleCancel">{{ $t('cancel') }}</a-button>
<a-button @click="handleUpload" type="primary">上传</a-button> <a-button @click="handleUpload" type="primary">{{ $t('upload') }}</a-button>
<a-button v-if="hasError && !isUploading" @click="downloadError" type="primary">失败下载</a-button> <a-button v-if="hasError && !isUploading" @click="downloadError" type="primary">{{ $t('cmdb.batch.downloadFailed') }}</a-button>
</a-space> </a-space>
</div> </div>
</a-col> </a-col>
@ -109,7 +109,7 @@ export default {
}, },
handleUpload() { handleUpload() {
if (!this.ciType) { if (!this.ciType) {
this.$message.error('尚未选择模板类型') this.$message.error(this.$t('cmdb.batch.unselectCIType'))
return return
} }
if (this.uploadData && this.uploadData.length > 0) { if (this.uploadData && this.uploadData.length > 0) {
@ -118,7 +118,7 @@ export default {
this.$refs.uploadResult.upload2Server() this.$refs.uploadResult.upload2Server()
}) })
} else { } else {
this.$message.error('请上传文件') this.$message.error(this.$t('cmdb.batch.pleaseUploadFile'))
} }
}, },
handleCancel() { handleCancel() {
@ -127,7 +127,7 @@ export default {
this.$refs.ciTypeChoice.selectNum = null this.$refs.ciTypeChoice.selectNum = null
this.hasError = false this.hasError = false
} else { } else {
this.$message.warning('批量上传已取消') this.$message.warning(this.$t('cmdb.batch.batchUploadCanceled'))
this.isUploading = false this.isUploading = false
} }
}, },

View File

@ -1,9 +1,9 @@
<template> <template>
<a-space> <a-space>
<span>模板类型</span> <span>{{ $t('cmdb.ciType.ciType') }}: </span>
<a-select <a-select
showSearch showSearch
placeholder="请选择模板类型" :placeholder="$t('cmdb.batch.selectCITypeTips')"
@change="selectCiType" @change="selectCiType"
:style="{ width: '300px' }" :style="{ width: '300px' }"
class="ops-select" class="ops-select"
@ -20,7 +20,7 @@
type="primary" type="primary"
class="ops-button-primary" class="ops-button-primary"
icon="download" icon="download"
>下载模板</a-button >{{ $t('cmdb.batch.downloadTemplate') }}</a-button
> >
<a-modal <a-modal
:bodyStyle="{ paddingTop: 0 }" :bodyStyle="{ paddingTop: 0 }"
@ -31,14 +31,14 @@
@ok="handleOk" @ok="handleOk"
wrapClassName="ci-type-choice-modal" wrapClassName="ci-type-choice-modal"
> >
<a-divider orientation="left">模型属性</a-divider> <a-divider orientation="left">{{ $t('cmdb.ciType.attributes') }}</a-divider>
<a-checkbox <a-checkbox
@change="changeCheckAll" @change="changeCheckAll"
:style="{ marginBottom: '20px' }" :style="{ marginBottom: '20px' }"
:indeterminate="indeterminate" :indeterminate="indeterminate"
:checked="checkAll" :checked="checkAll"
> >
全选 {{ $t('checkAll') }}
</a-checkbox> </a-checkbox>
<br /> <br />
<a-checkbox-group style="width:100%" v-model="checkedAttrs"> <a-checkbox-group style="width:100%" v-model="checkedAttrs">
@ -52,7 +52,7 @@
</a-row> </a-row>
</a-checkbox-group> </a-checkbox-group>
<template v-if="parentsType && parentsType.length"> <template v-if="parentsType && parentsType.length">
<a-divider orientation="left">模型关联</a-divider> <a-divider orientation="left">{{ $t('cmdb.ciType.relation') }}</a-divider>
<a-row :gutter="[24, 24]" align="top" type="flex"> <a-row :gutter="[24, 24]" align="top" type="flex">
<a-col :style="{ display: 'inline-flex' }" :span="12" v-for="item in parentsType" :key="item.id"> <a-col :style="{ display: 'inline-flex' }" :span="12" v-for="item in parentsType" :key="item.id">
<a-checkbox @click="clickParent(item)" :checked="checkedParents.includes(item.alias || item.name)"> <a-checkbox @click="clickParent(item)" :checked="checkedParents.includes(item.alias || item.name)">
@ -150,7 +150,7 @@ export default {
}, },
methods: { methods: {
selectCiType(el) { selectCiType(el) {
// 当选择好模板类型时的回调函数 // Callback function when a template type is selected
getCITypeAttributesById(el).then((res) => { getCITypeAttributesById(el).then((res) => {
this.$emit('getCiTypeAttr', res) this.$emit('getCiTypeAttr', res)
this.selectCiTypeAttrList = res this.selectCiTypeAttrList = res

View File

@ -10,8 +10,8 @@
:disabled="!ciType || isUploading" :disabled="!ciType || isUploading"
> >
<img :style="{ width: '80px', height: '80px' }" src="@/assets/file_upload.png" /> <img :style="{ width: '80px', height: '80px' }" src="@/assets/file_upload.png" />
<p class="ant-upload-text">点击或拖拽文件至此上传</p> <p class="ant-upload-text">{{ $t('cmdb.batch.drawTips') }}</p>
<p class="ant-upload-hint">支持文件类型xlsxlsx</p> <p class="ant-upload-hint">{{ $t('cmdb.batch.supportFileTypes') }}</p>
</a-upload-dragger> </a-upload-dragger>
<div v-for="item in fileList" :key="item.name" class="cmdb-batch-upload-dragger-file"> <div v-for="item in fileList" :key="item.name" class="cmdb-batch-upload-dragger-file">
<span><a-icon type="file" :style="{ color: '#2F54EB', marginRight: '5px' }" />{{ item.name }}</span> <span><a-icon type="file" :style="{ color: '#2F54EB', marginRight: '5px' }" />{{ item.name }}</span>

View File

@ -1,13 +1,13 @@
<template> <template>
<div class="cmdb-batch-upload-result" v-if="visible"> <div class="cmdb-batch-upload-result" v-if="visible">
<h3 class="cmdb-batch-upload-result-title">上传结果</h3> <h3 class="cmdb-batch-upload-result-title">{{ $t('cmdb.batch.uploadResult') }}</h3>
<div class="cmdb-batch-upload-result-content"> <div class="cmdb-batch-upload-result-content">
<h4> <h4>
&nbsp;<span style="color: blue">{{ total }}</span> 已成功 {{ $t('cmdb.batch.total') }}&nbsp;<span style="color: blue">{{ total }}</span> {{ $t('cmdb.batch.successItems') }}
<span style="color: lightgreen">{{ success }}</span> 失败 <span style="color: red">{{ errorNum }} </span> <span style="color: lightgreen">{{ success }}</span> {{ $t('cmdb.batch.failedItems') }} <span style="color: red">{{ errorNum }} </span>{{ $t('cmdb.batch.items') }}
</h4> </h4>
<div> <div>
<span>错误信息</span> <span>{{ $t('cmdb.batch.errorTips') }}: </span>
<ol> <ol>
<li :key="item + index" v-for="(item, index) in errorItems">{{ item }}</li> <li :key="item + index" v-for="(item, index) in errorItems">{{ item }}</li>
</ol> </ol>
@ -71,7 +71,7 @@ export default {
if (r.status === 'fulfilled') { if (r.status === 'fulfilled') {
this.success += 1 this.success += 1
} else { } else {
this.errorItems.push(r?.reason?.response?.data.message ?? '请求出现错误,请稍后再试') this.errorItems.push(r?.reason?.response?.data.message ?? this.$t('cmdb.batch.requestFailedTips'))
this.errorNum += 1 this.errorNum += 1
this.$emit('uploadResultError', 6 * i + j) this.$emit('uploadResultError', 6 * i + j)
} }
@ -86,7 +86,7 @@ export default {
} }
if (this.isUploading) { if (this.isUploading) {
this.$emit('uploadResultDone') this.$emit('uploadResultDone')
this.$message.success('批量上传已完成') this.$message.success(this.$t('cmdb.batch.requestSuccessTips'))
} }
}, },
}, },

View File

@ -11,22 +11,24 @@
" "
class="cmdb-views-header-metadata" class="cmdb-views-header-metadata"
> >
<a-icon type="info-circle" />属性说明 <a-icon type="info-circle" />{{ $t('cmdb.ci.attributeDesc') }}
</span> </span>
</span> </span>
<a-space> <a-space>
<a-button size="small" icon="plus" type="primary" @click="$refs.create.handleOpen(true, 'create')"> <a-button size="small" icon="plus" type="primary" @click="$refs.create.handleOpen(true, 'create')">
新建 {{ $t('create') }}
</a-button> </a-button>
<a-button size="small" icon="user-add" type="primary" ghost @click="handlePerm">授权</a-button> <a-button size="small" icon="user-add" type="primary" ghost @click="handlePerm">{{ $t('grant') }}</a-button>
<a-popconfirm <a-popconfirm
:title="`确认取消订阅 ${this.$route.meta.title || this.$route.meta.name} 吗?`" :title="
ok-text="确认" $t('cmdb.preference.confirmcancelSub2', { name: `${this.$route.meta.title || this.$route.meta.name}` })
cancel-text="取消" "
:ok-text="$t('confirm')"
:cancel-text="$t('cancel')"
@confirm="unsubscribe" @confirm="unsubscribe"
placement="bottomRight" placement="bottomRight"
> >
<a-button size="small" icon="star" type="primary" ghost>取消订阅</a-button> <a-button size="small" icon="star" type="primary" ghost>{{ $t('cmdb.preference.cancelSub') }}</a-button>
</a-popconfirm> </a-popconfirm>
</a-space> </a-space>
</div> </div>
@ -47,12 +49,12 @@
@setParamsFromPreferenceSearch="setParamsFromPreferenceSearch" @setParamsFromPreferenceSearch="setParamsFromPreferenceSearch"
/> />
<div class="ops-list-batch-action" v-show="!!selectedRowKeys.length"> <div class="ops-list-batch-action" v-show="!!selectedRowKeys.length">
<span @click="$refs.create.handleOpen(true, 'update')">修改</span> <span @click="$refs.create.handleOpen(true, 'update')">{{ $t('update') }}</span>
<a-divider type="vertical" /> <a-divider type="vertical" />
<span @click="openBatchDownload">下载</span> <span @click="openBatchDownload">{{ $t('download') }}</span>
<a-divider type="vertical" /> <a-divider type="vertical" />
<span @click="batchDelete">删除</span> <span @click="batchDelete">{{ $t('delete') }}</span>
<span>选取{{ selectedRowKeys.length }} </span> <span>{{ $t('cmdb.ci.selectRows', { rows: selectedRowKeys.length }) }}</span>
</div> </div>
</SearchForm> </SearchForm>
<CiDetail ref="detail" :typeId="typeId" /> <CiDetail ref="detail" :typeId="typeId" />
@ -114,7 +116,7 @@
:getPopupContainer="(trigger) => trigger.parentElement" :getPopupContainer="(trigger) => trigger.parentElement"
:style="{ width: '100%', height: '32px' }" :style="{ width: '100%', height: '32px' }"
v-model="row[col.field]" v-model="row[col.field]"
placeholder="请选择" :v-bind="$t('placeholder2')"
v-if="col.is_choice" v-if="col.is_choice"
:showArrow="false" :showArrow="false"
:mode="col.is_list ? 'multiple' : 'default'" :mode="col.is_list ? 'multiple' : 'default'"
@ -149,7 +151,7 @@
:getPopupContainer="(trigger) => trigger.parentElement" :getPopupContainer="(trigger) => trigger.parentElement"
:style="{ width: '100%', height: '32px' }" :style="{ width: '100%', height: '32px' }"
v-model="row[col.field]" v-model="row[col.field]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-else-if="col.is_list" v-else-if="col.is_list"
:showArrow="false" :showArrow="false"
mode="tags" mode="tags"
@ -230,9 +232,9 @@
</template> </template>
</template> </template>
</vxe-table-column> </vxe-table-column>
<vxe-column align="left" field="operate" fixed="right" width="80"> <vxe-column align="left" field="operate" fixed="right" width="120">
<template #header> <template #header>
<span>操作</span> <span>{{ $t('operation') }}</span>
<EditAttrsPopover :typeId="typeId" class="operation-icon" @refresh="refreshAfterEditAttrs" /> <EditAttrsPopover :typeId="typeId" class="operation-icon" @refresh="refreshAfterEditAttrs" />
<!-- <a-icon class="operation-icon" type="control" /> --> <!-- <a-icon class="operation-icon" type="control" /> -->
</template> </template>
@ -241,7 +243,7 @@
<a @click="$refs.detail.create(row.ci_id || row._id)"> <a @click="$refs.detail.create(row.ci_id || row._id)">
<a-icon type="unordered-list" /> <a-icon type="unordered-list" />
</a> </a>
<a-tooltip title="添加关系"> <a-tooltip :title="$t('cmdb.ci.addRelation')">
<a @click="$refs.detail.create(row.ci_id || row._id, 'tab_2', '2')"> <a @click="$refs.detail.create(row.ci_id || row._id, 'tab_2', '2')">
<a-icon type="retweet" /> <a-icon type="retweet" />
</a> </a>
@ -253,10 +255,10 @@
</template> </template>
</vxe-column> </vxe-column>
<template #empty> <template #empty>
<div v-if="loading" style="height: 200px; line-height: 200px">加载中...</div> <div v-if="loading" style="height: 200px; line-height: 200px">{{ $t('loading') }}</div>
<div v-else> <div v-else>
<img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" /> <img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" />
<div>暂无数据</div> <div>{{ $t('noData') }}</div>
</div> </div>
</template> </template>
</ops-table> </ops-table>
@ -270,7 +272,14 @@
:page-size="pageSize" :page-size="pageSize"
:page-size-options="pageSizeOptions" :page-size-options="pageSizeOptions"
@showSizeChange="onShowSizeChange" @showSizeChange="onShowSizeChange"
:show-total="(total, range) => `当前${range[0]}-${range[1]} 共 ${total}条记录`" :show-total="
(total, range) =>
$t('pagination.total', {
range0: range[0],
range1: range[1],
total,
})
"
@change=" @change="
(page) => { (page) => {
currentPage = page currentPage = page
@ -278,12 +287,14 @@
" "
> >
<template slot="buildOptionText" slot-scope="props"> <template slot="buildOptionText" slot-scope="props">
<span v-if="props.value !== '100000'">{{ props.value }}/</span> <span v-if="props.value !== '100000'">{{ props.value }}{{ $t('itemsPerPage') }}</span>
<span v-if="props.value === '100000'">全部</span> <span v-if="props.value === '100000'">{{ $t('cmdb.ci.all') }}</span>
</template> </template>
</a-pagination> </a-pagination>
</div> </div>
<create-instance-form ref="create" @reload="reloadData" @submit="batchUpdate" /> <create-instance-form ref="create" @reload="reloadData" @submit="batchUpdate" />
<!-- <EditAttrsDrawer ref="editAttrsDrawer" @refresh="refreshAfterEditAttrs" /> -->
<!-- <batch-update-relation :typeId="typeId" ref="batchUpdateRelation" @submit="batchUpdateRelation" /> -->
<JsonEditor ref="jsonEditor" @jsonEditorOk="jsonEditorOk" /> <JsonEditor ref="jsonEditor" @jsonEditorOk="jsonEditorOk" />
<BatchDownload ref="batchDownload" @batchDownload="batchDownload" /> <BatchDownload ref="batchDownload" @batchDownload="batchDownload" />
<MetadataDrawer ref="metadataDrawer" /> <MetadataDrawer ref="metadataDrawer" />
@ -363,17 +374,16 @@ export default {
preferenceAttrList: [], preferenceAttrList: [],
instanceList: [], instanceList: [],
// 表头
columns: [], columns: [],
// custom table alert & rowSelection // custom table alert & rowSelection
selectedRowKeys: [], selectedRowKeys: [],
// 对照是否编辑 // Check whether to edit
initialInstanceList: [], initialInstanceList: [],
sortByTable: undefined, sortByTable: undefined,
isEditActive: false, isEditActive: false,
attrList: [], attrList: [],
attributes: {}, attributes: {},
// 表格拖拽的参数 // Table drag parameters
tableDragClassName: [], tableDragClassName: [],
resource_type: {}, resource_type: {},
@ -419,11 +429,15 @@ export default {
}, },
inject: ['reloadBoard'], inject: ['reloadBoard'],
mounted() { mounted() {
// window.onkeypress = (e) => {
// this.handleKeyPress(e)
// }
setTimeout(() => { setTimeout(() => {
this.columnDrop() this.columnDrop()
}, 1000) }, 1000)
}, },
beforeDestroy() { beforeDestroy() {
// window.onkeypress = null
if (this.sortable) { if (this.sortable) {
this.sortable.destroy() this.sortable.destroy()
} }
@ -449,14 +463,19 @@ export default {
async loadTableData(sortByTable = undefined) { async loadTableData(sortByTable = undefined) {
try { try {
this.loading = true this.loading = true
// 若模糊搜索可以 queryParam相关后期可删除 // If fuzzy search is possible, queryParam can be deleted later.
// const queryParams = this.$refs['search'].queryParam || {}
const fuzzySearch = this.$refs['search'].fuzzySearch const fuzzySearch = this.$refs['search'].fuzzySearch
const expression = this.$refs['search'].expression || '' const expression = this.$refs['search'].expression || ''
const regQ = /(?<=q=).+(?=&)|(?<=q=).+$/g const regQ = /(?<=q=).+(?=&)|(?<=q=).+$/g
const regSort = /(?<=sort=).+/g const regSort = /(?<=sort=).+/g
const exp = expression.match(regQ) ? expression.match(regQ)[0] : null const exp = expression.match(regQ) ? expression.match(regQ)[0] : null
// 如果是表格点击的排序 以表格为准 // if (exp) {
// exp = exp.replace(/(\:)/g, '$1*')
// exp = exp.replace(/(\,)/g, '*$1')
// }
// If the sorting is done by clicking on the table, the table will prevail.
let sort let sort
if (sortByTable) { if (sortByTable) {
sort = sortByTable sort = sortByTable
@ -514,18 +533,55 @@ export default {
this.$refs['xTable'].getVxetableRef().setCheckboxRow(rows, true) this.$refs['xTable'].getVxetableRef().setCheckboxRow(rows, true)
} }
}, },
// mergeQ(params) {
// let q = `_type:${this.typeId}`
// Object.keys(params).forEach((key) => {
// if (!['pageNo', 'pageSize', 'sortField', 'sortOrder'].includes(key) && params[key] + '' !== '') {
// if (typeof params[key] === 'object' && params[key] && params[key].length > 1) {
// q += `,${key}:(${params[key].join(';')})`
// } else if (params[key]) {
// q += `,${key}:*${params[key]}*`
// }
// }
// })
// return q
// },
async loadPreferenceAttrList() { async loadPreferenceAttrList() {
const subscribed = await getSubscribeAttributes(this.typeId) const subscribed = await getSubscribeAttributes(this.typeId)
this.preferenceAttrList = subscribed.attributes // 已经订阅的全部列 this.preferenceAttrList = subscribed.attributes // All columns that have been subscribed
}, },
onSelectChange() { onSelectChange() {
// const current = records.map((i) => i.ci_id || i._id)
// const cached = new Set(this.selectedRowKeys)
// if (checked) {
// current.forEach((i) => {
// cached.add(i)
// })
// } else {
// if (row) {
// cached.delete(row.ci_id || row._id)
// } else {
// this.instanceList.map((row) => {
// cached.delete(row.ci_id || row._id)
// })
// }
// }
const xTable = this.$refs.xTable.getVxetableRef() const xTable = this.$refs.xTable.getVxetableRef()
const records = [...xTable.getCheckboxRecords(), ...xTable.getCheckboxReserveRecords()] const records = [...xTable.getCheckboxRecords(), ...xTable.getCheckboxReserveRecords()]
this.selectedRowKeys = records.map((i) => i.ci_id || i._id) this.selectedRowKeys = records.map((i) => i.ci_id || i._id)
}, },
onSelectRangeEnd({ records }) { onSelectRangeEnd({ records }) {
// const current = records.map((i) => i.ci_id || i._id)
// const cached = new Set(this.selectedRowKeys)
// current.forEach((i) => {
// cached.add(i)
// })
this.selectedRowKeys = records.map((i) => i.ci_id || i._id) this.selectedRowKeys = records.map((i) => i.ci_id || i._id)
// this.setSelectRows()
}, },
reloadData() { reloadData() {
this.loadTableData() this.loadTableData()
@ -538,7 +594,10 @@ export default {
const $table = this.$refs['xTable'].getVxetableRef() const $table = this.$refs['xTable'].getVxetableRef()
const data = {} const data = {}
this.columns.forEach((item) => { this.columns.forEach((item) => {
if (!(item.field in this.initialPasswordValue) && !_.isEqual(row[item.field], this.initialInstanceList[rowIndex][item.field])) { if (
!(item.field in this.initialPasswordValue) &&
!_.isEqual(row[item.field], this.initialInstanceList[rowIndex][item.field])
) {
data[item.field] = row[item.field] ?? null data[item.field] = row[item.field] ?? null
} }
}) })
@ -553,7 +612,7 @@ export default {
if (JSON.stringify(data) !== '{}') { if (JSON.stringify(data) !== '{}') {
updateCI(row.ci_id || row._id, data) updateCI(row.ci_id || row._id, data)
.then(() => { .then(() => {
this.$message.success('保存成功!') this.$message.success(this.$t('saveSuccess'))
$table.reloadRow(row, null) $table.reloadRow(row, null)
const _initialInstanceList = _.cloneDeep(this.initialInstanceList) const _initialInstanceList = _.cloneDeep(this.initialInstanceList)
_initialInstanceList[rowIndex] = { _initialInstanceList[rowIndex] = {
@ -611,8 +670,8 @@ export default {
batchUpdate(values) { batchUpdate(values) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认要批量修改吗?', content: that.$t('cmdb.ci.batchUpdateConfirm'),
async onOk() { async onOk() {
that.batchUpdateAsync(values) that.batchUpdateAsync(values)
}, },
@ -622,14 +681,14 @@ export default {
let successNum = 0 let successNum = 0
let errorNum = 0 let errorNum = 0
this.loading = true this.loading = true
this.loadTip = `正在批量修改...` this.loadTip = this.$t('cmdb.ci.batchUpdateInProgress') + '...'
const payload = {} const payload = {}
Object.keys(values).forEach((key) => { Object.keys(values).forEach((key) => {
if (values[key] || values[key] === 0) { if (values[key] || values[key] === 0) {
payload[key] = values[key] payload[key] = values[key]
} }
// 字段值支持置空 // Field values support blanking
// 目前存在字段值不支持置空由后端返回 // There are currently field values that do not support blanking and will be returned by the backend.
if (values[key] === undefined || values[key] === null) { if (values[key] === undefined || values[key] === null) {
payload[key] = null payload[key] = null
} }
@ -644,7 +703,11 @@ export default {
errorNum += 1 errorNum += 1
}) })
.finally(() => { .finally(() => {
this.loadTip = `正在批量修改${this.selectedRowKeys.length}成功${successNum}失败${errorNum}` this.loadTip = this.$t('cmdb.ci.batchUpdateInProgress2', {
total: this.selectedRowKeys.length,
successNum: successNum,
errorNum: errorNum,
})
}) })
} }
this.loading = false this.loading = false
@ -657,8 +720,8 @@ export default {
batchDelete() { batchDelete() {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认删除?', content: that.$t('confirmDelete'),
onOk() { onOk() {
that.batchDeleteAsync() that.batchDeleteAsync()
}, },
@ -668,7 +731,7 @@ export default {
let successNum = 0 let successNum = 0
let errorNum = 0 let errorNum = 0
this.loading = true this.loading = true
this.loadTip = `正在删除...` this.loadTip = this.$t('cmdb.ci.batchDeleting')
const floor = Math.ceil(this.selectedRowKeys.length / 6) const floor = Math.ceil(this.selectedRowKeys.length / 6)
for (let i = 0; i < floor; i++) { for (let i = 0; i < floor; i++) {
const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6) const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6)
@ -684,7 +747,11 @@ export default {
}) })
}) })
.finally(() => { .finally(() => {
this.loadTip = `正在删除${this.selectedRowKeys.length}成功${successNum}失败${errorNum}` this.loadTip = this.$t('cmdb.ci.batchDeleting2', {
total: this.selectedRowKeys.length,
successNum: successNum,
errorNum: errorNum,
})
}) })
} }
this.loading = false this.loading = false
@ -703,12 +770,12 @@ export default {
deleteCI(record) { deleteCI(record) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认删除?', content: that.$t('confirmDelete'),
onOk() { onOk() {
deleteCI(record.ci_id || record._id).then((res) => { deleteCI(record.ci_id || record._id).then((res) => {
// that.$refs.table.refresh(true) // that.$refs.table.refresh(true)
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.reloadData() that.reloadData()
}) })
}, },
@ -731,7 +798,7 @@ export default {
this.$refs.jsonEditor.open(column, row) this.$refs.jsonEditor.open(column, row)
}, },
jsonEditorOk(row, column, jsonData) { jsonEditorOk(row, column, jsonData) {
// 后端写数据有快慢不拉接口直接修改table的数据 // The backend writes data at different speeds. You can modify the table data directly without pulling the interface.
// this.reloadData() // this.reloadData()
this.instanceList.forEach((item) => { this.instanceList.forEach((item) => {
if (item._id === row._id) { if (item._id === row._id) {
@ -747,6 +814,9 @@ export default {
} else { } else {
this.currentPage = 1 this.currentPage = 1
} }
setTimeout(() => {
// this.setSelectRows()
}, 500)
}, },
handleSortCol({ column, property, order, sortBy, sortList, $event }) { handleSortCol({ column, property, order, sortBy, sortList, $event }) {
let sortByTable let sortByTable
@ -781,7 +851,7 @@ export default {
}, },
onEnd: (params) => { onEnd: (params) => {
// 由于开启了虚拟滚动newIndex和oldIndex是虚拟的 // 由于开启了虚拟滚动newIndex和oldIndex是虚拟的
const { newIndex, oldIndex, from, to } = params const { newIndex, oldIndex } = params
// 从tableDragClassName拿到colid // 从tableDragClassName拿到colid
const fromColid = this.tableDragClassName[oldIndex] const fromColid = this.tableDragClassName[oldIndex]
const toColid = this.tableDragClassName[newIndex] const toColid = this.tableDragClassName[newIndex]
@ -798,6 +868,9 @@ export default {
) )
}) })
}, },
// tableFilterChangeEvent({ column, property, values, datas, filterList, $event }) {
// console.log(111)
// },
getChoiceValueStyle(col, colValue) { getChoiceValueStyle(col, colValue) {
const _find = col.filters.find((item) => String(item[0]) === String(colValue)) const _find = col.filters.find((item) => String(item[0]) === String(colValue))
if (_find) { if (_find) {
@ -885,10 +958,10 @@ export default {
const text = `q=_type:${this.typeId}${exp ? `,${exp}` : ''}${fuzzySearch ? `,*${fuzzySearch}*` : ''}` const text = `q=_type:${this.typeId}${exp ? `,${exp}` : ''}${fuzzySearch ? `,*${fuzzySearch}*` : ''}`
this.$copyText(text) this.$copyText(text)
.then(() => { .then(() => {
this.$message.success('复制成功!') this.$message.success(this.$t('copySuccess'))
}) })
.catch(() => { .catch(() => {
this.$message.error('复制失败!') this.$message.error(this.$t('cmdb.ci.copyFailed'))
}) })
}, },
unsubscribe(ciType, type = 'all') { unsubscribe(ciType, type = 'all') {
@ -898,7 +971,7 @@ export default {
if (Number(ciType) === Number(lastTypeId)) { if (Number(ciType) === Number(lastTypeId)) {
localStorage.setItem('ops_ci_typeid', '') localStorage.setItem('ops_ci_typeid', '')
} }
this.$message.success('取消订阅成功') this.$message.success(this.$t('cmdb.preference.cancelSubSuccess'))
this.resetRoute() this.resetRoute()
this.$router.push('/cmdb/preference') this.$router.push('/cmdb/preference')
}) })
@ -929,7 +1002,7 @@ export default {
}) })
}) })
} else { } else {
this.$message.error('权限不足!') this.$message.error(this.$t('noPermission'))
} }
}) })
}, },

View File

@ -1,6 +1,6 @@
<template> <template>
<a-drawer <a-drawer
title="批量添加关系" :title="$t('cmdb.ci.batchAddRelation')"
width="50%" width="50%"
@close="() => { visible = false; $emit('refresh', true) }" @close="() => { visible = false; $emit('refresh', true) }"
:visible="visible" :visible="visible"

View File

@ -16,10 +16,10 @@
> >
<a-tabs v-model="activeTabKey" @change="changeTab"> <a-tabs v-model="activeTabKey" @change="changeTab">
<a-tab-pane key="tab_1"> <a-tab-pane key="tab_1">
<span slot="tab"><a-icon type="book" />属性</span> <span slot="tab"><a-icon type="book" />{{ $t('cmdb.attribute') }}</span>
<div :style="{ maxHeight: `${windowHeight - 44}px`, overflow: 'auto', padding: '24px' }" class="ci-detail-attr"> <div :style="{ maxHeight: `${windowHeight - 44}px`, overflow: 'auto', padding: '24px' }" class="ci-detail-attr">
<el-descriptions <el-descriptions
:title="group.name || '其他'" :title="group.name || $t('other')"
:key="group.name" :key="group.name"
v-for="group in attributeGroups" v-for="group in attributeGroups"
border border
@ -36,13 +36,13 @@
</div> </div>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="tab_2"> <a-tab-pane key="tab_2">
<span slot="tab"><a-icon type="branches" />关系</span> <span slot="tab"><a-icon type="branches" />{{ $t('cmdb.relation') }}</span>
<div :style="{ padding: '24px' }"> <div :style="{ padding: '24px' }">
<CiDetailRelation ref="ciDetailRelation" :ciId="ciId" :typeId="typeId" :ci="ci" /> <CiDetailRelation ref="ciDetailRelation" :ciId="ciId" :typeId="typeId" :ci="ci" />
</div> </div>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="tab_3"> <a-tab-pane key="tab_3">
<span slot="tab"><a-icon type="clock-circle" />操作历史</span> <span slot="tab"><a-icon type="clock-circle" />{{ $t('cmdb.ci.history') }}</span>
<div :style="{ padding: '24px', height: 'calc(100vh - 44px)' }"> <div :style="{ padding: '24px', height: 'calc(100vh - 44px)' }">
<vxe-table <vxe-table
ref="xTable" ref="xTable"
@ -54,22 +54,22 @@
:scroll-y="{ enabled: false }" :scroll-y="{ enabled: false }"
class="ops-stripe-table" class="ops-stripe-table"
> >
<vxe-table-column sortable field="created_at" title="时间"></vxe-table-column> <vxe-table-column sortable field="created_at" :title="$t('created_at')"></vxe-table-column>
<vxe-table-column <vxe-table-column
field="username" field="username"
title="用户" :title="$t('user')"
:filters="[]" :filters="[]"
:filter-method="filterUsernameMethod" :filter-method="filterUsernameMethod"
></vxe-table-column> ></vxe-table-column>
<vxe-table-column <vxe-table-column
field="operate_type" field="operate_type"
:filters="[ :filters="[
{ value: 0, label: '新增' }, { value: 0, label: $t('new') },
{ value: 1, label: '删除' }, { value: 1, label: $t('delete') },
{ value: 3, label: '修改' }, { value: 3, label: $t('update') },
]" ]"
:filter-method="filterOperateMethod" :filter-method="filterOperateMethod"
title="操作" :title="$t('operation')"
> >
<template #default="{ row }"> <template #default="{ row }">
{{ operateTypeMap[row.operate_type] }} {{ operateTypeMap[row.operate_type] }}
@ -77,17 +77,17 @@
</vxe-table-column> </vxe-table-column>
<vxe-table-column <vxe-table-column
field="attr_alias" field="attr_alias"
title="属性" :title="$t('cmdb.attribute')"
:filters="[]" :filters="[]"
:filter-method="filterAttrMethod" :filter-method="filterAttrMethod"
></vxe-table-column> ></vxe-table-column>
<vxe-table-column field="old" title=""></vxe-table-column> <vxe-table-column field="old" :title="$t('cmdb.history.old')"></vxe-table-column>
<vxe-table-column field="new" title=""></vxe-table-column> <vxe-table-column field="new" :title="$t('cmdb.history.new')"></vxe-table-column>
</vxe-table> </vxe-table>
</div> </div>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="tab_4"> <a-tab-pane key="tab_4">
<span slot="tab"><ops-icon type="itsm_auto_trigger" />触发历史</span> <span slot="tab"><ops-icon type="itsm_auto_trigger" />{{ $t('cmdb.history.triggerHistory') }}</span>
<div :style="{ padding: '24px', height: 'calc(100vh - 44px)' }"> <div :style="{ padding: '24px', height: 'calc(100vh - 44px)' }">
<TriggerTable :ci_id="ci._id" /> <TriggerTable :ci_id="ci._id" />
</div> </div>
@ -125,13 +125,7 @@ export default {
}, },
}, },
data() { data() {
const operateTypeMap = {
0: '新增',
1: '删除',
2: '修改',
}
return { return {
operateTypeMap,
visible: false, visible: false,
ci: {}, ci: {},
attributeGroups: [], attributeGroups: [],
@ -146,6 +140,14 @@ export default {
windowHeight() { windowHeight() {
return this.$store.state.windowHeight return this.$store.state.windowHeight
}, },
operateTypeMap() {
return {
0: this.$t('new'),
1: this.$t('delete'),
2: this.$t('update'),
}
},
}, },
provide() { provide() {
return { return {

View File

@ -10,8 +10,8 @@
:headerStyle="{ borderBottom: 'none' }" :headerStyle="{ borderBottom: 'none' }"
> >
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button @click="handleClose">取消</a-button> <a-button @click="handleClose">{{ $t('cancel') }}</a-button>
<a-button type="primary" @click="createInstance">提交</a-button> <a-button type="primary" @click="createInstance">{{ $t('submit') }}</a-button>
</div> </div>
<template v-if="action === 'create'"> <template v-if="action === 'create'">
<template v-for="group in attributesByGroup"> <template v-for="group in attributesByGroup">
@ -24,7 +24,7 @@
/> />
</template> </template>
<template v-if="parentsType && parentsType.length"> <template v-if="parentsType && parentsType.length">
<a-divider style="font-size:14px;margin:14px 0;font-weight:700;">模型关系</a-divider> <a-divider style="font-size:14px;margin:14px 0;font-weight:700;">{{ $t('cmdb.menu.citypeRelation') }}</a-divider>
<a-form> <a-form>
<a-row :gutter="24" align="top" type="flex"> <a-row :gutter="24" align="top" type="flex">
<a-col :span="12" v-for="item in parentsType" :key="item.id"> <a-col :span="12" v-for="item in parentsType" :key="item.id">
@ -40,7 +40,7 @@
{{ attr.alias || attr.name }} {{ attr.alias || attr.name }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<a-input placeholder="多个值使用,分割" v-model="parentsForm[item.name].value" style="width: 50%" /> <a-input :placeholder="$t('cmdb.ci.tips1')" v-model="parentsForm[item.name].value" style="width: 50%" />
</a-input-group> </a-input-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -50,11 +50,11 @@
</template> </template>
<template v-if="action === 'update'"> <template v-if="action === 'update'">
<a-form :form="form"> <a-form :form="form">
<p>可根据需要修改字段当值为<strong></strong>则该字段<strong>置空</strong></p> <p>{{ $t('cmdb.ci.tips2') }}</p>
<a-row :gutter="24" v-for="list in batchUpdateLists" :key="list.name"> <a-row :gutter="24" v-for="list in batchUpdateLists" :key="list.name">
<a-col :span="11"> <a-col :span="11">
<a-form-item> <a-form-item>
<el-select showSearch size="small" filterable v-model="list.name" placeholder="请选择需要修改的字段"> <el-select showSearch size="small" filterable v-model="list.name" :placeholder="$t('cmdb.ci.tips3')">
<el-option <el-option
v-for="attr in attributeList" v-for="attr in attributeList"
:key="attr.name" :key="attr.name"
@ -71,7 +71,7 @@
<a-select <a-select
:style="{ width: '100%' }" :style="{ width: '100%' }"
v-decorator="[list.name, { rules: [{ required: false }] }]" v-decorator="[list.name, { rules: [{ required: false }] }]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-if="getFieldType(list.name).split('%%')[0] === 'select'" v-if="getFieldType(list.name).split('%%')[0] === 'select'"
:mode="getFieldType(list.name).split('%%')[1] === 'multiple' ? 'multiple' : 'default'" :mode="getFieldType(list.name).split('%%')[1] === 'multiple' ? 'multiple' : 'default'"
showSearch showSearch
@ -119,7 +119,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-button type="primary" ghost icon="plus" @click="handleAdd">新增修改字段</a-button> <a-button type="primary" ghost icon="plus" @click="handleAdd">{{ $t('cmdb.ci.newUpdateField') }}</a-button>
</a-form> </a-form>
</template> </template>
<JsonEditor ref="jsonEditor" @jsonEditorOk="jsonEditorOk" /> <JsonEditor ref="jsonEditor" @jsonEditorOk="jsonEditorOk" />
@ -153,7 +153,6 @@ export default {
}, },
data() { data() {
return { return {
valueTypeMap,
action: '', action: '',
form: this.$form.createForm(this), form: this.$form.createForm(this),
visible: false, visible: false,
@ -171,7 +170,7 @@ export default {
}, },
computed: { computed: {
title() { title() {
return this.action === 'create' ? '创建 ' : '批量修改 ' return this.action === 'create' ? this.$t('create') + ' ' : this.$t('cmdb.ci.batchUpdate') + ' '
}, },
typeId() { typeId() {
if (this.typeIdFromRelation) { if (this.typeIdFromRelation) {
@ -179,6 +178,9 @@ export default {
} }
return this.$router.currentRoute.meta.typeId return this.$router.currentRoute.meta.typeId
}, },
valueTypeMap() {
return valueTypeMap()
},
}, },
provide() { provide() {
return { return {
@ -210,7 +212,7 @@ export default {
(attr) => !attrHasGroupIds.includes(attr.id) && !attr.is_computed (attr) => !attrHasGroupIds.includes(attr.id) && !attr.is_computed
) )
if (otherGroupAttr.length) { if (otherGroupAttr.length) {
_attributesByGroup.push({ id: -1, name: '其他', attributes: otherGroupAttr }) _attributesByGroup.push({ id: -1, name: this.$t('other'), attributes: otherGroupAttr })
} }
this.attributesByGroup = _attributesByGroup this.attributesByGroup = _attributesByGroup
}) })
@ -283,7 +285,7 @@ export default {
} }
}) })
addCI(values).then((res) => { addCI(values).then((res) => {
_this.$message.success('新增成功!') _this.$message.success(this.$t('addSuccess'))
_this.visible = false _this.visible = false
_this.$emit('reload', { ci_id: res.ci_id }) _this.$emit('reload', { ci_id: res.ci_id })
}) })
@ -332,7 +334,7 @@ export default {
} else if (_find.value_type === '0' || _find.value_type === '1') { } else if (_find.value_type === '0' || _find.value_type === '1') {
return 'input_number' return 'input_number'
} else if (_find.value_type === '4' || _find.value_type === '3') { } else if (_find.value_type === '4' || _find.value_type === '3') {
return valueTypeMap[_find.value_type] return this.valueTypeMap[_find.value_type]
} else { } else {
return 'input' return 'input'
} }

View File

@ -7,7 +7,7 @@
visible = false visible = false
} }
" "
title="属性说明" :title="$t('cmdb.ci.attributeDesc')"
width="72%" width="72%"
:bodyStyle="{ height: '100vh' }" :bodyStyle="{ height: '100vh' }"
> >
@ -18,7 +18,7 @@
:style="{ display: 'inline-block', width: '244px' }" :style="{ display: 'inline-block', width: '244px' }"
class="ops-input ops-input-radius" class="ops-input ops-input-radius"
type="search" type="search"
placeholder="搜索 名称 | 别名" :placeholder="$t('cmdb.ci.tips5')"
@keyup="searchAttributes" @keyup="searchAttributes"
> >
<a-icon type="search" slot="suffix" /> <a-icon type="search" slot="suffix" />
@ -56,8 +56,8 @@
: index === 2 : index === 2
? valueTypeFilters ? valueTypeFilters
: [ : [
{ label: '', value: true }, { label: $t('yes'), value: true },
{ label: '', value: false }, { label: $t('no'), value: false },
] ]
" "
type="html" type="html"
@ -82,78 +82,11 @@ import { valueTypeMap } from '@/modules/cmdb/utils/const'
export default { export default {
name: 'MetadataDrawer', name: 'MetadataDrawer',
data() { data() {
const columns = [
{
field: 'name',
title: '名称',
width: 150,
align: 'left',
help: null,
},
{
field: 'alias',
title: '别名',
width: 150,
align: 'left',
help: null,
},
{
field: 'value_type',
title: '类型',
width: 100,
align: 'left',
help: null,
},
{
field: 'is_index',
title: '是否索引',
width: 110,
help: '加快检索, 可以全文搜索, 无需使用条件过滤\n\n json目前不支持建索引 \n\n文本字符长度超过190不能建索引',
},
{
field: 'default_show',
title: '默认显示',
width: 110,
help: '订阅CI默认显示在table里的属性',
},
{
field: 'is_unique',
title: '是否唯一',
width: 110,
help: null,
},
{
field: 'is_choice',
title: '是否选择',
width: 110,
help: '表现形式是下拉框, 值必须在预定义值里',
},
{
field: 'is_list',
title: '是否列表',
width: 110,
help: '多值, 比如内网IP',
},
{
field: 'is_sortable',
title: '可排序',
width: 100,
help: '仅针对前端',
},
{
field: 'is_computed',
title: '计算属性',
width: 110,
help: '模型的其他属性通过表达式的方式计算出来\n\n一个代码片段计算返回的值',
},
]
return { return {
columns,
visible: false, visible: false,
list: [], list: [],
tableData: [], tableData: [],
loading: false, loading: false,
valueTypeMap,
valueTypeFilters: [], valueTypeFilters: [],
searchKey: '', searchKey: '',
} }
@ -162,6 +95,76 @@ export default {
windowHeight() { windowHeight() {
return this.$store.state.windowHeight return this.$store.state.windowHeight
}, },
valueTypeMap() {
return valueTypeMap()
},
columns() {
return [
{
field: 'name',
title: this.$t('name'),
width: 150,
align: 'left',
help: null,
},
{
field: 'alias',
title: this.$t('alias'),
width: 150,
align: 'left',
help: null,
},
{
field: 'value_type',
title: this.$t('type'),
width: 100,
align: 'left',
help: null,
},
{
field: 'is_index',
title: this.$t('cmdb.ciType.isIndex'),
width: 110,
help: this.$t('cmdb.ci.tips6'),
},
{
field: 'default_show',
title: this.$t('cmdb.ciType.defaultShow'),
width: 110,
help: this.$t('cmdb.ciType.defaultShowTips'),
},
{
field: 'is_unique',
title: this.$t('cmdb.ciType.isUnique'),
width: 110,
help: null,
},
{
field: 'is_choice',
title: this.$t('cmdb.ciType.isChoice'),
width: 110,
help: this.$t('cmdb.ci.tips7'),
},
{
field: 'is_list',
title: this.$t('cmdb.ciType.list'),
width: 110,
help: this.$t('cmdb.ci.tips8'),
},
{
field: 'is_sortable',
title: this.$t('cmdb.ciType.isSortable'),
width: 100,
help: this.$t('cmdb.ci.tips9'),
},
{
field: 'is_computed',
title: this.$t('cmdb.ciType.computedAttribute'),
width: 110,
help: this.$t('cmdb.ci.tips10'),
},
]
},
}, },
created: function() { created: function() {
this.valueTypeFilters = Object.keys(this.valueTypeMap).map((key) => { this.valueTypeFilters = Object.keys(this.valueTypeMap).map((key) => {

View File

@ -75,7 +75,7 @@
rules: [{ required: attr.is_required }], rules: [{ required: attr.is_required }],
}, },
]" ]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-if="attr.is_choice" v-if="attr.is_choice"
:mode="attr.is_list ? 'multiple' : 'default'" :mode="attr.is_list ? 'multiple' : 'default'"
showSearch showSearch
@ -113,7 +113,7 @@
rules: [{ required: attr.is_required }], rules: [{ required: attr.is_required }],
}, },
]" ]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-else-if="attr.is_list" v-else-if="attr.is_list"
mode="tags" mode="tags"
showSearch showSearch
@ -263,7 +263,7 @@ export default {
if (!_.isEqual(this.ci[this.attr.name], newData)) { if (!_.isEqual(this.ci[this.attr.name], newData)) {
await updateCI(this.ci._id, { [`${this.attr.name}`]: newData }) await updateCI(this.ci._id, { [`${this.attr.name}`]: newData })
.then(() => { .then(() => {
this.$message.success('更新成功!') this.$message.success(this.$t('updateSuccess'))
this.$emit('updateCIByself', { [`${this.attr.name}`]: newData }, this.attr.name) this.$emit('updateCIByself', { [`${this.attr.name}`]: newData }, this.attr.name)
}) })
.catch(() => { .catch(() => {
@ -286,7 +286,7 @@ export default {
if (!_.isEqual(this.ci[this.attr.name], jsonData)) { if (!_.isEqual(this.ci[this.attr.name], jsonData)) {
updateCI(this.ci._id, { [`${this.attr.name}`]: jsonData }) updateCI(this.ci._id, { [`${this.attr.name}`]: jsonData })
.then(() => { .then(() => {
this.$message.success('更新成功!') this.$message.success(this.$t('updateSuccess'))
this.$emit('updateCIByself', { [`${this.attr.name}`]: jsonData }, this.attr.name) this.$emit('updateCIByself', { [`${this.attr.name}`]: jsonData }, this.attr.name)
}) })
.catch(() => { .catch(() => {

View File

@ -2,10 +2,10 @@
<div class="ci-detail-relation"> <div class="ci-detail-relation">
<a-radio-group v-model="activeKey" size="small" @change="handleChangeActiveKey"> <a-radio-group v-model="activeKey" size="small" @change="handleChangeActiveKey">
<a-radio-button value="1"> <a-radio-button value="1">
拓扑 {{ $t('cmdb.ci.topo') }}
</a-radio-button> </a-radio-button>
<a-radio-button value="2"> <a-radio-button value="2">
表格 {{ $t('cmdb.ci.table') }}
</a-radio-button> </a-radio-button>
</a-radio-group> </a-radio-group>
<CiDetailRelationTopo ref="ciDetailRelationTopo" v-if="activeKey === '1'" /> <CiDetailRelationTopo ref="ciDetailRelationTopo" v-if="activeKey === '1'" />
@ -24,7 +24,7 @@
><a-icon ><a-icon
type="plus-square" type="plus-square"
/></a> /></a>
<span v-if="!canEdit[parent.id]">当前模型关系为多对多请前往关系视图进行增删操作</span> <span v-if="!canEdit[parent.id]">{{ $t('cmdb.ci.m2mTips') }}</span>
</div> </div>
<vxe-grid <vxe-grid
v-if="firstCIs[parent.name]" v-if="firstCIs[parent.name]"
@ -39,7 +39,7 @@
class="ops-stripe-table" class="ops-stripe-table"
> >
<template #operation_default="{ row }"> <template #operation_default="{ row }">
<a-popconfirm arrowPointAtCenter title="确认删除关系?" @confirm="deleteRelation(row._id, ciId)"> <a-popconfirm arrowPointAtCenter :title="$t('cmdb.ci.confirmDeleteRelation')" @confirm="deleteRelation(row._id, ciId)">
<a <a
:disabled="!canEdit[parent.id]" :disabled="!canEdit[parent.id]"
:style="{ :style="{
@ -68,7 +68,7 @@
><a-icon ><a-icon
type="plus-square" type="plus-square"
/></a> /></a>
<span v-if="!canEdit[child.id]">当前模型关系为多对多请前往关系视图进行增删操作</span> <span v-if="!canEdit[child.id]">{{ $t('cmdb.ci.m2mTips') }}</span>
</div> </div>
<vxe-grid <vxe-grid
v-if="secondCIs[child.name]" v-if="secondCIs[child.name]"
@ -82,7 +82,7 @@
class="ops-stripe-table" class="ops-stripe-table"
> >
<template #operation_default="{ row }"> <template #operation_default="{ row }">
<a-popconfirm arrowPointAtCenter title="确认删除关系?" @confirm="deleteRelation(ciId, row._id)"> <a-popconfirm arrowPointAtCenter :title="$t('cmdb.ci.confirmDeleteRelation')" @confirm="deleteRelation(ciId, row._id)">
<a <a
:disabled="!canEdit[child.id]" :disabled="!canEdit[child.id]"
:style="{ :style="{
@ -338,7 +338,7 @@ export default {
firstCIColumns[item.id].push({ firstCIColumns[item.id].push({
key: 'p_operation', key: 'p_operation',
field: 'operation', field: 'operation',
title: '操作', title: this.$t('operation'),
width: '60px', width: '60px',
fixed: 'right', fixed: 'right',
slots: { slots: {
@ -379,7 +379,7 @@ export default {
secondCIColumns[item.id].push({ secondCIColumns[item.id].push({
key: 'c_operation', key: 'c_operation',
field: 'operation', field: 'operation',
title: '操作', title: this.$t('operation'),
width: '60px', width: '60px',
fixed: 'right', fixed: 'right',
slots: { slots: {

View File

@ -91,7 +91,7 @@ export default {
const newNodes = [] const newNodes = []
const newEdges = [] const newEdges = []
if (!res.result.length) { if (!res.result.length) {
this.$message.info('无层级关系!') this.$message.info(this.$t('cmdb.ci.noLevel'))
return return
} }
const ci_types_list = this.ci_types() const ci_types_list = this.ci_types()

View File

@ -1,5 +1,6 @@
/* eslint-disable no-useless-constructor */ /* eslint-disable no-useless-constructor */
import { TreeNode } from 'butterfly-dag' import { TreeNode } from 'butterfly-dag'
import i18n from '@/lang'
import $ from 'jquery' import $ from 'jquery'
@ -31,7 +32,7 @@ class BaseNode extends TreeNode {
container.append(uniqueDom) container.append(uniqueDom)
if (opts.options.side && (!opts.options.children.length && !(opts.options.edges && opts.options.edges.length && opts.options.edges.find(e => e.source === opts.options.side && e.sourceNode === opts.options.id)))) { if (opts.options.side && (!opts.options.children.length && !(opts.options.edges && opts.options.edges.length && opts.options.edges.find(e => e.source === opts.options.side && e.sourceNode === opts.options.id)))) {
const addIcon = $(`<i aria-label="图标: plus-square" class="anticon anticon-plus-square add-icon-${opts.options.side}"><svg viewBox="64 64 896 896" data-icon="plus-square" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><path d="M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"></path><path d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"></path></svg></i>`) const addIcon = $(`<i aria-label="${i18n.t('icon')}: plus-square" class="anticon anticon-plus-square add-icon-${opts.options.side}"><svg viewBox="64 64 896 896" data-icon="plus-square" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false" class=""><path d="M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"></path><path d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"></path></svg></i>`)
container.append(addIcon) container.append(addIcon)
addIcon.on('click', () => { addIcon.on('click', () => {
if (opts.options.side === 'left') { if (opts.options.side === 'left') {

View File

@ -1,6 +1,6 @@
<template> <template>
<a-form :form="form"> <a-form :form="form">
<a-divider style="font-size: 14px; margin: 14px 0; font-weight: 700">{{ group.name || '其他' }}</a-divider> <a-divider style="font-size:14px;margin:14px 0;font-weight:700;">{{ group.name || $t('other') }}</a-divider>
<a-row :gutter="24" align="top" type="flex"> <a-row :gutter="24" align="top" type="flex">
<a-col <a-col
:span="12" :span="12"
@ -21,11 +21,11 @@
v-decorator="[ v-decorator="[
attr.name, attr.name,
{ {
rules: [{ required: attr.is_required, message: `请选择${attr.alias || attr.name}` }], rules: [{ required: attr.is_required, message: $t('placeholder2') + `${attr.alias || attr.name}` }],
initialValue: attr.default && attr.default.default ? attr.default.default : attr.is_list ? [] : null, initialValue: attr.default && attr.default.default ? attr.default.default : attr.is_list ? [] : null,
}, },
]" ]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-if="attr.is_choice" v-if="attr.is_choice"
:mode="attr.is_list ? 'multiple' : 'default'" :mode="attr.is_list ? 'multiple' : 'default'"
showSearch showSearch
@ -60,7 +60,7 @@
v-decorator="[ v-decorator="[
attr.name, attr.name,
{ {
rules: [{ required: attr.is_required, message: `请选择${attr.alias || attr.name}` }], rules: [{ required: attr.is_required, message: $t('placeholder2') + `${attr.alias || attr.name}` }],
initialValue: attr.default && attr.default.default ? attr.default.default : attr.is_list ? [] : null, initialValue: attr.default && attr.default.default ? attr.default.default : attr.is_list ? [] : null,
}, },
]" ]"
@ -70,7 +70,7 @@
v-decorator="[ v-decorator="[
attr.name, attr.name,
{ {
rules: [{ required: attr.is_required, message: `请输入${attr.alias || attr.name}` }], rules: [{ required: attr.is_required, message: $t('placeholder1') + `${attr.alias || attr.name}` }],
initialValue: attr.default && attr.default.default ? attr.default.default : null, initialValue: attr.default && attr.default.default ? attr.default.default : null,
}, },
]" ]"
@ -81,7 +81,7 @@
v-decorator="[ v-decorator="[
attr.name, attr.name,
{ {
rules: [{ required: attr.is_required, message: `请选择${attr.alias || attr.name}` }], rules: [{ required: attr.is_required, message: $t('placeholder2') + `${attr.alias || attr.name}` }],
initialValue: attr.default && attr.default.default ? moment(attr.default.default) : null, initialValue: attr.default && attr.default.default ? moment(attr.default.default) : null,
}, },
]" ]"
@ -96,7 +96,7 @@
attr.name, attr.name,
{ {
validateTrigger: ['submit'], validateTrigger: ['submit'],
rules: [{ required: attr.is_required, message: `请输入${attr.alias || attr.name}` }], rules: [{ required: attr.is_required, message: $t('placeholder1') + `${attr.alias || attr.name}` }],
initialValue: attr.default && attr.default.default ? JSON.stringify(attr.default.default) : '', initialValue: attr.default && attr.default.default ? JSON.stringify(attr.default.default) : '',
}, },
]" ]"
@ -109,7 +109,7 @@
attr.name, attr.name,
{ {
validateTrigger: ['submit'], validateTrigger: ['submit'],
rules: [{ required: attr.is_required, message: `请输入${attr.alias || attr.name}` }], rules: [{ required: attr.is_required, message: $t('placeholder1') + `${attr.alias || attr.name}` }],
initialValue: attr.default && attr.default.default ? attr.default.default : null, initialValue: attr.default && attr.default.default ? attr.default.default : null,
}, },
]" ]"

View File

@ -7,7 +7,7 @@
visible = false visible = false
} }
" "
title="字段设置" :title="$t('cmdb.ci.attributeSettings')"
> >
<CustomTransfer <CustomTransfer
ref="customTransfer" ref="customTransfer"
@ -17,16 +17,16 @@
width: '230px', width: '230px',
height: '500px', height: '500px',
}" }"
:titles="['未选属性', '已选属性']" :titles="[$t('cmdb.components.unselectAttributes'), $t('cmdb.components.selectAttributes')]"
:render="item => item.title" :render="item => item.title"
:targetKeys="selectedAttrList" :targetKeys="selectedAttrList"
@change="handleChange" @change="handleChange"
@selectChange="selectChange" @selectChange="selectChange"
> >
<span slot="notFoundContent">没数据</span> <span slot="notFoundContent">{{ $t('noData') }}</span>
</CustomTransfer> </CustomTransfer>
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button @click="handleSubmit" type="primary">确定</a-button> <a-button @click="handleSubmit" type="primary">{{ $t('confirm') }}</a-button>
</div> </div>
</CustomDrawer> </CustomDrawer>
</template> </template>
@ -79,16 +79,17 @@ export default {
this.selectedAttrList = targetKeys this.selectedAttrList = targetKeys
}, },
handleSubmit() { handleSubmit() {
const that = this
if (this.selectedAttrList.length) { if (this.selectedAttrList.length) {
subscribeCIType(this.typeId, this.selectedAttrList).then(res => { subscribeCIType(this.typeId, this.selectedAttrList).then(res => {
this.$message.success('订阅成功!') this.$message.success(this.$t('cmdb.components.subSuccess'))
this.visible = false this.visible = false
this.$emit('refresh') this.$emit('refresh')
}) })
} else { } else {
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '必须至少选择一个字段', content: that.$t('cmdb.ci.tips4'),
}) })
} }
}, },

View File

@ -75,12 +75,12 @@ export default {
return [item, !!this.fixedList.includes(item)] return [item, !!this.fixedList.includes(item)]
}) })
).then((res) => { ).then((res) => {
this.$message.success('订阅成功!') this.$message.success(this.$t('cmdb.components.subSuccess'))
this.visible = false this.visible = false
this.$emit('refresh') this.$emit('refresh')
}) })
} else { } else {
this.$message.error('请至少选择一个字段!') this.$message.error(this.$t('cmdb.ci.tips4'))
} }
}, },
setTargetKeys(targetKeys) { setTargetKeys(targetKeys) {

View File

@ -3,9 +3,9 @@
<Discovery :isSelected="true" :style="{ maxHeight: '75vh', overflow: 'auto' }" /> <Discovery :isSelected="true" :style="{ maxHeight: '75vh', overflow: 'auto' }" />
<template #footer> <template #footer>
<a-space> <a-space>
<a-button @click="handleCancel">取消</a-button> <a-button @click="handleCancel">{{ $t('cancel') }}</a-button>
<a-button type="primary" @click="handleOK">确认</a-button> <a-button type="primary" @click="handleOK">{{ $t('confirm') }}</a-button>
<a-button type="primary" @click="addPlugin">新建plugin</a-button> <a-button type="primary" @click="addPlugin">{{ $t('cmdb.ciType.addPlugin') }}</a-button>
</a-space> </a-space>
</template> </template>
</a-modal> </a-modal>
@ -55,7 +55,7 @@ export default {
await Promise.all(promises) await Promise.all(promises)
.then((res) => { .then((res) => {
this.getCITypeDiscovery(res[0].id) this.getCITypeDiscovery(res[0].id)
this.$message.success('添加成功') this.$message.success(this.$t('addSuccess'))
}) })
.catch(() => { .catch(() => {
this.getCITypeDiscovery() this.getCITypeDiscovery()

View File

@ -29,7 +29,7 @@
slot="tabBarExtraContent" slot="tabBarExtraContent"
:style="{ cursor: 'pointer' }" :style="{ cursor: 'pointer' }"
> >
<ops-icon type="icon-xianxing-tianjia" :style="{ color: '#2F54EB' }" /><a>添加</a> <ops-icon type="icon-xianxing-tianjia" :style="{ color: '#2F54EB' }" /><a>{{ $t('add') }}</a>
</a-space> </a-space>
</a-tabs> </a-tabs>
</div> </div>
@ -40,7 +40,7 @@
}" }"
> >
<img slot="image" :src="require('@/assets/data_empty.png')" /> <img slot="image" :src="require('@/assets/data_empty.png')" />
<span slot="description"> 暂无数据 </span> <span slot="description"> {{ $t('noData') }} </span>
<a-button <a-button
@click=" @click="
() => { () => {
@ -52,7 +52,7 @@
icon="plus" icon="plus"
class="ops-button-primary" class="ops-button-primary"
> >
添加 {{ $t('add') }}
</a-button> </a-button>
</a-empty> </a-empty>
<ADModal ref="adModal" :CITypeId="CITypeId" @addPlugin="openEditDrawer(null, 'add', 'agent')" /> <ADModal ref="adModal" :CITypeId="CITypeId" @addPlugin="openEditDrawer(null, 'add', 'agent')" />
@ -158,10 +158,10 @@ export default {
e.stopPropagation() e.stopPropagation()
const that = this const that = this
this.$confirm({ this.$confirm({
title: `确认删除 ${item?.extra_option?.alias || this.getADCITypeParam(item.adr_id)}`, title: that.$t('cmdb.ciType.confirmDeleteADT', { pluginName: `${item?.extra_option?.alias || this.getADCITypeParam(item.adr_id)}` }),
content: (h) => ( content: (h) => (
<div> <div>
<a-checkbox v-model={that.deletePlugin}>删除插件</a-checkbox> <a-checkbox v-model={that.deletePlugin}>{that.$t('cmdb.ciType.deletePlugin')}</a-checkbox>
</div> </div>
), ),
onOk() { onOk() {
@ -169,7 +169,7 @@ export default {
if (that.currentTab === item.id) { if (that.currentTab === item.id) {
that.currentTab = '' that.currentTab = ''
} }
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.getCITypeDiscovery() that.getCITypeDiscovery()
if (that.deletePlugin) { if (that.deletePlugin) {
await deleteDiscovery(item.adr_id).finally(() => { await deleteDiscovery(item.adr_id).finally(() => {

View File

@ -11,11 +11,11 @@
> >
<a-space> <a-space>
<ops-icon type="icon-xianxing-edit" /> <ops-icon type="icon-xianxing-edit" />
<span>编辑</span> <span>{{ $t('edit') }}</span>
</a-space> </a-space>
</a> </a>
<div>别名<a-input v-model="alias" style="width:200px;" /></div> <div>{{ $t('alias') }}<a-input v-model="alias" style="width:200px;" /></div>
<div class="attr-ad-header">字段映射</div> <div class="attr-ad-header">{{ $t('cmdb.ciType.attributeMap') }}</div>
<vxe-table <vxe-table
v-if="adrType === 'agent'" v-if="adrType === 'agent'"
ref="xTable" ref="xTable"
@ -26,13 +26,13 @@
:data="tableData" :data="tableData"
:style="{ width: '700px', marginBottom: '20px' }" :style="{ width: '700px', marginBottom: '20px' }"
> >
<vxe-colgroup title="自动发现"> <vxe-colgroup :title="$t('cmdb.ciType.autoDiscovery')">
<vxe-column field="name" title="名称"> </vxe-column> <vxe-column field="name" :title="$t('name')"> </vxe-column>
<vxe-column field="type" title="类型"> </vxe-column> <vxe-column field="type" :title="$t('type')"> </vxe-column>
<vxe-column field="desc" title="描述"> </vxe-column> <vxe-column field="desc" :title="$t('desc')"> </vxe-column>
</vxe-colgroup> </vxe-colgroup>
<vxe-colgroup title="模型属性"> <vxe-colgroup :title="$t('cmdb.ciType.attributes')">
<vxe-column field="attr" title="名称" :edit-render="{}"> <vxe-column field="attr" :title="$t('name')" :edit-render="{}">
<template #default="{row}"> <template #default="{row}">
{{ row.attr }} {{ row.attr }}
</template> </template>
@ -76,18 +76,18 @@
</a-form-model> </a-form-model>
<a-form :form="form3" v-if="adrType === 'snmp'" class="attr-ad-snmp-form"> <a-form :form="form3" v-if="adrType === 'snmp'" class="attr-ad-snmp-form">
<a-col :span="24"> <a-col :span="24">
<a-form-item label="节点" :labelCol="{ span: 2 }" :wrapperCol="{ span: 20 }"> <a-form-item :label="$t('cmdb.ciType.node')" :labelCol="{ span: 2 }" :wrapperCol="{ span: 20 }">
<MonitorNodeSetting ref="monitorNodeSetting" :initNodes="nodes" :form="form3" /> <MonitorNodeSetting ref="monitorNodeSetting" :initNodes="nodes" :form="form3" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-form> </a-form>
<div class="attr-ad-header">执行配置</div> <div class="attr-ad-header">{{ $t('cmdb.ciType.adExecConfig') }}</div>
<a-form-model :model="form" :labelCol="{ span: 2 }" :wrapperCol="{ span: 20 }"> <a-form-model :model="form" :labelCol="{ span: 2 }" :wrapperCol="{ span: 20 }">
<a-form-model-item label="执行机器"> <a-form-model-item :label="$t('cmdb.ciType.adExecTarget')">
<CustomRadio v-model="agent_type" :radioList="agentTypeRadioList"> <CustomRadio v-model="agent_type" :radioList="agentTypeRadioList">
<a-input <a-input
:style="{ width: '300px' }" :style="{ width: '300px' }"
placeholder="请输入以0x开头的16进制OneAgent ID" :placeholder="$t('cmdb.ciType.oneagentIdTips')"
v-show="agent_type === 'agent_id'" v-show="agent_type === 'agent_id'"
slot="extra_agent_id" slot="extra_agent_id"
v-model="form.agent_id" v-model="form.agent_id"
@ -96,26 +96,26 @@
:style="{ width: '300px' }" :style="{ width: '300px' }"
v-show="agent_type === 'query_expr'" v-show="agent_type === 'query_expr'"
slot="extra_query_expr" slot="extra_query_expr"
placeholder="从CMDB选择" :placeholder="$t('cmdb.ciType.selectFromCMDBTips')"
v-model="form.query_expr" v-model="form.query_expr"
> >
<a @click="handleOpenCmdb" slot="suffix"><a-icon type="menu"/></a> <a @click="handleOpenCmdb" slot="suffix"><a-icon type="menu"/></a>
</a-input> </a-input>
</CustomRadio> </CustomRadio>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="自动入库"> <a-form-model-item :label="$t('cmdb.ciType.adAutoInLib')">
<a-switch v-model="form.auto_accept" /> <a-switch v-model="form.auto_accept" />
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
<div class="attr-ad-header">采集频率</div> <div class="attr-ad-header">{{ $t('cmdb.ciType.adInterval') }}</div>
<CustomRadio :radioList="radioList" v-model="interval"> <CustomRadio :radioList="radioList" v-model="interval">
<span v-show="interval === 'interval'" slot="extra_interval"> <span v-show="interval === 'interval'" slot="extra_interval">
<a-input-number v-model="intervalValue" :min="1" /> <a-input-number v-model="intervalValue" :min="1" /> {{ $t('seconds') }}
</span> </span>
</CustomRadio> </CustomRadio>
<div class="attr-ad-footer"> <div class="attr-ad-footer">
<a-button type="primary" @click="handleSave">保存</a-button> <a-button type="primary" @click="handleSave">{{ $t('save') }}</a-button>
</div> </div>
<CMDBExprDrawer ref="cmdbDrawer" @copySuccess="copySuccess" /> <CMDBExprDrawer ref="cmdbDrawer" @copySuccess="copySuccess" />
</div> </div>
@ -160,11 +160,7 @@ export default {
}, },
}, },
data() { data() {
const radioList = [
{ value: 'interval', label: '按间隔' },
]
return { return {
radioList,
tableData: [], tableData: [],
form: { form: {
agent_id: '', agent_id: '',
@ -209,14 +205,20 @@ export default {
const { permissions = [] } = this.userRoles const { permissions = [] } = this.userRoles
if ((permissions.includes('cmdb_admin') || permissions.includes('admin')) && this.adrType !== 'http') { if ((permissions.includes('cmdb_admin') || permissions.includes('admin')) && this.adrType !== 'http') {
return [ return [
{ value: 'all', label: '所有节点' }, { value: 'all', label: this.$t('cmdb.ciType.allNodes') },
{ value: 'agent_id', label: '指定节点' }, { value: 'agent_id', label: this.$t('cmdb.ciType.specifyNodes') },
{ value: 'query_expr', label: '从CMDB中选择 ' }, { value: 'query_expr', label: this.$t('cmdb.ciType.selectFromCMDBTips') },
] ]
} }
return [ return [
{ value: 'agent_id', label: '指定节点' }, { value: 'agent_id', label: this.$t('cmdb.ciType.specifyNodes') },
{ value: 'query_expr', label: '从CMDB中选择 ' }, { value: 'query_expr', label: this.$t('cmdb.ciType.selectFromCMDBTips') },
]
},
radioList() {
return [
{ value: 'interval', label: this.$t('cmdb.ciType.byInterval') },
// { value: 'cron', label: '按cron', layout: 'vertical' },
] ]
}, },
}, },
@ -352,14 +354,14 @@ export default {
if (this.agent_type === 'agent_id' || this.agent_type === 'all') { if (this.agent_type === 'agent_id' || this.agent_type === 'all') {
params.query_expr = '' params.query_expr = ''
if (this.agent_type === 'agent_id' && !params.agent_id) { if (this.agent_type === 'agent_id' && !params.agent_id) {
this.$message.error('请填写指定节点!') this.$message.error(this.$t('cmdb.ciType.specifyNodesTips'))
return return
} }
} }
if (this.agent_type === 'query_expr' || this.agent_type === 'all') { if (this.agent_type === 'query_expr' || this.agent_type === 'all') {
params.agent_id = '' params.agent_id = ''
if (this.agent_type === 'query_expr' && !params.query_expr) { if (this.agent_type === 'query_expr' && !params.query_expr) {
this.$message.error('请从cmdb中选择') this.$message.error(this.$t('cmdb.ciType.selectFromCMDBTips'))
return return
} }
} }
@ -370,7 +372,7 @@ export default {
params.extra_option.alias = alias params.extra_option.alias = alias
} }
putCITypeDiscovery(currentAdt.id, params).then((res) => { putCITypeDiscovery(currentAdt.id, params).then((res) => {
this.$message.success('保存成功') this.$message.success(this.$t('saveSuccess'))
this.$emit('handleSave') this.$emit('handleSave')
}) })
}, },

View File

@ -8,8 +8,8 @@
<div :class="{ 'attribute-card-name': true, 'attribute-card-name-default-show': property.default_show }"> <div :class="{ 'attribute-card-name': true, 'attribute-card-name-default-show': property.default_show }">
{{ property.alias || property.name }} {{ property.alias || property.name }}
</div> </div>
<div v-if="property.is_password" class="attribute-card_value-type">密码</div> <div v-if="property.is_password" class="attribute-card_value-type">{{ $t('cmdb.ciType.password') }}</div>
<div v-else-if="property.is_link" class="attribute-card_value-type">链接</div> <div v-else-if="property.is_link" class="attribute-card_value-type">{{ $t('cmdb.ciType.link') }}</div>
<div v-else class="attribute-card_value-type">{{ valueTypeMap[property.value_type] }}</div> <div v-else class="attribute-card_value-type">{{ valueTypeMap[property.value_type] }}</div>
</div> </div>
<div <div
@ -53,7 +53,7 @@
<a-space class="attribute-card-operation"> <a-space class="attribute-card-operation">
<a v-if="!isStore"><a-icon type="edit" @click="handleEdit"/></a> <a v-if="!isStore"><a-icon type="edit" @click="handleEdit"/></a>
<a-tooltip title="所有CI触发计算"> <a-tooltip :title="$t('cmdb.ciType.computeForAllCITips')">
<a v-if="!isStore && property.is_computed"><a-icon type="redo" @click="handleCalcComputed"/></a> <a v-if="!isStore && property.is_computed"><a-icon type="redo" @click="handleCalcComputed"/></a>
</a-tooltip> </a-tooltip>
<a style="color:red;"><a-icon type="delete" @click="handleDelete"/></a> <a style="color:red;"><a-icon type="delete" @click="handleDelete"/></a>
@ -106,36 +106,40 @@ export default {
}, },
attributes: { attributes: {
type: Array, type: Array,
default: () => [] default: () => [],
} },
}, },
data() { data() {
const propertyList = [ return {}
},
computed: {
valueTypeMap() {
return valueTypeMap()
},
propertyList() {
return [
{ {
label: '是否唯一', label: this.$t('cmdb.ciType.isUnique'),
property: 'is_unique', property: 'is_unique',
}, },
{ {
label: '是否选择', label: this.$t('cmdb.ciType.isChoice'),
property: 'is_choice', property: 'is_choice',
}, },
{ {
label: '默认显示', label: this.$t('cmdb.ciType.defaultShow'),
property: 'default_show', property: 'default_show',
}, },
{ {
label: '可排序', label: this.$t('cmdb.ciType.isSortable'),
property: 'is_sortable', property: 'is_sortable',
}, },
{ {
label: '是否索引', label: this.$t('cmdb.ciType.isIndex'),
property: 'is_index', property: 'is_index',
}, },
] ]
return { },
valueTypeMap,
propertyList,
}
}, },
methods: { methods: {
getPropertyStyle, getPropertyStyle,
@ -145,17 +149,17 @@ export default {
handleDelete() { handleDelete() {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确认删除 ${that.property.alias || that.property.name}`, content: that.$t('cmdb.ciType.confirmDelete', { name: `${that.property.alias || that.property.name}` }),
onOk() { onOk() {
if (that.isStore) { if (that.isStore) {
deleteAttributesById(that.property.id).then(() => { deleteAttributesById(that.property.id).then(() => {
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.$emit('ok') that.$emit('ok')
}) })
} else { } else {
deleteCITypeAttributesById(that.CITypeId, { attr_id: [that.property.id] }).then(() => { deleteCITypeAttributesById(that.CITypeId, { attr_id: [that.property.id] }).then(() => {
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.$emit('ok') that.$emit('ok')
}) })
} }
@ -169,11 +173,11 @@ export default {
handleCalcComputed() { handleCalcComputed() {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确认触发所有CI的计算`, content: that.$t('cmdb.ciType.confirmcomputeForAllCITips'),
onOk() { onOk() {
calcComputedAttribute(that.property.id).then(() => { calcComputedAttribute(that.property.id).then(() => {
that.$message.success('触发成功!') that.$message.success(that.$t('cmdb.ciType.computeSuccess'))
}) })
}, },
}) })

View File

@ -11,20 +11,20 @@
wrapClassName="attribute-edit-form" wrapClassName="attribute-edit-form"
> >
<a-form :form="form" :layout="formLayout"> <a-form :form="form" :layout="formLayout">
<a-divider style="font-size:14px;margin-top:6px;">基础设置</a-divider> <a-divider style="font-size:14px;margin-top:6px;">{{ $t('cmdb.ciType.basicConfig') }}</a-divider>
<a-col :span="12"> <a-col :span="12">
<a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="属性名(英文)"> <a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" :label="$t('cmdb.ciType.AttributeName')">
<a-input <a-input
:disabled="true" :disabled="true"
name="name" name="name"
placeholder="英文" :placeholder="$t('cmdb.ciType.English')"
v-decorator="[ v-decorator="[
'name', 'name',
{ {
rules: [ rules: [
{ required: true, message: '请输入属性名' }, { required: true, message: $t('cmdb.ciType.inputAttributeName') },
{ {
message: '不能以数字开头,可以是英文 数字以及下划线 (_)', message: $t('cmdb.ciType.attributeNameTips'),
pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$'), pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$'),
}, },
], ],
@ -35,12 +35,12 @@
</a-col> </a-col>
<a-col <a-col
:span="12" :span="12"
><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="别名"> ><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" :label="$t('alias')">
<a-input name="alias" v-decorator="['alias', { rules: [] }]" /> </a-form-item <a-input name="alias" v-decorator="['alias', { rules: [] }]" /> </a-form-item
></a-col> ></a-col>
<a-col <a-col
:span="12" :span="12"
><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="数据类型"> ><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" :label="$t('cmdb.ciType.DataType')">
<a-select <a-select
:disabled="true" :disabled="true"
name="value_type" name="value_type"
@ -56,7 +56,7 @@
<a-form-item <a-form-item
:label-col="{ span: currentValueType === '6' ? 4 : 8 }" :label-col="{ span: currentValueType === '6' ? 4 : 8 }"
:wrapper-col="{ span: currentValueType === '6' ? 18 : 12 }" :wrapper-col="{ span: currentValueType === '6' ? 18 : 12 }"
label="默认值" :label="$t('cmdb.ciType.defaultValue')"
> >
<template> <template>
<a-select <a-select
@ -73,7 +73,7 @@
@select="selectIntDefaultValue" @select="selectIntDefaultValue"
> >
<a-select-option key="$auto_inc_id"> <a-select-option key="$auto_inc_id">
自增ID {{ $t('cmdb.ciType.autoIncID') }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<a-input-number <a-input-number
@ -100,13 +100,13 @@
@select="changeDefaultForDatetime" @select="changeDefaultForDatetime"
> >
<a-select-option key="$created_at"> <a-select-option key="$created_at">
创建时间 {{ $t('createdAt') }}
</a-select-option> </a-select-option>
<a-select-option key="$updated_at"> <a-select-option key="$updated_at">
更新时间 {{ $t('updatedAt') }}
</a-select-option> </a-select-option>
<a-select-option key="$custom_time"> <a-select-option key="$custom_time">
自定义时间 {{ $t('cmdb.ciType.customTime') }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<template v-else-if="currentValueType === '4' || currentValueType === '3'"> <template v-else-if="currentValueType === '4' || currentValueType === '3'">
@ -124,10 +124,10 @@
<a><a-icon type="down" /> </a> <a><a-icon type="down" /> </a>
<a-menu slot="overlay" @click="onClick"> <a-menu slot="overlay" @click="onClick">
<a-menu-item key="$created_at"> <a-menu-item key="$created_at">
<a>创建时间</a> <a>{{ $t('createdAt') }}</a>
</a-menu-item> </a-menu-item>
<a-menu-item key="$updated_at"> <a-menu-item key="$updated_at">
<a>更新时间</a> <a>{{ $t('updatedAt') }}</a>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</a-dropdown> </a-dropdown>
@ -150,7 +150,7 @@
<a-form-item <a-form-item
:label-col="horizontalFormItemLayout.labelCol" :label-col="horizontalFormItemLayout.labelCol"
:wrapper-col="horizontalFormItemLayout.wrapperCol" :wrapper-col="horizontalFormItemLayout.wrapperCol"
label="必须" :label="$t('required')"
> >
<a-switch <a-switch
@change="(checked) => onChange(checked, 'is_required')" @change="(checked) => onChange(checked, 'is_required')"
@ -160,7 +160,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6" v-if="currentValueType !== '6' && currentValueType !== '7'"> <a-col :span="6" v-if="currentValueType !== '6' && currentValueType !== '7'">
<a-form-item :label-col="{ span: 8 }" :wrapper-col="horizontalFormItemLayout.wrapperCol" label="唯一"> <a-form-item :label-col="{ span: 8 }" :wrapper-col="horizontalFormItemLayout.wrapperCol" :label="$t('cmdb.ciType.unique')">
<a-switch <a-switch
:disabled="isShowComputedArea" :disabled="isShowComputedArea"
@change="onChange" @change="onChange"
@ -178,8 +178,8 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `索引` }} >{{ $t('cmdb.ciType.index') }}
<a-tooltip title="字段可被用于检索,加速查询"> <a-tooltip :title="$t('cmdb.ciType.indexTips')">
<a-icon <a-icon
style="position:absolute;top:3px;left:-17px;color:#2f54eb;" style="position:absolute;top:3px;left:-17px;color:#2f54eb;"
type="question-circle" type="question-circle"
@ -210,8 +210,8 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `显示` }} >{{ $t('cmdb.ciType.defaultShow') }}
<a-tooltip title="CI实例表格默认展示该字段"> <a-tooltip :title="$t('cmdb.ciType.defaultShowTips')">
<a-icon <a-icon
style="position:absolute;top:3px;left:-17px;color:#2f54eb;" style="position:absolute;top:3px;left:-17px;color:#2f54eb;"
type="question-circle" type="question-circle"
@ -237,7 +237,7 @@
<a-form-item <a-form-item
:label-col="currentValueType === '2' ? horizontalFormItemLayout.labelCol : { span: 8 }" :label-col="currentValueType === '2' ? horizontalFormItemLayout.labelCol : { span: 8 }"
:wrapper-col="horizontalFormItemLayout.wrapperCol" :wrapper-col="horizontalFormItemLayout.wrapperCol"
label="排序" :label="$t('cmdb.ciType.isSortable')"
> >
<a-switch <a-switch
:disabled="isShowComputedArea" :disabled="isShowComputedArea"
@ -256,8 +256,8 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `多值` }} >{{ $t('cmdb.ciType.list') }}
<a-tooltip title="字段的值是1个或者多个接口返回的值的类型是list"> <a-tooltip :title="$t('cmdb.ciType.listTips')">
<a-icon <a-icon
style="position:absolute;top:3px;left:-17px;color:#2f54eb;" style="position:absolute;top:3px;left:-17px;color:#2f54eb;"
type="question-circle" type="question-circle"
@ -280,15 +280,15 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-divider style="font-size:14px;margin-top:6px;">高级设置</a-divider> <a-divider style="font-size:14px;margin-top:6px;">{{ $t('cmdb.ciType.advancedSettings') }}</a-divider>
<a-row> <a-row>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" label="字体"> <a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" :label="$t('cmdb.ciType.font')">
<FontArea ref="fontArea" /> <FontArea ref="fontArea" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24" v-if="!['6', '7'].includes(currentValueType)"> <a-col :span="24" v-if="!['6', '7'].includes(currentValueType)">
<a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" label="预定义值"> <a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" :label="$t('cmdb.ciType.choiceValue')">
<PreValueArea <PreValueArea
v-if="drawerVisible" v-if="drawerVisible"
:canDefineScript="canDefineScript" :canDefineScript="canDefineScript"
@ -302,10 +302,10 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `计算属性` }} >{{ $t('cmdb.ciType.computedAttribute') }}
<a-tooltip <a-tooltip
:title=" :title="
`该属性的值是通过模型的其它属性构建的表达式或者执行一段代码的方式计算而来属性的引用方法为: {{ 属性名 }}` $t('cmdb.ciType.computedAttributeTips')
" "
> >
<a-icon <a-icon
@ -343,8 +343,8 @@
<a-input name="id" type="hidden" v-decorator="['id', { rules: [] }]" /> <a-input name="id" type="hidden" v-decorator="['id', { rules: [] }]" />
</a-form-item> </a-form-item>
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button @click="onClose">取消</a-button> <a-button @click="onClose">{{ $t('cancel') }}</a-button>
<a-button @click="handleSubmit(false)" type="primary">确定</a-button> <a-button @click="handleSubmit(false)" type="primary">{{ $t('confirm') }}</a-button>
</div> </div>
</a-form> </a-form>
</CustomDrawer> </CustomDrawer>
@ -380,8 +380,7 @@ export default {
}, },
data() { data() {
return { return {
valueTypeMap, drawerTitle: this.$t('cmdb.ciType.addAttribute'),
drawerTitle: '新增属性',
drawerVisible: false, drawerVisible: false,
formLayout: 'horizontal', formLayout: 'horizontal',
@ -390,7 +389,7 @@ export default {
currentValueType: '0', currentValueType: '0',
default_value_json: {}, default_value_json: {},
default_value_json_right: true, // 当前json是否正确 default_value_json_right: true, // Is the current json correct?
canDefineComputed: false, canDefineComputed: false,
isShowComputedArea: false, isShowComputedArea: false,
@ -404,6 +403,9 @@ export default {
}, },
computed: { computed: {
valueTypeMap() {
return valueTypeMap()
},
formItemLayout() { formItemLayout() {
const { formLayout } = this const { formLayout } = this
return formLayout === 'horizontal' return formLayout === 'horizontal'
@ -434,7 +436,7 @@ export default {
this.canDefineComputed = false this.canDefineComputed = false
} }
this.drawerTitle = '新增属性' this.drawerTitle = this.$t('cmdb.ciType.addAttribute')
this.drawerVisible = true this.drawerVisible = true
}, },
onClose() { onClose() {
@ -463,13 +465,13 @@ export default {
}) })
} }
if (checked && property === 'is_sortable') { if (checked && property === 'is_sortable') {
this.$message.warning('选中排序,则必须也要选中!') this.$message.warning(this.$t('cmdb.ciType.addAttributeTips1'))
this.form.setFieldsValue({ this.form.setFieldsValue({
is_required: true, is_required: true,
}) })
} }
if (!checked && property === 'is_required' && this.form.getFieldValue('is_sortable')) { if (!checked && property === 'is_required' && this.form.getFieldValue('is_sortable')) {
this.$message.warning('选中排序,则必须也要选中!') this.$message.warning(this.$t('cmdb.ciType.addAttributeTips1'))
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue({ this.form.setFieldsValue({
is_required: true, is_required: true,
@ -492,7 +494,7 @@ export default {
if (_record.is_link) { if (_record.is_link) {
_record.value_type = '8' _record.value_type = '8'
} }
this.drawerTitle = '编辑属性' this.drawerTitle = this.$t('cmdb.ciType.editAttribute')
this.drawerVisible = true this.drawerVisible = true
this.record = _record this.record = _record
this.currentValueType = _record.value_type this.currentValueType = _record.value_type
@ -624,7 +626,7 @@ export default {
const computedAreaData = this.$refs.computedArea.getData() const computedAreaData = this.$refs.computedArea.getData()
values = { ...values, ...computedAreaData } values = { ...values, ...computedAreaData }
} else { } else {
// 如果是非计算属性就看看有没有预定义值 // If it is a non-computed attribute, check to see if there is a predefined value
if (!['6', '7'].includes(values.value_type)) { if (!['6', '7'].includes(values.value_type)) {
const preValueAreaData = this.$refs.preValueArea.getData() const preValueAreaData = this.$refs.preValueArea.getData()
values = { ...values, ...preValueAreaData } values = { ...values, ...preValueAreaData }
@ -652,7 +654,7 @@ export default {
if (isCalcComputed) { if (isCalcComputed) {
await calcComputedAttribute(attrId) await calcComputedAttribute(attrId)
} }
this.$message.success(`更新成功`) this.$message.success(this.$t('updateSuccess'))
this.handleOk() this.handleOk()
this.onClose() this.onClose()
}, },

View File

@ -2,15 +2,15 @@
<a-modal wrapClassName="attrbute-store-wrapper" width="80%" :visible="visible" @cancel="handleCancel"> <a-modal wrapClassName="attrbute-store-wrapper" width="80%" :visible="visible" @cancel="handleCancel">
<template slot="title"> <template slot="title">
<div class="attrbute-store-header"> <div class="attrbute-store-header">
<span>属性库</span> <span>{{ $t('cmdb.ciType.attributeLibray') }}</span>
<div class="attrbute-store-search"> <div class="attrbute-store-search">
<a-input-group compact> <a-input-group compact>
<a-select class="attrbute-store-search-select" v-model="searchKey"> <a-select class="attrbute-store-search-select" v-model="searchKey">
<a-select-option value="alias"> <a-select-option value="alias">
别名 {{ $t('alias') }}
</a-select-option> </a-select-option>
<a-select-option value="name"> <a-select-option value="name">
名称 {{ $t('name') }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<a-input <a-input
@ -53,7 +53,7 @@
</a-row> </a-row>
<a-empty v-else> <a-empty v-else>
<img slot="image" :src="require('@/assets/data_empty.png')" /> <img slot="image" :src="require('@/assets/data_empty.png')" />
<span slot="description"> 暂无数据 </span> <span slot="description"> {{ $t('noData') }} </span>
</a-empty> </a-empty>
</a-spin> </a-spin>
<template slot="footer"> <template slot="footer">
@ -63,7 +63,7 @@
show-quick-jumper show-quick-jumper
:current="tablePage.currentPage" :current="tablePage.currentPage"
:total="tablePage.totalResult" :total="tablePage.totalResult"
:show-total="(total, range) => `当前展示 ${range[0]}-${range[1]} 条数据, 共 ${total} 条`" :show-total="(total, range) => $t('pagination.total', { total: total, range0: range[0], range1: range[1] })"
:page-size="tablePage.pageSize" :page-size="tablePage.pageSize"
:default-current="1" :default-current="1"
@change="pageOrSizeChange" @change="pageOrSizeChange"

View File

@ -1,8 +1,8 @@
<template> <template>
<div> <div>
<a-modal v-model="addGroupModal" title="新增分组" @cancel="handleCancelCreateGroup" @ok="handleCreateGroup"> <a-modal v-model="addGroupModal" :title="$t('cmdb.ciType.addGroup')" @cancel="handleCancelCreateGroup" @ok="handleCreateGroup">
<span> <span>
<a-form-item label="名称" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }"> <a-form-item :label="$t('name')" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
<a-input type="text" v-model.trim="newGroupName" /> <a-input type="text" v-model.trim="newGroupName" />
</a-form-item> </a-form-item>
</span> </span>
@ -15,14 +15,14 @@
size="small" size="small"
class="ops-button-primary" class="ops-button-primary"
icon="plus" icon="plus"
>分组</a-button >{{ $t('cmdb.ciType.group') }}</a-button
> >
<a-button <a-button
type="primary" type="primary"
@click="handleOpenUniqueConstraint" @click="handleOpenUniqueConstraint"
size="small" size="small"
class="ops-button-primary" class="ops-button-primary"
>唯一校验</a-button >{{ $t('cmdb.ciType.uniqueConstraint') }}</a-button
> >
</a-space> </a-space>
<div :key="CITypeGroup.id" v-for="(CITypeGroup, index) in CITypeGroups"> <div :key="CITypeGroup.id" v-for="(CITypeGroup, index) in CITypeGroups">
@ -45,18 +45,18 @@
ref="editGroupInput" ref="editGroupInput"
v-model.trim="CITypeGroup.name" v-model.trim="CITypeGroup.name"
/> />
<a @click="handleSaveGroupName(index, CITypeGroup)" style="margin-right: 0.5rem">保存</a> <a @click="handleSaveGroupName(index, CITypeGroup)" style="margin-right: 0.5rem">{{ $t('save') }}</a>
<a @click="handleCancelGroupName(index, CITypeGroup)">取消</a> <a @click="handleCancelGroupName(index, CITypeGroup)">{{ $t('cancel') }}</a>
</span> </span>
</template> </template>
<a-space style="float: right"> <a-space style="float: right">
<a-tooltip v-if="index"> <a-tooltip v-if="index">
<template slot="title">上移</template> <template slot="title">{{ $t('cmdb.ciType.up') }}</template>
<a><a-icon type="arrow-up" v-if="index" @click="handleMoveGroup(index, index - 1)"/></a> <a><a-icon type="arrow-up" v-if="index" @click="handleMoveGroup(index, index - 1)"/></a>
</a-tooltip> </a-tooltip>
<a-tooltip v-if="index !== CITypeGroups.length - 1"> <a-tooltip v-if="index !== CITypeGroups.length - 1">
<template slot="title">下移</template> <template slot="title">{{ $t('cmdb.ciType.up') }}</template>
<a <a
><a-icon ><a-icon
type="arrow-down" type="arrow-down"
@ -66,11 +66,11 @@
</a-tooltip> </a-tooltip>
<a-tooltip> <a-tooltip>
<template slot="title">添加属性</template> <template slot="title">{{ $t('cmdb.ciType.selectAttribute') }}</template>
<a><a-icon type="plus" @click="handleAddGroupAttr(index)"/></a> <a><a-icon type="plus" @click="handleAddGroupAttr(index)"/></a>
</a-tooltip> </a-tooltip>
<a-tooltip> <a-tooltip>
<template slot="title">删除分组</template> <template slot="title">{{ $t('cmdb.ciType.deleteGroup') }}</template>
<a style="color:red;"><a-icon type="delete" @click="handleDeleteGroup(CITypeGroup)"/></a> <a style="color:red;"><a-icon type="delete" @click="handleDeleteGroup(CITypeGroup)"/></a>
</a-tooltip> </a-tooltip>
</a-space> </a-space>
@ -106,12 +106,12 @@
</div> </div>
<div> <div>
<div :style="{ height: '32px', lineHeight: '32px', display: 'inline-block', fontSize: '14px' }"> <div :style="{ height: '32px', lineHeight: '32px', display: 'inline-block', fontSize: '14px' }">
<span style="font-weight:700">其他</span> <span style="font-weight:700">{{ $t('other') }}</span>
<span style="color: #c3cdd7;margin-left:5px;">({{ otherGroupAttributes.length }})</span> <span style="color: #c3cdd7;margin-left:5px;">({{ otherGroupAttributes.length }})</span>
</div> </div>
<div style="float: right"> <div style="float: right">
<a-tooltip> <a-tooltip>
<template slot="title">添加属性</template> <template slot="title">{{ $t('cmdb.ciType.selectAttribute') }}</template>
<a @click="handleAddGroupAttr(undefined)"><a-icon type="plus"/></a> <a @click="handleAddGroupAttr(undefined)"><a-icon type="plus"/></a>
</a-tooltip> </a-tooltip>
</div> </div>
@ -304,7 +304,7 @@ export default {
if (CITypeGroup.name === CITypeGroup.originName) { if (CITypeGroup.name === CITypeGroup.originName) {
this.handleCancelGroupName(index, CITypeGroup) this.handleCancelGroupName(index, CITypeGroup)
} else if (this.CITypeGroups.map((x) => x.originName).includes(CITypeGroup.name)) { } else if (this.CITypeGroups.map((x) => x.originName).includes(CITypeGroup.name)) {
this.$message.error('分组名称已存在') this.$message.error(this.$t('cmdb.ciType.groupExisted'))
} else { } else {
updateCITypeGroupById(CITypeGroup.id, { updateCITypeGroupById(CITypeGroup.id, {
name: CITypeGroup.name, name: CITypeGroup.name,
@ -313,7 +313,7 @@ export default {
}).then((res) => { }).then((res) => {
CITypeGroup.editable = false CITypeGroup.editable = false
this.$set(this.CITypeGroups, index, CITypeGroup) this.$set(this.CITypeGroups, index, CITypeGroup)
this.$message.success('修改成功') this.$message.success(this.$t('updateSuccess'))
}) })
} }
}, },
@ -350,7 +350,7 @@ export default {
const fromGroupId = this.CITypeGroups[beforeIndex].id const fromGroupId = this.CITypeGroups[beforeIndex].id
const toGroupId = this.CITypeGroups[afterIndex].id const toGroupId = this.CITypeGroups[afterIndex].id
transferCITypeGroupIndex(this.CITypeId, { from: fromGroupId, to: toGroupId }).then((res) => { transferCITypeGroupIndex(this.CITypeId, { from: fromGroupId, to: toGroupId }).then((res) => {
this.$message.success('操作成功') this.$message.success(this.$t('operateSuccess'))
const beforeGroup = this.CITypeGroups[beforeIndex] const beforeGroup = this.CITypeGroups[beforeIndex]
this.CITypeGroups[beforeIndex] = this.CITypeGroups[afterIndex] this.CITypeGroups[beforeIndex] = this.CITypeGroups[afterIndex]
@ -403,8 +403,8 @@ export default {
handleDeleteGroup(group) { handleDeleteGroup(group) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确定要删除分组 ${group.name} `, content: that.$t('cmdb.ciType.confirmDeleteGroup', { groupName: `${group.name}` }),
onOk() { onOk() {
deleteCITypeGroupById(group.id).then((res) => { deleteCITypeGroupById(group.id).then((res) => {
that.CITypeGroups = that.CITypeGroups.filter((g) => g.id !== group.id) that.CITypeGroups = that.CITypeGroups.filter((g) => g.id !== group.id)
@ -417,13 +417,13 @@ export default {
console.log('changess') console.log('changess')
if (e.hasOwnProperty('moved') && e.moved.oldIndex !== e.moved.newIndex) { if (e.hasOwnProperty('moved') && e.moved.oldIndex !== e.moved.newIndex) {
if (group === -1) { if (group === -1) {
this.$message.error('其他分组中的属性不能进行排序,如需排序请先拖至自定义的分组!') this.$message.error(this.$t('cmdb.ciType.attributeSortedTips'))
} else { } else {
transferCITypeAttrIndex(this.CITypeId, { transferCITypeAttrIndex(this.CITypeId, {
from: { attr_id: e.moved.element.id, group_id: group > -1 ? group : null }, from: { attr_id: e.moved.element.id, group_id: group > -1 ? group : null },
to: { order: e.moved.newIndex, group_id: group > -1 ? group : null }, to: { order: e.moved.newIndex, group_id: group > -1 ? group : null },
}) })
.then((res) => this.$message.success('保存成功')) .then((res) => this.$message.success(this.$t('updateSuccess')))
.catch(() => { .catch(() => {
this.abortDraggable() this.abortDraggable()
}) })
@ -440,7 +440,7 @@ export default {
from: { attr_id: e.removed.element.id, group_id: group > -1 ? group : null }, from: { attr_id: e.removed.element.id, group_id: group > -1 ? group : null },
to: { group_id: this.addRemoveGroupFlag.to.group_id, order: this.addRemoveGroupFlag.to.order }, to: { group_id: this.addRemoveGroupFlag.to.group_id, order: this.addRemoveGroupFlag.to.order },
}) })
.then((res) => this.$message.success('保存成功')) .then((res) => this.$message.success(this.$t('saveSuccess')))
.catch(() => { .catch(() => {
this.abortDraggable() this.abortDraggable()
}) })
@ -456,9 +456,9 @@ export default {
}) })
}, },
updatePropertyIndex() { updatePropertyIndex() {
const attributes = [] // 全部属性 const attributes = [] // All attributes
let attributeOrder = 0 // 属性组 let attributeOrder = 0 // attribute group
let groupOrder = 0 // 组排序 let groupOrder = 0 // group sort
const promises = [] const promises = []
this.CITypeGroups.forEach((group) => { this.CITypeGroups.forEach((group) => {
@ -509,7 +509,7 @@ export default {
const that = this const that = this
Promise.all(promises).then((values) => { Promise.all(promises).then((values) => {
that.$message.success(`修改成功`) that.$message.success(that.$t('updateSuccess'))
that.getCITypeGroupData() that.getCITypeGroupData()
that.modalVisible = false that.modalVisible = false
}) })

View File

@ -5,23 +5,23 @@
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
> >
<a-divider style="font-size:14px;margin-top:6px;">基础设置</a-divider> <a-divider style="font-size:14px;margin-top:6px;">{{ $t('cmdb.ciType.basicConfig') }}</a-divider>
<a-row> <a-row>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="属性名(英文)"> <a-form-item :label="$t('cmdb.ciType.AttributeName')">
<a-input <a-input
name="name" name="name"
placeholder="英文" :placeholder="$t('cmdb.ciType.English')"
v-decorator="[ v-decorator="[
'name', 'name',
{ {
rules: [ rules: [
{ required: true, message: '请输入属性名' }, { required: true, message: $t('cmdb.ciType.inputAttributeName') },
{ {
message: '不能以数字开头,可以是英文 数字以及下划线 (_)', message: $t('cmdb.ciType.attributeNameTips'),
pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$'), pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$'),
}, },
{ message: '内置字段', pattern: RegExp('^(?!(id|_id|ci_id|type|_type|ci_type)$).*$') }, { message: $t('cmdb.ciType.buildinAttribute'), pattern: RegExp('^(?!(id|_id|ci_id|type|_type|ci_type)$).*$') },
], ],
}, },
]" ]"
@ -29,14 +29,14 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="别名"> <a-form-item :label="$t('alias')">
<a-input name="alias" v-decorator="['alias', { rules: [] }]" /> <a-input name="alias" v-decorator="['alias', { rules: [] }]" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row> <a-row>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="数据类型"> <a-form-item :label="$t('cmdb.ciType.DataType')">
<a-select <a-select
name="value_type" name="value_type"
style="width: 100%" style="width: 100%"
@ -56,7 +56,7 @@
<a-form-item <a-form-item
:label-col="{ span: currentValueType === '6' ? 4 : 8 }" :label-col="{ span: currentValueType === '6' ? 4 : 8 }"
:wrapper-col="{ span: currentValueType === '6' ? 18 : 15 }" :wrapper-col="{ span: currentValueType === '6' ? 18 : 15 }"
label="默认值" :label="$t('cmdb.ciType.defaultValue')"
> >
<template> <template>
<a-select <a-select
@ -79,7 +79,7 @@
@select="selectIntDefaultValue" @select="selectIntDefaultValue"
> >
<a-select-option key="$auto_inc_id"> <a-select-option key="$auto_inc_id">
自增ID {{ $t('cmdb.ciType.autoIncID') }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<a-input <a-input
@ -100,13 +100,13 @@
@select="changeDefaultForDatetime" @select="changeDefaultForDatetime"
> >
<a-select-option key="$created_at"> <a-select-option key="$created_at">
创建时间 {{ $t('createdAt') }}
</a-select-option> </a-select-option>
<a-select-option key="$updated_at"> <a-select-option key="$updated_at">
更新时间 {{ $t('updatedAt') }}
</a-select-option> </a-select-option>
<a-select-option key="$custom_time"> <a-select-option key="$custom_time">
自定义时间 {{ $t('cmdb.ciType.customTime') }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<template v-else-if="currentValueType === '4' || currentValueType === '3'"> <template v-else-if="currentValueType === '4' || currentValueType === '3'">
@ -124,10 +124,10 @@
<a><a-icon type="down" /> </a> <a><a-icon type="down" /> </a>
<a-menu slot="overlay" @click="onClick"> <a-menu slot="overlay" @click="onClick">
<a-menu-item key="$created_at"> <a-menu-item key="$created_at">
<a>创建时间</a> <a>{{ $t('createdAt') }}</a>
</a-menu-item> </a-menu-item>
<a-menu-item key="$updated_at"> <a-menu-item key="$updated_at">
<a>更新时间</a> <a>{{ $t('updatedAt') }}</a>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</a-dropdown> </a-dropdown>
@ -152,7 +152,7 @@
<a-form-item <a-form-item
:label-col="horizontalFormItemLayout.labelCol" :label-col="horizontalFormItemLayout.labelCol"
:wrapper-col="horizontalFormItemLayout.wrapperCol" :wrapper-col="horizontalFormItemLayout.wrapperCol"
label="必须" :label="$t('required')"
> >
<a-switch <a-switch
@change="(checked) => onChange(checked, 'is_required')" @change="(checked) => onChange(checked, 'is_required')"
@ -162,7 +162,7 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6" v-if="currentValueType !== '6' && currentValueType !== '7'"> <a-col :span="6" v-if="currentValueType !== '6' && currentValueType !== '7'">
<a-form-item :label-col="{ span: 8 }" :wrapper-col="horizontalFormItemLayout.wrapperCol" label="唯一"> <a-form-item :label-col="{ span: 8 }" :wrapper-col="horizontalFormItemLayout.wrapperCol" :label="$t('cmdb.ciType.unique')">
<a-switch <a-switch
:disabled="isShowComputedArea" :disabled="isShowComputedArea"
@change="onChange" @change="onChange"
@ -176,8 +176,8 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `索引` }} >{{ $t('cmdb.ciType.index') }}
<a-tooltip title="字段可被用于检索,加速查询"> <a-tooltip :title="$t('cmdb.ciType.indexTips')">
<a-icon <a-icon
style="position:absolute;top:3px;left:-17px;color:#2f54eb;" style="position:absolute;top:3px;left:-17px;color:#2f54eb;"
type="question-circle" type="question-circle"
@ -208,8 +208,8 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `显示` }} >{{ $t('cmdb.ciType.defaultShow') }}
<a-tooltip title="CI实例表格默认展示该字段"> <a-tooltip :title="$t('cmdb.ciType.defaultShowTips')">
<a-icon <a-icon
style="position:absolute;top:3px;left:-17px;color:#2f54eb;" style="position:absolute;top:3px;left:-17px;color:#2f54eb;"
type="question-circle" type="question-circle"
@ -235,7 +235,7 @@
<a-form-item <a-form-item
:label-col="currentValueType === '2' ? horizontalFormItemLayout.labelCol : { span: 8 }" :label-col="currentValueType === '2' ? horizontalFormItemLayout.labelCol : { span: 8 }"
:wrapper-col="horizontalFormItemLayout.wrapperCol" :wrapper-col="horizontalFormItemLayout.wrapperCol"
label="排序" :label="$t('cmdb.ciType.isSortable')"
> >
<a-switch <a-switch
:disabled="isShowComputedArea" :disabled="isShowComputedArea"
@ -254,8 +254,8 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `多值` }} >{{ $t('cmdb.ciType.list') }}
<a-tooltip title="字段的值是1个或者多个接口返回的值的类型是list"> <a-tooltip :title="$t('cmdb.ciType.listTips')">
<a-icon <a-icon
style="position:absolute;top:3px;left:-17px;color:#2f54eb;" style="position:absolute;top:3px;left:-17px;color:#2f54eb;"
type="question-circle" type="question-circle"
@ -278,15 +278,15 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-divider style="font-size:14px;margin-top:6px;">高级设置</a-divider> <a-divider style="font-size:14px;margin-top:6px;">{{ $t('cmdb.ciType.advancedSettings') }}</a-divider>
<a-row> <a-row>
<a-col :span="24"> <a-col :span="24">
<a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" label="字体"> <a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" :label="$t('cmdb.ciType.font')">
<FontArea ref="fontArea" /> <FontArea ref="fontArea" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24" v-if="!['6', '7'].includes(currentValueType)"> <a-col :span="24" v-if="!['6', '7'].includes(currentValueType)">
<a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" label="预定义值"> <a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" :label="$t('cmdb.ciType.choiceValue')">
<PreValueArea ref="preValueArea" :canDefineScript="canDefineScript" :disabled="isShowComputedArea" /> <PreValueArea ref="preValueArea" :canDefineScript="canDefineScript" :disabled="isShowComputedArea" />
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -295,10 +295,10 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `计算属性` }} >{{ $t('cmdb.ciType.computedAttribute') }}
<a-tooltip <a-tooltip
:title=" :title="
`该属性的值是通过模型的其它属性构建的表达式或者执行一段代码的方式计算而来属性的引用方法为: {{ 属性名 }}` $t('cmdb.ciType.computedAttributeTips')
" "
> >
<a-icon <a-icon
@ -326,9 +326,9 @@
</a-col> </a-col>
</a-row> </a-row>
<a-form-item v-if="hasFooter" :wrapper-col="{ offset: 18 }"> <a-form-item v-if="hasFooter" :wrapper-col="{ offset: 18 }">
<a-button type="primary" @click="handleSubmit">新增</a-button> <a-button type="primary" @click="handleSubmit">{{ $t('new') }}</a-button>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a-button @click="handleClose">取消</a-button> <a-button @click="handleClose">{{ $t('cancel') }}</a-button>
</a-form-item> </a-form-item>
</a-form> </a-form>
</template> </template>
@ -357,7 +357,6 @@ export default {
}, },
data() { data() {
return { return {
valueTypeMap,
formItemLayout: { formItemLayout: {
labelCol: { span: 8 }, labelCol: { span: 8 },
wrapperCol: { span: 15 }, wrapperCol: { span: 15 },
@ -369,7 +368,7 @@ export default {
form: this.$form.createForm(this), form: this.$form.createForm(this),
currentValueType: '2', currentValueType: '2',
default_value_json: {}, default_value_json: {},
default_value_json_right: true, // 当前json是否正确 default_value_json_right: true, // Is the current json correct?
canDefineComputed: false, canDefineComputed: false,
isShowComputedArea: false, isShowComputedArea: false,
@ -378,6 +377,9 @@ export default {
} }
}, },
computed: { computed: {
valueTypeMap() {
return valueTypeMap()
},
canDefineScript() { canDefineScript() {
return this.canDefineComputed return this.canDefineComputed
}, },
@ -423,7 +425,7 @@ export default {
const computedAreaData = this.$refs.computedArea.getData() const computedAreaData = this.$refs.computedArea.getData()
values = { ...values, ...computedAreaData } values = { ...values, ...computedAreaData }
} else { } else {
// 如果是非计算属性就看看有没有预定义值 // If it is a non-computed attribute, check to see if there is a predefined value
if (!['6', '7'].includes(values.value_type)) { if (!['6', '7'].includes(values.value_type)) {
const preValueAreaData = this.$refs.preValueArea.getData() const preValueAreaData = this.$refs.preValueArea.getData()
values = { ...values, ...preValueAreaData } values = { ...values, ...preValueAreaData }
@ -431,9 +433,9 @@ export default {
} }
const fontOptions = this.$refs.fontArea.getData() const fontOptions = this.$refs.fontArea.getData()
// is_index进行操作除了文本 索引隐藏掉 文本 索引默认是true // is_index: except for text, the index is hidden, text index default is true
// 框里的5种类型 is_index=true // 5 types in the box, is_index=true
// json类型密码链接 is_index=false // json, password, link is_index=false
if (['6', '7', '8'].includes(values.value_type)) { if (['6', '7', '8'].includes(values.value_type)) {
values.is_index = false values.is_index = false
} else if (values.value_type !== '2') { } else if (values.value_type !== '2') {
@ -497,13 +499,13 @@ export default {
}) })
} }
if (checked && property === 'is_sortable') { if (checked && property === 'is_sortable') {
this.$message.warning('选中排序,则必须也要选中!') this.$message.warning(this.$t('cmdb.ciType.addAttributeTips1'))
this.form.setFieldsValue({ this.form.setFieldsValue({
is_required: true, is_required: true,
}) })
} }
if (!checked && property === 'is_required' && this.form.getFieldValue('is_sortable')) { if (!checked && property === 'is_required' && this.form.getFieldValue('is_sortable')) {
this.$message.warning('选中排序,则必须也要选中!') this.$message.warning(this.$t('cmdb.ciType.addAttributeTips1'))
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue({ this.form.setFieldsValue({
is_required: true, is_required: true,

View File

@ -1,22 +1,22 @@
<template> <template>
<a-card :bordered="false" :bodyStyle="{ padding: '0' }"> <a-card :bordered="false" :bodyStyle="{ padding: '0' }">
<a-tabs :activeKey="activeKey" @change="changeTab" class="ops-tab" type="card"> <a-tabs :activeKey="activeKey" @change="changeTab" class="ops-tab" type="card">
<a-tab-pane key="1" tab="模型属性"> <a-tab-pane key="1" :tab="$t('cmdb.ciType.attributes')">
<AttributesTable ref="attributesTable" :CITypeId="CITypeId" :CITypeName="CITypeName"></AttributesTable> <AttributesTable ref="attributesTable" :CITypeId="CITypeId" :CITypeName="CITypeName"></AttributesTable>
</a-tab-pane> </a-tab-pane>
<a-tab-pane forceRender key="2" tab="模型关联"> <a-tab-pane forceRender key="2" :tab="$t('cmdb.ciType.relation')">
<RelationTable :CITypeId="CITypeId" :CITypeName="CITypeName"></RelationTable> <RelationTable :CITypeId="CITypeId" :CITypeName="CITypeName"></RelationTable>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="3" tab="触发器"> <a-tab-pane key="3" :tab="$t('cmdb.ciType.trigger')">
<TriggerTable ref="triggerTable" :CITypeId="CITypeId"></TriggerTable> <TriggerTable ref="triggerTable" :CITypeId="CITypeId"></TriggerTable>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="4" tab="属性自动发现"> <a-tab-pane key="4" :tab="$t('cmdb.ciType.attributeAD')">
<AttrAD :CITypeId="CITypeId"></AttrAD> <AttrAD :CITypeId="CITypeId"></AttrAD>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="5" tab="关系自动发现"> <a-tab-pane key="5" :tab="$t('cmdb.ciType.relationAD')">
<RelationAD :CITypeId="CITypeId"></RelationAD> <RelationAD :CITypeId="CITypeId"></RelationAD>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="6" tab="权限设置"> <a-tab-pane key="6" :tab="$t('cmdb.ciType.grant')">
<GrantComp :CITypeId="CITypeId" resourceType="CIType" :resourceTypeName="CITypeName"></GrantComp> <GrantComp :CITypeId="CITypeId" resourceType="CIType" :resourceTypeName="CITypeName"></GrantComp>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>

View File

@ -1,18 +1,18 @@
<template> <template>
<a-tabs v-model="activeKey" size="small" :tabBarStyle="{ borderBottom: 'none' }"> <a-tabs v-model="activeKey" size="small" :tabBarStyle="{ borderBottom: 'none' }">
<a-tab-pane key="expr" :disabled="!canDefineComputed"> <a-tab-pane key="expr" :disabled="!canDefineComputed">
<span style="font-size:12px;" slot="tab">表达式</span> <span style="font-size:12px;" slot="tab">{{ $t('cmdb.ciType.expr') }}</span>
<a-textarea v-model="compute_expr" :placeholder="`{{a}}+{{b}}`" :rows="2" :disabled="!canDefineComputed" /> <a-textarea v-model="compute_expr" :placeholder="`{{a}}+{{b}}`" :rows="2" :disabled="!canDefineComputed" />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="script" :disabled="!canDefineComputed"> <a-tab-pane key="script" :disabled="!canDefineComputed">
<span style="font-size:12px;" slot="tab">代码</span> <span style="font-size:12px;" slot="tab">{{ $t('cmdb.ciType.code') }}</span>
<codemirror style="z-index: 9999" :options="cmOptions" v-model="compute_script"></codemirror> <codemirror style="z-index: 9999" :options="cmOptions" v-model="compute_script"></codemirror>
</a-tab-pane> </a-tab-pane>
<template slot="tabBarExtraContent" v-if="showCalcComputed"> <template slot="tabBarExtraContent" v-if="showCalcComputed">
<a-button type="primary" size="small" @click="handleCalcComputed"> <a-button type="primary" size="small" @click="handleCalcComputed">
应用 {{ $t('cmdb.ciType.apply') }}
</a-button> </a-button>
<a-tooltip title="所有CI触发计算"> <a-tooltip :title="$t('cmdb.ciType.computeForAllCITips')">
<a-icon type="question-circle" style="margin-left:5px" /> <a-icon type="question-circle" style="margin-left:5px" />
</a-tooltip> </a-tooltip>
</template> </template>
@ -76,8 +76,8 @@ export default {
handleCalcComputed() { handleCalcComputed() {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: this.$t('warning'),
content: `确认触发将保存当前配置及触发所有CI的计算`, content: this.$t('cmdb.ciType.confirmcomputeForAllCITips'),
onOk() { onOk() {
that.$emit('handleCalcComputed') that.$emit('handleCalcComputed')
}, },

View File

@ -2,7 +2,9 @@
<div class="ci-types-wrap" :style="{ height: `${windowHeight - 66}px` }"> <div class="ci-types-wrap" :style="{ height: `${windowHeight - 66}px` }">
<div v-if="!CITypeGroups.length" class="ci-types-empty"> <div v-if="!CITypeGroups.length" class="ci-types-empty">
<a-empty :image="emptyImage" description=""></a-empty> <a-empty :image="emptyImage" description=""></a-empty>
<a-button icon="plus" size="small" type="primary" @click="handleClickAddGroup">新增分组</a-button> <a-button icon="plus" size="small" type="primary" @click="handleClickAddGroup">{{
$t('cmdb.ciType.addGroup')
}}</a-button>
</div> </div>
<SplitPane <SplitPane
v-else v-else
@ -23,7 +25,7 @@
icon="plus" icon="plus"
@click="handleClickAddGroup" @click="handleClickAddGroup"
class="ops-button-primary" class="ops-button-primary"
>分组</a-button >{{ $t('cmdb.ciType.group') }}</a-button
> >
<a-space> <a-space>
<a <a
@ -32,7 +34,7 @@
$refs.attributeStore.open() $refs.attributeStore.open()
} }
" "
>属性库</a >{{ $t('cmdb.ciType.attributeLibray') }}</a
> >
<a-dropdown v-if="permissions.includes('admin') || permissions.includes('cmdb_admin')"> <a-dropdown v-if="permissions.includes('admin') || permissions.includes('cmdb_admin')">
<a><ops-icon type="ops-menu" /></a> <a><ops-icon type="ops-menu" /></a>
@ -46,12 +48,12 @@
action="/api/v0.1/ci_types/template/import/file" action="/api/v0.1/ci_types/template/import/file"
@change="changeUploadFile" @change="changeUploadFile"
> >
<a><a-icon type="upload"/></a><a> 导入</a> <a><a-icon type="upload" /></a><a> {{ $t('upload') }}</a>
</a-upload> </a-upload>
</a-menu-item> </a-menu-item>
<a-menu-item key="1"> <a-menu-item key="1">
<a-space> <a-space>
<a href="/api/v0.1/ci_types/template/export/file"><a-icon type="download" /> 导出</a> <a href="/api/v0.1/ci_types/template/export/file"><a-icon type="download" /> {{ $t('download') }}</a>
</a-space> </a-space>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
@ -61,32 +63,30 @@
<draggable class="ci-types-left-content" :list="CITypeGroups" @end="handleChangeGroups" filter=".undraggable"> <draggable class="ci-types-left-content" :list="CITypeGroups" @end="handleChangeGroups" filter=".undraggable">
<div v-for="g in CITypeGroups" :key="g.id || g.name"> <div v-for="g in CITypeGroups" :key="g.id || g.name">
<div <div
:class=" :class="`${currentGId === g.id && !currentCId ? 'selected' : ''} ci-types-left-group ${
`${currentGId === g.id && !currentCId ? 'selected' : ''} ci-types-left-group ${
g.id === -1 ? 'undraggable' : '' g.id === -1 ? 'undraggable' : ''
}` }`"
"
@click="handleClickGroup(g.id)" @click="handleClickGroup(g.id)"
> >
<div> <div>
<OpsMoveIcon <OpsMoveIcon
style="width: 17px; height: 17px; display: none; position: absolute; left: -3px; top: 10px" style="width: 17px; height: 17px; display: none; position: absolute; left: -3px; top: 10px"
/> />
<span style="font-weight:700">{{ g.name || '其他' }}</span> <span style="font-weight: 700">{{ g.name || $t('other') }}</span>
<span :style="{ color: '#c3cdd7' }">({{ g.ci_types.length }})</span> <span :style="{ color: '#c3cdd7' }">({{ g.ci_types.length }})</span>
</div> </div>
<a-space> <a-space>
<a-tooltip> <a-tooltip>
<template slot="title">在该组中新增CI模型</template> <template slot="title">{{ $t('cmdb.ciType.addCITypeInGroup') }}</template>
<a><a-icon type="plus" @click="handleCreate(g)" /></a> <a><a-icon type="plus" @click="handleCreate(g)" /></a>
</a-tooltip> </a-tooltip>
<template v-if="g.id !== -1"> <template v-if="g.id !== -1">
<a-tooltip> <a-tooltip>
<template slot="title">编辑组名称</template> <template slot="title">{{ $t('cmdb.ciType.editGroup') }}</template>
<a><a-icon type="edit" @click="handleEditGroup(g)" /></a> <a><a-icon type="edit" @click="handleEditGroup(g)" /></a>
</a-tooltip> </a-tooltip>
<a-tooltip> <a-tooltip>
<template slot="title">删除该组</template> <template slot="title">{{ $t('cmdb.ciType.deleteGroup') }}</template>
<a style="color: red"><a-icon type="delete" @click="handleDeleteGroup(g)" /></a> <a style="color: red"><a-icon type="delete" @click="handleDeleteGroup(g)" /></a>
</a-tooltip> </a-tooltip>
</template> </template>
@ -134,10 +134,9 @@
<a><a-icon type="edit" @click="(e) => handleEdit(e, ci)" /></a> <a><a-icon type="edit" @click="(e) => handleEdit(e, ci)" /></a>
<a <a
v-if="permissions.includes('admin') || permissions.includes('cmdb_admin')" v-if="permissions.includes('admin') || permissions.includes('cmdb_admin')"
@click="(e) => handleDownloadCiType(e, ci)" @click="(e) => handleDownloadCiType(e, ci)">
><a-icon <a-icon type="download"/>
type="download" </a>
/></a>
<a style="color: red" @click="(e) => handleDelete(e, ci)"><a-icon type="delete" /></a> <a style="color: red" @click="(e) => handleDelete(e, ci)"><a-icon type="delete" /></a>
</a-space> </a-space>
</div> </div>
@ -151,13 +150,15 @@
<CITypeDetail v-if="currentCId" :CITypeId="currentCId" :CITypeName="currentCName" /> <CITypeDetail v-if="currentCId" :CITypeId="currentCId" :CITypeName="currentCName" />
<div v-else class="ci-types-right-empty"> <div v-else class="ci-types-right-empty">
<a-empty :image="emptyImage" description=""></a-empty> <a-empty :image="emptyImage" description=""></a-empty>
<a-button icon="plus" size="small" type="primary" @click="handleCreateCiFromEmpty">新增CI模型</a-button> <a-button icon="plus" size="small" type="primary" @click="handleCreateCiFromEmpty">{{
$t('cmdb.ciType.addCIType')
}}</a-button>
</div> </div>
</div> </div>
</template> </template>
</SplitPane> </SplitPane>
<a-modal v-model="modalVisible" :title="modalTitle" @ok="handleSubmitEditGroup"> <a-modal v-model="modalVisible" :title="modalTitle" @ok="handleSubmitEditGroup">
<a-form-item label="名称" :label-col="{ span: 4 }" :wrapper-col="{ span: 16 }"> <a-form-item :label="$t('name')" :label-col="{ span: 4 }" :wrapper-col="{ span: 16 }">
<a-input v-model="editingInput" /> <a-input v-model="editingInput" />
</a-form-item> </a-form-item>
</a-modal> </a-modal>
@ -167,7 +168,7 @@
:visible="drawerVisible" :visible="drawerVisible"
@close="onClose" @close="onClose"
placement="right" placement="right"
width="820px" width="900px"
:destroyOnClose="true" :destroyOnClose="true"
> >
<a-form <a-form
@ -176,17 +177,17 @@
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
> >
<a-form-item label="模型名(英文)"> <a-form-item :label="$t('cmdb.ciType.CITypeName')">
<a-input <a-input
name="name" name="name"
placeholder="英文" :placeholder="$t('cmdb.ciType.English')"
v-decorator="[ v-decorator="[
'name', 'name',
{ {
rules: [ rules: [
{ required: true, message: '请输入属性名' }, { required: true, message: $t('cmdb.ciType.inputAttributeName') },
{ {
message: '不能以数字开头,可以是英文 数字以及下划线 (_)', message: $t('cmdb.ciType.attributeNameTips'),
pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$'), pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$'),
}, },
], ],
@ -194,18 +195,21 @@
]" ]"
/> />
</a-form-item> </a-form-item>
<a-form-item label="别名"> <a-form-item :label="$t('alias')">
<a-input name="alias" v-decorator="['alias', { rules: [] }]" /> <a-input name="alias" v-decorator="['alias', { rules: [] }]" />
</a-form-item> </a-form-item>
<a-form-item label="图标"> <a-form-item :label="$t('icon')">
<IconArea class="ci_types-icon-area" ref="iconArea" /> <IconArea class="ci_types-icon-area" ref="iconArea" />
</a-form-item> </a-form-item>
<a-form-item label="默认排序" v-if="drawerTitle === '编辑模型'"> <a-form-item :label="$t('cmdb.ciType.defaultSort')" v-if="drawerTitle === $t('cmdb.ciType.editCIType')">
<el-select <el-select
size="small" size="small"
filterable filterable
clearable clearable
v-decorator="['default_order_attr', { rules: [{ required: false, message: '请选择默认排序字段' }] }]" v-decorator="[
'default_order_attr',
{ rules: [{ required: false, message: $t('cmdb.ciType.selectDefaultOrderAttr') }] },
]"
> >
<el-option <el-option
:key="item.name" :key="item.name"
@ -214,29 +218,30 @@
:label="item.alias || item.name" :label="item.alias || item.name"
> >
<span> {{ item.alias || item.name }}</span> <span> {{ item.alias || item.name }}</span>
<span :title="item.name" style="font-size:10px;color:#afafaf;"> {{ item.name }}</span> <span :title="item.name" style="font-size: 10px; color: #afafaf"> {{ item.name }}</span>
</el-option> </el-option>
<a-divider :style="{ margin: '5px 0' }" /> <a-divider :style="{ margin: '5px 0' }" />
<div :style="{ textAlign: 'right' }"> <div :style="{ textAlign: 'right' }">
<a-radio-group v-model="default_order_asc"> <a-radio-group v-model="default_order_asc">
<a-radio value="1"> <a-radio value="1">
正序 {{ $t('cmdb.ciType.asec') }}
</a-radio> </a-radio>
<a-radio value="2"> <a-radio value="2">
倒序 {{ $t('cmdb.ciType.desc') }}
</a-radio> </a-radio>
</a-radio-group> </a-radio-group>
</div> </div>
</el-select> </el-select>
</a-form-item> </a-form-item>
<a-form-item label="唯一标识"> <a-form-item :label="$t('cmdb.ciType.uniqueKey')">
<el-select <el-select
size="small" size="small"
filterable filterable
optionFilterProp="children" optionFilterProp="children"
name="unique_key" name="unique_key"
:filter-method="filterOption" :filter-method="filterOption"
v-decorator="['unique_key', { rules: [{ required: true, message: '请选择唯一标识' }] }]" v-decorator="['unique_key', { rules: [{ required: true, message: $t('cmdb.ciType.uniqueKeySelect') }] }]"
:placeholder="$t('placeholder2')"
> >
<el-option <el-option
:key="item.id" :key="item.id"
@ -245,11 +250,11 @@
:label="item.alias || item.name" :label="item.alias || item.name"
> >
<span> {{ item.alias || item.name }}</span> <span> {{ item.alias || item.name }}</span>
<span :title="item.name" style="font-size:10px;color:#afafaf;"> {{ item.name }}</span> <span :title="item.name" style="font-size: 10px; color: #afafaf"> {{ item.name }}</span>
</el-option> </el-option>
</el-select> </el-select>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a @click="handleCreatNewAttr">找不到想要的?</a> <a @click="handleCreatNewAttr">{{ $t('cmdb.ciType.notfound') }}</a>
</a-form-item> </a-form-item>
<div v-if="newAttrAreaVisible" :style="{ padding: '15px 8px 0 8px', backgroundColor: '#fafafa' }"> <div v-if="newAttrAreaVisible" :style="{ padding: '15px 8px 0 8px', backgroundColor: '#fafafa' }">
<create-new-attribute <create-new-attribute
@ -262,8 +267,10 @@
<a-input name="id" type="hidden" v-decorator="['id', { rules: [] }]" /> <a-input name="id" type="hidden" v-decorator="['id', { rules: [] }]" />
</a-form-item> </a-form-item>
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button @click="handleSubmit" :loading="loading" type="primary" style="margin-right: 1rem">确定</a-button> <a-button @click="handleSubmit" :loading="loading" type="primary" style="margin-right: 1rem">{{
<a-button @click="onClose">取消</a-button> $t('confirm')
}}</a-button>
<a-button @click="onClose">{{ $t('cancel') }}</a-button>
</div> </div>
</a-form> </a-form>
</CustomDrawer> </CustomDrawer>
@ -317,7 +324,7 @@ export default {
data() { data() {
return { return {
emptyImage, emptyImage,
modalTitle: '新增分组', modalTitle: this.$t('cmdb.ciType.addGroup'),
modalVisible: false, modalVisible: false,
editingGroup: null, editingGroup: null,
editingInput: '', editingInput: '',
@ -329,7 +336,7 @@ export default {
form: this.$form.createForm(this), form: this.$form.createForm(this),
drawerVisible: false, drawerVisible: false,
drawerTitle: '', drawerTitle: '',
selectGroup: {}, // 在当前group下新增ci type selectGroup: {}, // add CIType in group
formLayout: 'horizontal', formLayout: 'horizontal',
newAttrAreaVisible: false, newAttrAreaVisible: false,
@ -394,7 +401,7 @@ export default {
return null return null
}, },
filterAttributes() { filterAttributes() {
// 唯一标识 排除掉choice password 计算属性 json // unique key, excludes: choice password computed json
const _attributes = this.allAttributes.filter( const _attributes = this.allAttributes.filter(
(item) => !item.is_choice && !item.is_computed && !['6', '7'].includes(item.value_type) (item) => !item.is_choice && !item.is_computed && !['6', '7'].includes(item.value_type)
) )
@ -445,7 +452,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
groups.forEach((g) => { groups.forEach((g) => {
if (!g.id) { if (!g.id) {
// 给未分组增加一个假的id // Add a fake id to ungrouped
g.id = -1 g.id = -1
} }
if (isResetCurrentId && !alreadyReset && g.ci_types && g.ci_types.length) { if (isResetCurrentId && !alreadyReset && g.ci_types && g.ci_types.length) {
@ -468,7 +475,7 @@ export default {
handleClickAddGroup() { handleClickAddGroup() {
this.editingGroup = {} this.editingGroup = {}
this.editingInput = '' this.editingInput = ''
this.modalTitle = '新增分组' this.modalTitle = this.$t('cmdb.ciType.addGroup')
this.modalVisible = true this.modalVisible = true
}, },
async handleSubmitEditGroup() { async handleSubmitEditGroup() {
@ -477,11 +484,11 @@ export default {
name: this.editingInput, name: this.editingInput,
type_ids: this.editingGroup.ci_types.map((i) => i.id), type_ids: this.editingGroup.ci_types.map((i) => i.id),
}) })
this.$message.success('更新成功!') this.$message.success(this.$t('updateSuccess'))
} else { } else {
const { id } = await postCITypeGroup({ name: this.editingInput }) const { id } = await postCITypeGroup({ name: this.editingInput })
this.currentId = `${id}%null%null` this.currentId = `${id}%null%null`
this.$message.success('新增成功!') this.$message.success(this.$t('addSuccess'))
} }
this.modalVisible = false this.modalVisible = false
localStorage.setItem('ops_cityps_currentId', this.currentId) localStorage.setItem('ops_cityps_currentId', this.currentId)
@ -502,7 +509,7 @@ export default {
}) })
}, },
handleCreate(g) { handleCreate(g) {
this.drawerTitle = '新增模型' this.drawerTitle = this.$t('cmdb.ciType.addCIType')
this.drawerVisible = true this.drawerVisible = true
this.selectGroup = g this.selectGroup = g
this.$nextTick(() => { this.$nextTick(() => {
@ -510,7 +517,7 @@ export default {
}) })
}, },
handleCreateCiFromEmpty() { handleCreateCiFromEmpty() {
this.drawerTitle = '新增模型' this.drawerTitle = this.$t('cmdb.ciType.addCIType')
this.drawerVisible = true this.drawerVisible = true
const _find = this.CITypeGroups.find((item) => item.id === this.currentGId) const _find = this.CITypeGroups.find((item) => item.id === this.currentGId)
this.selectGroup = _find this.selectGroup = _find
@ -521,21 +528,21 @@ export default {
handleEditGroup(g) { handleEditGroup(g) {
this.editingGroup = g this.editingGroup = g
this.editingInput = g.name this.editingInput = g.name
this.modalTitle = '修改分组' this.modalTitle = this.$t('cmdb.ciType.editGroup')
this.modalVisible = true this.modalVisible = true
}, },
async handleDeleteGroup(g) { async handleDeleteGroup(g) {
if (g.ci_types && g.ci_types.length > 0) { if (g.ci_types && g.ci_types.length > 0) {
this.$message.error('该分组下有数据, 不能删除!') this.$message.error(this.$t('cmdb.ciType.cannotDeleteGroupTips'))
return return
} }
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确定要删除分组 ${g.name} `, content: that.$t('cmdb.ciType.confirmDeleteGroup', { groupName: `${g.name}` }),
onOk() { onOk() {
deleteCITypeGroup(g.id).then((res) => { deleteCITypeGroup(g.id).then((res) => {
that.$message.info(`删除成功`) that.$message.info(that.$t('deleteSuccess'))
that.loadCITypes(true) that.loadCITypes(true)
}) })
}, },
@ -582,11 +589,12 @@ export default {
end(g) { end(g) {
console.log('end', g) console.log('end', g)
this.endId = g.id this.endId = g.id
const that = this
if (this.startId === g.id && g.id !== -1 && this.addId !== -1) { if (this.startId === g.id && g.id !== -1 && this.addId !== -1) {
// 通过一个group内部换位置 // Changing positions within a group
putCITypeGroupByGId(g.id, { name: g.name, type_ids: g.ci_types.map((i) => i.id) }) putCITypeGroupByGId(g.id, { name: g.name, type_ids: g.ci_types.map((i) => i.id) })
.then(() => { .then(() => {
this.$message.success('保存成功!') this.$message.success(that.$t('saveSuccess'))
}) })
.catch(() => { .catch(() => {
this.loadCITypes(!this.currentId) this.loadCITypes(!this.currentId)
@ -598,7 +606,7 @@ export default {
}) })
} }
if (this.startId === g.id && g.id !== -1 && this.addId === -1) { if (this.startId === g.id && g.id !== -1 && this.addId === -1) {
// 从一个group换到其他 // Change from one group to another
const changedCiTypes = this.startGroup.ci_types const changedCiTypes = this.startGroup.ci_types
.filter((ciType) => { .filter((ciType) => {
const _find = g.ci_types.find((gCiType) => ciType.id === gCiType.id) const _find = g.ci_types.find((gCiType) => ciType.id === gCiType.id)
@ -610,7 +618,7 @@ export default {
.map((item) => item.id) .map((item) => item.id)
deleteCITypeGroup(g.id, { name: g.name, type_ids: changedCiTypes }) deleteCITypeGroup(g.id, { name: g.name, type_ids: changedCiTypes })
.then(() => { .then(() => {
this.$message.success('保存成功!') this.$message.success(that.$t('saveSuccess'))
}) })
.catch(() => { .catch(() => {
this.loadCITypes(!this.currentId) this.loadCITypes(!this.currentId)
@ -625,11 +633,12 @@ export default {
add(g) { add(g) {
console.log('add', g) console.log('add', g)
this.addId = g.id this.addId = g.id
const that = this
if (g.id && g.id !== -1) { if (g.id && g.id !== -1) {
// 跨组换位置 不换到其他 // Change positions across groups without changing to others
putCITypeGroupByGId(g.id, { name: g.name, type_ids: g.ci_types.map((i) => i.id) }) putCITypeGroupByGId(g.id, { name: g.name, type_ids: g.ci_types.map((i) => i.id) })
.then(() => { .then(() => {
this.$message.success('保存成功!') this.$message.success(that.$t('saveSuccess'))
}) })
.catch(() => { .catch(() => {
this.loadCITypes(!this.currentId) this.loadCITypes(!this.currentId)
@ -642,10 +651,11 @@ export default {
} }
}, },
async handleChangeCITypes(e, g) { async handleChangeCITypes(e, g) {
const that = this
if (g.id && g.id !== -1) { if (g.id && g.id !== -1) {
putCITypeGroupByGId(g.id, { name: g.name, type_ids: g.ci_types.map((i) => i.id) }) putCITypeGroupByGId(g.id, { name: g.name, type_ids: g.ci_types.map((i) => i.id) })
.then(() => { .then(() => {
this.$message.success('保存成功!') this.$message.success(that.$t('saveSuccess'))
}) })
.catch(() => { .catch(() => {
this.loadCITypes(!this.currentId) this.loadCITypes(!this.currentId)
@ -653,9 +663,10 @@ export default {
} }
}, },
async handleChangeGroups() { async handleChangeGroups() {
const that = this
putCITypeGroups({ group_ids: this.CITypeGroups.filter((c) => c.id).map((c) => c.id) }) putCITypeGroups({ group_ids: this.CITypeGroups.filter((c) => c.id).map((c) => c.id) })
.then(() => { .then(() => {
this.$message.success('保存成功!') this.$message.success(that.$t('saveSuccess'))
}) })
.catch(() => { .catch(() => {
this.loadCITypes(!this.currentId) this.loadCITypes(!this.currentId)
@ -665,7 +676,7 @@ export default {
const { type_id } = await createCIType(data).catch(() => { const { type_id } = await createCIType(data).catch(() => {
this.loading = false this.loading = false
}) })
this.$message.success(`添加成功`) this.$message.success(this.$t('addSuccess'))
if (this.selectGroup && this.selectGroup.id && this.selectGroup.id !== -1) { if (this.selectGroup && this.selectGroup.id && this.selectGroup.id !== -1) {
const ids = this.selectGroup.ci_types.map((i) => i.id) const ids = this.selectGroup.ci_types.map((i) => i.id)
ids.push(type_id) ids.push(type_id)
@ -684,9 +695,10 @@ export default {
}, 1000) }, 1000)
}, },
async updateCIType(CITypeId, data) { async updateCIType(CITypeId, data) {
const that = this
await updateCIType(CITypeId, data) await updateCIType(CITypeId, data)
.then((res) => { .then((res) => {
this.$message.success(`修改成功`) this.$message.success(that.$t('updateSuccess'))
const _currentId = this.currentId const _currentId = this.currentId
this.currentId = null this.currentId = null
@ -710,11 +722,11 @@ export default {
e.stopPropagation() e.stopPropagation()
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确定要删除模型 ${record.alias || record.name}`, content: that.$t('cmdb.ciType.confirmDeleteCIType', { typeName: `${record.alias || record.name}` }),
onOk() { onOk() {
deleteCIType(record.id).then((res) => { deleteCIType(record.id).then((res) => {
that.$message.success(`删除成功`) that.$message.success(that.$t('deleteSuccess'))
that.loadCITypes(true) that.loadCITypes(true)
that.resetRoute() that.resetRoute()
}) })
@ -746,7 +758,7 @@ export default {
handleEdit(e, record) { handleEdit(e, record) {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
this.drawerTitle = '编辑模型' this.drawerTitle = this.$t('cmdb.ciType.editCIType')
this.drawerVisible = true this.drawerVisible = true
getCITypeAttributesById(record.id).then((res) => { getCITypeAttributesById(record.id).then((res) => {
this.orderSelectionOptions = res.attributes.filter((item) => item.is_required) this.orderSelectionOptions = res.attributes.filter((item) => item.is_required)
@ -796,21 +808,21 @@ export default {
if (res.result) { if (res.result) {
this.$refs.cmdbGrant.open({ name: ci.name, cmdbGrantType: 'ci_type', CITypeId: ci.id }) this.$refs.cmdbGrant.open({ name: ci.name, cmdbGrantType: 'ci_type', CITypeId: ci.id })
} else { } else {
this.$message.error('权限不足!') this.$message.error(this.$t('noPermission'))
} }
}) })
}, },
changeUploadFile({ file, fileList, event }) { changeUploadFile({ file, fileList, event }) {
const key = 'upload' const key = 'upload'
if (file.status === 'uploading') { if (file.status === 'uploading') {
this.$message.loading({ content: '正在导入中', key, duration: 0 }) this.$message.loading({ content: this.$t('cmdb.ciType.uploading'), key, duration: 0 })
} }
if (file.status === 'done') { if (file.status === 'done') {
this.$message.success({ content: '导入成功', key, duration: 2 }) this.$message.success({ content: this.$t('uploadSuccess'), key, duration: 2 })
this.reload() this.reload()
} }
if (file.status === 'error') { if (file.status === 'error') {
this.$message.error({ content: '导入失败,请稍后重试', key, duration: 2 }) this.$message.error({ content: this.$t('cmdb.ciType.uploadFailed'), key, duration: 2 })
} }
}, },
}, },

View File

@ -18,18 +18,18 @@
visible = false visible = false
} }
" "
>取消</a-button >{{ $t('cancel') }}</a-button
> >
<a-button :loading="confirmLoading" @click="handleSubmit(false)" type="primary">继续添加</a-button> <a-button :loading="confirmLoading" @click="handleSubmit(false)" type="primary">{{ $t('cmdb.ciType.continueAdd') }}</a-button>
<a-button :loading="confirmLoading" type="primary" @click="handleSubmit">确定</a-button> <a-button :loading="confirmLoading" type="primary" @click="handleSubmit">{{ $t('confirm') }}</a-button>
</template> </template>
<a-tabs v-model="activeKey"> <a-tabs v-model="activeKey">
<a-tab-pane key="1" tab="新建属性"> <a-tab-pane key="1" :tab="$t('cmdb.ciType.addAttribute')">
<div :style="{ overflow: 'auto', maxHeight: '480px' }"> <div :style="{ overflow: 'auto', maxHeight: '480px' }">
<create-new-attribute ref="createNewAttribute" :hasFooter="false" @done="handleAddNewAttr" /> <create-new-attribute ref="createNewAttribute" :hasFooter="false" @done="handleAddNewAttr" />
</div> </div>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="已有属性" force-render> <a-tab-pane key="2" :tab="$t('cmdb.ciType.existedAttributes')" force-render>
<AttributesTransfer <AttributesTransfer
:dataSource="unLinkdAttrs" :dataSource="unLinkdAttrs"
:targetKeys="targetKeys" :targetKeys="targetKeys"
@ -67,7 +67,6 @@ export default {
}, },
data() { data() {
return { return {
valueTypeMap,
activeKey: '1', activeKey: '1',
visible: false, visible: false,
attributes: [], attributes: [],
@ -78,6 +77,9 @@ export default {
} }
}, },
computed: { computed: {
valueTypeMap() {
return valueTypeMap()
},
windowHeight() { windowHeight() {
return this.$store.state.windowHeight return this.$store.state.windowHeight
}, },
@ -154,7 +156,7 @@ export default {
}, },
handleClose(isCloseModal = true) { handleClose(isCloseModal = true) {
this.$emit('ok') this.$emit('ok')
this.$message.success('添加成功!') this.$message.success(this.$t('addSuccess'))
if (isCloseModal) { if (isCloseModal) {
this.visible = false this.visible = false
} }

View File

@ -7,7 +7,7 @@
:tabBarStyle="{ borderBottom: 'none' }" :tabBarStyle="{ borderBottom: 'none' }"
> >
<a-tab-pane key="define" :disabled="disabled"> <a-tab-pane key="define" :disabled="disabled">
<span style="font-size:12px;" slot="tab">定义</span> <span style="font-size:12px;" slot="tab">{{ $t('define') }}</span>
<PreValueTag type="add" :item="[]" @add="addNewValue" :disabled="disabled"> <PreValueTag type="add" :item="[]" @add="addNewValue" :disabled="disabled">
<template #default> <template #default>
<a-button <a-button
@ -17,7 +17,7 @@
:disabled="disabled" :disabled="disabled"
size="small" size="small"
> >
<a-icon type="plus" />添加</a-button <a-icon type="plus" />{{ $t('add') }}</a-button
> >
</template> </template>
</PreValueTag> </PreValueTag>
@ -41,9 +41,9 @@
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
>{{ `过滤` }} >{{ $t('cmdb.ciType.filter') }}
<a-tooltip <a-tooltip
title="返回的结果按字段来过滤,层级嵌套用##分隔比如k1##k2web请求返回{k1: [{k2: 1}, {k2: 2}]}, 解析结果为[1, 2]" :title="$t('cmdb.ciType.choiceWebhookTips')"
> >
<a-icon <a-icon
style="position:absolute;top:3px;left:-17px;color:#2f54eb;" style="position:absolute;top:3px;left:-17px;color:#2f54eb;"
@ -59,12 +59,12 @@
</a-form-model> </a-form-model>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="choice_other" :disabled="disabled"> <a-tab-pane key="choice_other" :disabled="disabled">
<span style="font-size:12px;" slot="tab">其他模型属性</span> <span style="font-size:12px;" slot="tab">{{ $t('cmdb.ciType.choiceOther') }}</span>
<a-row :gutter="[24, 24]"> <a-row :gutter="[24, 24]">
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item
:style="{ lineHeight: '24px', marginBottom: '5px' }" :style="{ lineHeight: '24px', marginBottom: '5px' }"
label="模型" :label="$t('cmdb.ciType.ciType')"
:label-col="{ span: 4 }" :label-col="{ span: 4 }"
:wrapper-col="{ span: 20 }" :wrapper-col="{ span: 20 }"
> >
@ -87,13 +87,13 @@
searchable searchable
:options="ciTypeGroup" :options="ciTypeGroup"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
placeholder="请选择CMDB模型" :placeholder="$t('cmdb.ciType.selectCIType')"
:normalizer=" :normalizer="
(node) => { (node) => {
return { return {
id: node.id || -1, id: node.id || -1,
label: node.alias || node.name || '其他', label: node.alias || node.name || $t('other'),
title: node.alias || node.name || '其他', title: node.alias || node.name || $t('other'),
children: node.ci_types, children: node.ci_types,
} }
} }
@ -120,7 +120,7 @@
<a-col :span="12" v-if="choice_other.type_ids && choice_other.type_ids.length"> <a-col :span="12" v-if="choice_other.type_ids && choice_other.type_ids.length">
<a-form-item <a-form-item
:style="{ marginBottom: '5px' }" :style="{ marginBottom: '5px' }"
label="属性" :label="$t('cmdb.ciType.attributes')"
:label-col="{ span: 4 }" :label-col="{ span: 4 }"
:wrapper-col="{ span: 20 }" :wrapper-col="{ span: 20 }"
> >
@ -133,13 +133,13 @@
searchable searchable
:options="typeAttrs" :options="typeAttrs"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
placeholder="请选择模型属性" :placeholder="$t('cmdb.ciType.selectCITypeAttributes')"
:normalizer=" :normalizer="
(node) => { (node) => {
return { return {
id: node.id || -1, id: node.id || -1,
label: node.alias || node.name || '其他', label: node.alias || node.name || $t('other'),
title: node.alias || node.name || '其他', title: node.alias || node.name || $t('other'),
} }
} }
" "
@ -161,7 +161,7 @@
<a-form-item <a-form-item
:style="{ marginBottom: '5px' }" :style="{ marginBottom: '5px' }"
class="pre-value-filter" class="pre-value-filter"
label="筛选" :label="$t('cmdb.ciType.filter')"
:label-col="{ span: 2 }" :label-col="{ span: 2 }"
:wrapper-col="{ span: 22 }" :wrapper-col="{ span: 22 }"
> >
@ -177,7 +177,7 @@
</a-row> </a-row>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="script" :disabled="disabled || !canDefineScript"> <a-tab-pane key="script" :disabled="disabled || !canDefineScript">
<span style="font-size:12px;" slot="tab">脚本</span> <span style="font-size:12px;" slot="tab">{{ $t('cmdb.ciType.code') }}</span>
<CustomCodeMirror <CustomCodeMirror
codeMirrorId="cmdb-pre-value" codeMirrorId="cmdb-pre-value"
ref="codemirror" ref="codemirror"
@ -232,7 +232,7 @@ export default {
typeAttrs: [], typeAttrs: [],
filterExp: '', filterExp: '',
script: script:
'class ChoiceValue(object):\n @staticmethod\n def values():\n """\n 执行入口, 返回预定义值\n :return: 返回一个列表, 值的类型同属性的类型\n 例如:\n return ["在线", "下线"]\n """\n return []', this.$t('cmdb.ciType.choiceScriptDemo'),
cmOptions: { cmOptions: {
lineNumbers: true, lineNumbers: true,
mode: 'python', mode: 'python',
@ -250,7 +250,7 @@ export default {
handler(newValue) { handler(newValue) {
const dom = document.querySelector('#preValueArea .ant-tabs-ink-bar') const dom = document.querySelector('#preValueArea .ant-tabs-ink-bar')
if (newValue) { if (newValue) {
// 如果是disabled 把tab 的ink-bar也置灰 // If it is disabled, the ink-bar of the tab will also be grayed out.
dom.style.backgroundColor = '#00000040' dom.style.backgroundColor = '#00000040'
} else { } else {
dom.style.backgroundColor = '#2f54eb' dom.style.backgroundColor = '#2f54eb'
@ -282,7 +282,7 @@ export default {
if (newValue) { if (newValue) {
const idx = this.valueList.findIndex((v) => v[0] === newValue) const idx = this.valueList.findIndex((v) => v[0] === newValue)
if (idx > -1) { if (idx > -1) {
this.$message.warning('当前值已存在!') this.$message.warning(this.$t('cmdb.ciType.valueExisted'))
} else { } else {
this.valueList.push([newValue, { style: newStyle, icon: { ...newIcon } }]) this.valueList.push([newValue, { style: newStyle, icon: { ...newIcon } }])
} }
@ -367,7 +367,7 @@ export default {
} }
const dom = document.querySelector('#preValueArea .ant-tabs-ink-bar') const dom = document.querySelector('#preValueArea .ant-tabs-ink-bar')
if (this.disabled) { if (this.disabled) {
// 如果是disabled 把tab 的ink-bar也置灰 // If it is disabled, the ink-bar of the tab will also be grayed out.
dom.style.backgroundColor = '#00000040' dom.style.backgroundColor = '#00000040'
} else { } else {
dom.style.backgroundColor = '#2f54eb' dom.style.backgroundColor = '#2f54eb'

View File

@ -11,9 +11,9 @@
> >
</a-input> </a-input>
<div ref="preValueEdit" slot="content"> <div ref="preValueEdit" slot="content">
<a-divider orientation="left" style="margin:8px 0;color:gray;font-size:10px;">图标</a-divider> <a-divider orientation="left" style="margin:8px 0;color:gray;font-size:10px;">{{ $t('icon') }}</a-divider>
<IconArea ref="iconArea" /> <IconArea ref="iconArea" />
<a-divider orientation="left" style="margin:8px 0;color:gray;font-size:10px;">字体</a-divider> <a-divider orientation="left" style="margin:8px 0;color:gray;font-size:10px;">{{ $t('cmdb.ciType.font') }}</a-divider>
<div :style="{ display: 'flex', justifyContent: 'space-around' }"> <div :style="{ display: 'flex', justifyContent: 'space-around' }">
<div <div
@click="changeFontStyle('fontWeight', 'bold')" @click="changeFontStyle('fontWeight', 'bold')"
@ -37,7 +37,7 @@
</div> </div>
</div> </div>
<a-divider orientation="left" style="margin:8px 0;color:gray;font-size:10px;">颜色</a-divider> <a-divider orientation="left" style="margin:8px 0;color:gray;font-size:10px;">{{ $t('cmdb.ciType.color') }}</a-divider>
<div :style="{ display: 'flex', justifyContent: 'space-around' }"> <div :style="{ display: 'flex', justifyContent: 'space-around' }">
<div class="attributes-font-color"> <div class="attributes-font-color">
<a-icon type="font-colors" /><el-color-picker <a-icon type="font-colors" /><el-color-picker
@ -56,11 +56,11 @@
</el-color-picker> </el-color-picker>
</div> </div>
</div> </div>
<a-divider orientation="left" style="margin:8px 0;color:gray;font-size:10px;">操作</a-divider> <a-divider orientation="left" style="margin:8px 0;color:gray;font-size:10px;">{{ $t('operation') }}</a-divider>
<div style="text-align:right;"> <div style="text-align:right;">
<a-tooltip <a-tooltip
v-if="type !== 'add'" v-if="type !== 'add'"
title="删除" :title="$t('delete')"
><a ><a
><a-icon ><a-icon
@click="handleDelete" @click="handleDelete"
@ -69,11 +69,11 @@
type="delete"/></a type="delete"/></a
></a-tooltip> ></a-tooltip>
<a-tooltip <a-tooltip
title="确定" :title="$t('confirm')"
><a><a-icon @click="handleEditOk" style="margin-right:10px;color:green;" type="check"/></a ><a><a-icon @click="handleEditOk" style="margin-right:10px;color:green;" type="check"/></a
></a-tooltip> ></a-tooltip>
<a-tooltip <a-tooltip
title="取消" :title="$t('cancel')"
><a ><a
><a-icon ><a-icon
@click=" @click="
@ -137,6 +137,9 @@ import _ from 'lodash'
import { ColorPicker } from 'element-ui' import { ColorPicker } from 'element-ui'
import { defautValueColor, defaultBGColors } from '../../utils/const' import { defautValueColor, defaultBGColors } from '../../utils/const'
import IconArea from './iconArea.vue' import IconArea from './iconArea.vue'
import lang from 'element-ui/lib/locale/lang/en'
import locale from 'element-ui/lib/locale'
locale.use(lang)
export default { export default {
name: 'PreValueTag', name: 'PreValueTag',
components: { ElColorPicker: ColorPicker, IconArea }, components: { ElColorPicker: ColorPicker, IconArea },

View File

@ -10,7 +10,7 @@
searchable searchable
:options="ciTypeADTAttributes" :options="ciTypeADTAttributes"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
placeholder="请选择属性" :placeholder="$t('cmdb.ciType.selectAttributes')"
:normalizer=" :normalizer="
(node) => { (node) => {
return { return {
@ -35,15 +35,15 @@
searchable searchable
:options="ciTypeGroup" :options="ciTypeGroup"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
placeholder="请选择模型" :placeholder="$t('cmdb.ciType.selectCIType')"
:disableBranchNodes="true" :disableBranchNodes="true"
@select="changeType(item)" @select="changeType(item)"
:normalizer=" :normalizer="
(node) => { (node) => {
return { return {
id: node.name || '其他', id: node.name || $t('other'),
label: node.alias || node.name || '其他', label: node.alias || node.name || $t('other'),
title: node.alias || node.name || '其他', title: node.alias || node.name || $t('other'),
children: node.ci_types, children: node.ci_types,
} }
} }
@ -67,7 +67,7 @@
searchable searchable
:options="item.attributes" :options="item.attributes"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
placeholder="请选择属性" :placeholder="$t('cmdb.ciType.selectAttributes')"
:normalizer=" :normalizer="
(node) => { (node) => {
return { return {
@ -89,7 +89,7 @@
</treeselect> </treeselect>
</div> </div>
<div class="relation-ad-footer"> <div class="relation-ad-footer">
<a-button type="primary" @click="handleSave">保存</a-button> <a-button type="primary" @click="handleSave">{{ $t('save') }}</a-button>
</div> </div>
</div> </div>
</template> </template>
@ -148,7 +148,7 @@ export default {
}, },
getCITypeDiscovery() { getCITypeDiscovery() {
getCITypeDiscovery(this.CITypeId).then(async (res) => { getCITypeDiscovery(this.CITypeId).then(async (res) => {
// 第一个下拉框的options // Options for the first drop-down box
const _ciTypeADTAttributes = [] const _ciTypeADTAttributes = []
res res
.filter((adt) => adt.adr_id) .filter((adt) => adt.adr_id)
@ -160,7 +160,7 @@ export default {
}) })
console.log(_ciTypeADTAttributes) console.log(_ciTypeADTAttributes)
this.ciTypeADTAttributes = _.uniqBy(_ciTypeADTAttributes, 'name') this.ciTypeADTAttributes = _.uniqBy(_ciTypeADTAttributes, 'name')
// 第一个下拉框的options // Options for the first drop-down box
const _find = res.find((adt) => !adt.adr_id) const _find = res.find((adt) => !adt.adr_id)
if (_find) { if (_find) {
this.adt_id = _find.id this.adt_id = _find.id
@ -242,7 +242,7 @@ export default {
} else { } else {
await postCITypeDiscovery(this.CITypeId, { relation: _relation }) await postCITypeDiscovery(this.CITypeId, { relation: _relation })
} }
this.$message.success('保存成功') this.$message.success(this.$t('saveSuccess'))
this.getCITypeDiscovery() this.getCITypeDiscovery()
} }
}, },

View File

@ -7,7 +7,7 @@
size="small" size="small"
class="ops-button-primary" class="ops-button-primary"
icon="plus" icon="plus"
>新增关系</a-button >{{ $t('cmdb.ciType.addRelation') }}</a-button
> >
<vxe-table <vxe-table
stripe stripe
@ -20,15 +20,15 @@
class="ops-stripe-table" class="ops-stripe-table"
:row-class-name="rowClass" :row-class-name="rowClass"
> >
<vxe-column field="source_ci_type_name" title="源模型英文名"></vxe-column> <vxe-column field="source_ci_type_name" :title="$t('cmdb.ciType.sourceCIType')"></vxe-column>
<vxe-column field="relation_type" title="关联类型"> <vxe-column field="relation_type" :title="$t('cmdb.ciType.relationType')">
<template #default="{row}"> <template #default="{row}">
<span style="color:#2f54eb" v-if="row.isParent"></span> <span style="color:#2f54eb" v-if="row.isParent">{{ $t('cmdb.ciType.isParent') }}</span>
{{ row.relation_type }} {{ row.relation_type }}
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="alias" title="目标模型名"></vxe-column> <vxe-column field="alias" :title="$t('cmdb.ciType.dstCIType')"></vxe-column>
<vxe-column field="constraint" title="关系约束"> <vxe-column field="constraint" :title="$t('cmdb.ciType.relationConstraint')">
<template #default="{row}"> <template #default="{row}">
<span v-if="row.isParent && constraintMap[row.constraint]">{{ <span v-if="row.isParent && constraintMap[row.constraint]">{{
constraintMap[row.constraint] constraintMap[row.constraint]
@ -39,11 +39,11 @@
<span v-else>{{ constraintMap[row.constraint] }}</span> <span v-else>{{ constraintMap[row.constraint] }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="operation" title="操作" width="100"> <vxe-column field="operation" :title="$t('operation')" width="100">
<template #default="{row}"> <template #default="{row}">
<a-space v-if="!row.isParent && row.source_ci_type_id"> <a-space v-if="!row.isParent && row.source_ci_type_id">
<a @click="handleOpenGrant(row)"><a-icon type="user-add"/></a> <a @click="handleOpenGrant(row)"><a-icon type="user-add"/></a>
<a-popconfirm title="确认删除?" @confirm="handleDelete(row)"> <a-popconfirm :title="$t('cmdb.ciType.confirmDelete2')" @confirm="handleDelete(row)">
<a style="color: red;"><a-icon type="delete"/></a> <a style="color: red;"><a-icon type="delete"/></a>
</a-popconfirm> </a-popconfirm>
</a-space> </a-space>
@ -52,7 +52,7 @@
<template #empty> <template #empty>
<div> <div>
<img :style="{ width: '100px' }" :src="require('@/assets/data_empty.png')" /> <img :style="{ width: '100px' }" :src="require('@/assets/data_empty.png')" />
<div>暂无数据</div> <div>{{ $t('noData') }}</div>
</div> </div>
</template> </template>
</vxe-table> </vxe-table>
@ -65,21 +65,24 @@
width="500px" width="500px"
> >
<a-form :form="form" @submit="handleSubmit" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }"> <a-form :form="form" @submit="handleSubmit" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }">
<a-form-item label="源模型"> <a-form-item :label="$t('cmdb.ciType.sourceCIType')">
<a-select <a-select
name="source_ci_type_id" name="source_ci_type_id"
v-decorator="['source_ci_type_id', { rules: [{ required: true, message: '请选择源模型' }] }]" v-decorator="[
'source_ci_type_id',
{ rules: [{ required: true, message: $t('cmdb.ciType.sourceCITypeTips') }] },
]"
> >
<a-select-option :value="CIType.id" :key="CIType.id" v-for="CIType in displayCITypes">{{ <a-select-option :value="CIType.id" :key="CIType.id" v-for="CIType in displayCITypes">{{
CIType.alias CIType.alias
}}</a-select-option> }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="目标模型"> <a-form-item :label="$t('cmdb.ciType.dstCIType')">
<a-select <a-select
showSearch showSearch
name="ci_type_id" name="ci_type_id"
v-decorator="['ci_type_id', { rules: [{ required: true, message: '请选择目标模型' }] }]" v-decorator="['ci_type_id', { rules: [{ required: true, message: $t('cmdb.ciType.dstCITypeTips') }] }]"
:filterOption="filterOption" :filterOption="filterOption"
> >
<a-select-option :value="CIType.id" :key="CIType.id" v-for="CIType in CITypes"> <a-select-option :value="CIType.id" :key="CIType.id" v-for="CIType in CITypes">
@ -88,10 +91,13 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="关联关系"> <a-form-item :label="$t('cmdb.ciType.relationType')">
<a-select <a-select
name="relation_type_id" name="relation_type_id"
v-decorator="['relation_type_id', { rules: [{ required: true, message: '请选择关联关系' }] }]" v-decorator="[
'relation_type_id',
{ rules: [{ required: true, message: $t('cmdb.ciType.relationTypeTips') }] },
]"
> >
<a-select-option :value="relationType.id" :key="relationType.id" v-for="relationType in relationTypes">{{ <a-select-option :value="relationType.id" :key="relationType.id" v-for="relationType in relationTypes">{{
relationType.name relationType.name
@ -99,11 +105,16 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="关联约束"> <a-form-item :label="$t('cmdb.ciType.relationConstraint')">
<a-select v-decorator="['constraint', { rules: [{ required: true, message: '请选择关联约束' }] }]"> <a-select
<a-select-option value="0">一对多</a-select-option> v-decorator="[
<a-select-option value="1">一对一</a-select-option> 'constraint',
<a-select-option value="2">多对多</a-select-option> { rules: [{ required: true, message: $t('cmdb.ciType.relationConstraintTips') }] },
]"
>
<a-select-option value="0">{{ $t('cmdb.ciType.one2Many') }}</a-select-option>
<a-select-option value="1">{{ $t('cmdb.ciType.one2One') }}</a-select-option>
<a-select-option value="2">{{ $t('cmdb.ciType.many2Many') }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-form> </a-form>
@ -145,11 +156,6 @@ export default {
drawerTitle: '', drawerTitle: '',
CITypes: [], CITypes: [],
relationTypes: [], relationTypes: [],
constraintMap: {
'0': '一对多',
'1': '一对一',
'2': '多对多',
},
tableData: [], tableData: [],
parentTableData: [], parentTableData: [],
} }
@ -161,6 +167,13 @@ export default {
windowHeight() { windowHeight() {
return this.$store.state.windowHeight return this.$store.state.windowHeight
}, },
constraintMap() {
return {
'0': this.$t('cmdb.ciType.one2Many'),
'1': this.$t('cmdb.ciType.one2One'),
'2': this.$t('cmdb.ciType.many2Many'),
}
},
}, },
async mounted() { async mounted() {
this.getCITypes() this.getCITypes()
@ -209,7 +222,7 @@ export default {
}, },
handleDelete(record) { handleDelete(record) {
deleteRelation(record.source_ci_type_id, record.id).then((res) => { deleteRelation(record.source_ci_type_id, record.id).then((res) => {
this.$message.success(`删除成功`) this.$message.success(this.$t('deleteSuccess'))
this.handleOk() this.handleOk()
}) })
}, },
@ -218,7 +231,7 @@ export default {
}, },
handleCreate() { handleCreate() {
this.drawerTitle = '新增关系' this.drawerTitle = this.$t('cmdb.ciType.addRelation')
this.visible = true this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue({ this.form.setFieldsValue({
@ -241,7 +254,7 @@ export default {
createRelation(values.source_ci_type_id, values.ci_type_id, values.relation_type_id, values.constraint).then( createRelation(values.source_ci_type_id, values.ci_type_id, values.relation_type_id, values.constraint).then(
(res) => { (res) => {
this.$message.success(`添加成功`) this.$message.success(this.$t('addSuccess'))
this.onClose() this.onClose()
this.handleOk() this.handleOk()
} }

View File

@ -1,61 +1,70 @@
<template> <template>
<CustomDrawer <CustomDrawer
wrapClassName="trigger-form" wrapClassName="trigger-form"
:width="700" :width="910"
:title="title" :title="title"
:visible="visible" :visible="visible"
@close="handleCancel" @close="handleCancel"
@ok="handleOk" @ok="handleOk"
> >
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button type="primary" ghost @click="handleCancel">取消</a-button> <a-button type="primary" ghost @click="handleCancel">{{ $t('cancel') }}</a-button>
<a-button v-if="triggerId" type="danger" @click="handleDetele">删除</a-button> <a-button v-if="triggerId" type="danger" @click="handleDetele">{{ $t('delete') }}</a-button>
<a-button @click="handleOk" type="primary">确定</a-button> <a-button @click="handleOk" type="primary">{{ $t('confirm') }}</a-button>
</div> </div>
<a-form-model ref="triggerForm" :model="form" :rules="rules" :label-col="{ span: 3 }" :wrapper-col="{ span: 18 }"> <a-form-model ref="triggerForm" :model="form" :rules="rules" :label-col="{ span: 3 }" :wrapper-col="{ span: 18 }">
<p><strong>基本信息</strong></p> <p>
<a-form-model-item label="名称" prop="name"> <strong>{{ $t('cmdb.ciType.basicInfo') }}</strong>
<a-input v-model="form.name" placeholder="请输入名称" /> </p>
<a-form-model-item :label="$t('name')" prop="name">
<a-input v-model="form.name" :placeholder="$t('cmdb.ciType.nameInputTips')" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="类型"> <a-form-model-item :label="$t('type')">
<a-radio-group v-model="category"> <a-radio-group v-model="category">
<a-radio-button :value="1"> <a-radio-button :value="1">
数据变更 {{ $t('cmdb.ciType.triggerDataChange') }}
</a-radio-button> </a-radio-button>
<a-radio-button :value="2"> <a-radio-button :value="2">
日期属性 {{ $t('cmdb.ciType.triggerDate') }}
</a-radio-button> </a-radio-button>
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="备注" prop="description"> <a-form-model-item :label="$t('desc')" prop="description">
<a-input v-model="form.description" placeholder="请输入备注" /> <a-input v-model="form.description" :placeholder="$t('cmdb.ciType.descInput')" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="开启" prop="enable"> <a-form-model-item :label="$t('cmdb.ciType.triggerEnable')" prop="enable">
<a-switch v-model="form.enable" /> <a-switch v-model="form.enable" />
</a-form-model-item> </a-form-model-item>
<template v-if="category === 1"> <template v-if="category === 1">
<p><strong>触发条件</strong></p> <p>
<a-form-model-item label="事件" prop="action"> <strong>{{ $t('cmdb.ciType.triggerCondition') }}</strong>
</p>
<a-form-model-item :label="$t('cmdb.ciType.event')" prop="action">
<a-radio-group v-model="form.action"> <a-radio-group v-model="form.action">
<a-radio value="0"> <a-radio value="0">
新增实例 {{ $t('cmdb.ciType.addInstance') }}
</a-radio> </a-radio>
<a-radio value="1"> <a-radio value="1">
删除实例 {{ $t('cmdb.ciType.deleteInstance') }}
</a-radio> </a-radio>
<a-radio value="2"> <a-radio value="2">
实例变更 {{ $t('cmdb.ciType.changeInstance') }}
</a-radio> </a-radio>
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
<a-form-model-item v-if="form.action === '2'" label="属性" prop="attr_ids"> <a-form-model-item v-if="form.action === '2'" :label="$t('cmdb.ciType.attributes')" prop="attr_ids">
<a-select v-model="form.attr_ids" show-search mode="multiple" placeholder="请选择属性(多选)"> <a-select
v-model="form.attr_ids"
show-search
mode="multiple"
:placeholder="$t('cmdb.ciType.selectMutipleAttributes')"
>
<a-select-option v-for="attr in attrList" :key="attr.id" :value="attr.id">{{ <a-select-option v-for="attr in attrList" :key="attr.id" :value="attr.id">{{
attr.alias || attr.name attr.alias || attr.name
}}</a-select-option> }}</a-select-option>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="筛选" class="trigger-form-filter"> <a-form-model-item :label="$t('cmdb.ciType.filter')" class="trigger-form-filter">
<FilterComp <FilterComp
ref="filterComp" ref="filterComp"
:isDropdown="false" :isDropdown="false"
@ -67,7 +76,9 @@
</template> </template>
</a-form-model> </a-form-model>
<template v-if="category === 2"> <template v-if="category === 2">
<p><strong>触发条件</strong></p> <p>
<strong>{{ $t('cmdb.ciType.triggerCondition') }}</strong>
</p>
<a-form-model <a-form-model
ref="dateForm" ref="dateForm"
:model="dateForm" :model="dateForm"
@ -75,14 +86,14 @@
:label-col="{ span: 3 }" :label-col="{ span: 3 }"
:wrapper-col="{ span: 18 }" :wrapper-col="{ span: 18 }"
> >
<a-form-model-item label="属性" prop="attr_id"> <a-form-model-item :label="$t('cmdb.ciType.attributes')" prop="attr_id">
<a-select v-model="dateForm.attr_id" placeholder="请选择属性(单选)"> <a-select v-model="dateForm.attr_id" :placeholder="$t('cmdb.ciType.selectSingleAttribute')">
<a-select-option v-for="attr in canAddTriggerAttr" :key="attr.id" :value="attr.id">{{ <a-select-option v-for="attr in canAddTriggerAttr" :key="attr.id" :value="attr.id">{{
attr.alias || attr.name attr.alias || attr.name
}}</a-select-option> }}</a-select-option>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="筛选" class="trigger-form-filter"> <a-form-model-item :label="$t('cmdb.ciType.filter')" class="trigger-form-filter">
<FilterComp <FilterComp
ref="filterComp" ref="filterComp"
:isDropdown="false" :isDropdown="false"
@ -91,22 +102,24 @@
:expression="filterExp ? `q=${filterExp}` : ''" :expression="filterExp ? `q=${filterExp}` : ''"
/> />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="提前" prop="before_days"> <a-form-model-item :label="$t('cmdb.ciType.beforeDays')" prop="before_days">
<a-input-number v-model="dateForm.before_days" :min="0" /> <a-input-number v-model="dateForm.before_days" :min="0" />
{{ $t('cmdb.ciType.days') }}
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="发送时间" prop="notify_at"> <a-form-model-item :label="$t('cmdb.ciType.notifyAt')" prop="notify_at">
<a-time-picker v-model="dateForm.notify_at" format="HH:mm" valueFormat="HH:mm" /> <a-time-picker v-model="dateForm.notify_at" format="HH:mm" valueFormat="HH:mm" />
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
</template> </template>
<p><strong>触发动作</strong></p> <p>
<strong>{{ $t('cmdb.ciType.triggerAction') }}</strong>
</p>
<a-radio-group <a-radio-group
v-model="triggerAction" v-model="triggerAction"
:style="{ width: '100%', display: 'flex', justifyContent: 'space-around', marginBottom: '10px' }" :style="{ width: '100%', display: 'flex', justifyContent: 'space-around', marginBottom: '10px' }"
> >
<a-radio value="1"> <a-radio value="1">
通知 {{ $t('cmdb.ciType.notify') }}
</a-radio> </a-radio>
<a-radio value="2"> <a-radio value="2">
Webhook Webhook
@ -126,13 +139,13 @@
<a-form-model-item label=" " :colon="false"> <a-form-model-item label=" " :colon="false">
<span class="trigger-tips">{{ tips }}</span> <span class="trigger-tips">{{ tips }}</span>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="收件人" prop="employee_ids" class="trigger-form-employee"> <a-form-model-item :label="$t('cmdb.ciType.receivers')" prop="employee_ids" class="trigger-form-employee">
<EmployeeTreeSelect multiple v-model="notifies.employee_ids" /> <EmployeeTreeSelect multiple v-model="notifies.employee_ids" />
<div class="trigger-form-custom-email"> <div class="trigger-form-custom-email">
<a-textarea <a-textarea
v-if="showCustomEmail" v-if="showCustomEmail"
v-model="notifies.custom_email" v-model="notifies.custom_email"
placeholder="请输入邮箱,多个邮箱用;分隔" :placeholder="$t('cmdb.ciType.emailTips')"
:rows="1" :rows="1"
/> />
<a-button <a-button
@ -144,37 +157,41 @@
type="primary" type="primary"
size="small" size="small"
class="ops-button-primary" class="ops-button-primary"
>{{ `${showCustomEmail ? '删除' : '添加'}自定义收件人` }}</a-button >{{ `${showCustomEmail ? $t('delete') : $t('add')}` }}{{ $t('cmdb.ciType.customEmail') }}</a-button
> >
</div> </div>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="通知标题" prop="subject"> <a-form-model-item :label="$t('cmdb.ciType.notifySubject')" prop="subject">
<a-input v-model="notifies.subject" placeholder="请输入通知标题" /> <a-input v-model="notifies.subject" :placeholder="$t('cmdb.ciType.notifySubjectTips')" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="内容" prop="body" :wrapper-col="{ span: 21 }"> <a-form-model-item :label="$t('cmdb.ciType.notifyContent')" prop="body" :wrapper-col="{ span: 21 }">
<NoticeContent :needOld="category === 1 && form.action === '2'" :attrList="attrList" ref="noticeContent" /> <NoticeContent :needOld="category === 1 && form.action === '2'" :attrList="attrList" ref="noticeContent" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="通知方式" prop="method"> <a-form-model-item :label="$t('cmdb.ciType.notifyMethod')" prop="method">
<a-checkbox-group v-model="notifies.method"> <a-checkbox-group v-model="notifies.method">
<a-row :style="{ marginTop: '4px' }" :gutter="[0, 12]"> <a-row :style="{ marginTop: '4px' }" :gutter="[0, 12]">
<a-col :span="6"> <a-col :span="6">
<a-checkbox value="email"> <ops-icon type="email" style="margin-right:5px" />邮件 </a-checkbox> <a-checkbox value="email">
<ops-icon type="email" style="margin-right:5px" />{{ $t('email') }}
</a-checkbox>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
<a-checkbox value="wechatApp"> <a-checkbox value="wechatApp">
<ops-icon type="wechatApp" style="margin-right:5px" />企业微信 <ops-icon type="wechatApp" style="margin-right:5px" />{{ $t('wechat') }}
</a-checkbox> </a-checkbox>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
<a-checkbox value="dingdingApp"> <a-checkbox value="dingdingApp">
<ops-icon type="dingdingApp" style="margin-right:5px" />钉钉 <ops-icon type="dingdingApp" style="margin-right:5px" />{{ $t('dingding') }}
</a-checkbox> </a-checkbox>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
<a-checkbox value="feishuApp"> <ops-icon type="feishuApp" style="margin-right:5px" />飞书 </a-checkbox> <a-checkbox value="feishuApp">
<ops-icon type="feishuApp" style="margin-right:5px" />{{ $t('feishu') }}
</a-checkbox>
</a-col> </a-col>
<a-col :span="4" :style="{ lineHeight: '32px' }"> <a-col :span="4" :style="{ lineHeight: '32px' }">
<ops-icon type="robot" style="margin-right:5px" />机器人 <ops-icon type="robot" style="margin-right:5px" />{{ $t('bot') }}
</a-col> </a-col>
<a-col :span="18"> <a-col :span="18">
<treeselect <treeselect
@ -196,7 +213,7 @@
searchable searchable
:options="appBot" :options="appBot"
value-consists-of="LEAF_PRIORITY" value-consists-of="LEAF_PRIORITY"
placeholder="请选择机器人" :placeholder="$t('cmdb.ciType.botSelect')"
:normalizer=" :normalizer="
(node) => { (node) => {
return { return {
@ -208,7 +225,7 @@
" "
appendToBody appendToBody
:zIndex="1050" :zIndex="1050"
noChildrenText="暂无数据" :noChildrenText="$t('noData')"
> >
<div <div
:title="node.label" :title="node.label"
@ -297,24 +314,22 @@ export default {
defaultForm, defaultForm,
defaultDateForm, defaultDateForm,
defaultNotify, defaultNotify,
tips: '标题、内容可以引用该模型的属性值,引用方法为: {{ attr_name }}',
webhookTips: '请求参数可以引用该模型的属性值,引用方法为: {{ attr_name }}',
visible: false, visible: false,
category: 1, category: 1,
form: _.cloneDeep(defaultForm), form: _.cloneDeep(defaultForm),
rules: { rules: {
name: [{ required: true, message: '请填写名称' }], name: [{ required: true, message: this.$t('cmdb.ciType.nameInputTips') }],
}, },
dateForm: _.cloneDeep(defaultDateForm), dateForm: _.cloneDeep(defaultDateForm),
dateFormRules: { dateFormRules: {
attr_id: [{ required: true, message: '请选择属性' }], attr_id: [{ required: true, message: this.$t('cmdb.ciType.selectAttributes') }],
}, },
notifies: _.cloneDeep(defaultNotify), notifies: _.cloneDeep(defaultNotify),
notifiesRules: {}, notifiesRules: {},
WxUsers: [], WxUsers: [],
filterValue: '', filterValue: '',
triggerId: null, triggerId: null,
title: '新增触发器', title: this.$t('cmdb.ciType.newTrigger'),
attrList: [], attrList: [],
filterExp: '', filterExp: '',
triggerAction: '1', triggerAction: '1',
@ -337,6 +352,12 @@ export default {
} }
return this.dags return this.dags
}, },
tips() {
return this.$t('cmdb.ciType.refAttributeTips')
},
webhookTips() {
return this.$t('cmdb.ciType.webhookRefAttributeTips')
},
}, },
inject: { inject: {
refresh: { refresh: {
@ -356,7 +377,7 @@ export default {
this.getNoticeConfigAppBot() this.getNoticeConfigAppBot()
this.attrList = attrList this.attrList = attrList
this.triggerId = null this.triggerId = null
this.title = '新增触发器' this.title = this.$t('cmdb.ciType.newTrigger')
this.form = _.cloneDeep(this.defaultForm) this.form = _.cloneDeep(this.defaultForm)
this.dateForm = _.cloneDeep(this.defaultDateForm) this.dateForm = _.cloneDeep(this.defaultDateForm)
this.notifies = _.cloneDeep(this.defaultNotify) this.notifies = _.cloneDeep(this.defaultNotify)
@ -376,7 +397,7 @@ export default {
this.attrList = attrList this.attrList = attrList
if (property.has_trigger) { if (property.has_trigger) {
this.triggerId = property.trigger.id this.triggerId = property.trigger.id
this.title = `编辑触发器 ${property.alias || property.name}` this.title = this.$t('cmdb.ciType.editTriggerTitle', { name: `${property.alias || property.name}` })
const { name, description, enable, action = '0', attr_ids, filter = '' } = property?.trigger?.option ?? {} const { name, description, enable, action = '0', attr_ids, filter = '' } = property?.trigger?.option ?? {}
this.filterExp = filter this.filterExp = filter
this.$nextTick(() => { this.$nextTick(() => {
@ -437,7 +458,7 @@ export default {
this.notifies = { employee_ids, custom_email, subject, method: _method } this.notifies = { employee_ids, custom_email, subject, method: _method }
} }
} else { } else {
this.title = `新增触发器 ${property.alias || property.name}` this.title = this.$t('cmdb.ciType.newTriggerTitle', { name: `${property.alias || property.name}` })
this.triggerId = null this.triggerId = null
this.form = _.cloneDeep(this.defaultForm) this.form = _.cloneDeep(this.defaultForm)
} }
@ -556,11 +577,11 @@ export default {
handleDetele() { handleDetele() {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认删除该触发器吗?', content: that.$t('cmdb.ciType.confirmDeleteTrigger'),
onOk() { onOk() {
deleteTrigger(that.CITypeId, that.triggerId).then(() => { deleteTrigger(that.CITypeId, that.triggerId).then(() => {
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.handleCancel() that.handleCancel()
if (that.refresh) { if (that.refresh) {
that.refresh() that.refresh()

View File

@ -7,10 +7,10 @@
size="small" size="small"
class="ops-button-primary" class="ops-button-primary"
icon="plus" icon="plus"
>新增触发器</a-button >{{ $t('cmdb.ciType.newTrigger') }}</a-button
> >
</div> </div>
<vxe-table <ops-table
stripe stripe
:data="tableData" :data="tableData"
size="small" size="small"
@ -20,40 +20,20 @@
:max-height="windowHeight - 180" :max-height="windowHeight - 180"
class="ops-stripe-table" class="ops-stripe-table"
> >
<vxe-column field="option.name" title="名称"></vxe-column> <vxe-column field="option.name" :title="$t('name')"></vxe-column>
<vxe-column field="option.description" title="备注"></vxe-column> <vxe-column field="option.description" :title="$t('desc')"></vxe-column>
<vxe-column field="type" title="类型"> <vxe-column field="type" :title="$t('type')">
<template #default="{ row }"> <template #default="{ row }">
<span v-if="row.attr_id">日期属性</span> <span v-if="row.attr_id">{{ $t('cmdb.ciType.triggerDate') }}</span>
<span v-else>数据变更</span> <span v-else>{{ $t('cmdb.ciType.triggerDataChange') }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="option.enable" title="开启"> <vxe-column field="option.enable" :title="$t('cmdb.ciType.triggerEnable')">
<template #default="{ row }"> <template #default="{ row }">
<a-switch :checked="row.option.enable" @click="changeEnable(row)"></a-switch> <a-switch :checked="row.option.enable" @click="changeEnable(row)"></a-switch>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="operation" :title="$t('operation')" width="100px" align="center">
<!-- <vxe-column field="attr_name" title="属性名"></vxe-column>
<vxe-column field="option.subject" title="主题"></vxe-column>
<vxe-column field="option.body" title="内容"></vxe-column>
<vxe-column field="option.wx_to" title="微信通知">
<template #default="{ row }">
<span v-for="(person, index) in row.option.wx_to" :key="person + index">[{{ person }}]</span>
</template>
</vxe-column>
<vxe-column field="option.mail_to" title="邮件通知">
<template #default="{ row }">
<span v-for="(email, index) in row.option.mail_to" :key="email + index">[{{ email }}]</span>
</template>
</vxe-column>
<vxe-column field="option.before_days" title="提前">
<template #default="{ row }">
<span v-if="row.option.before_days">{{ row.option.before_days }}</span>
</template>
</vxe-column>
<vxe-column field="option.notify_at" title="发送时间"></vxe-column> -->
<vxe-column field="operation" title="操作" width="80px" align="center">
<template #default="{ row }"> <template #default="{ row }">
<a-space> <a-space>
<a @click="handleEdit(row)"><a-icon type="edit"/></a> <a @click="handleEdit(row)"><a-icon type="edit"/></a>
@ -61,7 +41,7 @@
</a-space> </a-space>
</template> </template>
</vxe-column> </vxe-column>
</vxe-table> </ops-table>
<TriggerForm ref="triggerForm" :CITypeId="CITypeId" /> <TriggerForm ref="triggerForm" :CITypeId="CITypeId" />
</div> </div>
</template> </template>
@ -118,11 +98,11 @@ export default {
handleDetele(id) { handleDetele(id) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认删除该触发器吗?', content: that.$t('cmdb.ciType.confirmDeleteTrigger'),
onOk() { onOk() {
deleteTrigger(that.CITypeId, id).then(() => { deleteTrigger(that.CITypeId, id).then(() => {
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.getTableData() that.getTableData()
}) })
}, },

View File

@ -7,9 +7,9 @@
icon="plus" icon="plus"
size="small" size="small"
:style="{ marginBottom: '10px' }" :style="{ marginBottom: '10px' }"
>新增</a-button >{{ $t('new') }}</a-button
> >
<vxe-table <ops-table
:loading="loading" :loading="loading"
:data="tableData" :data="tableData"
:edit-config="{ trigger: 'manual', mode: 'row', showIcon: false, autoClear: false, showStatus: true }" :edit-config="{ trigger: 'manual', mode: 'row', showIcon: false, autoClear: false, showStatus: true }"
@ -18,8 +18,10 @@
ref="xTable" ref="xTable"
size="mini" size="mini"
keep-source keep-source
stripe
class="ops-stripe-table"
> >
<vxe-column field="attr_ids" title="属性" :edit-render="{}"> <vxe-column field="attr_ids" :title="$t('cmdb.ciType.attributes')" :edit-render="{}">
<template #default="{ row }"> <template #default="{ row }">
<template v-for="(attr, index) in row.attr_ids"> <template v-for="(attr, index) in row.attr_ids">
<span :key="attr" :style="{ color: '#2f54eb' }">{{ getDisplayName(attr) }}</span> <span :key="attr" :style="{ color: '#2f54eb' }">{{ getDisplayName(attr) }}</span>
@ -37,9 +39,9 @@
</vxe-select> </vxe-select>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column filed="opeartion" title="操作" width="100"> <vxe-column filed="opeartion" :title="$t('operation')" width="100">
<template #default="{ row }"> <template #default="{ row }">
<template v-if="$refs.xTable.isActiveByRow(row)"> <template v-if="$refs.xTable.getVxetableRef().isActiveByRow(row)">
<a-space> <a-space>
<a> <a-icon @click="saveRowEvent(row)" type="save"/></a> <a> <a-icon @click="saveRowEvent(row)" type="save"/></a>
</a-space> </a-space>
@ -47,14 +49,14 @@
<template v-else> <template v-else>
<a-space> <a-space>
<a> <a-icon @click="editRowEvent(row)" type="edit"/></a> <a> <a-icon @click="editRowEvent(row)" type="edit"/></a>
<a-popconfirm title="确认删除?" @confirm="removeRowEvent(row)"> <a-popconfirm :title="$t('cmdb.ciType.confirmDelete2')" @confirm="removeRowEvent(row)">
<a :style="{ color: 'red' }"> <a-icon type="delete"/></a> <a :style="{ color: 'red' }"> <a-icon type="delete"/></a>
</a-popconfirm> </a-popconfirm>
</a-space> </a-space>
</template> </template>
</template> </template>
</vxe-column> </vxe-column>
</vxe-table> </ops-table>
</a-modal> </a-modal>
</template> </template>
@ -98,7 +100,7 @@ export default {
}) })
}, },
async handleAddUnique(row) { async handleAddUnique(row) {
const $table = this.$refs.xTable const $table = this.$refs.xTable.getVxetableRef()
const record = { const record = {
attr_ids: [], attr_ids: [],
} }
@ -106,7 +108,7 @@ export default {
await $table.setActiveRow(newRow) await $table.setActiveRow(newRow)
}, },
saveRowEvent(row) { saveRowEvent(row) {
const $table = this.$refs.xTable const $table = this.$refs.xTable.getVxetableRef()
$table.clearActived().then(() => { $table.clearActived().then(() => {
if (row.id) { if (row.id) {
updateUniqueConstraint(this.CITypeId, row.id, { attr_ids: row.attr_ids }).then((res) => { updateUniqueConstraint(this.CITypeId, row.id, { attr_ids: row.attr_ids }).then((res) => {
@ -120,12 +122,12 @@ export default {
}) })
}, },
editRowEvent(row) { editRowEvent(row) {
const $table = this.$refs.xTable const $table = this.$refs.xTable.getVxetableRef()
$table.setActiveRow(row) $table.setActiveRow(row)
}, },
removeRowEvent(row) { removeRowEvent(row) {
deleteUniqueConstraint(this.CITypeId, row.id).then((res) => { deleteUniqueConstraint(this.CITypeId, row.id).then((res) => {
this.$message.success('删除成功!') this.$message.success(this.$t('deleteSuccess'))
this.getTableList() this.getTableList()
}) })
}, },

View File

@ -53,7 +53,7 @@
<span>{{ row[`key${index}`] }}</span> <span>{{ row[`key${index}`] }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="value" title="数量"></vxe-column> <vxe-column field="value" :title="$t('cmdb.custom_dashboard.quantity')"></vxe-column>
</template> </template>
</vxe-table> </vxe-table>
<div <div

View File

@ -1,7 +1,7 @@
<template> <template>
<a-modal <a-modal
width="1100px" width="1200px"
:title="`${type === 'add' ? '新增' : '编辑'}图表`" :title="`${type === 'add' ? $t('cmdb.custom_dashboard.newChart') : $t('cmdb.custom_dashboard.editChart')}`"
:visible="visible" :visible="visible"
@cancel="handleclose" @cancel="handleclose"
@ok="handleok" @ok="handleok"
@ -10,10 +10,10 @@
<div class="chart-wrapper"> <div class="chart-wrapper">
<div class="chart-left"> <div class="chart-left">
<a-form-model ref="chartForm" :model="form" :rules="rules" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }"> <a-form-model ref="chartForm" :model="form" :rules="rules" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
<a-form-model-item label="标题" prop="name"> <a-form-model-item :label="$t('cmdb.custom_dashboard.title')" prop="name">
<a-input v-model="form.name" placeholder="请输入图表标题"></a-input> <a-input v-model="form.name" :placeholder="$t('cmdb.custom_dashboard.titleTips')"></a-input>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="类型" prop="category" v-if="chartType !== 'count' && chartType !== 'table'"> <a-form-model-item :label="$t('type')" prop="category" v-if="chartType !== 'count' && chartType !== 'table'">
<a-radio-group <a-radio-group
@change=" @change="
() => { () => {
@ -28,7 +28,7 @@
</a-radio-button> </a-radio-button>
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="类型" prop="tableCategory" v-if="chartType === 'table'"> <a-form-model-item :label="$t('type')" prop="tableCategory" v-if="chartType === 'table'">
<a-radio-group <a-radio-group
@change=" @change="
() => { () => {
@ -39,16 +39,16 @@
v-model="form.tableCategory" v-model="form.tableCategory"
> >
<a-radio-button :value="1"> <a-radio-button :value="1">
计算指标 {{ $t('cmdb.custom_dashboard.calcIndicators') }}
</a-radio-button> </a-radio-button>
<a-radio-button :value="2"> <a-radio-button :value="2">
资源数据 {{ $t('cmdb.menu.ciTable') }}
</a-radio-button> </a-radio-button>
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
<a-form-model-item <a-form-model-item
v-if="(chartType !== 'table' && form.category !== 2) || (chartType === 'table' && form.tableCategory === 1)" v-if="(chartType !== 'table' && form.category !== 2) || (chartType === 'table' && form.tableCategory === 1)"
label="模型" :label="$t('cmdb.ciType.ciType')"
prop="type_ids" prop="type_ids"
> >
<a-select <a-select
@ -56,7 +56,7 @@
optionFilterProp="children" optionFilterProp="children"
@change="changeCIType" @change="changeCIType"
v-model="form.type_ids" v-model="form.type_ids"
placeholder="请选择模型" :placeholder="$t('cmdb.ciType.selectCIType')"
mode="multiple" mode="multiple"
> >
<a-select-option v-for="ci_type in ci_types" :key="ci_type.id" :value="ci_type.id">{{ <a-select-option v-for="ci_type in ci_types" :key="ci_type.id" :value="ci_type.id">{{
@ -64,13 +64,13 @@
}}</a-select-option> }}</a-select-option>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
<a-form-model-item v-else label="模型" prop="type_id"> <a-form-model-item v-else :label="$t('cmdb.ciType.ciType')" prop="type_id">
<a-select <a-select
show-search show-search
optionFilterProp="children" optionFilterProp="children"
@change="changeCIType" @change="changeCIType"
v-model="form.type_id" v-model="form.type_id"
placeholder="请选择模型" :placeholder="$t('cmdb.ciType.selectCIType')"
> >
<a-select-option v-for="ci_type in ci_types" :key="ci_type.id" :value="ci_type.id">{{ <a-select-option v-for="ci_type in ci_types" :key="ci_type.id" :value="ci_type.id">{{
ci_type.alias || ci_type.name ci_type.alias || ci_type.name
@ -78,7 +78,7 @@
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
<a-form-model-item <a-form-model-item
label="维度" :label="$t('cmdb.custom_dashboard.dimensions')"
prop="attr_ids" prop="attr_ids"
v-if="(['bar', 'line', 'pie'].includes(chartType) && form.category === 1) || chartType === 'table'" v-if="(['bar', 'line', 'pie'].includes(chartType) && form.category === 1) || chartType === 'table'"
> >
@ -86,7 +86,7 @@
:filter-option="filterOption" :filter-option="filterOption"
@change="changeAttr" @change="changeAttr"
v-model="form.attr_ids" v-model="form.attr_ids"
placeholder="请选择维度" :placeholder="$t('cmdb.custom_dashboard.selectDimensions')"
mode="multiple" mode="multiple"
show-search show-search
> >
@ -100,7 +100,7 @@
</a-form-model-item> </a-form-model-item>
<a-form-model-item <a-form-model-item
prop="type_ids" prop="type_ids"
label="关系模型" :label="$t('cmdb.custom_dashboard.childCIType')"
v-if="['bar', 'line', 'pie'].includes(chartType) && form.category === 2" v-if="['bar', 'line', 'pie'].includes(chartType) && form.category === 2"
> >
<a-select <a-select
@ -108,12 +108,12 @@
optionFilterProp="children" optionFilterProp="children"
mode="multiple" mode="multiple"
v-model="form.type_ids" v-model="form.type_ids"
placeholder="请选择模型" :placeholder="$t('cmdb.ciType.selectCIType')"
> >
<a-select-opt-group <a-select-opt-group
v-for="(key, index) in Object.keys(level2children)" v-for="(key, index) in Object.keys(level2children)"
:key="key" :key="key"
:label="`层级${index + 1}`" :label="$t('cmdb.custom_dashboard.level') + `${index + 1}`"
> >
<a-select-option <a-select-option
@click="(e) => clickLevel2children(e, citype, index + 1)" @click="(e) => clickLevel2children(e, citype, index + 1)"
@ -127,7 +127,11 @@
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
<div :class="{ 'chart-left-preview': true, 'chart-left-preview-empty': !isShowPreview }"> <div :class="{ 'chart-left-preview': true, 'chart-left-preview-empty': !isShowPreview }">
<span class="chart-left-preview-operation" @click="showPreview"><a-icon type="play-circle" /> 预览</span> <span
class="chart-left-preview-operation"
@click="showPreview"
><a-icon type="play-circle" /> {{ $t('cmdb.custom_dashboard.preview') }}</span
>
<template v-if="isShowPreview"> <template v-if="isShowPreview">
<div v-if="chartType !== 'count'" class="cmdb-dashboard-grid-item-title"> <div v-if="chartType !== 'count'" class="cmdb-dashboard-grid-item-title">
<template v-if="form.showIcon && ciType"> <template v-if="form.showIcon && ciType">
@ -190,14 +194,19 @@
</div> </div>
</template> </template>
</div> </div>
<a-form-model-item label="是否显示icon" prop="showIcon" :label-col="{ span: 5 }" :wrapper-col="{ span: 18 }"> <a-form-model-item
:label="$t('cmdb.custom_dashboard.showIcon')"
prop="showIcon"
:label-col="{ span: 5 }"
:wrapper-col="{ span: 18 }"
>
<a-switch v-model="form.showIcon"></a-switch> <a-switch v-model="form.showIcon"></a-switch>
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
</div> </div>
<div class="chart-right"> <div class="chart-right">
<h4>图表类型</h4> <h4>{{ $t('cmdb.custom_dashboard.chartType') }}</h4>
<div class="chart-right-type"> <div class="chart-right-type">
<div <div
:class="{ 'chart-right-type-box': true, 'chart-right-type-box-selected': chartType === t.value }" :class="{ 'chart-right-type-box': true, 'chart-right-type-box-selected': chartType === t.value }"
@ -209,7 +218,7 @@
<span>{{ t.label }}</span> <span>{{ t.label }}</span>
</div> </div>
</div> </div>
<h4>数据筛选</h4> <h4>{{ $t('cmdb.custom_dashboard.dataFilter') }}</h4>
<FilterComp <FilterComp
ref="filterComp" ref="filterComp"
:isDropdown="false" :isDropdown="false"
@ -217,9 +226,9 @@
@setExpFromFilter="setExpFromFilter" @setExpFromFilter="setExpFromFilter"
:expression="filterExp ? `q=${filterExp}` : ''" :expression="filterExp ? `q=${filterExp}` : ''"
/> />
<h4>格式</h4> <h4>{{ $t('cmdb.custom_dashboard.format') }}</h4>
<a-form-model :colon="false" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }"> <a-form-model :colon="false" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
<a-form-model-item label="字体颜色" v-if="chartType === 'count'"> <a-form-model-item :label="$t('cmdb.custom_dashboard.fontColor')" v-if="chartType === 'count'">
<ColorPicker <ColorPicker
v-model="fontColor" v-model="fontColor"
:colorList="[ :colorList="[
@ -235,7 +244,7 @@
]" ]"
/> />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="背景颜色" v-if="chartType === 'count'"> <a-form-model-item :label="$t('cmdb.custom_dashboard.backgroundColor')" v-if="chartType === 'count'">
<ColorPicker <ColorPicker
v-model="bgColor" v-model="bgColor"
:colorList="[ :colorList="[
@ -251,10 +260,10 @@
]" ]"
/> />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="图表颜色" v-else-if="chartType !== 'table'"> <a-form-model-item :label="$t('cmdb.custom_dashboard.chartColor')" v-else-if="chartType !== 'table'">
<ColorListPicker v-model="chartColor" /> <ColorListPicker v-model="chartColor" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="图表长度(%)"> <a-form-model-item :label="$t('cmdb.custom_dashboard.chartLength') + `(%)`">
<a-radio-group class="chart-width" style="width:100%;" v-model="width"> <a-radio-group class="chart-width" style="width:100%;" v-model="width">
<a-radio-button :value="3"> <a-radio-button :value="3">
25 25
@ -270,27 +279,23 @@
</a-radio-button> </a-radio-button>
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="柱状图类型" v-if="chartType === 'bar'"> <a-form-model-item :label="$t('cmdb.custom_dashboard.barType')" v-if="chartType === 'bar'">
<a-radio-group v-model="barStack"> <a-radio-group v-model="barStack">
<a-radio value="total"> <a-radio value="total">
堆积柱状图 {{ $t('cmdb.custom_dashboard.stackedBar') }}
</a-radio> </a-radio>
<a-radio value=""> <a-radio value="">
多系列柱状图 {{ $t('cmdb.custom_dashboard.multipleSeriesBar') }}
</a-radio> </a-radio>
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="方向" v-if="chartType === 'bar'"> <a-form-model-item :label="$t('cmdb.custom_dashboard.direction')" v-if="chartType === 'bar'">
<a-radio-group v-model="barDirection"> <a-radio-group v-model="barDirection">
<a-radio value="x"> <a-radio value="x"> X {{ $t('cmdb.custom_dashboard.axis') }} </a-radio>
X轴 <a-radio value="y"> Y {{ $t('cmdb.custom_dashboard.axis') }} </a-radio>
</a-radio>
<a-radio value="y">
y轴
</a-radio>
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="下方阴影" v-if="chartType === 'line'"> <a-form-model-item :label="$t('cmdb.custom_dashboard.lowerShadow')" v-if="chartType === 'line'">
<a-switch v-model="isShadow" /> <a-switch v-model="isShadow" />
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
@ -320,31 +325,7 @@ export default {
}, },
}, },
data() { data() {
const chartTypeList = [
{
value: 'count',
label: '指标',
},
{
value: 'bar',
label: '柱状图',
},
{
value: 'line',
label: '折线图',
},
{
value: 'pie',
label: '饼状图',
},
{
value: 'table',
label: '表格',
},
]
return { return {
dashboardCategory,
chartTypeList,
visible: false, visible: false,
attributes: [], attributes: [],
type: 'add', type: 'add',
@ -360,11 +341,11 @@ export default {
}, },
rules: { rules: {
category: [{ required: true, trigger: 'change' }], category: [{ required: true, trigger: 'change' }],
name: [{ required: true, message: '请输入图表名称' }], name: [{ required: true, message: this.$t('cmdb.custom_dashboard.titleTips') }],
type_id: [{ required: true, message: '请选择模型', trigger: 'change' }], type_id: [{ required: true, message: this.$t('cmdb.ciType.selectCIType'), trigger: 'change' }],
type_ids: [{ required: true, message: '请选择模型', trigger: 'change' }], type_ids: [{ required: true, message: this.$t('cmdb.ciType.selectCIType'), trigger: 'change' }],
attr_ids: [{ required: true, message: '请选择模型属性', trigger: 'change' }], attr_ids: [{ required: true, message: this.$t('cmdb.ciType.selectCITypeAttributes'), trigger: 'change' }],
level: [{ required: true, message: '请输入关系层级' }], level: [{ required: true, message: this.$t('cmdb.custom_dashboard.levelTips') }],
showIcon: [{ required: false }], showIcon: [{ required: false }],
}, },
item: {}, item: {},
@ -372,7 +353,7 @@ export default {
width: 3, width: 3,
fontColor: '#ffffff', fontColor: '#ffffff',
bgColor: ['#6ABFFE', '#5375EB'], bgColor: ['#6ABFFE', '#5375EB'],
chartColor: '#5DADF2,#86DFB7,#5A6F96,#7BD5FF,#FFB980,#4D58D6,#D9B6E9,#8054FF', // 图表颜色 chartColor: '#5DADF2,#86DFB7,#5A6F96,#7BD5FF,#FFB980,#4D58D6,#D9B6E9,#8054FF', // chart color
isShowPreview: false, isShowPreview: false,
filterExp: undefined, filterExp: undefined,
previewData: null, previewData: null,
@ -391,6 +372,33 @@ export default {
} }
return null return null
}, },
chartTypeList() {
return [
{
value: 'count',
label: this.$t('cmdb.custom_dashboard.count'),
},
{
value: 'bar',
label: this.$t('cmdb.custom_dashboard.bar'),
},
{
value: 'line',
label: this.$t('cmdb.custom_dashboard.line'),
},
{
value: 'pie',
label: this.$t('cmdb.custom_dashboard.pie'),
},
{
value: 'table',
label: this.$t('cmdb.custom_dashboard.table'),
},
]
},
dashboardCategory() {
return dashboardCategory()
},
}, },
inject: ['layout'], inject: ['layout'],
methods: { methods: {

View File

@ -1,7 +1,9 @@
import i18n from '@/lang'
export const category_1_bar_options = (data, options) => { export const category_1_bar_options = (data, options) => {
// 计算一级分类 // Calculate first level classification
const xData = Object.keys(data) const xData = Object.keys(data)
// 计算共有多少二级分类 // Calculate how many secondary categories there are
const secondCategory = {} const secondCategory = {}
Object.keys(data).forEach(key => { Object.keys(data).forEach(key => {
if (Object.prototype.toString.call(data[key]) === '[object Object]') { if (Object.prototype.toString.call(data[key]) === '[object Object]') {
@ -9,7 +11,7 @@ export const category_1_bar_options = (data, options) => {
secondCategory[key1] = Array.from({ length: xData.length }).fill(0) secondCategory[key1] = Array.from({ length: xData.length }).fill(0)
}) })
} else { } else {
secondCategory['其他'] = Array.from({ length: xData.length }).fill(0) secondCategory[i18n.t('other')] = Array.from({ length: xData.length }).fill(0)
} }
}) })
Object.keys(secondCategory).forEach(key => { Object.keys(secondCategory).forEach(key => {
@ -18,7 +20,7 @@ export const category_1_bar_options = (data, options) => {
secondCategory[key][idx] = data[x][key] secondCategory[key][idx] = data[x][key]
} }
if (typeof data[x] === 'number') { if (typeof data[x] === 'number') {
secondCategory['其他'][idx] = data[x] secondCategory[i18n.t('other')][idx] = data[x]
} }
}) })
}) })
@ -121,7 +123,7 @@ export const category_1_line_options = (data, options) => {
}, { }, {
offset: 1, color: '#ffffff' // 100% 处的颜色 offset: 1, color: '#ffffff' // 100% 处的颜色
}], }],
global: false // 缺省为 false global: false // default is false
} }
} : null } : null
} }

View File

@ -1,4 +1,8 @@
export const dashboardCategory = { import i18n from '@/lang'
1: { label: '默认' },
2: { label: '关系' } export const dashboardCategory = () => {
return {
1: { label: i18n.t('cmdb.custom_dashboard.default') },
2: { label: i18n.t('cmdb.custom_dashboard.relation') }
}
} }

View File

@ -16,7 +16,7 @@
type="primary" type="primary"
icon="plus-circle" icon="plus-circle"
class="ops-button-primary" class="ops-button-primary"
>新增图表</a-button >{{ $t('cmdb.custom_dashboard.newChart') }}</a-button
> >
</div> </div>
<GridLayout <GridLayout
@ -78,10 +78,10 @@
></a> ></a>
<a-menu slot="overlay"> <a-menu slot="overlay">
<a-menu-item> <a-menu-item>
<a @click="() => openChartForm('edit', item)"><a-icon style="margin-right:5px" type="edit" />编辑</a> <a @click="() => openChartForm('edit', item)"><a-icon style="margin-right:5px" type="edit" />{{ $t('edit') }}</a>
</a-menu-item> </a-menu-item>
<a-menu-item> <a-menu-item>
<a @click="deleteChart(item)"><a-icon style="margin-right:5px" type="delete" />删除</a> <a @click="deleteChart(item)"><a-icon style="margin-right:5px" type="delete" />{{ $t('delete') }}</a>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</a-dropdown> </a-dropdown>
@ -116,7 +116,7 @@
> >
定制仪表盘 定制仪表盘
</a-button> </a-button>
<span v-else>管理员暂未定制仪表盘</span> <span v-else>{{ $t('cmdb.custom_dashboard.noCustomDashboard') }}</span>
</div> </div>
<ChartForm ref="chartForm" @refresh="refresh" :ci_types="ci_types" :totalData="totalData" /> <ChartForm ref="chartForm" @refresh="refresh" :ci_types="ci_types" :totalData="totalData" />
</div> </div>

View File

@ -32,7 +32,7 @@
/></a> /></a>
</a-space> </a-space>
<a v-else @click="handleEdit"><a-icon type="eye"/></a> <a v-else @click="handleEdit"><a-icon type="eye"/></a>
<span>{{ rule.is_plugin ? 'Plugin' : '默认' }}</span> <span>{{ rule.is_plugin ? 'Plugin' : $t('cmdb.custom_dashboard.default') }}</span>
</div> </div>
</template> </template>
</div> </div>
@ -57,7 +57,7 @@ export default {
return this.rule?.option?.icon ?? { color: '', name: 'caise-wuliji' } return this.rule?.option?.icon ?? { color: '', name: 'caise-wuliji' }
}, },
isDeletable() { isDeletable() {
return !['物理机', '虚拟机', '网卡', '硬盘', 'server', 'vserver', 'NIC', 'harddisk'].includes(this.rule.name) return ![this.$t('cmdb.ad.server'), this.$t('cmdb.ad.vserver'), this.$t('cmdb.ad.nic'), this.$t('cmdb.ad.disk'), 'server', 'vserver', 'NIC', 'harddisk'].includes(this.rule.name)
}, },
}, },
inject: { inject: {

View File

@ -8,21 +8,21 @@
:label-col="{ span: 2 }" :label-col="{ span: 2 }"
:wrapper-col="{ span: 20 }" :wrapper-col="{ span: 20 }"
> >
<a-divider :style="{ margin: '5px 0' }">基础设置</a-divider> <a-divider :style="{ margin: '5px 0' }">{{ $t('cmdb.ciType.basicConfig') }}</a-divider>
<a-form-model-item label="名称" prop="name"> <a-form-model-item :label="$t('name')" prop="name">
<a-input v-model="form.name" /> <a-input v-model="form.name" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="图标" v-if="is_inner"> <a-form-model-item :label="$t('icon')" v-if="is_inner">
<CustomIconSelect v-model="customIcon" :style="{ marginTop: '6px' }" /> <CustomIconSelect v-model="customIcon" :style="{ marginTop: '6px' }" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="模式" prop="is_plugin"> <a-form-model-item :label="$t('cmdb.ad.mode')" prop="is_plugin">
<a-radio-group v-model="form.is_plugin" @change="changeIsPlugin" :disabled="!is_inner"> <a-radio-group v-model="form.is_plugin" @change="changeIsPlugin" :disabled="!is_inner">
<a-radio :value="false">默认</a-radio> <a-radio :value="false">{{ $t('cmdb.custom_dashboard.default') }}</a-radio>
<a-radio :value="true">plugin</a-radio> <a-radio :value="true">plugin</a-radio>
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
<a-divider :style="{ margin: '5px 0' }">采集设置</a-divider> <a-divider :style="{ margin: '5px 0' }">{{ $t('cmdb.ad.collectSettings') }}</a-divider>
<CustomCodeMirror <CustomCodeMirror
codeMirrorId="cmdb-adt" codeMirrorId="cmdb-adt"
v-if="form.is_plugin" v-if="form.is_plugin"
@ -36,7 +36,7 @@
type="primary" type="primary"
ghost ghost
@click="handleSubmit(true)" @click="handleSubmit(true)"
>更新字段</a-button >{{ $t('cmdb.ad.updateFields') }}</a-button
> >
</div> </div>
<a-button <a-button
@ -47,7 +47,7 @@
icon="plus" icon="plus"
:style="{ marginBottom: '10px' }" :style="{ marginBottom: '10px' }"
@click="insertEvent(-1)" @click="insertEvent(-1)"
>新增</a-button >{{ $t('new') }}</a-button
> >
<vxe-table <vxe-table
size="mini" size="mini"
@ -60,24 +60,24 @@
:data="tableData" :data="tableData"
:edit-config="{ trigger: 'manual', mode: 'row' }" :edit-config="{ trigger: 'manual', mode: 'row' }"
> >
<vxe-column field="name" title="名称" :edit-render="{ autofocus: '.vxe-input--inner' }"> <vxe-column field="name" :title="$t('name')" :edit-render="{ autofocus: '.vxe-input--inner' }">
<template #edit="{ row }"> <template #edit="{ row }">
<vxe-input v-model="row.name" type="text"></vxe-input> <vxe-input v-model="row.name" type="text"></vxe-input>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="type" title="类型" :edit-render="{}"> <vxe-column field="type" :title="$t('type')" :edit-render="{}">
<template #edit="{ row }"> <template #edit="{ row }">
<vxe-select v-model="row.type" transfer> <vxe-select v-model="row.type" transfer>
<vxe-option v-for="item in typeList" :key="item" :value="item" :label="item"></vxe-option> <vxe-option v-for="item in typeList" :key="item" :value="item" :label="item"></vxe-option>
</vxe-select> </vxe-select>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="desc" title="描述" :edit-render="{ autofocus: '.vxe-input--inner' }"> <vxe-column field="desc" :title="$t('desc')" :edit-render="{ autofocus: '.vxe-input--inner' }">
<template #edit="{ row }"> <template #edit="{ row }">
<vxe-input v-model="row.desc" type="text"></vxe-input> <vxe-input v-model="row.desc" type="text"></vxe-input>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column title="操作" width="60" v-if="!form.is_plugin"> <vxe-column :title="$t('operation')" width="60" v-if="!form.is_plugin">
<template #default="{ row }"> <template #default="{ row }">
<a-space v-if="$refs.xTable.isActiveByRow(row)"> <a-space v-if="$refs.xTable.isActiveByRow(row)">
<a @click="saveRowEvent(row)"><a-icon type="save"/></a> <a @click="saveRowEvent(row)"><a-icon type="save"/></a>
@ -92,8 +92,8 @@
</vxe-table> </vxe-table>
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button @click="handleClose">取消</a-button> <a-button @click="handleClose">{{ $t('cancel') }}</a-button>
<a-button @click="handleSubmit(false)" type="primary">保存</a-button> <a-button @click="handleSubmit(false)" type="primary">{{ $t('save') }}</a-button>
</div> </div>
</template> </template>
<template v-else> <template v-else>
@ -119,53 +119,7 @@ export default {
}, },
}, },
data() { data() {
const default_plugin_script = `# -*- coding:utf-8 -*- const default_plugin_script = this.$t('cmdb.ad.pluginScript')
import json
class AutoDiscovery(object):
@property
def unique_key(self):
"""
:return: 返回唯一属性的名字
"""
return
@staticmethod
def attributes():
"""
定义属性字段
:return: 返回属性字段列表, 列表项是(名称, 类型, 描述), 名称必须是英文
类型: String Integer Float Date DateTime Time JSON
例如:
return [
("ci_type", "String", "模型名称"),
("private_ip", "String", "内网IP, 多值逗号分隔")
]
"""
return []
@staticmethod
def run():
"""
执行入口, 返回采集的属性值
:return: 返回一个列表, 列表项是字典, 字典key是属性名称, value是属性值
例如:
return [dict(ci_type="server", private_ip="192.168.1.1")]
"""
return []
if __name__ == "__main__":
result = AutoDiscovery().run()
if isinstance(result, list):
print("AutoDiscovery::Result::{}".format(json.dumps(result)))
else:
print("ERROR: 采集返回必须是列表")
`
const typeList = ['String', 'Integer', 'Float', 'Date', 'DateTime', 'Time', 'JSON'] const typeList = ['String', 'Integer', 'Float', 'Date', 'DateTime', 'Time', 'JSON']
return { return {
default_plugin_script, default_plugin_script,
@ -196,9 +150,9 @@ if __name__ == "__main__":
return this.ruleData.name return this.ruleData.name
} }
if (this.type === 'edit') { if (this.type === 'edit') {
return `编辑${this.ruleData.name}` return this.$t('edit') + `${this.ruleData.name}`
} }
return '新建' return this.$t('new')
}, },
}, },
inject: { inject: {
@ -278,7 +232,7 @@ if __name__ == "__main__":
cancelRowEvent(row) { cancelRowEvent(row) {
const $table = this.$refs.xTable const $table = this.$refs.xTable
$table.clearActived().then(() => { $table.clearActived().then(() => {
// 还原行数据 // Restore row data
$table.revertData(row) $table.revertData(row)
}) })
}, },
@ -312,7 +266,7 @@ if __name__ == "__main__":
this.tableData = res.attributes this.tableData = res.attributes
this.type = 'edit' this.type = 'edit'
this.ruleData = res this.ruleData = res
this.$message.success('更新成功!') this.$message.success(this.$t('updateSuccess'))
if (this.is_inner) { if (this.is_inner) {
this.getDiscovery() this.getDiscovery()
} }
@ -321,7 +275,7 @@ if __name__ == "__main__":
this.handleClose() this.handleClose()
console.log(this.is_inner) console.log(this.is_inner)
if (this.is_inner) { if (this.is_inner) {
this.$message.success('保存成功!') this.$message.success(this.$t('saveSuccess'))
this.getDiscovery() this.getDiscovery()
} else { } else {
this.$emit('updateNotInner', res) this.$emit('updateNotInner', res)

View File

@ -3,9 +3,9 @@
<div :style="{ textAlign: 'right' }"> <div :style="{ textAlign: 'right' }">
<a-space v-if="!isSelected"> <a-space v-if="!isSelected">
<a-upload name="file" :multiple="false" accept=".json" :fileList="[]" :beforeUpload="beforeUpload"> <a-upload name="file" :multiple="false" accept=".json" :fileList="[]" :beforeUpload="beforeUpload">
<a><a-icon type="upload" />规则导入</a> <a><a-icon type="upload" />{{ $t('cmdb.ad.upload') }}</a>
</a-upload> </a-upload>
<a @click="download"><a-icon type="download" />规则导出</a> <a @click="download"><a-icon type="download" />{{ $t('cmdb.ad.download') }}</a>
</a-space> </a-space>
</div> </div>
<div v-for="{ type, label } in typeCategory" :key="type"> <div v-for="{ type, label } in typeCategory" :key="type">
@ -45,22 +45,26 @@ export default {
}, },
data() { data() {
return { return {
typeCategory: [ typeCategoryChildren: { agent: [], snmp: [], http: [] },
}
},
computed: {
typeCategory() {
return [
{ {
type: 'agent', type: 'agent',
label: '内置 & 插件', label: this.$t('cmdb.ad.agent'),
}, },
{ {
type: 'snmp', type: 'snmp',
label: '网络设备', label: this.$t('cmdb.ad.snmp'),
}, },
{ {
type: 'http', type: 'http',
label: '公有云资源', label: this.$t('cmdb.ad.http'),
},
]
}, },
],
typeCategoryChildren: { agent: [], snmp: [], http: [] },
}
}, },
provide() { provide() {
return { return {
@ -87,11 +91,11 @@ export default {
deleteRule(rule) { deleteRule(rule) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确认删除 ${rule.name}`, content: that.$t('confirmDelete', { name: `${rule.name}` }),
onOk() { onOk() {
deleteDiscovery(rule.id).then(() => { deleteDiscovery(rule.id).then(() => {
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.getDiscovery() that.getDiscovery()
}) })
}, },
@ -99,13 +103,14 @@ export default {
}, },
download() { download() {
const x = new XMLHttpRequest() const x = new XMLHttpRequest()
const that = this
x.open('GET', `/api/v0.1/adr/template/export/file`, true) x.open('GET', `/api/v0.1/adr/template/export/file`, true)
x.responseType = 'blob' x.responseType = 'blob'
x.onload = function(e) { x.onload = function(e) {
const url = window.URL.createObjectURL(x.response) const url = window.URL.createObjectURL(x.response)
const a = document.createElement('a') const a = document.createElement('a')
a.href = url a.href = url
a.download = `自动发现规则` a.download = that.$t('cmdb.ad.rule')
a.click() a.click()
} }
x.send() x.send()
@ -120,13 +125,13 @@ export default {
const state = Number(xhr.readyState) const state = Number(xhr.readyState)
if (state === 4) { if (state === 4) {
if (xhr.status === 200) { if (xhr.status === 200) {
that.$message.success('上传成功') that.$message.success(that.$t('uploadSuccess'))
that.getDiscovery() that.getDiscovery()
} }
} }
} }
xhr.ontimeout = function() { xhr.ontimeout = function() {
that.$httpError('超时错误') that.$httpError(that.$t('cmdb.ad.timeout'))
} }
xhr.send(formData) xhr.send(formData)

View File

@ -3,7 +3,7 @@
<template #one> <template #one>
<div v-for="group in ci_types_list" :key="group.id"> <div v-for="group in ci_types_list" :key="group.id">
<div> <div>
<strong>{{ group.name || '其他' }}</strong <strong>{{ group.name || $t('other') }}</strong
><span :style="{ color: 'rgb(195, 205, 215)' }">({{ group.ci_types.length }})</span> ><span :style="{ color: 'rgb(195, 205, 215)' }">({{ group.ci_types.length }})</span>
</div> </div>
<div <div
@ -33,17 +33,17 @@
<template #two> <template #two>
<div id="discovery-ci"> <div id="discovery-ci">
<a-input-search <a-input-search
placeholder="请查找" :placeholder="$t('cmdb.components.pleaseSearch')"
class="ops-input ops-input-radius" class="ops-input ops-input-radius"
:style="{ width: '200px', marginRight: '20px', marginBottom: '10px' }" :style="{ width: '200px', marginRight: '20px', marginBottom: '10px' }"
@search="handleSearch" @search="handleSearch"
allowClear allowClear
/> />
<div class="ops-list-batch-action" :style="{ marginBottom: '10px' }" v-show="!!selectedRowKeys.length"> <div class="ops-list-batch-action" :style="{ marginBottom: '10px' }" v-show="!!selectedRowKeys.length">
<span @click="batchAccept">入库</span> <span @click="batchAccept">{{ $t('cmdb.ad.accept') }}</span>
<a-divider type="vertical" /> <a-divider type="vertical" />
<span @click="batchDelete">删除</span> <span @click="batchDelete">{{ $t('delete') }}</span>
<span>选取{{ selectedRowKeys.length }} </span> <span>{{ $t('cmdb.ci.selectRows', { rows: selectedRowKeys.length }) }}</span>
</div> </div>
<ops-table <ops-table
show-overflow show-overflow
@ -79,33 +79,33 @@
<vxe-column <vxe-column
align="center" align="center"
field="is_accept" field="is_accept"
title="是否入库" :title="$t('cmdb.ad.isAccpet')"
v-bind="columns.length ? { width: '100px' } : { minWidth: '100px' }" v-bind="columns.length ? { width: '100px' } : { minWidth: '100px' }"
:filters="[ :filters="[
{ label: '', value: true }, { label: $t('yes'), value: true },
{ label: '', value: false }, { label: $t('no'), value: false },
]" ]"
> >
<template #default="{row}"> <template #default="{row}">
{{ row.is_accept ? '' : '' }} {{ row.is_accept ? $t('yes') : $t('no') }}
</template> </template>
</vxe-column> </vxe-column>
<vxe-column <vxe-column
field="accept_by" field="accept_by"
title="入库人" :title="$t('cmdb.ad.accpetBy')"
v-bind="columns.length ? { width: '80px' } : { minWidth: '80px' }" v-bind="columns.length ? { width: '80px' } : { minWidth: '80px' }"
:filters="[]" :filters="[]"
></vxe-column> ></vxe-column>
<vxe-column <vxe-column
field="accept_time" field="accept_time"
title="入库时间" :title="$t('cmdb.ad.acceptTime')"
sortable sortable
v-bind="columns.length ? { width: '130px' } : { minWidth: '130px' }" v-bind="columns.length ? { width: '130px' } : { minWidth: '130px' }"
></vxe-column> ></vxe-column>
<vxe-column title="操作" v-bind="columns.length ? { width: '60px' } : { minWidth: '60px' }" align="center"> <vxe-column :title="$t('operation')" v-bind="columns.length ? { width: '60px' } : { minWidth: '60px' }" align="center">
<template #default="{row}"> <template #default="{row}">
<a-space> <a-space>
<a-tooltip title="入库"> <a-tooltip :title="$t('cmdb.ad.accept')">
<a v-if="!row.is_accept" @click="accept(row)"><ops-icon type="icon-xianxing-edit"/></a> <a v-if="!row.is_accept" @click="accept(row)"><ops-icon type="icon-xianxing-edit"/></a>
</a-tooltip> </a-tooltip>
<a :style="{ color: 'red' }" @click="deleteADC(row)"><ops-icon type="icon-xianxing-delete"/></a> <a :style="{ color: 'red' }" @click="deleteADC(row)"><ops-icon type="icon-xianxing-delete"/></a>
@ -115,7 +115,7 @@
<template #empty> <template #empty>
<div> <div>
<img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" /> <img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" />
<div>暂无数据</div> <div>{{ $t('noData') }}</div>
</div> </div>
</template> </template>
</ops-table> </ops-table>
@ -242,11 +242,11 @@ export default {
this.$refs.xTable.getVxetableRef().clearCheckboxReserve() this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确认入库`, content: that.$t('cmdb.ad.confirmAccept'),
onOk() { onOk() {
updateADCAccept(row.id).then(() => { updateADCAccept(row.id).then(() => {
that.$message.success('入库成功') that.$message.success(that.$t('cmdb.ad.accpetSuccess'))
that.getAdc(false) that.getAdc(false)
}) })
}, },
@ -258,11 +258,11 @@ export default {
this.$refs.xTable.getVxetableRef().clearCheckboxReserve() this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确认删除该条数据`, content: that.$t('cmdb.ad.deleteADC'),
onOk() { onOk() {
deleteAdc(row.id).then(() => { deleteAdc(row.id).then(() => {
that.$message.success('删除成功') that.$message.success(that.$t('deleteSuccess'))
that.getAdc(false) that.getAdc(false)
}) })
}, },
@ -273,7 +273,7 @@ export default {
for (let i = 0; i < this.selectedRowKeys.length; i++) { for (let i = 0; i < this.selectedRowKeys.length; i++) {
await updateADCAccept(this.selectedRowKeys[i]) await updateADCAccept(this.selectedRowKeys[i])
} }
this.$message.success('入库成功') this.$message.success(this.$t('cmdb.ad.acceptSuccess'))
this.getAdc(false) this.getAdc(false)
this.selectedRowKeys = [] this.selectedRowKeys = []
this.$refs.xTable.getVxetableRef().clearCheckboxRow() this.$refs.xTable.getVxetableRef().clearCheckboxRow()
@ -283,13 +283,13 @@ export default {
async batchDelete() { async batchDelete() {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确认删除这些数据`, content: that.$t('cmdb.ad.batchDelete'),
async onOk() { async onOk() {
for (let i = 0; i < that.selectedRowKeys.length; i++) { for (let i = 0; i < that.selectedRowKeys.length; i++) {
await deleteAdc(that.selectedRowKeys[i]) await deleteAdc(that.selectedRowKeys[i])
} }
that.$message.success('删除成功') that.$message.success(that.$t('deleteSuccess'))
that.getAdc(false) that.getAdc(false)
that.selectedRowKeys = [] that.selectedRowKeys = []
that.$refs.xTable.getVxetableRef().clearCheckboxRow() that.$refs.xTable.getVxetableRef().clearCheckboxRow()

View File

@ -1,6 +1,8 @@
<template> <template>
<div class="model-relation"> <div class="model-relation">
<a-button @click="handleCreate" type="primary" style="margin-bottom: 15px;" icon="plus">新增关系</a-button> <a-button @click="handleCreate" type="primary" style="margin-bottom: 15px;" icon="plus">{{
$t('cmdb.ciType.addRelation')
}}</a-button>
<model-relation-table ref="table"></model-relation-table> <model-relation-table ref="table"></model-relation-table>
<a-modal <a-modal
:closable="false" :closable="false"
@ -11,11 +13,14 @@
width="500px" width="500px"
> >
<a-form :form="form" @submit="handleSubmit" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }"> <a-form :form="form" @submit="handleSubmit" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }">
<a-form-item label="源模型"> <a-form-item :label="$t('cmdb.ciType.sourceCIType')">
<a-select <a-select
showSearch showSearch
name="source_ci_type_id" name="source_ci_type_id"
v-decorator="['source_ci_type_id', { rules: [{ required: true, message: '请选择源模型' }] }]" v-decorator="[
'source_ci_type_id',
{ rules: [{ required: true, message: $t('cmdb.ciType.sourceCITypeTips') }] },
]"
@change="handleSourceTypeChange" @change="handleSourceTypeChange"
:filterOption="filterOption" :filterOption="filterOption"
> >
@ -24,11 +29,11 @@
}}</a-select-option> }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="目标模型"> <a-form-item :label="$t('cmdb.ciType.dstCIType')">
<a-select <a-select
showSearch showSearch
name="ci_type_id" name="ci_type_id"
v-decorator="['ci_type_id', { rules: [{ required: true, message: '请选择目标模型' }] }]" v-decorator="['ci_type_id', { rules: [{ required: true, message: $t('cmdb.ciType.dstCITypeTips') }] }]"
@change="handleTargetTypeChange" @change="handleTargetTypeChange"
:filterOption="filterOption" :filterOption="filterOption"
> >
@ -38,10 +43,13 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="关联关系"> <a-form-item :label="$t('cmdb.ciType.relationType')">
<a-select <a-select
name="relation_type_id" name="relation_type_id"
v-decorator="['relation_type_id', { rules: [{ required: true, message: '请选择关联关系' }] }]" v-decorator="[
'relation_type_id',
{ rules: [{ required: true, message: $t('cmdb.ciType.relationTypeTips') }] },
]"
> >
<a-select-option :value="relationType.id" :key="relationType.id" v-for="relationType in relationTypes">{{ <a-select-option :value="relationType.id" :key="relationType.id" v-for="relationType in relationTypes">{{
relationType.name relationType.name
@ -49,11 +57,16 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="关联约束"> <a-form-item :label="$t('cmdb.ciType.relationConstraint')">
<a-select v-decorator="['constraint', { rules: [{ required: true, message: '请选择关联约束' }] }]"> <a-select
<a-select-option value="0">一对多</a-select-option> v-decorator="[
<a-select-option value="1">一对一</a-select-option> 'constraint',
<a-select-option value="2">多对多</a-select-option> { rules: [{ required: true, message: $t('cmdb.ciType.relationConstraintTips') }] },
]"
>
<a-select-option value="0">{{ $t('cmdb.ciType.one2Many') }}</a-select-option>
<a-select-option value="1">{{ $t('cmdb.ciType.one2One') }}</a-select-option>
<a-select-option value="2">{{ $t('cmdb.ciType.many2Many') }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-form> </a-form>
@ -66,7 +79,7 @@ import ModelRelationTable from './modules/modelRelationTable.vue'
import { searchResourceType } from '@/modules/acl/api/resource' import { searchResourceType } from '@/modules/acl/api/resource'
import { getCITypeGroupsConfig } from '@/modules/cmdb/api/ciTypeGroup' import { getCITypeGroupsConfig } from '@/modules/cmdb/api/ciTypeGroup'
import { getCITypes } from '@/modules/cmdb/api/CIType' import { getCITypes } from '@/modules/cmdb/api/CIType'
import { createRelation, deleteRelation, getRelationTypes } from '@/modules/cmdb/api/CITypeRelation' import { createRelation, deleteRelation, getCITypeChildren, getRelationTypes } from '@/modules/cmdb/api/CITypeRelation'
export default { export default {
name: 'Index', name: 'Index',
components: { components: {
@ -85,16 +98,40 @@ export default {
drawerTitle: '', drawerTitle: '',
CITypes: [], CITypes: [],
relationTypes: [], relationTypes: [],
constraintMap: {
'0': '一对多',
'1': '一对一',
'2': '多对多',
},
sourceCITypeId: undefined, sourceCITypeId: undefined,
targetCITypeId: undefined, targetCITypeId: undefined,
} }
}, },
computed: {
currentCId() {
if (this.currentId) {
if (this.currentId.split('%')[1] !== 'null') {
return Number(this.currentId.split('%')[1])
}
return null
}
return null
},
displayCITypes() {
return this.CITypes
// return this.CITypes.filter((c) => c.id !== this.targetCITypeId)
},
displayTargetCITypes() {
return this.CITypes
// return this.CITypes.filter((c) => c.id !== this.sourceCITypeId)
},
CITypeId() {
return this.currentCId
},
constraintMap() {
return {
'0': this.$t('cmdb.ciType.one2Many'),
'1': this.$t('cmdb.ciType.one2One'),
'2': this.$t('cmdb.ciType.many2Many'),
}
},
},
provide() { provide() {
return { return {
resource_type: () => { resource_type: () => {
@ -116,26 +153,6 @@ export default {
}) })
this.loadCITypes(!_currentId) this.loadCITypes(!_currentId)
}, },
computed: {
currentCId() {
if (this.currentId) {
if (this.currentId.split('%')[1] !== 'null') {
return Number(this.currentId.split('%')[1])
}
return null
}
return null
},
displayCITypes() {
return this.CITypes
},
displayTargetCITypes() {
return this.CITypes
},
CITypeId() {
return this.currentCId
},
},
methods: { methods: {
async loadCITypes(isResetCurrentId = false) { async loadCITypes(isResetCurrentId = false) {
const groups = await getCITypeGroupsConfig({ need_other: true }) const groups = await getCITypeGroupsConfig({ need_other: true })
@ -146,7 +163,6 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
groups.forEach((g) => { groups.forEach((g) => {
if (!g.id) { if (!g.id) {
// 给未分组增加一个假的id
g.id = -1 g.id = -1
} }
if (isResetCurrentId && !alreadyReset && g.ci_types && g.ci_types.length) { if (isResetCurrentId && !alreadyReset && g.ci_types && g.ci_types.length) {
@ -172,7 +188,7 @@ export default {
}) })
}, },
handleCreate() { handleCreate() {
this.drawerTitle = '新增关系' this.drawerTitle = this.$t('cmdb.ciType.addRelation')
this.visible = true this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue({ this.form.setFieldsValue({
@ -192,7 +208,7 @@ export default {
if (!err) { if (!err) {
createRelation(values.source_ci_type_id, values.ci_type_id, values.relation_type_id, values.constraint).then( createRelation(values.source_ci_type_id, values.ci_type_id, values.relation_type_id, values.constraint).then(
(res) => { (res) => {
this.$message.success(`添加成功`) this.$message.success(this.$t('addSuccess'))
this.onClose() this.onClose()
this.handleOk() this.handleOk()
} }
@ -207,7 +223,7 @@ export default {
}, },
handleDelete(record) { handleDelete(record) {
deleteRelation(record.source_ci_type_id, record.id).then((res) => { deleteRelation(record.source_ci_type_id, record.id).then((res) => {
this.$message.success(`删除成功`) this.$message.success(this.$t('deleteSuccess'))
this.handleOk() this.handleOk()
}) })

View File

@ -11,22 +11,27 @@
:data="tableData" :data="tableData"
:sort-config="{ defaultSort: { field: 'created_at', order: 'desc' } }" :sort-config="{ defaultSort: { field: 'created_at', order: 'desc' } }"
> >
<vxe-column field="created_at" title="创建时间" sortable width="159px"></vxe-column> <vxe-column field="created_at" :title="$t('created_at')" sortable width="159px"></vxe-column>
<vxe-column field="parent.alias" title="源模型"></vxe-column> <vxe-column field="parent.alias" :title="$t('cmdb.ciType.sourceCIType')"></vxe-column>
<vxe-column field="relation_type_id" title="关系" :filters="[{ data: '' }]" :filter-multiple="false"> <vxe-column
field="relation_type_id"
:title="$t('cmdb.custom_dashboard.relation')"
:filters="[{ data: '' }]"
:filter-multiple="false"
>
<template #default="{ row }"> <template #default="{ row }">
<a-tag color="cyan"> <a-tag color="cyan">
{{ row.relation_type.name }} {{ row.relation_type.name }}
</a-tag> </a-tag>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="child.alias" title="目标模型"></vxe-column> <vxe-column field="child.alias" :title="$t('cmdb.ciType.dstCIType')"></vxe-column>
<vxe-column field="constraint" title="关联约束"></vxe-column> <vxe-column field="constraint" :title="$t('cmdb.ciType.relationConstraint')"></vxe-column>
<vxe-column field="authorization" title="操作" width="89px"> <vxe-column field="authorization" :title="$t('operation')" width="89px">
<template #default="{ row }"> <template #default="{ row }">
<a-space> <a-space>
<a @click="handleOpenGrant(row)"><a-icon type="user-add"/></a> <a @click="handleOpenGrant(row)"><a-icon type="user-add"/></a>
<a-popconfirm title="确认删除?" @confirm="deleteRelation(row)"> <a-popconfirm :title="$t('cmdb.ciType.confirmDelete2')" @confirm="deleteRelation(row)">
<a :style="{ color: 'red' }"><ops-icon type="icon-xianxing-delete"/></a> <a :style="{ color: 'red' }"><ops-icon type="icon-xianxing-delete"/></a>
</a-popconfirm> </a-popconfirm>
</a-space> </a-space>
@ -48,11 +53,6 @@ export default {
drawerVisible: false, drawerVisible: false,
tableData: [], tableData: [],
relationTypeList: null, relationTypeList: null,
constraintMap: {
'0': '一对多',
'1': '一对一',
'2': '多对多',
},
} }
}, },
components: { components: {
@ -65,6 +65,13 @@ export default {
windowHeight() { windowHeight() {
return this.$store.state.windowHeight return this.$store.state.windowHeight
}, },
constraintMap() {
return {
'0': this.$t('cmdb.ciType.one2Many'),
'1': this.$t('cmdb.ciType.one2One'),
'2': this.$t('cmdb.ciType.many2Many'),
}
},
}, },
methods: { methods: {
async refresh() { async refresh() {
@ -103,7 +110,8 @@ export default {
}, },
deleteRelation(row) { deleteRelation(row) {
deleteRelation(row.parent_id, row.child_id).then((res) => { deleteRelation(row.parent_id, row.child_id).then((res) => {
this.$message.success(`删除成功`) this.$message.success(this.$t('deleteSuccess'))
this.getRelationTypes()
this.refresh() this.refresh()
}) })
}, },

View File

@ -2,16 +2,16 @@
<div> <div>
<a-card :bordered="false"> <a-card :bordered="false">
<a-tabs default-active-key="1"> <a-tabs default-active-key="1">
<a-tab-pane key="1" tab="CI变更"> <a-tab-pane key="1" :tab="$t('cmdb.history.ciChange')">
<ci-table></ci-table> <ci-table></ci-table>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="关系变更"> <a-tab-pane key="2" :tab="$t('cmdb.history.relationChange')">
<relation-table></relation-table> <relation-table></relation-table>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="3" tab="模型变更"> <a-tab-pane key="3" :tab="$t('cmdb.history.ciTypeChange')">
<type-table></type-table> <type-table></type-table>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="4" tab="触发历史"> <a-tab-pane key="4" :tab="$t('cmdb.history.triggerHistory')">
<TriggerTable></TriggerTable> <TriggerTable></TriggerTable>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>

View File

@ -23,22 +23,28 @@
:scroll-y="{ enabled: false }" :scroll-y="{ enabled: false }"
class="ops-unstripe-table" class="ops-unstripe-table"
> >
<vxe-column field="created_at" width="159px" title="操作时间"></vxe-column> <vxe-column field="created_at" width="159px" :title="$t('cmdb.history.opreateTime')"></vxe-column>
<vxe-column field="user" width="100px" title="用户"> <vxe-column field="user" width="100px" :title="$t('cmdb.history.user')">
<template #header="{ column }"> <template #header="{ column }">
<span>{{ column.title }}</span> <span>{{ column.title }}</span>
<a-popover trigger="click" placement="bottom"> <a-popover trigger="click" placement="bottom">
<a-icon class="filter" type="filter" theme="filled" /> <a-icon class="filter" type="filter" theme="filled" />
<a slot="content"> <a slot="content">
<a-input placeholder="输入筛选用户名" size="small" v-model="queryParams.username" style="width: 200px" allowClear/> <a-input
<a-button type="link" class="filterButton" @click="filterUser">筛选</a-button> :placeholder="$t('cmdb.history.userTips')"
<a-button type="link" class="filterResetButton" @click="filterUserReset">重置</a-button> size="small"
v-model="queryParams.username"
style="width: 200px"
allowClear
/>
<a-button type="link" class="filterButton" @click="filterUser">{{ $t('cmdb.history.filter') }}</a-button>
<a-button type="link" class="filterResetButton" @click="filterUserReset">{{ $t('reset') }}</a-button>
</a> </a>
</a-popover> </a-popover>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="type_id" width="100px" title="模型"></vxe-column> <vxe-column field="type_id" width="100px" :title="$t('cmdb.ciType.ciType')"></vxe-column>
<vxe-column field="operate_type" width="89px" title="操作"> <vxe-column field="operate_type" width="89px" :title="$t('operation')">
<template #header="{ column }"> <template #header="{ column }">
<span>{{ column.title }}</span> <span>{{ column.title }}</span>
<a-popover trigger="click" placement="bottom"> <a-popover trigger="click" placement="bottom">
@ -46,7 +52,7 @@
<a slot="content"> <a slot="content">
<a-select <a-select
v-model="queryParams.operate_type" v-model="queryParams.operate_type"
placeholder="选择筛选操作" :placeholder="$t('cmdb.history.filterOperate')"
show-search show-search
style="width: 200px" style="width: 200px"
:filter-option="filterOption" :filter-option="filterOption"
@ -58,19 +64,20 @@
v-for="(choice, index) in ciTableAttrList[4].choice_value" v-for="(choice, index) in ciTableAttrList[4].choice_value"
> >
{{ Object.keys(choice)[0] }} {{ Object.keys(choice)[0] }}
</a-select-option </a-select-option>
>
</a-select> </a-select>
<a-button type="link" class="filterButton" @click="filterOperate">筛选</a-button> <a-button type="link" class="filterButton" @click="filterOperate">{{
<a-button type="link" class="filterResetButton" @click="filterOperateReset">重置</a-button> $t('cmdb.history.filter')
}}</a-button>
<a-button type="link" class="filterResetButton" @click="filterOperateReset">{{ $t('reset') }}</a-button>
</a> </a>
</a-popover> </a-popover>
</template> </template>
<template #default="{ row }"> <template #default="{ row }">
<a-tag color="green" v-if="row.operate_type === '新增' "> <a-tag color="green" v-if="row.operate_type === $t('new')">
{{ row.operate_type }} {{ row.operate_type }}
</a-tag> </a-tag>
<a-tag color="orange" v-else-if="row.operate_type === '修改' "> <a-tag color="orange" v-else-if="row.operate_type === $t('update')">
{{ row.operate_type }} {{ row.operate_type }}
</a-tag> </a-tag>
<a-tag color="red" v-else> <a-tag color="red" v-else>
@ -78,9 +85,9 @@
</a-tag> </a-tag>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="attr_alias" title="属性"></vxe-column> <vxe-column field="attr_alias" :title="$t('cmdb.history.attribute')"></vxe-column>
<vxe-column field="old" title=""></vxe-column> <vxe-column field="old" :title="$t('cmdb.history.old')"></vxe-column>
<vxe-column field="new" title=""></vxe-column> <vxe-column field="new" :title="$t('cmdb.history.new')"></vxe-column>
</vxe-table> </vxe-table>
<pager <pager
:current-page.sync="queryParams.page" :current-page.sync="queryParams.page"
@ -94,6 +101,7 @@
</div> </div>
</template> </template>
<script> <script>
import { mapState } from 'vuex'
import Pager from './pager.vue' import Pager from './pager.vue'
import SearchForm from './searchForm.vue' import SearchForm from './searchForm.vue'
import { getCIHistoryTable, getUsers } from '@/modules/cmdb/api/history' import { getCIHistoryTable, getUsers } from '@/modules/cmdb/api/history'
@ -102,14 +110,10 @@ import { getCITypeAttributesById } from '@/modules/cmdb/api/CITypeAttr'
export default { export default {
name: 'CiTable', name: 'CiTable',
components: { SearchForm, Pager }, components: { SearchForm, Pager },
inject: ['reload'],
data() { data() {
return { return {
typeId: undefined, typeId: undefined,
operateTypeMap: new Map([
['0', '新增'],
['1', '删除'],
['2', '修改'],
]),
loading: true, loading: true,
typeList: null, typeList: null,
userList: [], userList: [],
@ -122,59 +126,68 @@ export default {
}, },
ciTableAttrList: [ ciTableAttrList: [
{ {
alias: '日期', alias: this.$t('cmdb.ciType.date'),
is_choice: false, is_choice: false,
name: 'datetime', name: 'datetime',
value_type: '3' value_type: '3',
}, },
{ {
alias: '用户', alias: this.$t('cmdb.history.user'),
is_choice: true, is_choice: true,
name: 'username', name: 'username',
value_type: '2', value_type: '2',
choice_value: [] choice_value: [],
}, },
{ {
alias: '模型', alias: this.$t('cmdb.ciType.ciType'),
is_choice: true, is_choice: true,
name: 'type_id', name: 'type_id',
value_type: '2', value_type: '2',
choice_value: [], choice_value: [],
}, },
{ {
alias: '属性', alias: this.$t('cmdb.history.attribute'),
is_choice: true, is_choice: true,
name: 'attr_id', name: 'attr_id',
value_type: '2', value_type: '2',
choice_value: [] choice_value: [],
}, },
{ {
alias: '操作', alias: this.$t('operation'),
is_choice: true, is_choice: true,
name: 'operate_type', name: 'operate_type',
value_type: '2', value_type: '2',
choice_value: [ choice_value: [{ [this.$t('new')]: 0 }, { [this.$t('delete')]: 1 }, { [this.$t('update')]: 2 }],
{ '新增': 0 },
{ '删除': 1 },
{ '修改': 2 },
]
}, },
{ {
alias: 'CI_ID', alias: 'CI_ID',
is_choice: false, is_choice: false,
name: 'ci_id', name: 'ci_id',
value_type: '2' value_type: '2',
} },
], ],
} }
}, },
computed: { computed: {
...mapState(['locale']),
windowHeight() { windowHeight() {
return this.$store.state.windowHeight return this.$store.state.windowHeight
}, },
windowHeightMinus() { windowHeightMinus() {
return this.isExpand ? 396 : 331 return this.isExpand ? 396 : 331
} },
operateTypeMap() {
return new Map([
['0', this.$t('new')],
['1', this.$t('delete')],
['2', this.$t('update')],
])
},
},
watch: {
locale() {
this.reload()
},
}, },
async created() { async created() {
this.$watch( this.$watch(
@ -185,23 +198,19 @@ export default {
delete this.$refs.child.queryParams.attr_id delete this.$refs.child.queryParams.attr_id
} }
) )
await Promise.all([ await Promise.all([this.getUserList(), this.getTypes()])
this.getUserList(),
this.getTypes()
])
await this.getTable(this.queryParams) await this.getTable(this.queryParams)
}, },
updated() { updated() {
this.$refs.xTable.$el.querySelector('.vxe-table--body-wrapper').scrollTop = 0 this.$refs.xTable.$el.querySelector('.vxe-table--body-wrapper').scrollTop = 0
}, },
methods: { methods: {
// 获取表格数据
async getTable(queryParams) { async getTable(queryParams) {
try { try {
this.loading = true this.loading = true
const res = await getCIHistoryTable(queryParams) const res = await getCIHistoryTable(queryParams)
const tempArr = [] const tempArr = []
res.records.forEach(item => { res.records.forEach((item) => {
item[0].type_id = this.handleTypeId(item[0].type_id) item[0].type_id = this.handleTypeId(item[0].type_id)
item[1].forEach((subItem) => { item[1].forEach((subItem) => {
subItem.operate_type = this.handleOperateType(subItem.operate_type) subItem.operate_type = this.handleOperateType(subItem.operate_type)
@ -215,24 +224,22 @@ export default {
this.loading = false this.loading = false
} }
}, },
// 获取用户列表
async getUserList() { async getUserList() {
const res = await getUsers() const res = await getUsers()
this.userList = res.map(x => { this.userList = res.map((x) => {
const username = x.nickname const username = x.nickname
const obj = { const obj = {
[username]: username [username]: username,
} }
return obj return obj
}) })
this.ciTableAttrList[1].choice_value = this.userList this.ciTableAttrList[1].choice_value = this.userList
}, },
// 获取模型
async getTypes() { async getTypes() {
const res = await getCITypes() const res = await getCITypes()
const typesArr = [] const typesArr = []
const typesMap = new Map() const typesMap = new Map()
res.ci_types.forEach(item => { res.ci_types.forEach((item) => {
const tempObj = {} const tempObj = {}
tempObj[item.alias] = item.id tempObj[item.alias] = item.id
if (item.alias) { if (item.alias) {
@ -243,7 +250,6 @@ export default {
this.typeList = typesMap this.typeList = typesMap
this.ciTableAttrList[2].choice_value = typesArr this.ciTableAttrList[2].choice_value = typesArr
}, },
// 获取模型对应属性
async getAttrs(type_id) { async getAttrs(type_id) {
if (!type_id) { if (!type_id) {
this.ciTableAttrList[3].choice_value = [] this.ciTableAttrList[3].choice_value = []
@ -251,7 +257,7 @@ export default {
} }
const res = await getCITypeAttributesById(type_id) const res = await getCITypeAttributesById(type_id)
const attrsArr = [] const attrsArr = []
res.attributes.forEach(item => { res.attributes.forEach((item) => {
const tempObj = {} const tempObj = {}
tempObj[item.alias] = item.id tempObj[item.alias] = item.id
if (item.alias) { if (item.alias) {
@ -272,12 +278,10 @@ export default {
handleExpandChange(expand) { handleExpandChange(expand) {
this.isExpand = expand this.isExpand = expand
}, },
// 处理查询
handleSearch(queryParams) { handleSearch(queryParams) {
this.queryParams = queryParams this.queryParams = queryParams
this.getTable(this.queryParams) this.getTable(this.queryParams)
}, },
// 重置表单
searchFormReset() { searchFormReset() {
this.queryParams = { this.queryParams = {
page: 1, page: 1,
@ -287,21 +291,17 @@ export default {
username: '', username: '',
ci_id: undefined, ci_id: undefined,
attr_id: undefined, attr_id: undefined,
operate_type: undefined operate_type: undefined,
} }
// 将属性options重置
this.ciTableAttrList[3].choice_value = [] this.ciTableAttrList[3].choice_value = []
this.getTable(this.queryParams) this.getTable(this.queryParams)
}, },
// 转换operate_type
handleOperateType(operate_type) { handleOperateType(operate_type) {
return this.operateTypeMap.get(operate_type) return this.operateTypeMap.get(operate_type)
}, },
// 转换type_id
handleTypeId(type_id) { handleTypeId(type_id) {
return this.typeList.get(type_id) ? this.typeList.get(type_id) : type_id return this.typeList.get(type_id) ? this.typeList.get(type_id) : type_id
}, },
// 表单改变重新获取属性列表
searchFormChange(queryParams) { searchFormChange(queryParams) {
if (this.typeId !== queryParams.type_id) { if (this.typeId !== queryParams.type_id) {
this.typeId = queryParams.type_id this.typeId = queryParams.type_id
@ -312,20 +312,14 @@ export default {
this.$refs.child.queryParams.attr_id = undefined this.$refs.child.queryParams.attr_id = undefined
} }
}, },
// 合并表格
mergeRowMethod({ row, _rowIndex, column, visibleData }) { mergeRowMethod({ row, _rowIndex, column, visibleData }) {
const fields = ['created_at', 'user', 'type_id'] const fields = ['created_at', 'user', 'type_id']
// 单元格值 = [.属性] 确定一格
const cellValue = row[column.property] const cellValue = row[column.property]
const created_at = row['created_at'] const created_at = row['created_at']
// 如果单元格值不为空且作用域包含当前列
if (column.property === 'created_at') { if (column.property === 'created_at') {
if (cellValue && fields.includes(column.property)) { if (cellValue && fields.includes(column.property)) {
// 前一行
const prevRow = visibleData[_rowIndex - 1] const prevRow = visibleData[_rowIndex - 1]
// 下一行
let nextRow = visibleData[_rowIndex + 1] let nextRow = visibleData[_rowIndex + 1]
// 如果前一行不为空且前一行单元格的值与cellValue相同
if (prevRow && prevRow[column.property] === cellValue) { if (prevRow && prevRow[column.property] === cellValue) {
return { rowspan: 0, colspan: 0 } return { rowspan: 0, colspan: 0 }
} else { } else {
@ -340,11 +334,8 @@ export default {
} }
} else if (column.property === 'user') { } else if (column.property === 'user') {
if (cellValue && fields.includes(column.property)) { if (cellValue && fields.includes(column.property)) {
// 前一行
const prevRow = visibleData[_rowIndex - 1] const prevRow = visibleData[_rowIndex - 1]
// 下一行
let nextRow = visibleData[_rowIndex + 1] let nextRow = visibleData[_rowIndex + 1]
// 如果前一行不为空且前一行单元格的值与cellValue相同
if (prevRow && prevRow[column.property] === cellValue && prevRow['created_at'] === created_at) { if (prevRow && prevRow[column.property] === cellValue && prevRow['created_at'] === created_at) {
return { rowspan: 0, colspan: 0 } return { rowspan: 0, colspan: 0 }
} else { } else {
@ -359,11 +350,8 @@ export default {
} }
} else if (column.property === 'type_id') { } else if (column.property === 'type_id') {
if (cellValue && fields.includes(column.property)) { if (cellValue && fields.includes(column.property)) {
// 前一行
const prevRow = visibleData[_rowIndex - 1] const prevRow = visibleData[_rowIndex - 1]
// 下一行
let nextRow = visibleData[_rowIndex + 1] let nextRow = visibleData[_rowIndex + 1]
// 如果前一行不为空且前一行单元格的值与cellValue相同
if (prevRow && prevRow[column.property] === cellValue && prevRow['created_at'] === created_at) { if (prevRow && prevRow[column.property] === cellValue && prevRow['created_at'] === created_at) {
return { rowspan: 0, colspan: 0 } return { rowspan: 0, colspan: 0 }
} else { } else {
@ -401,11 +389,9 @@ export default {
this.getTable(this.queryParams) this.getTable(this.queryParams)
}, },
filterOption(input, option) { filterOption(input, option) {
return ( return option.componentOptions.children[0].text.indexOf(input) >= 0
option.componentOptions.children[0].text.indexOf(input) >= 0 },
) },
}
}
} }
</script> </script>

View File

@ -9,10 +9,10 @@
<a-dropdown class="dropdown" placement="topCenter" :trigger="['click']" :disabled="dropdownIsDisabled"> <a-dropdown class="dropdown" placement="topCenter" :trigger="['click']" :disabled="dropdownIsDisabled">
<a-menu slot="overlay"> <a-menu slot="overlay">
<a-menu-item v-for="(size,index) in pageSizes" :key="index" @click="handleItemClick(size)"> <a-menu-item v-for="(size,index) in pageSizes" :key="index" @click="handleItemClick(size)">
{{ size }}/ {{ size }}{{ $t('cmdb.history.itemsPerPage') }}
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
<a-button size="small"> {{ pageSize }}/ <a-icon type="down" /> </a-button> <a-button size="small"> {{ pageSize }}{{ $t('cmdb.history.itemsPerPage') }} <a-icon type="down" /> </a-button>
</a-dropdown> </a-dropdown>
</a-space> </a-space>
</a-col> </a-col>

View File

@ -21,27 +21,27 @@
stripe stripe
class="ops-stripe-table" class="ops-stripe-table"
> >
<vxe-column field="created_at" width="159px" title="操作时间"></vxe-column> <vxe-column field="created_at" width="159px" :title="$t('cmdb.history.opreateTime')"></vxe-column>
<vxe-column field="user" width="100px" title="用户"> <vxe-column field="user" width="100px" :title="$t('cmdb.history.user')">
<template #header="{ column }"> <template #header="{ column }">
<span>{{ column.title }}</span> <span>{{ column.title }}</span>
<a-popover trigger="click" placement="bottom"> <a-popover trigger="click" placement="bottom">
<a-icon class="filter" type="filter" theme="filled" /> <a-icon class="filter" type="filter" theme="filled" />
<a slot="content"> <a slot="content">
<a-input <a-input
placeholder="输入筛选用户名" :placeholder="$t('cmdb.history.userTips')"
size="small" size="small"
v-model="queryParams.username" v-model="queryParams.username"
style="width: 200px" style="width: 200px"
allowClear allowClear
/> />
<a-button type="link" class="filterButton" @click="filterUser">筛选</a-button> <a-button type="link" class="filterButton" @click="filterUser">{{ $t('cmdb.history.filter') }}</a-button>
<a-button type="link" class="filterResetButton" @click="filterUserReset">重置</a-button> <a-button type="link" class="filterResetButton" @click="filterUserReset">{{ $t('reset') }}</a-button>
</a> </a>
</a-popover> </a-popover>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="operate_type" width="89px" title="操作"> <vxe-column field="operate_type" width="89px" :title="$t('operation')">
<template #header="{ column }"> <template #header="{ column }">
<span>{{ column.title }}</span> <span>{{ column.title }}</span>
<a-popover trigger="click" placement="bottom"> <a-popover trigger="click" placement="bottom">
@ -49,7 +49,7 @@
<a slot="content"> <a slot="content">
<a-select <a-select
v-model="queryParams.operate_type" v-model="queryParams.operate_type"
placeholder="选择筛选操作" :placeholder="$t('cmdb.history.filterOperate')"
show-search show-search
style="width: 200px" style="width: 200px"
:filter-option="filterOption" :filter-option="filterOption"
@ -63,16 +63,18 @@
{{ Object.keys(choice)[0] }} {{ Object.keys(choice)[0] }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<a-button type="link" class="filterButton" @click="filterOperate">筛选</a-button> <a-button type="link" class="filterButton" @click="filterOperate">{{
<a-button type="link" class="filterResetButton" @click="filterOperateReset">重置</a-button> $t('cmdb.history.filter')
}}</a-button>
<a-button type="link" class="filterResetButton" @click="filterOperateReset">{{ $t('reset') }}</a-button>
</a> </a>
</a-popover> </a-popover>
</template> </template>
<template #default="{ row }"> <template #default="{ row }">
<a-tag color="green" v-if="row.operate_type.includes('新增')"> <a-tag color="green" v-if="row.operate_type.includes($t('new'))">
{{ row.operate_type }} {{ row.operate_type }}
</a-tag> </a-tag>
<a-tag color="orange" v-else-if="row.operate_type.includes('修改')"> <a-tag color="orange" v-else-if="row.operate_type.includes($t('update'))">
{{ row.operate_type }} {{ row.operate_type }}
</a-tag> </a-tag>
<a-tag color="red" v-else> <a-tag color="red" v-else>
@ -80,7 +82,7 @@
</a-tag> </a-tag>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="changeDescription" title="描述"> <vxe-column field="changeDescription" :title="$t('desc')">
<template #default="{ row }"> <template #default="{ row }">
<a-tag v-if="row && row.first"> <a-tag v-if="row && row.first">
{{ {{
@ -91,18 +93,18 @@
}` }`
}} }}
</a-tag> </a-tag>
<a-tag v-if="row.changeDescription === '没有修改'"> <a-tag v-if="row.changeDescription === $t('cmdb.history.noUpdate')">
{{ row.relation_type_id }} {{ row.relation_type_id }}
</a-tag> </a-tag>
<template v-else-if="row.operate_type.includes('修改')"> <template v-else-if="row.operate_type.includes($t('update'))">
<a-tag :key="index" color="orange" v-for="(tag, index) in row.changeArr"> <a-tag :key="index" color="orange" v-for="(tag, index) in row.changeArr">
{{ tag }} {{ tag }}
</a-tag> </a-tag>
</template> </template>
<a-tag color="green" v-else-if="row.operate_type.includes('新增')" :style="{ fontWeight: 'bolder' }"> <a-tag color="green" v-else-if="row.operate_type.includes($t('new'))" :style="{ fontWeight: 'bolder' }">
{{ row.relation_type_id }} {{ row.relation_type_id }}
</a-tag> </a-tag>
<a-tag color="red" v-else-if="row.operate_type.includes('删除')"> <a-tag color="red" v-else-if="row.operate_type.includes($t('delete'))">
{{ row.relation_type_id }} {{ row.relation_type_id }}
</a-tag> </a-tag>
<a-tag v-if="row && row.second"> <a-tag v-if="row && row.second">
@ -130,6 +132,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex'
import SearchForm from './searchForm' import SearchForm from './searchForm'
import Pager from './pager.vue' import Pager from './pager.vue'
import { getCITypes } from '@/modules/cmdb/api/CIType' import { getCITypes } from '@/modules/cmdb/api/CIType'
@ -138,6 +141,7 @@ import { getRelationTypes } from '@/modules/cmdb/api/relationType'
export default { export default {
name: 'RelationTable', name: 'RelationTable',
components: { SearchForm, Pager }, components: { SearchForm, Pager },
inject: ['reload'],
data() { data() {
return { return {
visible: false, visible: false,
@ -147,11 +151,6 @@ export default {
relationTypeList: null, relationTypeList: null,
total: 0, total: 0,
userList: [], userList: [],
operateTypeMap: new Map([
['0', '新增'],
['1', '删除'],
['2', '修改'],
]),
queryParams: { queryParams: {
page: 1, page: 1,
page_size: 50, page_size: 50,
@ -164,13 +163,13 @@ export default {
}, },
relationTableAttrList: [ relationTableAttrList: [
{ {
alias: '日期', alias: this.$t('cmdb.ciType.date'),
is_choice: false, is_choice: false,
name: 'datetime', name: 'datetime',
value_type: '3', value_type: '3',
}, },
{ {
alias: '用户', alias: this.$t('cmdb.history.user'),
is_choice: true, is_choice: true,
name: 'username', name: 'username',
value_type: '2', value_type: '2',
@ -191,36 +190,44 @@ export default {
choice_value: [], choice_value: [],
}, },
{ {
alias: '操作', alias: this.$t('operation'),
is_choice: true, is_choice: true,
name: 'operate_type', name: 'operate_type',
value_type: '2', value_type: '2',
choice_value: [{ 新增: 0 }, { 删除: 1 }, { 修改: 2 }], choice_value: [{ [this.$t('new')]: 0 }, { [this.$t('delete')]: 1 }, { [this.$t('update')]: 2 }],
}, },
], ],
} }
}, },
async created() { async created() {
await Promise.all([ await Promise.all([this.getRelationTypes(), this.getUserList(), this.getTypes()])
this.getRelationTypes(),
this.getUserList(),
this.getTypes(),
])
await this.getTable(this.queryParams) await this.getTable(this.queryParams)
}, },
updated() { updated() {
this.$refs.xTable.$el.querySelector('.vxe-table--body-wrapper').scrollTop = 0 this.$refs.xTable.$el.querySelector('.vxe-table--body-wrapper').scrollTop = 0
}, },
computed: { computed: {
...mapState(['locale']),
windowHeight() { windowHeight() {
return this.$store.state.windowHeight return this.$store.state.windowHeight
}, },
windowHeightMinus() { windowHeightMinus() {
return this.isExpand ? 396 : 331 return this.isExpand ? 396 : 331
}, },
operateTypeMap() {
return new Map([
['0', this.$t('new')],
['1', this.$t('delete')],
['2', this.$t('update')],
])
},
},
watch: {
locale() {
this.reload()
},
}, },
methods: { methods: {
// 获取表格数据
async getTable(queryParams) { async getTable(queryParams) {
try { try {
this.loading = true this.loading = true
@ -242,7 +249,6 @@ export default {
this.loading = false this.loading = false
} }
}, },
// 获取用户列表
async getUserList() { async getUserList() {
const res = await getUsers() const res = await getUsers()
this.userList = res.map((x) => { this.userList = res.map((x) => {
@ -254,7 +260,6 @@ export default {
}) })
this.relationTableAttrList[1].choice_value = this.userList this.relationTableAttrList[1].choice_value = this.userList
}, },
// 获取模型
async getTypes() { async getTypes() {
const res = await getCITypes() const res = await getCITypes()
const typesArr = [] const typesArr = []
@ -268,7 +273,6 @@ export default {
this.relationTableAttrList[2].choice_value = typesArr this.relationTableAttrList[2].choice_value = typesArr
this.relationTableAttrList[3].choice_value = typesArr this.relationTableAttrList[3].choice_value = typesArr
}, },
// 获取关系
async getRelationTypes() { async getRelationTypes() {
const res = await getRelationTypes() const res = await getRelationTypes()
const relationTypeMap = new Map() const relationTypeMap = new Map()
@ -289,12 +293,10 @@ export default {
handleExpandChange(expand) { handleExpandChange(expand) {
this.isExpand = expand this.isExpand = expand
}, },
// 处理查询
handleSearch(queryParams) { handleSearch(queryParams) {
this.queryParams = queryParams this.queryParams = queryParams
this.getTable(queryParams) this.getTable(queryParams)
}, },
// 重置表单
searchFormReset() { searchFormReset() {
this.queryParams = { this.queryParams = {
page: 1, page: 1,
@ -308,28 +310,20 @@ export default {
} }
this.getTable(this.queryParams) this.getTable(this.queryParams)
}, },
// 转换operate_type
handleOperateType(operate_type) { handleOperateType(operate_type) {
return this.operateTypeMap.get(operate_type) return this.operateTypeMap.get(operate_type)
}, },
// 转换relation_type_id
handleRelationType(relation_type_id) { handleRelationType(relation_type_id) {
return this.relationTypeList.get(relation_type_id) return this.relationTypeList.get(relation_type_id)
}, },
// 合并表格
mergeRowMethod({ row, _rowIndex, column, visibleData }) { mergeRowMethod({ row, _rowIndex, column, visibleData }) {
const fields = ['created_at', 'user'] const fields = ['created_at', 'user']
// 单元格值 = [.属性] 确定一格
const cellValue = row[column.property] const cellValue = row[column.property]
const created_at = row['created_at'] const created_at = row['created_at']
// 如果单元格值不为空且作用域包含当前列
if (column.property === 'created_at') { if (column.property === 'created_at') {
if (cellValue && fields.includes(column.property)) { if (cellValue && fields.includes(column.property)) {
// 前一行
const prevRow = visibleData[_rowIndex - 1] const prevRow = visibleData[_rowIndex - 1]
// 下一行
let nextRow = visibleData[_rowIndex + 1] let nextRow = visibleData[_rowIndex + 1]
// 如果前一行不为空且前一行单元格的值与cellValue相同
if (prevRow && prevRow[column.property] === cellValue) { if (prevRow && prevRow[column.property] === cellValue) {
return { rowspan: 0, colspan: 0 } return { rowspan: 0, colspan: 0 }
} else { } else {
@ -344,11 +338,8 @@ export default {
} }
} else if (column.property === 'user') { } else if (column.property === 'user') {
if (cellValue && fields.includes(column.property)) { if (cellValue && fields.includes(column.property)) {
// 前一行
const prevRow = visibleData[_rowIndex - 1] const prevRow = visibleData[_rowIndex - 1]
// 下一行
let nextRow = visibleData[_rowIndex + 1] let nextRow = visibleData[_rowIndex + 1]
// 如果前一行不为空且前一行单元格的值与cellValue相同
if (prevRow && prevRow[column.property] === cellValue && prevRow['created_at'] === created_at) { if (prevRow && prevRow[column.property] === cellValue && prevRow['created_at'] === created_at) {
return { rowspan: 0, colspan: 0 } return { rowspan: 0, colspan: 0 }
} else { } else {

View File

@ -18,7 +18,7 @@
> >
<a-select <a-select
v-model="queryParams[attr.name]" v-model="queryParams[attr.name]"
placeholder="请选择" :placeholder="$t('cmdb.history.pleaseSelect')"
v-if="attr.is_choice" v-if="attr.is_choice"
show-search show-search
:filter-option="filterOption" :filter-option="filterOption"
@ -37,7 +37,7 @@
@change="onChange" @change="onChange"
:style="{width:'100%'}" :style="{width:'100%'}"
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
:placeholder="['开始时间', '结束时间']" :placeholder="[$t('cmdb.history.startTime'), $t('cmdb.history.endTime')]"
:show-time="{ :show-time="{
hideDisabledOptions: true, hideDisabledOptions: true,
defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')], defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
@ -65,7 +65,7 @@
> >
<a-select <a-select
v-model="queryParams[item.name]" v-model="queryParams[item.name]"
placeholder="请选择" :placeholder="$t('cmdb.history.pleaseSelect')"
v-if="item.is_choice" v-if="item.is_choice"
show-search show-search
:filter-option="filterOption" :filter-option="filterOption"
@ -84,7 +84,7 @@
:style="{width:'100%'}" :style="{width:'100%'}"
@change="onChange" @change="onChange"
format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm"
:placeholder="['开始时间', '结束时间']" :placeholder="[$t('cmdb.history.startTime'), $t('cmdb.history.endTime')]"
v-else-if="valueTypeMap[item.value_type] == 'date' || valueTypeMap[item.value_type] == 'datetime'" v-else-if="valueTypeMap[item.value_type] == 'date' || valueTypeMap[item.value_type] == 'datetime'"
:show-time="{ :show-time="{
hideDisabledOptions: true, hideDisabledOptions: true,
@ -99,13 +99,13 @@
<a-row> <a-row>
<a-col :span="24" :style="{ textAlign: 'right' , marginBottom: '10px' }"> <a-col :span="24" :style="{ textAlign: 'right' , marginBottom: '10px' }">
<a-button type="primary" html-type="submit" @click="handleSearch"> <a-button type="primary" html-type="submit" @click="handleSearch">
查询 {{ $t('query') }}
</a-button> </a-button>
<a-button :style="{ marginLeft: '8px' }" @click="handleReset"> <a-button :style="{ marginLeft: '8px' }" @click="handleReset">
重置 {{ $t('reset') }}
</a-button> </a-button>
<a :style="{ marginLeft: '8px', fontSize: '12px' }" @click="toggle" v-if="attrList.length >= 4"> <a :style="{ marginLeft: '8px', fontSize: '12px' }" @click="toggle" v-if="attrList.length >= 4">
{{ expand?'隐藏':'展开' }} <a-icon :type="expand ? 'up' : 'down'" /> {{ expand?$t('hide'):$t('expand') }} <a-icon :type="expand ? 'up' : 'down'" />
</a> </a>
</a-col> </a-col>
</a-row> </a-row>
@ -126,7 +126,6 @@ export default {
}, },
data() { data() {
return { return {
valueTypeMap,
expand: false, expand: false,
queryParams: { queryParams: {
page: 1, page: 1,
@ -135,6 +134,11 @@ export default {
date: undefined date: undefined
} }
}, },
computed: {
valueTypeMap() {
return valueTypeMap()
},
},
watch: { watch: {
queryParams: { queryParams: {
deep: true, deep: true,

View File

@ -9,33 +9,33 @@
:data="tableData" :data="tableData"
v-bind="ci_id ? { maxHeight: `${windowHeight - 94}px` } : { height: `${windowHeight - 225}px` }" v-bind="ci_id ? { maxHeight: `${windowHeight - 94}px` } : { height: `${windowHeight - 225}px` }"
> >
<vxe-column field="trigger_name" title="触发器名称"> </vxe-column> <vxe-column field="trigger_name" :title="$t('cmdb.history.triggerName')"> </vxe-column>
<vxe-column field="type" title="类型"> <vxe-column field="type" :title="$t('type')">
<template #default="{ row }"> <template #default="{ row }">
<span v-if="row.trigger && row.trigger.attr_id">日期属性</span> <span v-if="row.trigger && row.trigger.attr_id">{{ $t('cmdb.ciType.triggerDate') }}</span>
<span v-else-if="row.trigger && !row.trigger.attr_id">数据变更</span> <span v-else-if="row.trigger && !row.trigger.attr_id">{{ $t('cmdb.ciType.triggerDataChange') }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column title="事件"> <vxe-column :title="$t('cmdb.history.event')">
<template #default="{ row }"> <template #default="{ row }">
<span v-if="row.operate_type === '0'">新增实例</span> <span v-if="row.operate_type === '0'">{{ $t('cmdb.ciType.addInstance') }}</span>
<span v-else-if="row.operate_type === '1'">删除实例</span> <span v-else-if="row.operate_type === '1'">{{ $t('cmdb.ciType.deleteInstance') }}</span>
<span v-else-if="row.operate_type === '2'">实例变更</span> <span v-else-if="row.operate_type === '2'">{{ $t('cmdb.ciType.changeInstance') }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column title="动作"> <vxe-column :title="$t('cmdb.history.action')">
<template #default="{ row }"> <template #default="{ row }">
<span v-if="row.webhook">Webhook</span> <span v-if="row.webhook">Webhook</span>
<span v-else-if="row.notify">通知</span> <span v-else-if="row.notify">{{ $t('cmdb.ciType.notify') }}</span>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column title="状态"> <vxe-column :title="$t('cmdb.history.status')">
<template #default="{ row }"> <template #default="{ row }">
<a-tag color="green" v-if="row.is_ok">已完成</a-tag> <a-tag color="green" v-if="row.is_ok">{{ $t('cmdb.history.done') }}</a-tag>
<a-tag color="red" v-else>未完成</a-tag> <a-tag color="red" v-else>{{ $t('cmdb.history.undone') }}</a-tag>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column title="触发时间"> <vxe-column :title="$t('cmdb.history.triggerTime')">
<template #default="{row}"> <template #default="{row}">
{{ row.updated_at || row.created_at }} {{ row.updated_at || row.created_at }}
</template> </template>
@ -49,7 +49,7 @@
:page-size-options="pageSizeOptions" :page-size-options="pageSizeOptions"
:current="tablePage.currentPage" :current="tablePage.currentPage"
:total="tablePage.totalResult" :total="tablePage.totalResult"
:show-total="(total, range) => `共 ${total} 条记录`" :show-total="(total, range) => $t('cmdb.history.totalItems', { total: total })"
:page-size="tablePage.pageSize" :page-size="tablePage.pageSize"
:default-current="1" :default-current="1"
@change="pageOrSizeChange" @change="pageOrSizeChange"

View File

@ -18,9 +18,9 @@
stripe stripe
class="ops-stripe-table" class="ops-stripe-table"
> >
<vxe-column field="created_at" width="159px" title="操作时间"></vxe-column> <vxe-column field="created_at" width="159px" :title="$t('cmdb.history.opreateTime')"></vxe-column>
<vxe-column field="user" width="116px" title="用户"></vxe-column> <vxe-column field="user" width="116px" :title="$t('cmdb.history.user')"></vxe-column>
<vxe-column field="operate_type" width="135px" title="操作"> <vxe-column field="operate_type" width="135px" :title="$t('operation')">
<template #header="{ column }"> <template #header="{ column }">
<span>{{ column.title }}</span> <span>{{ column.title }}</span>
<a-popover trigger="click" placement="bottom"> <a-popover trigger="click" placement="bottom">
@ -28,7 +28,7 @@
<a slot="content"> <a slot="content">
<a-select <a-select
v-model="queryParams.operate_type" v-model="queryParams.operate_type"
placeholder="选择筛选操作" :placeholder="$t('cmdb.history.filterOperate')"
show-search show-search
style="width: 200px" style="width: 200px"
:filter-option="filterOption" :filter-option="filterOption"
@ -42,16 +42,18 @@
{{ Object.keys(choice)[0] }} {{ Object.keys(choice)[0] }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<a-button type="link" class="filterButton" @click="filterOperate">筛选</a-button> <a-button type="link" class="filterButton" @click="filterOperate">{{
<a-button type="link" class="filterResetButton" @click="filterOperateReset">重置</a-button> $t('cmdb.history.filter')
}}</a-button>
<a-button type="link" class="filterResetButton" @click="filterOperateReset">{{ $t('reset') }}</a-button>
</a> </a>
</a-popover> </a-popover>
</template> </template>
<template #default="{ row }"> <template #default="{ row }">
<a-tag color="green" v-if="row.operate_type.includes('新增')"> <a-tag color="green" v-if="row.operate_type.includes($t('new'))">
{{ row.operate_type }} {{ row.operate_type }}
</a-tag> </a-tag>
<a-tag color="orange" v-else-if="row.operate_type.includes('修改')"> <a-tag color="orange" v-else-if="row.operate_type.includes($t('update'))">
{{ row.operate_type }} {{ row.operate_type }}
</a-tag> </a-tag>
<a-tag color="red" v-else> <a-tag color="red" v-else>
@ -59,25 +61,25 @@
</a-tag> </a-tag>
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="type_id" title="模型" width="150px"> <vxe-column field="type_id" :title="$t('cmdb.ciType.ciType')" width="150px">
<template #default="{ row }"> <template #default="{ row }">
{{ row.operate_type === '删除模型' ? row.change.alias : row.type_id }} {{ row.operate_type === $t('cmdb.history.deleteCIType') ? row.change.alias : row.type_id }}
</template> </template>
</vxe-column> </vxe-column>
<vxe-column field="changeDescription" title="描述"> <vxe-column field="changeDescription" :title="$t('desc')">
<template #default="{ row }"> <template #default="{ row }">
<p style="color:rgba(0, 0, 0, 0.65);" v-if="row.changeDescription === '没有修改'"> <p style="color:rgba(0, 0, 0, 0.65);" v-if="row.changeDescription === $t('cmdb.history.noUpdate')">
{{ row.changeDescription }} {{ row.changeDescription }}
</p> </p>
<template v-else-if="row.operate_type.includes('修改')"> <template v-else-if="row.operate_type.includes($t('update'))">
<p :key="index" style="color:#fa8c16;" v-for="(tag, index) in row.changeArr"> <p :key="index" style="color:#fa8c16;" v-for="(tag, index) in row.changeArr">
{{ tag }} {{ tag }}
</p> </p>
</template> </template>
<p class="more-tag" style="color:#52c41a;" v-else-if="row.operate_type.includes('新增')"> <p class="more-tag" style="color:#52c41a;" v-else-if="row.operate_type.includes($t('new'))">
{{ row.changeDescription }} {{ row.changeDescription }}
</p> </p>
<p style="color:#f5222d;" v-else-if="row.operate_type.includes('删除')"> <p style="color:#f5222d;" v-else-if="row.operate_type.includes($t('delete'))">
{{ row.changeDescription }} {{ row.changeDescription }}
</p> </p>
</template> </template>
@ -94,7 +96,7 @@
:page-size="pageSize" :page-size="pageSize"
@change="onChange" @change="onChange"
@showSizeChange="onShowSizeChange" @showSizeChange="onShowSizeChange"
:show-total="(total) => `共 ${total} 条记录`" :show-total="(total) => $t('cmdb.history.totalItems', { total: total })"
> >
</a-pagination> </a-pagination>
</a-col> </a-col>
@ -104,6 +106,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { mapState } from 'vuex'
import SearchForm from './searchForm' import SearchForm from './searchForm'
import { getCITypesTable, getUsers } from '@/modules/cmdb/api/history' import { getCITypesTable, getUsers } from '@/modules/cmdb/api/history'
import { getCITypes } from '@/modules/cmdb/api/CIType' import { getCITypes } from '@/modules/cmdb/api/CIType'
@ -111,59 +114,13 @@ import { getRelationTypes } from '@/modules/cmdb/api/relationType'
export default { export default {
name: 'TypeTable', name: 'TypeTable',
components: { SearchForm }, components: { SearchForm },
inject: ['reload'],
data() { data() {
return { return {
loading: true, loading: true,
relationTypeList: null, relationTypeList: null,
operateTypeMap: new Map([
['0', '新增模型'],
['1', '修改模型'],
['2', '删除模型'],
['3', '新增属性'],
['4', '修改属性'],
['5', '删除属性'],
['6', '新增触发器'],
['7', '修改触发器'],
['8', '删除触发器'],
['9', '新增联合唯一'],
['10', '修改联合唯一'],
['11', '删除联合唯一'],
['12', '新增关系'],
['13', '删除关系'],
]),
typeList: null, typeList: null,
userList: [], userList: [],
typeTableAttrList: [
{
alias: '模型',
is_choice: true,
name: 'type_id',
value_type: '2',
choice_value: [],
},
{
alias: '操作',
is_choice: true,
name: 'operate_type',
value_type: '2',
choice_value: [
{ 新增模型: 0 },
{ 修改模型: 1 },
{ 删除模型: 2 },
{ 新增属性: 3 },
{ 修改属性: 4 },
{ 删除属性: 5 },
{ 新增触发器: 6 },
{ 修改触发器: 7 },
{ 删除触发器: 8 },
{ 新增联合唯一: 9 },
{ 修改联合唯一: 10 },
{ 删除联合唯一: 11 },
{ 新增关系: 12 },
{ 删除关系: 13 },
],
},
],
pageSizeOptions: ['50', '100', '200'], pageSizeOptions: ['50', '100', '200'],
isExpand: false, isExpand: false,
current: 1, current: 1,
@ -177,26 +134,72 @@ export default {
type_id: undefined, type_id: undefined,
operate_type: undefined, operate_type: undefined,
}, },
typeTableAttrList: [
{
alias: this.$t('cmdb.ciType.ciType'),
is_choice: true,
name: 'type_id',
value_type: '2',
choice_value: [],
},
{
alias: this.$t('operation'),
is_choice: true,
name: 'operate_type',
value_type: '2',
choice_value: [
{ [this.$t('cmdb.history.addCIType')]: 0 },
{ [this.$t('cmdb.history.updateCIType')]: 1 },
{ [this.$t('cmdb.history.deleteCIType')]: 2 },
{ [this.$t('cmdb.history.addAttribute')]: 3 },
{ [this.$t('cmdb.history.updateAttribute')]: 4 },
{ [this.$t('cmdb.history.deleteAttribute')]: 5 },
{ [this.$t('cmdb.history.addTrigger')]: 6 },
{ [this.$t('cmdb.history.updateTrigger')]: 7 },
{ [this.$t('cmdb.history.deleteTrigger')]: 8 },
{ [this.$t('cmdb.history.addUniqueConstraint')]: 9 },
{ [this.$t('cmdb.history.updateUniqueConstraint')]: 10 },
{ [this.$t('cmdb.history.deleteUniqueConstraint')]: 11 },
{ [this.$t('cmdb.history.addRelation')]: 12 },
{ [this.$t('cmdb.history.deleteRelation')]: 13 },
],
},
],
} }
}, },
async created() { async created() {
await Promise.all([ await Promise.all([this.getRelationTypes(), this.getTypes(), this.getUserList()])
this.getRelationTypes(),
this.getTypes(),
this.getUserList(),
])
await this.getTable(this.queryParams) await this.getTable(this.queryParams)
}, },
updated() { updated() {
this.$refs.xTable.$el.querySelector('.vxe-table--body-wrapper').scrollTop = 0 this.$refs.xTable.$el.querySelector('.vxe-table--body-wrapper').scrollTop = 0
}, },
computed: { computed: {
...mapState(['locale']),
windowHeight() { windowHeight() {
return this.$store.state.windowHeight return this.$store.state.windowHeight
}, },
windowHeightMinus() { windowHeightMinus() {
return this.isExpand ? 396 : 335 return this.isExpand ? 396 : 335
}, },
operateTypeMap() {
return new Map([
['0', this.$t('cmdb.history.addCIType')],
['1', this.$t('cmdb.history.updateCIType')],
['2', this.$t('cmdb.history.deleteCIType')],
['3', this.$t('cmdb.history.addAttribute')],
['4', this.$t('cmdb.history.updateAttribute')],
['5', this.$t('cmdb.history.deleteAttribute')],
['6', this.$t('cmdb.history.addTrigger')],
['7', this.$t('cmdb.history.updateTrigger')],
['8', this.$t('cmdb.history.deleteTrigger')],
['9', this.$t('cmdb.history.addUniqueConstraint')],
['10', this.$t('cmdb.history.updateUniqueConstraint')],
['11', this.$t('cmdb.history.deleteUniqueConstraint')],
['12', this.$t('cmdb.history.addRelation')],
['13', this.$t('cmdb.history.deleteRelation')],
])
},
}, },
watch: { watch: {
current(val) { current(val) {
@ -205,9 +208,11 @@ export default {
pageSize(val) { pageSize(val) {
this.queryParams.page_size = val this.queryParams.page_size = val
}, },
locale() {
this.reload()
},
}, },
methods: { methods: {
// 获取表格数据
async getTable(queryParams) { async getTable(queryParams) {
try { try {
this.loading = true this.loading = true
@ -228,7 +233,6 @@ export default {
this.loading = false this.loading = false
} }
}, },
// 获取模型
async getTypes() { async getTypes() {
const res = await getCITypes() const res = await getCITypes()
const typesArr = [] const typesArr = []
@ -242,10 +246,8 @@ export default {
} }
}) })
this.typeList = typesMap this.typeList = typesMap
// 设置模型options选项
this.typeTableAttrList[0].choice_value = typesArr this.typeTableAttrList[0].choice_value = typesArr
}, },
// 获取用户列表
async getUserList() { async getUserList() {
const res = await getUsers() const res = await getUsers()
const userListMap = new Map() const userListMap = new Map()
@ -254,7 +256,6 @@ export default {
}) })
this.userList = userListMap this.userList = userListMap
}, },
// 获取关系
async getRelationTypes() { async getRelationTypes() {
const res = await getRelationTypes() const res = await getRelationTypes()
const relationTypeMap = new Map() const relationTypeMap = new Map()
@ -275,13 +276,11 @@ export default {
handleExpandChange(expand) { handleExpandChange(expand) {
this.isExpand = expand this.isExpand = expand
}, },
// 处理查询
handleSearch(queryParams) { handleSearch(queryParams) {
this.current = 1 this.current = 1
this.queryParams = queryParams this.queryParams = queryParams
this.getTable(this.queryParams) this.getTable(this.queryParams)
}, },
// 重置表单
searchFormReset() { searchFormReset() {
this.queryParams = { this.queryParams = {
page: 1, page: 1,
@ -291,31 +290,26 @@ export default {
} }
this.getTable(this.queryParams) this.getTable(this.queryParams)
}, },
// 转换operate_type
handleOperateType(operate_type) { handleOperateType(operate_type) {
return this.operateTypeMap.get(operate_type) return this.operateTypeMap.get(operate_type)
}, },
// 转换type_id
handleTypeId(type_id) { handleTypeId(type_id) {
return this.typeList.get(type_id) ? this.typeList.get(type_id) : type_id return this.typeList.get(type_id) ? this.typeList.get(type_id) : type_id
}, },
// 转换uid
handleUID(uid) { handleUID(uid) {
return this.userList.get(uid) return this.userList.get(uid)
}, },
// 转换relation_type_id
handleRelationType(relation_type_id) { handleRelationType(relation_type_id) {
return this.relationTypeList.get(relation_type_id) return this.relationTypeList.get(relation_type_id)
}, },
// 处理改变描述
handleChangeDescription(item, operate_type) { handleChangeDescription(item, operate_type) {
switch (operate_type) { switch (operate_type) {
// 新增模型 // add CIType
case '0': { case '0': {
item.changeDescription = '新增模型:' + item.change.alias item.changeDescription = this.$t('cmdb.history.addCIType') + ': ' + item.change.alias
break break
} }
// 修改模型 // update CIType
case '1': { case '1': {
item.changeArr = [] item.changeArr = []
for (const key in item.change.old) { for (const key in item.change.old) {
@ -323,30 +317,30 @@ export default {
const oldVal = item.change.old[key] const oldVal = item.change.old[key]
if (!_.isEqual(newVal, oldVal) && key !== 'updated_at') { if (!_.isEqual(newVal, oldVal) && key !== 'updated_at') {
if (oldVal === null) { if (oldVal === null) {
const str = ` [ ${key} : 改为 ${newVal || '""'} ] ` const str = ` [ ${key} : ${newVal || '""'} ] `
item.changeDescription += str item.changeDescription += str
item.changeArr.push(str) item.changeArr.push(str)
} else { } else {
const str = ` [ ${key} : ${oldVal || '""'} 改为 ${newVal || '""'} ] ` const str = ` [ ${key} : ${oldVal || '""'} -> ${newVal || '""'} ] `
item.changeDescription += ` [ ${key} : ${oldVal || '""'} 改为 ${newVal || '""'} ] ` item.changeDescription += ` [ ${key} : ${oldVal || '""'} -> ${newVal || '""'} ] `
item.changeArr.push(str) item.changeArr.push(str)
} }
} }
} }
if (!item.changeDescription) item.changeDescription = '没有修改' if (!item.changeDescription) item.changeDescription = this.$t('cmdb.history.noModifications')
break break
} }
// 删除模型 // delete CIType
case '2': { case '2': {
item.changeDescription = `删除模型${item.change.alias}` item.changeDescription = this.$t('cmdb.history.addCIType') + ': ' + `${item.change.alias}`
break break
} }
// 新增属性 // add Attribute
case '3': { case '3': {
item.changeDescription = `属性名${item.change.alias}` item.changeDescription = `${this.$t('cmdb.history.attr')}${item.change.alias}`
break break
} }
// 修改属性 // update Attribute
case '4': { case '4': {
item.changeArr = [] item.changeArr = []
for (const key in item.change.old) { for (const key in item.change.old) {
@ -363,74 +357,86 @@ export default {
if (Object.prototype.toString.call(oldStr) === '[object Object]') { if (Object.prototype.toString.call(oldStr) === '[object Object]') {
oldStr = JSON.stringify(oldStr) oldStr = JSON.stringify(oldStr)
} }
const str = `${key} : ${oldStr ? ` ${oldStr || '""'} ` : ''} 改为 ${newStr || '""'}` const str = `${key} : ${oldStr ? ` ${oldStr || '""'} ` : ''} -> ${newStr || '""'}`
item.changeDescription += ` [ ${str} ] ` item.changeDescription += ` [ ${str} ] `
item.changeArr.push(str) item.changeArr.push(str)
} }
} }
if (!item.changeDescription) item.changeDescription = '没有修改' if (!item.changeDescription) item.changeDescription = this.$t('cmdb.history.noModifications')
break break
} }
// 删除属性 // delete Attribute
case '5': { case '5': {
item.changeDescription = `删除${item.change.alias}` item.changeDescription = `${this.$t('delete')}${item.change.alias}`
break break
} }
// 新增触发器 // add trigger
case '6': { case '6': {
item.changeDescription = `属性ID${item.change.attr_id}提前${item.change.option.before_days}主题${item.change.option.subject}\n内容${item.change.option.body}\n通知时间${item.change.option.notify_at}` item.changeDescription = this.$t('cmdb.history.noModifications', {
attr_id: item.change.attr_id,
before_days: item.change.option.before_days,
subject: item.change.option.subject,
body: item.change.option.body,
notify_at: item.change.option.notify_at,
})
break break
} }
// 修改触发器 // update trigger
case '7': { case '7': {
item.changeArr = [] item.changeArr = []
for (const key in item.change.old.option) { for (const key in item.change.old.option) {
const newVal = item.change.new.option[key] const newVal = item.change.new.option[key]
const oldVal = item.change.old.option[key] const oldVal = item.change.old.option[key]
if (!_.isEqual(newVal, oldVal) && key !== 'updated_at') { if (!_.isEqual(newVal, oldVal) && key !== 'updated_at') {
const str = ` [ ${key} : ${oldVal} 改为 ${newVal} ] ` const str = ` [ ${key} : ${oldVal} -> ${newVal} ] `
item.changeDescription += str item.changeDescription += str
item.changeArr.push(str) item.changeArr.push(str)
} }
} }
if (!item.changeDescription) item.changeDescription = '没有修改' if (!item.changeDescription) item.changeDescription = this.$t('cmdb.history.noModifications')
break break
} }
// 删除触发器 // delete trigger
case '8': { case '8': {
item.changeDescription = `属性ID${item.change.attr_id}提前${item.change.option.before_days}主题${item.change.option.subject}\n内容${item.change.option.body}\n通知时间${item.change.option.notify_at}` item.changeDescription = this.$t('cmdb.history.noModifications', {
attr_id: item.change.attr_id,
before_days: item.change.option.before_days,
subject: item.change.option.subject,
body: item.change.option.body,
notify_at: item.change.option.notify_at,
})
break break
} }
// 新增联合唯一 // add unique constraint
case '9': { case '9': {
item.changeDescription = `属性id[${item.change.attr_ids}]` item.changeDescription = `${this.$t('cmdb.history.attrId')}[${item.change.attr_ids}]`
break break
} }
// 修改联合唯一 // update unique constraint
case '10': { case '10': {
item.changeArr = [] item.changeArr = []
const oldVal = item.change.old.attr_ids const oldVal = item.change.old.attr_ids
const newVal = item.change.new.attr_ids const newVal = item.change.new.attr_ids
const str = `属性id[${oldVal}] -> [${newVal}]` const str = `${this.$t('cmdb.history.attrId')}[${oldVal}] -> [${newVal}]`
item.changeDescription = str item.changeDescription = str
item.changeArr.push(str) item.changeArr.push(str)
break break
} }
// 删除联合唯一 // delete unique constraint
case '11': { case '11': {
item.changeDescription = `属性id[${item.change.attr_ids}]` item.changeDescription = `${this.$t('cmdb.history.attrId')}[${item.change.attr_ids}]`
break break
} }
// 新增关系 // add relation
case '12': { case '12': {
item.changeDescription = `新增${item.change.parent.alias} -> ${this.handleRelationType( item.changeDescription = `${this.$t('new')}${item.change.parent.alias} -> ${this.handleRelationType(
item.change.relation_type_id item.change.relation_type_id
)} -> ${item.change.child.alias}` )} -> ${item.change.child.alias}`
break break
} }
// 删除关系 // delete relation
case '13': { case '13': {
item.changeDescription = `删除${item.change.parent_id.alias} -> ${this.handleRelationType( item.changeDescription = `${this.$t('delete')}${item.change.parent_id.alias} -> ${this.handleRelationType(
item.change.relation_type_id item.change.relation_type_id
)} -> ${item.change.child.alias}` )} -> ${item.change.child.alias}`
break break

View File

@ -2,10 +2,10 @@
<div class="cmdb-preference" :style="{ height: `${windowHeight - 40}px` }"> <div class="cmdb-preference" :style="{ height: `${windowHeight - 40}px` }">
<div class="cmdb-preference-left"> <div class="cmdb-preference-left">
<div class="cmdb-preference-left-card"> <div class="cmdb-preference-left-card">
<span class="cmdb-preference-left-card-title">我的订阅</span> <span class="cmdb-preference-left-card-title">{{ $t('cmdb.preference.mySub') }}</span>
<span <span
class="cmdb-preference-left-card-content" class="cmdb-preference-left-card-content"
><ops-icon type="cmdb-ci" :style="{ marginRight: '5px' }" />资源数据 ><ops-icon type="cmdb-ci" :style="{ marginRight: '5px' }" />{{ $t('cmdb.menu.ciTable') }}:
<a-badge <a-badge
showZero showZero
:count="self.instance.length" :count="self.instance.length"
@ -20,7 +20,7 @@
> >
<span <span
class="cmdb-preference-left-card-content" class="cmdb-preference-left-card-content"
><ops-icon type="cmdb-tree" :style="{ marginRight: '5px' }" />资源层级 ><ops-icon type="cmdb-tree" :style="{ marginRight: '5px' }" />{{ $t('cmdb.menu.ciTree') }}:
<a-badge <a-badge
showZero showZero
:count="self.tree.length" :count="self.tree.length"
@ -66,14 +66,14 @@
</div> </div>
<span class="cmdb-preference-group-content-title">{{ ciType.alias || ciType.name }}</span> <span class="cmdb-preference-group-content-title">{{ ciType.alias || ciType.name }}</span>
<span class="cmdb-preference-group-content-action"> <span class="cmdb-preference-group-content-action">
<a-tooltip title="取消订阅"> <a-tooltip :title="$t('cmdb.preference.cancelSub')">
<span <span
@click="unsubscribe(ciType, group.type)" @click="unsubscribe(ciType, group.type)"
><ops-icon type="cmdb-preference-cancel-subscribe" /> ><ops-icon type="cmdb-preference-cancel-subscribe" />
</span> </span>
</a-tooltip> </a-tooltip>
<a-divider type="vertical" :style="{ margin: '0 3px' }" /> <a-divider type="vertical" :style="{ margin: '0 3px' }" />
<a-tooltip title="编辑订阅"> <a-tooltip :title="$t('cmdb.preference.editSub')">
<span <span
@click="openSubscribeSetting(ciType, `${index + 1}`)" @click="openSubscribeSetting(ciType, `${index + 1}`)"
><ops-icon ><ops-icon
@ -126,7 +126,8 @@
<div class="cmdb-preference-colleague"> <div class="cmdb-preference-colleague">
<template v-if="type_id2users[item.id] && type_id2users[item.id].length"> <template v-if="type_id2users[item.id] && type_id2users[item.id].length">
<span <span
>{{ type_id2users[item.id].length > 99 ? '99+' : type_id2users[item.id].length }}位同事已订阅</span >{{ type_id2users[item.id].length > 99 ? '99+' : type_id2users[item.id].length
}}{{ $t('cmdb.preference.peopleSub') }}</span
> >
<span class="cmdb-preference-colleague-name"> <span class="cmdb-preference-colleague-name">
<span v-for="uid in type_id2users[item.id].slice(0, 4)" :key="uid"> <span v-for="uid in type_id2users[item.id].slice(0, 4)" :key="uid">
@ -135,11 +136,11 @@
<span class="cmdb-preference-colleague-ellipsis" v-if="type_id2users[item.id].length > 4">...</span> <span class="cmdb-preference-colleague-ellipsis" v-if="type_id2users[item.id].length > 4">...</span>
</span> </span>
</template> </template>
<span v-else :style="{ marginLeft: 'auto' }">暂无同事订阅</span> <span v-else :style="{ marginLeft: 'auto' }">{{ $t('cmdb.preference.noSub') }}</span>
</div> </div>
<div class="cmdb-preference-progress"> <div class="cmdb-preference-progress">
<div class="cmdb-preference-progress-info"> <div class="cmdb-preference-progress-info">
<span>自动发现</span> <span>{{ $t('cmdb.menu.ad') }}</span>
<span>{{ item.integrity }}%</span> <span>{{ item.integrity }}%</span>
</div> </div>
<div class="cmdb-preference-progress-gray"> <div class="cmdb-preference-progress-gray">
@ -148,15 +149,13 @@
</div> </div>
<a-divider :style="{ margin: '10px 0 3px 0' }" /> <a-divider :style="{ margin: '10px 0 3px 0' }" />
<div class="cmdb-preference-footor-subscribed" v-if="item.is_subscribed"> <div class="cmdb-preference-footor-subscribed" v-if="item.is_subscribed">
<span <span><a-icon type="clock-circle" :style="{ marginRight: '3px' }" />{{ getsubscribedDays(item) }}</span>
><a-icon type="clock-circle" :style="{ marginRight: '3px' }" />{{ getsubscribedDays(item) }}订阅</span
>
<span> <span>
<a-tooltip title="取消订阅"> <a-tooltip :title="$t('cmdb.preference.cancelSub')">
<span @click="unsubscribe(item)"><ops-icon type="cmdb-preference-cancel-subscribe" /> </span> <span @click="unsubscribe(item)"><ops-icon type="cmdb-preference-cancel-subscribe" /> </span>
</a-tooltip> </a-tooltip>
<a-divider type="vertical" :style="{ margin: '0 3px' }" /> <a-divider type="vertical" :style="{ margin: '0 3px' }" />
<a-tooltip title="编辑订阅"> <a-tooltip :title="$t('cmdb.preference.editSub')">
<span @click="openSubscribeSetting(item)"><ops-icon type="cmdb-preference-subscribe"/></span> <span @click="openSubscribeSetting(item)"><ops-icon type="cmdb-preference-subscribe"/></span>
</a-tooltip> </a-tooltip>
</span> </span>
@ -164,7 +163,9 @@
<div v-else class="cmdb-preference-footor-unsubscribed"> <div v-else class="cmdb-preference-footor-unsubscribed">
<span <span
@click="openSubscribeSetting(item)" @click="openSubscribeSetting(item)"
><ops-icon :style="{ marginRight: '3px' }" type="cmdb-preference-subscribe" />订阅</span ><ops-icon :style="{ marginRight: '3px' }" type="cmdb-preference-subscribe" />{{
$t('cmdb.preference.sub')
}}</span
> >
</div> </div>
</div> </div>
@ -242,7 +243,7 @@ export default {
} }
if (!group.id) { if (!group.id) {
group.id = -1 group.id = -1
group.name = '其他' group.name = this.$t('other')
} }
}) })
this.citypeData = ciTypeGroup this.citypeData = ciTypeGroup
@ -251,7 +252,7 @@ export default {
this.type_id2users = type_id2users this.type_id2users = type_id2users
const _myPreferences = [ const _myPreferences = [
{ {
name: '资源数据', name: this.$t('cmdb.menu.ciTable'),
ci_types: self.instance.map((item) => { ci_types: self.instance.map((item) => {
const _find = pref.find((ci) => ci.id === item) const _find = pref.find((ci) => ci.id === item)
return _find return _find
@ -260,7 +261,7 @@ export default {
type: 'ci', type: 'ci',
}, },
{ {
name: '资源层级', name: this.$t('cmdb.menu.ciTree'),
ci_types: self.tree.map((item) => { ci_types: self.tree.map((item) => {
const _find = pref.find((ci) => ci.id === item) const _find = pref.find((ci) => ci.id === item)
return _find return _find
@ -285,23 +286,28 @@ export default {
moment.duration(moment().diff(moment(subscribedTime))) moment.duration(moment().diff(moment(subscribedTime)))
const day = moment().diff(moment(subscribedTime), 'day') const day = moment().diff(moment(subscribedTime), 'day')
if (day > 0 && day < 1) { if (day > 0 && day < 1) {
return `${moment().diff(moment(subscribedTime), 'hour')}小时前` return `${moment().diff(moment(subscribedTime), 'hour')}` + this.$t('cmdb.preference.hoursAgo')
} else if (day >= 1 && day <= 31) { } else if (day >= 1 && day <= 31) {
return `${day}天前` return `${day} ` + this.$t('cmdb.preference.daysAgo')
} else if (day > 31 && day < 365) { } else if (day > 31 && day < 365) {
return `${moment().diff(moment(subscribedTime), 'month')}月前` return `${moment().diff(moment(subscribedTime), 'month')}` + this.$t('cmdb.preference.monthsAgo')
} else if (day >= 365) { } else if (day >= 365) {
return `${moment().diff(moment(subscribedTime), 'year')}年前` return `${moment().diff(moment(subscribedTime), 'year')}` + this.$t('cmdb.preference.yearsAgo')
} }
return '刚刚' return this.$t('cmdb.preference.just')
}, },
unsubscribe(ciType, type = 'all') { unsubscribe(ciType, type = 'all') {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: `确认取消订阅 ${ciType.alias || ciType.name} ${ content:
type !== 'all' ? `${type === 'ci' ? '资源数据' : '资源层级'}` : '' that.$t('cmdb.preference.confirmcancelSub') +
} `, ` ${ciType.alias || ciType.name} ${
type !== 'all'
? that.$t('cmdb.preference.of') +
`${type === 'ci' ? this.$t('cmdb.menu.ciTable') : that.$t('cmdb.menu.ciTree')}`
: ''
} `,
onOk() { onOk() {
const promises = [] const promises = []
if (type === 'all' || type === 'ci') { if (type === 'all' || type === 'ci') {
@ -320,7 +326,7 @@ export default {
localStorage.setItem('ops_ci_typeid', '') localStorage.setItem('ops_ci_typeid', '')
} }
} }
that.$message.success('取消订阅成功') that.$message.success(that.$t('cmdb.preference.cancelSubSuccess'))
that.resetRoute() that.resetRoute()
}) })
}, },

View File

@ -12,12 +12,12 @@
isEdit = true isEdit = true
} }
" "
>新增业务关系</a-button >{{ $t('cmdb.preference_relation.newServiceTree') }}</a-button
> >
<template v-else> <template v-else>
<a-input v-model="newRelationViewName" placeholder="新增业务关系名"></a-input> <a-input v-model="newRelationViewName" :placeholder="$t('cmdb.preference_relation.serviceTreeName')"></a-input>
<a-checkbox v-model="is_public">公开</a-checkbox> <a-checkbox v-model="is_public">{{ $t('cmdb.preference_relation.public') }}</a-checkbox>
<a-button type="primary" size="small" @click="handleSaveRelationViews">保存</a-button> <a-button type="primary" size="small" @click="handleSaveRelationViews">{{ $t('save') }}</a-button>
<a-button <a-button
type="primary" type="primary"
size="small" size="small"
@ -29,10 +29,10 @@
newRelationViewName = '' newRelationViewName = ''
} }
" "
>取消</a-button >{{ $t('cancel') }}</a-button
> >
</template> </template>
<a-button type="primary" size="small" @click="handleSave">保存布局</a-button> <a-button type="primary" size="small" @click="handleSave">{{ $t('cmdb.preference_relation.saveLayout') }}</a-button>
</a-space> </a-space>
</div> </div>
<SeeksRelationGraph v-if="isPullConfig" ref="ciTypeRelationGraph" :options="graphOptions"> <SeeksRelationGraph v-if="isPullConfig" ref="ciTypeRelationGraph" :options="graphOptions">
@ -59,7 +59,7 @@
> >
<div class="relation-views"> <div class="relation-views">
<h3 :style="{ padding: '10px 0 0 20px' }">{{ view }}</h3> <h3 :style="{ padding: '10px 0 0 20px' }">{{ view }}</h3>
<a-popconfirm :title="`确认删除 ${view}`" @confirm="confirmDelete(view)"> <a-popconfirm :title="$t('cmdb.ciType.confirmDelete', { name: `${view}` })" @confirm="confirmDelete(view)">
<a class="relation-views-close"><a-icon type="close"/></a> <a class="relation-views-close"><a-icon type="close"/></a>
</a-popconfirm> </a-popconfirm>
<div :style="{ height: '250px' }"> <div :style="{ height: '250px' }">
@ -246,7 +246,7 @@ export default {
if (e.target.checked) { if (e.target.checked) {
const graph = this.$refs.ciTypeRelationGraph const graph = this.$refs.ciTypeRelationGraph
if (!graph.getNodeById(node.id).targetTo.length) { if (!graph.getNodeById(node.id).targetTo.length) {
this.$message.warning(`${node.text} 不存在子节点不能形成业务关系请重新选择`) this.$message.warning(`${node.text} ` + this.$t('cmdb.preference_relation.childNodesNotFound'))
return return
} }
if (!this.checkedNodes.length) { if (!this.checkedNodes.length) {
@ -278,7 +278,7 @@ export default {
const idFrom = startNode.targetFrom.findIndex((item) => item.id === node.id) const idFrom = startNode.targetFrom.findIndex((item) => item.id === node.id)
const idTo = endNode.targetTo.findIndex((item) => item.id === node.id) const idTo = endNode.targetTo.findIndex((item) => item.id === node.id)
if (idFrom <= -1 && idTo <= -1) { if (idFrom <= -1 && idTo <= -1) {
this.$message.warning(`${node.text} 不能与当前选中节点形成视图请重新选择`) this.$message.warning(`${node.text} ` + this.$t('cmdb.preference_relation.tips1'))
return return
} }
if (idFrom > -1) { if (idFrom > -1) {
@ -290,11 +290,11 @@ export default {
}, },
async handleSaveRelationViews() { async handleSaveRelationViews() {
if (!this.newRelationViewName) { if (!this.newRelationViewName) {
this.$message.warning('请输入新增业务关系名!') this.$message.warning(this.$t('cmdb.preference_relation.tips2'))
return return
} }
if (this.checkedNodes.length < 2) { if (this.checkedNodes.length < 2) {
this.$message.warning('请选择至少两个节点!') this.$message.warning(this.$t('cmdb.preference_relation.tips3'))
return return
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
@ -341,7 +341,7 @@ export default {
} }
}), }),
}).then((res) => { }).then((res) => {
this.$message.success('保存成功!') this.$message.success(this.$t('saveSuccess'))
}) })
} }
}, },

View File

@ -1,18 +1,18 @@
<template> <template>
<CustomDrawer <CustomDrawer
:closable="false" :closable="false"
:title="drawerTitle" :title="$t('cmdb.preference_relation.newServiceTree')"
:visible="drawerVisible" :visible="drawerVisible"
@close="onClose" @close="onClose"
placement="right" placement="right"
width="30%" width="30%"
> >
<a-form :form="form" :layout="formLayout" @submit="handleSubmit"> <a-form :form="form" :layout="formLayout" @submit="handleSubmit">
<a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="业务关系名"> <a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" :label="$t('cmdb.preference_relation.serviceTreeName')">
<a-input <a-input
name="name" name="name"
placeholder placeholder
v-decorator="['name', { rules: [{ required: true, message: '请输入类型名' }] }]" v-decorator="['name', { rules: [{ required: true, message: $t('cmdb.preference_relation.tips2')}] }]"
/> />
</a-form-item> </a-form-item>
@ -21,8 +21,8 @@
</a-form-item> </a-form-item>
<div class="custom-drawer-bottom-action"> <div class="custom-drawer-bottom-action">
<a-button @click="onClose">取消</a-button> <a-button @click="onClose">{{ $t('cancel') }}</a-button>
<a-button @click="handleSubmit" type="primary">提交</a-button> <a-button @click="handleSubmit" type="primary">{{ $t('submit') }}</a-button>
</div> </div>
</a-form> </a-form>
</CustomDrawer> </CustomDrawer>
@ -35,7 +35,6 @@ export default {
name: 'RelationViewForm', name: 'RelationViewForm',
data() { data() {
return { return {
drawerTitle: '新增业务关系',
drawerVisible: false, drawerVisible: false,
formLayout: 'vertical', formLayout: 'vertical',
crIds: [], crIds: [],
@ -95,7 +94,7 @@ export default {
createRelationView(data) { createRelationView(data) {
data.cr_ids = this.crIds data.cr_ids = this.crIds
subscribeRelationView(data).then(res => { subscribeRelationView(data).then(res => {
this.$message.success('新增成功!') this.$message.success(this.$t('addSuccess'))
this.onClose() this.onClose()
this.$emit('refresh') this.$emit('refresh')
}) })

View File

@ -1,7 +1,7 @@
<template> <template>
<a-card :bordered="false"> <a-card :bordered="false">
<div class="action-btn"> <div class="action-btn">
<a-button @click="handleCreate" type="primary" style="margin-bottom: 15px;">新增关系类型</a-button> <a-button @click="handleCreate" type="primary" style="margin-bottom: 15px;">{{ $t('cmdb.relation_type.addRelationType') }}</a-button>
</div> </div>
<vxe-table <vxe-table
ref="relationTypeTable" ref="relationTypeTable"
@ -16,20 +16,20 @@
> >
<vxe-table-column <vxe-table-column
field="name" field="name"
title="名称" :title="$t('name')"
:edit-render="{ name: 'input', attrs: { type: 'text' }, events: { keyup: customCloseEdit } }" :edit-render="{ name: 'input', attrs: { type: 'text' }, events: { keyup: customCloseEdit } }"
></vxe-table-column> ></vxe-table-column>
<vxe-table-column field="updateTime" title="更新时间"> <vxe-table-column field="updateTime" :title="$t('updated_at')">
<template #default="{row}"> <template #default="{row}">
{{ row.updated_at || row.created_at }} {{ row.updated_at || row.created_at }}
</template> </template>
</vxe-table-column> </vxe-table-column>
<vxe-table-column field="operation" title="操作" align="center"> <vxe-table-column field="operation" :title="$t('operation')" align="center">
<template #default="{row}"> <template #default="{row}">
<template> <template>
<a><a-icon type="edit" @click="handleEdit(row)"/></a> <a><a-icon type="edit" @click="handleEdit(row)"/></a>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a-popconfirm title="确认删除吗?" @confirm="handleDelete(row)" okText="" cancelText=""> <a-popconfirm :title="$t('confirmDelete')" @confirm="handleDelete(row)" :okText="$t('yes')" :cancelText="$t('no')">
<a :style="{ color: 'red' }"><a-icon type="delete"/></a> <a :style="{ color: 'red' }"><a-icon type="delete"/></a>
</a-popconfirm> </a-popconfirm>
</template> </template>
@ -50,6 +50,7 @@ import {
export default { export default {
name: 'RelationType', name: 'RelationType',
components: {},
data() { data() {
return { return {
tableData: [], tableData: [],
@ -97,14 +98,14 @@ export default {
}, },
updateRelationType(id, data) { updateRelationType(id, data) {
updateRelationType(id, data).then((res) => { updateRelationType(id, data).then((res) => {
this.$message.success('更新成功!') this.$message.success(this.$t('updateSuccess'))
this.loadData() this.loadData()
}) })
}, },
createRelationType(data) { createRelationType(data) {
addRelationType(data).then((res) => { addRelationType(data).then((res) => {
this.$message.success('新增成功!') this.$message.success(this.$t('addSuccess'))
this.loadData() this.loadData()
}) })
}, },
@ -113,12 +114,12 @@ export default {
}, },
deleteRelationType(id) { deleteRelationType(id) {
deleteRelationType(id).then((res) => { deleteRelationType(id).then((res) => {
this.$message.success('删除成功!') this.$message.success(this.$t('deleteSuccess'))
this.loadData() this.loadData()
}) })
}, },
customCloseEdit(value, $event) { customCloseEdit(value, $event) {
// 回车结束编辑 // enter, close edit
if ($event.keyCode === 13) { if ($event.keyCode === 13) {
const $table = this.$refs.relationTypeTable const $table = this.$refs.relationTypeTable
$table.clearActived() $table.clearActived()

View File

@ -3,7 +3,7 @@
<div v-if="relationViews.name2id && relationViews.name2id.length" class="relation-views-wrapper"> <div v-if="relationViews.name2id && relationViews.name2id.length" class="relation-views-wrapper">
<div class="cmdb-views-header"> <div class="cmdb-views-header">
<span class="cmdb-views-header-title">{{ $route.meta.name }}</span> <span class="cmdb-views-header-title">{{ $route.meta.name }}</span>
<a-button size="small" icon="user-add" type="primary" ghost @click="handlePerm">授权</a-button> <a-button size="small" icon="user-add" type="primary" ghost @click="handlePerm">{{ $t('grant') }}</a-button>
</div> </div>
<SplitPane <SplitPane
:min="200" :min="200"
@ -63,19 +63,19 @@
type="primary" type="primary"
size="small" size="small"
@click="$refs.create.handleOpen(true, 'create')" @click="$refs.create.handleOpen(true, 'create')"
>新建</a-button >{{ $t('create') }}</a-button
> >
<div class="ops-list-batch-action" v-if="isLeaf && isShowBatchIcon"> <div class="ops-list-batch-action" v-if="isLeaf && isShowBatchIcon">
<template v-if="selectedRowKeys.length"> <template v-if="selectedRowKeys.length">
<span @click="$refs.create.handleOpen(true, 'update')">修改</span> <span @click="$refs.create.handleOpen(true, 'update')">{{ $t('update') }}</span>
<a-divider type="vertical" /> <a-divider type="vertical" />
<span @click="openBatchDownload">下载</span> <span @click="openBatchDownload">{{ $t('download') }}</span>
<a-divider type="vertical" /> <a-divider type="vertical" />
<span @click="batchDelete">删除实例</span> <span @click="batchDelete">{{ $t('cmdb.ciType.deleteInstance') }}</span>
<a-divider type="vertical" /> <a-divider type="vertical" />
<span @click="batchDeleteCIRelation">删除关系</span> <span @click="batchDeleteCIRelation">{{ $t('cmdb.history.deleteRelation') }}</span>
<span>选取{{ selectedRowKeys.length }} </span> <span>{{ $t('cmdb.ci.selectRows', { rows: selectedRowKeys.length }) }}</span>
</template> </template>
</div> </div>
<PreferenceSearch <PreferenceSearch
@ -141,7 +141,7 @@
:getPopupContainer="(trigger) => trigger.parentElement" :getPopupContainer="(trigger) => trigger.parentElement"
:style="{ width: '100%', height: '32px' }" :style="{ width: '100%', height: '32px' }"
v-model="row[col.field]" v-model="row[col.field]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-if="col.is_choice" v-if="col.is_choice"
:showArrow="false" :showArrow="false"
:mode="col.is_list ? 'multiple' : 'default'" :mode="col.is_list ? 'multiple' : 'default'"
@ -176,7 +176,7 @@
:getPopupContainer="(trigger) => trigger.parentElement" :getPopupContainer="(trigger) => trigger.parentElement"
:style="{ width: '100%', height: '32px' }" :style="{ width: '100%', height: '32px' }"
v-model="row[col.field]" v-model="row[col.field]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-else-if="col.is_list" v-else-if="col.is_list"
:showArrow="false" :showArrow="false"
mode="tags" mode="tags"
@ -256,9 +256,9 @@
</template> </template>
</template> </template>
</vxe-table-column> </vxe-table-column>
<vxe-column align="left" field="operate" fixed="right" width="80"> <vxe-column align="left" field="operate" fixed="right" width="120">
<template #header> <template #header>
<span>操作</span> <span>{{ $t('operation') }}</span>
<EditAttrsPopover <EditAttrsPopover
:typeId="Number(currentTypeId[0])" :typeId="Number(currentTypeId[0])"
class="operation-icon" class="operation-icon"
@ -270,13 +270,13 @@
<a @click="$refs.detail.create(row.ci_id || row._id)"> <a @click="$refs.detail.create(row.ci_id || row._id)">
<a-icon type="unordered-list" /> <a-icon type="unordered-list" />
</a> </a>
<a-tooltip title="添加关系"> <a-tooltip :title="$t('cmdb.ci.addRelation')">
<a @click="$refs.detail.create(row.ci_id || row._id, 'tab_2', '2')"> <a @click="$refs.detail.create(row.ci_id || row._id, 'tab_2', '2')">
<a-icon type="retweet" /> <a-icon type="retweet" />
</a> </a>
</a-tooltip> </a-tooltip>
<template v-if="isLeaf"> <template v-if="isLeaf">
<a-tooltip title="删除实例"> <a-tooltip :title="$t('cmdb.ciType.deleteInstance')">
<a @click="deleteCI(row)" :style="{ color: 'red' }"> <a @click="deleteCI(row)" :style="{ color: 'red' }">
<a-icon type="delete" /> <a-icon type="delete" />
</a> </a>
@ -286,10 +286,10 @@
</template> </template>
</vxe-column> </vxe-column>
<template #empty> <template #empty>
<div v-if="loading" style="height: 200px; line-height: 200px">加载中...</div> <div v-if="loading" style="height: 200px; line-height: 200px">{{ $t('loading') }}</div>
<div v-else> <div v-else>
<img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" /> <img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" />
<div>暂无数据</div> <div>{{ $t('noData') }}</div>
</div> </div>
</template> </template>
</vxe-table> </vxe-table>
@ -303,12 +303,19 @@
:page-size="pageSize" :page-size="pageSize"
:page-size-options="pageSizeOptions" :page-size-options="pageSizeOptions"
@showSizeChange="onShowSizeChange" @showSizeChange="onShowSizeChange"
:show-total="(total, range) => `当前${range[0]}-${range[1]} 共 ${total}条记录`" :show-total="
(total, range) =>
$t('pagination.total', {
range0: range[0],
range1: range[1],
total,
})
"
:style="{ alignSelf: 'flex-end', marginRight: '12px' }" :style="{ alignSelf: 'flex-end', marginRight: '12px' }"
> >
<template slot="buildOptionText" slot-scope="props"> <template slot="buildOptionText" slot-scope="props">
<span v-if="props.value !== '100000'">{{ props.value }}/</span> <span v-if="props.value !== '100000'">{{ props.value }}{{ $t('cmdb.history.itemsPerPage') }}</span>
<span v-if="props.value === '100000'">全部</span> <span v-if="props.value === '100000'">{{ $t('cmdb.components.all') }}</span>
</template> </template>
</a-pagination> </a-pagination>
</div> </div>
@ -317,7 +324,7 @@
</SplitPane> </SplitPane>
</div> </div>
<a-alert <a-alert
message="管理员 还未配置业务关系, 或者你无权限访问!" :message="$t('cmdb.serviceTreealert1')"
banner banner
v-else-if="relationViews.name2id && !relationViews.name2id.length" v-else-if="relationViews.name2id && !relationViews.name2id.length"
></a-alert> ></a-alert>
@ -1010,15 +1017,15 @@ export default {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: (h) => ( content: (h) => (
<div> <div>
确认删除 <strong>{Object.values(firstCIObj)[0]}</strong> {that.$t('confirmDelete2', { name: Object.values(firstCIObj)[0] })}
</div> </div>
), ),
onOk() { onOk() {
deleteCIRelationView(_tempTreeParent[0], _tempTree[0], { ancestor_ids }).then((res) => { deleteCIRelationView(_tempTreeParent[0], _tempTree[0], { ancestor_ids }).then((res) => {
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
setTimeout(() => { setTimeout(() => {
that.reload() that.reload()
}, 500) }, 500)
@ -1038,10 +1045,10 @@ export default {
const currentShowType = this.showTypes.find((item) => item.id === Number(this.currentTypeId[0])) const currentShowType = this.showTypes.find((item) => item.id === Number(this.currentTypeId[0]))
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: (h) => ( content: (h) => (
<div> <div>
确认将选中的 <strong>{currentShowType.alias || currentShowType.name}</strong> 从当前关系中删除 {that.$t('cmdb.serviceTreedeleteRelationConfirm', { name: currentShowType.alias || currentShowType.name })}
</div> </div>
), ),
onOk() { onOk() {
@ -1101,7 +1108,7 @@ export default {
}) })
}) })
} else { } else {
this.$message.error('权限不足!') this.$message.error(this.$t('noPermission'))
} }
}) })
}, },
@ -1242,7 +1249,7 @@ export default {
if (JSON.stringify(data) !== '{}') { if (JSON.stringify(data) !== '{}') {
updateCI(row.ci_id || row._id, data) updateCI(row.ci_id || row._id, data)
.then(() => { .then(() => {
this.$message.success('保存成功!') this.$message.success(this.$t('saveSuccess'))
$table.reloadRow(row, null) $table.reloadRow(row, null)
const _initialInstanceList = _.cloneDeep(this.initialInstanceList) const _initialInstanceList = _.cloneDeep(this.initialInstanceList)
_initialInstanceList[rowIndex] = { _initialInstanceList[rowIndex] = {
@ -1266,11 +1273,11 @@ export default {
deleteCI(record) { deleteCI(record) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认删除?', content: that.$t('confirmDelete'),
onOk() { onOk() {
deleteCI(record.ci_id || record._id).then((res) => { deleteCI(record.ci_id || record._id).then((res) => {
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.loadData({}, 'refreshNumber') that.loadData({}, 'refreshNumber')
}) })
}, },
@ -1298,8 +1305,8 @@ export default {
batchUpdateFromCreateInstance(values) { batchUpdateFromCreateInstance(values) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认要批量修改吗 ?', content: that.$t('cmdb.ci.batchUpdateConfirm'),
onOk() { onOk() {
that.loading = true that.loading = true
const payload = {} const payload = {}
@ -1320,7 +1327,7 @@ export default {
}) })
Promise.all(promises) Promise.all(promises)
.then((res) => { .then((res) => {
that.$message.success('批量修改成功') that.$message.success(that.$t('updateSuccess'))
that.$refs.create.visible = false that.$refs.create.visible = false
}) })
.catch((e) => { .catch((e) => {
@ -1371,8 +1378,8 @@ export default {
batchDelete() { batchDelete() {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认删除?', content: that.$t('confirmDelete'),
onOk() { onOk() {
that.loading = true that.loading = true
const promises = that.selectedRowKeys.map((c) => { const promises = that.selectedRowKeys.map((c) => {
@ -1382,7 +1389,7 @@ export default {
}) })
Promise.all(promises) Promise.all(promises)
.then((res) => { .then((res) => {
that.$message.success('删除成功') that.$message.success(that.$t('deleteSuccess'))
}) })
.catch((e) => { .catch((e) => {
console.log(e) console.log(e)
@ -1445,10 +1452,10 @@ export default {
const text = `q=_type:${this.currentTypeId[0]}${exp ? `,${exp}` : ''}${fuzzySearch ? `,*${fuzzySearch}*` : ''}` const text = `q=_type:${this.currentTypeId[0]}${exp ? `,${exp}` : ''}${fuzzySearch ? `,*${fuzzySearch}*` : ''}`
this.$copyText(text) this.$copyText(text)
.then(() => { .then(() => {
this.$message.success('复制成功!') this.$message.success(this.$t('copySuccess'))
}) })
.catch(() => { .catch(() => {
this.$message.error('复制失败!') this.$message.error(this.$t('cmdb.serviceTreecopyFailed'))
}) })
}, },
}, },

View File

@ -11,12 +11,24 @@
> >
<div :style="{ width: '100%' }" id="add-table-modal"> <div :style="{ width: '100%' }" id="add-table-modal">
<a-spin :spinning="loading"> <a-spin :spinning="loading">
<!-- <a-input
v-model="expression"
class="ci-searchform-expression"
:style="{ width, marginBottom: '10px' }"
:placeholder="placeholder"
@focus="
() => {
isFocusExpression = true
}
"
/> -->
<SearchForm <SearchForm
ref="searchForm" ref="searchForm"
:typeId="addTypeId" :typeId="addTypeId"
:preferenceAttrList="preferenceAttrList" :preferenceAttrList="preferenceAttrList"
@refresh="handleSearch" @refresh="handleSearch"
/> />
<!-- <a @click="handleSearch"><a-icon type="search"/></a> -->
<vxe-table <vxe-table
ref="xTable" ref="xTable"
row-id="_id" row-id="_id"
@ -52,7 +64,14 @@
:total="totalNumber" :total="totalNumber"
show-quick-jumper show-quick-jumper
:page-size="50" :page-size="50"
:show-total="(total, range) => `当前${range[0]}-${range[1]} 共 ${total}条记录`" :show-total="
(total, range) =>
$t('pagination.total', {
range0: range[0],
range1: range[1],
total,
})
"
:style="{ textAlign: 'right', marginTop: '10px' }" :style="{ textAlign: 'right', marginTop: '10px' }"
@change="handleChangePage" @change="handleChangePage"
/> />
@ -94,7 +113,7 @@ export default {
return this.$store.state.windowHeight - 250 return this.$store.state.windowHeight - 250
}, },
placeholder() { placeholder() {
return this.isFocusExpression ? 'q=os_version:centos&sort=os_version' : '表达式搜索' return this.isFocusExpression ? this.$t('cmdb.serviceTreetips1') : this.$t('cmdb.serviceTreetips2')
}, },
width() { width() {
return this.isFocusExpression ? '500px' : '100px' return this.isFocusExpression ? '500px' : '100px'
@ -103,6 +122,7 @@ export default {
watch: {}, watch: {},
methods: { methods: {
async openModal(ciObj, ciId, addTypeId, type, ancestor_ids = undefined) { async openModal(ciObj, ciId, addTypeId, type, ancestor_ids = undefined) {
console.log(ciObj, ciId, addTypeId, type)
this.visible = true this.visible = true
this.ciObj = ciObj this.ciObj = ciObj
this.ciId = ciId this.ciId = ciId
@ -121,6 +141,10 @@ export default {
}, },
async fetchData(isInit) { async fetchData(isInit) {
this.loading = true this.loading = true
// if (isInit) {
// const subscribed = await getSubscribeAttributes(this.addTypeId)
// this.preferenceAttrList = subscribed.attributes // 已经订阅的全部列
// }
let sort, fuzzySearch, expression, exp let sort, fuzzySearch, expression, exp
if (!isInit) { if (!isInit) {
fuzzySearch = this.$refs['searchForm'].fuzzySearch fuzzySearch = this.$refs['searchForm'].fuzzySearch
@ -179,7 +203,7 @@ export default {
await batchUpdateCIRelationParents(ciIds, [this.ciId]) await batchUpdateCIRelationParents(ciIds, [this.ciId])
} }
setTimeout(() => { setTimeout(() => {
this.$message.success('添加成功!') this.$message.success(this.$t('addSuccess'))
this.handleClose() this.handleClose()
this.$emit('reload') this.$emit('reload')
}, 500) }, 500)

View File

@ -1,8 +1,8 @@
<template> <template>
<a-dropdown :trigger="['contextmenu']"> <a-dropdown :trigger="['contextmenu']">
<a-menu slot="overlay" @click="({ key: menuKey }) => this.onContextMenuClick(this.treeKey, menuKey)"> <a-menu slot="overlay" @click="({ key: menuKey }) => this.onContextMenuClick(this.treeKey, menuKey)">
<a-menu-item v-for="item in menuList" :key="item.id">新增{{ item.alias }}</a-menu-item> <a-menu-item v-for="item in menuList" :key="item.id">{{ $t('new') }} {{ item.alias }}</a-menu-item>
<a-menu-item v-if="showDelete" key="delete">删除节点</a-menu-item> <a-menu-item v-if="showDelete" key="delete">{{ $t('cmdb.serviceTree.deleteNode') }}</a-menu-item>
</a-menu> </a-menu>
<div <div
:style="{ :style="{

View File

@ -2,7 +2,7 @@
<div id="resource_search" :style="{ height: fromCronJob ? `${windowHeight - 48}px` : `${windowHeight - 90}px` }"> <div id="resource_search" :style="{ height: fromCronJob ? `${windowHeight - 48}px` : `${windowHeight - 90}px` }">
<div class="cmdb-views-header"> <div class="cmdb-views-header">
<span> <span>
<span class="cmdb-views-header-title">资源搜索</span> <span class="cmdb-views-header-title">{{ $t('cmdb.menu.ciSearch') }}</span>
</span> </span>
</div> </div>
<div :style="{ backgroundColor: '#fff', padding: '12px', borderRadius: '15px' }"> <div :style="{ backgroundColor: '#fff', padding: '12px', borderRadius: '15px' }">
@ -24,7 +24,9 @@
alignItems: 'center', alignItems: 'center',
}" }"
> >
<a-button icon="download" type="primary" ghost size="small" @click="handleExport">导出</a-button> <a-button icon="download" type="primary" ghost size="small" @click="handleExport">{{
$t('download')
}}</a-button>
<PreferenceSearch <PreferenceSearch
ref="preferenceSearch" ref="preferenceSearch"
@getQAndSort="getQAndSort" @getQAndSort="getQAndSort"
@ -68,7 +70,7 @@
> >
<vxe-column <vxe-column
v-if="instanceList.length" v-if="instanceList.length"
title="模型" :title="$t('cmdb.ciType.ciType')"
field="ci_type_alias" field="ci_type_alias"
:width="100" :width="100"
fixed="left" fixed="left"
@ -149,12 +151,14 @@
</vxe-colgroup> </vxe-colgroup>
<template #empty> <template #empty>
<div v-if="loading" style="height: 200px; line-height: 200px">加载中...</div> <div>
<div v-else>
<img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" /> <img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" />
<div>暂无数据</div> <div>{{ $t('noData') }}</div>
</div> </div>
</template> </template>
<template #loading>
<div style="height: 200px; line-height: 200px">{{ $t('loading') }}</div>
</template>
</vxe-table> </vxe-table>
<div :style="{ textAlign: 'right', marginTop: '4px' }"> <div :style="{ textAlign: 'right', marginTop: '4px' }">
<a-pagination <a-pagination
@ -166,7 +170,14 @@
:page-size="pageSize" :page-size="pageSize"
:page-size-options="pageSizeOptions" :page-size-options="pageSizeOptions"
@showSizeChange="onShowSizeChange" @showSizeChange="onShowSizeChange"
:show-total="(total, range) => `当前${range[0]}-${range[1]} 共 ${total}条记录`" :show-total="
(total, range) =>
$t('pagination.total', {
range0: range[0],
range1: range[1],
total,
})
"
@change=" @change="
(page) => { (page) => {
currentPage = page currentPage = page
@ -175,8 +186,8 @@
" "
> >
<template slot="buildOptionText" slot-scope="props"> <template slot="buildOptionText" slot-scope="props">
<span v-if="props.value !== '100000'">{{ props.value }}/</span> <span v-if="props.value !== '100000'">{{ props.value }}{{ $t('itemsPerPage') }}</span>
<span v-if="props.value === '100000'">全部</span> <span v-if="props.value === '100000'">{{ $t('all') }}</span>
</template> </template>
</a-pagination> </a-pagination>
</div> </div>
@ -444,9 +455,11 @@ export default {
return {} return {}
}, },
handleExport() { handleExport() {
// this.$refs.xTable.openExport()
this.$refs.batchDownload.open({ this.$refs.batchDownload.open({
preferenceAttrList: [{ id: `ci_type_alias`, value: 'ci_type_alias', label: '模型' }, ...this.columnsGroup], preferenceAttrList: [
{ id: `ci_type_alias`, value: 'ci_type_alias', label: this.$t('cmdb.ciType.ciType') },
...this.columnsGroup,
],
}) })
}, },
batchDownload({ filename, type, checkedKeys }) { batchDownload({ filename, type, checkedKeys }) {
@ -517,11 +530,11 @@ export default {
}${fuzzySearch ? `,*${fuzzySearch}*` : ''}` }${fuzzySearch ? `,*${fuzzySearch}*` : ''}`
this.$copyText(text) this.$copyText(text)
.then(() => { .then(() => {
this.$message.success('复制成功!') this.$message.success(this.$t('copySuccess'))
this.$emit('copySuccess', text) this.$emit('copySuccess', text)
}) })
.catch(() => { .catch(() => {
this.$message.error('复制失败!') this.$message.error(this.$t('cmdb.ci.copyFailed'))
}) })
}, },
}, },

View File

@ -1,9 +1,9 @@
<template> <template>
<div :style="{ marginBottom: '-24px' }"> <div :style="{ marginBottom: '-24px' }">
<div v-if="!subscribeTreeViewCiTypesLoading && subscribeTreeViewCiTypes.length === 0"> <div v-if="!subscribeTreeViewCiTypesLoading && subscribeTreeViewCiTypes.length === 0">
<a-alert message="请先到 我的订阅 页面完成订阅!" banner></a-alert> <a-alert :message="$t('cmdb.tree.tips1')" banner></a-alert>
</div> </div>
<div class="tree-views"> <div class="tree-views" v-else>
<div class="cmdb-views-header"> <div class="cmdb-views-header">
<span> <span>
<span class="cmdb-views-header-title">{{ currentCiTypeName }}</span> <span class="cmdb-views-header-title">{{ currentCiTypeName }}</span>
@ -15,16 +15,12 @@
" "
class="cmdb-views-header-metadata" class="cmdb-views-header-metadata"
><a-icon type="info-circle" /> ><a-icon type="info-circle" />
属性说明 {{ $t('cmdb.components.attributeDesc') }}
</span> </span>
</span> </span>
<a-button <a-button size="small" icon="plus" type="primary" @click="$refs.create.handleOpen(true, 'create')">{{
size="small" $t('create')
icon="plus" }}</a-button>
type="primary"
@click="$refs.create.handleOpen(true, 'create')"
>新建</a-button
>
</div> </div>
<SplitPane <SplitPane
:min="200" :min="200"
@ -82,12 +78,12 @@
</span> </span>
<span class="tree-views-left-header-name">{{ ciType.alias || ciType.name }}</span> <span class="tree-views-left-header-name">{{ ciType.alias || ciType.name }}</span>
<div class="actions"> <div class="actions">
<a-tooltip title="取消订阅"> <a-tooltip :title="$t('cmdb.preference.cancelSub')">
<div class="action" @click="(e) => cancelSubscribe(e, ciType)"> <div class="action" @click="(e) => cancelSubscribe(e, ciType)">
<a-icon type="star" /> <a-icon type="star" />
</div> </div>
</a-tooltip> </a-tooltip>
<a-tooltip title="订阅设置"> <a-tooltip :title="$t('cmdb.tree.subSettings')">
<div class="action" @click="(e) => subscribeSetting(e, ciType)"> <div class="action" @click="(e) => subscribeSetting(e, ciType)">
<a-icon type="setting" /> <a-icon type="setting" />
</div> </div>
@ -132,12 +128,12 @@
/> />
<div class="ops-list-batch-action"> <div class="ops-list-batch-action">
<template v-if="selectedRowKeys.length"> <template v-if="selectedRowKeys.length">
<span @click="$refs.create.handleOpen(true, 'update')">修改</span> <span @click="$refs.create.handleOpen(true, 'update')">{{ $t('update') }}</span>
<a-divider type="vertical" /> <a-divider type="vertical" />
<span @click="openBatchDownload">下载</span> <span @click="openBatchDownload">{{ $t('download') }}</span>
<a-divider type="vertical" /> <a-divider type="vertical" />
<span @click="batchDelete">删除</span> <span @click="batchDelete">{{ $t('delete') }}</span>
<span>选取{{ selectedRowKeys.length }} </span> <span>{{ $t('cmdb.ci.selectRows', { rows: selectedRowKeys.length }) }}</span>
</template> </template>
</div> </div>
</div> </div>
@ -199,7 +195,7 @@
:getPopupContainer="(trigger) => trigger.parentElement" :getPopupContainer="(trigger) => trigger.parentElement"
:style="{ width: '100%', height: '32px' }" :style="{ width: '100%', height: '32px' }"
v-model="row[col.field]" v-model="row[col.field]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-if="col.is_choice" v-if="col.is_choice"
:showArrow="false" :showArrow="false"
:mode="col.is_list ? 'multiple' : 'default'" :mode="col.is_list ? 'multiple' : 'default'"
@ -234,7 +230,7 @@
:getPopupContainer="(trigger) => trigger.parentElement" :getPopupContainer="(trigger) => trigger.parentElement"
:style="{ width: '100%', height: '32px' }" :style="{ width: '100%', height: '32px' }"
v-model="row[col.field]" v-model="row[col.field]"
placeholder="请选择" :placeholder="$t('placeholder2')"
v-else-if="col.is_list" v-else-if="col.is_list"
:showArrow="false" :showArrow="false"
mode="tags" mode="tags"
@ -314,9 +310,9 @@
</template> </template>
</template> </template>
</vxe-table-column> </vxe-table-column>
<vxe-table-column align="left" field="operate" fixed="right" width="80"> <vxe-table-column align="left" field="operate" fixed="right" width="120">
<template #header> <template #header>
<span>操作</span> <span>{{ $t('operation') }}</span>
<EditAttrsPopover :typeId="Number(typeId)" class="operation-icon" @refresh="refreshAfterEditAttrs" /> <EditAttrsPopover :typeId="Number(typeId)" class="operation-icon" @refresh="refreshAfterEditAttrs" />
</template> </template>
<template #default="{ row }"> <template #default="{ row }">
@ -324,13 +320,13 @@
<a @click="$refs.detail.create(row.ci_id || row._id)"> <a @click="$refs.detail.create(row.ci_id || row._id)">
<a-icon type="unordered-list" /> <a-icon type="unordered-list" />
</a> </a>
<a-tooltip title="添加关系"> <a-tooltip :title="$t('cmdb.ci.addRelation')">
<a @click="$refs.detail.create(row.ci_id || row._id, 'tab_2', '2')"> <a @click="$refs.detail.create(row.ci_id || row._id, 'tab_2', '2')">
<a-icon type="retweet" /> <a-icon type="retweet" />
</a> </a>
</a-tooltip> </a-tooltip>
<template> <template>
<a-tooltip title="删除实例"> <a-tooltip :title="$t('cmdb.ciType.deleteInstance')">
<a @click="deleteCI(row)" :style="{ color: 'red' }"> <a @click="deleteCI(row)" :style="{ color: 'red' }">
<a-icon type="delete" /> <a-icon type="delete" />
</a> </a>
@ -340,14 +336,14 @@
</template> </template>
</vxe-table-column> </vxe-table-column>
<template #empty> <template #empty>
<div v-if="loading" style="height: 200px; line-height: 200px">加载中...</div> <div v-if="loading" style="height: 200px; line-height: 200px">{{ $t('loading') }}</div>
<div v-else> <div v-else>
<img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" /> <img :style="{ width: '200px' }" :src="require('@/assets/data_empty.png')" />
<div>暂无数据</div> <div>{{ $t('noData') }}</div>
</div> </div>
</template> </template>
<template #loading> <template #loading>
<div style="height: 200px; line-height: 200px">{{ loadTip || '加载中...' }}</div> <div style="height: 200px; line-height: 200px">{{ loadTip || $t('loading') }}</div>
</template> </template>
</ops-table> </ops-table>
<div :style="{ textAlign: 'right', marginTop: '4px' }"> <div :style="{ textAlign: 'right', marginTop: '4px' }">
@ -359,7 +355,14 @@
show-quick-jumper show-quick-jumper
:page-size="pageSize" :page-size="pageSize"
:page-size-options="pageSizeOptions" :page-size-options="pageSizeOptions"
:show-total="(total, range) => `当前${range[0]}-${range[1]} 共 ${total}条记录`" :show-total="
(total, range) =>
$t('pagination.total', {
range0: range[0],
range1: range[1],
total,
})
"
:style="{ alignSelf: 'flex-end' }" :style="{ alignSelf: 'flex-end' }"
@showSizeChange="onShowSizeChange" @showSizeChange="onShowSizeChange"
@change=" @change="
@ -370,8 +373,8 @@
" "
> >
<template slot="buildOptionText" slot-scope="props"> <template slot="buildOptionText" slot-scope="props">
<span v-if="props.value !== '100000'">{{ props.value }}/</span> <span v-if="props.value !== '100000'">{{ props.value }}{{ $t('itemsPerPage') }}</span>
<span v-if="props.value === '100000'">全部</span> <span v-if="props.value === '100000'">{{ $t('all') }}</span>
</template> </template>
</a-pagination> </a-pagination>
</div> </div>
@ -539,9 +542,6 @@ export default {
}, },
inject: ['reload'], inject: ['reload'],
async created() { async created() {
// const res = await getSubscribeTreeView()
// this.subscribeTreeViewCiTypes = res
// await this.initPage()
await this.getTreeViews() await this.getTreeViews()
}, },
mounted() { mounted() {
@ -780,15 +780,13 @@ export default {
e.preventDefault() e.preventDefault()
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: (h) => ( content: (h) => (
<div> <div>{that.$t('cmdb.preference.confirmcancelSub2', { name: ciType.alias || ciType.name })}</div>
确认要取消订阅 <span style={{ fontWeight: 700, color: 'black' }}>{ciType.alias || ciType.name}</span>
</div>
), ),
onOk() { onOk() {
subscribeTreeView(ciType.type_id, []).then(() => { subscribeTreeView(ciType.type_id, []).then(() => {
that.$message.success('取消订阅成功') that.$message.success(that.$t('cmdb.preference.cancelSubSuccess'))
if (Number(that.$route.params.typeId) === Number(ciType.type_id)) { if (Number(that.$route.params.typeId) === Number(ciType.type_id)) {
that.$router.history.push('/cmdb/treeviews') that.$router.history.push('/cmdb/treeviews')
that.reload() that.reload()
@ -902,34 +900,17 @@ export default {
deleteCI(record) { deleteCI(record) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认删除?', content: that.$t('confirmDelete'),
onOk() { onOk() {
deleteCI(record.ci_id || record._id).then((res) => { deleteCI(record.ci_id || record._id).then((res) => {
that.$message.success('删除成功!') that.$message.success(that.$t('deleteSuccess'))
that.reload() that.reload()
}) })
}, },
}) })
}, },
onSelectChange(e) { onSelectChange(e) {
/* const current = records.map((i) => i._id)
const cached = new Set(this.selectedRowKeys)
if (checked) {
current.forEach((i) => {
cached.add(i)
})
} else {
if (row) {
cached.delete(row._id)
} else {
this.instanceList.map((row) => {
cached.delete(row._id)
})
}
}
this.selectedRowKeys = Array.from(cached) */
const xTable = this.$refs.xTable.getVxetableRef() const xTable = this.$refs.xTable.getVxetableRef()
const records = [...xTable.getCheckboxRecords(), ...xTable.getCheckboxReserveRecords()] const records = [...xTable.getCheckboxRecords(), ...xTable.getCheckboxReserveRecords()]
this.selectedRowKeys = records.map((i) => i.ci_id || i._id) this.selectedRowKeys = records.map((i) => i.ci_id || i._id)
@ -1001,7 +982,7 @@ export default {
if (JSON.stringify(data) !== '{}') { if (JSON.stringify(data) !== '{}') {
updateCI(row._id, data) updateCI(row._id, data)
.then(() => { .then(() => {
this.$message.success('保存成功!') this.$message.success(this.$t('saveSuccess'))
const arr1 = this.treeViewsLevels.map((item) => item.name) const arr1 = this.treeViewsLevels.map((item) => item.name)
const arr2 = Object.keys(data) const arr2 = Object.keys(data)
const arr3 = arr1.filter((item) => { const arr3 = arr1.filter((item) => {
@ -1054,10 +1035,7 @@ export default {
this.$refs.jsonEditor.open(column, row) this.$refs.jsonEditor.open(column, row)
}, },
async openBatchDownload() { async openBatchDownload() {
this.$refs.batchDownload.open({ this.$refs.batchDownload.open({ preferenceAttrList: this.currentAttrList, ciTypeName: this.currentCiTypeName })
preferenceAttrList: this.currentAttrList,
ciTypeName: this.$route.meta.title || this.$route.meta.name,
})
}, },
batchDownload({ filename, type, checkedKeys }) { batchDownload({ filename, type, checkedKeys }) {
console.log(filename, type) console.log(filename, type)
@ -1090,8 +1068,8 @@ export default {
batchDelete() { batchDelete() {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认删除?', content: that.$t('confirmDelete'),
onOk() { onOk() {
that.batchDeleteAsync() that.batchDeleteAsync()
}, },
@ -1101,7 +1079,7 @@ export default {
let successNum = 0 let successNum = 0
let errorNum = 0 let errorNum = 0
this.loading = true this.loading = true
this.loadTip = `正在删除...` this.loadTip = this.$t('cmdb.ci.batchDeleting')
const floor = Math.ceil(this.selectedRowKeys.length / 6) const floor = Math.ceil(this.selectedRowKeys.length / 6)
for (let i = 0; i < floor; i++) { for (let i = 0; i < floor; i++) {
const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6) const itemList = this.selectedRowKeys.slice(6 * i, 6 * i + 6)
@ -1117,7 +1095,11 @@ export default {
}) })
}) })
.finally(() => { .finally(() => {
this.loadTip = `正在删除${this.selectedRowKeys.length}成功${successNum}失败${errorNum}` this.loadTip = this.$t('cmdb.ci.batchDeleting2', {
total: this.selectedRowKeys.length,
successNum: successNum,
errorNum: errorNum,
})
}) })
} }
this.loading = false this.loading = false
@ -1130,8 +1112,8 @@ export default {
batchUpdateFromCreateInstance(values) { batchUpdateFromCreateInstance(values) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('warning'),
content: '确认要批量修改吗 ?', content: that.$t('cmdb.ci.batchUpdateConfirm'),
onOk() { onOk() {
that.batchUpdateAsync(values) that.batchUpdateAsync(values)
}, },
@ -1141,7 +1123,7 @@ export default {
let successNum = 0 let successNum = 0
let errorNum = 0 let errorNum = 0
this.loading = true this.loading = true
this.loadTip = `正在批量修改...` this.loadTip = this.$t('cmdb.ci.batchUpdateInProgress')
const payload = {} const payload = {}
Object.keys(values).forEach((key) => { Object.keys(values).forEach((key) => {
if (values[key] || values[key] === 0) { if (values[key] || values[key] === 0) {
@ -1163,7 +1145,11 @@ export default {
errorNum += 1 errorNum += 1
}) })
.finally(() => { .finally(() => {
this.loadTip = `正在批量修改${this.selectedRowKeys.length}成功${successNum}失败${errorNum}` this.loadTip = this.$t('cmdb.ci.batchUpdateInProgress2', {
total: this.selectedRowKeys.length,
successNum: successNum,
errorNum: errorNum,
})
}) })
} }
this.loading = false this.loading = false
@ -1217,10 +1203,10 @@ export default {
const text = `q=_type:${this.typeId}${exp ? `,${exp}` : ''}${fuzzySearch ? `,*${fuzzySearch}*` : ''}` const text = `q=_type:${this.typeId}${exp ? `,${exp}` : ''}${fuzzySearch ? `,*${fuzzySearch}*` : ''}`
this.$copyText(text) this.$copyText(text)
.then(() => { .then(() => {
this.$message.success('复制成功!') this.$message.success(this.$t('copySuccess'))
}) })
.catch(() => { .catch(() => {
this.$message.error('复制失败!') this.$message.error(this.$t('cmdb.ci.copyFailed'))
}) })
}, },
}, },