publicApiService.js 5.0 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
const getId = async (pathname) => {
	// 获取流程引擎 事务workId 和表dataBaseId
	let idObj = await getOneStopConfig(pathname);
	if (typeof idObj === 'undefined' || !idObj) {
		console.error('没有找到对应的流程引擎id');
		return false;
	} else {
		return {
			dataBaseId: idObj,
			workId: idObj,
		};
	}
王绍森's avatar
王绍森 committed
43 44
};

45 46 47 48 49 50 51 52
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
53 54
};

55 56 57 58 59 60 61 62 63 64 65 66 67 68
const filterHeaderColumns = (res, workId) => {
  // 27355 门户---单位个人中心,,双选会申请,,不要营业执照字段
  if(workId === '1366228504210833408' &&
    window.location.href.indexOf('/CompanyCenter') > -1 && Array.isArray(res)
  ){
    res = res.filter((g) => {
      return g.dataIndex !== 'LfKUHjglHFM';
    })
  }

  return res;
}


69 70
const getColumns = (workId) => {
	// 获取表头 workId
71 72 73
	return apiRequest('/UnifiedAppFormApi/getFormTitle', { id: workId }).then((res) => {
    return filterHeaderColumns(res, workId);
  });
王绍森's avatar
王绍森 committed
74 75
};

76 77 78 79 80
const findListTaskDefinition = (params) => {
  // 获取表头 workId
  return apiRequest('/UnifiedAppFormApi/findListTaskDefinition', params);
};

81 82 83 84
const getHead = (dataObjId) => {
	// 获取表头 workId
	return apiRequest('/DataColumnApi/getHeaderList', { dataObjId });
};
王绍森's avatar
王绍森 committed
85

86
const getGroupList = ({columnId, appId = undefined}) => {
87
	// 获取表头 workId
88
	return apiRequest('/DataColumnApi/getGroupList', { columnId, appId });
89 90
};

王绍森's avatar
王绍森 committed
91 92 93
/**
 * 获取下拉枚举值
 * */
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
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) => {
113
	return await apiRequest('/DataColumnApi/getBatchOptions', { ids });
王绍森's avatar
王绍森 committed
114 115 116 117 118
};

/**
 * 获取下拉枚举值 通过sql语句
 * */
119 120 121 122 123 124 125 126 127 128 129 130 131
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
132 133 134 135 136 137
};

/**
 * 获取发起流程填写的字段表单详情
 * */
const getFormDetail = (id) => {
138 139 140 141 142 143 144
	return apiRequest('/UnifiedAppApi/getDetail', { id }).then((x) => {
		if (x) {
			return x;
		} else {
			return {};
		}
	});
王绍森's avatar
王绍森 committed
145 146 147 148 149 150
};

/**
 *  发起流程
 * */
const startProcess = (info) => {
151 152 153 154 155 156 157
	return apiRequest('/UnifiedAppFormApi/startProcess', info).then((x) => {
		if (x) {
			return x;
		} else {
			return null;
		}
	});
王绍森's avatar
王绍森 committed
158 159 160 161 162 163 164 165
};

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

const getApplyPage = (info) => {
166 167 168
	return apiRequest('/UnifiedAppFormApi/getApplyPage', info).then((x) => {
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
169 170 171 172 173 174 175
};
/**
 *  查询一个流程的详情数据
 *
 * */

const getDetailInfo = (id) => {
176
  return getHistoryFormDetail({id}).then((x) => {
177 178 179 180 181 182 183
		if (x) {
			return x;
		} else {
			return null;
		}
	});
};
王绍森's avatar
王绍森 committed
184 185 186 187 188 189 190
/**
 * 待办业务
 * pageSize: 10
 * appId: 1185524814832467968
 * pageNo: 1
 * */
const getWaitPage = (info) => {
191 192 193
	return apiRequest('/UnifiedAppFormApi/getWaitPage', info).then((x) => {
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
194 195 196 197 198 199 200 201
};
/**
 * 已办业务
 * pageSize: 10
 * appId: 1185524814832467968
 * pageNo: 1
 * */
const getHandledPage = (info) => {
202 203 204
	return apiRequest('/UnifiedAppFormApi/getHandledPage', info).then((x) => {
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
205 206 207 208 209 210 211 212 213
};

/**
 * 审核接口,支持批量
 *  taskIds: 08d8d359-f7a6-11e9-9a27-0242b1fd760b
 *  examineMap: {"examine":"0","reason":"通过"}
 *  taskForm: {}
 * */
const handleAudit = (info) => {
214 215 216 217 218
	return apiRequest('/UnifiedAppFormApi/examineProcess', info).then((x) => {
		if (x) {
			return x;
		}
	});
王绍森's avatar
王绍森 committed
219 220 221
};

const handleSqlData = (info) => {
222 223 224 225 226 227 228
	return apiRequest('/DataColumnApi/getSqlData', info).then((x) => {
		if (x) {
			return x;
		} else {
			return [];
		}
	});
王绍森's avatar
王绍森 committed
229 230
};

231 232 233 234 235 236 237 238
const handleSqlfind = async (sqlKey = '') => {
	return await apiRequest('/SqlManageEntityApi/find', { sqlKey }).then((x) => {
		if (x) {
			return x;
		} else {
			return null;
		}
	});
王绍森's avatar
王绍森 committed
239 240 241
};

export {
242 243 244 245 246
	getId,
	getColumns,
	getPages,
	getFormDetail,
	getOptions,
247
	getBatchOptions,
248 249 250 251 252 253 254 255 256 257
	startProcess,
	getApplyPage,
	getDetailInfo,
	getWaitPage,
	getHandledPage,
	handleAudit,
	handleSqlData,
	handleSqlfind,
	getSqlOptions,
	getHead,
258
	getGroupList,
259
  findListTaskDefinition,
王绍森's avatar
王绍森 committed
260
};