This commit is contained in:
六如
2024-11-27 10:08:24 +08:00
parent 5e2c3fab46
commit 85b33e7c3d
36 changed files with 837 additions and 419 deletions

View File

@@ -4,6 +4,7 @@ import type { Result } from "@/model";
// 后端请求接口
const apiUrl: any = createUrl({
addApp: "/doc/app/add",
syncDoc: "/doc/app/syncDoc",
listApp: "/doc/app/list",
listDocTree: "/doc/info/tree",
publish: "/doc/info/publish"
@@ -31,6 +32,16 @@ export const api: any = {
addApp(data: object) {
return http.post<Result<any>, any>(apiUrl.addApp, { data });
},
/**
* 同步文档
* @param data 表单内容
*/
syncDoc(docAppId) {
const data = {
id: docAppId
};
return http.post<Result<any>, any>(apiUrl.syncDoc, { data });
},
/**
* 发布
* @param data 表单内容

View File

@@ -17,6 +17,7 @@ export const tabsData = ref<Array<any>>([
export const activeName = ref(0);
const docAppId = ref(0);
export const loading = ref(false);
// 表格对象
export const { tableData, buttons: actionButtons } = useTable<any[]>();
@@ -55,11 +56,15 @@ export const tableColumns: PlusColumn[] = [
},
{
label: "版本号",
prop: "docVersion"
prop: "docVersion",
width: 80
},
{
label: "描述",
prop: "description"
prop: "description",
tableColumnProps: {
showOverflowTooltip: true
}
},
{
label: "发布状态",
@@ -101,21 +106,17 @@ export const tableColumns: PlusColumn[] = [
// 表格按钮定义
actionButtons.value = [
{
text: row => (row.isPublish ? "下线" : "发布"),
text: "发布",
confirm: {
options: { draggable: false },
popconfirmProps: { width: 300 },
message: params => {
const row = params.row;
const opt = row.isPublish ? "下线" : "发布";
const isFolder = row.isFolder;
return isFolder === 1
? `确定要${opt}[${row.docTitle}]下所有接口吗?`
: `确定要${opt}[${row.docTitle}]吗?`;
return `确定要发布[${row.docTitle}]下所有接口吗?`;
}
},
props: (row: any) => ({
type: row.isPublish === 1 ? "danger" : "success"
props: (_: any) => ({
type: "success"
}),
onConfirm(params: ButtonsCallBackParams) {
const data = {
@@ -126,7 +127,8 @@ actionButtons.value = [
ElMessage.success("保存成功");
search();
});
}
},
show: (row: any) => row.isFolder === 1
},
{
text: "下线",
@@ -153,6 +155,32 @@ actionButtons.value = [
});
},
show: (row: any) => row.isFolder === 1
},
{
text: row => (row.isPublish ? "下线" : "发布"),
confirm: {
options: { draggable: false },
popconfirmProps: { width: 300 },
message: params => {
const row = params.row;
const opt = row.isPublish ? "下线" : "发布";
return `确定要${opt}[${row.docTitle}]吗?`;
}
},
props: (row: any) => ({
type: row.isPublish === 1 ? "danger" : "success"
}),
onConfirm(params: ButtonsCallBackParams) {
const data = {
id: params.row.id,
isPublish: params.row.isPublish === 1 ? 0 : 1
};
api.publish(data).then(() => {
ElMessage.success("保存成功");
search();
});
},
show: (row: any) => row.isFolder === 0
}
];
@@ -166,6 +194,28 @@ const search = async () => {
loadContent(docAppId.value);
};
export function handleSyncApi() {
ElMessageBox.confirm("确定要同步远程接口吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
loading.value = true;
api
.syncDoc(docAppId.value)
.then(() => {
loading.value = false;
ElMessage.success("同步成功");
search();
})
.catch(() => {
loading.value = false;
});
})
.catch(() => {});
}
export const handleClick = data => {
const id = data.props.name;
activeTab(id);

View File

@@ -3,17 +3,19 @@ import {
activeName,
handleClick,
handleAddApp,
handleSyncApi,
tabsData,
actionButtons,
tableColumns,
tableRows,
filterText,
loading,
handleSearch
} from "./index";
import { Search } from "@element-plus/icons-vue";
</script>
<template>
<el-card shadow="never">
<el-card v-loading="loading" shadow="never">
<div v-show="tabsData.length === 0">
<el-button type="primary" @click="handleAddApp">添加应用</el-button>
</div>
@@ -57,6 +59,9 @@ import { Search } from "@element-plus/icons-vue";
</template>
</el-input>
</template>
<template #toolbar>
<el-button type="primary" @click="handleSyncApi">同步接口</el-button>
</template>
</PlusTable>
</el-card>
</template>