Browse Source

Merge pull request #109 in DEC/decision-webui-dcm from ~ALAN/decision-webui-dcm:feature/10.0 to release/10.0

* commit '6f8343bdffecdd00cd9ce06aef4575182cc41b1e':
  undefined([object Object]):
qufenxi
alan 5 years ago
parent
commit
ce3ab9fb6e
  1. 3
      assets/scripts/dec.js
  2. 1
      i18n/zh_cn.properties
  3. 1
      private/i18n.ts
  4. 3
      src/modules/constants/env.ts
  5. 32
      src/modules/crud/crud.service.ts

3
assets/scripts/dec.js

@ -3,6 +3,9 @@ window.DecCst = {
CONNECTION_DELETED: '21300035', CONNECTION_DELETED: '21300035',
CONNECTION_UNDER_EDIT: '21300034', CONNECTION_UNDER_EDIT: '21300034',
DUPLICATE_NAMES: '21300005', DUPLICATE_NAMES: '21300005',
LOGIN_INFO_NOT_AVAILABLE: '21300014',
LOGIN_INFO_ERROR: '21300018',
TIMEOUT: '21300001',
}, },
Connect: { Connect: {
ConnectionType: { ConnectionType: {

1
i18n/zh_cn.properties

@ -111,6 +111,7 @@ Dec-Dcm_Connection_Click_Connect_Database=点击连接数据库
Dec-Dcm_Connection_Read_Mode_List=以读取模式列表 Dec-Dcm_Connection_Read_Mode_List=以读取模式列表
Dec-Dcm_Connection_NO_Connection_Pool=无数据连接,可在数据连接管理页面添加 Dec-Dcm_Connection_NO_Connection_Pool=无数据连接,可在数据连接管理页面添加
Dec-Dcm_Connection_Cannot_Too_Lang=文本长度不能大于200个字符 Dec-Dcm_Connection_Cannot_Too_Lang=文本长度不能大于200个字符
Dec-Dcm_Login_Error=登录信息已失效,请重新登录
BI-Multi_Date_Quarter_End= 季度末 BI-Multi_Date_Quarter_End= 季度末
BI-Multi_Date_Month_Begin= 月初 BI-Multi_Date_Month_Begin= 月初
BI-Multi_Date_YMD= 年月日 BI-Multi_Date_YMD= 年月日

1
private/i18n.ts

@ -110,6 +110,7 @@ export default {
'Dec-Dcm_Connection_Read_Mode_List': '以读取模式列表', 'Dec-Dcm_Connection_Read_Mode_List': '以读取模式列表',
'Dec-Dcm_Connection_NO_Connection_Pool': '无数据连接,可在数据连接管理页面添加', 'Dec-Dcm_Connection_NO_Connection_Pool': '无数据连接,可在数据连接管理页面添加',
'Dec-Dcm_Connection_Cannot_Too_Lang': '文本长度不能大于200个字符', 'Dec-Dcm_Connection_Cannot_Too_Lang': '文本长度不能大于200个字符',
'Dec-Dcm_Login_Error': '登录信息已失效,请重新登录',
'BI-Multi_Date_Quarter_End': '季度末', 'BI-Multi_Date_Quarter_End': '季度末',
'BI-Multi_Date_Month_Begin': '月初', 'BI-Multi_Date_Month_Begin': '月初',
'BI-Multi_Date_YMD': '年月日', 'BI-Multi_Date_YMD': '年月日',

3
src/modules/constants/env.ts

@ -17,4 +17,7 @@ export const errorCode: {
CONNECTION_DELETED: string; CONNECTION_DELETED: string;
CONNECTION_UNDER_EDIT: string; CONNECTION_UNDER_EDIT: string;
DUPLICATE_NAMES: string; DUPLICATE_NAMES: string;
LOGIN_INFO_NOT_AVAILABLE: string;
LOGIN_INFO_ERROR: string;
TIMEOUT: string;
} = DecCst.ErrorCode; } = DecCst.ErrorCode;

32
src/modules/crud/crud.service.ts

@ -1,7 +1,7 @@
import 'es6-promise/auto'; import 'es6-promise/auto';
import axios, { AxiosResponse, AxiosError } from 'axios'; import axios, { AxiosResponse, AxiosError } from 'axios';
import { CrudReqOpts, CrudParams, ResultType } from './crud.typings.d'; import { CrudReqOpts, CrudParams, ResultType } from './crud.typings.d';
import { ReqPrefix } from '../constants/env'; import { ReqPrefix, errorCode } from '../constants/env';
const defaultHeaders = { const defaultHeaders = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest', 'X-Requested-With': 'XMLHttpRequest',
@ -39,6 +39,26 @@ function getCookieByName(name: string):string {
return value; return value;
} }
function checkStatus(response: AxiosResponse) {
const status = response.status;
const noLoginErr = [errorCode.LOGIN_INFO_ERROR, errorCode.LOGIN_INFO_NOT_AVAILABLE, errorCode.TIMEOUT];
const resData = status === 200
? typeof response.data === 'string'
? BI.jsonDecode(response.data)
: response.data
: {};
if (noLoginErr.includes(BI.get(resData, 'errorCode'))) {
BI.Msg.alert(BI.i18nText('BI-Basic_Prompt'), BI.i18nText('Dec-Dcm_Login_Error'), () => {
window.location.reload(true);
});
return new Promise(() => {});
}
return resData;
}
export async function request(reqOptions: CrudReqOpts = {}): Promise<ResultType> { export async function request(reqOptions: CrudReqOpts = {}): Promise<ResultType> {
const { url, type, headers, data, params } = reqOptions; const { url, type, headers, data, params } = reqOptions;
@ -57,15 +77,7 @@ export async function request(reqOptions: CrudReqOpts = {}): Promise<ResultType>
paramsSerializer, paramsSerializer,
data, data,
}) })
.then((response: AxiosResponse) => { .then(checkStatus)
const status = response.status;
return status === 200
? typeof response.data === 'string'
? BI.jsonDecode(response.data)
: response.data
: {};
})
.catch((error: AxiosError) => { .catch((error: AxiosError) => {
console.log(error); console.log(error);
}); });

Loading…
Cancel
Save