affairModels.js 8.1 KB
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5
/**
 * 徐立
 * 2019年9月20日
 * 事务相关接口
 */
6
import { uaaRequest } from '../utils/request';
7 8
import prepareShow from "@/webPublic/one_stop_public/Table/prepareShow";
import {deepCopy} from "@/webPublic/one_stop_public/utils/myutils";
9
import { getHistoryFormDetail } from '@/webPublic/Services';
chscls@163.com's avatar
chscls@163.com committed
10

徐立's avatar
徐立 committed
11 12
const api = '/UnifiedAppFormApi';
const myCollect = {
13 14 15 16
	namespace: 'affair',
	state: {
		user: {}, // 用户数据
		todoListApps: [],
17
    todoListMessage: [],
18
    goBackInfo: {},
19 20 21 22
    pageInfo: {
		  totalPage: 1,
      total: 0,
    },
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
	},
	effects: {
		/**
		 * 获取待办分页
		 * @param {pageSize} 每页大小
		 * @param {appId} 应用id
		 * @param {pageNo} 页码
		 */
		*getBacklog({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/getWaitPage`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			} else {
				const appIds = new Set();
				response?.rows?.map((x) => {
					appIds.add(x.appId);
					return null;
				});
				yield put({
					type: 'todoList',
					payload: {
						todoListApps: Array.from(appIds),
					},
				});
50 51 52 53 54
        yield put({
          type: 'todoInfo',
          payload: {
            todoListMessage: response,
          },
55 56 57 58 59 60 61
        });
        yield put({
          type: 'savePageInfo',
          payload: {
            totalPage: Number(response.totalPage),
            total: Number(response.total),
          },
62
        });
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
			}
			if (callback && typeof callback === 'function') {
				callback(response);
			}
		},
		/**
		 * 获取已办分页
		 * @param {pageSize} 每页大小
		 * @param {appId} 应用id
		 * @param {pageNo} 页码
		 */
		*getHaveDone({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/getHandledPage`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
82 83 84 85 86 87 88
      yield put({
        type: 'savePageInfo',
        payload: {
          totalPage: Number(response.totalPage),
          total: Number(response.total),
        },
      });
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 获取草稿分页
		 * @param {pageSize} 每页大小
		 * @param {appId} 应用id
		 * @param {pageNo} 页码
		 */
		*getDraft({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/getDraftPage`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
107 108 109 110 111 112 113
      yield put({
        type: 'savePageInfo',
        payload: {
          totalPage: Number(response.totalPage),
          total: Number(response.total),
        },
      });
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 获取申请分页
		 * @param {pageSize} 每页大小
		 * @param {appId} 应用id
		 * @param {pageNo} 页码
		 */
		*getApply({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/getApplyPage`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
132 133 134 135 136 137 138
      yield put({
        type: 'savePageInfo',
        payload: {
          totalPage: Number(response.totalPage),
          total: Number(response.total),
        },
      });
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
			if (callback) {
				callback(response);
			}
		},
		*getData({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/getData`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 审批流程
		 * @param {taskId} 任务id
		 * @param {examineMap} 审核内容
		 */
		*getExamineProcess({ payload, callback }, { call, put }) {
161
			let response = yield call(uaaRequest, `${api}/examineProcess`, {
162 163
				...payload,
			});
164

165 166 167 168 169 170 171 172 173 174 175 176 177
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 根据id获得表单详情
		 * @param {id} 表单id
		 */
		*getIdFormDetail({ payload, callback }, { call, put }) {
178
			const response = yield call(getHistoryFormDetail, {
179 180 181 182 183 184
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
185

186
      yield call(prepareShow, deepCopy(response)); // prepareShow( // 执行templateWillMount公式
187
			if (callback) {
188
				callback(window.smartFormGlobalProps.data);
189 190
			}
		},
钟是志's avatar
钟是志 committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204

    //26708 学生事务/请假管理/请假申请,202002050943 辅导员在手机端填写的审批原因 在这个表中没有体现出来
    *getIdFormDetailNoNeedShowForm({ payload, callback }, { call, put }) {
      const response = yield call(getHistoryFormDetail, {
        ...payload,
      });
      if (response == null) {
        yield put({ type: 'nom' });
        return;
      }
      if (callback) {
        callback(response);
      }
    },
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
		/**
		 * 删除草稿
		 * @param {ids } 表单ids
		 */
		*removeDraft({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/removeDraft`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 撤销流程
		 * @param {id} 表单id
		 */
		*revokeProcess({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/revokeProcess`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 保存或修改草稿
		 * @param {appId} 应用id
		 * @param {id} 表单id
		 * @param {content} 表单内容
		 * @param {title} 表单标题
		 */
		*saveDraft({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/saveDraft`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 发起流程
		 * @param {appId} 应用id
		 * @param {id} 表单id
		 * @param {content} 表单内容
		 * @param {title} 表单标题
		 */
		*startProcess({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/startProcess`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		*startProcessByService({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/startProcessByService`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		*getHandleUser({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/getHandleUser`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 获取应用列表字段信息
		 * @param {id} 表单id
		 */
		*getFormTitle({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/getFormTitle`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
		/**
		 * 获取数据字段
		 * @param payload
		 * @param callback
		 * @param call
		 * @param put
		 * @returns {IterableIterator<*>}
		 */
		*getDataTitle({ payload, callback }, { call, put }) {
			const response = yield call(uaaRequest, `${api}/getDataTitle`, {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			if (callback) {
				callback(response);
			}
		},
	},
	reducers: {
		nom(state, action) {
			return { ...state };
		},
340 341 342 343 344 345
    todoInfo(state, { payload } ) {
		  return {
		    ...state,
        todoListMessage: payload.todoListMessage,
      }
    },
346 347 348 349 350 351
		todoList(state, { payload }) {
			return {
				...state,
				todoListApps: payload.todoListApps,
			};
		},
352 353 354 355 356
    saveGoBack(state, { payload }) {
      return {
        ...state,
        goBackInfo: payload,
      };
357 358 359 360 361 362
    },
    savePageInfo(state, { payload }) {
      return {
        ...state,
        pageInfo: payload,
      };
363
    },
364
	},
徐立's avatar
徐立 committed
365 366
};
export default myCollect;