CN-1734 fix: Entity setting页面开发

This commit is contained in:
刘洪洪
2024-11-17 22:52:18 +08:00
parent b47e72ef3e
commit 868c49a8ee
5 changed files with 81 additions and 110 deletions

View File

@@ -364,7 +364,6 @@ export default {
}, },
computed: { computed: {
networkAnalyticsMenu () { networkAnalyticsMenu () {
console.log('-------', this.$store.getters.menuList)
return this.$store.getters.menuList.find(menu => menu.code === 'networkAnalytics') return this.$store.getters.menuList.find(menu => menu.code === 'networkAnalytics')
}, },
locationIntelligenceMenu () { locationIntelligenceMenu () {
@@ -782,7 +781,6 @@ export default {
}, },
// 仅处理除panel外的相关路径的导航 // 仅处理除panel外的相关路径的导航
async jumpOther (route, index) { async jumpOther (route, index) {
console.log('route', route, index)
if (route === '/setting') { if (route === '/setting') {
this.isShowSetting = true this.isShowSetting = true
return true return true

View File

@@ -33,7 +33,7 @@
<div class="col-resize-area"></div> <div class="col-resize-area"></div>
</template> </template>
<template #default="scope" :column="item"> <template #default="scope" :column="item">
<template v-if="item.prop === 'createdTime' || item.prop === 'updateTime'"> <template v-if="item.prop === 'ctime' || item.prop === 'utime'">
<template v-if="scope.row[item.prop]"> <template v-if="scope.row[item.prop]">
{{ dateFormatByAppearance(scope.row[item.prop]) || '-' }} {{ dateFormatByAppearance(scope.row[item.prop]) || '-' }}
</template> </template>
@@ -94,25 +94,18 @@ export default {
}, },
{ {
label: this.$t('config.user.createTime'), label: this.$t('config.user.createTime'),
prop: 'createTime', prop: 'ctime',
show: true, show: true,
minWidth: 200 minWidth: 200
}, },
{ {
label: this.$t('overall.updateTime'), label: this.$t('overall.updateTime'),
prop: 'updateTime', prop: 'utime',
show: true show: true
} }
] ]
} }
}, },
computed: {
uploadParams () {
return {
indicatorType: 'IP'
}
}
},
methods: { methods: {
dateFormatByAppearance, dateFormatByAppearance,
// 禁止勾选buildIn为1的项即禁止修改、删除admin的账号 // 禁止勾选buildIn为1的项即禁止修改、删除admin的账号

View File

@@ -64,8 +64,7 @@ import dataListMixin from '@/mixins/data-list'
import Loading from '@/components/common/Loading' import Loading from '@/components/common/Loading'
import cnDataList from '@/components/table/CnDataList' import cnDataList from '@/components/table/CnDataList'
import ProfilesTable from '@/components/table/setting/ProfilesTable' import ProfilesTable from '@/components/table/setting/ProfilesTable'
import { profilesList } from '@/utils/static-data' import axios from 'axios'
import axios from '_axios@0.21.4@axios'
export default { export default {
name: 'EntitySetting', name: 'EntitySetting',
@@ -136,11 +135,6 @@ export default {
} }
if (!this.isInit) { if (!this.isInit) {
// this.tableData = profilesList
// this.pageObj.total = profilesList.length
// this.isNoData = !this.tableData || this.tableData.length === 0
// this.toggleLoading(false)
console.log('params', this.searchLabel)
axios.get(listUrl, { params: this.searchLabel }).then(response => { axios.get(listUrl, { params: this.searchLabel }).then(response => {
if (response.status === 200) { if (response.status === 200) {
this.$nextTick(() => { this.$nextTick(() => {
@@ -185,31 +179,11 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.toggleLoading(true) this.toggleLoading(true)
axios.delete(api.setting.profiles.profiles + '?id=' + ids).then(response => { axios.delete(api.setting.profiles.profiles + '?ids=' + ids).then(response => {
if (response.status === 200) { if (response.status === 200) {
this.delFlag = true this.delFlag = true
this.$message({ this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
duration: 2000, this.getTableData()
type: 'success',
message: this.$t('tip.deleteSuccess')
})
let params = null
if (this.intent) {
params = { intent: this.intent }
}
if (this.category) {
params = {
...params,
category: this.category
}
}
if (this.name) {
params = {
...params,
name: this.name
}
}
this.getTableData(params)
} else { } else {
this.$message.error(response.data.message) this.$message.error(response.data.message)
} }

View File

@@ -20,13 +20,13 @@
</template> </template>
<div class="form-collapse-content"> <div class="form-collapse-content">
<el-form ref="sourceForm" :model="editObj" label-position="top" :rules="sourceRules"> <el-form ref="sourceForm" :model="editObj" label-position="top" :rules="sourceRules">
<el-form-item :label="$t('setting.source')" prop="source_id" class="form-setting__block margin-b-20"> <el-form-item :label="$t('setting.source')" prop="sourceId" class="form-setting__block margin-b-20">
<el-select v-model="editObj.source_id" class="form-setting__select" placeholder=" "> <el-select v-model="editObj.sourceId" class="form-setting__select" placeholder=" ">
<el-option <el-option
v-for="item in sourceOption" v-for="item in sourceOption"
:key="item.source_id" :key="item.id"
:label="item.label" :label="item.name"
:value="item.source_id" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@@ -209,7 +209,7 @@ export default {
activeNames: ['1'], activeNames: ['1'],
intervalList: [], intervalList: [],
sourceRules: { sourceRules: {
source_id: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }] sourceId: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }]
}, },
mappingRules: { mappingRules: {
type: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }], type: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }],
@@ -270,7 +270,7 @@ export default {
const editObj = ref({ const editObj = ref({
id: '', id: '',
source_id: '', sourceId: '',
entities: [], entities: [],
schemaMappingData: { schemaMappingData: {
data: [ data: [
@@ -303,12 +303,36 @@ export default {
methods: { methods: {
switchStatus, switchStatus,
initSourceData () { initSourceData () {
this.sourceOption = [ axios.get(api.setting.source.source).then(response => {
{ source_id: '1', value: 'ip_metric1', label: 'IP metric1' }, if (response.status === 200) {
{ source_id: '2', value: 'ip_metric2', label: 'IP metric2' }, if (!response.data.data) {
{ source_id: '3', value: 'ip_metric3', label: 'IP metric3' }, throw new Error('No data found, id: ' + this.ruleId)
{ source_id: '4', value: 'ip_metric4', label: 'IP metric4' } }
] this.sourceOption = response.data.data.list
if (this.sourceOption && this.sourceOption.length > 0) {
this.sourceOption.forEach((item, index) => {
if (typeof item.fields === 'string') {
this.sourceOption[index].fieldsList = JSON.parse(item.fields)
}
if (typeof item.lookups === 'string') {
this.sourceOption[index].lookupsList = JSON.parse(item.lookups)
}
})
}
} else {
console.error(response.data)
}
}).catch(e => {
console.error(e)
this.$message.error(this.errorMsgHandler(e))
this.$router.push({
path: '/setting/entitySetting',
query: {
pageNo: this.pageNoForTable ? Number(this.pageNoForTable) : 1,
t: +new Date()
}
})
})
}, },
/** 编辑时获取详情 */ /** 编辑时获取详情 */
getDetailInfo () { getDetailInfo () {
@@ -318,11 +342,22 @@ export default {
throw new Error('No data found, id: ' + this.ruleId) throw new Error('No data found, id: ' + this.ruleId)
} }
this.myLoading = false this.myLoading = false
this.editObj = { this.editObj = { ...this.editObj, ...response.data.data, ruleId: this.ruleId }
...response.data.data,
ruleId: this.ruleId if (this.editObj.entities && typeof this.editObj.entities === 'string') {
const entities = JSON.parse(this.editObj.entities)
entities.forEach(item => {
const list = []
for (const [key, value] of Object.entries(item.mapping)) {
list.push({ field: key, source: value.toString() })
}
item.list = list
})
this.editObj.schemaMappingData.data = entities
}
if (this.editObj.relations && typeof this.editObj.relations === 'string') {
this.editObj.relationData.data = JSON.parse(this.editObj.relations)
} }
this.ruleObj = this.$_.cloneDeep(this.editObj.ruleConfigObj)
this.activeNames = ['1', '2'] this.activeNames = ['1', '2']
} else { } else {
console.error(response.data) console.error(response.data)
@@ -425,7 +460,6 @@ export default {
} else { } else {
this.isCloseMappingItem = this.editObj.schemaMappingData.data[0].list.length > 1 this.isCloseMappingItem = this.editObj.schemaMappingData.data[0].list.length > 1
} }
console.log('shuzu', this.editObj.schemaMappingData.data)
}, },
/** 删除relation的子项 **/ /** 删除relation的子项 **/
deleteRelationItem (index) { deleteRelationItem (index) {
@@ -442,21 +476,16 @@ export default {
return name return name
}, },
visibleFromEntity (index) { visibleFromEntity (index) {
console.log('visible---from', this.editObj.relationData.data, index)
}, },
changeFromEntity (index) { changeFromEntity (index) {
console.log('from---data', this.editObj.relationData.data)
this.editObj.relationData.data[index].fromDisabled = true this.editObj.relationData.data[index].fromDisabled = true
}, },
changeToEntity (index) { changeToEntity (index) {
console.log('to---data', this.editObj.relationData.data)
this.editObj.relationData.data[index].toDisabled = true this.editObj.relationData.data[index].toDisabled = true
}, },
handleToEntityData (index) { handleToEntityData (index) {
console.log('index', index)
if (index && index >= 0) { if (index && index >= 0) {
const obj = this.editObj.relationData.data[index] // const obj = this.editObj.relationData.data[index]
console.log('obj', obj)
} }
return this.editObj.schemaMappingData.data return this.editObj.schemaMappingData.data
}, },
@@ -497,27 +526,20 @@ export default {
const valid3 = await this.$refs.relationForm.validate((valid) => { const valid3 = await this.$refs.relationForm.validate((valid) => {
return valid return valid
}) })
console.log('obj', this.editObj)
const formObj = this.$_.cloneDeep(this.editObj)
formObj.schemaMappingData.data.forEach((item) => {
const obj = {}
item.list.forEach(ite => {
obj[ite.field] = ite.source
})
item.mapping = this.$_.cloneDeep(obj)
})
console.log('formObj', formObj)
if (valid1 && valid2 && valid3) { if (valid1 && valid2 && valid3) {
this.myLoading = true this.myLoading = true
if (!this.ruleId) { const formObj = this.$_.cloneDeep(this.editObj)
const formObj = this.$_.cloneDeep(this.editObj) formObj.schemaMappingData.data.forEach((item) => {
formObj.schemaMappingData.data.forEach((item) => { const obj = {}
const obj = {} item.list.forEach(ite => {
item.list.forEach(ite => { obj[ite.field] = ite.source
obj[ite.field] = ite.source
})
item.mapping = this.$_.cloneDeep(obj)
}) })
item.mapping = this.$_.cloneDeep(obj)
})
formObj.entities = JSON.stringify(formObj.schemaMappingData.data)
formObj.relations = JSON.stringify(formObj.relationData.data)
if (!this.ruleId) {
// post调用是新增put是编辑 // post调用是新增put是编辑
axios.post(api.setting.profiles.profiles, formObj).then(response => { axios.post(api.setting.profiles.profiles, formObj).then(response => {
if (response.status === 200) { if (response.status === 200) {
@@ -540,7 +562,7 @@ export default {
this.myLoading = false this.myLoading = false
}) })
} else { } else {
axios.put(api.setting.profiles.profiles, 'formObj').then(response => { axios.put(api.setting.profiles.profiles, formObj).then(response => {
if (response.status === 200) { if (response.status === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') }) this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
@@ -581,14 +603,14 @@ export default {
queryInfo.name = this.settingObj.name queryInfo.name = this.settingObj.name
} }
if (this.settingObj.editFlag || this.ruleObj.editFlag) { // if (this.settingObj.editFlag || this.ruleObj.editFlag) {
this.confirmMessage(queryInfo) // this.confirmMessage(queryInfo)
} else { // } else {
this.$router.push({ // }
path: '/setting/entitySetting', this.$router.push({
query: queryInfo path: '/setting/entitySetting',
}) query: queryInfo
} })
}, },
confirmMessage (queryInfo) { confirmMessage (queryInfo) {
ElMessageBox.confirm(this.$t('tip.leavePage'), { ElMessageBox.confirm(this.$t('tip.leavePage'), {

View File

@@ -140,23 +140,7 @@ export default {
type: 'success', type: 'success',
message: this.$t('tip.deleteSuccess') message: this.$t('tip.deleteSuccess')
}) })
let params = null this.getTableData()
if (this.intent) {
params = { intent: this.intent }
}
if (this.category) {
params = {
...params,
category: this.category
}
}
if (this.name) {
params = {
...params,
name: this.name
}
}
this.getTableData(params)
} else { } else {
this.$message.error(response.data.message) this.$message.error(response.data.message)
} }