Commit 4d35e7f3 authored by 郭铭瑶's avatar 郭铭瑶 🤘

所有获取数据判断非空

parent af9f585f
......@@ -304,7 +304,8 @@ function fetchSubjects() {
})
.then((res) => {
console.log('subject', res.data.content)
const [{ links, nodes }] = res.data.content
const { links = [], nodes = [] } =
res.data && res.data.content && res.data.content[0]
subjectOptions.value = nodes.map((item) => ({
label: item.subjectName,
value: item.nodeId,
......@@ -325,7 +326,7 @@ function fetchTags() {
url: api.GET_TAG_CLASS,
})
.then((res) => {
const data = res.data.content
const data = (res.data && res.data.content) || []
tagClassOptions.value = data.map((e) => ({
label: e.classification,
value: e.classification,
......@@ -342,7 +343,6 @@ function fetchTags() {
label: e.labelName,
value: e.nodeId + '',
}))
console.log(tagOptions.value)
})
}
fetchTags()
......@@ -353,8 +353,8 @@ function getSelectOptions() {
url: api.GET_RELATIONS,
})
.then((res) => {
if (!res.data || !res.data.content) return
relationOptions.value = res.data.content.map((item) => ({
const data = (res.data && res.data.content) || []
relationOptions.value = data.map((item) => ({
label: item.relationName,
value: item.id + '',
}))
......@@ -364,8 +364,8 @@ function getSelectOptions() {
url: api.GET_SYSTEMS,
})
.then((res) => {
if (!res.data || !res.data.content) return
systemOptions.value = res.data.content.map((item) => ({
const data = (res.data && res.data.content) || []
systemOptions.value = data.map((item) => ({
label: item.systemName,
value: item.nodeId + '',
}))
......@@ -383,7 +383,7 @@ function fetchSubordinates(params = null) {
},
})
.then((res) => {
const { links, nodes } = res.data.content
const { links = [], nodes = [] } = res.data && res.data.content
graphData.value = {
nodes: [
...graphData.value.nodes,
......@@ -442,7 +442,6 @@ function selectTag(nodeId, i) {
function submitNewNode(e) {
e.preventDefault()
console.log(formData.value)
formRef.value.validate(async (errors) => {
if (!errors) {
isLoading.value = true
......@@ -625,7 +624,10 @@ const searchNodes = (type, key) => {
params,
})
.then((res) => {
graphData.value = res.data.content
graphData.value = (res.data && res.data.content) || {
links: [],
nodes: [],
}
})
}
......
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