labour_sg_repository.dart 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  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.isNotEmpty(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? contactNo,
  310. String? description,
  311. String? note,
  312. String? age,
  313. String? sex,
  314. String? withFoodCert,
  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(contactNo)) {
  325. params["contact_no"] = contactNo!;
  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(withFoodCert)) {
  340. params["with_food_cert"] = withFoodCert!;
  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? contactNo,
  366. String? description,
  367. String? note,
  368. String? age,
  369. String? sex,
  370. String? withFoodCert,
  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(contactNo)) {
  382. params["contact_no"] = contactNo!;
  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(withFoodCert)) {
  397. params["with_food_cert"] = withFoodCert!;
  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? positionId,
  497. String? remark, {
  498. CancelToken? cancelToken,
  499. }) async {
  500. //参数
  501. Map<String, String> params = {};
  502. params['job_title_id'] = jobTitleId ?? "";
  503. params['start_time'] = startTime ?? "";
  504. params['end_time'] = endTime ?? "";
  505. params['outlet_id'] = outletId ?? "";
  506. params['sex_limit'] = sexLimit.toString();
  507. if (sexLimit == 1) {
  508. params['male_limit'] = maleLimit ?? "0";
  509. params['female_limit'] = femaleLimit ?? "0";
  510. // params['need_num'] = (int.parse(maleLimit ?? "0") + int.parse(femaleLimit ?? "0")).toString(); //不传 need_num 字段
  511. } else {
  512. params['need_num'] = needNum ?? "0";
  513. }
  514. if (Utils.isNotEmpty(repeatStart)) {
  515. params['repeat_start'] = repeatStart ?? "";
  516. }
  517. if (Utils.isNotEmpty(repeatEnd)) {
  518. params['repeat_end'] = repeatEnd ?? "";
  519. }
  520. if (Utils.isNotEmpty(requestType)) {
  521. params['request_type'] = requestType ?? "";
  522. }
  523. if (Utils.isNotEmpty(positionId) && requestType == "1") {
  524. params['position_id'] = positionId ?? "";
  525. }
  526. if (Utils.isNotEmpty(remark)) {
  527. params['remark'] = remark ?? "";
  528. }
  529. final result = await httpProvider.requestNetResult(
  530. ApiConstants.apiLabourRequestAddSubmitSG,
  531. method: HttpMethod.POST,
  532. params: params,
  533. networkDebounce: true,
  534. isShowLoadingDialog: true,
  535. cancelToken: cancelToken,
  536. );
  537. //根据返回的结果,封装原始数据为Bean/Entity对象
  538. if (result.isSuccess) {
  539. //重新赋值data或list
  540. return result.convert();
  541. }
  542. return result.convert();
  543. }
  544. //用工请求的查询选项(Job List)
  545. Future<HttpResult<JobListIndexSGEntity>> fetchJobListIndex({
  546. CancelToken? cancelToken,
  547. }) async {
  548. final result = await httpProvider.requestNetResult(
  549. ApiConstants.apiJobListIndexSG,
  550. cancelToken: cancelToken,
  551. );
  552. //根据返回的结果,封装原始数据为Bean/Entity对象
  553. if (result.isSuccess) {
  554. //重新赋值data或list
  555. final json = result.getDataJson();
  556. var data = JobListIndexSGEntity.fromJson(json!);
  557. //重新赋值data或list
  558. return result.convert<JobListIndexSGEntity>(data: data);
  559. }
  560. return result.convert();
  561. }
  562. //用工请求的查询列表(Job List)
  563. Future<HttpResult<JobListSGEntity>> fetchJobListTable(
  564. String? startDate,
  565. String? endDate,
  566. String? status,
  567. String? outletId, {
  568. required int curPage,
  569. CancelToken? cancelToken,
  570. }) async {
  571. Map<String, String> params = {};
  572. if (Utils.isNotEmpty(startDate)) {
  573. params['start_date'] = startDate ?? "";
  574. }
  575. if (Utils.isNotEmpty(endDate)) {
  576. params['end_date'] = endDate ?? "";
  577. }
  578. if (Utils.isNotEmpty(status)) {
  579. params['status'] = status ?? "";
  580. }
  581. if (Utils.isNotEmpty(outletId)) {
  582. params['outlet_id'] = outletId ?? "";
  583. }
  584. params['cur_page'] = curPage.toString();
  585. params['page_size'] = "10";
  586. final result = await httpProvider.requestNetResult(
  587. ApiConstants.apiJobListTableSG,
  588. params: params,
  589. cancelToken: cancelToken,
  590. );
  591. //根据返回的结果,封装原始数据为Bean/Entity对象
  592. if (result.isSuccess) {
  593. //重新赋值data或list
  594. final json = result.getDataJson();
  595. var data = JobListSGEntity.fromJson(json!);
  596. //重新赋值data或list
  597. return result.convert<JobListSGEntity>(data: data);
  598. }
  599. return result.convert();
  600. }
  601. /// 根据ID获取主列表的Item数据,用于刷新Item
  602. Future<HttpResult<JobListSGEntity>> fetchJobListByIds(
  603. String? jobId, {
  604. CancelToken? cancelToken,
  605. }) async {
  606. //参数
  607. Map<String, String> params = {};
  608. params["cur_page"] = "1";
  609. params["page_size"] = "9999";
  610. if (!Utils.isEmpty(jobId)) {
  611. params["job_id"] = jobId!;
  612. }
  613. final result = await httpProvider.requestNetResult(
  614. ApiConstants.apiJobListTableSG,
  615. params: params,
  616. cancelToken: cancelToken,
  617. );
  618. //根据返回的结果,封装原始数据为Bean/Entity对象
  619. if (result.isSuccess) {
  620. //重新赋值data或list
  621. final json = result.getDataJson();
  622. var data = JobListSGEntity.fromJson(json!);
  623. //重新赋值data或list
  624. return result.convert<JobListSGEntity>(data: data);
  625. }
  626. return result.convert();
  627. }
  628. //用工请求的编辑详情(Job List)
  629. Future<HttpResult<JobListEditIndexSGEntity>> fetchJobListEditIndex(
  630. String? jobId, {
  631. CancelToken? cancelToken,
  632. }) async {
  633. Map<String, String> params = {};
  634. params['job_id'] = jobId ?? "";
  635. final result = await httpProvider.requestNetResult(
  636. ApiConstants.apiJobListEditIndexSG,
  637. params: params,
  638. isShowLoadingDialog: true,
  639. cancelToken: cancelToken,
  640. );
  641. //根据返回的结果,封装原始数据为Bean/Entity对象
  642. if (result.isSuccess) {
  643. //重新赋值data或list
  644. final json = result.getDataJson();
  645. var data = JobListEditIndexSGEntity.fromJson(json!);
  646. //重新赋值data或list
  647. return result.convert<JobListEditIndexSGEntity>(data: data);
  648. }
  649. return result.convert();
  650. }
  651. //用工请求的编辑提交(Job List)
  652. Future<HttpResult> editJobListSubmit(
  653. String? jobId,
  654. String? startTime,
  655. String? endTime,
  656. String? outletId,
  657. int sexLimit,
  658. String? maleLimit,
  659. String? femaleLimit,
  660. String? needNum,
  661. String? requestType,
  662. String? positionId,
  663. String? remark, {
  664. CancelToken? cancelToken,
  665. }) async {
  666. //参数
  667. Map<String, String> params = {};
  668. params['job_id'] = jobId ?? "";
  669. params['start_time'] = startTime ?? "";
  670. params['end_time'] = endTime ?? "";
  671. params['outlet_id'] = outletId ?? "";
  672. params['sex_limit'] = sexLimit.toString();
  673. if (sexLimit == 1) {
  674. params['male_limit'] = maleLimit ?? "0";
  675. params['female_limit'] = femaleLimit ?? "0";
  676. // params['need_num'] = (int.parse(maleLimit ?? "0") + int.parse(femaleLimit ?? "0")).toString();
  677. } else {
  678. params['need_num'] = needNum ?? "0";
  679. }
  680. if (Utils.isNotEmpty(requestType)) {
  681. params['request_type'] = requestType ?? "";
  682. }
  683. if (Utils.isNotEmpty(positionId) && requestType == "1") {
  684. params['position_id'] = positionId ?? "";
  685. }
  686. if (Utils.isNotEmpty(remark)) {
  687. params['remark'] = remark ?? "";
  688. }
  689. final result = await httpProvider.requestNetResult(
  690. ApiConstants.apiJobListEditSubmitSG,
  691. method: HttpMethod.POST,
  692. params: params,
  693. networkDebounce: true,
  694. isShowLoadingDialog: true,
  695. cancelToken: cancelToken,
  696. );
  697. //根据返回的结果,封装原始数据为Bean/Entity对象
  698. if (result.isSuccess) {
  699. //重新赋值data或list
  700. return result.convert();
  701. }
  702. return result.convert();
  703. }
  704. //用工请求的取消(Job List)
  705. Future<HttpResult> cancelJobList(
  706. String? jobId, {
  707. CancelToken? cancelToken,
  708. }) async {
  709. //参数
  710. Map<String, String> params = {};
  711. params['job_id'] = jobId ?? "";
  712. final result = await httpProvider.requestNetResult(
  713. ApiConstants.apiJobListCancelSG,
  714. method: HttpMethod.POST,
  715. params: params,
  716. networkDebounce: true,
  717. isShowLoadingDialog: true,
  718. cancelToken: cancelToken,
  719. );
  720. //根据返回的结果,封装原始数据为Bean/Entity对象
  721. if (result.isSuccess) {
  722. //重新赋值data或list
  723. return result.convert();
  724. }
  725. return result.convert();
  726. }
  727. //用工请求的删除(Job List)
  728. Future<HttpResult> deleteJobList(
  729. String? jobId, {
  730. CancelToken? cancelToken,
  731. }) async {
  732. //参数
  733. Map<String, String> params = {};
  734. params['job_id'] = jobId ?? "";
  735. final result = await httpProvider.requestNetResult(
  736. ApiConstants.apiJobListDeleteSG,
  737. method: HttpMethod.POST,
  738. params: params,
  739. networkDebounce: true,
  740. isShowLoadingDialog: true,
  741. cancelToken: cancelToken,
  742. );
  743. //根据返回的结果,封装原始数据为Bean/Entity对象
  744. if (result.isSuccess) {
  745. //重新赋值data或list
  746. return result.convert();
  747. }
  748. return result.convert();
  749. }
  750. //用工请求的考勤确认(Job List)
  751. Future<HttpResult> confirmJobList(
  752. String? jobId, {
  753. CancelToken? cancelToken,
  754. }) async {
  755. //参数
  756. Map<String, String> params = {};
  757. params['job_id'] = jobId ?? "";
  758. final result = await httpProvider.requestNetResult(
  759. ApiConstants.apiJobListConfirmSG,
  760. method: HttpMethod.POST,
  761. params: params,
  762. networkDebounce: true,
  763. isShowLoadingDialog: true,
  764. cancelToken: cancelToken,
  765. );
  766. //根据返回的结果,封装原始数据为Bean/Entity对象
  767. if (result.isSuccess) {
  768. //重新赋值data或list
  769. return result.convert();
  770. }
  771. return result.convert();
  772. }
  773. }