publicApiService.js 4.6 KB
Newer Older
王绍森's avatar
王绍森 committed
1
/**
2
 * 事务页面。 根据事务接口。达到增删发起事务流程
王绍森's avatar
王绍森 committed
3 4 5 6 7 8
 * 2019年10月23日 09:48:13
 * 钟是志
 *
 * */

import { apiRequest } from '../request';
9
import { getOneStopConfig, isJSON } from '@/baseComponent/utils';
10
import { getHistoryFormDetail } from '@/webPublic/Services';
王绍森's avatar
王绍森 committed
11 12

const giveValue = (x) => {
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
	if (x && x.rows) {
		let res = [];
		for (let item of x.rows) {
			res.push({
				...item.hisTaskListData,
				...item,
			});
		}
		x.rows = res;
		return x;
	} else {
		return {
			rows: [],
			total: 1,
		};
	}
王绍森's avatar
王绍森 committed
29 30
};

31 32 33 34 35 36 37 38 39 40 41 42 43
const getId = async (pathname) => {
	// 获取流程引擎 事务workId 和表dataBaseId
	let idObj = await getOneStopConfig(pathname);
	console.log(idObj);
	if (typeof idObj === 'undefined' || !idObj) {
		console.error('没有找到对应的流程引擎id');
		return false;
	} else {
		return {
			dataBaseId: idObj,
			workId: idObj,
		};
	}
王绍森's avatar
王绍森 committed
44 45
};

46 47 48 49 50 51 52 53
const getPages = (info) => {
	// 获取代办事项 分页数据 workId
	// workId, pageSize, pageNo,
	if (typeof info.pageNo === 'undefined') {
		info.pageNo = 1;
		info.pageSize = 10;
	}
	return apiRequest('/UnifiedAppFormApi/getWaitPage', info);
王绍森's avatar
王绍森 committed
54 55
};

56 57 58
const getColumns = (workId) => {
	// 获取表头 workId
	return apiRequest('/UnifiedAppFormApi/getFormTitle', { id: workId });
王绍森's avatar
王绍森 committed
59 60
};

61 62 63 64 65
const findListTaskDefinition = (params) => {
  // 获取表头 workId
  return apiRequest('/UnifiedAppFormApi/findListTaskDefinition', params);
};

66 67 68 69
const getHead = (dataObjId) => {
	// 获取表头 workId
	return apiRequest('/DataColumnApi/getHeaderList', { dataObjId });
};
王绍森's avatar
王绍森 committed
70

71
const getGroupList = ({columnId, appId = undefined}) => {
72
	// 获取表头 workId
73
	return apiRequest('/DataColumnApi/getGroupList', { columnId, appId });
74 75
};

王绍森's avatar
王绍森 committed
76 77 78
/**
 * 获取下拉枚举值
 * */
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
const getOptions = async (id, filterSql = undefined, key, name) => {
	return await apiRequest('/DataColumnApi/getOptions', { id, filterSql }).then((x) => {
		if (x) {
			return x.map((y) => {
				return {
					key: y[key],
					name: y[name],
				};
			});
		} else {
			return [];
		}
	});
};

/**
 * 批量获取下拉枚举值
 * */
const getBatchOptions = async (ids) => {
98
	return await apiRequest('/DataColumnApi/getBatchOptions', { ids });
王绍森's avatar
王绍森 committed
99 100 101 102 103
};

/**
 * 获取下拉枚举值 通过sql语句
 * */
104 105 106 107 108 109 110 111 112 113 114 115 116
const getSqlOptions = async (id, sqlKey = undefined, key, name) => {
	return await apiRequest('/DataColumnApi/getSqlOptions', { id, sqlKey }).then((x) => {
		if (x) {
			return x.map((y) => {
				return {
					key: y[key],
					name: y[name],
				};
			});
		} else {
			return [];
		}
	});
王绍森's avatar
王绍森 committed
117 118 119 120 121 122
};

/**
 * 获取发起流程填写的字段表单详情
 * */
const getFormDetail = (id) => {
123 124 125 126 127 128 129
	return apiRequest('/UnifiedAppApi/getDetail', { id }).then((x) => {
		if (x) {
			return x;
		} else {
			return {};
		}
	});
王绍森's avatar
王绍森 committed
130 131 132 133 134 135
};

/**
 *  发起流程
 * */
const startProcess = (info) => {
136 137 138 139 140 141 142
	return apiRequest('/UnifiedAppFormApi/startProcess', info).then((x) => {
		if (x) {
			return x;
		} else {
			return null;
		}
	});
王绍森's avatar
王绍森 committed
143 144 145 146 147 148 149 150
};

/**
 *  查询已发起的流程的分页接口
 *
 * */

const getApplyPage = (info) => {
151 152 153
	return apiRequest('/UnifiedAppFormApi/getApplyPage', info).then((x) => {
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
154 155 156 157 158 159 160
};
/**
 *  查询一个流程的详情数据
 *
 * */

const getDetailInfo = (id) => {
161
  return getHistoryFormDetail({id}).then((x) => {
162 163 164 165 166 167 168
		if (x) {
			return x;
		} else {
			return null;
		}
	});
};
王绍森's avatar
王绍森 committed
169 170 171 172 173 174 175
/**
 * 待办业务
 * pageSize: 10
 * appId: 1185524814832467968
 * pageNo: 1
 * */
const getWaitPage = (info) => {
176 177 178
	return apiRequest('/UnifiedAppFormApi/getWaitPage', info).then((x) => {
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
179 180 181 182 183 184 185 186
};
/**
 * 已办业务
 * pageSize: 10
 * appId: 1185524814832467968
 * pageNo: 1
 * */
const getHandledPage = (info) => {
187 188 189
	return apiRequest('/UnifiedAppFormApi/getHandledPage', info).then((x) => {
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
190 191 192 193 194 195 196 197 198
};

/**
 * 审核接口,支持批量
 *  taskIds: 08d8d359-f7a6-11e9-9a27-0242b1fd760b
 *  examineMap: {"examine":"0","reason":"通过"}
 *  taskForm: {}
 * */
const handleAudit = (info) => {
199 200 201 202 203
	return apiRequest('/UnifiedAppFormApi/examineProcess', info).then((x) => {
		if (x) {
			return x;
		}
	});
王绍森's avatar
王绍森 committed
204 205 206
};

const handleSqlData = (info) => {
207 208 209 210 211 212 213
	return apiRequest('/DataColumnApi/getSqlData', info).then((x) => {
		if (x) {
			return x;
		} else {
			return [];
		}
	});
王绍森's avatar
王绍森 committed
214 215
};

216 217 218 219 220 221 222 223
const handleSqlfind = async (sqlKey = '') => {
	return await apiRequest('/SqlManageEntityApi/find', { sqlKey }).then((x) => {
		if (x) {
			return x;
		} else {
			return null;
		}
	});
王绍森's avatar
王绍森 committed
224 225 226
};

export {
227 228 229 230 231
	getId,
	getColumns,
	getPages,
	getFormDetail,
	getOptions,
232
	getBatchOptions,
233 234 235 236 237 238 239 240 241 242
	startProcess,
	getApplyPage,
	getDetailInfo,
	getWaitPage,
	getHandledPage,
	handleAudit,
	handleSqlData,
	handleSqlfind,
	getSqlOptions,
	getHead,
243
	getGroupList,
244
  findListTaskDefinition,
王绍森's avatar
王绍森 committed
245
};