提交 1f177946 authored 作者: 钟是志's avatar 钟是志

优化一站式应用获取应用id 的方法

上级 bb5e6adc
......@@ -7,7 +7,11 @@
import { uaaRequest } from './one_stop_public/utils/request';
import config from '@/config/config';
import { setOneStopActiveMenusConfig, setOneStopConfig } from '@/webPublic/zyd_public/utils/utils';
import {
getOneStopConfig,
setOneStopActiveMenusConfig,
setOneStopConfig,
} from '@/webPublic/zyd_public/utils/utils';
import { getOneStopConfigList } from '@/webPublic/one_stop_public/publicServices';
import prepareShow from '@/webPublic/one_stop_public/Table/prepareShow';
import { queryApiVersion } from '@/webPublic/one_stop_public/utils/queryConfig';
......@@ -25,16 +29,14 @@ import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils';
* @param {String} code 模板的code
*/
export const fetchTemplateByCode = (code) =>
uaaRequest('/UnifiedServicePatternApi/getDetail', { code });
uaaRequest('/UnifiedServicePatternApi/getDetail', { code });
export const fetchTemplateById = (id) =>
uaaRequest('/UnifiedAppApi/getDetail', { id })
.then((res) => {
return prepareShow(res)
.then((x) => {
return res;
});
});
uaaRequest('/UnifiedAppApi/getDetail', { id }).then((res) => {
return prepareShow(res).then((x) => {
return res;
});
});
/**
* 查询表格中某条数据
......@@ -43,18 +45,13 @@ export const fetchTemplateById = (id) =>
* @param{String} value 元数据表格中键对应的值
* @param{Bool} isBase key是否base加密过,默认传true
*/
export const fetchTableItem = ({
dataObjId,
key,
value,
isBase = true,
}) => {
return uaaRequest('/DataObjApi/getFormData', {
dataObjId,
key,
value,
isBase,
});
export const fetchTableItem = ({ dataObjId, key, value, isBase = true }) => {
return uaaRequest('/DataObjApi/getFormData', {
dataObjId,
key,
value,
isBase,
});
};
/**
......@@ -64,20 +61,14 @@ export const fetchTableItem = ({
* @param {Number} pageSize
* @param {Number} pageNo
*/
export const fetchTableData = ({
dataObjId,
query,
pageSize,
pageNo,
...other
}) => {
return uaaRequest('/DataObjApi/getFormDataPage', {
dataObjId,
query: JSON.stringify(query),
pageNo,
pageSize,
...other,
});
export const fetchTableData = ({ dataObjId, query, pageSize, pageNo, ...other }) => {
return uaaRequest('/DataObjApi/getFormDataPage', {
dataObjId,
query: JSON.stringify(query),
pageNo,
pageSize,
...other,
});
};
/**
......@@ -85,7 +76,7 @@ export const fetchTableData = ({
* @param {String} objId 元数据id
*/
export const fetchTableHeader = (objId) =>
uaaRequest('/DataColumnApi/getHeaderList', { dataObjId: objId });
uaaRequest('/DataColumnApi/getHeaderList', { dataObjId: objId });
/**
* 删除元数据中的数据
......@@ -94,11 +85,11 @@ export const fetchTableHeader = (objId) =>
* @param {String} value 主键对应的值,删除多条数据时传数组
*/
export const deleteTableItem = (objId, primaryKey, value) => {
const copyValue = Array.isArray(value) ? value.join(',') : value;
return uaaRequest('/DataObjApi/deleteFormData', {
objId,
keys: JSON.stringify({ [primaryKey]: copyValue }),
});
const copyValue = Array.isArray(value) ? value.join(',') : value;
return uaaRequest('/DataObjApi/deleteFormData', {
objId,
keys: JSON.stringify({ [primaryKey]: copyValue }),
});
};
/**
......@@ -108,18 +99,13 @@ export const deleteTableItem = (objId, primaryKey, value) => {
* @param {Bool} isAdd true是新增,false是编辑
* @param {Bool} isBase 数据是否编码过,从模板中出来的数据是编码过,默认true
*/
export const addOrEditTableItem = ({
objId,
data,
isAdd,
isBase = true,
}) => {
return uaaRequest('/DataObjApi/addFormData', {
data: JSON.stringify(data),
isAdd,
objId,
isBase,
});
export const addOrEditTableItem = ({ objId, data, isAdd, isBase = true }) => {
return uaaRequest('/DataObjApi/addFormData', {
data: JSON.stringify(data),
isAdd,
objId,
isBase,
});
};
/**
......@@ -128,45 +114,43 @@ export const addOrEditTableItem = ({
* @param {String} code 申报数据的code
*/
export const getHistoryFormDetail = (params = {}) => {
return uaaRequest('/UnifiedAppFormApi/getFormDetail', params)
.then((res) => {
if (res) {
// console.log(queryApiVersion());
if (queryApiVersion() === '2.0') { // 2.0的接口 流程日志单独获取
return api2_0_getTaskInfo(params)
.then((res2) => {
return {
...res,
...res2,
};
});
} else {
return res;
}
} else {
return null;
}
})
.then((g) => {
// console.log(g);
return g;
});
return uaaRequest('/UnifiedAppFormApi/getFormDetail', params)
.then((res) => {
if (res) {
// console.log(queryApiVersion());
if (queryApiVersion() === '2.0') {
// 2.0的接口 流程日志单独获取
return api2_0_getTaskInfo(params).then((res2) => {
return {
...res,
...res2,
};
});
} else {
return res;
}
} else {
return null;
}
})
.then((g) => {
// console.log(g);
return g;
});
};
export const api2_0_getTaskInfo = (params = {}) => {
return uaaRequest('/UnifiedAppFormApi/getFormNextUser', params)
.then((res) => {
if (res) {
return res;
} else {
return {};
}
});
return uaaRequest('/UnifiedAppFormApi/getFormNextUser', params).then((res) => {
if (res) {
return res;
} else {
return {};
}
});
};
export const getTaskDefinition = (data) => {
return uaaRequest('/UnifiedAppFormApi/getTaskDefinition', data);
return uaaRequest('/UnifiedAppFormApi/getTaskDefinition', data);
};
/**
......@@ -174,7 +158,7 @@ export const getTaskDefinition = (data) => {
* 用于授权
*/
export const getAppList = (params = {}) => {
return uaaRequest('/UnifiedAppApi/getListByTree', params);
return uaaRequest('/UnifiedAppApi/getListByTree', params);
};
/**
......@@ -182,7 +166,7 @@ export const getAppList = (params = {}) => {
* 用于一站式 应用分类列表 tree
*/
export const getAppTypeList = () => {
return uaaRequest('/UnifiedAppGroupApi/getList', {});
return uaaRequest('/UnifiedAppGroupApi/getList', {});
};
/**
......@@ -190,42 +174,46 @@ export const getAppTypeList = () => {
* 用于一站式 应用树形列表 tree
*/
export const getListByTreeList = (params = {}) => {
return uaaRequest('/UnifiedAppApi/getListByTree', params);
return uaaRequest('/UnifiedAppApi/getListByTree', params);
};
export { getOneStopMyInfo };
export function getOneStopActiveMenus(key) {
return new Promise((resolve, reject) => {
setOneStopActiveMenusConfig('');
resolve(true);
});
return new Promise((resolve, reject) => {
setOneStopActiveMenusConfig('');
resolve(true);
});
}
export function getOnestopKey(key = '', formKey = 'key_list', formValue = 'value_list') {
getOneStopActiveMenus()
.then((res) => {
});
return fetchTableData({
dataObjId: config.onestopConfigDataObjId || '1248169933162938368',
pageNo: 1,
pageSize: 5000,
})
.then((x) => {
if (x && x.rows && x.rows.length) {
const onestopConfigList = {};
for (const item of x.rows) {
onestopConfigList[item[formKey]] = item[formValue];
}
setOneStopConfig(onestopConfigList);
getOneStopConfigList();
if (key) {
return onestopConfigList[key];
}
} else {
console.error('没有配置一站式相关服务,无法使用部分功能');
return false;
}
});
getOneStopActiveMenus().then((res) => {});
if (config.getOnestopAppIdByMyPath) {
getOneStopConfigList();
if (key) {
getOneStopConfig(key);
}
} else {
return fetchTableData({
dataObjId: config.onestopConfigDataObjId || '1248169933162938368',
pageNo: 1,
pageSize: 5000,
}).then((x) => {
if (x && x.rows && x.rows.length) {
const onestopConfigList = {};
for (const item of x.rows) {
onestopConfigList[item[formKey]] = item[formValue];
}
setOneStopConfig(onestopConfigList);
getOneStopConfigList();
if (key) {
return onestopConfigList[key];
}
} else {
console.error('没有配置一站式相关服务,无法使用部分功能');
return false;
}
});
}
}
......@@ -7,98 +7,99 @@ import moment from 'moment';
import { Icon, message, notification } from 'antd';
import { getOneStopActiveMenus, getOnestopKey } from '../../Services';
import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON';
import config from '@/config/config';
import { getIconConfig } from '@/utils/authority';
let messageTime = new Date().getTime() - 3000;
export { isJSON };
/**
* 校验 开始时间必须在结束时间之前的函数
* */
export function checkDate(endTime = '2019-01-01', startTime = '2018-12-31') {
return moment(endTime)
.isAfter(moment(startTime));
return moment(endTime).isAfter(moment(startTime));
}
/**
* 去除字符串中的所有html 标签
* */
export function matchReg(str) {
let reg = /<\/?.+?\/?>/g;
return str.replace(reg, '')
.replace(/&nbsp;/g, ' ');
let reg = /<\/?.+?\/?>/g;
return str.replace(reg, '').replace(/&nbsp;/g, ' ');
}
export function htmlFormat(str) {
if (typeof str !== 'string') {
return '';
}
const newTxt = str.replace(/\s+([^<>]+)(?=<)/g, function (match) {
return match.replace(/\s/g, '&nbsp;');
});
return newTxt;
if (typeof str !== 'string') {
return '';
}
const newTxt = str.replace(/\s+([^<>]+)(?=<)/g, function(match) {
return match.replace(/\s/g, '&nbsp;');
});
return newTxt;
}
export function countSpecialField(filedSpanBig, nameSpanBig) {
let style = {};
if (document.body.clientWidth > 1400) {
if (filedSpanBig === 5) {
// 当设置一行排列5个字段时 自定义宽度为20%
style = { width: '20%' };
}
if (filedSpanBig === 1 && nameSpanBig === 2) {
// 当一行显示一个字段 然后名字又特别长时 使用这个width
style = { width: '6%' };
}
}
return style;
let style = {};
if (document.body.clientWidth > 1400) {
if (filedSpanBig === 5) {
// 当设置一行排列5个字段时 自定义宽度为20%
style = { width: '20%' };
}
if (filedSpanBig === 1 && nameSpanBig === 2) {
// 当一行显示一个字段 然后名字又特别长时 使用这个width
style = { width: '6%' };
}
}
return style;
}
/**
* 深拷贝函数
* */
export function deepCopy(obj, parent = null) {
if (React.isValidElement(obj)) {
return React.cloneElement(obj);
}
if (moment.isMoment(obj)) {
return obj.clone(obj);
}
if (['boolean', 'string', 'number'].indexOf(typeof obj) > -1 || !obj) {
return obj;
}
let result;
if (obj.constructor === Array) {
result = [];
} else {
result = {};
}
let keys = Object.keys(obj),
key = null,
temp = null,
_parent = parent;
// 该字段有父级则需要追溯该字段的父级
while (_parent) {
// 如果该字段引用了它的父级则为循环引用
if (_parent.originalParent === obj) {
// 循环引用直接返回同级的新对象
return _parent.currentParent;
}
_parent = _parent.parent;
}
for (let i = 0; i < keys.length; i++) {
key = keys[i];
temp = obj[key];
// 如果字段的值也是一个对象
if (temp && typeof temp === 'object') {
// 递归执行深拷贝 将同级的待拷贝对象与新对象传递给 parent 方便追溯循环引用
result[key] = deepCopy(temp, {
originalParent: obj,
currentParent: result,
parent: parent,
});
} else {
result[key] = temp;
}
}
return result;
if (React.isValidElement(obj)) {
return React.cloneElement(obj);
}
if (moment.isMoment(obj)) {
return obj.clone(obj);
}
if (['boolean', 'string', 'number'].indexOf(typeof obj) > -1 || !obj) {
return obj;
}
let result;
if (obj.constructor === Array) {
result = [];
} else {
result = {};
}
let keys = Object.keys(obj),
key = null,
temp = null,
_parent = parent;
// 该字段有父级则需要追溯该字段的父级
while (_parent) {
// 如果该字段引用了它的父级则为循环引用
if (_parent.originalParent === obj) {
// 循环引用直接返回同级的新对象
return _parent.currentParent;
}
_parent = _parent.parent;
}
for (let i = 0; i < keys.length; i++) {
key = keys[i];
temp = obj[key];
// 如果字段的值也是一个对象
if (temp && typeof temp === 'object') {
// 递归执行深拷贝 将同级的待拷贝对象与新对象传递给 parent 方便追溯循环引用
result[key] = deepCopy(temp, {
originalParent: obj,
currentParent: result,
parent: parent,
});
} else {
result[key] = temp;
}
}
return result;
}
/**
......@@ -109,64 +110,62 @@ export function deepCopy(obj, parent = null) {
* @returns {*|boolean}
*/
export function getFormElemValue(type, e, other) {
let value = e;
switch (type) {
case 'input':
value = e.target.value;
break;
case 'checkbox':
value = e.target.checked;
break;
case 'textarea':
value = e.target.value;
break;
case 'buttonUpload':
value = e.url;
break;
case 'upload':
value = Array.isArray(e) ? e.join(',') : '';
break;
default:
break;
}
return value;
let value = e;
switch (type) {
case 'input':
value = e.target.value;
break;
case 'checkbox':
value = e.target.checked;
break;
case 'textarea':
value = e.target.value;
break;
case 'buttonUpload':
value = e.url;
break;
case 'upload':
value = Array.isArray(e) ? e.join(',') : '';
break;
default:
break;
}
return value;
}
/**
* 生成随机字符串
* */
export function randomStr() {
return Math.random()
.toString(36)
.substr(2);
return Math.random()
.toString(36)
.substr(2);
}
export function checkMustHaveValue(configFileds, data) {
for (let item of configFileds) {
if (!data[item.key] && data[item.key] !== false && data[item.key] !== 0) {
return false;
}
}
return true;
for (let item of configFileds) {
if (!data[item.key] && data[item.key] !== false && data[item.key] !== 0) {
return false;
}
}
return true;
}
export function mustHaveValue(configFields, data) {
for (let item of configFields) {
if (!item.required) continue;
if (Array.isArray(data[item.key]) && data[item.key].length < 1) {
message.warning(`${item.name}是必填项请填写`);
return false;
}
if (!data[item.key] && data[item.key] !== false && data[item.key] !== 0) {
message.warning(`${item.name}是必填项请填写`);
return false;
}
}
return true;
for (let item of configFields) {
if (!item.required) continue;
if (Array.isArray(data[item.key]) && data[item.key].length < 1) {
message.warning(`${item.name}是必填项请填写`);
return false;
}
if (!data[item.key] && data[item.key] !== false && data[item.key] !== 0) {
message.warning(`${item.name}是必填项请填写`);
return false;
}
}
return true;
}
/**
......@@ -174,158 +173,164 @@ export function mustHaveValue(configFields, data) {
* 通过数组排序,比较临近元素
* */
export function isRepeat(ary) {
if (ary.length <= 1) {
return false;
}
let nary = ary.sort();
for (let i = 0; i < ary.length - 1; i++) {
if (nary[i] === nary[i + 1]) {
return nary[i];
// alert("数组重复内容:" + nary[i]);
}
}
return false;
if (ary.length <= 1) {
return false;
}
let nary = ary.sort();
for (let i = 0; i < ary.length - 1; i++) {
if (nary[i] === nary[i + 1]) {
return nary[i];
// alert("数组重复内容:" + nary[i]);
}
}
return false;
}
export function displayRender(label) {
if (label && label.length) {
return label[label.length - 1];
} else {
return '';
}
if (label && label.length) {
return label[label.length - 1];
} else {
return '';
}
}
export function isEmptyValue(value) {
return typeof value === 'undefined' || value === null || value === '';
return typeof value === 'undefined' || value === null || value === '';
}
// 全局的通知消息组件
export function controlNotification(props) {
const nowTime = new Date().getTime();
if (nowTime - messageTime < 3000) {
return;
}
messageTime = nowTime;
notification.info({
...props,
icon: <Icon type="info-circle" style={{ color: '#fa8c16' }}/>,
});
return true;
const nowTime = new Date().getTime();
if (nowTime - messageTime < 3000) {
return;
}
messageTime = nowTime;
notification.info({
...props,
icon: <Icon type="info-circle" style={{ color: '#fa8c16' }} />,
});
return true;
}
export function setOneStopConfig(value) {
if (typeof value !== 'string') {
value = JSON.stringify(value);
}
localStorage.setItem('oneStopConfig', value);
if (typeof value !== 'string') {
value = JSON.stringify(value);
}
localStorage.setItem('oneStopConfig', value);
}
export function getOneStopConfig(key) {
let configList = localStorage.getItem('oneStopConfig');
if (configList && isJSON(configList)) {
let data = JSON.parse(configList);
if (data && typeof data === 'object') {
if (typeof data === 'undefined') {
return '';
if (config.getOnestopAppIdByMyPath) { // 禅道 29636
try {
const allPath = getIconConfig();
if(allPath[key] && allPath[key].appId){
return allPath[key].appId;
}else{
console.error('mypath 中, 未获取到应用id', key);
return false;
}
return data[key] || false;
}
} else {
return getOnestopKey(key);
}
} catch (e) {
console.log(e);
}
}
let configList = localStorage.getItem('oneStopConfig');
if (configList && isJSON(configList)) {
let data = JSON.parse(configList);
if (data && typeof data === 'object') {
if (typeof data === 'undefined') {
return '';
}
return data[key] || false;
}
} else {
return getOnestopKey(key);
}
}
export function setOneStopActiveMenusConfig(value) {
window.oneStopActiveMenusConfig = value;
window.oneStopActiveMenusConfig = value;
}
export function getOneStopActiveMenusConfig(key) {
if (window.oneStopActiveMenusConfig && typeof window.oneStopActiveMenusConfig === 'object') {
return window.oneStopActiveMenusConfig[key] || false;
} else {
return getOneStopActiveMenus(key);
}
if (window.oneStopActiveMenusConfig && typeof window.oneStopActiveMenusConfig === 'object') {
return window.oneStopActiveMenusConfig[key] || false;
} else {
return getOneStopActiveMenus(key);
}
}
export function diGuiTree(treeData = [], i = 0) {
// for (let item of treeData) {
// if(i === 2){
// item.selectable = true;
// }
// if (item.children && item.children.length) {
// i += 1;
// diGuiTree(item.children, i);
// }
// }
return treeData;
// for (let item of treeData) {
// if(i === 2){
// item.selectable = true;
// }
// if (item.children && item.children.length) {
// i += 1;
// diGuiTree(item.children, i);
// }
// }
return treeData;
}
export { downloadFile } from './downloadFile';
// 校验密码是否符合 包含数字 字母 和特殊字符 解决 中医大的安全漏洞
export default function CheckPassWord(password = '', length = 12) {
// console.log(password);
if (!password || password.length < length) {
// message.warning("密码过于简单, 请输入不小于8位的密码 且必须包含数字和字母!");
// console.log('位数不够');
return false;
}
let cRegex = new RegExp(/.*[\u4e00-\u9fa5]+.*$/);
if (cRegex.test(password)) {
message.warning('密码中不能包含中文字符!');
return false;
}
let pwdRegex = new RegExp(`(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{${length},30}`);
if (!pwdRegex.test(password)) {
// alert("您的密码复杂度太低(密码中必须包含字母、数字、特殊字符),请及时修改密码!");
return false;
}
return true;
// console.log(password);
if (!password || password.length < length) {
// message.warning("密码过于简单, 请输入不小于8位的密码 且必须包含数字和字母!");
// console.log('位数不够');
return false;
}
let cRegex = new RegExp(/.*[\u4e00-\u9fa5]+.*$/);
if (cRegex.test(password)) {
message.warning('密码中不能包含中文字符!');
return false;
}
let pwdRegex = new RegExp(`(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{${length},30}`);
if (!pwdRegex.test(password)) {
// alert("您的密码复杂度太低(密码中必须包含字母、数字、特殊字符),请及时修改密码!");
return false;
}
return true;
}
/**
*
* 检查文本格式是否正确
* */
export function checkInputType(data, type) {
switch (type) {
case 'phone':
if (!(/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(data))) {
message.warning('手机号码格式错误!');
return false;
}
break;
case 'email':
if (!(/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(data))) {
message.warning('邮箱格式错误!');
return false;
}
break;
case 'idCard':
if (!(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(data))) {
message.warning('身份证号码格式错误!');
return false;
}
break;
default:
break;
}
return true;
switch (type) {
case 'phone':
if (!/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(data)) {
message.warning('手机号码格式错误!');
return false;
}
break;
case 'email':
if (!/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(data)) {
message.warning('邮箱格式错误!');
return false;
}
break;
case 'idCard':
if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(data)) {
message.warning('身份证号码格式错误!');
return false;
}
break;
default:
break;
}
return true;
}
export { getHeaders } from './getHeaders';
export { getIsGui_Jian, getIsBei_Dian, getIsA_Ba } from './getSchoolType';
// (function (_0x49c6e2, _0x5afabe) {
// const _0x125f6a = _0x3342,
// _0x2c1408 = _0x49c6e2();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论