This commit is contained in:
pycook 2020-02-15 20:57:05 +08:00
parent acf881dcb7
commit 07d2af6671
17 changed files with 244 additions and 157 deletions

View File

@ -1,5 +1,6 @@
import T from 'ant-design-vue/es/table/Table' import T from 'ant-design-vue/es/table/Table'
import get from 'lodash.get' import get from 'lodash.get'
import i18n from '@/locales'
export default { export default {
data () { data () {
@ -232,7 +233,7 @@ export default {
<a style="margin-left: 24px" onClick={() => { <a style="margin-left: 24px" onClick={() => {
callback() callback()
this.clearSelected() this.clearSelected()
}}>清空</a> }}>{ i18n.t('table.clear') }</a>
) )
}, },
renderAlert () { renderAlert () {
@ -254,7 +255,7 @@ export default {
return ( return (
<a-alert showIcon={true} style="margin-bottom: 16px"> <a-alert showIcon={true} style="margin-bottom: 16px">
<template slot="message"> <template slot="message">
<span style="margin-right: 12px">已选择: <a style="font-weight: 600">{this.selectedRows.length}</a></span> <span style="margin-right: 12px">{ i18n.t('table.selected') }: <a style="font-weight: 600">{this.selectedRows.length}</a></span>
{needTotalItems} {needTotalItems}
{clearItem} {clearItem}
</template> </template>

View File

@ -31,8 +31,6 @@ export default i18n
const loadedLanguages = [defaultLang] const loadedLanguages = [defaultLang]
// 从缓存設置中加载当前语言
function setI18nLanguage (lang) { function setI18nLanguage (lang) {
i18n.locale = lang i18n.locale = lang
axios.defaults.headers.common['Accept-Language'] = lang axios.defaults.headers.common['Accept-Language'] = lang
@ -46,7 +44,6 @@ export function i18nRender (key) {
export function loadLanguageAsync (lang = defaultLang) { export function loadLanguageAsync (lang = defaultLang) {
return new Promise(resolve => { return new Promise(resolve => {
// 缓存语言设置
Vue.ls.set('lang', lang) Vue.ls.set('lang', lang)
if (i18n.locale !== lang) { if (i18n.locale !== lang) {
if (!loadedLanguages.includes(lang)) { if (!loadedLanguages.includes(lang)) {

View File

@ -4,32 +4,36 @@ export default {
antLocale: enUS, antLocale: enUS,
menu: { menu: {
preference: 'Preference', preference: 'Preference',
relationViews: 'RelationViews', relationViews: 'Relation Views',
treeViews: 'TreeViews', treeViews: 'Tree Views',
batch: 'Batch', batch: 'Batch Import',
ciType: 'CiType', ciType: 'Modeling',
acl: 'ACL', acl: 'Authorization',
ciModelManager: 'Model', ciModelManager: 'CI Type',
ciPropertyRep: 'Propertys', ciPropertyRep: 'Attributes',
ciRelationType: 'RelationType', ciRelationType: 'Relation Type',
ciRelationViewDefine: 'RelationViewDefine', ciRelationViewDefine: 'Relation View Define',
aclUsersManager: 'Users', aclUsersManager: 'Users',
aclRolesManager: 'Roles', aclRolesManager: 'Roles',
aclResourceManager: 'Resources', aclResourceManager: 'Resources',
aclResourceType: 'ResourceType' aclResourceType: 'Resource Type'
}, },
button: { button: {
cancel: 'Cancel', cancel: 'Cancel',
submit: 'Submit', submit: 'Submit',
query: 'Query', query: 'Query',
add: 'Add', add: 'Add',
new: 'New',
update: 'Edit',
delete: 'Delete', delete: 'Delete',
yes: 'Yes', yes: 'Yes',
no: 'No', no: 'No',
reset: 'Reset', reset: 'Reset',
subscribe: 'Subscribe', subscribe: 'Subscribe',
downloadTemplate: 'Download',
upload: 'Upload',
download: 'Download', download: 'Download',
upload: 'Upload' displayFields: 'Display Fields'
}, },
tip: { tip: {
sourceCode: 'view on', sourceCode: 'view on',
@ -40,17 +44,47 @@ export default {
detail: 'Detail', detail: 'Detail',
delete: 'Delete', delete: 'Delete',
edit: 'Edit', edit: 'Edit',
operate: 'Operate', operate: 'Operation',
create: 'Create',
clear: 'Clear', clear: 'Clear',
modify: 'Modify', modify: 'Modify',
unselectedAttribute: 'Unselect Attributes',
selectedAttribute: 'Selected Attributes',
noData: 'No Data',
addSuccess: 'Add successfully',
updateSuccess: 'Update successfully',
deleteSuccess: 'Delete successfully',
cancelSuccess: 'Cancel successfully',
downloading: 'Downloading ...',
deleting: 'Deleting ...',
confirmDelete: 'Confirm deleting ?',
warning: 'Warning',
other: 'Other',
requestFailed: 'Request error, please try again later',
pleaseSelect: 'please select' pleaseSelect: 'please select'
}, },
ci: { ci: {
batchOperate: 'Batch Operation',
confirmBatchUpdate: 'Confirm batch modification?',
batchUpdate: 'Batch update ...',
batchUpdateSuccess: 'Batch update successfully',
confirmDelete: 'Confirm deleting ?',
attribute: 'Attributes',
relation: 'Relation',
history: 'History',
time: 'Time',
user: 'User',
batchUpdateTip: 'Just fill in the fields that need to be modified!',
selectLevel: '- - directory level selection - -',
displayFieldDefine: 'Display Fields Define'
},
table: {
selected: 'Selected', selected: 'Selected',
batchOperate: 'Batch operate' clear: 'Clear'
}, },
preference: { preference: {
cancelSubscribeConfirm: 'Really want to unsubscribe ?',
subscribeSuccess: 'Subscribe successfully',
subscribeModel: 'Subscribe Model', subscribeModel: 'Subscribe Model',
resourceView: 'Resource View', resourceView: 'Resource View',
subFormTip: 'You can either define a tree view or subscribe to a resource view, which will be presented separately in sidebar' subFormTip: 'You can either define a tree view or subscribe to a resource view, which will be presented separately in sidebar'
@ -62,11 +96,34 @@ export default {
dragFileHere: 'click or drag file to here!', dragFileHere: 'click or drag file to here!',
suportFileType: 'suport file type' suportFileType: 'suport file type'
}, },
relationView: {
tip: 'The administrator has not configured the relational view, or you do not have permission to access it!'
},
treeView: {
tip: 'Please go to my subscription page to complete the subscription!'
},
ciType: { ciType: {
add: 'Add', add: 'Add',
editModel: 'edit model', addAttribute: 'Add Attribute',
modelName: 'model name', editModel: 'Edit Model',
alias: 'alias', modelName: 'Model Name',
name: 'Name',
alias: 'Alias',
type: 'Type',
unique: 'Unique',
index: 'Index',
sort: 'Sort',
link: 'Link',
password: 'Password',
list: 'List',
integer: 'Integer',
float: 'Float',
text: 'Text',
nameValidate: "You can't start with a number, you can start with an English number and an underscore (_)",
nameRequired: 'Please enter a attribute name',
isIt: 'Is it ',
predefinedValue: 'Predefined values',
predefinedValueTip: 'Multiple values are separated by line breaks',
uniqueFlag: 'unique flag' uniqueFlag: 'unique flag'
} }
} }

View File

@ -23,13 +23,17 @@ export default {
submit: '提交', submit: '提交',
query: '查询', query: '查询',
add: '新增', add: '新增',
new: '新建',
update: '修改',
delete: '删除', delete: '删除',
yes: '', yes: '',
no: '', no: '',
reset: '重置', reset: '重置',
subscribe: '订阅', subscribe: '订阅',
download: '下载模板', downloadTemplate: '下载模板',
upload: '上传' upload: '上传',
download: '下载',
displayFields: '显示字段'
}, },
tip: { tip: {
sourceCode: '源代码', sourceCode: '源代码',
@ -41,16 +45,46 @@ export default {
delete: '删除', delete: '删除',
edit: '编辑', edit: '编辑',
operate: '操作', operate: '操作',
create: '创建',
clear: '清空', clear: '清空',
modify: '修改', modify: '修改',
unselectedAttribute: '未选属性',
selectedAttribute: '已选属性',
noData: '没数据',
addSuccess: '新增成功',
updateSuccess: '修改成功',
deleteSuccess: '删除成功',
cancelSuccess: '取消成功',
downloading: '正在下载 ...',
deleting: '正在删除 ...',
confirmDelete: '真的要删除吗 ?',
warning: '警告',
other: '其他',
requestFailed: '请求出现错误,请稍后再试',
pleaseSelect: '请选择' pleaseSelect: '请选择'
}, },
ci: { ci: {
batchOperate: '批量操作',
confirmBatchUpdate: '确认要批量修改吗 ?',
batchUpdate: '批量修改',
batchUpdateSuccess: '批量修改成功',
confirmDelete: '真的要删除吗 ?',
attribute: '属性',
relation: '关系',
history: '操作历史',
time: '时间',
user: '用户',
batchUpdateTip: '只需要填写需要修改的字段即可!',
selectLevel: '- - 目录层级的选择 - -',
displayFieldDefine: '显示字段定义'
},
table: {
selected: '已选择', selected: '已选择',
batchOperate: '批量操作' clear: '清空'
}, },
preference: { preference: {
cancelSubscribeConfirm: '真的要取消订阅吗 ?',
subscribeSuccess: '订阅成功',
subscribeModel: '订阅模型', subscribeModel: '订阅模型',
resourceView: '资源视图', resourceView: '资源视图',
subFormTip: '既可以定义树形视图, 也可以订阅资源视图, 资源视图会在SideBar单独呈现' subFormTip: '既可以定义树形视图, 也可以订阅资源视图, 资源视图会在SideBar单独呈现'
@ -62,11 +96,34 @@ export default {
dragFileHere: '点击或拖拽文件至此上传!', dragFileHere: '点击或拖拽文件至此上传!',
suportFileType: '支持文件类型' suportFileType: '支持文件类型'
}, },
relationView: {
tip: '管理员 还未配置关系视图, 或者你无权限访问!'
},
treeView: {
tip: '请先到 我的订阅 页面完成订阅!'
},
ciType: { ciType: {
add: '新增', add: '新增',
addAttribute: '新增属性',
editModel: '编辑模型', editModel: '编辑模型',
modelName: '模型名(英文)', modelName: '模型名(英文)',
name: '名称',
alias: '别名', alias: '别名',
type: '类型',
unique: '唯一',
index: '索引',
sort: '排序',
link: '链接',
password: '密码',
list: '列表',
integer: '整数',
float: '浮点数',
text: '文本',
nameValidate: '不能以数字开头,可以是英文 数字以及下划线 (_)',
nameRequired: '请输入属性名',
isIt: '是否',
predefinedValue: '预定义值',
predefinedValueTip: '多个值使用换行分隔',
uniqueFlag: '唯一标识' uniqueFlag: '唯一标识'
} }
} }

View File

@ -12,7 +12,7 @@
:rowKey="record=>record.id" :rowKey="record=>record.id"
:rowSelection="options.rowSelection" :rowSelection="options.rowSelection"
:scroll="scroll" :scroll="scroll"
:pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条记录`, pageSizeOptions: pageSizeOptions}" :pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} ${total} records in total`, pageSizeOptions: pageSizeOptions}"
showPagination="auto" showPagination="auto"
:pageSize="25" :pageSize="25"
ref="table" ref="table"

View File

@ -19,7 +19,7 @@
style="margin-left: 20px" style="margin-left: 20px"
:disabled="downLoadButtonDis" :disabled="downLoadButtonDis"
@click="downLoadExcel" @click="downLoadExcel"
>{{ $t('button.download') }}</a-button> >{{ $t('button.downloadTemplate') }}</a-button>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>

View File

@ -11,8 +11,8 @@
type="primary" type="primary"
icon="plus" icon="plus"
@click="$refs.create.visible = true; $refs.create.action='create'" @click="$refs.create.visible = true; $refs.create.action='create'"
>新建</a-button> >{{ $t('button.new') }}</a-button>
<a-button class="right" @click="showDrawer(typeId)">显示字段</a-button> <a-button class="right" @click="showDrawer(typeId)">{{ $t('button.displayFields') }}</a-button>
<a-dropdown v-action:edit v-if="selectedRowKeys.length > 0"> <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0">
<a-menu slot="overlay"> <a-menu slot="overlay">
<a-menu-item <a-menu-item
@ -20,20 +20,20 @@
@click="$refs.create.visible = true; $refs.create.action='update'" @click="$refs.create.visible = true; $refs.create.action='update'"
> >
<span @click="$refs.create.visible = true"> <span @click="$refs.create.visible = true">
<a-icon type="edit" />&nbsp;修改 <a-icon type="edit" />&nbsp;{{ $t('button.update') }}
</span> </span>
</a-menu-item> </a-menu-item>
<a-menu-item key="batchDownload" @click="batchDownload"> <a-menu-item key="batchDownload" @click="batchDownload">
<json-excel :fetch="batchDownload" name="cmdb.xls"> <json-excel :fetch="batchDownload" name="cmdb.xls">
<a-icon type="download" />&nbsp;下载 <a-icon type="download" />&nbsp;{{ $t('button.download') }}
</json-excel> </json-excel>
</a-menu-item> </a-menu-item>
<a-menu-item key="batchDelete" @click="batchDelete"> <a-menu-item key="batchDelete" @click="batchDelete">
<a-icon type="delete" />删除 <a-icon type="delete" />{{ $t('button.delete') }}
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
<a-button style="margin-left: 8px"> <a-button style="margin-left: 8px">
批量操作 {{ $t('ci.batchOperate') }}
<a-icon type="down" /> <a-icon type="down" />
</a-button> </a-button>
</a-dropdown> </a-dropdown>
@ -48,7 +48,7 @@
:alert="options.alert" :alert="options.alert"
:rowSelection="options.rowSelection" :rowSelection="options.rowSelection"
:scroll="{ x: scrollX, y: scrollY }" :scroll="{ x: scrollX, y: scrollY }"
:pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条记录`, pageSizeOptions: pageSizeOptions}" :pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} ${total} records in total`, pageSizeOptions: pageSizeOptions}"
showPagination="auto" showPagination="auto"
:pageSize="25" :pageSize="25"
> >
@ -64,10 +64,10 @@
<template> <template>
<a <a
@click="$refs.detail.visible = true; $refs.detail.ciId = record.key; $refs.detail.create()" @click="$refs.detail.visible = true; $refs.detail.ciId = record.key; $refs.detail.create()"
>详情</a> >{{ $t('tip.detail') }}</a>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a @click="deleteCI(record)">删除</a> <a @click="deleteCI(record)">{{ $t('tip.delete') }}</a>
</template> </template>
</span> </span>
</s-table> </s-table>
@ -79,7 +79,7 @@
<template> <template>
<div> <div>
<a-drawer <a-drawer
title="显示字段定义" :title="$t('ci.displayFieldDefine')"
:width="600" :width="600"
@close="onClose" @close="onClose"
:visible="visible" :visible="visible"
@ -93,13 +93,13 @@
width: '230px', width: '230px',
height: '500px', height: '500px',
}" }"
:titles="['未选属性','已选属性']" :titles="[$t('tip.unselectedAttribute'), $t('tip.selectedAttribute')]"
:render="item=>item.title" :render="item=>item.title"
:targetKeys="selectedAttrList" :targetKeys="selectedAttrList"
@change="handleChange" @change="handleChange"
@search="handleSearch" @search="handleSearch"
> >
<span slot="notFoundContent">没数据</span> <span slot="notFoundContent">{{ $t('tip.noData') }}</span>
</a-transfer> </a-transfer>
</template> </template>
<div <div
@ -114,8 +114,8 @@
textAlign: 'right', textAlign: 'right',
}" }"
> >
<a-button :style="{marginRight: '8px'}" @click="onClose">取消</a-button> <a-button :style="{marginRight: '8px'}" @click="onClose">{{ $t('button.cancel') }}</a-button>
<a-button @click="subInstanceSubmit" type="primary">提交</a-button> <a-button @click="subInstanceSubmit" type="primary">{{ $t('button.submit') }}</a-button>
</div> </div>
</a-drawer> </a-drawer>
</div> </div>
@ -177,9 +177,7 @@ export default {
visible: false, visible: false,
instanceList: [], instanceList: [],
// 表头
columns: [], columns: [],
// 加载数据方法 必须为 Promise 对象
loadInstances: parameter => { loadInstances: parameter => {
const params = Object.assign(parameter, this.$refs.search.queryParam) const params = Object.assign(parameter, this.$refs.search.queryParam)
let q = `q=_type:${this.$router.currentRoute.meta.typeId}` let q = `q=_type:${this.$router.currentRoute.meta.typeId}`
@ -288,10 +286,11 @@ export default {
this.visible = false this.visible = false
}, },
subInstanceSubmit () { subInstanceSubmit () {
const that = this
subscribeCIType(this.typeId, this.selectedAttrList) subscribeCIType(this.typeId, this.selectedAttrList)
.then(res => { .then(res => {
notification.success({ notification.success({
message: '修改成功' message: that.$t('tip.updateSuccess')
}) })
this.reload() this.reload()
}) })
@ -388,7 +387,7 @@ export default {
}) })
columns.push({ columns.push({
title: '操作', title: this.$t('tip.operate'),
key: 'operation', key: 'operation',
width: 100, width: 100,
fixed: 'right', fixed: 'right',
@ -423,7 +422,7 @@ export default {
}, },
async batchDownload () { async batchDownload () {
this.loading = true this.loading = true
this.loadTip = '正在下载 ...' this.loadTip = this.$t('tip.downloading')
const promises = this.selectedRowKeys.map(ciId => { const promises = this.selectedRowKeys.map(ciId => {
return searchCI(`q=_id:${ciId}`).then(res => { return searchCI(`q=_id:${ciId}`).then(res => {
const ciMap = {} const ciMap = {}
@ -444,11 +443,11 @@ export default {
batchUpdate (values) { batchUpdate (values) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('tip.warning'),
content: '确认要批量修改吗 ?', content: that.$t('ci.confirmBatchUpdate'),
onOk () { onOk () {
that.loading = true that.loading = true
that.loadTip = '正在批量修改 ...' that.loadTip = that.$t('ci.batchUpdate')
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) {
@ -464,7 +463,7 @@ export default {
.then(res => { .then(res => {
that.loading = false that.loading = false
notification.success({ notification.success({
message: '批量修改成功' message: that.$t('ci.batchUpdateSuccess')
}) })
that.$refs.create.visible = false that.$refs.create.visible = false
@ -490,11 +489,11 @@ export default {
batchDelete () { batchDelete () {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('tip.warning'),
content: '真的要删除吗 ?', content: that.$t('ci.confirmDelete'),
onOk () { onOk () {
that.loading = true that.loading = true
that.loadTip = '正在删除 ...' that.loadTip = that.$t('tip.deleting')
const promises = that.selectedRowKeys.map(ciId => { const promises = that.selectedRowKeys.map(ciId => {
return deleteCI(ciId).then(res => { return deleteCI(ciId).then(res => {
return 'ok' return 'ok'
@ -504,7 +503,7 @@ export default {
.then(res => { .then(res => {
that.loading = false that.loading = false
notification.success({ notification.success({
message: '删除成功' message: that.$t('tip.deleteSuccess')
}) })
that.$refs.table.clearSelected() that.$refs.table.clearSelected()
setTimeout(() => { setTimeout(() => {
@ -527,8 +526,8 @@ export default {
deleteCI (record) { deleteCI (record) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('tip.warning'),
content: '真的要删除吗 ?', content: that.$t('ci.confirmDelete'),
onOk () { onOk () {
deleteCI(record.key) deleteCI(record.key)
.then(res => { .then(res => {

View File

@ -16,7 +16,7 @@
<div v-if="activeTabKey === 'tab_1'"> <div v-if="activeTabKey === 'tab_1'">
<a-card <a-card
type="inner" type="inner"
:title="group.name || '其他'" :title="group.name || $t('tip.other')"
:key="group.name" :key="group.name"
v-for="group in attributeGroups" v-for="group in attributeGroups"
> >
@ -116,22 +116,22 @@ export default {
tabList: [ tabList: [
{ {
key: 'tab_1', key: 'tab_1',
tab: '属性' tab: this.$t('ci.attribute')
}, },
{ {
key: 'tab_2', key: 'tab_2',
tab: '关系' tab: this.$t('ci.relation')
}, },
{ {
key: 'tab_3', key: 'tab_3',
tab: '操作历史' tab: this.$t('ci.history')
} }
], ],
activeTabKey: 'tab_1', activeTabKey: 'tab_1',
rowSpanMap: {}, rowSpanMap: {},
historyColumns: [ historyColumns: [
{ {
title: '时间', title: this.$t('ci.time'),
dataIndex: 'created_at', dataIndex: 'created_at',
key: 'created_at', key: 'created_at',
customRender: (value, row, index) => { customRender: (value, row, index) => {
@ -144,7 +144,7 @@ export default {
} }
}, },
{ {
title: '用户', title: this.$t('ci.user'),
dataIndex: 'username', dataIndex: 'username',
key: 'username', key: 'username',
customRender: (value, row, index) => { customRender: (value, row, index) => {
@ -157,13 +157,13 @@ export default {
} }
}, },
{ {
title: '操作', title: this.$t('tip.operate'),
dataIndex: 'operate_type', dataIndex: 'operate_type',
key: 'operate_type', key: 'operate_type',
scopedSlots: { customRender: 'operate_type' } scopedSlots: { customRender: 'operate_type' }
}, },
{ {
title: '属性', title: this.$t('ci.attribute'),
dataIndex: 'attr_alias', dataIndex: 'attr_alias',
key: 'attr_name' key: 'attr_name'
}, },
@ -181,21 +181,12 @@ export default {
ciHistory: [] ciHistory: []
} }
}, },
created () {
// this.getAttributes()
// this.getCI()
// this.getFirstCIs()
// this.getSecondCIs()
// this.getParentCITypes()
// this.getChildCITypes()
// this.getCIHistory()
},
filters: { filters: {
operateTypeFilter (operateType) { operateTypeFilter (operateType) {
const operateTypeMap = { const operateTypeMap = {
'0': '新增', '0': this.$t('button.add'),
'1': '删除', '1': this.$t('button.delete'),
'2': '修改' '2': this.$t('button.update')
} }
return operateTypeMap[operateType] return operateTypeMap[operateType]
} }

View File

@ -7,7 +7,7 @@
:visible="visible" :visible="visible"
:wrapStyle="{height: 'calc(100% - 108px)', overflow: 'auto', paddingBottom: '108px'}" :wrapStyle="{height: 'calc(100% - 108px)', overflow: 'auto', paddingBottom: '108px'}"
> >
<p v-if="action === 'update'">只需要填写需要修改的字段即可!</p> <p v-if="action === 'update'">{{ $t('ci.batchUpdateTip') }}</p>
<a-form :form="form" :layout="formLayout" @submit="createInstance"> <a-form :form="form" :layout="formLayout" @submit="createInstance">
<a-button type="primary" @click="createInstance">Submit</a-button> <a-button type="primary" @click="createInstance">Submit</a-button>
<a-form-item <a-form-item
@ -18,7 +18,7 @@
> >
<a-select <a-select
v-decorator="[ attr.name, { rules: [ { required: attr.is_required && action === 'create' ? true: false } ] } ]" v-decorator="[ attr.name, { rules: [ { required: attr.is_required && action === 'create' ? true: false } ] } ]"
placeholder="请选择" :placeholder="$t('tip.pleaseSelect')"
v-if="attr.is_choice" v-if="attr.is_choice"
> >
<a-select-option <a-select-option
@ -92,7 +92,7 @@ export default {
}, },
computed: { computed: {
title () { title () {
return this.action === 'create' ? '创建 ' : '批量修改 ' return this.action === 'create' ? this.$t('tip.create') + ' ' : this.$t('ci.batchUpdate') + ' '
} }
}, },
watch: { watch: {
@ -115,14 +115,6 @@ export default {
getAttributeList () { getAttributeList () {
getCITypeAttributesById(this.typeId).then(res => { getCITypeAttributesById(this.typeId).then(res => {
const attrList = res.attributes const attrList = res.attributes
// res.attributes.forEach(item =>
// attrList.push({
// name: item.name,
// alias: item.alias,
// value_type: item.value_type,
// is_required: item.is_required
// })
// )
this.attributeList = attrList.sort((x, y) => y.is_required - x.is_required) this.attributeList = attrList.sort((x, y) => y.is_required - x.is_required)
}) })
}, },
@ -144,7 +136,7 @@ export default {
addCI(values) addCI(values)
.then(res => { .then(res => {
notification.success({ notification.success({
message: '新增成功' message: this.$t('tip.addSuccess')
}) })
}) })
.catch(e => { .catch(e => {

View File

@ -12,7 +12,7 @@
<a-form-item :label="prefAttr.alias || prefAttr.name"> <a-form-item :label="prefAttr.alias || prefAttr.name">
<a-select <a-select
v-model="queryParam[prefAttr.name]" v-model="queryParam[prefAttr.name]"
placeholder="请选择" :placeholder="$t('tip.pleaseSelect')"
v-if="prefAttr.is_choice" v-if="prefAttr.is_choice"
> >
<a-select-option <a-select-option
@ -45,7 +45,7 @@
v-for="item in preferenceAttrList.slice(4)" v-for="item in preferenceAttrList.slice(4)"
> >
<a-form-item :label="item.alias || item.name"> <a-form-item :label="item.alias || item.name">
<a-select v-model="queryParam[item.name]" placeholder="请选择" v-if="item.is_choice"> <a-select v-model="queryParam[item.name]" :placeholder="$t('tip.pleaseSelect')" v-if="item.is_choice">
<a-select-option <a-select-option
:value="choice" :value="choice"
:key="'advanced_' + item.name + index" :key="'advanced_' + item.name + index"
@ -104,7 +104,6 @@ var valueTypeMap = {
export default { export default {
data () { data () {
return { return {
// 高级搜索 展开/关闭
advanced: false, advanced: false,
queryParam: {}, queryParam: {},
valueTypeMap: valueTypeMap valueTypeMap: valueTypeMap

View File

@ -2,7 +2,7 @@
<a-card :bordered="false"> <a-card :bordered="false">
<div class="action-btn"> <div class="action-btn">
<a-button @click="handleCreate" type="primary" style="margin-right: 0.3rem;">{{ btnName }}</a-button> <a-button @click="handleCreate" type="primary" style="margin-right: 0.3rem;">{{ $t('ciType.addAttribute') }}</a-button>
</div> </div>
<s-table <s-table
@ -12,7 +12,7 @@
:rowKey="record=>record.id" :rowKey="record=>record.id"
:rowSelection="options.rowSelection" :rowSelection="options.rowSelection"
:scroll="scroll" :scroll="scroll"
:pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条记录`, pageSizeOptions: pageSizeOptions}" :pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} ${total} records in total`, pageSizeOptions: pageSizeOptions}"
showPagination="auto" showPagination="auto"
:pageSize="25" :pageSize="25"
ref="table" ref="table"
@ -34,7 +34,7 @@
icon="search" icon="search"
size="small" size="small"
style="width: 90px; margin-right: 8px" style="width: 90px; margin-right: 8px"
>搜索</a-button> >{{ $t('button.query') }}</a-button>
<a-button <a-button
@click="() => handleReset(clearFilters, column)" @click="() => handleReset(clearFilters, column)"
size="small" size="small"
@ -73,10 +73,10 @@
<a-divider type="vertical"/> <a-divider type="vertical"/>
<a-popconfirm <a-popconfirm
title="确认删除?" :title="$t('tip.confirmDelete')"
@confirm="handleDelete(record)" @confirm="handleDelete(record)"
okText="" :okText="$t('button.yes')"
cancelText="" :cancelText="$t('button.no')"
> >
<a>{{ $t('tip.delete') }}</a> <a>{{ $t('tip.delete') }}</a>
</a-popconfirm> </a-popconfirm>
@ -104,7 +104,6 @@ export default {
data () { data () {
return { return {
scroll: { x: 1000, y: 500 }, scroll: { x: 1000, y: 500 },
btnName: '新增属性',
CITypeName: this.$route.params.CITypeName, CITypeName: this.$route.params.CITypeName,
CITypeId: this.$route.params.CITypeId, CITypeId: this.$route.params.CITypeId,
@ -125,7 +124,7 @@ export default {
}, },
columns: [ columns: [
{ {
title: '名称', title: this.$t('ciType.alias'),
dataIndex: 'alias', dataIndex: 'alias',
sorter: false, sorter: false,
width: 250, width: 250,
@ -144,7 +143,7 @@ export default {
} }
}, },
{ {
title: '英文名', title: this.$t('ciType.name'),
dataIndex: 'name', dataIndex: 'name',
sorter: false, sorter: false,
width: 250, width: 250,
@ -163,7 +162,7 @@ export default {
} }
}, },
{ {
title: '类型', title: this.$t('ciType.type'),
dataIndex: 'value_type', dataIndex: 'value_type',
sorter: false, sorter: false,
width: 80, width: 80,
@ -172,7 +171,7 @@ export default {
}, },
{ {
title: '唯一', title: this.$t('ciType.unique'),
dataIndex: 'is_unique', dataIndex: 'is_unique',
width: 50, width: 50,
sorter: false, sorter: false,
@ -180,7 +179,7 @@ export default {
}, },
{ {
title: '索引', title: this.$t('ciType.index'),
dataIndex: 'is_index', dataIndex: 'is_index',
sorter: false, sorter: false,
width: 50, width: 50,
@ -188,7 +187,7 @@ export default {
}, },
{ {
title: '排序', title: this.$t('ciType.sort'),
dataIndex: 'is_sortable', dataIndex: 'is_sortable',
sorter: false, sorter: false,
width: 50, width: 50,
@ -196,7 +195,7 @@ export default {
}, },
{ {
title: '链接', title: this.$t('ciType.link'),
dataIndex: 'is_link', dataIndex: 'is_link',
sorter: false, sorter: false,
width: 50, width: 50,
@ -204,7 +203,7 @@ export default {
}, },
{ {
title: '密码', title: this.$t('ciType.password'),
dataIndex: 'is_password', dataIndex: 'is_password',
sorter: false, sorter: false,
width: 50, width: 50,
@ -212,7 +211,7 @@ export default {
}, },
{ {
title: '列表', title: this.$t('ciType.list'),
dataIndex: 'is_list', dataIndex: 'is_list',
sorter: false, sorter: false,
scopedSlots: { customRender: 'is_check' } scopedSlots: { customRender: 'is_check' }
@ -220,7 +219,7 @@ export default {
}, },
{ {
title: '操作', title: this.$t('tip.operate'),
dataIndex: 'action', dataIndex: 'action',
width: 100, width: 100,
fixed: 'right', fixed: 'right',
@ -248,11 +247,8 @@ export default {
}, },
mdl: {}, mdl: {},
// 高级搜索 展开/关闭
advanced: false, advanced: false,
// 查询参数
queryParam: {}, queryParam: {},
// 表头
selectedRowKeys: [], selectedRowKeys: [],
selectedRows: [], selectedRows: [],
@ -340,13 +336,13 @@ export default {
deleteAttribute (attrId) { deleteAttribute (attrId) {
deleteAttributesById(attrId) deleteAttributesById(attrId)
.then(res => { .then(res => {
this.$message.success(`删除成功`) this.$message.success(this.$t('tip.deleteSuccess'))
this.handleOk() this.handleOk()
}) })
.catch(err => this.requestFailed(err)) .catch(err => this.requestFailed(err))
}, },
requestFailed (err) { requestFailed (err) {
const msg = ((err.response || {}).data || {}).message || '请求出现错误,请稍后再试' const msg = ((err.response || {}).data || {}).message || this.$t('tip.requestFailed')
this.$message.error(`${msg}`) this.$message.error(`${msg}`)
} }

View File

@ -13,18 +13,17 @@
<a-form-item <a-form-item
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
label="属性名(英文)" :label="$t('ciType.name')"
> >
<a-input <a-input
name="name" name="name"
placeholder="英文" v-decorator="['name', {rules: [{ required: true, message: $t('ciType.nameRequired')},{message: $t('ciType.nameValidate'), pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$')}]} ]"
v-decorator="['name', {rules: [{ required: true, message: '请输入属性名'},{message: '不能以数字开头,可以是英文 数字以及下划线 (_)', pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$')}]} ]"
/> />
</a-form-item> </a-form-item>
<a-form-item <a-form-item
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
label="别名" :label="$t('ciType.alias')"
> >
<a-input <a-input
name="alias" name="alias"
@ -35,7 +34,7 @@
<a-form-item <a-form-item
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
label="数据类型" :label="$t('ciType.type')"
> >
<a-select <a-select
@ -51,7 +50,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('ciType.isIt') + $t('ciType.unique')"
> >
<a-switch <a-switch
@change="onChange" @change="onChange"
@ -63,7 +62,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('ciType.isIt') + $t('ciType.index')"
> >
<a-switch <a-switch
@change="onChange" @change="onChange"
@ -75,7 +74,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('ciType.isIt') + $t('ciType.sort')"
> >
<a-switch <a-switch
@change="onChange" @change="onChange"
@ -86,7 +85,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('ciType.isIt') + $t('ciType.link')"
> >
<a-switch <a-switch
@change="onChange" @change="onChange"
@ -97,7 +96,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('ciType.isIt') + $t('ciType.password')"
> >
<a-switch <a-switch
@change="onChange" @change="onChange"
@ -108,7 +107,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('ciType.isIt') + $t('ciType.list')"
> >
<a-switch <a-switch
@change="onChange" @change="onChange"
@ -119,12 +118,12 @@
<a-form-item <a-form-item
:label-col="formItemLayout.labelCol" :label-col="formItemLayout.labelCol"
:wrapper-col="formItemLayout.wrapperCol" :wrapper-col="formItemLayout.wrapperCol"
label="预定义值" :label="$t('ciType.predefinedValue')"
> >
<a-textarea <a-textarea
:rows="5" :rows="5"
name="choice_value" name="choice_value"
placeholder="多个值使用换行分隔" :placeholder="$t('ciType.predefinedValueTip')"
v-decorator="['choice_value', {rules: []} ]" v-decorator="['choice_value', {rules: []} ]"
/> />
</a-form-item> </a-form-item>
@ -171,7 +170,7 @@ export default {
data () { data () {
return { return {
drawerTitle: '新增属性', drawerTitle: this.$t('ciType.addAttribute'),
drawerVisible: false, drawerVisible: false,
CITypeName: this.$route.params.CITypeName, CITypeName: this.$route.params.CITypeName,
CITypeId: this.$route.params.CITypeId, CITypeId: this.$route.params.CITypeId,
@ -271,7 +270,7 @@ export default {
updateAttribute (attrId, data) { updateAttribute (attrId, data) {
updateAttributeById(attrId, data) updateAttributeById(attrId, data)
.then(res => { .then(res => {
this.$message.success(`更新成功`) this.$message.success(this.$t('tip.updateSuccess'))
this.handleOk() this.handleOk()
this.onClose() this.onClose()
}).catch(err => this.requestFailed(err)) }).catch(err => this.requestFailed(err))
@ -283,12 +282,12 @@ export default {
if (this.CITypeId) { if (this.CITypeId) {
createCITypeAttributes(this.CITypeId, { attr_id: [res.attr_id] }) createCITypeAttributes(this.CITypeId, { attr_id: [res.attr_id] })
.then(res => { .then(res => {
this.$message.success(`添加成功`) this.$message.success(this.$t('tip.addSuccess'))
this.handleOk() this.handleOk()
this.onClose() this.onClose()
}).catch(err => this.requestFailed(err)) }).catch(err => this.requestFailed(err))
} else { } else {
this.$message.success(`添加成功`) this.$message.success(this.$t('tip.addSuccess'))
this.handleOk() this.handleOk()
this.onClose() this.onClose()
} }
@ -297,7 +296,7 @@ export default {
}, },
requestFailed (err) { requestFailed (err) {
const msg = ((err.response || {}).data || {}).message || '请求出现错误,请稍后再试' const msg = ((err.response || {}).data || {}).message || this.$t('tip.requestFailed')
this.$message.error(`${msg}`) this.$message.error(`${msg}`)
} }

View File

@ -1,9 +1,11 @@
import i18n from '@/locales'
export const valueTypeMap = { export const valueTypeMap = {
'0': '整数', '0': i18n.t('ciType.integer'),
'1': '浮点数', '1': i18n.t('ciType.float'),
'2': '文本', '2': i18n.t('ciType.text'),
'3': 'datetime', '3': 'Datetime',
'4': 'date', '4': 'Date',
'5': 'time', '5': 'Time',
'6': 'json' '6': 'Json'
} }

View File

@ -158,8 +158,8 @@ export default {
form: this.$form.createForm(this), form: this.$form.createForm(this),
scroll: { x: 1030, y: 600 }, scroll: { x: 1030, y: 600 },
singleAttrAction: { singleAttrAction: {
btnName: '新增属性', btnName: this.$t('ciType.addAttribute'),
drawerTitle: '新增属性', drawerTitle: this.$t('ciType.addAttribute'),
drawerVisible: false drawerVisible: false
}, },
batchBindAttrAction: { batchBindAttrAction: {

View File

@ -17,7 +17,7 @@
<span <span
:class="item.is_subscribed?'subscribe-success':'unsubscribe'" :class="item.is_subscribed?'subscribe-success':'unsubscribe'"
slot="title" slot="title"
>{{ item.is_subscribed ? $t('tip.subscribed') : $t('tip.unsubscribed') }}</span> >{{ item.is_subscribed ? $t('tip.subscribed') : $t('tip.unsubscribed') }}</span>
</a-card-meta> </a-card-meta>
<template class="ant-card-actions" slot="actions"> <template class="ant-card-actions" slot="actions">
<a :disabled="!item.is_subscribed" @click="unsubscribe(item.id)">{{ $t('button.cancel') }}</a> <a :disabled="!item.is_subscribed" @click="unsubscribe(item.id)">{{ $t('button.cancel') }}</a>
@ -49,7 +49,7 @@
<a-select <a-select
ref="tree" ref="tree"
mode="multiple" mode="multiple"
placeholder="- - 目录层级的选择 - -" :placeholder="$t('ci.selectLevel')"
:value="treeViews" :value="treeViews"
style="width: 100%" style="width: 100%"
@change="handleTreeSub" @change="handleTreeSub"
@ -80,13 +80,13 @@
width: '230px', width: '230px',
height: '500px', height: '500px',
}" }"
:titles="['未选属性','已选属性']" :titles="[$t('tip.unselectedAttribute'), $t('tip.selectedAttribute')]"
:render="item=>item.title" :render="item=>item.title"
:targetKeys="selectedAttrList" :targetKeys="selectedAttrList"
@change="handleChange" @change="handleChange"
@search="handleSearch" @search="handleSearch"
> >
<span slot="notFoundContent">没数据</span> <span slot="notFoundContent">{{ $t('tip.noData') }}</span>
</a-transfer> </a-transfer>
</template> </template>
<div <div
@ -161,15 +161,15 @@ export default {
unsubscribe (citypeId) { unsubscribe (citypeId) {
const that = this const that = this
this.$confirm({ this.$confirm({
title: '警告', title: that.$t('tip.warning'),
content: '真的要取消订阅吗 ?', content: that.$t('preference.cancelSubscribeConfirm'),
onOk () { onOk () {
const unsubCIType = subscribeCIType(citypeId, '') const unsubCIType = subscribeCIType(citypeId, '')
const unsubTree = subscribeTreeView(citypeId, '') const unsubTree = subscribeTreeView(citypeId, '')
Promise.all([unsubCIType, unsubTree]) Promise.all([unsubCIType, unsubTree])
.then(() => { .then(() => {
notification.success({ notification.success({
message: '取消成功' message: that.$t('tip.cancelSuccess')
}) })
that.resetRoute() that.resetRoute()
}) })
@ -183,7 +183,6 @@ export default {
onCancel () {} onCancel () {}
}) })
}, },
// 显示右边的弹出框
showDrawer (typeId, typeName) { showDrawer (typeId, typeName) {
this.typeId = typeId this.typeId = typeId
this.typeName = typeName this.typeName = typeName
@ -223,17 +222,15 @@ export default {
handleTreeSub (values) { handleTreeSub (values) {
this.treeViews = values this.treeViews = values
}, },
// 处理点击改变事件
handleChange (targetKeys, direction, moveKeys) { handleChange (targetKeys, direction, moveKeys) {
this.selectedAttrList = targetKeys this.selectedAttrList = targetKeys
}, },
handleSearch (dir, value) {}, handleSearch (dir, value) {},
// 处理提交事件
subInstanceSubmit () { subInstanceSubmit () {
subscribeCIType(this.typeId, this.selectedAttrList) subscribeCIType(this.typeId, this.selectedAttrList)
.then(res => { .then(res => {
notification.success({ notification.success({
message: '订阅成功' message: this.$t('preference.subscribeSuccess')
}) })
this.resetRoute() this.resetRoute()
}) })
@ -281,7 +278,7 @@ export default {
subscribeTreeView(this.typeId, this.treeViews) subscribeTreeView(this.typeId, this.treeViews)
.then(res => { .then(res => {
notification.success({ notification.success({
message: '订阅成功' message: this.$t('preference.subscribeSuccess')
}) })
}) })
.catch(e => { .catch(e => {

View File

@ -7,7 +7,7 @@
>{{ item[0] }}</router-link> >{{ item[0] }}</router-link>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
<a-alert message="管理员 还未配置关系视图, 或者你无权限访问!" banner v-else-if="relationViews.name2id && !relationViews.name2id.length"></a-alert> <a-alert :message="$t('relationView.tip')" banner v-else-if="relationViews.name2id && !relationViews.name2id.length"></a-alert>
<div style="clear: both; margin-top: 20px"></div> <div style="clear: both; margin-top: 20px"></div>
<template> <template>
<a-row :gutter="8"> <a-row :gutter="8">
@ -30,7 +30,7 @@
:columns="columns" :columns="columns"
:data="loadInstances" :data="loadInstances"
:scroll="{ x: scrollX, y: scrollY }" :scroll="{ x: scrollX, y: scrollY }"
:pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条记录`, pageSizeOptions: pageSizeOptions}" :pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} ${total} records in total`, pageSizeOptions: pageSizeOptions}"
:pageSize="25" :pageSize="25"
showPagination="auto" showPagination="auto"
></s-table> ></s-table>

View File

@ -7,7 +7,7 @@
>{{ ciType.alias || ciTypes.name }}</router-link> >{{ ciType.alias || ciTypes.name }}</router-link>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
<a-alert message="请先到 我的订阅 页面完成订阅!" banner v-else-if="ciTypes && !ciTypes.length"></a-alert> <a-alert :message="$t('treeView.tip')" banner v-else-if="ciTypes && !ciTypes.length"></a-alert>
<div style="clear: both; margin-top: 20px"></div> <div style="clear: both; margin-top: 20px"></div>
<template> <template>
<a-row :gutter="8"> <a-row :gutter="8">
@ -25,7 +25,7 @@
:columns="columns" :columns="columns"
:data="loadInstances" :data="loadInstances"
:scroll="{ x: scrollX, y: scrollY }" :scroll="{ x: scrollX, y: scrollY }"
:pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条记录`, pageSizeOptions: pageSizeOptions}" :pagination="{ showTotal: (total, range) => `${range[0]}-${range[1]} ${total} records in total`, pageSizeOptions: pageSizeOptions}"
:pageSize="25" :pageSize="25"
showPagination="auto" showPagination="auto"
></s-table> ></s-table>