kn-cli 1.0.64 → 1.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/readme.md +3 -0
- package/src/create.js +2 -0
- package/templates/template_oa/public/src/components/IFrame/index.jsx +3 -0
- package/templates/template_oa/webpack.api.js +7 -3
- package/templates/template_oa_jwt/.gitignore +6 -0
- package/templates/template_oa_jwt/build.sh +7 -0
- package/templates/template_oa_jwt/cli.config.js +30 -0
- package/templates/template_oa_jwt/dev.sh +89 -0
- package/templates/template_oa_jwt/frontend_build.sh +88 -0
- package/templates/template_oa_jwt/init/prepare-commit-msg +5 -0
- package/templates/template_oa_jwt/init.sh +33 -0
- package/templates/template_oa_jwt/jsconfig.json +10 -0
- package/templates/template_oa_jwt/package.json +25 -0
- package/templates/template_oa_jwt/public/404.html +26 -0
- package/templates/template_oa_jwt/public/favicon.ico +0 -0
- package/templates/template_oa_jwt/public/index.html +44 -0
- package/templates/template_oa_jwt/public/src/_antd.less +216 -0
- package/templates/template_oa_jwt/public/src/_reset.less +134 -0
- package/templates/template_oa_jwt/public/src/_variable.less +84 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.less +57 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.svg +36 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_oa_jwt/public/src/assets/images/NY-pop-bg.png +0 -0
- package/templates/template_oa_jwt/public/src/assets/images/avatar.png +0 -0
- package/templates/template_oa_jwt/public/src/assets/images/loading.svg +40 -0
- package/templates/template_oa_jwt/public/src/components/Alert/index.jsx +0 -0
- package/templates/template_oa_jwt/public/src/components/Alert/index.less +0 -0
- package/templates/template_oa_jwt/public/src/components/Auth/index.jsx +44 -0
- package/templates/template_oa_jwt/public/src/components/Dialog/index.jsx +150 -0
- package/templates/template_oa_jwt/public/src/components/Dialog/index.less +123 -0
- package/templates/template_oa_jwt/public/src/components/Empty/index.jsx +23 -0
- package/templates/template_oa_jwt/public/src/components/Empty/index.less +6 -0
- package/templates/template_oa_jwt/public/src/components/Footer/index.jsx +17 -0
- package/templates/template_oa_jwt/public/src/components/Footer/index.less +28 -0
- package/templates/template_oa_jwt/public/src/components/FormRow/index.jsx +39 -0
- package/templates/template_oa_jwt/public/src/components/FormRow/index.less +67 -0
- package/templates/template_oa_jwt/public/src/components/FormTable/index.jsx +137 -0
- package/templates/template_oa_jwt/public/src/components/FormTable/index.less +18 -0
- package/templates/template_oa_jwt/public/src/components/IFrame/index.jsx +44 -0
- package/templates/template_oa_jwt/public/src/components/IFrame/index.less +4 -0
- package/templates/template_oa_jwt/public/src/components/IconFont/index.jsx +10 -0
- package/templates/template_oa_jwt/public/src/components/IconFont/index.less +5 -0
- package/templates/template_oa_jwt/public/src/components/Layout/Basic/index.jsx +52 -0
- package/templates/template_oa_jwt/public/src/components/Layout/Basic/index.less +82 -0
- package/templates/template_oa_jwt/public/src/components/Layout/CenterBody/index.jsx +15 -0
- package/templates/template_oa_jwt/public/src/components/Layout/CenterBody/index.less +36 -0
- package/templates/template_oa_jwt/public/src/components/Layout/FormBlock/index.jsx +23 -0
- package/templates/template_oa_jwt/public/src/components/Layout/FormBlock/index.less +37 -0
- package/templates/template_oa_jwt/public/src/components/Layout/Provider/index.jsx +12 -0
- package/templates/template_oa_jwt/public/src/components/Layout/index.jsx +27 -0
- package/templates/template_oa_jwt/public/src/components/Layout/index.less +8 -0
- package/templates/template_oa_jwt/public/src/components/Link/index.jsx +24 -0
- package/templates/template_oa_jwt/public/src/components/Link/index.less +11 -0
- package/templates/template_oa_jwt/public/src/components/Loading/index.jsx +16 -0
- package/templates/template_oa_jwt/public/src/components/Loading/index.less +96 -0
- package/templates/template_oa_jwt/public/src/components/Nav/index.jsx +184 -0
- package/templates/template_oa_jwt/public/src/components/Nav/index.less +38 -0
- package/templates/template_oa_jwt/public/src/components/Page/PageLoading/index.jsx +30 -0
- package/templates/template_oa_jwt/public/src/components/Page/PageLoading/index.less +29 -0
- package/templates/template_oa_jwt/public/src/components/Popup/index.jsx +22 -0
- package/templates/template_oa_jwt/public/src/components/Popup/index.less +18 -0
- package/templates/template_oa_jwt/public/src/components/Select/DepSelect/index.jsx +47 -0
- package/templates/template_oa_jwt/public/src/components/Select/StaffSelect/index.jsx +97 -0
- package/templates/template_oa_jwt/public/src/components/Select/StaffSelect/index.less +24 -0
- package/templates/template_oa_jwt/public/src/components/Toast/index.jsx +60 -0
- package/templates/template_oa_jwt/public/src/components/Toast/index.less +43 -0
- package/templates/template_oa_jwt/public/src/components/Upload/index.jsx +358 -0
- package/templates/template_oa_jwt/public/src/components/title/index.jsx +12 -0
- package/templates/template_oa_jwt/public/src/components/title/index.less +21 -0
- package/templates/template_oa_jwt/public/src/dictionary/index.js +20 -0
- package/templates/template_oa_jwt/public/src/hooks/index.jsx +21 -0
- package/templates/template_oa_jwt/public/src/hooks/useDelay.jsx +29 -0
- package/templates/template_oa_jwt/public/src/hooks/useImageLoader.jsx +27 -0
- package/templates/template_oa_jwt/public/src/hooks/useLoading.jsx +42 -0
- package/templates/template_oa_jwt/public/src/hooks/useLogin.jsx +33 -0
- package/templates/template_oa_jwt/public/src/hooks/usePreload.jsx +66 -0
- package/templates/template_oa_jwt/public/src/hooks/useScrollTop.jsx +32 -0
- package/templates/template_oa_jwt/public/src/hooks/useSearch.jsx +137 -0
- package/templates/template_oa_jwt/public/src/hooks/useUpdate.jsx +11 -0
- package/templates/template_oa_jwt/public/src/index.jsx +50 -0
- package/templates/template_oa_jwt/public/src/mock/common.js +484 -0
- package/templates/template_oa_jwt/public/src/mock/index.js +63 -0
- package/templates/template_oa_jwt/public/src/mock/user.js +70 -0
- package/templates/template_oa_jwt/public/src/mock/utils.js +33 -0
- package/templates/template_oa_jwt/public/src/pages/components/pageTitle/index.jsx +13 -0
- package/templates/template_oa_jwt/public/src/pages/components/pageTitle/index.less +20 -0
- package/templates/template_oa_jwt/public/src/pages/components/totalRecord/index.jsx +21 -0
- package/templates/template_oa_jwt/public/src/pages/components/totalRecord/index.less +16 -0
- package/templates/template_oa_jwt/public/src/pages/demo/detail/index.jsx +14 -0
- package/templates/template_oa_jwt/public/src/pages/demo/index.jsx +399 -0
- package/templates/template_oa_jwt/public/src/pages/demo/index.less +15 -0
- package/templates/template_oa_jwt/public/src/pages/login/index.jsx +29 -0
- package/templates/template_oa_jwt/public/src/pages/login/index.less +44 -0
- package/templates/template_oa_jwt/public/src/pages/redirect/index.jsx +31 -0
- package/templates/template_oa_jwt/public/src/provider/app.jsx +66 -0
- package/templates/template_oa_jwt/public/src/route.jsx +45 -0
- package/templates/template_oa_jwt/public/src/services/common.js +133 -0
- package/templates/template_oa_jwt/public/src/services/demo.js +41 -0
- package/templates/template_oa_jwt/public/src/services/index.js +266 -0
- package/templates/template_oa_jwt/public/src/services/token.js +132 -0
- package/templates/template_oa_jwt/public/src/utils/index.js +115 -0
- package/templates/template_oa_jwt/public/static/about.html +1 -0
- package/templates/template_oa_jwt/public/static/kssoLogin.html +22 -0
- package/templates/template_oa_jwt/public/static/noAuth.html +217 -0
- package/templates/template_oa_jwt/public/static/noAuth.png +0 -0
- package/templates/template_oa_jwt/readme.md +71 -0
- package/templates/template_oa_jwt/report.sh +68 -0
- package/templates/template_oa_jwt/tools/iconfont/gulpfile.js +70 -0
- package/templates/template_oa_jwt/tools/iconfont/package.json +20 -0
- package/templates/template_oa_jwt/tools/iconfont/run.sh +39 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/arrowBack.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/check.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/close.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/down.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/image.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/play.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/refresh.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/warn.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/templates/_icons.css +26 -0
- package/templates/template_oa_jwt/tools/iconfont/templates/_icons.less +29 -0
- package/templates/template_oa_jwt/tools/iconfont/templates/index.html +56 -0
- package/templates/template_oa_jwt/tools/tinypng/package.json +11 -0
- package/templates/template_oa_jwt/tools/tinypng/run.sh +15 -0
- package/templates/template_oa_jwt/versionPublish.sh +27 -0
- package/templates/template_oa_jwt/webpack.api.js +61 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
|
|
2
|
+
import {GET_TOKEN,GET_DEFAULT_CROSS} from '@/services';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取员工列表
|
|
7
|
+
*/
|
|
8
|
+
export async function GET_STAFF_LIST() {
|
|
9
|
+
let ret = await GET_DEFAULT_CROSS(`${OA_HOST}/common/getNewUserList`);
|
|
10
|
+
return ret;
|
|
11
|
+
// let response = await axios({
|
|
12
|
+
// method: 'get',
|
|
13
|
+
// xsrfCookieName: '',
|
|
14
|
+
// xsrfHeaderName: '',
|
|
15
|
+
// withCredentials: true,
|
|
16
|
+
// url: `${EnvConfig.oaHost}/common/getNewUserList`,
|
|
17
|
+
// });
|
|
18
|
+
|
|
19
|
+
// return response && response.data ? response.data : null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 所有部门信息
|
|
24
|
+
*/
|
|
25
|
+
export async function GET_DEP_LIST() {
|
|
26
|
+
return GET_DEFAULT_CROSS(`${OA_HOST}/common/getBenefitDept`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 获取公司信息
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export function GET_COMPANY_LIST(){
|
|
34
|
+
return GET_DEFAULT_CROSS(`${OA_HOST}/filestore/list?status=1`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 上传文件
|
|
43
|
+
*/
|
|
44
|
+
export async function POST_IMPORT_EXCEL(url, file, onProgress) {
|
|
45
|
+
let formdata = new FormData();
|
|
46
|
+
let token = await GET_TOKEN();
|
|
47
|
+
formdata.append('file', file);
|
|
48
|
+
formdata.append('_token', token);
|
|
49
|
+
let response = await axios({
|
|
50
|
+
method: 'post',
|
|
51
|
+
url: url,
|
|
52
|
+
data: formdata,
|
|
53
|
+
onUploadProgress: (e) => {
|
|
54
|
+
onProgress({ percent: `${e.loaded}/${e.total}` * 100 });
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
return response && response.data ? response.data : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 获取下载文件的url路径
|
|
62
|
+
*/
|
|
63
|
+
export function GET_DOWNLOAD_FILE(s_name) {
|
|
64
|
+
return `${OA_HOST}/file/download?name=${s_name}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export async function UPLOAD_FILE(file, param, onProgress) {
|
|
70
|
+
// return new Promise(res=>{
|
|
71
|
+
// res({
|
|
72
|
+
// url:'https://officialwebsite-static.kingnet.com/20210312142223-360%E6%88%AA%E5%9B%BE20210312142143898.jpg',
|
|
73
|
+
// key:'123',
|
|
74
|
+
// })
|
|
75
|
+
// });
|
|
76
|
+
let token = await GET_TOKEN();
|
|
77
|
+
let formdata = new FormData();
|
|
78
|
+
|
|
79
|
+
formdata.append('uploadFile', file);
|
|
80
|
+
formdata.append('_token', token);
|
|
81
|
+
|
|
82
|
+
let response = await axios({
|
|
83
|
+
method: 'post',
|
|
84
|
+
url: `${OA_HOST}/file/upload`,
|
|
85
|
+
data: formdata,
|
|
86
|
+
xsrfCookieName: '',
|
|
87
|
+
xsrfHeaderName: '',
|
|
88
|
+
withCredentials: true,
|
|
89
|
+
|
|
90
|
+
onUploadProgress: (e) => {
|
|
91
|
+
let per = parseFloat((e.loaded / e.total) * 100).toFixed(0);
|
|
92
|
+
onProgress({ percent: per });
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
if(response&&response.data&&response.data.info){
|
|
96
|
+
response = response.data.info;
|
|
97
|
+
response = {
|
|
98
|
+
url:response.s_name,
|
|
99
|
+
key:response.c_name
|
|
100
|
+
};
|
|
101
|
+
}else{
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return response||null;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 检查文件类型
|
|
110
|
+
* filename:文件名称
|
|
111
|
+
* types:array|string,['png','gif']|'png' 类型
|
|
112
|
+
*/
|
|
113
|
+
export function CHECK_FILE_TYPE(types, filename) {
|
|
114
|
+
let reg = '';
|
|
115
|
+
|
|
116
|
+
if (types.constructor === Array) {
|
|
117
|
+
types = types.join('|');
|
|
118
|
+
}
|
|
119
|
+
reg = `[.](${types})$`;
|
|
120
|
+
reg = new RegExp(reg, 'i');
|
|
121
|
+
return reg.test(filename);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 模拟延迟
|
|
128
|
+
*/
|
|
129
|
+
export async function DELAY(ms) {
|
|
130
|
+
return new Promise((reslove) => {
|
|
131
|
+
setTimeout(reslove, ms);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
import {GET_DEFAULT_CROSS} from '@/services';
|
|
3
|
+
|
|
4
|
+
export function TEST_AUTH(params){
|
|
5
|
+
return GET_DEFAULT_CROSS(`${API_HOST}/me`)
|
|
6
|
+
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export function GET_LIST(params={
|
|
11
|
+
current:1,
|
|
12
|
+
pageSize:10,
|
|
13
|
+
keywords:''
|
|
14
|
+
}){
|
|
15
|
+
const {current,pageSize,keywords='-'}=params;
|
|
16
|
+
console.log('GET_LIST',params)
|
|
17
|
+
let list=[];
|
|
18
|
+
for(let i=0;i<200;i++){
|
|
19
|
+
list.push({
|
|
20
|
+
id:i,
|
|
21
|
+
value:`item-${i}-${keywords}`,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
let total=200;
|
|
25
|
+
let startIdx = (current-1)*pageSize;
|
|
26
|
+
let data = list.splice(startIdx,pageSize);
|
|
27
|
+
let req= {
|
|
28
|
+
code:0,
|
|
29
|
+
data,
|
|
30
|
+
page:{
|
|
31
|
+
current,
|
|
32
|
+
pageSize,
|
|
33
|
+
total
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return new Promise(resolve=>{
|
|
37
|
+
setTimeout(()=>{
|
|
38
|
+
resolve(req)
|
|
39
|
+
},500)
|
|
40
|
+
})
|
|
41
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import Axios from 'axios';
|
|
2
|
+
import qs from 'qs';
|
|
3
|
+
import { message } from 'antd';
|
|
4
|
+
import { toHref, exportExcel } from '@/utils';
|
|
5
|
+
import { CHANGE_TOKEN, setRefreshToken ,toLogin} from './token';
|
|
6
|
+
const axios = Axios.create();
|
|
7
|
+
console.log(`========API_HOST:${API_HOST}========`);
|
|
8
|
+
|
|
9
|
+
const tokenMode='header';//header,cookie
|
|
10
|
+
const tokenName='Authorization';
|
|
11
|
+
|
|
12
|
+
const CODE = {
|
|
13
|
+
200: 'KN0200',
|
|
14
|
+
401: 'KN0401', // 未登录
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let Modal = {
|
|
18
|
+
error: (options) => {
|
|
19
|
+
message.error(options.content);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let jwt = localStorage.getItem('jwt') || '';
|
|
24
|
+
|
|
25
|
+
export const setJwt = (value) => {
|
|
26
|
+
if(value==''){
|
|
27
|
+
localStorage.removeItem('jwt');
|
|
28
|
+
jwt='';
|
|
29
|
+
return;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
localStorage.setItem('jwt', value);
|
|
33
|
+
jwt = value;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
axios.interceptors.request.use(function (config) {
|
|
39
|
+
const header = { 'X-Requested-With': 'XMLHttpRequest' };
|
|
40
|
+
if(tokenMode=='header'){
|
|
41
|
+
if (jwt) {
|
|
42
|
+
header[tokenName] = `Bearer ${jwt}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (config.headers) {
|
|
46
|
+
config.headers = { ...config.headers, ...header };
|
|
47
|
+
} else {
|
|
48
|
+
config.headers = header;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 在发送请求之前做些什么
|
|
52
|
+
return config;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 统一拦截异常消息弹屏报错处理
|
|
57
|
+
* 如果希望某条消息不拦截,可以再发送消息时带上 noInterceptors:true|'all'
|
|
58
|
+
*/
|
|
59
|
+
axios.interceptors.response.use(
|
|
60
|
+
function (response) {
|
|
61
|
+
// setJwt(response?.headers['set-token'] || jwt);
|
|
62
|
+
if (response.config.noInterceptors) {
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
65
|
+
if (response.data.code !== CODE[200]) {
|
|
66
|
+
// console.log(`${JSON.stringify(response.data)}`);
|
|
67
|
+
Modal.error({ title: `注意`, content: `${response.data.info}(${response.data.code})` });
|
|
68
|
+
}
|
|
69
|
+
return response;
|
|
70
|
+
},
|
|
71
|
+
function (error) {
|
|
72
|
+
if (error.response.config.noInterceptors === 'all') {
|
|
73
|
+
return Promise.reject(error.response);
|
|
74
|
+
}
|
|
75
|
+
console.error(error);
|
|
76
|
+
// jwt失效
|
|
77
|
+
if (error.response.status === 401) {
|
|
78
|
+
// 页面接口401时,重新换取token后,再重新发起请求
|
|
79
|
+
return refreshAndRetry(error);
|
|
80
|
+
} else if (error.response.status === 403) {
|
|
81
|
+
toHref('/static/noAuth.html'); // OA无权限页面上线后,更新地址,
|
|
82
|
+
// 测试环境 http://192.168.90.250:8886/mobile/feishuNoAuth/index.html
|
|
83
|
+
|
|
84
|
+
// Modal.error({
|
|
85
|
+
// title: '提示',
|
|
86
|
+
// content: `${error.response.data.info}`,
|
|
87
|
+
// });
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
Modal.error({
|
|
91
|
+
title: `网络错误${error.response.status}`,
|
|
92
|
+
content: `${error.response.status} ${error.response.data.msg}`,
|
|
93
|
+
});
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
let buffer = {};
|
|
102
|
+
export async function GET_DEFAULT(url, param, options) {
|
|
103
|
+
if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
|
|
104
|
+
let now = Date.now();
|
|
105
|
+
|
|
106
|
+
let bufferItem;
|
|
107
|
+
if (options?.ttl) {
|
|
108
|
+
if (buffer[url]) {
|
|
109
|
+
bufferItem = buffer[url];
|
|
110
|
+
if (bufferItem.param == param && now <= bufferItem.endTime) {
|
|
111
|
+
return bufferItem?.response?.data || null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
let response = await axios({
|
|
116
|
+
method: 'GET',
|
|
117
|
+
url: param ? `${url}?${param}` : url,
|
|
118
|
+
...options,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (options?.ttl) {
|
|
122
|
+
if (!buffer[url]) {
|
|
123
|
+
buffer[url] = {};
|
|
124
|
+
}
|
|
125
|
+
buffer[url].param = param;
|
|
126
|
+
let ttl = options.ttl === true ? 1000 * 2 : options.ttl;
|
|
127
|
+
buffer[url].endTime = Date.now() + ttl;
|
|
128
|
+
buffer[url].response = response;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return response && response.data ? response.data : null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function GET_DEFAULT_CROSS(url, param) {
|
|
135
|
+
if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
|
|
136
|
+
|
|
137
|
+
let response = await axios({
|
|
138
|
+
method: 'GET',
|
|
139
|
+
xsrfCookieName: '',
|
|
140
|
+
xsrfHeaderName: '',
|
|
141
|
+
withCredentials: true,
|
|
142
|
+
url: param ? `${url}?${param}` : url,
|
|
143
|
+
});
|
|
144
|
+
return response && response.data ? response.data : null;
|
|
145
|
+
}
|
|
146
|
+
export async function EXPORT_DEFAULT_CROSS(url, param, user) {
|
|
147
|
+
if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
|
|
148
|
+
|
|
149
|
+
let response = await axios({
|
|
150
|
+
method: 'GET',
|
|
151
|
+
xsrfCookieName: '',
|
|
152
|
+
xsrfHeaderName: '',
|
|
153
|
+
responseType: 'blob',
|
|
154
|
+
withCredentials: true,
|
|
155
|
+
noInterceptors: true,
|
|
156
|
+
url: param ? `${url}?${param}` : url,
|
|
157
|
+
});
|
|
158
|
+
exportExcel(response, user);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export async function POST_DEFAULT(url, params, method, options) {
|
|
162
|
+
let data = params;
|
|
163
|
+
// if (params) params = qs.stringify(params, { arrayFormat: 'indices' });
|
|
164
|
+
// if (typeof params === 'string') {
|
|
165
|
+
// data = params;
|
|
166
|
+
// } else {
|
|
167
|
+
// data = { ...params };
|
|
168
|
+
// }
|
|
169
|
+
// let token= await GET_TOKEN();
|
|
170
|
+
let response = await axios({
|
|
171
|
+
method: method || 'POST',
|
|
172
|
+
url: url,
|
|
173
|
+
data:{
|
|
174
|
+
// _token:token,
|
|
175
|
+
...data
|
|
176
|
+
},
|
|
177
|
+
...options,
|
|
178
|
+
// headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
179
|
+
});
|
|
180
|
+
return response && response.data ? response.data : null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export async function POST_DEFAULT_CROSS(url, params) {
|
|
184
|
+
// let token= await GET_TOKEN();
|
|
185
|
+
|
|
186
|
+
let data = {};
|
|
187
|
+
// if (params) params = qs.stringify(params, { arrayFormat: 'indices' });
|
|
188
|
+
|
|
189
|
+
if (typeof params === 'string') {
|
|
190
|
+
data = params;
|
|
191
|
+
} else {
|
|
192
|
+
data = { ...params };
|
|
193
|
+
}
|
|
194
|
+
let response = await axios({
|
|
195
|
+
// headers:{
|
|
196
|
+
// 'X-XSRF-TOKEN': token,
|
|
197
|
+
// },
|
|
198
|
+
method: 'POST',
|
|
199
|
+
url: url,
|
|
200
|
+
xsrfCookieName: '',
|
|
201
|
+
xsrfHeaderName: '',
|
|
202
|
+
withCredentials: true,
|
|
203
|
+
data: {
|
|
204
|
+
// _token:token,
|
|
205
|
+
...data,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
return response && response.data ? response.data : null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
/**************************************************************************
|
|
214
|
+
* 基础共享接口
|
|
215
|
+
*************************************************************************/
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* 获取用户token
|
|
221
|
+
*/
|
|
222
|
+
export async function GET_TOKEN() {
|
|
223
|
+
let cookie = document.cookie.split(';').map(item=>item.split('='));
|
|
224
|
+
let xsrf = cookie.filter(item=>item[0].trim().toUpperCase()==='XSRF-TOKEN')
|
|
225
|
+
return Promise.resolve(xsrf[0][1]);
|
|
226
|
+
// let response = await axios({
|
|
227
|
+
// method: 'get',
|
|
228
|
+
// url: '/csrf_token',
|
|
229
|
+
// })
|
|
230
|
+
// return (response && response.data) ? response.data : null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
export function FORMAT_RESPONSE_NO_PAGINATION(response){
|
|
236
|
+
const {code,data={}}= response;
|
|
237
|
+
let req={
|
|
238
|
+
code: code === CODE[200] ? 0 : 1,
|
|
239
|
+
data: data.data,
|
|
240
|
+
page:{
|
|
241
|
+
current: data.current || 1,
|
|
242
|
+
pageSize: data.pageSize || data.data.length,
|
|
243
|
+
total: data.total || data.data.length,
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return req;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
*
|
|
251
|
+
* @param {} error 业务接口401时,用 refreshToken 重新获取token,再重试当前接口
|
|
252
|
+
* @returns
|
|
253
|
+
*/
|
|
254
|
+
const refreshAndRetry = async (error) => {
|
|
255
|
+
if (!localStorage.getItem('refreshToken')) {
|
|
256
|
+
if(toLogin)toLogin(error.response.data.data.auth_url);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const tokenRes = await CHANGE_TOKEN();
|
|
260
|
+
if (tokenRes) {
|
|
261
|
+
setJwt(tokenRes.data.access_token);
|
|
262
|
+
setRefreshToken(tokenRes.data.refresh_token);
|
|
263
|
+
const res = await axios(error.config);
|
|
264
|
+
return res;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import Axios from 'axios';
|
|
2
|
+
import { message } from 'antd';
|
|
3
|
+
import { toHref } from '@/utils';
|
|
4
|
+
const axios = Axios.create();
|
|
5
|
+
|
|
6
|
+
const CODE = {
|
|
7
|
+
200: 'KN0200',
|
|
8
|
+
401: 'KN0401', // 未登录
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
let Modal = {
|
|
13
|
+
error: (options) => {
|
|
14
|
+
message.error(options.content);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let refreshToken = localStorage.getItem('refreshToken') || '';
|
|
19
|
+
|
|
20
|
+
export const setRefreshToken = (value) => {
|
|
21
|
+
if(value==''){
|
|
22
|
+
localStorage.removeItem('refreshToken');
|
|
23
|
+
refreshToken='';
|
|
24
|
+
return;
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
localStorage.setItem('refreshToken', value);
|
|
28
|
+
refreshToken = value;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export let logout = ()=>{}
|
|
32
|
+
export const setLogout=(fn)=>{
|
|
33
|
+
window.logout=fn;
|
|
34
|
+
logout=fn;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export let toLogin = ()=>{}
|
|
38
|
+
export const setToLogin=(fn)=>{
|
|
39
|
+
toLogin=fn;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
axios.interceptors.request.use(function (config) {
|
|
43
|
+
const header = { 'X-Requested-With': 'XMLHttpRequest' };
|
|
44
|
+
if (config.headers) {
|
|
45
|
+
config.headers = { ...config.headers, ...header };
|
|
46
|
+
} else {
|
|
47
|
+
config.headers = header;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 在发送请求之前做些什么
|
|
51
|
+
return config;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 统一拦截异常消息弹屏报错处理
|
|
56
|
+
* 如果希望某条消息不拦截,可以再发送消息时带上 noInterceptors:true|'all'
|
|
57
|
+
*/
|
|
58
|
+
axios.interceptors.response.use(
|
|
59
|
+
function (response) {
|
|
60
|
+
if (response.config.noInterceptors) {
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
if (response.data.code !== CODE[200]) {
|
|
64
|
+
Modal.error({ title: `注意`, content: `${response.data.info}(${response.data.code})` });
|
|
65
|
+
}
|
|
66
|
+
return response;
|
|
67
|
+
},
|
|
68
|
+
function (error) {
|
|
69
|
+
if (error.response.config.noInterceptors === 'all') {
|
|
70
|
+
return Promise.reject(error.response);
|
|
71
|
+
}
|
|
72
|
+
console.log('token error:', JSON.stringify(error));
|
|
73
|
+
const url = error.response.data.data.auth_url;
|
|
74
|
+
if(toLogin)toLogin(url);
|
|
75
|
+
return;
|
|
76
|
+
// jwt失效
|
|
77
|
+
if (error.response.status === 401) {
|
|
78
|
+
const url = error.response.data.data.auth_url;
|
|
79
|
+
if(toLogin)toLogin(url);
|
|
80
|
+
return;
|
|
81
|
+
} else if (error.response.status === 403) {
|
|
82
|
+
toHref('/static/noAuth.html'); // OA无权限页面上线后,更新地址,
|
|
83
|
+
// 测试环境 http://192.168.90.250:8886/mobile/feishuNoAuth/index.html
|
|
84
|
+
|
|
85
|
+
// Modal.error({
|
|
86
|
+
// title: '提示',
|
|
87
|
+
// content: `${error.response.data.info}`,
|
|
88
|
+
// });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
Modal.error({
|
|
92
|
+
title: `网络错误${error.response.status}`,
|
|
93
|
+
content: `${error.response.config.url} ${error.response.data.msg}`,
|
|
94
|
+
});
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
async function POST_DEFAULT_CROSS(url, params) {
|
|
102
|
+
|
|
103
|
+
let data = {};
|
|
104
|
+
|
|
105
|
+
if (typeof params === 'string') {
|
|
106
|
+
data = params;
|
|
107
|
+
} else {
|
|
108
|
+
data = { ...params };
|
|
109
|
+
}
|
|
110
|
+
let response = await axios({
|
|
111
|
+
method: 'POST',
|
|
112
|
+
url: url,
|
|
113
|
+
xsrfCookieName: '',
|
|
114
|
+
xsrfHeaderName: '',
|
|
115
|
+
withCredentials: true,
|
|
116
|
+
data: data,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return response && response.data ? response.data : null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* code 换AccessToken接口
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
export async function CHANGE_TOKEN(params){
|
|
129
|
+
let values = params ? params : {refresh_token: refreshToken};
|
|
130
|
+
const res = await POST_DEFAULT_CROSS(`${KSSO_HOST}/oauth/ksso/exchange`, values);
|
|
131
|
+
return res;
|
|
132
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
|
|
3
|
+
export const openLink = (link, target = '_blank') => {
|
|
4
|
+
let domLink = document.createElement('a');
|
|
5
|
+
domLink.href = link;
|
|
6
|
+
domLink.setAttribute('target', target);
|
|
7
|
+
domLink.style.opacity = 0;
|
|
8
|
+
domLink.style.zIndex = -999;
|
|
9
|
+
document.body.appendChild(domLink);
|
|
10
|
+
domLink.click();
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
document.body.removeChild(domLink);
|
|
13
|
+
}, 200);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const isMobile = () => {
|
|
17
|
+
return navigator.userAgent.match(
|
|
18
|
+
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const toHref = (url, replace, newWindow) => {
|
|
23
|
+
if (window.knFeishu) {
|
|
24
|
+
window.knFeishu.ToHref(url, replace, newWindow);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (newWindow) {
|
|
28
|
+
window.open(url);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (replace) {
|
|
32
|
+
location.replace(url);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
location.href = url;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const jumpUrl = (url, options = {}) => {
|
|
39
|
+
const { replace, newWindow, reload } = options;
|
|
40
|
+
if (reload) {
|
|
41
|
+
location.reload();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (replace) {
|
|
45
|
+
location.replace(url);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (newWindow) {
|
|
49
|
+
window.open(url);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
location.href = url;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// 关闭页面
|
|
58
|
+
export const closeWindow = () => {
|
|
59
|
+
if (window.knFeishu && window.knFeishu.closeWindow) {
|
|
60
|
+
window.knFeishu.closeWindow();
|
|
61
|
+
} else {
|
|
62
|
+
if (window.close) {
|
|
63
|
+
window.close();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export function formatMoney(s, n = 2) {
|
|
70
|
+
if (typeof s === 'undefined' || s === '') {
|
|
71
|
+
return '-'
|
|
72
|
+
}
|
|
73
|
+
s = parseFloat(s + '');
|
|
74
|
+
if (isNaN(s)) {
|
|
75
|
+
s = 0;
|
|
76
|
+
}
|
|
77
|
+
return s.toFixed(n).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 配置页面模块 枚举
|
|
82
|
+
*/
|
|
83
|
+
export const moduleEnum = [
|
|
84
|
+
{ value: 0, label: '基本信息', show: false, disabled: true },
|
|
85
|
+
{ value: 1, label: '仲裁', show: true, disabled: false },
|
|
86
|
+
{ value: 2, label: '一审', show: true, disabled: false },
|
|
87
|
+
{ value: 3, label: '二审', show: true, disabled: false },
|
|
88
|
+
{ value: 4, label: '执行', show: true, disabled: false },
|
|
89
|
+
{ value: 5, label: '提醒事项', show: false, disabled: true },
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
// JS0298 管理员权限
|
|
93
|
+
// JS0299 查看权限
|
|
94
|
+
export const isNoAuth = (user) => {
|
|
95
|
+
return !user.roles.includes('JS0298') && !user.roles.includes('JS0299')
|
|
96
|
+
}
|
|
97
|
+
export const isEditAuth = (user) => {
|
|
98
|
+
return user.roles.includes('JS0298')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const exportExcel = (response, user) => {
|
|
102
|
+
const blob = new Blob([response.data], { type: `${type},charset=UTF-8` });
|
|
103
|
+
const disposition = response.headers.get('content-disposition');
|
|
104
|
+
const fileName = `管理系统-${user.usr_username}-${moment().format('YYYY-MM-DD')}.xlsx`;
|
|
105
|
+
// const fileName = decodeURI(
|
|
106
|
+
// disposition
|
|
107
|
+
// ? disposition.split(';')[1].split('filename=')[1]
|
|
108
|
+
// : `管理系统-${user.usr_username}-${moment().format('YYYY-MM-DD HH:mm-ss')}.xlsx`,
|
|
109
|
+
// );
|
|
110
|
+
const link = document.createElement('a');
|
|
111
|
+
link.href = window.URL.createObjectURL(blob);
|
|
112
|
+
link.download = fileName.replace(/"/g, '');
|
|
113
|
+
link.click();
|
|
114
|
+
window.URL.revokeObjectURL(link.href);
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport"
|
|
7
|
+
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no,viewport-fit=cover" />
|
|
8
|
+
<meta name="format-detection" content="telephone=no,email=no,adress=no">
|
|
9
|
+
<meta name="apple-touch-fullscreen" content="yes">
|
|
10
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
11
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
12
|
+
<title></title>
|
|
13
|
+
<script>
|
|
14
|
+
var url = location.protocol + '//' + location.host+'/#/login';
|
|
15
|
+
location.replace('https://ksso.kingnet.com/oauth2/auth?client_id=30000655&response_type=code&redirect_uri=' + encodeURIComponent(url));
|
|
16
|
+
</script>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
</body>
|
|
21
|
+
|
|
22
|
+
</html>
|