feat(resource): 对接急救宣教资源管理 V3 接口

- 审批与上架分离:已通过状态显示「已通过」+「上架」操作
- 分类扁平化:分类表单去掉父级分类字段
- 标签从分类 tags 字段联动取,不再调独立标签接口
- 标签表单加所属分类必填,支持从分类「+标签」按钮预设锁定
- 审核记录字段对齐后端:resourceTitle/auditRejectReason
- 资源表单 footer 隐藏默认按钮,写操作 API 关全局提示避免重复弹
This commit is contained in:
wanghao
2026-06-25 10:30:22 +08:00
parent c01fd0741d
commit 9c6680146f
8 changed files with 99 additions and 69 deletions
+25 -17
View File
@@ -29,7 +29,7 @@
<a-tag v-if="status === 2" color="red" style="margin-left: 4px">冻结</a-tag>
<span class="tree-actions">
<a-button type="link" size="small" @click.stop="handleEditCategory({ id, name })"></a-button>
<a-button type="link" size="small" @click.stop="handleAddSubCategory(id)">+</a-button>
<a-button type="link" size="small" @click.stop="handleAddTagUnderCategory(id)">+标签</a-button>
<a-button type="link" size="small" danger @click.stop="handleDeleteCategory({ id, name })"></a-button>
</span>
</div>
@@ -93,7 +93,7 @@
<!-- 分类新增/编辑弹窗 -->
<CategoryFormModal @register="registerCategoryModal" @success="loadCategoryTree" />
<!-- 标签新增/编辑弹窗 -->
<TagFormModal @register="registerTagModal" @success="loadTags" />
<TagFormModal @register="registerTagModal" @success="loadCategoryTree" />
</div>
</template>
@@ -105,7 +105,6 @@
import {
categoryListAllApi,
categoryDeleteApi,
tagListAllApi,
tagDeleteApi,
buildTree,
} from './label.api';
@@ -144,9 +143,13 @@
const categoryTreeSelectData = computed(() => categoryTree.value);
function onSelectCategory(keys: string[], info: any) {
function onSelectCategory(keys: string[]) {
// V3:标签数据从分类的 tags 字段取,不再单独调接口
if (keys.length > 0) {
createMessage.info(`已选中分类:${info.node.name}`);
const category = categoryList.value.find((c) => c.id === keys[0]);
tagList.value = category?.tags || [];
} else {
tagList.value = [];
}
}
@@ -155,9 +158,15 @@
}
function handleAddSubCategory(parentId: string) {
// V3:分类扁平化,此函数已废弃,保留以防其他地方调用
openCategoryModal(true, { isUpdate: false, parentId });
}
// V3:分类项后面的「+标签」按钮,新增该分类下的标签
function handleAddTagUnderCategory(parentId: string) {
openTagModal(true, { isUpdate: false, parentId });
}
function handleEditCategory(record: any) {
openCategoryModal(true, { isUpdate: true, record });
}
@@ -195,7 +204,7 @@
function handleDeleteTag(tag: any) {
tagDeleteApi({ id: tag.id }, () => {
createMessage.success('已删除标签');
loadTags();
loadCategoryTree();
});
}
@@ -255,24 +264,23 @@
if (expandedKeys.value.length === 0 && categoryTree.value.length > 0) {
expandedKeys.value = [categoryTree.value[0].id];
}
// V3:默认选中第一个分类,标签从分类的 tags 字段取
if (selectedKeys.value.length === 0 && categoryList.value.length > 0) {
const first = categoryList.value[0];
selectedKeys.value = [first.id];
tagList.value = first?.tags || [];
} else if (selectedKeys.value.length > 0) {
// 已选中分类,重新拉数据后刷新该分类的标签(新增/编辑/删除标签后回显最新数据)
const selected = categoryList.value.find((c) => c.id === selectedKeys.value[0]);
tagList.value = selected?.tags || [];
}
} finally {
categoryLoading.value = false;
}
}
async function loadTags() {
tagLoading.value = true;
try {
const res = await tagListAllApi();
tagList.value = res || [];
} finally {
tagLoading.value = false;
}
}
onMounted(() => {
loadCategoryTree();
loadTags();
});
</script>