labour_sg_repository.dart 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  1. import 'dart:typed_data';
  2. import 'package:domain/entity/response/job_list_edit_index_s_g_entity.dart';
  3. import 'package:domain/entity/response/job_list_index_s_g_entity.dart';
  4. import 'package:domain/entity/response/job_template_edit_index_entity.dart';
  5. import 'package:domain/entity/response/job_template_s_g_entity.dart';
  6. import 'package:domain/entity/response/job_title_edit_index_entity.dart';
  7. import 'package:domain/entity/response/job_title_s_g_entity.dart';
  8. import 'package:domain/entity/response/labour_request_s_g_add_index_entity.dart';
  9. import 'package:domain/entity/response/labour_request_s_g_entity.dart';
  10. import 'package:get/get.dart';
  11. import 'package:plugin_platform/dio_export.dart';
  12. import 'package:plugin_platform/http/http_provider.dart';
  13. import 'package:plugin_platform/http/http_result.dart';
  14. import 'package:shared/utils/util.dart';
  15. import '../constants/api_constants.dart';
  16. import '../entity/response/job_list_s_g_entity.dart';
  17. import '../entity/response/labour_request_index_entity.dart';
  18. import '../entity/response/labour_request_s_g_edit_index_entity.dart';
  19. import '../entity/response/labour_request_s_g_list_entity.dart';
  20. /// 用工相关(新加坡)
  21. class LabourSGRepository extends GetxService {
  22. HttpProvider httpProvider;
  23. LabourSGRepository({required this.httpProvider});
  24. /// 用工模版中的工作标题列表
  25. Future<HttpResult<JobTitleSGEntity>> fetchJobTitleList(
  26. String? keyword, {
  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"] = "10";
  34. if (Utils.isNotEmpty(keyword)) {
  35. params["keyword"] = keyword!;
  36. }
  37. final result = await httpProvider.requestNetResult(
  38. ApiConstants.apiJobTitleListSG,
  39. params: params,
  40. cancelToken: cancelToken,
  41. );
  42. //根据返回的结果,封装原始数据为Bean/Entity对象
  43. if (result.isSuccess) {
  44. //重新赋值data或list
  45. final json = result.getDataJson();
  46. var data = JobTitleSGEntity.fromJson(json!);
  47. //重新赋值data或list
  48. return result.convert<JobTitleSGEntity>(data: data);
  49. }
  50. return result.convert();
  51. }
  52. /// 根据ID获取主列表的Item数据,用于刷新Item
  53. Future<HttpResult<JobTitleSGEntity>> fetchJobTitleListByIds(
  54. String? ids, {
  55. CancelToken? cancelToken,
  56. }) async {
  57. //参数
  58. Map<String, String> params = {};
  59. params["cur_page"] = "1";
  60. params["page_size"] = "9999";
  61. if (!Utils.isEmpty(ids)) {
  62. params["job_title_id"] = ids!;
  63. }
  64. final result = await httpProvider.requestNetResult(
  65. ApiConstants.apiJobTitleListSG,
  66. params: params,
  67. isShowLoadingDialog: true,
  68. cancelToken: cancelToken,
  69. );
  70. //根据返回的结果,封装原始数据为Bean/Entity对象
  71. if (result.isSuccess) {
  72. //重新赋值data或list
  73. final json = result.getDataJson();
  74. var data = JobTitleSGEntity.fromJson(json!);
  75. //重新赋值data或list
  76. return result.convert<JobTitleSGEntity>(data: data);
  77. }
  78. return result.convert();
  79. }
  80. /// 添加工作标题的详情或选项数据
  81. Future<HttpResult<JobTitleEditIndexEntity>> fetchJobTitleAddIndex({
  82. CancelToken? cancelToken,
  83. }) async {
  84. final result = await httpProvider.requestNetResult(
  85. ApiConstants.apiJobTitleAddIndexSG,
  86. isShowLoadingDialog: true,
  87. cancelToken: cancelToken,
  88. );
  89. //根据返回的结果,封装原始数据为Bean/Entity对象
  90. if (result.isSuccess) {
  91. //重新赋值data或list
  92. final json = result.getDataJson();
  93. var data = JobTitleEditIndexEntity.fromJson(json!);
  94. //重新赋值data或list
  95. return result.convert<JobTitleEditIndexEntity>(data: data);
  96. }
  97. return result.convert();
  98. }
  99. /// 编辑工作标题的详情或选项数据
  100. Future<HttpResult<JobTitleEditIndexEntity>> fetchJobTitleEditIndex(
  101. String? titleId, {
  102. CancelToken? cancelToken,
  103. }) async {
  104. Map<String, String> params = {};
  105. params["title_id"] = titleId ?? "";
  106. final result = await httpProvider.requestNetResult(
  107. ApiConstants.apiJobTitleEditIndexSG,
  108. params: params,
  109. isShowLoadingDialog: true,
  110. cancelToken: cancelToken,
  111. );
  112. //根据返回的结果,封装原始数据为Bean/Entity对象
  113. if (result.isSuccess) {
  114. //重新赋值data或list
  115. final json = result.getDataJson();
  116. var data = JobTitleEditIndexEntity.fromJson(json!);
  117. //重新赋值data或list
  118. return result.convert<JobTitleEditIndexEntity>(data: data);
  119. }
  120. return result.convert();
  121. }
  122. /// 添加工作标题的提交
  123. Future<HttpResult> addJobTitleSubmit(
  124. String? jobTitle,
  125. String? sort,
  126. String? templateId, {
  127. CancelToken? cancelToken,
  128. }) async {
  129. //参数
  130. Map<String, String> params = {};
  131. params['job_title'] = jobTitle ?? "";
  132. if (!Utils.isEmpty(templateId)) {
  133. params["template_id"] = templateId!;
  134. }
  135. if (!Utils.isEmpty(sort)) {
  136. params["sort"] = sort!;
  137. }
  138. final result = await httpProvider.requestNetResult(
  139. ApiConstants.apiJobTitleAddSubmitSG,
  140. method: HttpMethod.POST,
  141. params: params,
  142. networkDebounce: true,
  143. isShowLoadingDialog: true,
  144. cancelToken: cancelToken,
  145. );
  146. //根据返回的结果,封装原始数据为Bean/Entity对象
  147. if (result.isSuccess) {
  148. //重新赋值data或list
  149. return result.convert();
  150. }
  151. return result.convert();
  152. }
  153. /// 编辑工作标题的提交
  154. Future<HttpResult> editJobTitleSubmit(
  155. String? titleId,
  156. String? jobTitle,
  157. String? sort,
  158. String? templateId, {
  159. CancelToken? cancelToken,
  160. }) async {
  161. //参数
  162. Map<String, String> params = {};
  163. params['job_title'] = jobTitle ?? "";
  164. params['title_id'] = titleId ?? "";
  165. if (!Utils.isEmpty(templateId)) {
  166. params["template_id"] = templateId!;
  167. }
  168. if (!Utils.isEmpty(sort)) {
  169. params["sort"] = sort!;
  170. }
  171. final result = await httpProvider.requestNetResult(
  172. ApiConstants.apiJobTitleEditSubmitSG,
  173. method: HttpMethod.POST,
  174. params: params,
  175. networkDebounce: true,
  176. isShowLoadingDialog: true,
  177. cancelToken: cancelToken,
  178. );
  179. //根据返回的结果,封装原始数据为Bean/Entity对象
  180. if (result.isSuccess) {
  181. //重新赋值data或list
  182. return result.convert();
  183. }
  184. return result.convert();
  185. }
  186. /// 删除工作标题的提交
  187. Future<HttpResult> deleteJobTitleSubmit(
  188. String? titleId, {
  189. CancelToken? cancelToken,
  190. }) async {
  191. //参数
  192. Map<String, String> params = {};
  193. params['title_id'] = titleId ?? "";
  194. final result = await httpProvider.requestNetResult(
  195. ApiConstants.apiJobTitleDeleteSG,
  196. method: HttpMethod.POST,
  197. params: params,
  198. networkDebounce: true,
  199. isShowLoadingDialog: true,
  200. cancelToken: cancelToken,
  201. );
  202. //根据返回的结果,封装原始数据为Bean/Entity对象
  203. if (result.isSuccess) {
  204. //重新赋值data或list
  205. return result.convert();
  206. }
  207. return result.convert();
  208. }
  209. // =================================== Template ↓ ===================================
  210. /// 用工模版中的工作标题列表
  211. Future<HttpResult<JobTemplateSGEntity>> fetchJobTemplateList(
  212. String? keyword, {
  213. required int curPage,
  214. CancelToken? cancelToken,
  215. }) async {
  216. //参数
  217. Map<String, String> params = {};
  218. params["cur_page"] = curPage.toString();
  219. params["page_size"] = "10";
  220. if (!Utils.isEmpty(keyword)) {
  221. params["keyword"] = keyword!;
  222. }
  223. final result = await httpProvider.requestNetResult(
  224. ApiConstants.apiJobTemplateListSG,
  225. params: params,
  226. cancelToken: cancelToken,
  227. );
  228. //根据返回的结果,封装原始数据为Bean/Entity对象
  229. if (result.isSuccess) {
  230. //重新赋值data或list
  231. final json = result.getDataJson();
  232. var data = JobTemplateSGEntity.fromJson(json!);
  233. //重新赋值data或list
  234. return result.convert<JobTemplateSGEntity>(data: data);
  235. }
  236. return result.convert();
  237. }
  238. /// 根据ID获取主列表的Item数据,用于刷新Item
  239. Future<HttpResult<JobTemplateSGEntity>> fetchJobTemplateListByIds(
  240. String? ids, {
  241. CancelToken? cancelToken,
  242. }) async {
  243. //参数
  244. Map<String, String> params = {};
  245. params["cur_page"] = "1";
  246. params["page_size"] = "9999";
  247. if (!Utils.isEmpty(ids)) {
  248. params["job_temp_id"] = ids!;
  249. }
  250. final result = await httpProvider.requestNetResult(
  251. ApiConstants.apiJobTemplateListSG,
  252. params: params,
  253. isShowLoadingDialog: true,
  254. cancelToken: cancelToken,
  255. );
  256. //根据返回的结果,封装原始数据为Bean/Entity对象
  257. if (result.isSuccess) {
  258. //重新赋值data或list
  259. final json = result.getDataJson();
  260. var data = JobTemplateSGEntity.fromJson(json!);
  261. //重新赋值data或list
  262. return result.convert<JobTemplateSGEntity>(data: data);
  263. }
  264. return result.convert();
  265. }
  266. /// 添加工作模板的详情或选项数据
  267. Future<HttpResult<JobTemplateEditIndexEntity>> fetchJobTemplateAddIndex({
  268. CancelToken? cancelToken,
  269. }) async {
  270. final result = await httpProvider.requestNetResult(
  271. ApiConstants.apiJobTemplateAddIndexSG,
  272. isShowLoadingDialog: true,
  273. cancelToken: cancelToken,
  274. );
  275. //根据返回的结果,封装原始数据为Bean/Entity对象
  276. if (result.isSuccess) {
  277. //重新赋值data或list
  278. final json = result.getDataJson();
  279. var data = JobTemplateEditIndexEntity.fromJson(json!);
  280. //重新赋值data或list
  281. return result.convert<JobTemplateEditIndexEntity>(data: data);
  282. }
  283. return result.convert();
  284. }
  285. /// 编辑工作模板的详情或选项数据
  286. Future<HttpResult<JobTemplateEditIndexEntity>> fetchJobTemplateEditIndex(
  287. String? templateId, {
  288. CancelToken? cancelToken,
  289. }) async {
  290. Map<String, String> params = {};
  291. params["template_id"] = templateId ?? "";
  292. final result = await httpProvider.requestNetResult(
  293. ApiConstants.apiJobTemplateEditIndexSG,
  294. params: params,
  295. isShowLoadingDialog: true,
  296. cancelToken: cancelToken,
  297. );
  298. //根据返回的结果,封装原始数据为Bean/Entity对象
  299. if (result.isSuccess) {
  300. //重新赋值data或list
  301. final json = result.getDataJson();
  302. var data = JobTemplateEditIndexEntity.fromJson(json!);
  303. //重新赋值data或list
  304. return result.convert<JobTemplateEditIndexEntity>(data: data);
  305. }
  306. return result.convert();
  307. }
  308. /// 添加工作模板的提交
  309. Future<HttpResult> addJobTemplateSubmit(
  310. String? name,
  311. String? contact,
  312. String? contactNo,
  313. String? description,
  314. String? note,
  315. String? age,
  316. String? sex,
  317. String? withFoodCert,
  318. String? language, {
  319. CancelToken? cancelToken,
  320. }) async {
  321. //参数
  322. Map<String, String> params = {};
  323. params['name'] = name ?? "";
  324. if (!Utils.isEmpty(contact)) {
  325. params["contact"] = contact!;
  326. }
  327. if (!Utils.isEmpty(contactNo)) {
  328. params["contact_no"] = contactNo!;
  329. }
  330. if (!Utils.isEmpty(description)) {
  331. params["description"] = description!;
  332. }
  333. if (!Utils.isEmpty(note)) {
  334. params["note"] = note!;
  335. }
  336. if (!Utils.isEmpty(age)) {
  337. params["age"] = age!;
  338. }
  339. if (!Utils.isEmpty(sex)) {
  340. params["sex"] = sex!;
  341. }
  342. if (!Utils.isEmpty(withFoodCert)) {
  343. params["with_food_cert"] = withFoodCert!;
  344. }
  345. if (!Utils.isEmpty(language)) {
  346. params["language"] = language!;
  347. }
  348. final result = await httpProvider.requestNetResult(
  349. ApiConstants.apiJobTemplateAddSubmitSG,
  350. method: HttpMethod.POST,
  351. params: params,
  352. networkDebounce: true,
  353. isShowLoadingDialog: true,
  354. cancelToken: cancelToken,
  355. );
  356. //根据返回的结果,封装原始数据为Bean/Entity对象
  357. if (result.isSuccess) {
  358. //重新赋值data或list
  359. return result.convert();
  360. }
  361. return result.convert();
  362. }
  363. /// 编辑工作模板的提交
  364. Future<HttpResult> editJobTemplateSubmit(
  365. String? templateId,
  366. String? name,
  367. String? contact,
  368. String? contactNo,
  369. String? description,
  370. String? note,
  371. String? age,
  372. String? sex,
  373. String? withFoodCert,
  374. String? language, {
  375. CancelToken? cancelToken,
  376. }) async {
  377. //参数
  378. Map<String, String> params = {};
  379. params['name'] = name ?? "";
  380. params['template_id'] = templateId ?? "";
  381. if (!Utils.isEmpty(contact)) {
  382. params["contact"] = contact!;
  383. }
  384. if (!Utils.isEmpty(contactNo)) {
  385. params["contact_no"] = contactNo!;
  386. }
  387. if (!Utils.isEmpty(description)) {
  388. params["description"] = description!;
  389. }
  390. if (!Utils.isEmpty(note)) {
  391. params["note"] = note!;
  392. }
  393. if (!Utils.isEmpty(age)) {
  394. params["age"] = age!;
  395. }
  396. if (!Utils.isEmpty(sex)) {
  397. params["sex"] = sex!;
  398. }
  399. if (!Utils.isEmpty(withFoodCert)) {
  400. params["with_food_cert"] = withFoodCert!;
  401. }
  402. if (!Utils.isEmpty(language)) {
  403. params["language"] = language!;
  404. }
  405. final result = await httpProvider.requestNetResult(
  406. ApiConstants.apiJobTemplateEditSubmitSG,
  407. method: HttpMethod.POST,
  408. params: params,
  409. networkDebounce: true,
  410. isShowLoadingDialog: true,
  411. cancelToken: cancelToken,
  412. );
  413. //根据返回的结果,封装原始数据为Bean/Entity对象
  414. if (result.isSuccess) {
  415. //重新赋值data或list
  416. return result.convert();
  417. }
  418. return result.convert();
  419. }
  420. /// 删除工作标题的提交
  421. Future<HttpResult> deleteJobTemplateSubmit(
  422. String? templateId, {
  423. CancelToken? cancelToken,
  424. }) async {
  425. //参数
  426. Map<String, String> params = {};
  427. params['template_id'] = templateId ?? "";
  428. final result = await httpProvider.requestNetResult(
  429. ApiConstants.apiJobTemplateDeleteSG,
  430. method: HttpMethod.POST,
  431. params: params,
  432. networkDebounce: true,
  433. isShowLoadingDialog: true,
  434. cancelToken: cancelToken,
  435. );
  436. //根据返回的结果,封装原始数据为Bean/Entity对象
  437. if (result.isSuccess) {
  438. //重新赋值data或list
  439. return result.convert();
  440. }
  441. return result.convert();
  442. }
  443. /// 用工请求的首页数据
  444. Future<HttpResult<LabourRequestSGCountList?>> fetchLabourRequestMain(
  445. String? date, {
  446. CancelToken? cancelToken,
  447. }) async {
  448. Map<String, String> params = {};
  449. if (Utils.isNotEmpty(date)) {
  450. params["date"] = date ?? "";
  451. }
  452. final result = await httpProvider.requestNetResult(
  453. ApiConstants.apiLabourRequestMainSG,
  454. params: params,
  455. cancelToken: cancelToken,
  456. );
  457. // //根据返回的结果,封装原始数据为Bean/Entity对象
  458. // if (result.isSuccess) {
  459. // //重新赋值data或list
  460. // final json = result.getDataJson();
  461. // var data = LabourRequestSGEntity.fromJson(json!);
  462. // //重新赋值data或list
  463. // return result.convert<LabourRequestSGEntity>(data: data);
  464. // }
  465. // return result.convert();
  466. if (result.isSuccess) {
  467. var jsonList = result.getListJson();
  468. var list = jsonList?.map((e) {
  469. if (e is Map<String, dynamic>) {
  470. return LabourRequestSGCountList.fromJson(e);
  471. } else {
  472. return null;
  473. }
  474. }).toList();
  475. return result.convert<LabourRequestSGCountList?>(list: list);
  476. }
  477. return result.convert<LabourRequestSGCountList>();
  478. }
  479. /// 添加用工请求的选项数据
  480. Future<HttpResult<LabourRequestSGAddIndexEntity>> fetchLabourRequestAddIndex({
  481. bool isShowLoadingDialog = true,
  482. CancelToken? cancelToken,
  483. }) async {
  484. final result = await httpProvider.requestNetResult(
  485. ApiConstants.apiLabourRequestAddIndexSG,
  486. isShowLoadingDialog: isShowLoadingDialog,
  487. cancelToken: cancelToken,
  488. );
  489. //根据返回的结果,封装原始数据为Bean/Entity对象
  490. if (result.isSuccess) {
  491. //重新赋值data或list
  492. final json = result.getDataJson();
  493. var data = LabourRequestSGAddIndexEntity.fromJson(json!);
  494. //重新赋值data或list
  495. return result.convert<LabourRequestSGAddIndexEntity>(data: data);
  496. }
  497. return result.convert();
  498. }
  499. //用工请求的查询选项(Job List)
  500. Future<HttpResult<JobListIndexSGEntity>> fetchJobListIndex({
  501. CancelToken? cancelToken,
  502. }) async {
  503. final result = await httpProvider.requestNetResult(
  504. ApiConstants.apiJobListIndexSG,
  505. cancelToken: cancelToken,
  506. );
  507. //根据返回的结果,封装原始数据为Bean/Entity对象
  508. if (result.isSuccess) {
  509. //重新赋值data或list
  510. final json = result.getDataJson();
  511. var data = JobListIndexSGEntity.fromJson(json!);
  512. //重新赋值data或list
  513. return result.convert<JobListIndexSGEntity>(data: data);
  514. }
  515. return result.convert();
  516. }
  517. //用工请求的查询列表(Job List)
  518. Future<HttpResult<JobListSGEntity>> fetchJobListTable(
  519. String? startDate,
  520. String? endDate,
  521. String? status,
  522. String? outletId, {
  523. required int curPage,
  524. CancelToken? cancelToken,
  525. }) async {
  526. Map<String, String> params = {};
  527. if (Utils.isNotEmpty(startDate)) {
  528. params['start_date'] = startDate ?? "";
  529. }
  530. if (Utils.isNotEmpty(endDate)) {
  531. params['end_date'] = endDate ?? "";
  532. }
  533. if (Utils.isNotEmpty(status)) {
  534. params['status'] = status ?? "";
  535. }
  536. if (Utils.isNotEmpty(outletId)) {
  537. params['outlet_id'] = outletId ?? "";
  538. }
  539. params['cur_page'] = curPage.toString();
  540. params['page_size'] = "10";
  541. final result = await httpProvider.requestNetResult(
  542. ApiConstants.apiJobListTableSG,
  543. params: params,
  544. cancelToken: cancelToken,
  545. );
  546. //根据返回的结果,封装原始数据为Bean/Entity对象
  547. if (result.isSuccess) {
  548. //重新赋值data或list
  549. final json = result.getDataJson();
  550. var data = JobListSGEntity.fromJson(json!);
  551. //重新赋值data或list
  552. return result.convert<JobListSGEntity>(data: data);
  553. }
  554. return result.convert();
  555. }
  556. /// 根据ID获取主列表的Item数据,用于刷新Item
  557. Future<HttpResult<JobListSGEntity>> fetchJobListByIds(
  558. String? jobId, {
  559. CancelToken? cancelToken,
  560. }) async {
  561. //参数
  562. Map<String, String> params = {};
  563. params["cur_page"] = "1";
  564. params["page_size"] = "9999";
  565. if (!Utils.isEmpty(jobId)) {
  566. params["job_id"] = jobId!;
  567. }
  568. final result = await httpProvider.requestNetResult(
  569. ApiConstants.apiJobListTableSG,
  570. params: params,
  571. cancelToken: cancelToken,
  572. );
  573. //根据返回的结果,封装原始数据为Bean/Entity对象
  574. if (result.isSuccess) {
  575. //重新赋值data或list
  576. final json = result.getDataJson();
  577. var data = JobListSGEntity.fromJson(json!);
  578. //重新赋值data或list
  579. return result.convert<JobListSGEntity>(data: data);
  580. }
  581. return result.convert();
  582. }
  583. //用工请求的编辑详情(Job List)
  584. Future<HttpResult<JobListEditIndexSGEntity>> fetchJobListEditIndex(
  585. String? jobId, {
  586. CancelToken? cancelToken,
  587. }) async {
  588. Map<String, String> params = {};
  589. params['job_id'] = jobId ?? "";
  590. final result = await httpProvider.requestNetResult(
  591. ApiConstants.apiJobListEditIndexSG,
  592. params: params,
  593. isShowLoadingDialog: true,
  594. cancelToken: cancelToken,
  595. );
  596. //根据返回的结果,封装原始数据为Bean/Entity对象
  597. if (result.isSuccess) {
  598. //重新赋值data或list
  599. final json = result.getDataJson();
  600. var data = JobListEditIndexSGEntity.fromJson(json!);
  601. //重新赋值data或list
  602. return result.convert<JobListEditIndexSGEntity>(data: data);
  603. }
  604. return result.convert();
  605. }
  606. //用工请求的编辑提交(Job List)
  607. Future<HttpResult> editJobListSubmit(
  608. String? jobId,
  609. String? startTime,
  610. String? endTime,
  611. String? outletId,
  612. int sexLimit,
  613. String? maleLimit,
  614. String? femaleLimit,
  615. String? needNum,
  616. String? requestType,
  617. String? remark, {
  618. CancelToken? cancelToken,
  619. }) async {
  620. //参数
  621. Map<String, String> params = {};
  622. params['job_id'] = jobId ?? "";
  623. params['start_time'] = startTime ?? "";
  624. params['end_time'] = endTime ?? "";
  625. params['outlet_id'] = outletId ?? "";
  626. params['sex_limit'] = sexLimit.toString();
  627. if (sexLimit == 1) {
  628. params['male_limit'] = maleLimit ?? "0";
  629. params['female_limit'] = femaleLimit ?? "0";
  630. // params['need_num'] = (int.parse(maleLimit ?? "0") + int.parse(femaleLimit ?? "0")).toString();
  631. } else {
  632. params['need_num'] = needNum ?? "0";
  633. }
  634. if (Utils.isNotEmpty(requestType)) {
  635. params['request_type'] = requestType ?? "";
  636. }
  637. if (Utils.isNotEmpty(remark)) {
  638. params['remark'] = remark ?? "";
  639. }
  640. final result = await httpProvider.requestNetResult(
  641. ApiConstants.apiJobListEditSubmitSG,
  642. method: HttpMethod.POST,
  643. params: params,
  644. networkDebounce: true,
  645. isShowLoadingDialog: true,
  646. cancelToken: cancelToken,
  647. );
  648. //根据返回的结果,封装原始数据为Bean/Entity对象
  649. if (result.isSuccess) {
  650. //重新赋值data或list
  651. return result.convert();
  652. }
  653. return result.convert();
  654. }
  655. //用工请求的取消(Job List)
  656. Future<HttpResult> cancelJobList(
  657. String? jobId, {
  658. CancelToken? cancelToken,
  659. }) async {
  660. //参数
  661. Map<String, String> params = {};
  662. params['job_id'] = jobId ?? "";
  663. final result = await httpProvider.requestNetResult(
  664. ApiConstants.apiJobListCancelSG,
  665. method: HttpMethod.POST,
  666. params: params,
  667. networkDebounce: true,
  668. isShowLoadingDialog: true,
  669. cancelToken: cancelToken,
  670. );
  671. //根据返回的结果,封装原始数据为Bean/Entity对象
  672. if (result.isSuccess) {
  673. //重新赋值data或list
  674. return result.convert();
  675. }
  676. return result.convert();
  677. }
  678. //用工请求的删除(Job List)
  679. Future<HttpResult> deleteJobList(
  680. String? jobId, {
  681. CancelToken? cancelToken,
  682. }) async {
  683. //参数
  684. Map<String, String> params = {};
  685. params['job_id'] = jobId ?? "";
  686. final result = await httpProvider.requestNetResult(
  687. ApiConstants.apiJobListDeleteSG,
  688. method: HttpMethod.POST,
  689. params: params,
  690. networkDebounce: true,
  691. isShowLoadingDialog: true,
  692. cancelToken: cancelToken,
  693. );
  694. //根据返回的结果,封装原始数据为Bean/Entity对象
  695. if (result.isSuccess) {
  696. //重新赋值data或list
  697. return result.convert();
  698. }
  699. return result.convert();
  700. }
  701. //用工请求的考勤确认(Job List)
  702. Future<HttpResult> confirmJobList(
  703. String? jobId, {
  704. CancelToken? cancelToken,
  705. }) async {
  706. //参数
  707. Map<String, String> params = {};
  708. params['job_id'] = jobId ?? "";
  709. final result = await httpProvider.requestNetResult(
  710. ApiConstants.apiJobListConfirmSG,
  711. method: HttpMethod.POST,
  712. params: params,
  713. networkDebounce: true,
  714. isShowLoadingDialog: true,
  715. cancelToken: cancelToken,
  716. );
  717. //根据返回的结果,封装原始数据为Bean/Entity对象
  718. if (result.isSuccess) {
  719. //重新赋值data或list
  720. return result.convert();
  721. }
  722. return result.convert();
  723. }
  724. // V2 - 新版的LabourRequest 改动
  725. /// 获取用工请求的筛选选项
  726. Future<HttpResult<LabourRequestIndexEntity>> fetchLabourRequestSGIndex({
  727. CancelToken? cancelToken,
  728. }) async {
  729. final result = await httpProvider.requestNetResult(
  730. ApiConstants.apiLabourRequestIndex,
  731. cancelToken: cancelToken,
  732. );
  733. //根据返回的结果,封装原始数据为Bean/Entity对象
  734. if (result.isSuccess) {
  735. //重新赋值data或list
  736. final json = result.getDataJson();
  737. var data = LabourRequestIndexEntity.fromJson(json!);
  738. //重新赋值data或list
  739. return result.convert<LabourRequestIndexEntity>(data: data);
  740. }
  741. return result.convert();
  742. }
  743. /// 获取用工请求的主列表
  744. Future<HttpResult<LabourRequestSGListEntity>> fetchLabourRequestSGList(
  745. String? keyword,
  746. String? startDate,
  747. String? endDate,
  748. String? statusId,
  749. String? departmentId, {
  750. required int curPage,
  751. CancelToken? cancelToken,
  752. }) async {
  753. //参数
  754. Map<String, String> params = {};
  755. params["cur_page"] = curPage.toString();
  756. params["page_size"] = "20";
  757. if (!Utils.isEmpty(keyword)) {
  758. params["job_title"] = keyword!;
  759. }
  760. if (!Utils.isEmpty(startDate)) {
  761. params["job_start"] = startDate!;
  762. }
  763. if (!Utils.isEmpty(endDate)) {
  764. params["job_end"] = endDate!;
  765. }
  766. if (!Utils.isEmpty(statusId)) {
  767. params["status"] = statusId!;
  768. }
  769. if (!Utils.isEmpty(departmentId)) {
  770. params["outlet_id"] = departmentId!;
  771. }
  772. final result = await httpProvider.requestNetResult(
  773. ApiConstants.apiLabourRequestList,
  774. params: params,
  775. cancelToken: cancelToken,
  776. );
  777. //根据返回的结果,封装原始数据为Bean/Entity对象
  778. if (result.isSuccess) {
  779. //重新赋值data或list
  780. final json = result.getDataJson();
  781. var data = LabourRequestSGListEntity.fromJson(json!);
  782. //重新赋值data或list
  783. return result.convert<LabourRequestSGListEntity>(data: data);
  784. }
  785. return result.convert();
  786. }
  787. /// 根据ID获取主列表的Item数据,用于刷新Item
  788. Future<HttpResult<LabourRequestSGListEntity>> fetchItemByRequestId(
  789. String? requestId, {
  790. CancelToken? cancelToken,
  791. }) async {
  792. //参数
  793. Map<String, String> params = {};
  794. params["cur_page"] = "1";
  795. params["page_size"] = "1";
  796. if (!Utils.isEmpty(requestId)) {
  797. params["request_id"] = requestId!;
  798. }
  799. final result = await httpProvider.requestNetResult(
  800. ApiConstants.apiLabourRequestList,
  801. params: params,
  802. isShowLoadingDialog: true,
  803. cancelToken: cancelToken,
  804. );
  805. //根据返回的结果,封装原始数据为Bean/Entity对象
  806. if (result.isSuccess) {
  807. //重新赋值data或list
  808. final json = result.getDataJson();
  809. var data = LabourRequestSGListEntity.fromJson(json!);
  810. //重新赋值data或list
  811. return result.convert<LabourRequestSGListEntity>(data: data);
  812. }
  813. return result.convert();
  814. }
  815. /// 删除工作标题的提交
  816. Future<HttpResult> submitLabourRequestAdd(
  817. String? jobTitleId,
  818. String? startTime,
  819. String? endTime,
  820. String? repeatStart,
  821. String? repeatEnd,
  822. String? outletId,
  823. int sexLimit,
  824. String? maleLimit,
  825. String? femaleLimit,
  826. String? needNum,
  827. String? requestType,
  828. String? remark, {
  829. CancelToken? cancelToken,
  830. }) async {
  831. //参数
  832. Map<String, String> params = {};
  833. params['job_title_id'] = jobTitleId ?? "";
  834. params['start_time'] = startTime ?? "";
  835. params['end_time'] = endTime ?? "";
  836. params['outlet_id'] = outletId ?? "";
  837. params['sex_limit'] = sexLimit.toString();
  838. if (sexLimit == 1) {
  839. params['male_limit'] = maleLimit ?? "0";
  840. params['female_limit'] = femaleLimit ?? "0";
  841. // params['need_num'] = (int.parse(maleLimit ?? "0") + int.parse(femaleLimit ?? "0")).toString(); //不传 need_num 字段
  842. } else {
  843. params['need_num'] = needNum ?? "0";
  844. }
  845. if (Utils.isNotEmpty(repeatStart)) {
  846. params['repeat_start'] = repeatStart ?? "";
  847. }
  848. if (Utils.isNotEmpty(repeatEnd)) {
  849. params['repeat_end'] = repeatEnd ?? "";
  850. }
  851. if (Utils.isNotEmpty(requestType)) {
  852. params['request_type'] = requestType ?? "";
  853. }
  854. if (Utils.isNotEmpty(remark)) {
  855. params['remark'] = remark ?? "";
  856. }
  857. final result = await httpProvider.requestNetResult(
  858. ApiConstants.apiLabourRequestAddSubmitSG,
  859. method: HttpMethod.POST,
  860. params: params,
  861. networkDebounce: true,
  862. isShowLoadingDialog: true,
  863. cancelToken: cancelToken,
  864. );
  865. //根据返回的结果,封装原始数据为Bean/Entity对象
  866. if (result.isSuccess) {
  867. //重新赋值data或list
  868. return result.convert();
  869. }
  870. return result.convert();
  871. }
  872. /// 用工的编辑详情
  873. Future<HttpResult<LabourRequestSGEditIndexEntity>> fetchLabourRequestEditDetail(
  874. String? requestId, {
  875. bool isShowLoadingDialog = true,
  876. CancelToken? cancelToken,
  877. }) async {
  878. //参数
  879. Map<String, String> params = {};
  880. params['request_id'] = requestId ?? "";
  881. final result = await httpProvider.requestNetResult(
  882. ApiConstants.apiLabourRequestEditDetail,
  883. params: params,
  884. isShowLoadingDialog: isShowLoadingDialog,
  885. cancelToken: cancelToken,
  886. );
  887. //根据返回的结果,封装原始数据为Bean/Entity对象
  888. if (result.isSuccess) {
  889. //重新赋值data或list
  890. final json = result.getDataJson();
  891. var data = LabourRequestSGEditIndexEntity.fromJson(json!);
  892. //重新赋值data或list
  893. return result.convert<LabourRequestSGEditIndexEntity>(data: data);
  894. }
  895. return result.convert();
  896. }
  897. /// 编辑工作标题的提交
  898. Future<HttpResult> submitLabourRequestEdit(
  899. String? requestId,
  900. String? startTime,
  901. String? endTime,
  902. String? outletId,
  903. int sexLimit,
  904. String? maleLimit,
  905. String? femaleLimit,
  906. String? needNum,
  907. String? requestType,
  908. String? remark, {
  909. CancelToken? cancelToken,
  910. }) async {
  911. //参数
  912. Map<String, String> params = {};
  913. params['request_id'] = requestId ?? "";
  914. params['start_time'] = startTime ?? "";
  915. params['end_time'] = endTime ?? "";
  916. params['outlet_id'] = outletId ?? "";
  917. params['sex_limit'] = sexLimit.toString();
  918. if (sexLimit == 1) {
  919. params['male_limit'] = maleLimit ?? "0";
  920. params['female_limit'] = femaleLimit ?? "0";
  921. // params['need_num'] = (int.parse(maleLimit ?? "0") + int.parse(femaleLimit ?? "0")).toString(); //不传 need_num 字段
  922. } else {
  923. params['need_num'] = needNum ?? "0";
  924. }
  925. if (Utils.isNotEmpty(requestType)) {
  926. params['request_type'] = requestType ?? "";
  927. }
  928. if (Utils.isNotEmpty(remark)) {
  929. params['remark'] = remark ?? "";
  930. }
  931. final result = await httpProvider.requestNetResult(
  932. ApiConstants.apiLabourRequestEditSubmit,
  933. method: HttpMethod.POST,
  934. params: params,
  935. networkDebounce: true,
  936. isShowLoadingDialog: true,
  937. cancelToken: cancelToken,
  938. );
  939. //根据返回的结果,封装原始数据为Bean/Entity对象
  940. if (result.isSuccess) {
  941. //重新赋值data或list
  942. return result.convert();
  943. }
  944. return result.convert();
  945. }
  946. /// 删除新加坡的用工请求
  947. Future<HttpResult> deleteLabourRequestSG(
  948. String? requestId, {
  949. CancelToken? cancelToken,
  950. }) async {
  951. //参数
  952. Map<String, String> params = {};
  953. params['request_id'] = requestId ?? "";
  954. final result = await httpProvider.requestNetResult(
  955. ApiConstants.apiLabourRequestDelete,
  956. method: HttpMethod.POST,
  957. params: params,
  958. networkDebounce: true,
  959. isShowLoadingDialog: true,
  960. cancelToken: cancelToken,
  961. );
  962. //根据返回的结果,封装原始数据为Bean/Entity对象
  963. if (result.isSuccess) {
  964. //重新赋值data或list
  965. return result.convert();
  966. }
  967. return result.convert();
  968. }
  969. }