CN-1733 fix: 1、完善Entity Setting页面的mapping下拉框数据;2、添加删除校验
This commit is contained in:
@@ -123,6 +123,7 @@ $border-color-light: var(--el-border-color-light);
|
||||
width: 596px;
|
||||
line-height: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-primary);
|
||||
font-weight: bold;
|
||||
@@ -131,6 +132,15 @@ $border-color-light: var(--el-border-color-light);
|
||||
div:nth-child(1) {
|
||||
width: 288px;
|
||||
}
|
||||
|
||||
.block-header__menu {
|
||||
display: flex;
|
||||
padding: 10px;
|
||||
|
||||
div:nth-child(1) {
|
||||
width: 278px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.el-form {
|
||||
@@ -138,8 +148,8 @@ $border-color-light: var(--el-border-color-light);
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.block-body {
|
||||
width: 596px;
|
||||
.block-body, .block-body1 {
|
||||
width: 576px;
|
||||
display: flex;
|
||||
|
||||
.el-form-item {
|
||||
@@ -147,11 +157,12 @@ $border-color-light: var(--el-border-color-light);
|
||||
}
|
||||
|
||||
.block-body__select {
|
||||
width: 260px;
|
||||
width: 255px;
|
||||
}
|
||||
|
||||
.block-body-equal {
|
||||
margin: 0 10px;
|
||||
color: var(--el-text-color-disabled);
|
||||
}
|
||||
|
||||
.mapping-item-add {
|
||||
@@ -187,10 +198,18 @@ $border-color-light: var(--el-border-color-light);
|
||||
}
|
||||
|
||||
.relation-type__select {
|
||||
width: 312px;
|
||||
width: 302px;
|
||||
margin: 0 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.block-body {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.block-body1 {
|
||||
width: 596px;
|
||||
}
|
||||
}
|
||||
|
||||
.form-setting-type {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: "cn-icon"; /* Project id 2614877 */
|
||||
src: url('iconfont.woff2?t=1730282688072') format('woff2'),
|
||||
url('iconfont.woff?t=1730282688072') format('woff'),
|
||||
url('iconfont.ttf?t=1730282688072') format('truetype');
|
||||
src: url('iconfont.woff2?t=1731894091336') format('woff2'),
|
||||
url('iconfont.woff?t=1731894091336') format('woff'),
|
||||
url('iconfont.ttf?t=1731894091336') format('truetype');
|
||||
}
|
||||
|
||||
.cn-icon {
|
||||
@@ -13,6 +13,14 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.cn-icon-System:before {
|
||||
content: "\e830";
|
||||
}
|
||||
|
||||
.cn-icon-mutual:before {
|
||||
content: "\ec8d";
|
||||
}
|
||||
|
||||
.cn-icon-breached-human-black:before {
|
||||
content: "\e824";
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -33,13 +33,18 @@
|
||||
<div class="col-resize-area"></div>
|
||||
</template>
|
||||
<template #default="scope" :column="item">
|
||||
<template v-if="item.prop === 'ctime' || item.prop === 'utime'">
|
||||
<template v-if="item.prop === 'create_time' || item.prop === 'update_time'">
|
||||
<template v-if="scope.row[item.prop]">
|
||||
{{ dateFormatByAppearance(scope.row[item.prop]) || '-' }}
|
||||
</template>
|
||||
<template v-else><span>-</span></template>
|
||||
</template>
|
||||
<span v-else>{{ scope.row[item.prop] || '-' }}</span>
|
||||
<template v-if="item.prop === 'entitySource'">
|
||||
{{ scope.row[item.prop].name || '-' }}
|
||||
</template>
|
||||
<template v-if="item.prop === 'entities' || item.prop === 'relations'">
|
||||
{{ handleListTypes(scope.row[item.prop]) }}
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template v-slot:empty>
|
||||
@@ -75,32 +80,32 @@ export default {
|
||||
},
|
||||
{
|
||||
label: this.$t('setting.source'),
|
||||
prop: 'source',
|
||||
prop: 'entitySource',
|
||||
show: true,
|
||||
sortable: 'custom',
|
||||
minWidth: 200
|
||||
},
|
||||
{
|
||||
label: this.$t('setting.entityTypes'),
|
||||
prop: 'entityTypes',
|
||||
prop: 'entities',
|
||||
show: true,
|
||||
minWidth: 200
|
||||
},
|
||||
{
|
||||
label: this.$t('setting.relationTypes'),
|
||||
prop: 'relationTypes',
|
||||
prop: 'relations',
|
||||
show: true,
|
||||
minWidth: 200
|
||||
},
|
||||
{
|
||||
label: this.$t('config.user.createTime'),
|
||||
prop: 'ctime',
|
||||
prop: 'create_time',
|
||||
show: true,
|
||||
minWidth: 200
|
||||
},
|
||||
{
|
||||
label: this.$t('overall.updateTime'),
|
||||
prop: 'utime',
|
||||
prop: 'update_time',
|
||||
show: true
|
||||
}
|
||||
]
|
||||
@@ -111,6 +116,21 @@ export default {
|
||||
// 禁止勾选buildIn为1的项,即禁止修改、删除admin的账号
|
||||
checkSelectable (row) {
|
||||
return row.buildIn !== 1
|
||||
},
|
||||
handleListTypes (data) {
|
||||
let str = ''
|
||||
if (data && typeof data === 'string') {
|
||||
data = JSON.parse(data)
|
||||
data.forEach(item => {
|
||||
if (!str) {
|
||||
str = item.type + ','
|
||||
} else if (str.indexOf(item.type) < 0) {
|
||||
str += item.type + ','
|
||||
}
|
||||
})
|
||||
str = str.slice(0, -1)
|
||||
}
|
||||
return str
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@
|
||||
<div class="col-resize-area"></div>
|
||||
</template>
|
||||
<template #default="scope" :column="item">
|
||||
<template v-if="item.prop === 'createdTime'">
|
||||
<template v-if="item.prop === 'create_time'">
|
||||
<template v-if="scope.row[item.prop]">
|
||||
{{ dateFormatByAppearance(scope.row[item.prop]) || '-' }}
|
||||
</template>
|
||||
<template v-else><span>-</span></template>
|
||||
</template>
|
||||
<template v-else-if="item.prop === 'option'">
|
||||
<i class="cn-icon cn-icon-upload" style="cursor: pointer;" @click="dialogVisible=true"></i>
|
||||
<i class="cn-icon cn-icon-upload" style="cursor: pointer;" @click="clickOption(scope.row)"></i>
|
||||
</template>
|
||||
<span v-else>{{ scope.row[item.prop] || '-' }}</span>
|
||||
</template>
|
||||
@@ -58,7 +58,7 @@
|
||||
</template>
|
||||
<div class="sources-dialog__body">
|
||||
<div class="dialog__body-upload">
|
||||
<!-- <loading :loading="uploadLoading"></loading>-->
|
||||
<loading :loading="uploadLoading"></loading>
|
||||
<el-upload :action="uploadUrl"
|
||||
:headers="uploadHeaders"
|
||||
:data="uploadParams"
|
||||
@@ -107,6 +107,7 @@ import unitConvert from '@/utils/unit-convert'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { ref } from 'vue'
|
||||
import { api } from '@/utils/api'
|
||||
import Loading from '@/components/common/Loading'
|
||||
|
||||
export default {
|
||||
name: 'SourcesTable',
|
||||
@@ -119,6 +120,7 @@ export default {
|
||||
mixins: [table],
|
||||
data () {
|
||||
return {
|
||||
sourceId: '',
|
||||
tableTitle: [ // 原始table列
|
||||
{
|
||||
label: 'ID',
|
||||
@@ -142,7 +144,7 @@ export default {
|
||||
},
|
||||
{
|
||||
label: this.$t('config.user.createTime'),
|
||||
prop: 'createdTime',
|
||||
prop: 'create_time',
|
||||
show: true,
|
||||
minWidth: 150
|
||||
},
|
||||
@@ -153,13 +155,14 @@ export default {
|
||||
}
|
||||
],
|
||||
dialogVisible: false,
|
||||
uploadUrl: api.setting.source.sourceUpload,
|
||||
uploadUrl: BASE_CONFIG.baseUrl + api.setting.source.sourceUpload,
|
||||
uploadHeaders: {
|
||||
'Cn-Authorization': localStorage.getItem(storageKey.token)
|
||||
},
|
||||
fileList: [],
|
||||
fileTypeLimit: '.csv',
|
||||
language: localStorage.getItem(storageKey.language) || EN,
|
||||
uploadLoading: false,
|
||||
tipsInfo: {
|
||||
en: [
|
||||
{ value: 0, label: 'You can now integrate data to our platform using two methods:' },
|
||||
@@ -173,18 +176,27 @@ export default {
|
||||
{ value: 2, label: '2. Kafka 直接传输:将您的数据发送到我们服务器上的特定 Kafka 主题,确保每条消息都包含带有 source_id 的标头。' },
|
||||
{ value: 3, label: '有关 Kafka 服务器的信息,请联系您的管理员。' }
|
||||
]
|
||||
}
|
||||
},
|
||||
uploadFileSizeLimit: 1024 * 1024 * 1024,
|
||||
isClick: true
|
||||
}
|
||||
},
|
||||
components: {
|
||||
Loading
|
||||
},
|
||||
computed: {
|
||||
uploadParams () {
|
||||
return {
|
||||
indicatorType: 'IP'
|
||||
id: this.sourceId
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
dateFormatByAppearance,
|
||||
clickOption (item) {
|
||||
this.sourceId = item.id
|
||||
this.dialogVisible = true
|
||||
},
|
||||
// 禁止勾选buildIn为1的项,即禁止修改、删除admin的账号
|
||||
checkSelectable (row) {
|
||||
return row.buildIn !== 1
|
||||
|
||||
@@ -390,7 +390,7 @@ export const api = {
|
||||
setting: {
|
||||
source: {
|
||||
source: apiVersion + '/entity/sources', // get列表查询,delete删除,post新增,put修改
|
||||
sourceUpload: apiVersion + 'entity/sources/upload' // 文件上传,post
|
||||
sourceUpload: apiVersion + '/entity/sources/upload' // 文件上传,post
|
||||
},
|
||||
profiles: {
|
||||
profiles: apiVersion + '/entity/profiles' // get列表查询,delete删除,post新增,put修改
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -18,7 +18,7 @@
|
||||
</button>
|
||||
<button id="tag-edit" class="business-button business-button--light tag__btn margin-r-10"
|
||||
:disabled="disableEdit"
|
||||
@click="editTag">
|
||||
@click="editEntity">
|
||||
<i class="cn-icon-edit cn-icon"></i>
|
||||
<span>{{ $t('overall.edit') }}</span>
|
||||
</button>
|
||||
@@ -202,7 +202,7 @@ export default {
|
||||
}).catch(() => {})
|
||||
}
|
||||
},
|
||||
editTag () {
|
||||
editEntity () {
|
||||
if (this.batchDeleteObjs.length === 0) {
|
||||
this.$alert(this.$t('tip.pleaseSelectForEdit'), {
|
||||
confirmButtonText: this.$t('tip.yes'),
|
||||
|
||||
@@ -21,12 +21,13 @@
|
||||
<div class="form-collapse-content">
|
||||
<el-form ref="sourceForm" :model="editObj" label-position="top" :rules="sourceRules">
|
||||
<el-form-item :label="$t('setting.source')" prop="sourceId" class="form-setting__block margin-b-20">
|
||||
<el-select v-model="editObj.sourceId" class="form-setting__select" placeholder=" ">
|
||||
<el-select v-model="editObj.sourceId" class="form-setting__select" placeholder="" @change="onChangeSource" @visible-change="visibleSource($event)">
|
||||
<el-option
|
||||
v-for="item in sourceOption"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
:disabled="item.disabled"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -38,16 +39,19 @@
|
||||
<div class="form-content__block" v-for="(item, index) in editObj.schemaMappingData.data" :key="index">
|
||||
<div class="block-header">
|
||||
<div>{{ item.name }}</div>
|
||||
<div>{{ $t('setting.source') }}</div>
|
||||
<div class="block-header__menu">
|
||||
<div>{{ $t('setting.sourceField') }}</div>
|
||||
<div>{{ $t('setting.entityField') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="block-body" v-for="(ite, ind) in item.list" :key="index+'-'+ind">
|
||||
<el-form-item :prop="`data.${index}.list.${ind}.field`" :rules="mappingRules.type">
|
||||
<el-select v-model="ite.field" class="block-body__select" placeholder="">
|
||||
<el-option
|
||||
v-for="obj in mappingFieldOption"
|
||||
:key="obj.value"
|
||||
:label="obj.label"
|
||||
:value="obj.value"
|
||||
:key="obj.name"
|
||||
:label="obj.name"
|
||||
:value="obj.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -55,15 +59,16 @@
|
||||
<el-form-item :prop="`data.${index}.list.${ind}.source`" :rules="mappingRules.source">
|
||||
<el-select v-model="ite.source" class="block-body__select" placeholder="">
|
||||
<el-option
|
||||
v-for="obj in mappingSourceOption"
|
||||
:key="obj.value"
|
||||
:label="obj.label"
|
||||
:value="obj.value"
|
||||
v-for="obj in settingFields[item.type]"
|
||||
:key="obj.fieldName"
|
||||
:label="obj.fieldName"
|
||||
:value="obj.fieldName"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<i class="cn-icon cn-icon-add mapping-item-add" @click="addMappingListItem(index, ind)"></i>
|
||||
<i class="cn-icon cn-icon-close mapping-item-close" v-if="isCloseMappingItem" @click="deleteMappingItem(index, ind)"></i>
|
||||
<i class="cn-icon cn-icon-close mapping-item-close" @click="deleteMappingItem(index, ind)"></i>
|
||||
<!-- <i class="cn-icon cn-icon-close mapping-item-close" v-if="isCloseMappingItem" @click="deleteMappingItem(index, ind)"></i>-->
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
@@ -111,36 +116,39 @@
|
||||
<div class="form-collapse-content">
|
||||
<el-form :model="editObj.relationData" ref="relationForm">
|
||||
<div class="form-content__block">
|
||||
<div class="block-body" v-for="(item, index) in editObj.relationData.data" :key="index">
|
||||
<div class="block-body1" v-for="(item, index) in editObj.relationData.data" :key="index">
|
||||
<el-form-item :prop="`data.${index}.from_entity_index`" :rules="relationRules">
|
||||
<el-select
|
||||
v-model="item.from_entity_index"
|
||||
:disabled="item.fromDisabled"
|
||||
:class="item.fromDisabled ? 'relation-field__select-disabled' : 'relation-field__select'"
|
||||
class="relation-field__select"
|
||||
placeholder=""
|
||||
@visible-change="visibleFromEntity(index)"
|
||||
@visible-change="visibleFromEntity($event, index)"
|
||||
@change="changeFromEntity(index)">
|
||||
<el-option
|
||||
v-for="obj in editObj.schemaMappingData.data"
|
||||
:key="obj.index"
|
||||
:label="obj.name"
|
||||
:value="obj.index"
|
||||
:disabled="obj.disabled"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="block-body-equal">=</div>
|
||||
<div class="block-body-equal">
|
||||
<i class="cn-icon cn-icon-mutual"></i>
|
||||
</div>
|
||||
<el-form-item :prop="`data.${index}.to_entity_index`" :rules="relationRules">
|
||||
<el-select
|
||||
v-model="item.to_entity_index"
|
||||
:disabled="item.toDisabled"
|
||||
:class="item.toDisabled ? 'relation-field__select-disabled' : 'relation-field__select'"
|
||||
class="relation-field__select"
|
||||
placeholder=""
|
||||
@visible-change="visibleToEntity($event, index)"
|
||||
@change="changeToEntity(index)">
|
||||
<el-option
|
||||
v-for="obj in editObj.schemaMappingData.data"
|
||||
:key="obj.index"
|
||||
:label="obj.name"
|
||||
:value="obj.index"
|
||||
:disabled="obj.disabled"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -174,10 +182,10 @@
|
||||
<div class="switch__block margin-20">
|
||||
<div class="block-title">{{ $t('overall.status') }}</div>
|
||||
<el-switch
|
||||
v-model="editObj.enable"
|
||||
v-model="editObj.is_valid"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
:active-text="$t(switchStatus(editObj.enable))"/>
|
||||
:active-text="$t(switchStatus(editObj.is_valid))"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -201,6 +209,7 @@ import { ref } from 'vue'
|
||||
import Loading from '@/components/common/Loading'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { toUpperCaseByString, switchStatus } from '@/utils/tools'
|
||||
import { settingFields } from '@/utils/constants'
|
||||
|
||||
export default {
|
||||
name: 'EntitySettingForm',
|
||||
@@ -217,11 +226,7 @@ export default {
|
||||
},
|
||||
relationRules: { required: true, message: this.$t('validate.required'), trigger: 'change' },
|
||||
sourceOption: [],
|
||||
mappingFieldOption: [
|
||||
{ value: 'IP_address', label: 'IP_address' },
|
||||
{ value: 'Port', label: 'Port' },
|
||||
{ value: 'ASN', label: 'ASN' }
|
||||
],
|
||||
mappingFieldOption: [],
|
||||
mappingSourceOption: [
|
||||
{ value: 'dns_server_role', label: 'dns_server_role' },
|
||||
{ value: 'ip_addr', label: 'ip_addr' },
|
||||
@@ -232,7 +237,7 @@ export default {
|
||||
{ label: 'Domain', value: 'Domain' },
|
||||
{ label: 'APP', value: 'APP' }
|
||||
],
|
||||
isCloseMappingItem: false, // 删除mapping标识
|
||||
isCloseMappingItem: true, // 删除mapping标识
|
||||
showMappingType: false,
|
||||
mappingItemType: '', // 添加mapping映射类型
|
||||
typeList: [
|
||||
@@ -248,7 +253,8 @@ export default {
|
||||
{ value: 'CARRY_APP_DOMAIN', label: 'CARRY_APP_DOMAIN' },
|
||||
{ value: 'VISIT_SUBSCRIBER_APP', label: 'VISIT_SUBSCRIBER_APP' },
|
||||
{ value: 'CALL_SUBSCRIBER_SUBSCRIBER', label: 'CALL_SUBSCRIBER_SUBSCRIBER' }
|
||||
]
|
||||
],
|
||||
settingFields
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@@ -289,7 +295,7 @@ export default {
|
||||
relationData: {
|
||||
data: [{ from_entity_index: '', to_entity_index: '', type: '', fromDisabled: false, toDisabled: false }]
|
||||
},
|
||||
enable: 1
|
||||
is_valid: 1
|
||||
})
|
||||
|
||||
return {
|
||||
@@ -432,34 +438,64 @@ export default {
|
||||
},
|
||||
/** 删除mapping下的子项 **/
|
||||
deleteMappingItem (index, ind) {
|
||||
const type = this.editObj.schemaMappingData.data[index].type
|
||||
if (this.editObj.schemaMappingData.data[index].list.length > 1) {
|
||||
this.editObj.schemaMappingData.data[index].list.splice(ind, 1)
|
||||
const currentIndex = this.editObj.schemaMappingData.data[index].index
|
||||
const obj = this.editObj.relationData.data.find(d => d.from_entity_index === currentIndex || d.to_entity_index === currentIndex)
|
||||
if (obj) {
|
||||
const name = this.editObj.schemaMappingData.data[index].name
|
||||
ElMessageBox.alert(`${name} ${this.$t('setting.deleteMappingTip')}`, this.$t('overall.tip'), {
|
||||
confirmButtonText: 'OK',
|
||||
callback: () => {}
|
||||
})
|
||||
} else {
|
||||
this.editObj.schemaMappingData.data.splice(index, 1)
|
||||
}
|
||||
|
||||
this.editObj.schemaMappingData.data.forEach((item, index) => {
|
||||
item.index = index + 1
|
||||
})
|
||||
|
||||
// 删除同类型的,name需要重新排序
|
||||
const list = this.editObj.schemaMappingData.data.filter(d => d.type === type)
|
||||
if (list && list.length > 0) {
|
||||
if (list.length === 1) {
|
||||
list[0].name = this.handleMappingName(list[0].type)
|
||||
const type = this.editObj.schemaMappingData.data[index].type
|
||||
if (this.editObj.schemaMappingData.data[index].list.length > 1) {
|
||||
this.editObj.schemaMappingData.data[index].list.splice(ind, 1)
|
||||
} else {
|
||||
list.forEach((item, i) => {
|
||||
item.name = this.handleMappingName(item.type, i)
|
||||
this.editObj.schemaMappingData.data.splice(index, 1)
|
||||
}
|
||||
|
||||
this.editObj.schemaMappingData.data.forEach((item, index) => {
|
||||
item.index = index + 1
|
||||
})
|
||||
|
||||
// 删除同类型的,name需要重新排序
|
||||
const list = this.editObj.schemaMappingData.data.filter(d => d.type === type)
|
||||
if (list && list.length > 0) {
|
||||
if (list.length === 1) {
|
||||
list[0].name = this.handleMappingName(list[0].type)
|
||||
} else {
|
||||
list.forEach((item, i) => {
|
||||
item.name = this.handleMappingName(item.type, i)
|
||||
})
|
||||
}
|
||||
}
|
||||
// if (this.editObj.schemaMappingData.data.length > 1) {
|
||||
// this.isCloseMappingItem = true
|
||||
// } else {
|
||||
// this.isCloseMappingItem = this.editObj.schemaMappingData.data[0].list.length > 1
|
||||
// }
|
||||
let usedFlag = false
|
||||
if (this.editObj.schemaMappingData.data.length > 0) {
|
||||
this.editObj.schemaMappingData.data.forEach(item => {
|
||||
const obj1 = item.list.find(d => d.field)
|
||||
if (obj1 && !usedFlag) {
|
||||
usedFlag = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
usedFlag = false
|
||||
}
|
||||
|
||||
if (usedFlag && this.editObj.sourceId) {
|
||||
this.sourceOption.forEach(item => {
|
||||
item.disabled = item.id !== this.editObj.sourceId
|
||||
})
|
||||
} else if (!usedFlag) {
|
||||
this.sourceOption.forEach(item => {
|
||||
item.disabled = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (this.editObj.schemaMappingData.data.length > 1) {
|
||||
this.isCloseMappingItem = true
|
||||
} else {
|
||||
this.isCloseMappingItem = this.editObj.schemaMappingData.data[0].list.length > 1
|
||||
}
|
||||
},
|
||||
/** 删除relation的子项 **/
|
||||
deleteRelationItem (index) {
|
||||
@@ -475,7 +511,69 @@ export default {
|
||||
}
|
||||
return name
|
||||
},
|
||||
visibleFromEntity (index) {
|
||||
/** relation第一个下拉框出现时的操作 */
|
||||
visibleFromEntity (callback, index) {
|
||||
if (callback) {
|
||||
// true出现下拉框,false隐藏下拉框
|
||||
const item = this.editObj.relationData.data[index]
|
||||
if (!item.from_entity_index && !item.to_entity_index) {
|
||||
// from和to都为空的话,不禁选
|
||||
this.editObj.schemaMappingData.data.forEach(ite => {
|
||||
ite.disabled = false
|
||||
})
|
||||
} else if (item.to_entity_index) {
|
||||
// to已经选择,则禁选to本身的index和to相关联的index
|
||||
const obj = this.editObj.schemaMappingData.data.find(d => d.index === item.to_entity_index)
|
||||
obj.disabled = true
|
||||
const filterList = this.editObj.relationData.data.filter(d => d.from_entity_index === item.to_entity_index || d.to_entity_index === item.to_entity_index)
|
||||
filterList.forEach(ite => {
|
||||
const obj1 = this.editObj.schemaMappingData.data.find(d => d.index === ite.to_entity_index)
|
||||
const obj2 = this.editObj.schemaMappingData.data.find(d => d.index === ite.from_entity_index)
|
||||
if (obj1) {
|
||||
obj1.disabled = true
|
||||
}
|
||||
if (obj2) {
|
||||
obj2.disabled = true
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.editObj.schemaMappingData.data.forEach(ite => {
|
||||
ite.disabled = false
|
||||
})
|
||||
}
|
||||
},
|
||||
/** relation第二个下拉框出现时的操作 */
|
||||
visibleToEntity (callback, index) {
|
||||
if (callback) {
|
||||
// true出现下拉框,false隐藏下拉框
|
||||
const item = this.editObj.relationData.data[index]
|
||||
if (!item.from_entity_index && !item.to_entity_index) {
|
||||
// from和to都为空的话,不禁选
|
||||
this.editObj.schemaMappingData.data.forEach(ite => {
|
||||
ite.disabled = false
|
||||
})
|
||||
} else if (item.from_entity_index) {
|
||||
// from已经选择,则禁选from本身的index和from相关联的index
|
||||
const obj = this.editObj.schemaMappingData.data.find(d => d.index === item.from_entity_index)
|
||||
obj.disabled = true
|
||||
const filterList = this.editObj.relationData.data.filter(d => d.from_entity_index === item.from_entity_index || d.to_entity_index === item.from_entity_index)
|
||||
filterList.forEach(ite => {
|
||||
const obj1 = this.editObj.schemaMappingData.data.find(d => d.index === ite.from_entity_index)
|
||||
const obj2 = this.editObj.schemaMappingData.data.find(d => d.index === ite.to_entity_index)
|
||||
if (obj1) {
|
||||
obj1.disabled = true
|
||||
}
|
||||
if (obj2) {
|
||||
obj2.disabled = true
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.editObj.schemaMappingData.data.forEach(ite => {
|
||||
ite.disabled = false
|
||||
})
|
||||
}
|
||||
},
|
||||
changeFromEntity (index) {
|
||||
this.editObj.relationData.data[index].fromDisabled = true
|
||||
@@ -483,12 +581,6 @@ export default {
|
||||
changeToEntity (index) {
|
||||
this.editObj.relationData.data[index].toDisabled = true
|
||||
},
|
||||
handleToEntityData (index) {
|
||||
if (index && index >= 0) {
|
||||
// const obj = this.editObj.relationData.data[index]
|
||||
}
|
||||
return this.editObj.schemaMappingData.data
|
||||
},
|
||||
/** 获取Rule Definition折叠板form数据 */
|
||||
getRuleObj (data) {
|
||||
if (data.dataSource && data.knowledgeId && data.level) {
|
||||
@@ -592,6 +684,7 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
/** 底部返回按钮 */
|
||||
cancel () {
|
||||
const { query } = this.$route
|
||||
const queryInfo = {
|
||||
@@ -628,6 +721,51 @@ export default {
|
||||
})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
/** 切换source数据源 */
|
||||
onChangeSource (id) {
|
||||
const obj = this.sourceOption.find(d => d.id === id)
|
||||
if (obj) {
|
||||
const fieldList = obj.fieldsList
|
||||
const myLookupsList = []
|
||||
obj.lookupsList.forEach(item => {
|
||||
myLookupsList.push({ name: item.output_field })
|
||||
})
|
||||
this.mappingFieldOption = fieldList.concat(myLookupsList)
|
||||
} else {
|
||||
this.mappingFieldOption = []
|
||||
}
|
||||
},
|
||||
visibleSource (callback) {
|
||||
if (callback) {
|
||||
// 如果relation中有数据,则禁选source
|
||||
const obj = this.editObj.relationData.data.find(d => d.from_entity_index || d.to_entity_index)
|
||||
if (obj && this.editObj.sourceId) {
|
||||
this.sourceOption.forEach(item => {
|
||||
item.disabled = item.id !== this.editObj.sourceId
|
||||
})
|
||||
}
|
||||
let usedFlag = false
|
||||
if (this.editObj.schemaMappingData.data.length > 0) {
|
||||
this.editObj.schemaMappingData.data.forEach(item => {
|
||||
const obj1 = item.list.find(d => d.field)
|
||||
if (obj1 && !usedFlag) {
|
||||
usedFlag = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
usedFlag = false
|
||||
}
|
||||
if (usedFlag && this.editObj.sourceId) {
|
||||
this.sourceOption.forEach(item => {
|
||||
item.disabled = item.id !== this.editObj.sourceId
|
||||
})
|
||||
} else if (!usedFlag) {
|
||||
this.sourceOption.forEach(item => {
|
||||
item.disabled = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</button>
|
||||
<button id="tag-edit" class="business-button business-button--light tag__btn margin-r-10"
|
||||
:disabled="disableEdit"
|
||||
@click="editTag">
|
||||
@click="editSource">
|
||||
<i class="cn-icon-edit cn-icon"></i>
|
||||
<span>{{ $t('overall.edit') }}</span>
|
||||
</button>
|
||||
@@ -38,7 +38,7 @@
|
||||
:custom-table-title="tools.customTableTitle"
|
||||
:height="mainTableHeight"
|
||||
:table-data="tableData"
|
||||
@delete="delItem"
|
||||
@delete="del"
|
||||
@edit="edit"
|
||||
@download="download"
|
||||
@preview="preview"
|
||||
@@ -209,7 +209,7 @@ export default {
|
||||
this.object = u
|
||||
this.rightBox.show = true
|
||||
},
|
||||
editTag () {
|
||||
editSource () {
|
||||
if (this.batchDeleteObjs.length === 0) {
|
||||
this.$alert(this.$t('tip.pleaseSelectForEdit'), {
|
||||
confirmButtonText: this.$t('tip.yes'),
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<el-input :ref="`default-${index}`" v-model="item.default" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<i class="cn-icon cn-icon-close remove-btn" v-if="sourceObj.fieldsData.data.length > 1" @click="removeFieldItem(index)"></i>
|
||||
<i class="cn-icon cn-icon-close remove-btn" @click="removeFieldItem(index)"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
<el-input v-model="item.output_field" :placeholder="$t('setting.outputFieldName')" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<i class="cn-icon cn-icon-close remove-btn" v-if="sourceObj.lookupsData.data.length > 1" @click="removeLookupItem(index)"></i>
|
||||
<i class="cn-icon cn-icon-close remove-btn" @click="removeLookupItem(index)"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -142,10 +142,10 @@
|
||||
<div class="form-setting__block margin-b-20">
|
||||
<div class="block-title">{{ $t('overall.status') }}</div>
|
||||
<el-switch
|
||||
v-model="sourceObj.enable"
|
||||
v-model="sourceObj.is_valid"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
:active-text="$t(switchStatus(sourceObj.enable))"/>
|
||||
:active-text="$t(switchStatus(sourceObj.is_valid))"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -324,9 +324,16 @@ export default {
|
||||
return valid
|
||||
})
|
||||
if (valid1 && valid2 && valid3) {
|
||||
this.myLoading = true
|
||||
this.sourceObj.fields = JSON.stringify(this.sourceObj.fieldsData.data)
|
||||
this.sourceObj.lookups = JSON.stringify(this.sourceObj.lookupsData.data)
|
||||
if (this.sourceObj.fieldsData.data.length === 0 && this.sourceObj.lookupsData.data.length === 0) {
|
||||
ElMessageBox.alert(`${this.$t('detection.create.informationFilled')}`, this.$t('overall.tip'), {
|
||||
confirmButtonText: 'OK',
|
||||
callback: () => {}
|
||||
})
|
||||
return true
|
||||
}
|
||||
this.myLoading = true
|
||||
if (!this.sourceId) {
|
||||
// post调用是新增,put是编辑
|
||||
axios.post(api.setting.source.source, this.sourceObj).then(response => {
|
||||
@@ -432,8 +439,18 @@ export default {
|
||||
})
|
||||
},
|
||||
removeFieldItem (i) {
|
||||
this.addEditFlag = false
|
||||
this.sourceObj.fieldsData.data.splice(i, 1)
|
||||
// 如果lookups里存在filed的字段,则进行提示
|
||||
const name = this.sourceObj.fieldsData.data[i].name
|
||||
const obj = this.sourceObj.lookupsData.data.find(d => d.lookup_field === name && name)
|
||||
if (obj) {
|
||||
ElMessageBox.alert(`${name} ${this.$t('setting.deleteFieldTip')}`, this.$t('overall.tip'), {
|
||||
confirmButtonText: 'OK',
|
||||
callback: () => {}
|
||||
})
|
||||
} else {
|
||||
this.addEditFlag = false
|
||||
this.sourceObj.fieldsData.data.splice(i, 1)
|
||||
}
|
||||
},
|
||||
removeLookupItem (i) {
|
||||
this.addEditFlag = false
|
||||
@@ -465,7 +482,7 @@ export default {
|
||||
data: [{ function: '', lookup_field: '', output_type: '', output_field: '' }]
|
||||
},
|
||||
description: '',
|
||||
enable: 1
|
||||
is_valid: 1
|
||||
}
|
||||
const sourceObj = ref(_.cloneDeep(blankObject))
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user