labour_sg_repository.dart 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  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. /// 用工相关(新加坡)
  18. class LabourSGRepository extends GetxService {
  19. HttpProvider httpProvider;
  20. LabourSGRepository({required this.httpProvider});
  21. /// 用工模版中的工作标题列表
  22. Future<HttpResult<JobTitleSGEntity>> fetchJobTitleList(
  23. String? keyword, {
  24. required int curPage,
  25. CancelToken? cancelToken,
  26. }) async {
  27. //参数
  28. Map<String, String> params = {};
  29. params["cur_page"] = curPage.toString();
  30. params["page_size"] = "10";
  31. if (!Utils.isEmpty(keyword)) {
  32. params["keyword"] = keyword!;
  33. }
  34. final result = await httpProvider.requestNetResult(
  35. ApiConstants.apiJobTitleListSG,
  36. params: params,
  37. cancelToken: cancelToken,
  38. );
  39. //根据返回的结果,封装原始数据为Bean/Entity对象
  40. if (result.isSuccess) {
  41. //重新赋值data或list
  42. final json = result.getDataJson();
  43. var data = JobTitleSGEntity.fromJson(json!);
  44. //重新赋值data或list
  45. return result.convert<JobTitleSGEntity>(data: data);
  46. }
  47. return result.convert();
  48. }
  49. /// 根据ID获取主列表的Item数据,用于刷新Item
  50. Future<HttpResult<JobTitleSGEntity>> fetchJobTitleListByIds(
  51. String? ids, {
  52. CancelToken? cancelToken,
  53. }) async {
  54. //参数
  55. Map<String, String> params = {};
  56. params["cur_page"] = "1";
  57. params["page_size"] = "9999";
  58. if (!Utils.isEmpty(ids)) {
  59. params["job_title_id"] = ids!;
  60. }
  61. final result = await httpProvider.requestNetResult(
  62. ApiConstants.apiJobTitleListSG,
  63. params: params,
  64. isShowLoadingDialog: true,
  65. cancelToken: cancelToken,
  66. );
  67. //根据返回的结果,封装原始数据为Bean/Entity对象
  68. if (result.isSuccess) {
  69. //重新赋值data或list
  70. final json = result.getDataJson();
  71. var data = JobTitleSGEntity.fromJson(json!);
  72. //重新赋值data或list
  73. return result.convert<JobTitleSGEntity>(data: data);
  74. }
  75. return result.convert();
  76. }
  77. /// 添加工作标题的详情或选项数据
  78. Future<HttpResult<JobTitleEditIndexEntity>> fetchJobTitleAddIndex({
  79. CancelToken? cancelToken,
  80. }) async {
  81. final result = await httpProvider.requestNetResult(
  82. ApiConstants.apiJobTitleAddIndexSG,
  83. isShowLoadingDialog: true,
  84. cancelToken: cancelToken,
  85. );
  86. //根据返回的结果,封装原始数据为Bean/Entity对象
  87. if (result.isSuccess) {
  88. //重新赋值data或list
  89. final json = result.getDataJson();
  90. var data = JobTitleEditIndexEntity.fromJson(json!);
  91. //重新赋值data或list
  92. return result.convert<JobTitleEditIndexEntity>(data: data);
  93. }
  94. return result.convert();
  95. }
  96. /// 编辑工作标题的详情或选项数据
  97. Future<HttpResult<JobTitleEditIndexEntity>> fetchJobTitleEditIndex(
  98. String? titleId, {
  99. CancelToken? cancelToken,
  100. }) async {
  101. Map<String, String> params = {};
  102. params["title_id"] = titleId ?? "";
  103. final result = await httpProvider.requestNetResult(
  104. ApiConstants.apiJobTitleEditIndexSG,
  105. params: params,
  106. isShowLoadingDialog: true,
  107. cancelToken: cancelToken,
  108. );
  109. //根据返回的结果,封装原始数据为Bean/Entity对象
  110. if (result.isSuccess) {
  111. //重新赋值data或list
  112. final json = result.getDataJson();
  113. var data = JobTitleEditIndexEntity.fromJson(json!);
  114. //重新赋值data或list
  115. return result.convert<JobTitleEditIndexEntity>(data: data);
  116. }
  117. return result.convert();
  118. }
  119. /// 添加工作标题的提交
  120. Future<HttpResult> addJobTitleSubmit(
  121. String? jobTitle,
  122. String? sort,
  123. String? templateId, {
  124. CancelToken? cancelToken,
  125. }) async {
  126. //参数
  127. Map<String, String> params = {};
  128. params['job_title'] = jobTitle ?? "";
  129. if (!Utils.isEmpty(templateId)) {
  130. params["template_id"] = templateId!;
  131. }
  132. if (!Utils.isEmpty(sort)) {
  133. params["sort"] = sort!;
  134. }
  135. final result = await httpProvider.requestNetResult(
  136. ApiConstants.apiJobTitleAddSubmitSG,
  137. method: HttpMethod.POST,
  138. params: params,
  139. networkDebounce: true,
  140. isShowLoadingDialog: true,
  141. cancelToken: cancelToken,
  142. );
  143. //根据返回的结果,封装原始数据为Bean/Entity对象
  144. if (result.isSuccess) {
  145. //重新赋值data或list
  146. return result.convert();
  147. }
  148. return result.convert();
  149. }
  150. /// 编辑工作标题的提交
  151. Future<HttpResult> editJobTitleSubmit(
  152. String? titleId,
  153. String? jobTitle,
  154. String? sort,
  155. String? templateId, {
  156. CancelToken? cancelToken,
  157. }) async {
  158. //参数
  159. Map<String, String> params = {};
  160. params['job_title'] = jobTitle ?? "";
  161. params['title_id'] = titleId ?? "";
  162. if (!Utils.isEmpty(templateId)) {
  163. params["template_id"] = templateId!;
  164. }
  165. if (!Utils.isEmpty(sort)) {
  166. params["sort"] = sort!;
  167. }
  168. final result = await httpProvider.requestNetResult(
  169. ApiConstants.apiJobTitleEditSubmitSG,
  170. method: HttpMethod.POST,
  171. params: params,
  172. networkDebounce: true,
  173. isShowLoadingDialog: true,
  174. cancelToken: cancelToken,
  175. );
  176. //根据返回的结果,封装原始数据为Bean/Entity对象
  177. if (result.isSuccess) {
  178. //重新赋值data或list
  179. return result.convert();
  180. }
  181. return result.convert();
  182. }
  183. /// 删除工作标题的提交
  184. Future<HttpResult> deleteJobTitleSubmit(
  185. String? titleId, {
  186. CancelToken? cancelToken,
  187. }) async {
  188. //参数
  189. Map<String, String> params = {};
  190. params['title_id'] = titleId ?? "";
  191. final result = await httpProvider.requestNetResult(
  192. ApiConstants.apiJobTitleDeleteSG,
  193. method: HttpMethod.POST,
  194. params: params,
  195. networkDebounce: true,
  196. isShowLoadingDialog: true,
  197. cancelToken: cancelToken,
  198. );
  199. //根据返回的结果,封装原始数据为Bean/Entity对象
  200. if (result.isSuccess) {
  201. //重新赋值data或list
  202. return result.convert();
  203. }
  204. return result.convert();
  205. }
  206. // =================================== Template ↓ ===================================
  207. /// 用工模版中的工作标题列表
  208. Future<HttpResult<JobTemplateSGEntity>> fetchJobTemplateList(
  209. String? keyword, {
  210. required int curPage,
  211. CancelToken? cancelToken,
  212. }) async {
  213. //参数
  214. Map<String, String> params = {};
  215. params["cur_page"] = curPage.toString();
  216. params["page_size"] = "10";
  217. if (!Utils.isEmpty(keyword)) {
  218. params["keyword"] = keyword!;
  219. }
  220. final result = await httpProvider.requestNetResult(
  221. ApiConstants.apiJobTemplateListSG,
  222. params: params,
  223. cancelToken: cancelToken,
  224. );
  225. //根据返回的结果,封装原始数据为Bean/Entity对象
  226. if (result.isSuccess) {
  227. //重新赋值data或list
  228. final json = result.getDataJson();
  229. var data = JobTemplateSGEntity.fromJson(json!);
  230. //重新赋值data或list
  231. return result.convert<JobTemplateSGEntity>(data: data);
  232. }
  233. return result.convert();
  234. }
  235. /// 根据ID获取主列表的Item数据,用于刷新Item
  236. Future<HttpResult<JobTemplateSGEntity>> fetchJobTemplateListByIds(
  237. String? ids, {
  238. CancelToken? cancelToken,
  239. }) async {
  240. //参数
  241. Map<String, String> params = {};
  242. params["cur_page"] = "1";
  243. params["page_size"] = "9999";
  244. if (!Utils.isEmpty(ids)) {
  245. params["job_temp_id"] = ids!;
  246. }
  247. final result = await httpProvider.requestNetResult(
  248. ApiConstants.apiJobTemplateListSG,
  249. params: params,
  250. isShowLoadingDialog: true,
  251. cancelToken: cancelToken,
  252. );
  253. //根据返回的结果,封装原始数据为Bean/Entity对象
  254. if (result.isSuccess) {
  255. //重新赋值data或list
  256. final json = result.getDataJson();
  257. var data = JobTemplateSGEntity.fromJson(json!);
  258. //重新赋值data或list
  259. return result.convert<JobTemplateSGEntity>(data: data);
  260. }
  261. return result.convert();
  262. }
  263. /// 添加工作模板的详情或选项数据
  264. Future<HttpResult<JobTemplateEditIndexEntity>> fetchJobTemplateAddIndex({
  265. CancelToken? cancelToken,
  266. }) async {
  267. final result = await httpProvider.requestNetResult(
  268. ApiConstants.apiJobTemplateAddIndexSG,
  269. isShowLoadingDialog: true,
  270. cancelToken: cancelToken,
  271. );
  272. //根据返回的结果,封装原始数据为Bean/Entity对象
  273. if (result.isSuccess) {
  274. //重新赋值data或list
  275. final json = result.getDataJson();
  276. var data = JobTemplateEditIndexEntity.fromJson(json!);
  277. //重新赋值data或list
  278. return result.convert<JobTemplateEditIndexEntity>(data: data);
  279. }
  280. return result.convert();
  281. }
  282. /// 编辑工作模板的详情或选项数据
  283. Future<HttpResult<JobTemplateEditIndexEntity>> fetchJobTemplateEditIndex(
  284. String? templateId, {
  285. CancelToken? cancelToken,
  286. }) async {
  287. Map<String, String> params = {};
  288. params["template_id"] = templateId ?? "";
  289. final result = await httpProvider.requestNetResult(
  290. ApiConstants.apiJobTemplateEditIndexSG,
  291. params: params,
  292. isShowLoadingDialog: true,
  293. cancelToken: cancelToken,
  294. );
  295. //根据返回的结果,封装原始数据为Bean/Entity对象
  296. if (result.isSuccess) {
  297. //重新赋值data或list
  298. final json = result.getDataJson();
  299. var data = JobTemplateEditIndexEntity.fromJson(json!);
  300. //重新赋值data或list
  301. return result.convert<JobTemplateEditIndexEntity>(data: data);
  302. }
  303. return result.convert();
  304. }
  305. /// 添加工作模板的提交
  306. Future<HttpResult> addJobTemplateSubmit(
  307. String? name,
  308. String? contact,
  309. String? contact_no,
  310. String? description,
  311. String? note,
  312. String? age,
  313. String? sex,
  314. String? with_food_cert,
  315. String? language, {
  316. CancelToken? cancelToken,
  317. }) async {
  318. //参数
  319. Map<String, String> params = {};
  320. params['name'] = name ?? "";
  321. if (!Utils.isEmpty(contact)) {
  322. params["contact"] = contact!;
  323. }
  324. if (!Utils.isEmpty(contact_no)) {
  325. params["contact_no"] = contact_no!;
  326. }
  327. if (!Utils.isEmpty(description)) {
  328. params["description"] = description!;
  329. }
  330. if (!Utils.isEmpty(note)) {
  331. params["note"] = note!;
  332. }
  333. if (!Utils.isEmpty(age)) {
  334. params["age"] = age!;
  335. }
  336. if (!Utils.isEmpty(sex)) {
  337. params["sex"] = sex!;
  338. }
  339. if (!Utils.isEmpty(with_food_cert)) {
  340. params["with_food_cert"] = with_food_cert!;
  341. }
  342. if (!Utils.isEmpty(language)) {
  343. params["language"] = language!;
  344. }
  345. final result = await httpProvider.requestNetResult(
  346. ApiConstants.apiJobTemplateAddSubmitSG,
  347. method: HttpMethod.POST,
  348. params: params,
  349. networkDebounce: true,
  350. isShowLoadingDialog: true,
  351. cancelToken: cancelToken,
  352. );
  353. //根据返回的结果,封装原始数据为Bean/Entity对象
  354. if (result.isSuccess) {
  355. //重新赋值data或list
  356. return result.convert();
  357. }
  358. return result.convert();
  359. }
  360. /// 编辑工作模板的提交
  361. Future<HttpResult> editJobTemplateSubmit(
  362. String? templateId,
  363. String? name,
  364. String? contact,
  365. String? contact_no,
  366. String? description,
  367. String? note,
  368. String? age,
  369. String? sex,
  370. String? with_food_cert,
  371. String? language, {
  372. CancelToken? cancelToken,
  373. }) async {
  374. //参数
  375. Map<String, String> params = {};
  376. params['name'] = name ?? "";
  377. params['template_id'] = templateId ?? "";
  378. if (!Utils.isEmpty(contact)) {
  379. params["contact"] = contact!;
  380. }
  381. if (!Utils.isEmpty(contact_no)) {
  382. params["contact_no"] = contact_no!;
  383. }
  384. if (!Utils.isEmpty(description)) {
  385. params["description"] = description!;
  386. }
  387. if (!Utils.isEmpty(note)) {
  388. params["note"] = note!;
  389. }
  390. if (!Utils.isEmpty(age)) {
  391. params["age"] = age!;
  392. }
  393. if (!Utils.isEmpty(sex)) {
  394. params["sex"] = sex!;
  395. }
  396. if (!Utils.isEmpty(with_food_cert)) {
  397. params["with_food_cert"] = with_food_cert!;
  398. }
  399. if (!Utils.isEmpty(language)) {
  400. params["language"] = language!;
  401. }
  402. final result = await httpProvider.requestNetResult(
  403. ApiConstants.apiJobTemplateEditSubmitSG,
  404. method: HttpMethod.POST,
  405. params: params,
  406. networkDebounce: true,
  407. isShowLoadingDialog: true,
  408. cancelToken: cancelToken,
  409. );
  410. //根据返回的结果,封装原始数据为Bean/Entity对象
  411. if (result.isSuccess) {
  412. //重新赋值data或list
  413. return result.convert();
  414. }
  415. return result.convert();
  416. }
  417. /// 删除工作标题的提交
  418. Future<HttpResult> deleteJobTemplateSubmit(
  419. String? templateId, {
  420. CancelToken? cancelToken,
  421. }) async {
  422. //参数
  423. Map<String, String> params = {};
  424. params['template_id'] = templateId ?? "";
  425. final result = await httpProvider.requestNetResult(
  426. ApiConstants.apiJobTemplateDeleteSG,
  427. method: HttpMethod.POST,
  428. params: params,
  429. networkDebounce: true,
  430. isShowLoadingDialog: true,
  431. cancelToken: cancelToken,
  432. );
  433. //根据返回的结果,封装原始数据为Bean/Entity对象
  434. if (result.isSuccess) {
  435. //重新赋值data或list
  436. return result.convert();
  437. }
  438. return result.convert();
  439. }
  440. /// 用工请求的首页数据
  441. Future<HttpResult<LabourRequestSGEntity>> fetchLabourRequestMain(
  442. String? date, {
  443. CancelToken? cancelToken,
  444. }) async {
  445. Map<String, String> params = {};
  446. if (Utils.isNotEmpty(date)) {
  447. params["date"] = date ?? "";
  448. }
  449. final result = await httpProvider.requestNetResult(
  450. ApiConstants.apiLabourRequestMainSG,
  451. params: params,
  452. cancelToken: cancelToken,
  453. );
  454. //根据返回的结果,封装原始数据为Bean/Entity对象
  455. if (result.isSuccess) {
  456. //重新赋值data或list
  457. final json = result.getDataJson();
  458. var data = LabourRequestSGEntity.fromJson(json!);
  459. //重新赋值data或list
  460. return result.convert<LabourRequestSGEntity>(data: data);
  461. }
  462. return result.convert();
  463. }
  464. /// 添加用工请求的选项数据
  465. Future<HttpResult<LabourRequestSGAddIndexEntity>> fetchLabourRequestAddIndex({
  466. CancelToken? cancelToken,
  467. }) async {
  468. final result = await httpProvider.requestNetResult(
  469. ApiConstants.apiLabourRequestAddIndexSG,
  470. isShowLoadingDialog: true,
  471. cancelToken: cancelToken,
  472. );
  473. //根据返回的结果,封装原始数据为Bean/Entity对象
  474. if (result.isSuccess) {
  475. //重新赋值data或list
  476. final json = result.getDataJson();
  477. var data = LabourRequestSGAddIndexEntity.fromJson(json!);
  478. //重新赋值data或list
  479. return result.convert<LabourRequestSGAddIndexEntity>(data: data);
  480. }
  481. return result.convert();
  482. }
  483. /// 删除工作标题的提交
  484. Future<HttpResult> submitLabourRequestAdd(
  485. String? jobTitleId,
  486. String? startTime,
  487. String? endTime,
  488. String? repeatStart,
  489. String? repeatEnd,
  490. String? outletId,
  491. int sexLimit,
  492. String? maleLimit,
  493. String? femaleLimit,
  494. String? needNum,
  495. String? requestType,
  496. String? remark, {
  497. CancelToken? cancelToken,
  498. }) async {
  499. //参数
  500. Map<String, String> params = {};
  501. params['job_title_id'] = jobTitleId ?? "";
  502. params['start_time'] = startTime ?? "";
  503. params['end_time'] = endTime ?? "";
  504. params['outlet_id'] = outletId ?? "";
  505. params['sex_limit'] = sexLimit.toString();
  506. if (sexLimit == 1) {
  507. params['male_limit'] = maleLimit ?? "0";
  508. params['female_limit'] = femaleLimit ?? "0";
  509. // params['need_num'] = (int.parse(maleLimit ?? "0") + int.parse(femaleLimit ?? "0")).toString(); //不传 need_num 字段
  510. } else {
  511. params['need_num'] = needNum ?? "0";
  512. }
  513. if (Utils.isNotEmpty(repeatStart)) {
  514. params['repeat_start'] = repeatStart ?? "";
  515. }
  516. if (Utils.isNotEmpty(repeatEnd)) {
  517. params['repeat_end'] = repeatEnd ?? "";
  518. }
  519. if (Utils.isNotEmpty(requestType)) {
  520. params['request_type'] = requestType ?? "";
  521. }
  522. if (Utils.isNotEmpty(remark)) {
  523. params['remark'] = remark ?? "";
  524. }
  525. final result = await httpProvider.requestNetResult(
  526. ApiConstants.apiLabourRequestAddSubmitSG,
  527. method: HttpMethod.POST,
  528. params: params,
  529. networkDebounce: true,
  530. isShowLoadingDialog: true,
  531. cancelToken: cancelToken,
  532. );
  533. //根据返回的结果,封装原始数据为Bean/Entity对象
  534. if (result.isSuccess) {
  535. //重新赋值data或list
  536. return result.convert();
  537. }
  538. return result.convert();
  539. }
  540. //用工请求的查询选项(Job List)
  541. Future<HttpResult<JobListIndexSGEntity>> fetchJobListIndex({
  542. CancelToken? cancelToken,
  543. }) async {
  544. final result = await httpProvider.requestNetResult(
  545. ApiConstants.apiJobListIndexSG,
  546. cancelToken: cancelToken,
  547. );
  548. //根据返回的结果,封装原始数据为Bean/Entity对象
  549. if (result.isSuccess) {
  550. //重新赋值data或list
  551. final json = result.getDataJson();
  552. var data = JobListIndexSGEntity.fromJson(json!);
  553. //重新赋值data或list
  554. return result.convert<JobListIndexSGEntity>(data: data);
  555. }
  556. return result.convert();
  557. }
  558. //用工请求的查询列表(Job List)
  559. Future<HttpResult<JobListSGEntity>> fetchJobListTable(
  560. String? startDate,
  561. String? endDate,
  562. String? status,
  563. String? outletId, {
  564. required int curPage,
  565. CancelToken? cancelToken,
  566. }) async {
  567. Map<String, String> params = {};
  568. if (Utils.isNotEmpty(startDate)) {
  569. params['start_date'] = startDate ?? "";
  570. }
  571. if (Utils.isNotEmpty(endDate)) {
  572. params['end_date'] = endDate ?? "";
  573. }
  574. if (Utils.isNotEmpty(status)) {
  575. params['status'] = status ?? "";
  576. }
  577. if (Utils.isNotEmpty(outletId)) {
  578. params['outlet_id'] = outletId ?? "";
  579. }
  580. params['cur_page'] = curPage.toString();
  581. params['page_size'] = "10";
  582. final result = await httpProvider.requestNetResult(
  583. ApiConstants.apiJobListTableSG,
  584. params: params,
  585. cancelToken: cancelToken,
  586. );
  587. //根据返回的结果,封装原始数据为Bean/Entity对象
  588. if (result.isSuccess) {
  589. //重新赋值data或list
  590. final json = result.getDataJson();
  591. var data = JobListSGEntity.fromJson(json!);
  592. //重新赋值data或list
  593. return result.convert<JobListSGEntity>(data: data);
  594. }
  595. return result.convert();
  596. }
  597. /// 根据ID获取主列表的Item数据,用于刷新Item
  598. Future<HttpResult<JobListSGEntity>> fetchJobListByIds(
  599. String? jobId, {
  600. CancelToken? cancelToken,
  601. }) async {
  602. //参数
  603. Map<String, String> params = {};
  604. params["cur_page"] = "1";
  605. params["page_size"] = "9999";
  606. if (!Utils.isEmpty(jobId)) {
  607. params["job_id"] = jobId!;
  608. }
  609. final result = await httpProvider.requestNetResult(
  610. ApiConstants.apiJobListTableSG,
  611. params: params,
  612. cancelToken: cancelToken,
  613. );
  614. //根据返回的结果,封装原始数据为Bean/Entity对象
  615. if (result.isSuccess) {
  616. //重新赋值data或list
  617. final json = result.getDataJson();
  618. var data = JobListSGEntity.fromJson(json!);
  619. //重新赋值data或list
  620. return result.convert<JobListSGEntity>(data: data);
  621. }
  622. return result.convert();
  623. }
  624. //用工请求的编辑详情(Job List)
  625. Future<HttpResult<JobListEditIndexSGEntity>> fetchJobListEditIndex(
  626. String? jobId, {
  627. CancelToken? cancelToken,
  628. }) async {
  629. Map<String, String> params = {};
  630. params['job_id'] = jobId ?? "";
  631. final result = await httpProvider.requestNetResult(
  632. ApiConstants.apiJobListEditIndexSG,
  633. params: params,
  634. isShowLoadingDialog: true,
  635. cancelToken: cancelToken,
  636. );
  637. //根据返回的结果,封装原始数据为Bean/Entity对象
  638. if (result.isSuccess) {
  639. //重新赋值data或list
  640. final json = result.getDataJson();
  641. var data = JobListEditIndexSGEntity.fromJson(json!);
  642. //重新赋值data或list
  643. return result.convert<JobListEditIndexSGEntity>(data: data);
  644. }
  645. return result.convert();
  646. }
  647. //用工请求的编辑提交(Job List)
  648. Future<HttpResult> editJobListSubmit(
  649. String? jobId,
  650. String? startTime,
  651. String? endTime,
  652. String? outletId,
  653. int sexLimit,
  654. String? maleLimit,
  655. String? femaleLimit,
  656. String? needNum,
  657. String? requestType,
  658. String? remark, {
  659. CancelToken? cancelToken,
  660. }) async {
  661. //参数
  662. Map<String, String> params = {};
  663. params['job_id'] = jobId ?? "";
  664. params['start_time'] = startTime ?? "";
  665. params['end_time'] = endTime ?? "";
  666. params['outlet_id'] = outletId ?? "";
  667. params['sex_limit'] = sexLimit.toString();
  668. if (sexLimit == 1) {
  669. params['male_limit'] = maleLimit ?? "0";
  670. params['female_limit'] = femaleLimit ?? "0";
  671. // params['need_num'] = (int.parse(maleLimit ?? "0") + int.parse(femaleLimit ?? "0")).toString();
  672. } else {
  673. params['need_num'] = needNum ?? "0";
  674. }
  675. if (Utils.isNotEmpty(requestType)) {
  676. params['request_type'] = requestType ?? "";
  677. }
  678. if (Utils.isNotEmpty(remark)) {
  679. params['remark'] = remark ?? "";
  680. }
  681. final result = await httpProvider.requestNetResult(
  682. ApiConstants.apiJobListEditSubmitSG,
  683. method: HttpMethod.POST,
  684. params: params,
  685. networkDebounce: true,
  686. isShowLoadingDialog: true,
  687. cancelToken: cancelToken,
  688. );
  689. //根据返回的结果,封装原始数据为Bean/Entity对象
  690. if (result.isSuccess) {
  691. //重新赋值data或list
  692. return result.convert();
  693. }
  694. return result.convert();
  695. }
  696. //用工请求的取消(Job List)
  697. Future<HttpResult> cancelJobList(
  698. String? jobId, {
  699. CancelToken? cancelToken,
  700. }) async {
  701. //参数
  702. Map<String, String> params = {};
  703. params['job_id'] = jobId ?? "";
  704. final result = await httpProvider.requestNetResult(
  705. ApiConstants.apiJobListCancelSG,
  706. method: HttpMethod.POST,
  707. params: params,
  708. networkDebounce: true,
  709. isShowLoadingDialog: true,
  710. cancelToken: cancelToken,
  711. );
  712. //根据返回的结果,封装原始数据为Bean/Entity对象
  713. if (result.isSuccess) {
  714. //重新赋值data或list
  715. return result.convert();
  716. }
  717. return result.convert();
  718. }
  719. //用工请求的删除(Job List)
  720. Future<HttpResult> deleteJobList(
  721. String? jobId, {
  722. CancelToken? cancelToken,
  723. }) async {
  724. //参数
  725. Map<String, String> params = {};
  726. params['job_id'] = jobId ?? "";
  727. final result = await httpProvider.requestNetResult(
  728. ApiConstants.apiJobListDeleteSG,
  729. method: HttpMethod.POST,
  730. params: params,
  731. networkDebounce: true,
  732. isShowLoadingDialog: true,
  733. cancelToken: cancelToken,
  734. );
  735. //根据返回的结果,封装原始数据为Bean/Entity对象
  736. if (result.isSuccess) {
  737. //重新赋值data或list
  738. return result.convert();
  739. }
  740. return result.convert();
  741. }
  742. //用工请求的考勤确认(Job List)
  743. Future<HttpResult> confirmJobList(
  744. String? jobId, {
  745. CancelToken? cancelToken,
  746. }) async {
  747. //参数
  748. Map<String, String> params = {};
  749. params['job_id'] = jobId ?? "";
  750. final result = await httpProvider.requestNetResult(
  751. ApiConstants.apiJobListConfirmSG,
  752. method: HttpMethod.POST,
  753. params: params,
  754. networkDebounce: true,
  755. isShowLoadingDialog: true,
  756. cancelToken: cancelToken,
  757. );
  758. //根据返回的结果,封装原始数据为Bean/Entity对象
  759. if (result.isSuccess) {
  760. //重新赋值data或list
  761. return result.convert();
  762. }
  763. return result.convert();
  764. }
  765. }