th_oa_repository.dart 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. import 'package:domain/entity/response/t_h_o_a_attachment_entity.dart';
  2. import 'package:domain/entity/response/t_h_o_a_labour_detail_entity.dart';
  3. import 'package:domain/entity/response/t_h_o_a_labour_review_table_entity.dart';
  4. import 'package:domain/entity/response/t_h_o_a_labour_table_entity.dart';
  5. import 'package:domain/entity/response/t_h_upload_file_entity.dart';
  6. import 'package:get/get.dart';
  7. import 'package:plugin_platform/http/http_provider.dart';
  8. import 'package:plugin_platform/http/http_result.dart';
  9. import 'package:plugin_platform/platform_export.dart';
  10. import 'package:shared/utils/util.dart';
  11. import '../constants/api_constants.dart';
  12. import '../entity/response/labour_request_index_entity.dart';
  13. import '../entity/response/labour_request_work_flow_entity.dart';
  14. import '../entity/response/labour_review_status_entity.dart';
  15. /// 泰国的 OA 的数据仓库
  16. class THOARepository extends GetxService {
  17. HttpProvider httpProvider;
  18. THOARepository({required this.httpProvider});
  19. /// 获取OA用工请求的筛选选项
  20. Future<HttpResult<LabourRequestIndexEntity>> fetchLabourRequestIndex({
  21. CancelToken? cancelToken,
  22. }) async {
  23. final result = await httpProvider.requestNetResult(
  24. ApiConstants.apiOALabourRequestOptionTH,
  25. cancelToken: cancelToken,
  26. );
  27. //根据返回的结果,封装原始数据为Bean/Entity对象
  28. if (result.isSuccess) {
  29. //重新赋值data或list
  30. final json = result.getDataJson();
  31. var data = LabourRequestIndexEntity.fromJson(json!);
  32. //重新赋值data或list
  33. return result.convert<LabourRequestIndexEntity>(data: data);
  34. }
  35. return result.convert();
  36. }
  37. /// 获取OA用工请求的列表
  38. Future<HttpResult<THOALabourTableEntity>> fetchLabourRequestTable({
  39. required int curPage,
  40. String? divisionId,
  41. String? outletId,
  42. String? status,
  43. String? startDate,
  44. String? endDate,
  45. CancelToken? cancelToken,
  46. }) async {
  47. Map<String, String> params = {};
  48. params['cur_page'] = curPage.toString();
  49. params['cur_page'] = curPage.toString();
  50. if (Utils.isNotEmpty(divisionId)) {
  51. params['division_id'] = divisionId!;
  52. }
  53. if (Utils.isNotEmpty(outletId)) {
  54. params['outlet_id'] = outletId!;
  55. }
  56. if (Utils.isNotEmpty(status)) {
  57. params['status'] = status!;
  58. }
  59. if (Utils.isNotEmpty(startDate)) {
  60. params['start_date'] = startDate!;
  61. }
  62. if (Utils.isNotEmpty(endDate)) {
  63. params['end_date'] = endDate!;
  64. }
  65. final result = await httpProvider.requestNetResult(
  66. ApiConstants.apiOALabourRequestTableTH,
  67. params: params,
  68. cancelToken: cancelToken,
  69. );
  70. if (result.isSuccess) {
  71. final json = result.getDataJson();
  72. var data = THOALabourTableEntity.fromJson(json!);
  73. return result.convert<THOALabourTableEntity>(data: data);
  74. }
  75. return result.convert();
  76. }
  77. /// 根据ID获取主列表的Item数据,用于刷新Item
  78. Future<HttpResult<THOALabourTableEntity>> fetchItemByRequestId(
  79. String? requestId, {
  80. CancelToken? cancelToken,
  81. }) async {
  82. //参数
  83. Map<String, String> params = {};
  84. params["cur_page"] = "1";
  85. params["page_size"] = "1";
  86. if (!Utils.isEmpty(requestId)) {
  87. params["request_id"] = requestId!;
  88. }
  89. final result = await httpProvider.requestNetResult(
  90. ApiConstants.apiOALabourRequestTableTH,
  91. params: params,
  92. isShowLoadingDialog: true,
  93. cancelToken: cancelToken,
  94. );
  95. if (result.isSuccess) {
  96. final json = result.getDataJson();
  97. var data = THOALabourTableEntity.fromJson(json!);
  98. return result.convert<THOALabourTableEntity>(data: data);
  99. }
  100. return result.convert();
  101. }
  102. /// 撤回用工请求
  103. Future<HttpResult> recallLabourRequest(
  104. String? requestId, {
  105. CancelToken? cancelToken,
  106. }) async {
  107. //参数
  108. Map<String, String> params = {};
  109. params['request_id'] = requestId ?? "";
  110. final result = await httpProvider.requestNetResult(
  111. ApiConstants.apiOALabourRequestRecallTH,
  112. method: HttpMethod.POST,
  113. params: params,
  114. networkDebounce: true,
  115. isShowLoadingDialog: true,
  116. cancelToken: cancelToken,
  117. );
  118. if (result.isSuccess) {
  119. return result.convert();
  120. }
  121. return result.convert();
  122. }
  123. /// 删除用工请求
  124. Future<HttpResult> deleteLabourRequest(
  125. String? requestId, {
  126. CancelToken? cancelToken,
  127. }) async {
  128. //参数
  129. Map<String, String> params = {};
  130. params['request_id'] = requestId ?? "";
  131. final result = await httpProvider.requestNetResult(
  132. ApiConstants.apiOALabourRequestDeleteTH,
  133. method: HttpMethod.POST,
  134. params: params,
  135. networkDebounce: true,
  136. isShowLoadingDialog: true,
  137. cancelToken: cancelToken,
  138. );
  139. if (result.isSuccess) {
  140. return result.convert();
  141. }
  142. return result.convert();
  143. }
  144. /// 用工的审核详情工作流列表
  145. Future<HttpResult<LabourRequestWorkFlowEntity>> fetchLabourRequestWorkFlow(
  146. String? requestId, {
  147. CancelToken? cancelToken,
  148. }) async {
  149. //参数
  150. Map<String, String> params = {};
  151. if (!Utils.isEmpty(requestId)) {
  152. params["request_id"] = requestId!;
  153. }
  154. final result = await httpProvider.requestNetResult(
  155. ApiConstants.apiOALabourRequestWorkflowTH,
  156. params: params,
  157. cancelToken: cancelToken,
  158. );
  159. if (result.isSuccess) {
  160. final json = result.getDataJson();
  161. var data = LabourRequestWorkFlowEntity.fromJson(json!);
  162. return result.convert<LabourRequestWorkFlowEntity>(data: data);
  163. }
  164. return result.convert();
  165. }
  166. /// 用工请求 Add Option
  167. Future<HttpResult<THOALabourDetailEntity>> fetchLabourRequestAddOption({
  168. CancelToken? cancelToken,
  169. }) async {
  170. final result = await httpProvider.requestNetResult(
  171. ApiConstants.apiOALabourRequestAddOptionTH,
  172. isShowLoadingDialog: true,
  173. cancelToken: cancelToken,
  174. );
  175. if (result.isSuccess) {
  176. final json = result.getDataJson();
  177. var data = THOALabourDetailEntity.fromJson(json!);
  178. return result.convert<THOALabourDetailEntity>(data: data);
  179. }
  180. return result.convert();
  181. }
  182. /// 用工请求 Edit Detail
  183. Future<HttpResult<THOALabourDetailEntity>> fetchLabourRequestEditDetail(
  184. String? requestId, {
  185. CancelToken? cancelToken,
  186. }) async {
  187. //参数
  188. Map<String, String> params = {};
  189. params['request_id'] = requestId ?? "";
  190. final result = await httpProvider.requestNetResult(
  191. ApiConstants.apiOALabourRequestDetailTH,
  192. params: params,
  193. isShowLoadingDialog: true,
  194. cancelToken: cancelToken,
  195. );
  196. if (result.isSuccess) {
  197. final json = result.getDataJson();
  198. var data = THOALabourDetailEntity.fromJson(json!);
  199. return result.convert<THOALabourDetailEntity>(data: data);
  200. }
  201. return result.convert();
  202. }
  203. /// 添加用工请求提交
  204. Future<HttpResult> addLabourRequestSubmit({
  205. required String? jobTitleId,
  206. required String? startTime,
  207. required String? endTime,
  208. String? repeatStart,
  209. String? repeatEnd,
  210. required String? outletId,
  211. int? sexLimit,
  212. String? needNum,
  213. String? maleLimit,
  214. String? femaleLimit,
  215. String? description,
  216. String? employmentType,
  217. String? eventName,
  218. String? eventType,
  219. String? passengers,
  220. String? estRevenue,
  221. String? position,
  222. String? estCost,
  223. String? attUrl,
  224. CancelToken? cancelToken,
  225. }) async {
  226. //参数
  227. Map<String, String> params = {};
  228. params['job_title_id'] = jobTitleId ?? "";
  229. params['start_time'] = startTime ?? "";
  230. params['end_time'] = endTime ?? "";
  231. params['outlet_id'] = outletId ?? "";
  232. params['repeat_start'] = repeatStart ?? "";
  233. params['repeat_end'] = repeatEnd ?? "";
  234. params['sex_limit'] = sexLimit?.toString() ?? "0";
  235. if (sexLimit == 1) {
  236. params['male_limit'] = maleLimit ?? "0";
  237. params['female_limit'] = femaleLimit ?? "0";
  238. } else {
  239. params['need_num'] = needNum ?? "0";
  240. }
  241. params['description'] = description ?? "";
  242. params['employment_type'] = employmentType ?? "";
  243. params['event_name'] = eventName ?? "";
  244. params['event_type'] = eventType ?? "";
  245. params['passengers'] = passengers ?? "";
  246. params['est_revenue'] = estRevenue ?? "";
  247. params['position'] = position ?? "";
  248. params['est_cost'] = estCost ?? "";
  249. params['att_url'] = attUrl ?? "";
  250. final result = await httpProvider.requestNetResult(
  251. ApiConstants.apiOALabourRequestAddSubmitTH,
  252. method: HttpMethod.POST,
  253. params: params,
  254. networkDebounce: true,
  255. isShowLoadingDialog: true,
  256. cancelToken: cancelToken,
  257. );
  258. if (result.isSuccess) {
  259. return result.convert();
  260. }
  261. return result.convert();
  262. }
  263. /// 编辑用工请求提交
  264. Future<HttpResult> editLabourRequestSubmit({
  265. required bool isReviewEdit,
  266. required String? requestId,
  267. required String? jobTitleId,
  268. required String? startTime,
  269. required String? endTime,
  270. String? repeatStart,
  271. String? repeatEnd,
  272. required String? outletId,
  273. int? sexLimit,
  274. String? needNum,
  275. String? maleLimit,
  276. String? femaleLimit,
  277. String? description,
  278. String? employmentType,
  279. String? eventName,
  280. String? eventType,
  281. String? passengers,
  282. String? estRevenue,
  283. String? position,
  284. String? estCost,
  285. CancelToken? cancelToken,
  286. }) async {
  287. //参数
  288. Map<String, String> params = {};
  289. params['request_id'] = requestId ?? "";
  290. params['job_title_id'] = jobTitleId ?? "";
  291. params['start_time'] = startTime ?? "";
  292. params['end_time'] = endTime ?? "";
  293. params['outlet_id'] = outletId ?? "";
  294. params['repeat_start'] = repeatStart ?? "";
  295. params['repeat_end'] = repeatEnd ?? "";
  296. params['sex_limit'] = sexLimit?.toString() ?? "0";
  297. if (sexLimit == 1) {
  298. params['male_limit'] = maleLimit ?? "0";
  299. params['female_limit'] = femaleLimit ?? "0";
  300. } else {
  301. params['need_num'] = needNum ?? "0";
  302. }
  303. params['description'] = description ?? "";
  304. params['employment_type'] = employmentType ?? "";
  305. params['event_name'] = eventName ?? "";
  306. params['event_type'] = eventType ?? "";
  307. params['passengers'] = passengers ?? "";
  308. params['est_revenue'] = estRevenue ?? "";
  309. params['position'] = position ?? "";
  310. params['est_cost'] = estCost ?? "";
  311. final result = await httpProvider.requestNetResult(
  312. isReviewEdit ? ApiConstants.apiOALabourReviewEditSubmitTH : ApiConstants.apiOALabourRequestEditSubmitTH,
  313. method: HttpMethod.POST,
  314. params: params,
  315. networkDebounce: true,
  316. isShowLoadingDialog: true,
  317. cancelToken: cancelToken,
  318. );
  319. if (result.isSuccess) {
  320. return result.convert();
  321. }
  322. return result.convert();
  323. }
  324. /// 泰国上传文件
  325. Future<HttpResult<THUploadFileEntity>> uploadFile(
  326. String? filePath, {
  327. CancelToken? cancelToken,
  328. }) async {
  329. //参数
  330. Map<String, String> params = {};
  331. //文件
  332. Map<String, String> fileParams = {};
  333. if (Utils.isNotEmpty(filePath)) {
  334. fileParams['file'] = filePath!;
  335. }
  336. final result = await httpProvider.requestNetResult(
  337. ApiConstants.apiUploadFileTH,
  338. method: HttpMethod.POST,
  339. params: params,
  340. paths: fileParams,
  341. networkDebounce: true,
  342. isShowLoadingDialog: true,
  343. cancelToken: cancelToken,
  344. );
  345. if (result.isSuccess) {
  346. final json = result.getDataJson();
  347. var data = THUploadFileEntity.fromJson(json!);
  348. return result.convert<THUploadFileEntity>(data: data);
  349. }
  350. return result.convert();
  351. }
  352. /// OA 附件列表
  353. Future<HttpResult<THOAAttachmentEntity>> fetchAttachmentTable({
  354. required String? requestId,
  355. required int curPage,
  356. CancelToken? cancelToken,
  357. }) async {
  358. //参数
  359. Map<String, String> params = {};
  360. params['request_id'] = requestId ?? "";
  361. params['cur_page'] = curPage.toString();
  362. params['page_size'] = "10";
  363. final result = await httpProvider.requestNetResult(
  364. ApiConstants.apiOAAttachmentListTH,
  365. params: params,
  366. cancelToken: cancelToken,
  367. );
  368. if (result.isSuccess) {
  369. final json = result.getDataJson();
  370. var data = THOAAttachmentEntity.fromJson(json!);
  371. return result.convert<THOAAttachmentEntity>(data: data);
  372. }
  373. return result.convert();
  374. }
  375. /// OA附件添加
  376. Future<HttpResult> addAttachmentSubmit({
  377. required String? requestId,
  378. required String? attUrl,
  379. CancelToken? cancelToken,
  380. }) async {
  381. //参数
  382. Map<String, String> params = {};
  383. params['request_id'] = requestId ?? "";
  384. params['att_url'] = attUrl ?? "";
  385. final result = await httpProvider.requestNetResult(
  386. ApiConstants.apiOAAttachmentAddTH,
  387. method: HttpMethod.POST,
  388. params: params,
  389. networkDebounce: true,
  390. isShowLoadingDialog: true,
  391. cancelToken: cancelToken,
  392. );
  393. if (result.isSuccess) {
  394. return result.convert();
  395. }
  396. return result.convert();
  397. }
  398. /// OA附件删除
  399. Future<HttpResult> deleteAttachmentSubmit({
  400. required String? attId,
  401. CancelToken? cancelToken,
  402. }) async {
  403. //参数
  404. Map<String, String> params = {};
  405. params['att_id'] = attId ?? "";
  406. final result = await httpProvider.requestNetResult(
  407. ApiConstants.apiOAAttachmentDeleteTH,
  408. method: HttpMethod.POST,
  409. params: params,
  410. networkDebounce: true,
  411. isShowLoadingDialog: true,
  412. cancelToken: cancelToken,
  413. );
  414. if (result.isSuccess) {
  415. return result.convert();
  416. }
  417. return result.convert();
  418. }
  419. // =================================== 用工审核 ↓ ===================================
  420. /// 用工审核选项
  421. Future<HttpResult<LabourRequestIndexEntity>> fetchLabourReviewIndex({
  422. CancelToken? cancelToken,
  423. }) async {
  424. final result = await httpProvider.requestNetResult(
  425. ApiConstants.apiOALabourReviewOptionTH,
  426. cancelToken: cancelToken,
  427. );
  428. if (result.isSuccess) {
  429. final json = result.getDataJson();
  430. var data = LabourRequestIndexEntity.fromJson(json!);
  431. return result.convert<LabourRequestIndexEntity>(data: data);
  432. }
  433. return result.convert();
  434. }
  435. /// 用工审核列表
  436. Future<HttpResult<THOALabourReviewTableEntity>> fetchLabourReviewList(
  437. String? keyword,
  438. String? startDate,
  439. String? endDate,
  440. String? outletId, {
  441. required int curPage,
  442. CancelToken? cancelToken,
  443. }) async {
  444. //参数
  445. Map<String, String> params = {};
  446. params["cur_page"] = curPage.toString();
  447. params["page_size"] = "10";
  448. if (!Utils.isEmpty(keyword)) {
  449. params["job_title"] = keyword!;
  450. }
  451. if (!Utils.isEmpty(startDate)) {
  452. params["job_start"] = startDate!;
  453. }
  454. if (!Utils.isEmpty(endDate)) {
  455. params["job_end"] = endDate!;
  456. }
  457. if (!Utils.isEmpty(outletId)) {
  458. params["outlet_id"] = outletId!;
  459. }
  460. final result = await httpProvider.requestNetResult(
  461. ApiConstants.apiOALabourReviewTableTH,
  462. params: params,
  463. cancelToken: cancelToken,
  464. );
  465. if (result.isSuccess) {
  466. final json = result.getDataJson();
  467. var data = THOALabourReviewTableEntity.fromJson(json!);
  468. return result.convert<THOALabourReviewTableEntity>(data: data);
  469. }
  470. return result.convert();
  471. }
  472. /// 根据ID获取主列表的Item数据,用于刷新审核列表Item
  473. Future<HttpResult<THOALabourReviewTableEntity>> fetchItemByRecordId(
  474. String? requestId, {
  475. CancelToken? cancelToken,
  476. }) async {
  477. //参数
  478. Map<String, String> params = {};
  479. params["cur_page"] = "1";
  480. params["page_size"] = "1";
  481. if (!Utils.isEmpty(requestId)) {
  482. params["request_id"] = requestId!;
  483. }
  484. final result = await httpProvider.requestNetResult(
  485. ApiConstants.apiOALabourReviewTableTH,
  486. params: params,
  487. isShowLoadingDialog: true,
  488. cancelToken: cancelToken,
  489. );
  490. //根据返回的结果,封装原始数据为Bean/Entity对象
  491. if (result.isSuccess) {
  492. //重新赋值data或list
  493. final json = result.getDataJson();
  494. var data = THOALabourReviewTableEntity.fromJson(json!);
  495. //重新赋值data或list
  496. return result.convert<THOALabourReviewTableEntity>(data: data);
  497. }
  498. return result.convert();
  499. }
  500. ///OA 用工审核工作流
  501. Future<HttpResult<LabourReviewStatusEntity>> fetchLabourReviewStatusView(
  502. String? orderId, {
  503. CancelToken? cancelToken,
  504. }) async {
  505. //参数
  506. Map<String, String> params = {};
  507. if (!Utils.isEmpty(orderId)) {
  508. params["order_id"] = orderId!;
  509. }
  510. final result = await httpProvider.requestNetResult(
  511. ApiConstants.apiOALabourReviewWorkflowTH,
  512. params: params,
  513. cancelToken: cancelToken,
  514. );
  515. if (result.isSuccess) {
  516. final json = result.getDataJson();
  517. var data = LabourReviewStatusEntity.fromJson(json!);
  518. return result.convert<LabourReviewStatusEntity>(data: data);
  519. }
  520. return result.convert();
  521. }
  522. /// OA用工审核的批量操作
  523. Future<HttpResult> batchActionLabourReviews({
  524. required String? recordIds,
  525. required String? type,
  526. String? auditMark,
  527. CancelToken? cancelToken,
  528. }) async {
  529. //参数
  530. Map<String, String> params = {};
  531. params['record_ids'] = recordIds ?? "";
  532. params['type'] = type ?? "";
  533. if (Utils.isNotEmpty(auditMark)){
  534. params['audit_mark'] = auditMark!;
  535. }
  536. final result = await httpProvider.requestNetResult(
  537. ApiConstants.apiOALabourReviewBatchTH,
  538. method: HttpMethod.POST,
  539. params: params,
  540. networkDebounce: true,
  541. isShowLoadingDialog: true,
  542. cancelToken: cancelToken,
  543. );
  544. if (result.isSuccess) {
  545. return result.convert();
  546. }
  547. return result.convert();
  548. }
  549. }