Skip to content

Commit

Permalink
Merge pull request #1120 from Carlmac/fix-doc-import
Browse files Browse the repository at this point in the history
fix(import-doc): 修复资源 Yaml 文档匹配逻辑错误问题
  • Loading branch information
jinquantianxia authored Nov 21, 2024
2 parents 13911cd + cb04331 commit 58948fe
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/dashboard-front/src/views/resource/setting/import-doc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,21 @@
>
<template #default="{ data }">
<!-- 若是没匹配到资源,给出提示 -->
<template v-if="!data?.resource">
<span class="warning-c">{{ t('未匹配到资源') }}</span>
<!-- 若导入的是 zip -->
<template v-if="docType === 'archive'">
<span v-if="!data?.resource" class="warning-c">{{ t('未匹配到资源') }}</span>
<template v-else>
<span class="danger-c" v-if="!!data?.resource_doc">{{ t('覆盖') }}</span>
<span class="success-c" v-else>{{ t('新建') }}</span>
</template>
</template>
<!-- 若导入方式是自行编辑的 yaml -->
<template v-else>
<span class="danger-c" v-if="!!data?.resource_doc">{{ t('覆盖') }}</span>
<span class="success-c" v-else>{{ t('新建') }}</span>
<span v-if="!data?.id" class="warning-c">{{ t('未匹配到资源') }}</span>
<template v-else>
<span class="danger-c" v-if="hasExistedDoc(data)">{{ t('覆盖') }}</span>
<span class="success-c" v-else>{{ t('新建') }}</span>
</template>
</template>
</template>
</bk-table-column>
Expand Down Expand Up @@ -429,6 +438,14 @@ const handleHiddenExample = () => {
isShowExample.value = false;
};
const hasExistedDoc = (data?: { doc?: { id: number, language: string }[] }) => {
if (!data?.doc?.length) {
return false;
}
return data.doc.find(item => item.language === language.value)?.id;
};
</script>
<style scoped lang="scss">
.import-docs-container{
Expand Down

0 comments on commit 58948fe

Please sign in to comment.