|
@@ -1,17 +1,19 @@
|
|
|
-import { getRoleList } from "@/api/system";
|
|
|
-import { type PaginationProps } from "@pureadmin/table";
|
|
|
-import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
-import { reactive, ref, computed, onMounted } from "vue";
|
|
|
-// 获取URLLIST
|
|
|
-import { getGroupUrl } from "@/utils/getUrl/getUrl"
|
|
|
-import { http } from "@/utils/http";
|
|
|
-// 获取当前板块接口列表
|
|
|
-const UrlList = await getGroupUrl(['kxsConfigServer']);
|
|
|
-
|
|
|
+import { reactive, onMounted, ref, ElMessage, ElMessageBox, http, getGroupUrl, RegularVerification, verification, PaginationProps } from "@/utils/importUsed"
|
|
|
+// 表单实例
|
|
|
+const ruleFormRef = ref()
|
|
|
export function useApiInfo() {
|
|
|
+ // 接口列表实例
|
|
|
+ let UrlList = reactive(null)
|
|
|
+ // 获取当前板块接口列表
|
|
|
+ onMounted(async () => {
|
|
|
+ UrlList = await getGroupUrl(["kxsConfigServer"]);
|
|
|
+ onSearch(ruleFormRef.value);
|
|
|
+ groupIdQuery();
|
|
|
+
|
|
|
+ });
|
|
|
let form = reactive({
|
|
|
- groupId: 0, //分组
|
|
|
- apiName: "", //接口名称
|
|
|
+ groupId:"", //分组
|
|
|
+ apiName:"", //接口名称
|
|
|
|
|
|
});
|
|
|
const dataList = ref([]);
|
|
@@ -36,18 +38,18 @@ export function useApiInfo() {
|
|
|
width: 70,
|
|
|
hide: ({ checkList }) => !checkList.includes("序号列")
|
|
|
},
|
|
|
- {
|
|
|
- label: "分组api接口分组",
|
|
|
+ {
|
|
|
+ label: "分组名称",
|
|
|
prop: "apiGroupInfo.groupName",
|
|
|
minWidth: 200
|
|
|
},
|
|
|
{
|
|
|
- label: "分组api接口分组",
|
|
|
+ label: "分组说明",
|
|
|
prop: "apiGroupInfo.groupRemark",
|
|
|
minWidth: 200
|
|
|
},
|
|
|
{
|
|
|
- label: "分组api接口分组",
|
|
|
+ label: "分组版本号",
|
|
|
prop: "apiGroupInfo.groupVersion",
|
|
|
minWidth: 200
|
|
|
},
|
|
@@ -60,59 +62,77 @@ export function useApiInfo() {
|
|
|
{
|
|
|
label: "操作",
|
|
|
fixed: "right",
|
|
|
- width: 200,
|
|
|
+ width: 120,
|
|
|
slot: "operation"
|
|
|
}
|
|
|
];
|
|
|
// 当前页数量切换
|
|
|
function handleSizeChange(val: number) {
|
|
|
- console.log(`${val} items per page`);
|
|
|
- onSearch()
|
|
|
+ if (typeof val === "number") {
|
|
|
+ pagination.pageSize = val;
|
|
|
+ onSearch(ruleFormRef.value);
|
|
|
+ }
|
|
|
}
|
|
|
// 当前页码切换
|
|
|
function handleCurrentChange(val: number) {
|
|
|
console.log(`current page: ${val}`);
|
|
|
- onSearch()
|
|
|
+ if (typeof val === "number") {
|
|
|
+ pagination.currentPage = val;
|
|
|
+ onSearch(ruleFormRef.value);
|
|
|
+ }
|
|
|
}
|
|
|
// 选择表格项
|
|
|
function handleSelectionChange(val) {
|
|
|
- console.log("handleSelectionChange", val);
|
|
|
- onSearch()
|
|
|
+ console.log(`SelectionChange: ${val}`);
|
|
|
+ onSearch(ruleFormRef.value);
|
|
|
}
|
|
|
// 搜索列表
|
|
|
- async function onSearch(type = 'search') {
|
|
|
- if (type === 'all') {
|
|
|
- form.groupId = 0;
|
|
|
- form.apiName = "";
|
|
|
-
|
|
|
- }
|
|
|
- // if (type == 'search' && !Object.values(form).some(item => !!item)) {
|
|
|
- // return ElMessage({
|
|
|
- // message: "请输入查询条件",
|
|
|
- // type: "error"
|
|
|
- // });
|
|
|
- // };
|
|
|
- loading.value = true;
|
|
|
- const { status, msg, data }: any = await http.Request({ method: UrlList.kxsConfigServer.apiInfolist.method, url: UrlList.kxsConfigServer.apiInfolist.url, params: { ...form, pageSize: pagination.pageSize, pageNum: pagination.currentPage } });
|
|
|
+ async function onSearch(formEl) {
|
|
|
+ // 表单校验拦截
|
|
|
+ if (!formEl) return
|
|
|
+ await formEl.validate(async (valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ //表单校验成功回调
|
|
|
+ console.log('submit!')
|
|
|
+ // 状态调整为加载中
|
|
|
+ loading.value = true;
|
|
|
+ // 调用接口(需动态生成接口)
|
|
|
+ const { status, msg, data }: any = await http.Request({
|
|
|
+ method: UrlList.kxsConfigServer.apiInfolist.method,
|
|
|
+ url: UrlList.kxsConfigServer.apiInfolist.url,
|
|
|
+ params: {
|
|
|
+ ...form,
|
|
|
+ pageSize: pagination.pageSize,
|
|
|
+ pageNum: pagination.currentPage
|
|
|
+ }
|
|
|
+ });
|
|
|
+ dataList.value = data.records;
|
|
|
+ pagination.total = data.total;
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.value = false;
|
|
|
+ }, 500);
|
|
|
+ } else {
|
|
|
+ //表单校验失败回调
|
|
|
+ ElMessage({
|
|
|
+ message: "请输入完整信息",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 分组选项数据
|
|
|
+ const groupIdOptionList = ref([]);
|
|
|
+ //获取分组数据
|
|
|
+ async function groupIdQuery() {
|
|
|
+ const { status, data }: any = await http.Request({ method: UrlList.kxsConfigServer.apiGroupselectList.method, url: UrlList.kxsConfigServer.apiGroupselectList.url, params: { } });
|
|
|
if (status === 1) {
|
|
|
- dataList.value = data.records;
|
|
|
- pagination.total = data.total;
|
|
|
- setTimeout(() => {
|
|
|
- loading.value = false;
|
|
|
- }, 500);
|
|
|
- } else {
|
|
|
- ElMessageBox.alert(msg, "提示", {
|
|
|
- confirmButtonText: "关闭",
|
|
|
- type: "warning"
|
|
|
- });
|
|
|
+ groupIdOptionList.value = data.records;
|
|
|
}
|
|
|
}
|
|
|
- onMounted(() => {
|
|
|
- onSearch();
|
|
|
- apiInfoquery();
|
|
|
- });
|
|
|
|
|
|
- // 删除
|
|
|
+
|
|
|
+
|
|
|
+ // 删除
|
|
|
function handleDelete(row) {
|
|
|
ElMessageBox.confirm(
|
|
|
`是否删除该api接口? `,
|
|
@@ -123,28 +143,36 @@ export function useApiInfo() {
|
|
|
type: "warning"
|
|
|
}
|
|
|
).then(async () => {
|
|
|
- const { status, msg }: any = await http.Request({ method: UrlList.kxsConfigServer.apiInfodelete.method, url: UrlList.kxsConfigServer.apiInfodelete.url, params: row.id });
|
|
|
+ const { status, msg }: any = await http.Request({ method: UrlList.kxsConfigServer.apiInfodelete.method, url: UrlList.kxsConfigServer.apiInfodelete.url, params: String(row.id) });
|
|
|
if (status === 1) {
|
|
|
ElMessage({
|
|
|
message: "删除成功",
|
|
|
type: "success"
|
|
|
});
|
|
|
- onSearch();
|
|
|
+ onSearch(ruleFormRef);
|
|
|
} else {
|
|
|
ElMessageBox.alert(msg, "提示", {
|
|
|
- confirmButtonText: "关闭",
|
|
|
- type: "warning"
|
|
|
- });
|
|
|
+ confirmButtonText: "关闭",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
};
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- // 新增
|
|
|
+ // 新增
|
|
|
const addVisible = ref(false);
|
|
|
function handleAdd() {
|
|
|
addVisible.value = true;
|
|
|
};
|
|
|
|
|
|
+ // 设置版本号
|
|
|
+ const editSetVersionVisible = ref(false);
|
|
|
+ const editSetVersionFormData = ref({});
|
|
|
+ function handleSetVersion(row) {
|
|
|
+ editSetVersionVisible.value = true;
|
|
|
+ // 表格数据赋值
|
|
|
+ editSetVersionFormData.value = row;
|
|
|
+ };
|
|
|
// 修改
|
|
|
const editUpdateVisible = ref(false);
|
|
|
const editUpdateFormData = ref({});
|
|
@@ -153,18 +181,13 @@ export function useApiInfo() {
|
|
|
// 表格数据赋值
|
|
|
editUpdateFormData.value = row;
|
|
|
};
|
|
|
-
|
|
|
- // 分组选项数据
|
|
|
- const groupIdOptionList = ref([])
|
|
|
-
|
|
|
- //获取分组数据
|
|
|
- async function apiInfoquery() {
|
|
|
- //通过ID获取表格数据
|
|
|
- const UrlList = await getGroupUrl(['kxsConfigServer']);
|
|
|
- const { status, data }: any = await http.Request({ method: UrlList.kxsConfigServer.apiGroupselectList.method, url: UrlList.kxsConfigServer.apiGroupselectList.url, params: {} });
|
|
|
- if (status === 1) {
|
|
|
- groupIdOptionList.value = data.records;
|
|
|
- }
|
|
|
+ // 设置请求地址
|
|
|
+ const editSetRouterVisible = ref(false);
|
|
|
+ const editSetRouterFormData = ref({});
|
|
|
+ function handleSetRouter(row) {
|
|
|
+ editSetRouterVisible.value = true;
|
|
|
+ // 表格数据赋值
|
|
|
+ editSetRouterFormData.value = row;
|
|
|
};
|
|
|
|
|
|
return {
|
|
@@ -177,13 +200,22 @@ export function useApiInfo() {
|
|
|
handleSizeChange,
|
|
|
handleCurrentChange,
|
|
|
handleSelectionChange,
|
|
|
+ ruleFormRef,
|
|
|
+ groupIdQuery,
|
|
|
+ groupIdOptionList,
|
|
|
+
|
|
|
handleAdd,
|
|
|
addVisible,
|
|
|
+ handleSetVersion,
|
|
|
+ editSetVersionVisible,
|
|
|
+ editSetVersionFormData,
|
|
|
+ handleDelete,
|
|
|
handleUpdate,
|
|
|
editUpdateVisible,
|
|
|
editUpdateFormData,
|
|
|
- handleDelete,
|
|
|
- groupIdOptionList
|
|
|
+ handleSetRouter,
|
|
|
+ editSetRouterVisible,
|
|
|
+ editSetRouterFormData,
|
|
|
|
|
|
};
|
|
|
}
|