Commit c9f37980 authored by 郭铭瑶's avatar 郭铭瑶 🤘

编辑标签

parent 6897f92d
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
class="tag" class="tag"
:class="{ :class="{
on: curTagKey === n.key, on: curTagKey === n.key,
'click-able': n.key.indexOf('Property') >= 0, 'click-able':
n.key.indexOf('Property') >= 0 || n.key === 'SubjectLabel',
}" }"
size="small" size="small"
round round
...@@ -67,6 +68,7 @@ export default { ...@@ -67,6 +68,7 @@ export default {
Property_manage: '#abd1c6', Property_manage: '#abd1c6',
Property_service: '#f9bc60', Property_service: '#f9bc60',
Property_use: '#d9d4e7', Property_use: '#d9d4e7',
SubjectLabel: '#dda52d',
} }
let instance = null let instance = null
const container = ref(null) const container = ref(null)
...@@ -202,6 +204,8 @@ export default { ...@@ -202,6 +204,8 @@ export default {
return '服务行为' return '服务行为'
case 'Property_use': case 'Property_use':
return '使用行为' return '使用行为'
case 'SubjectLabel':
return '标签'
default: default:
return '未知' return '未知'
} }
...@@ -273,7 +277,7 @@ export default { ...@@ -273,7 +277,7 @@ export default {
linkList.value = linkResult linkList.value = linkResult
} }
function onTagClick({ key }) { function onTagClick({ key }) {
if (key.indexOf('Property') < 0) return if (key.indexOf('Property') < 0 && key !== 'SubjectLabel') return
if (curTagKey.value === key) { if (curTagKey.value === key) {
curTagKey.value = null curTagKey.value = null
} else { } else {
......
...@@ -58,9 +58,9 @@ ...@@ -58,9 +58,9 @@
/> />
</n-form-item> </n-form-item>
<template v-if="getTagName(data.relationId) === '标签'"> <template v-if="getTagName(data.relationId) === '标签'">
<n-form-item label="标签名称" path="tag"> <n-form-item label="标签名称" path="labelName">
<n-select <n-select
v-model:value="data.tag" v-model:value="data.labelName"
placeholder="请选择" placeholder="请选择"
filterable filterable
tag tag
...@@ -232,6 +232,29 @@ ...@@ -232,6 +232,29 @@
/> />
</n-form-item> </n-form-item>
</template> </template>
<template v-else-if="curNode.nodeLabel === 'SubjectLabel'">
<n-form-item label="标签名称" path="labelName">
<n-select
v-model:value="editData.labelName"
placeholder="请选择"
filterable
tag
:options="tagOptions"
/>
</n-form-item>
<n-form-item label="标签分类" path="classification">
<n-select
v-model:value="editData.classification"
placeholder="请选择"
:options="tagClassOptions"
/>
</n-form-item>
<n-form-item path="isPositive" :show-label="false">
<n-checkbox v-model:checked="editData.isPositive"
>是否为积极的标签</n-checkbox
>
</n-form-item>
</template>
<n-space justify="end"> <n-space justify="end">
<n-button <n-button
:loading="isLoading" :loading="isLoading"
...@@ -316,7 +339,7 @@ function fetchTags() { ...@@ -316,7 +339,7 @@ function fetchTags() {
tagOptions.value = data.map((e) => ({ tagOptions.value = data.map((e) => ({
// TODO // TODO
label: e.labelName, label: e.labelName,
value: e.id, value: e.id + '',
})) }))
}) })
} }
...@@ -402,6 +425,7 @@ function getTagName(relationId) { ...@@ -402,6 +425,7 @@ function getTagName(relationId) {
function submitNewNode(e) { function submitNewNode(e) {
e.preventDefault() e.preventDefault()
console.log(formData.value)
formRef.value.validate(async (errors) => { formRef.value.validate(async (errors) => {
if (!errors) { if (!errors) {
isLoading.value = true isLoading.value = true
...@@ -442,13 +466,14 @@ function submitNewNode(e) { ...@@ -442,13 +466,14 @@ function submitNewNode(e) {
relationId: tagData[0].relationId, relationId: tagData[0].relationId,
labelList: tagData.map((item) => { labelList: tagData.map((item) => {
let obj = { let obj = {
id: null, labelName: item.labelName,
labelName: item.tag,
} }
if (tagOptions.value.findIndex((e) => e.value == item.tag) >= 0) { const curTag = tagOptions.value.find(
(e) => e.value == item.labelName
)
if (curTag) {
obj = { obj = {
id: item.tag, id: curTag.id,
labelName: null,
} }
} }
return { return {
...@@ -652,7 +677,7 @@ const rules = { ...@@ -652,7 +677,7 @@ const rules = {
trigger: ['change', 'blur'], trigger: ['change', 'blur'],
}, },
], ],
tag: [ labelName: [
{ {
required: true, required: true,
message: '请选择标签名称', message: '请选择标签名称',
...@@ -749,6 +774,22 @@ function editNode(e) { ...@@ -749,6 +774,22 @@ function editNode(e) {
params = { params = {
propertyName: editData.value.propertyName, propertyName: editData.value.propertyName,
} }
} else if (nodeLabel === 'SubjectLabel') {
const { labelName } = editData.value
let obj = {
labelName,
}
const curTag = tagOptions.value.find((e) => e.value == labelName)
if (curTag) {
obj = {
id: curTag.id,
}
}
params = {
classification: editData.value.classification,
isPositive: editData.value.isPositive,
...obj,
}
} }
ajax ajax
.put({ .put({
......
...@@ -245,7 +245,12 @@ export default class RelationGraph { ...@@ -245,7 +245,12 @@ export default class RelationGraph {
.attr('fill', '#000') .attr('fill', '#000')
.style('font-size', 12) .style('font-size', 12)
.style('font-weight', 'normal') .style('font-weight', 'normal')
.text((d) => d[d.nodeLabel.toLowerCase() + 'Name']) .text((d) => {
if (d.nodeLabel === 'SubjectLabel') {
return d.labelName
}
return d[d.nodeLabel.toLowerCase() + 'Name']
})
} }
initLinks() { initLinks() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment