publicApiService.js 5.5 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';
11
import prepareShow from '@/webPublic/one_stop_public/Table/prepareShow';
王绍森's avatar
王绍森 committed
12 13

const giveValue = (x) => {
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
	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
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);
	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 59 60 61 62 63 64 65 66 67 68 69
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;
}


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

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

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

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

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

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

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

152 153 154 155 156 157 158 159 160 161 162 163 164
/**
 *
 * */
const getServiceDetail = (id) => {
  return apiRequest('/UnifiedServiceApi/getDetail', { id }).then((x) => {
    if (x) {
      return x;
    } else {
      return {};
    }
  });
};

王绍森's avatar
王绍森 committed
165 166 167 168
/**
 *  发起流程
 * */
const startProcess = (info) => {
169 170 171 172 173 174 175
	return apiRequest('/UnifiedAppFormApi/startProcess', info).then((x) => {
		if (x) {
			return x;
		} else {
			return null;
		}
	});
王绍森's avatar
王绍森 committed
176 177 178 179 180 181 182 183
};

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

const getApplyPage = (info) => {
184 185 186
	return apiRequest('/UnifiedAppFormApi/getApplyPage', info).then((x) => {
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
187 188 189 190 191 192 193
};
/**
 *  查询一个流程的详情数据
 *
 * */

const getDetailInfo = (id) => {
194
  return getHistoryFormDetail({id}).then((x) => {
195 196 197 198 199 200 201
		if (x) {
			return x;
		} else {
			return null;
		}
	});
};
王绍森's avatar
王绍森 committed
202 203 204 205 206 207 208
/**
 * 待办业务
 * pageSize: 10
 * appId: 1185524814832467968
 * pageNo: 1
 * */
const getWaitPage = (info) => {
209
	return apiRequest('/UnifiedAppFormApi/getWaitPage', info).then((x) => {
210 211 212 213 214
	  if(x && x.rows){
	    for(let item of x.rows){
	      item.operationDiy = '审核';
      }
    }
215 216
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
217 218 219 220 221 222 223 224
};
/**
 * 已办业务
 * pageSize: 10
 * appId: 1185524814832467968
 * pageNo: 1
 * */
const getHandledPage = (info) => {
225 226 227
	return apiRequest('/UnifiedAppFormApi/getHandledPage', info).then((x) => {
		return giveValue(x);
	});
王绍森's avatar
王绍森 committed
228 229 230 231 232 233 234 235 236
};

/**
 * 审核接口,支持批量
 *  taskIds: 08d8d359-f7a6-11e9-9a27-0242b1fd760b
 *  examineMap: {"examine":"0","reason":"通过"}
 *  taskForm: {}
 * */
const handleAudit = (info) => {
237 238 239 240 241
	return apiRequest('/UnifiedAppFormApi/examineProcess', info).then((x) => {
		if (x) {
			return x;
		}
	});
王绍森's avatar
王绍森 committed
242 243 244
};

const handleSqlData = (info) => {
245 246 247 248 249 250 251
	return apiRequest('/DataColumnApi/getSqlData', info).then((x) => {
		if (x) {
			return x;
		} else {
			return [];
		}
	});
王绍森's avatar
王绍森 committed
252 253
};

254 255 256 257 258 259 260 261
const handleSqlfind = async (sqlKey = '') => {
	return await apiRequest('/SqlManageEntityApi/find', { sqlKey }).then((x) => {
		if (x) {
			return x;
		} else {
			return null;
		}
	});
王绍森's avatar
王绍森 committed
262 263 264
};

export {
265 266 267 268
	getId,
	getColumns,
	getPages,
	getFormDetail,
269
  getServiceDetail,
270
	getOptions,
271
	getBatchOptions,
272 273 274 275 276 277 278 279 280 281
	startProcess,
	getApplyPage,
	getDetailInfo,
	getWaitPage,
	getHandledPage,
	handleAudit,
	handleSqlData,
	handleSqlfind,
	getSqlOptions,
	getHead,
282
	getGroupList,
283
  findListTaskDefinition,
王绍森's avatar
王绍森 committed
284
};