uk_labour_repository.dart 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. import 'dart:io';
  2. import 'package:domain/entity/response/uk_labour_request_review_detail_entity.dart';
  3. import 'package:domain/entity/response/uk_labour_request_review_list_entity.dart';
  4. import 'package:domain/entity/server_time.dart';
  5. import 'package:get/get.dart';
  6. import 'package:plugin_platform/platform_export.dart';
  7. import 'package:plugin_platform/http/http_provider.dart';
  8. import 'package:plugin_platform/http/http_result.dart';
  9. import 'package:shared/utils/log_utils.dart';
  10. import 'package:shared/utils/util.dart';
  11. import '../constants/api_constants.dart';
  12. import '../entity/response/uk_labour_request_detail_entity.dart';
  13. import '../entity/response/uk_labour_request_preselect_addstatff_list_entity.dart';
  14. import '../entity/response/uk_labour_request_preselected_list_entity.dart';
  15. import '../entity/response/uk_labour_request_table_entity.dart';
  16. /// 用工请求相关
  17. class UkLabourRepository extends GetxService {
  18. HttpProvider httpProvider;
  19. UkLabourRepository({required this.httpProvider});
  20. /// 获取用工请求的主列表
  21. Future<HttpResult<UkLabourRequestTableEntity>> fetchLabourRequestList(
  22. String? keyword,
  23. String? startDate,
  24. String? endDate,
  25. String? statusId,
  26. String? departmentId, {
  27. required int curPage,
  28. CancelToken? cancelToken,
  29. }) async {
  30. //参数
  31. Map<String, String> params = {};
  32. params["cur_page"] = curPage.toString();
  33. params["page_size"] = "20";
  34. if (!Utils.isEmpty(keyword)) {
  35. params["job_title"] = keyword!;
  36. }
  37. if (!Utils.isEmpty(startDate)) {
  38. params["job_start"] = startDate!;
  39. }
  40. if (!Utils.isEmpty(endDate)) {
  41. params["job_end"] = endDate!;
  42. }
  43. if (!Utils.isEmpty(statusId)) {
  44. params["co_status"] = statusId!;
  45. }
  46. if (!Utils.isEmpty(departmentId)) {
  47. params["co_department_id"] = departmentId!;
  48. }
  49. final result = await httpProvider.requestNetResult(
  50. ApiConstants.apiLabourRequestList,
  51. params: params,
  52. cancelToken: cancelToken,
  53. );
  54. //根据返回的结果,封装原始数据为Bean/Entity对象
  55. if (result.isSuccess) {
  56. //重新赋值data或list
  57. final json = result.getDataJson();
  58. var data = UkLabourRequestTableEntity.fromJson(json!);
  59. //重新赋值data或list
  60. return result.convert<UkLabourRequestTableEntity>(data: data);
  61. }
  62. return result.convert();
  63. }
  64. /// 根据ID获取主列表的Item数据,用于刷新Item
  65. Future<HttpResult<UkLabourRequestTableEntity>> fetchItemByRequestId(
  66. String? requestId, {
  67. CancelToken? cancelToken,
  68. }) async {
  69. //参数
  70. Map<String, String> params = {};
  71. params["cur_page"] = "1";
  72. params["page_size"] = "1";
  73. if (!Utils.isEmpty(requestId)) {
  74. params["request_id"] = requestId!;
  75. }
  76. final result = await httpProvider.requestNetResult(
  77. ApiConstants.apiLabourRequestList,
  78. params: params,
  79. isShowLoadingDialog: true,
  80. cancelToken: cancelToken,
  81. );
  82. //根据返回的结果,封装原始数据为Bean/Entity对象
  83. if (result.isSuccess) {
  84. //重新赋值data或list
  85. final json = result.getDataJson();
  86. var data = UkLabourRequestTableEntity.fromJson(json!);
  87. //重新赋值data或list
  88. return result.convert<UkLabourRequestTableEntity>(data: data);
  89. }
  90. return result.convert();
  91. }
  92. /// 添加用工的选项
  93. Future<HttpResult<UkLabourRequestDetailEntity>> fetchLabourRequestAddOption({
  94. CancelToken? cancelToken,
  95. }) async {
  96. final result = await httpProvider.requestNetResult(
  97. ApiConstants.apiLabourRequestAddOption,
  98. isShowLoadingDialog: true,
  99. cancelToken: cancelToken,
  100. );
  101. //根据返回的结果,封装原始数据为Bean/Entity对象
  102. if (result.isSuccess) {
  103. //重新赋值data或list
  104. final json = result.getDataJson();
  105. var data = UkLabourRequestDetailEntity.fromJson(json!);
  106. //重新赋值data或list
  107. return result.convert<UkLabourRequestDetailEntity>(data: data);
  108. }
  109. return result.convert();
  110. }
  111. /// 获取labourequest 详情
  112. Future<HttpResult<UkLabourRequestDetailEntity>> fetchLabourRequestDetail(
  113. String? requestId, {
  114. CancelToken? cancelToken,
  115. }) async {
  116. //参数
  117. Map<String, String> params = {};
  118. if (!Utils.isEmpty(requestId)) {
  119. params["request_id"] = requestId!;
  120. }
  121. final result = await httpProvider.requestNetResult(
  122. ApiConstants.apiLabourRequestEditDetail,
  123. params: params,
  124. isShowLoadingDialog: true,
  125. cancelToken: cancelToken,
  126. );
  127. //根据返回的结果,封装原始数据为Bean/Entity对象
  128. if (result.isSuccess) {
  129. //重新赋值data或list
  130. final json = result.getDataJson();
  131. var data = UkLabourRequestDetailEntity.fromJson(json!);
  132. //重新赋值data或list
  133. return result.convert<UkLabourRequestDetailEntity>(data: data);
  134. }
  135. return result.convert();
  136. }
  137. /// 编辑用工请求发布
  138. Future<HttpResult> editLabourRequestSubmit({
  139. String? requestId,
  140. String? templateId,
  141. String? jobStart,
  142. String? jobEnd,
  143. String? departmentId,
  144. String? needNum,
  145. String? salaryBy,
  146. String? repeatDateStr,
  147. String? amount,
  148. String? description,
  149. String? employmentType,
  150. String? eventName,
  151. String? eventType,
  152. String? passengers,
  153. String? estRevenue,
  154. String? position,
  155. String? estCost,
  156. dynamic? attUrl,
  157. CancelToken? cancelToken,
  158. }) async {
  159. //参数
  160. Map<String, dynamic> params = {};
  161. params['request_id'] = requestId ?? "";
  162. params['template_id'] = templateId ?? "";
  163. params['job_start'] = jobStart ?? "";
  164. params['job_end'] = jobEnd ?? "";
  165. params['need_num'] = needNum ?? "";
  166. if (!Utils.isEmpty(departmentId)) {
  167. params["co_department_id"] = departmentId!;
  168. }
  169. params['salary_by'] = salaryBy ?? "";
  170. if (!Utils.isEmpty(amount)) {
  171. params["amount"] = amount!;
  172. }
  173. if(!Utils.isEmpty(repeatDateStr)) {
  174. params["select"] = repeatDateStr!;
  175. }
  176. params['description'] = description ?? "";
  177. params['employment_type'] = employmentType ?? "";
  178. params['event_name'] = eventName ?? "";
  179. params['event_type'] = eventType ?? "";
  180. params['passengers'] = passengers ?? "";
  181. params['est_revenue'] = estRevenue ?? "";
  182. params['position'] = position ?? "";
  183. params['est_cost'] = estCost ?? "";
  184. //可能是file 也可能是 url
  185. Map<String, String> filePathParams = {};
  186. // 判断 http 或者 https 开头
  187. if(Utils.isNotEmpty(attUrl)){
  188. if(attUrl!.startsWith("http") || attUrl!.startsWith("https")){
  189. params['att_url'] = attUrl;
  190. }else {
  191. filePathParams['att_url'] = attUrl;
  192. }
  193. }
  194. final result = await httpProvider.requestNetResult(
  195. ApiConstants.apiLabourRequestEditSubmit,
  196. method: HttpMethod.POST,
  197. params: params,
  198. paths: filePathParams,
  199. networkDebounce: true,
  200. isShowLoadingDialog: true,
  201. cancelToken: cancelToken,
  202. );
  203. //根据返回的结果,封装原始数据为Bean/Entity对象
  204. if (result.isSuccess) {
  205. //重新赋值data或list
  206. return result.convert();
  207. }
  208. return result.convert();
  209. }
  210. /// 新增 labourequest用工请求发布
  211. Future<HttpResult> addLabourRequestSubmit({
  212. String? templateId,
  213. String? jobDate,
  214. String? jobStart,
  215. String? jobEnd,
  216. String? departmentId,
  217. String? needNum,
  218. String? salaryBy,
  219. String? repeatDateStr,
  220. String? amount,
  221. String? jobApplyPreId,
  222. String? description,
  223. String? employmentType,
  224. String? eventName,
  225. String? eventType,
  226. String? passengers,
  227. String? estRevenue,
  228. String? position,
  229. String? estCost,
  230. dynamic? attUrl,
  231. CancelToken? cancelToken,
  232. }) async {
  233. //参数
  234. Map<String, dynamic> params = {};
  235. params['template_id'] = templateId ?? "";
  236. params['job_date'] = jobDate ?? "";
  237. params['start_time'] = jobStart ?? "";
  238. params['end_time'] = jobEnd ?? "";
  239. params['need_num'] = needNum ?? "";
  240. if (!Utils.isEmpty(departmentId)) {
  241. params["co_department_id"] = departmentId!;
  242. }
  243. params['salary_by'] = salaryBy ?? "";
  244. if(!Utils.isEmpty(repeatDateStr)){
  245. params["select"] = repeatDateStr!;
  246. }
  247. if(!Utils.isEmpty(jobApplyPreId)){
  248. params["job_apply_pre_id"] = jobApplyPreId!;
  249. }
  250. if (!Utils.isEmpty(amount)) {
  251. params["amount"] = amount!;
  252. }
  253. params['description'] = description ?? "";
  254. params['employment_type'] = employmentType ?? "";
  255. params['event_name'] = eventName ?? "";
  256. params['event_type'] = eventType ?? "";
  257. params['passengers'] = passengers ?? "";
  258. params['est_revenue'] = estRevenue ?? "";
  259. params['position'] = position ?? "";
  260. params['est_cost'] = estCost ?? "";
  261. //可能是file 也可能是 url
  262. Map<String, String> filePathParams = {};
  263. // 判断 http 或者 https 开头
  264. if(Utils.isNotEmpty(attUrl)){
  265. if(attUrl!.startsWith("http") || attUrl!.startsWith("https")){
  266. params['att_url'] = attUrl;
  267. }else {
  268. filePathParams['att_url'] = attUrl;
  269. }
  270. }
  271. final result = await httpProvider.requestNetResult(
  272. ApiConstants.apiLabourRequestAddSubmit,
  273. method: HttpMethod.POST,
  274. params: params,
  275. paths: filePathParams,
  276. networkDebounce: true,
  277. isShowLoadingDialog: true,
  278. cancelToken: cancelToken,
  279. );
  280. //根据返回的结果,封装原始数据为Bean/Entity对象
  281. if (result.isSuccess) {
  282. //重新赋值data或list
  283. return result.convert();
  284. }
  285. return result.convert();
  286. }
  287. /// 用工请求 快速复制
  288. Future<HttpResult> quickCopyLabourRequestSubmit(
  289. String? requestId,
  290. // 格式[Y-m-d]
  291. String? jobDate,
  292. //格式[H:m]
  293. String? startTime,
  294. //格式[H:m]
  295. String? endTime,
  296. {
  297. CancelToken? cancelToken,
  298. }) async {
  299. //参数
  300. Map<String, String> params = {};
  301. params['request_id'] = requestId ?? "";
  302. params['job_date'] = jobDate ?? "";
  303. params['start_time'] = startTime ?? "";
  304. params['end_time'] = endTime ?? "";
  305. final result = await httpProvider.requestNetResult(
  306. ApiConstants.apiLabourRequestQuickCopyUK,
  307. method: HttpMethod.POST,
  308. params: params,
  309. networkDebounce: true,
  310. isShowLoadingDialog: true,
  311. cancelToken: cancelToken,
  312. );
  313. //根据返回的结果,封装原始数据为Bean/Entity对象
  314. if (result.isSuccess) {
  315. //重新赋值data或list
  316. return result.convert();
  317. }
  318. return result.convert();
  319. }
  320. /// 获取 labourequest preselected 列表
  321. Future<HttpResult<UkLabourRequestPreselectedListEntity>> fetchLabourRequestPreselectedList(
  322. String reQuestId,
  323. {
  324. required int curPage,
  325. CancelToken? cancelToken,
  326. }) async {
  327. //参数
  328. Map<String, String> params = {};
  329. params["cur_page"] = curPage.toString();
  330. params["page_size"] = "20";
  331. if (!Utils.isEmpty(reQuestId)) {
  332. params["request_id"] = reQuestId;
  333. }
  334. final result = await httpProvider.requestNetResult(
  335. ApiConstants.apiLabourRequestPreSelectListUK,
  336. params: params,
  337. cancelToken: cancelToken,
  338. );
  339. //根据返回的结果,封装原始数据为Bean/Entity对象
  340. if (result.isSuccess) {
  341. //重新赋值data或list
  342. final json = result.getDataJson();
  343. var data = UkLabourRequestPreselectedListEntity.fromJson(json!);
  344. //重新赋值data或list
  345. return result.convert<UkLabourRequestPreselectedListEntity>(data: data);
  346. }
  347. return result.convert();
  348. }
  349. /// 预选人-添加员工的列表
  350. Future<HttpResult<UkLabourRequestPreselectAddstatffListEntity>> fetchtPreselectedAddStaffList(
  351. String? keyWord,
  352. String? reQuestId,
  353. {
  354. required int curPage,
  355. CancelToken? cancelToken,
  356. }) async {
  357. //参数
  358. Map<String, String> params = {};
  359. params["cur_page"] = curPage.toString();
  360. params["page_size"] = "20";
  361. if (!Utils.isEmpty(keyWord)) {
  362. params["keyword"] = keyWord!;
  363. }
  364. if (!Utils.isEmpty(reQuestId)) {
  365. params["request_id"] = reQuestId!;
  366. }
  367. final result = await httpProvider.requestNetResult(
  368. ApiConstants.apiLabourRequestPreSelectAddStaffListUK,
  369. params: params,
  370. cancelToken: cancelToken,
  371. );
  372. //根据返回的结果,封装原始数据为Bean/Entity对象
  373. if (result.isSuccess) {
  374. //重新赋值data或list
  375. final json = result.getDataJson();
  376. var data = UkLabourRequestPreselectAddstatffListEntity.fromJson(json!);
  377. //重新赋值data或list
  378. return result.convert<UkLabourRequestPreselectAddstatffListEntity>(data: data);
  379. }
  380. return result.convert();
  381. }
  382. //// 添加预选员工
  383. Future<HttpResult> labourRequestPreselectedAddStaffSubmit(
  384. String reQuestId,
  385. String staffIds,
  386. {
  387. CancelToken? cancelToken,
  388. }) async {
  389. //参数
  390. Map<String, String> params = {};
  391. params['request_id'] = reQuestId ?? "";
  392. params['staff_ids'] = staffIds ?? "";
  393. final result = await httpProvider.requestNetResult(
  394. ApiConstants.apiLabourRequestPreSelectAddBatchUK,
  395. method: HttpMethod.POST,
  396. params: params,
  397. networkDebounce: true,
  398. isShowLoadingDialog: true,
  399. cancelToken: cancelToken,
  400. );
  401. //根据返回的结果,封装原始数据为Bean/Entity对象
  402. if (result.isSuccess) {
  403. //重新赋值data或list
  404. return result.convert();
  405. }
  406. return result.convert();
  407. }
  408. /// 删除预选员工
  409. Future<HttpResult> labourRequestPreselectedDelete(
  410. String selectedId,
  411. {
  412. CancelToken? cancelToken,
  413. }) async {
  414. //参数
  415. Map<String, String> params = {};
  416. params['selected_id'] = selectedId ?? "";
  417. final result = await httpProvider.requestNetResult(
  418. ApiConstants.apiLabourRequestPreSelectDeleteUK,
  419. method: HttpMethod.POST,
  420. params: params,
  421. networkDebounce: true,
  422. isShowLoadingDialog: true,
  423. cancelToken: cancelToken,
  424. );
  425. //根据返回的结果,封装原始数据为Bean/Entity对象
  426. if (result.isSuccess) {
  427. //重新赋值data或list
  428. return result.convert();
  429. }
  430. return result.convert();
  431. }
  432. /// labourequest -review ------------
  433. /// 获取用工请求审核的主列表
  434. Future<HttpResult<UkLabourRequestReviewListEntity>> fetchLabourRequestReViewList({
  435. String? keyword,
  436. String? startDate,
  437. String? endDate,
  438. String? departmentId,
  439. required int curPage,
  440. CancelToken? cancelToken,
  441. }) async {
  442. //参数
  443. Map<String, String> params = {};
  444. params["cur_page"] = curPage.toString();
  445. params["page_size"] = "20";
  446. if (!Utils.isEmpty(keyword)) {
  447. params["job_title"] = keyword!;
  448. }
  449. if (!Utils.isEmpty(startDate)) {
  450. params["job_start"] = startDate!;
  451. }
  452. if (!Utils.isEmpty(endDate)) {
  453. params["job_end"] = endDate!;
  454. }
  455. if (!Utils.isEmpty(departmentId)) {
  456. params["co_department_id"] = departmentId!;
  457. }
  458. final result = await httpProvider.requestNetResult(
  459. ApiConstants.apiLabourRequestReViewListUK,
  460. params: params,
  461. cancelToken: cancelToken,
  462. );
  463. //根据返回的结果,封装原始数据为Bean/Entity对象
  464. if (result.isSuccess) {
  465. //重新赋值data或list
  466. final json = result.getDataJson();
  467. var data = UkLabourRequestReviewListEntity.fromJson(json!);
  468. //重新赋值data或list
  469. return result.convert<UkLabourRequestReviewListEntity>(data: data);
  470. }
  471. return result.convert();
  472. }
  473. /// labourrequest -review 编辑提交
  474. Future<HttpResult> labourRequestReviewEditSubmit(
  475. {
  476. String? requestId,
  477. String? templateId,
  478. String? location,
  479. String? jobLocationOther,
  480. String? jobStart, //开始时间 格式[Y-m-d H:i:s]
  481. String? jobEnd, //结束时间 格式[Y-m-d H:i:s]
  482. String? salaryBy,
  483. String? departmentId,
  484. String? needNum,
  485. String? amount, // service_type==1时 必填
  486. String? repeatDateStr,
  487. String? jobApplyPreId,
  488. String? description,
  489. String? employmentType,
  490. String? eventName,
  491. String? eventType,
  492. String? passengers,
  493. String? estRevenue,
  494. String? position,
  495. String? estCost,
  496. dynamic? attUrl,
  497. CancelToken? cancelToken,
  498. }) async {
  499. //参数
  500. Map<String, dynamic> params = {};
  501. params['request_id'] = requestId ?? "";
  502. params['template_id'] = templateId ?? "";
  503. params['job_start'] = jobStart ?? "";
  504. params['job_end'] = jobEnd ?? "";
  505. params['need_num'] = needNum ?? "";
  506. if (!Utils.isEmpty(departmentId)) {
  507. params["co_department_id"] = departmentId!;
  508. }
  509. params['salary_by'] = salaryBy ?? "";
  510. if (!Utils.isEmpty(amount)) {
  511. params["amount"] = amount!;
  512. }
  513. if(!Utils.isEmpty(repeatDateStr)) {
  514. params["select"] = repeatDateStr!;
  515. }
  516. params['description'] = description ?? "";
  517. params['employment_type'] = employmentType ?? "";
  518. params['event_name'] = eventName ?? "";
  519. params['event_type'] = eventType ?? "";
  520. params['passengers'] = passengers ?? "";
  521. params['est_revenue'] = estRevenue ?? "";
  522. params['position'] = position ?? "";
  523. params['est_cost'] = estCost ?? "";
  524. //可能是file 也可能是 url
  525. Map<String, String> filePathParams = {};
  526. // 判断 http 或者 https 开头
  527. if(Utils.isNotEmpty(attUrl)){
  528. if(attUrl!.startsWith("http") || attUrl!.startsWith("https")){
  529. params['att_url'] = attUrl;
  530. }else {
  531. filePathParams['att_url'] = attUrl;
  532. }
  533. }
  534. final result = await httpProvider.requestNetResult(
  535. ApiConstants.apiLabourRequestReViewEditUK,
  536. method: HttpMethod.POST,
  537. params: params,
  538. paths: filePathParams,
  539. networkDebounce: true,
  540. isShowLoadingDialog: true,
  541. cancelToken: cancelToken,
  542. );
  543. //根据返回的结果,封装原始数据为Bean/Entity对象
  544. if (result.isSuccess) {
  545. //重新赋值data或list
  546. return result.convert();
  547. }
  548. return result.convert();
  549. }
  550. /// labourrequest -review 批量审核(批量同意/批量拒绝)
  551. Future<HttpResult> labourRequestReviewBatchSubmit(
  552. {
  553. // 多个Record Ids以逗号分隔
  554. String? recordIds,
  555. // 审核类型Type【approve|reject】
  556. String? type,
  557. CancelToken? cancelToken,
  558. }) async {
  559. //参数
  560. Map<String, String> params = {};
  561. params['record_ids'] = recordIds ?? "";
  562. params['type'] = type ?? "";
  563. final result = await httpProvider.requestNetResult(
  564. ApiConstants.apiLabourRequestReViewBatchSubmitUK,
  565. method: HttpMethod.POST,
  566. params: params,
  567. networkDebounce: true,
  568. isShowLoadingDialog: true,
  569. cancelToken: cancelToken,
  570. );
  571. //根据返回的结果,封装原始数据为Bean/Entity对象
  572. if (result.isSuccess) {
  573. //重新赋值data或list
  574. return result.convert();
  575. }
  576. return result.convert();
  577. }
  578. }