Skip to content

Dev #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 15, 2025
Merged

Dev #107

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"@ant-design/icons": "^5.4.0",
"@ant-design/pro-components": "^2.8.7",
"@babel/standalone": "^7.25.6",
"@codingapi/flow-pc": "^0.0.24",
"@codingapi/form-pc": "^0.0.24",
"@codingapi/ui-framework": "^0.0.24",
"@codingapi/flow-pc": "^0.0.36",
"@codingapi/form-pc": "^0.0.36",
"@codingapi/ui-framework": "^0.0.36",
"@dnd-kit/core": "^6.2.0",
"@dnd-kit/sortable": "^9.0.0",
"@handsontable/react-wrapper": "^15.0.0",
Expand Down
6 changes: 3 additions & 3 deletions admin-ui/src/api/account.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {get, post} from "@/api/index";
import {httpClient} from "@/api/index";

export async function login(body: Account.LoginRequest) {
return post('/user/login', body);
return httpClient.post('/user/login', body);
}

export async function captcha() {
return get('/open/captcha');
return httpClient.get('/open/captcha');
}


Expand Down
52 changes: 26 additions & 26 deletions admin-ui/src/api/flow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {get, page, post} from "@/api/index";
import {httpClient} from "@/api/index";


// 流程设计
Expand All @@ -12,79 +12,79 @@ export async function list(
type: string
}[]
) {
return page('/api/query/flowWork/list', params, sort, filter, match);
return httpClient.page('/api/query/flowWork/list', params, sort, filter, match);
}


export async function save(body: any) {
return post('/api/cmd/flowWork/save', body);
return httpClient.post('/api/cmd/flowWork/save', body);
}

export async function copy(id: any) {
return post('/api/cmd/flowWork/copy', {id});
return httpClient.post('/api/cmd/flowWork/copy', {id});
}

export async function remove(id: any) {
return post('/api/cmd/flowWork/delete', {id});
return httpClient.post('/api/cmd/flowWork/delete', {id});
}

export async function changeState(id: any) {
return post('/api/cmd/flowWork/changeState', {id});
return httpClient.post('/api/cmd/flowWork/changeState', {id});
}

export async function schema(body: any) {
return post('/api/cmd/flowWork/schema', body);
return httpClient.post('/api/cmd/flowWork/schema', body);
}

// 流程控制

export async function startFlow(body:any) {
return post('/api/cmd/flowRecord/startFlow', body);
return httpClient.post('/api/cmd/flowRecord/startFlow', body);
}

export async function getFlowStep(body:any) {
return post('/api/cmd/flowRecord/getFlowStep', body);
return httpClient.post('/api/cmd/flowRecord/getFlowStep', body);
}

export async function removeFlow(body:any) {
return post('/api/cmd/flowRecord/remove', body);
return httpClient.post('/api/cmd/flowRecord/remove', body);
}


export async function detail(id?:any,workCode?:any) {
return get('/api/query/flowRecord/detail', {id,workCode});
return httpClient.get('/api/query/flowRecord/detail', {id,workCode});
}

export async function saveFlow(body:any) {
return post('/api/cmd/flowRecord/save', body);
return httpClient.post('/api/cmd/flowRecord/save', body);
}

export async function submitFlow(body:any) {
return post('/api/cmd/flowRecord/submitFlow', body);
return httpClient.post('/api/cmd/flowRecord/submitFlow', body);
}

export async function trySubmitFlow(body:any) {
return post('/api/cmd/flowRecord/trySubmitFlow', body);
return httpClient.post('/api/cmd/flowRecord/trySubmitFlow', body);
}

export async function custom(body:any) {
return post('/api/cmd/flowRecord/custom', body);
return httpClient.post('/api/cmd/flowRecord/custom', body);
}

export async function recall(body:any) {
return post('/api/cmd/flowRecord/recall', body);
return httpClient.post('/api/cmd/flowRecord/recall', body);
}

export async function postponed(body:any) {
return post('/api/cmd/flowRecord/postponed', body);
return httpClient.post('/api/cmd/flowRecord/postponed', body);
}

export async function transfer(body:any) {
return post('/api/cmd/flowRecord/transfer', body);
return httpClient.post('/api/cmd/flowRecord/transfer', body);
}

export async function urge(body:any) {
return post('/api/cmd/flowRecord/urge', body);
return httpClient.post('/api/cmd/flowRecord/urge', body);
}


Expand All @@ -97,7 +97,7 @@ export async function flowRecordList(params: any,
key: string,
type: string
}[]) {
return page('/api/query/flowRecord/list', params, sort, filter, match);
return httpClient.page('/api/query/flowRecord/list', params, sort, filter, match);
}


Expand All @@ -108,7 +108,7 @@ export async function findAllByOperatorId(params: any,
key: string,
type: string
}[]) {
return page('/api/query/flowRecord/findAllByOperatorId', params, sort, filter, match);
return httpClient.page('/api/query/flowRecord/findAllByOperatorId', params, sort, filter, match);
}


Expand All @@ -119,7 +119,7 @@ export async function findTodoByOperatorId(params: any,
key: string,
type: string
}[]) {
return page('/api/query/flowRecord/findTodoByOperatorId', params, sort, filter, match);
return httpClient.page('/api/query/flowRecord/findTodoByOperatorId', params, sort, filter, match);
}

export async function findDoneByOperatorId(params: any,
Expand All @@ -129,7 +129,7 @@ export async function findDoneByOperatorId(params: any,
key: string,
type: string
}[]) {
return page('/api/query/flowRecord/findDoneByOperatorId', params, sort, filter, match);
return httpClient.page('/api/query/flowRecord/findDoneByOperatorId', params, sort, filter, match);
}


Expand All @@ -140,7 +140,7 @@ export async function findInitiatedByOperatorId(params: any,
key: string,
type: string
}[]) {
return page('/api/query/flowRecord/findInitiatedByOperatorId', params, sort, filter, match);
return httpClient.page('/api/query/flowRecord/findInitiatedByOperatorId', params, sort, filter, match);
}


Expand All @@ -151,7 +151,7 @@ export async function findTimeoutTodoByOperatorId(params: any,
key: string,
type: string
}[]) {
return page('/api/query/flowRecord/findTimeoutTodoByOperatorId', params, sort, filter, match);
return httpClient.page('/api/query/flowRecord/findTimeoutTodoByOperatorId', params, sort, filter, match);
}

export async function findPostponedTodoByOperatorId(params: any,
Expand All @@ -161,5 +161,5 @@ export async function findPostponedTodoByOperatorId(params: any,
key: string,
type: string
}[]) {
return page('/api/query/flowRecord/findPostponedTodoByOperatorId', params, sort, filter, match);
return httpClient.page('/api/query/flowRecord/findPostponedTodoByOperatorId', params, sort, filter, match);
}
127 changes: 7 additions & 120 deletions admin-ui/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,124 +1,11 @@
import axios from "axios";
import {sleep, textToBase64} from "@/utils";
import {message} from "antd";
import {HttpClient} from "@codingapi/ui-framework";

const api = axios.create({
timeout: 10000,
headers: {
"Content-Type": "application/json",
export const httpClient = new HttpClient(10000, {
success:(msg:string)=>{
message.success(msg).then();
},
});

api.interceptors.request.use((config: any) => {
const token = localStorage.getItem("token");
if (token) {
config.headers = {
Authorization: `${token}`,
} as any;
}
return config;
}, (error: any) => {
return Promise.reject(error);
});

api.interceptors.response.use(async (response: any) => {
const headers = response.headers;
const token = headers['authorization'];

const state = response.status;
if (state === 200) {
if (token) {
console.log('reset token', token);
localStorage.setItem("token", token)
}

if(response.data) {
const success = response.data.success;
if (!success) {
const errMessage = response.data.errMessage;
const errCode = response.data.errCode;
if ("token.expire" === errCode || "token.error" === errCode) {
message.error('登录已过期,请退出再重新打开');
await sleep(1500);
localStorage.clear();
window.location.href = '/#login';
} else {
if ("login.error" === errCode) {
return response;
}
message.error(errMessage)
}
}
}else {
message.error('抱歉,该账户无权限访问');
}
}
return response;
},
(error: any) => {
const response = error.response;
const state = response.data.status;

if(state === 403){
message.error('抱歉,该账户无权限访问').then();
return {
data: {
success: false,
}
}
}
return Promise.reject(error);
}
)


export const get = async (url: string, params?: any) => {
try {
const response = await api.get(url, {
params
});
return response.data;
}catch (e){
return {
success: false,
}
}
}

export const post = async (url: string, data: any) => {
try {
const response = await api.post(url, data);
return response.data;
}catch (e){
return {
success: false,
}
}
}

export const page = async (url: string, params: any, sort: any, filter: any, match: {
key: string,
type: string
}[]) => {
const response = await get(url, {
...params,
sort: textToBase64(sort),
filter: textToBase64(filter),
params: textToBase64(match),
});

if(response.success){
const list = response.data.total > 0 ? response.data.list : [];
return {
data: list,
success: response.success,
total: response.data.total
};
}else{
return {
data: [],
success: response.success,
total: 0
}
error:(msg:string)=>{
message.error(msg).then();
}
}
})
6 changes: 3 additions & 3 deletions admin-ui/src/api/jar.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {post} from "@/api/index";
import {httpClient} from "@/api/index";

export async function upload(body: any) {
return post('/api/jar/upload', body);
return httpClient.post('/api/jar/upload', body);
}

export async function restart() {
return post('/api/jar/restart',{});
return httpClient.post('/api/jar/restart',{});
}
6 changes: 3 additions & 3 deletions admin-ui/src/api/leave.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {page, post} from "@/api/index";
import {httpClient} from "@/api/index";

export async function list(
params: any,
Expand All @@ -9,12 +9,12 @@ export async function list(
type: string
}[]
) {
return page('/api/query/leave/list', params, sort, filter, match);
return httpClient.page('/api/query/leave/list', params, sort, filter, match);
}



export async function startLeave(body: any) {
return post('/api/cmd/leave/startLeave', body);
return httpClient.post('/api/cmd/leave/startLeave', body);
}

25 changes: 0 additions & 25 deletions admin-ui/src/api/node.ts

This file was deleted.

6 changes: 3 additions & 3 deletions admin-ui/src/api/oss.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {get, post} from "@/api/index";
import {httpClient} from "@/api/index";


export async function loadFiles(ids: string) {
return get('/api/oss/load', {ids: ids});
return httpClient.get('/api/oss/load', {ids: ids});
}


export async function upload(body: any) {
return post('/api/oss/upload', body);
return httpClient.post('/api/oss/upload', body);
}
Loading