doway-coms 1.6.11 → 1.6.13
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/.browserslistrc +2 -2
- package/README.md +28 -28
- package/package.json +52 -52
- package/packages/BaseButton/index.js +7 -7
- package/packages/BaseButton/src/index.vue +241 -241
- package/packages/BaseCheckbox/index.js +7 -7
- package/packages/BaseCheckbox/src/index.vue +134 -134
- package/packages/BaseDate/index.js +7 -7
- package/packages/BaseDate/src/index.vue +197 -197
- package/packages/BaseDateWeek/index.js +7 -7
- package/packages/BaseDateWeek/src/index.vue +163 -163
- package/packages/BaseDatetime/index.js +7 -7
- package/packages/BaseDatetime/src/index.vue +196 -196
- package/packages/BaseForm/index.js +7 -7
- package/packages/BaseForm/src/index.vue +666 -666
- package/packages/BaseGantt/index.js +9 -9
- package/packages/BaseGantt/src/index.vue +608 -608
- package/packages/BaseGrid/index.js +9 -9
- package/packages/BaseGrid/src/index.vue +2725 -2725
- package/packages/BaseGridAdjust/index.js +9 -9
- package/packages/BaseGridAdjust/src/index.vue +455 -455
- package/packages/BaseInput/index.js +7 -7
- package/packages/BaseInput/src/index.vue +164 -164
- package/packages/BaseIntervalInput/index.js +7 -7
- package/packages/BaseIntervalInput/src/index.vue +310 -310
- package/packages/BaseKanbanEmpty/index.js +7 -7
- package/packages/BaseKanbanEmpty/src/index.vue +176 -176
- package/packages/BaseNumberInput/index.js +7 -7
- package/packages/BaseNumberInput/src/index.vue +229 -229
- package/packages/BasePagination/index.js +7 -7
- package/packages/BasePagination/src/index.vue +91 -91
- package/packages/BasePictureCard/index.js +7 -7
- package/packages/BasePictureCard/src/index.vue +561 -561
- package/packages/BasePrintPreview/index.js +7 -7
- package/packages/BasePrintPreview/src/index.vue +117 -117
- package/packages/BasePulldown/index.js +7 -7
- package/packages/BasePulldown/src/index.vue +1095 -1090
- package/packages/BaseSearch/index.js +7 -7
- package/packages/BaseSearch/src/index.vue +935 -935
- package/packages/BaseSelect/index.js +7 -7
- package/packages/BaseSelect/src/index.vue +153 -155
- package/packages/BaseSelectMulti/index.js +7 -7
- package/packages/BaseSelectMulti/src/index.vue +148 -148
- package/packages/BaseTextArea/index.js +7 -7
- package/packages/BaseTextArea/src/index.vue +178 -178
- package/packages/BaseTime/index.js +7 -7
- package/packages/BaseTime/src/index.vue +166 -166
- package/packages/BaseTool/index.js +7 -7
- package/packages/BaseTool/src/index.vue +349 -349
- package/packages/BaseToolStatus/index.js +7 -7
- package/packages/BaseToolStatus/src/index.vue +383 -383
- package/packages/index.js +165 -165
- package/packages/styles/default.less +80 -80
- package/packages/utils/api.js +45 -45
- package/packages/utils/auth.js +38 -38
- package/packages/utils/common.js +583 -583
- package/packages/utils/dom.js +181 -181
- package/packages/utils/enum.js +83 -83
- package/packages/utils/filters.js +458 -458
- package/packages/utils/gridFormat.js +52 -52
- package/packages/utils/msg.js +16 -16
- package/packages/utils/patchFiles.js +44 -44
- package/packages/utils/request.js +169 -169
- package/packages/utils/store.js +261 -261
- package/vue.config.js +59 -59
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import VXETable from 'vxe-table'
|
|
2
|
-
import XEUtils from 'xe-utils'
|
|
3
|
-
VXETable.formats.mixin({
|
|
4
|
-
// 格式化性别
|
|
5
|
-
formatSex({ cellValue }) {
|
|
6
|
-
return cellValue ? (cellValue === '1' ? '男' : '女') : ''
|
|
7
|
-
},
|
|
8
|
-
formatCheckbox({ cellValue }) {
|
|
9
|
-
return cellValue === true ? '是' : '否'
|
|
10
|
-
},
|
|
11
|
-
// 格式化下拉选项
|
|
12
|
-
formatSelect(scope) {
|
|
13
|
-
let dataSource = scope.column.params.dataSource
|
|
14
|
-
if (!dataSource) {
|
|
15
|
-
// console.error(scope.cellValue + ' 字典缺失')
|
|
16
|
-
return scope.cellValue
|
|
17
|
-
}
|
|
18
|
-
const item = dataSource.find(item => item.value === scope.cellValue)
|
|
19
|
-
return item ? item.caption : scope.cellValue
|
|
20
|
-
},
|
|
21
|
-
// 格式化日期,默认 yyyy-MM-dd HH:mm:ss
|
|
22
|
-
formatDateTime({ cellValue }, format) {
|
|
23
|
-
if (cellValue && cellValue.indexOf('.') > 0) {
|
|
24
|
-
cellValue = cellValue.substr(0, cellValue.indexOf('.'))
|
|
25
|
-
}
|
|
26
|
-
return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd HH:mm:ss')
|
|
27
|
-
},
|
|
28
|
-
formatDate({ cellValue }, format) {
|
|
29
|
-
return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd')
|
|
30
|
-
},
|
|
31
|
-
// 四舍五入金额,每隔3位逗号分隔,默认2位数
|
|
32
|
-
formatAmount({ cellValue }, digits = 2) {
|
|
33
|
-
return '¥' + XEUtils.commafy(XEUtils.toNumber(cellValue), { digits })
|
|
34
|
-
},
|
|
35
|
-
// 格式化银行卡,默认每4位空格隔开
|
|
36
|
-
formatBankcard({ cellValue }) {
|
|
37
|
-
return XEUtils.commafy(XEUtils.toValueString(cellValue), {
|
|
38
|
-
spaceNumber: 4,
|
|
39
|
-
separator: ' '
|
|
40
|
-
})
|
|
41
|
-
},
|
|
42
|
-
// 四舍五入,默认两位数
|
|
43
|
-
formatFixedNumber({ cellValue }, digits = 2) {
|
|
44
|
-
return XEUtils.toFixed(XEUtils.round(cellValue, digits), digits)
|
|
45
|
-
},
|
|
46
|
-
// 向下舍入,默认两位数
|
|
47
|
-
formatCutNumber({ cellValue }, digits = 2) {
|
|
48
|
-
return XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
|
|
49
|
-
},
|
|
50
|
-
formatPercent({ cellValue }) {
|
|
51
|
-
return cellValue + '%'
|
|
52
|
-
}
|
|
1
|
+
import VXETable from 'vxe-table'
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
VXETable.formats.mixin({
|
|
4
|
+
// 格式化性别
|
|
5
|
+
formatSex({ cellValue }) {
|
|
6
|
+
return cellValue ? (cellValue === '1' ? '男' : '女') : ''
|
|
7
|
+
},
|
|
8
|
+
formatCheckbox({ cellValue }) {
|
|
9
|
+
return cellValue === true ? '是' : '否'
|
|
10
|
+
},
|
|
11
|
+
// 格式化下拉选项
|
|
12
|
+
formatSelect(scope) {
|
|
13
|
+
let dataSource = scope.column.params.dataSource
|
|
14
|
+
if (!dataSource) {
|
|
15
|
+
// console.error(scope.cellValue + ' 字典缺失')
|
|
16
|
+
return scope.cellValue
|
|
17
|
+
}
|
|
18
|
+
const item = dataSource.find(item => item.value === scope.cellValue)
|
|
19
|
+
return item ? item.caption : scope.cellValue
|
|
20
|
+
},
|
|
21
|
+
// 格式化日期,默认 yyyy-MM-dd HH:mm:ss
|
|
22
|
+
formatDateTime({ cellValue }, format) {
|
|
23
|
+
if (cellValue && cellValue.indexOf('.') > 0) {
|
|
24
|
+
cellValue = cellValue.substr(0, cellValue.indexOf('.'))
|
|
25
|
+
}
|
|
26
|
+
return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd HH:mm:ss')
|
|
27
|
+
},
|
|
28
|
+
formatDate({ cellValue }, format) {
|
|
29
|
+
return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd')
|
|
30
|
+
},
|
|
31
|
+
// 四舍五入金额,每隔3位逗号分隔,默认2位数
|
|
32
|
+
formatAmount({ cellValue }, digits = 2) {
|
|
33
|
+
return '¥' + XEUtils.commafy(XEUtils.toNumber(cellValue), { digits })
|
|
34
|
+
},
|
|
35
|
+
// 格式化银行卡,默认每4位空格隔开
|
|
36
|
+
formatBankcard({ cellValue }) {
|
|
37
|
+
return XEUtils.commafy(XEUtils.toValueString(cellValue), {
|
|
38
|
+
spaceNumber: 4,
|
|
39
|
+
separator: ' '
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
// 四舍五入,默认两位数
|
|
43
|
+
formatFixedNumber({ cellValue }, digits = 2) {
|
|
44
|
+
return XEUtils.toFixed(XEUtils.round(cellValue, digits), digits)
|
|
45
|
+
},
|
|
46
|
+
// 向下舍入,默认两位数
|
|
47
|
+
formatCutNumber({ cellValue }, digits = 2) {
|
|
48
|
+
return XEUtils.toFixed(XEUtils.floor(cellValue, digits), digits)
|
|
49
|
+
},
|
|
50
|
+
formatPercent({ cellValue }) {
|
|
51
|
+
return cellValue + '%'
|
|
52
|
+
}
|
|
53
53
|
})
|
package/packages/utils/msg.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {notification,Modal } from 'ant-design-vue'
|
|
2
|
-
export function successMsg(msg, desc){
|
|
3
|
-
notification['success']({ message: msg, description: desc, top: '100px' })
|
|
4
|
-
}
|
|
5
|
-
export function warningMsg(msg, desc){
|
|
6
|
-
notification['warning']({ message: msg, description: desc, top: '100px' })
|
|
7
|
-
}
|
|
8
|
-
export function errorMsg(msg, desc){
|
|
9
|
-
notification['error']({ message: msg, description: desc, top: '100px' })
|
|
10
|
-
}
|
|
11
|
-
export function infoMsg(dataInfo){
|
|
12
|
-
notification['info'](dataInfo)
|
|
13
|
-
}
|
|
14
|
-
export function closeMsg(key){
|
|
15
|
-
notification.close(key)
|
|
16
|
-
}
|
|
1
|
+
import {notification,Modal } from 'ant-design-vue'
|
|
2
|
+
export function successMsg(msg, desc){
|
|
3
|
+
notification['success']({ message: msg, description: desc, top: '100px' })
|
|
4
|
+
}
|
|
5
|
+
export function warningMsg(msg, desc){
|
|
6
|
+
notification['warning']({ message: msg, description: desc, top: '100px' })
|
|
7
|
+
}
|
|
8
|
+
export function errorMsg(msg, desc){
|
|
9
|
+
notification['error']({ message: msg, description: desc, top: '100px' })
|
|
10
|
+
}
|
|
11
|
+
export function infoMsg(dataInfo){
|
|
12
|
+
notification['info'](dataInfo)
|
|
13
|
+
}
|
|
14
|
+
export function closeMsg(key){
|
|
15
|
+
notification.close(key)
|
|
16
|
+
}
|
|
17
17
|
export const confirmMsg = Modal.confirm
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const chalk = require('chalk')
|
|
5
|
-
|
|
6
|
-
// 解决 node_modules 修改源码,导致重新装包而要手动替换源码的重复操作。
|
|
7
|
-
// 将 new_node_modules 内的文件 覆盖 真正的 node_modules
|
|
8
|
-
|
|
9
|
-
const REAL_NODE_MODULES = path.resolve('./node_modules') // 旧node_modules
|
|
10
|
-
|
|
11
|
-
const MY_NODE_MODULES = path.resolve('new_node_modules') // 新node_modules
|
|
12
|
-
|
|
13
|
-
copy(MY_NODE_MODULES, REAL_NODE_MODULES)
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
*复制目录中的所有文件包括子目录
|
|
18
|
-
*@param{string}需要复制的目录、文件
|
|
19
|
-
*@param{string}复制到指定的目录、文件
|
|
20
|
-
*@param{function}每次复制前,都会经过一次filterFn,若返回true,则复制。
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
function copy(origin, target, filterFn = () => true) {
|
|
25
|
-
if (fs.statSync(origin).isDirectory()) {
|
|
26
|
-
// 来源是个文件夹,那目标也整一个文件夹
|
|
27
|
-
|
|
28
|
-
if (!fs.existsSync(target)) {
|
|
29
|
-
fs.mkdirSync(target)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
fs.readdirSync(origin).forEach(originName => {
|
|
33
|
-
const originFilePath = path.resolve(origin, originName)
|
|
34
|
-
|
|
35
|
-
const targetFilePath = path.resolve(target, originName)
|
|
36
|
-
|
|
37
|
-
copy(originFilePath, targetFilePath, filterFn)
|
|
38
|
-
})
|
|
39
|
-
} else if (filterFn(origin, target)) {
|
|
40
|
-
console.info(chalk.blue('已被覆盖的文件:', target))
|
|
41
|
-
fs.copyFileSync(origin, target)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const chalk = require('chalk')
|
|
5
|
+
|
|
6
|
+
// 解决 node_modules 修改源码,导致重新装包而要手动替换源码的重复操作。
|
|
7
|
+
// 将 new_node_modules 内的文件 覆盖 真正的 node_modules
|
|
8
|
+
|
|
9
|
+
const REAL_NODE_MODULES = path.resolve('./node_modules') // 旧node_modules
|
|
10
|
+
|
|
11
|
+
const MY_NODE_MODULES = path.resolve('new_node_modules') // 新node_modules
|
|
12
|
+
|
|
13
|
+
copy(MY_NODE_MODULES, REAL_NODE_MODULES)
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
|
|
17
|
+
*复制目录中的所有文件包括子目录
|
|
18
|
+
*@param{string}需要复制的目录、文件
|
|
19
|
+
*@param{string}复制到指定的目录、文件
|
|
20
|
+
*@param{function}每次复制前,都会经过一次filterFn,若返回true,则复制。
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function copy(origin, target, filterFn = () => true) {
|
|
25
|
+
if (fs.statSync(origin).isDirectory()) {
|
|
26
|
+
// 来源是个文件夹,那目标也整一个文件夹
|
|
27
|
+
|
|
28
|
+
if (!fs.existsSync(target)) {
|
|
29
|
+
fs.mkdirSync(target)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fs.readdirSync(origin).forEach(originName => {
|
|
33
|
+
const originFilePath = path.resolve(origin, originName)
|
|
34
|
+
|
|
35
|
+
const targetFilePath = path.resolve(target, originName)
|
|
36
|
+
|
|
37
|
+
copy(originFilePath, targetFilePath, filterFn)
|
|
38
|
+
})
|
|
39
|
+
} else if (filterFn(origin, target)) {
|
|
40
|
+
console.info(chalk.blue('已被覆盖的文件:', target))
|
|
41
|
+
fs.copyFileSync(origin, target)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
45
|
console.info(chalk.bold.yellow('💡💡💡 以上的文件已被rewrite_node_modules中的文件替换,升级版本后请注意检查!!!'))
|
|
@@ -1,169 +1,169 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import { licenseAuthorizeApi } from './api'
|
|
3
|
-
import { notification, message, Modal, Input } from 'ant-design-vue'
|
|
4
|
-
import Vue from 'vue'
|
|
5
|
-
import store from './store'
|
|
6
|
-
import moment from 'moment'
|
|
7
|
-
// create an axios instance
|
|
8
|
-
const service = axios.create({
|
|
9
|
-
// baseURL: process.env.BASE_API, // api的base_url
|
|
10
|
-
timeout: 1000 * 60 * 5 // request timeout
|
|
11
|
-
})
|
|
12
|
-
// request interceptor
|
|
13
|
-
service.interceptors.request.use(
|
|
14
|
-
config => {
|
|
15
|
-
// Do something before request is sent
|
|
16
|
-
let tempToken = store.state.token
|
|
17
|
-
if (tempToken) {
|
|
18
|
-
config.headers.Authorization = `Bearer ${tempToken}`
|
|
19
|
-
}
|
|
20
|
-
// config.headers.Accept = 'application/json,Date, text/plain, */*'
|
|
21
|
-
return config
|
|
22
|
-
},
|
|
23
|
-
error => {
|
|
24
|
-
// Do something with request error
|
|
25
|
-
Promise.reject(error)
|
|
26
|
-
}
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
// respone interceptor
|
|
30
|
-
service.interceptors.response.use(
|
|
31
|
-
async response => {
|
|
32
|
-
const res = response.data
|
|
33
|
-
// 导出文件进入判断
|
|
34
|
-
if (res instanceof Blob) {
|
|
35
|
-
if (res.type === 'application/json') {
|
|
36
|
-
const enc = await new TextDecoder('utf-8');
|
|
37
|
-
await res.arrayBuffer().then((buffer) => {
|
|
38
|
-
const tempData = JSON.parse(enc.decode(new Uint8Array(buffer))) || {};
|
|
39
|
-
if (tempData['code'] && tempData['code'] === 500) {
|
|
40
|
-
notification.error({
|
|
41
|
-
message: '错误信息',
|
|
42
|
-
top:"100px",
|
|
43
|
-
description: h => {
|
|
44
|
-
return h('div', null, [
|
|
45
|
-
h('p', { domProps: { innerHTML: tempData['msg'] } }, null)
|
|
46
|
-
])
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
return Promise.reject(tempData['msg'])
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
.catch(reason => Promise.reject(reason))
|
|
53
|
-
}
|
|
54
|
-
return response;
|
|
55
|
-
}
|
|
56
|
-
if (res.status === 200 || res.code === 200) {
|
|
57
|
-
return response.data
|
|
58
|
-
}
|
|
59
|
-
if (res.code == 60001) {
|
|
60
|
-
return new Promise(() => {
|
|
61
|
-
let inputVal = '';
|
|
62
|
-
Modal.info({
|
|
63
|
-
zIndex: 3100,
|
|
64
|
-
title: '授权',
|
|
65
|
-
okText: '授权',
|
|
66
|
-
destroyOnClose: true,
|
|
67
|
-
keyboard: true,
|
|
68
|
-
closable: true,
|
|
69
|
-
content: h => {
|
|
70
|
-
return h('div', null, [
|
|
71
|
-
h(Input, {
|
|
72
|
-
attrs: {
|
|
73
|
-
type: 'text',
|
|
74
|
-
placeholder: "请输入许可",
|
|
75
|
-
},
|
|
76
|
-
on: {
|
|
77
|
-
input: event => {
|
|
78
|
-
inputVal = event.target.value;
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
}),
|
|
82
|
-
]);
|
|
83
|
-
},
|
|
84
|
-
async onOk() {
|
|
85
|
-
try {
|
|
86
|
-
let data = {
|
|
87
|
-
system: store.state.webAppCode,
|
|
88
|
-
license: inputVal
|
|
89
|
-
}
|
|
90
|
-
let info = await licenseAuthorizeApi(data)
|
|
91
|
-
Modal.success({
|
|
92
|
-
zIndex: 4000,
|
|
93
|
-
title: '验证成功',
|
|
94
|
-
content: h => {
|
|
95
|
-
return h('div', null, [
|
|
96
|
-
h('div', null, `许可有效期至:${info.content}`),
|
|
97
|
-
]);
|
|
98
|
-
},
|
|
99
|
-
onOk() {
|
|
100
|
-
// 返回控制台并清空全部标签页
|
|
101
|
-
store.dispatch('goWorkbench')
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
Modal.error({
|
|
107
|
-
zIndex: 4000,
|
|
108
|
-
title: '错误信息',
|
|
109
|
-
destroyOnClose: true,
|
|
110
|
-
keyboard: true,
|
|
111
|
-
content: h => {
|
|
112
|
-
return h('div', null, [
|
|
113
|
-
h('div', null, error),
|
|
114
|
-
]);
|
|
115
|
-
},
|
|
116
|
-
})
|
|
117
|
-
return Promise.reject(error)
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
onCancel() {
|
|
121
|
-
// 返回控制台并清空全部标签页
|
|
122
|
-
store.dispatch('goWorkbench')
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
if (res.status === undefined && res.code === undefined) {
|
|
128
|
-
return response.data
|
|
129
|
-
}
|
|
130
|
-
if (res.code === 401) {
|
|
131
|
-
store.dispatch('logOut')
|
|
132
|
-
return Promise.reject(res.msg)
|
|
133
|
-
}
|
|
134
|
-
// 如果是授权接口报的错,不通过通用错误显示
|
|
135
|
-
if (response.config.url.indexOf('licenseAuthorize') == -1) {
|
|
136
|
-
notification.error({
|
|
137
|
-
message: '错误信息',
|
|
138
|
-
top:"100px",
|
|
139
|
-
description: h => {
|
|
140
|
-
return h('div', null, [
|
|
141
|
-
h('p', { domProps: { innerHTML: res.msg } }, null)
|
|
142
|
-
])
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
return Promise.reject(res.msg)
|
|
147
|
-
},
|
|
148
|
-
error => {
|
|
149
|
-
if (error.response && error.response.status === 401) {
|
|
150
|
-
// alert('会话过期1');
|
|
151
|
-
store.dispatch('logOut').then(() => {})
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
let errorMsg = ''
|
|
155
|
-
if (error.response && error.response.data && error.response.data.error) {
|
|
156
|
-
if (error.response.data.error_description) {
|
|
157
|
-
errorMsg = error.response.data.error_description
|
|
158
|
-
} else {
|
|
159
|
-
errorMsg = error.response.data.error
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
errorMsg = error.msg
|
|
163
|
-
}
|
|
164
|
-
notification['error']({ message: '错误信息', description: errorMsg, top:"100px" })
|
|
165
|
-
return Promise.reject(error)
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
export default service
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import { licenseAuthorizeApi } from './api'
|
|
3
|
+
import { notification, message, Modal, Input } from 'ant-design-vue'
|
|
4
|
+
import Vue from 'vue'
|
|
5
|
+
import store from './store'
|
|
6
|
+
import moment from 'moment'
|
|
7
|
+
// create an axios instance
|
|
8
|
+
const service = axios.create({
|
|
9
|
+
// baseURL: process.env.BASE_API, // api的base_url
|
|
10
|
+
timeout: 1000 * 60 * 5 // request timeout
|
|
11
|
+
})
|
|
12
|
+
// request interceptor
|
|
13
|
+
service.interceptors.request.use(
|
|
14
|
+
config => {
|
|
15
|
+
// Do something before request is sent
|
|
16
|
+
let tempToken = store.state.token
|
|
17
|
+
if (tempToken) {
|
|
18
|
+
config.headers.Authorization = `Bearer ${tempToken}`
|
|
19
|
+
}
|
|
20
|
+
// config.headers.Accept = 'application/json,Date, text/plain, */*'
|
|
21
|
+
return config
|
|
22
|
+
},
|
|
23
|
+
error => {
|
|
24
|
+
// Do something with request error
|
|
25
|
+
Promise.reject(error)
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
// respone interceptor
|
|
30
|
+
service.interceptors.response.use(
|
|
31
|
+
async response => {
|
|
32
|
+
const res = response.data
|
|
33
|
+
// 导出文件进入判断
|
|
34
|
+
if (res instanceof Blob) {
|
|
35
|
+
if (res.type === 'application/json') {
|
|
36
|
+
const enc = await new TextDecoder('utf-8');
|
|
37
|
+
await res.arrayBuffer().then((buffer) => {
|
|
38
|
+
const tempData = JSON.parse(enc.decode(new Uint8Array(buffer))) || {};
|
|
39
|
+
if (tempData['code'] && tempData['code'] === 500) {
|
|
40
|
+
notification.error({
|
|
41
|
+
message: '错误信息',
|
|
42
|
+
top:"100px",
|
|
43
|
+
description: h => {
|
|
44
|
+
return h('div', null, [
|
|
45
|
+
h('p', { domProps: { innerHTML: tempData['msg'] } }, null)
|
|
46
|
+
])
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
return Promise.reject(tempData['msg'])
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.catch(reason => Promise.reject(reason))
|
|
53
|
+
}
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
if (res.status === 200 || res.code === 200) {
|
|
57
|
+
return response.data
|
|
58
|
+
}
|
|
59
|
+
if (res.code == 60001) {
|
|
60
|
+
return new Promise(() => {
|
|
61
|
+
let inputVal = '';
|
|
62
|
+
Modal.info({
|
|
63
|
+
zIndex: 3100,
|
|
64
|
+
title: '授权',
|
|
65
|
+
okText: '授权',
|
|
66
|
+
destroyOnClose: true,
|
|
67
|
+
keyboard: true,
|
|
68
|
+
closable: true,
|
|
69
|
+
content: h => {
|
|
70
|
+
return h('div', null, [
|
|
71
|
+
h(Input, {
|
|
72
|
+
attrs: {
|
|
73
|
+
type: 'text',
|
|
74
|
+
placeholder: "请输入许可",
|
|
75
|
+
},
|
|
76
|
+
on: {
|
|
77
|
+
input: event => {
|
|
78
|
+
inputVal = event.target.value;
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
83
|
+
},
|
|
84
|
+
async onOk() {
|
|
85
|
+
try {
|
|
86
|
+
let data = {
|
|
87
|
+
system: store.state.webAppCode,
|
|
88
|
+
license: inputVal
|
|
89
|
+
}
|
|
90
|
+
let info = await licenseAuthorizeApi(data)
|
|
91
|
+
Modal.success({
|
|
92
|
+
zIndex: 4000,
|
|
93
|
+
title: '验证成功',
|
|
94
|
+
content: h => {
|
|
95
|
+
return h('div', null, [
|
|
96
|
+
h('div', null, `许可有效期至:${info.content}`),
|
|
97
|
+
]);
|
|
98
|
+
},
|
|
99
|
+
onOk() {
|
|
100
|
+
// 返回控制台并清空全部标签页
|
|
101
|
+
store.dispatch('goWorkbench')
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
Modal.error({
|
|
107
|
+
zIndex: 4000,
|
|
108
|
+
title: '错误信息',
|
|
109
|
+
destroyOnClose: true,
|
|
110
|
+
keyboard: true,
|
|
111
|
+
content: h => {
|
|
112
|
+
return h('div', null, [
|
|
113
|
+
h('div', null, error),
|
|
114
|
+
]);
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
return Promise.reject(error)
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
onCancel() {
|
|
121
|
+
// 返回控制台并清空全部标签页
|
|
122
|
+
store.dispatch('goWorkbench')
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
if (res.status === undefined && res.code === undefined) {
|
|
128
|
+
return response.data
|
|
129
|
+
}
|
|
130
|
+
if (res.code === 401) {
|
|
131
|
+
store.dispatch('logOut')
|
|
132
|
+
return Promise.reject(res.msg)
|
|
133
|
+
}
|
|
134
|
+
// 如果是授权接口报的错,不通过通用错误显示
|
|
135
|
+
if (response.config.url.indexOf('licenseAuthorize') == -1) {
|
|
136
|
+
notification.error({
|
|
137
|
+
message: '错误信息',
|
|
138
|
+
top:"100px",
|
|
139
|
+
description: h => {
|
|
140
|
+
return h('div', null, [
|
|
141
|
+
h('p', { domProps: { innerHTML: res.msg } }, null)
|
|
142
|
+
])
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
return Promise.reject(res.msg)
|
|
147
|
+
},
|
|
148
|
+
error => {
|
|
149
|
+
if (error.response && error.response.status === 401) {
|
|
150
|
+
// alert('会话过期1');
|
|
151
|
+
store.dispatch('logOut').then(() => {})
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
let errorMsg = ''
|
|
155
|
+
if (error.response && error.response.data && error.response.data.error) {
|
|
156
|
+
if (error.response.data.error_description) {
|
|
157
|
+
errorMsg = error.response.data.error_description
|
|
158
|
+
} else {
|
|
159
|
+
errorMsg = error.response.data.error
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
errorMsg = error.msg
|
|
163
|
+
}
|
|
164
|
+
notification['error']({ message: '错误信息', description: errorMsg, top:"100px" })
|
|
165
|
+
return Promise.reject(error)
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
export default service
|