job_repository.dart 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. import 'dart:typed_data';
  2. import 'package:domain/entity/response/job_list_add_staff_entity.dart';
  3. import 'package:domain/entity/response/job_list_applied_edit_entity.dart';
  4. import 'package:domain/entity/response/job_list_applied_info_entity.dart';
  5. import 'package:domain/entity/response/job_list_applied_staff_list_entity.dart';
  6. import 'package:domain/entity/response/job_list_applied_staff_search_entity.dart';
  7. import 'package:domain/entity/response/job_list_detail_entity.dart';
  8. import 'package:domain/entity/response/job_list_entity.dart';
  9. import 'package:domain/entity/response/job_list_index_entity.dart';
  10. import 'package:domain/entity/response/job_list_remark_view_entity.dart';
  11. import 'package:domain/entity/response/staff_detail_entity.dart';
  12. import 'package:domain/entity/response/staff_labour_history_entity.dart';
  13. import 'package:domain/entity/response/staff_remark_history_entity.dart';
  14. import 'package:get/get.dart';
  15. import 'package:plugin_platform/dio_export.dart';
  16. import 'package:plugin_platform/http/http_provider.dart';
  17. import 'package:plugin_platform/http/http_result.dart';
  18. import 'package:shared/utils/util.dart';
  19. import '../constants/api_constants.dart';
  20. import '../entity/response/attendance_entity.dart';
  21. import '../entity/response/attendance_review_entity.dart';
  22. import '../entity/response/check_success_entity.dart';
  23. import '../entity/response/job_list_applied_work_flow_entity.dart';
  24. /// 工作相关
  25. class JobRepository extends GetxService {
  26. HttpProvider httpProvider;
  27. JobRepository({required this.httpProvider});
  28. /// 获取当前酒店的考勤成员列表
  29. Future<HttpResult<AttendanceEntity>> fetchAttendanceList(
  30. String? keyword,
  31. String? startDate,
  32. String? endDate, {
  33. CancelToken? cancelToken,
  34. }) async {
  35. Map<String, String> params = {};
  36. params["cur_page"] = "1";
  37. params["page_size"] = "9999";
  38. if (!Utils.isEmpty(keyword)) {
  39. params["keyword"] = keyword!;
  40. }
  41. if (!Utils.isEmpty(startDate)) {
  42. params["start_date"] = startDate!;
  43. }
  44. if (!Utils.isEmpty(endDate)) {
  45. params["end_date"] = endDate!;
  46. }
  47. final result = await httpProvider.requestNetResult(
  48. ApiConstants.apiSignApplied,
  49. params: params,
  50. cancelToken: cancelToken,
  51. );
  52. //根据返回的结果,封装原始数据为Bean/Entity对象
  53. if (result.isSuccess) {
  54. //重新赋值data或list
  55. final json = result.getDataJson();
  56. var data = AttendanceEntity.fromJson(json!);
  57. //重新赋值data或list
  58. return result.convert<AttendanceEntity>(data: data);
  59. }
  60. return result.convert();
  61. }
  62. /// 用户上传考勤
  63. Future<HttpResult<CheckSuccessEntity>> submitCheckInOut(
  64. String? appliedId,
  65. ByteData? byteData, {
  66. bool isCheckIn = false,
  67. CancelToken? cancelToken,
  68. }) async {
  69. //Post请求
  70. Map<String, String> params = {};
  71. params['applied_id'] = appliedId ?? "";
  72. params['check_type'] = isCheckIn ? "1" : "2";
  73. Map<String, Uint8List> streams = {};
  74. if (byteData != null) {
  75. streams["capture"] = byteData.buffer.asUint8List();
  76. }
  77. final result = await httpProvider.requestNetResult(
  78. method: HttpMethod.POST,
  79. ApiConstants.apiSignInOut,
  80. params: params,
  81. pathStreams: streams,
  82. networkDebounce: true,
  83. isShowLoadingDialog: true,
  84. cancelToken: cancelToken,
  85. );
  86. //根据返回的结果,封装原始数据为Bean/Entity对象
  87. if (result.isSuccess) {
  88. final json = result.getDataJson();
  89. var data = CheckSuccessEntity.fromJson(json!);
  90. //重新赋值data
  91. return result.convert<CheckSuccessEntity>(data: data);
  92. }
  93. return result.convert<CheckSuccessEntity>();
  94. }
  95. /// 工作列表的筛选选项
  96. Future<HttpResult<JobListIndexEntity>> fetchJobListIndex({
  97. CancelToken? cancelToken,
  98. }) async {
  99. final result = await httpProvider.requestNetResult(
  100. ApiConstants.apiJobListIndex,
  101. cancelToken: cancelToken,
  102. );
  103. //根据返回的结果,封装原始数据为Bean/Entity对象
  104. if (result.isSuccess) {
  105. //重新赋值data或list
  106. final json = result.getDataJson();
  107. var data = JobListIndexEntity.fromJson(json!);
  108. //重新赋值data或list
  109. return result.convert<JobListIndexEntity>(data: data);
  110. }
  111. return result.convert();
  112. }
  113. /// 获取工作列表的主列表
  114. Future<HttpResult<JobListEntity>> fetchJobListTable(
  115. String? keyword,
  116. String? startDate,
  117. String? endDate,
  118. String? statusId,
  119. String? departmentId, {
  120. required int curPage,
  121. CancelToken? cancelToken,
  122. }) async {
  123. //参数
  124. Map<String, String> params = {};
  125. params["cur_page"] = curPage.toString();
  126. params["page_size"] = "20";
  127. if (!Utils.isEmpty(keyword)) {
  128. params["job_title"] = keyword!;
  129. }
  130. if (!Utils.isEmpty(startDate)) {
  131. params["start_time"] = startDate!;
  132. }
  133. if (!Utils.isEmpty(endDate)) {
  134. params["end_time"] = endDate!;
  135. }
  136. if (!Utils.isEmpty(statusId)) {
  137. params["status"] = statusId!;
  138. }
  139. if (!Utils.isEmpty(departmentId)) {
  140. params["co_department_id"] = departmentId!;
  141. }
  142. final result = await httpProvider.requestNetResult(
  143. ApiConstants.apiJobListTable,
  144. params: params,
  145. cancelToken: cancelToken,
  146. );
  147. //根据返回的结果,封装原始数据为Bean/Entity对象
  148. if (result.isSuccess) {
  149. //重新赋值data或list
  150. final json = result.getDataJson();
  151. var data = JobListEntity.fromJson(json!);
  152. //重新赋值data或list
  153. return result.convert<JobListEntity>(data: data);
  154. }
  155. return result.convert();
  156. }
  157. /// 工作列表的详情
  158. Future<HttpResult<JobListDetailEntity>> fetchJobListDetail(
  159. String? jobId, {
  160. CancelToken? cancelToken,
  161. }) async {
  162. //参数
  163. Map<String, String> params = {};
  164. params['job_id'] = jobId ?? "";
  165. final result = await httpProvider.requestNetResult(
  166. ApiConstants.apiJobListDetail,
  167. params: params,
  168. isShowLoadingDialog: true,
  169. cancelToken: cancelToken,
  170. );
  171. //根据返回的结果,封装原始数据为Bean/Entity对象
  172. if (result.isSuccess) {
  173. //重新赋值data或list
  174. final json = result.getDataJson();
  175. var data = JobListDetailEntity.fromJson(json!);
  176. //重新赋值data或list
  177. return result.convert<JobListDetailEntity>(data: data);
  178. }
  179. return result.convert();
  180. }
  181. /// 工作中已申请的工作信息
  182. Future<HttpResult<JobListAppliedInfoEntity>> fetchJobAppliedInfo(
  183. String? jobId, {
  184. CancelToken? cancelToken,
  185. }) async {
  186. //参数
  187. Map<String, String> params = {};
  188. params['job_id'] = jobId ?? "";
  189. final result = await httpProvider.requestNetResult(
  190. ApiConstants.apiJobListAppliedJobInfo,
  191. params: params,
  192. cancelToken: cancelToken,
  193. );
  194. //根据返回的结果,封装原始数据为Bean/Entity对象
  195. if (result.isSuccess) {
  196. //重新赋值data或list
  197. final json = result.getDataJson();
  198. var data = JobListAppliedInfoEntity.fromJson(json!);
  199. //重新赋值data或list
  200. return result.convert<JobListAppliedInfoEntity>(data: data);
  201. }
  202. return result.convert();
  203. }
  204. /// 工作中已申请的成员列表
  205. Future<HttpResult<JobListAppliedStaffListEntity>> fetchJobAppliedStaffs(
  206. String? jobId,
  207. String? staffName, {
  208. String? appliedId,
  209. required int curPage,
  210. CancelToken? cancelToken,
  211. }) async {
  212. //参数
  213. Map<String, String> params = {};
  214. params["cur_page"] = curPage.toString();
  215. params["page_size"] = "10";
  216. if (!Utils.isEmpty(jobId)) {
  217. params["job_id"] = jobId!;
  218. }
  219. if (!Utils.isEmpty(appliedId)) {
  220. params["applied_id"] = appliedId!;
  221. }
  222. if (!Utils.isEmpty(staffName)) {
  223. params["staff_name"] = staffName!;
  224. }
  225. final result = await httpProvider.requestNetResult(
  226. ApiConstants.apiJobListAppliedStaffList,
  227. params: params,
  228. cancelToken: cancelToken,
  229. );
  230. //根据返回的结果,封装原始数据为Bean/Entity对象
  231. if (result.isSuccess) {
  232. //重新赋值data或list
  233. final json = result.getDataJson();
  234. var data = JobListAppliedStaffListEntity.fromJson(json!);
  235. //重新赋值data或list
  236. return result.convert<JobListAppliedStaffListEntity>(data: data);
  237. }
  238. return result.convert();
  239. }
  240. /// 根据ID获取主列表的Item数据,用于刷新Item
  241. Future<HttpResult<JobListAppliedStaffListEntity>> fetchItemByAppliedIds(
  242. String? jobId,
  243. String? appliedIds, {
  244. CancelToken? cancelToken,
  245. }) async {
  246. //参数
  247. Map<String, String> params = {};
  248. params["cur_page"] = "1";
  249. params["page_size"] = "9999";
  250. if (!Utils.isEmpty(appliedIds)) {
  251. params["applied_ids"] = appliedIds!;
  252. }
  253. if (!Utils.isEmpty(jobId)) {
  254. params["job_id"] = jobId!;
  255. }
  256. final result = await httpProvider.requestNetResult(
  257. ApiConstants.apiJobListAppliedStaffList,
  258. params: params,
  259. isShowLoadingDialog: true,
  260. cancelToken: cancelToken,
  261. );
  262. //根据返回的结果,封装原始数据为Bean/Entity对象
  263. if (result.isSuccess) {
  264. //重新赋值data或list
  265. final json = result.getDataJson();
  266. var data = JobListAppliedStaffListEntity.fromJson(json!);
  267. //重新赋值data或list
  268. return result.convert<JobListAppliedStaffListEntity>(data: data);
  269. }
  270. return result.convert();
  271. }
  272. /// 添加员工的全部员工数据列表
  273. Future<HttpResult<JobListAppliedStaffSearchEntity>> searchStaffList(
  274. String? jobId,
  275. String? keyword, {
  276. required int curPage,
  277. CancelToken? cancelToken,
  278. }) async {
  279. //参数
  280. Map<String, String> params = {};
  281. params["cur_page"] = curPage.toString();
  282. params["page_size"] = "10";
  283. if (!Utils.isEmpty(jobId)) {
  284. params["job_id"] = jobId!;
  285. }
  286. if (!Utils.isEmpty(keyword)) {
  287. params["keyword"] = keyword!;
  288. }
  289. final result = await httpProvider.requestNetResult(
  290. ApiConstants.apiJobListAppliedStaffSearch,
  291. params: params,
  292. cancelToken: cancelToken,
  293. );
  294. //根据返回的结果,封装原始数据为Bean/Entity对象
  295. if (result.isSuccess) {
  296. //重新赋值data或list
  297. final json = result.getDataJson();
  298. var data = JobListAppliedStaffSearchEntity.fromJson(json!);
  299. //重新赋值data或list
  300. return result.convert<JobListAppliedStaffSearchEntity>(data: data);
  301. }
  302. return result.convert();
  303. }
  304. /// 添加员工到工作
  305. Future<HttpResult<JobListAddStaffEntity>> addStaff2Job(
  306. String? jobId,
  307. String? staffIds, {
  308. CancelToken? cancelToken,
  309. }) async {
  310. //参数
  311. Map<String, String> params = {};
  312. if (!Utils.isEmpty(jobId)) {
  313. params["job_id"] = jobId!;
  314. }
  315. if (!Utils.isEmpty(staffIds)) {
  316. params["staff_ids"] = staffIds!;
  317. }
  318. final result = await httpProvider.requestNetResult(
  319. ApiConstants.apiJobListAppliedStaffAdd,
  320. isShowLoadingDialog: true,
  321. method: HttpMethod.POST,
  322. params: params,
  323. cancelToken: cancelToken,
  324. );
  325. //根据返回的结果,封装原始数据为Bean/Entity对象
  326. if (result.isSuccess) {
  327. //重新赋值data或list
  328. final json = result.getDataJson();
  329. var data = JobListAddStaffEntity.fromJson(json!);
  330. //重新赋值data或list
  331. return result.convert<JobListAddStaffEntity>(data: data);
  332. }
  333. return result.convert();
  334. }
  335. /// 批量修改员工的签到信息与状态
  336. Future<HttpResult> batchEditStaffCheckTime(
  337. String? jobId,
  338. String? appliedIds,
  339. String? startTime,
  340. String? endTime, {
  341. CancelToken? cancelToken,
  342. }) async {
  343. //参数
  344. Map<String, String> params = {};
  345. if (!Utils.isEmpty(startTime)) {
  346. params["start_time"] = startTime!;
  347. }
  348. if (!Utils.isEmpty(endTime)) {
  349. params["end_time"] = endTime!;
  350. }
  351. if (!Utils.isEmpty(appliedIds)) {
  352. params["applied_ids"] = appliedIds!;
  353. }
  354. if (!Utils.isEmpty(jobId)) {
  355. params["job_id"] = jobId!;
  356. }
  357. final result = await httpProvider.requestNetResult(
  358. ApiConstants.apiJobListAppliedStaffBatchEdit,
  359. isShowLoadingDialog: true,
  360. method: HttpMethod.POST,
  361. params: params,
  362. cancelToken: cancelToken,
  363. );
  364. //根据返回的结果,封装原始数据为Bean/Entity对象
  365. if (result.isSuccess) {
  366. //重新赋值data或list
  367. return result.convert();
  368. }
  369. return result.convert();
  370. }
  371. /// 获取单个员工的信息,准备修改
  372. Future<HttpResult<JobListAppliedEditEntity>> fetchAppliedEditView(
  373. String? appliedId, {
  374. CancelToken? cancelToken,
  375. }) async {
  376. //参数
  377. Map<String, String> params = {};
  378. if (!Utils.isEmpty(appliedId)) {
  379. params["applied_id"] = appliedId!;
  380. }
  381. final result = await httpProvider.requestNetResult(
  382. ApiConstants.apiJobListAppliedStaffEditIndex,
  383. isShowLoadingDialog: true,
  384. params: params,
  385. cancelToken: cancelToken,
  386. );
  387. //根据返回的结果,封装原始数据为Bean/Entity对象
  388. if (result.isSuccess) {
  389. //重新赋值data或list
  390. final json = result.getDataJson();
  391. var data = JobListAppliedEditEntity.fromJson(json!);
  392. //重新赋值data或list
  393. return result.convert<JobListAppliedEditEntity>(data: data);
  394. }
  395. return result.convert();
  396. }
  397. /// 单独修改单个员工的信息
  398. Future<HttpResult> editAppliedSingleStaffInfo(
  399. String? appliedId,
  400. JobListAppliedEditEntity entity, {
  401. CancelToken? cancelToken,
  402. }) async {
  403. //参数
  404. Map<String, String> params = {};
  405. if (!Utils.isEmpty(appliedId)) {
  406. params["applied_id"] = appliedId!;
  407. }
  408. if (!Utils.isEmpty(entity.startTime)) {
  409. params["start_time"] = entity.startTime!;
  410. }
  411. if (!Utils.isEmpty(entity.endTime)) {
  412. params["end_time"] = entity.endTime!;
  413. }
  414. if (!Utils.isEmpty(entity.securityIn)) {
  415. params["security_in"] = entity.securityIn!;
  416. }
  417. if (!Utils.isEmpty(entity.securityOut)) {
  418. params["security_out"] = entity.securityOut!;
  419. }
  420. if (!Utils.isEmpty(entity.workIn)) {
  421. params["work_in"] = entity.workIn!;
  422. }
  423. if (!Utils.isEmpty(entity.workOut)) {
  424. params["work_out"] = entity.workOut!;
  425. }
  426. if (entity.jobUnit == "hour") {
  427. if (!Utils.isEmpty(entity.adjustHours)) {
  428. params["adjust_hours"] = entity.adjustHours!;
  429. }
  430. } else {
  431. if (entity.totalRooms != 0) {
  432. params["total_rooms"] = entity.totalRooms.toString();
  433. }
  434. }
  435. if (entity.reasonType != 0) {
  436. params["co_reason_type"] = entity.reasonType.toString();
  437. }
  438. if (!Utils.isEmpty(entity.coReason)) {
  439. params["co_reason"] = entity.coReason!;
  440. }
  441. final result = await httpProvider.requestNetResult(
  442. ApiConstants.apiJobListAppliedStaffEditSubmit,
  443. isShowLoadingDialog: true,
  444. method: HttpMethod.POST,
  445. params: params,
  446. cancelToken: cancelToken,
  447. );
  448. //根据返回的结果,封装原始数据为Bean/Entity对象
  449. if (result.isSuccess) {
  450. //重新赋值data或list
  451. return result.convert();
  452. }
  453. return result.convert();
  454. }
  455. /// 给员工评分的详情与选项
  456. Future<HttpResult<JobListRemarkViewEntity>> fetchAppliedStaffReviewView(
  457. String? appliedId, {
  458. CancelToken? cancelToken,
  459. }) async {
  460. //参数
  461. Map<String, String> params = {};
  462. if (!Utils.isEmpty(appliedId)) {
  463. params["applied_id"] = appliedId!;
  464. }
  465. final result = await httpProvider.requestNetResult(
  466. ApiConstants.apiJobListAppliedStaffReviewIndex,
  467. isShowLoadingDialog: true,
  468. params: params,
  469. cancelToken: cancelToken,
  470. );
  471. //根据返回的结果,封装原始数据为Bean/Entity对象
  472. if (result.isSuccess) {
  473. //重新赋值data或list
  474. final json = result.getDataJson();
  475. var data = JobListRemarkViewEntity.fromJson(json!);
  476. //重新赋值data或list
  477. return result.convert<JobListRemarkViewEntity>(data: data);
  478. }
  479. return result.convert();
  480. }
  481. /// 单独给单个员工评分的提交
  482. Future<HttpResult> remarkAppliedSingleStaffSubmit(
  483. String? appliedId,
  484. String? attitude_rate,
  485. String? grooming_rate,
  486. String? performance_rate,
  487. String? experience_rate,
  488. String? content, {
  489. CancelToken? cancelToken,
  490. }) async {
  491. //参数
  492. Map<String, String> params = {};
  493. if (!Utils.isEmpty(appliedId)) {
  494. params["applied_id"] = appliedId!;
  495. }
  496. if (!Utils.isEmpty(attitude_rate)) {
  497. params["attitude_rate"] = attitude_rate!;
  498. }
  499. if (!Utils.isEmpty(grooming_rate)) {
  500. params["grooming_rate"] = grooming_rate!;
  501. }
  502. if (!Utils.isEmpty(performance_rate)) {
  503. params["performance_rate"] = performance_rate!;
  504. }
  505. if (!Utils.isEmpty(experience_rate)) {
  506. params["experience_rate"] = experience_rate!;
  507. }
  508. if (!Utils.isEmpty(content)) {
  509. params["content"] = content!;
  510. }
  511. final result = await httpProvider.requestNetResult(
  512. ApiConstants.apiJobListAppliedStaffReviewSubmit,
  513. isShowLoadingDialog: true,
  514. method: HttpMethod.POST,
  515. params: params,
  516. cancelToken: cancelToken,
  517. );
  518. //根据返回的结果,封装原始数据为Bean/Entity对象
  519. if (result.isSuccess) {
  520. //重新赋值data或list
  521. return result.convert();
  522. }
  523. return result.convert();
  524. }
  525. /// 批量提交多个员工的考勤
  526. Future<HttpResult> submitBatchStaffApprove(
  527. String? appliedIds, {
  528. CancelToken? cancelToken,
  529. }) async {
  530. //参数
  531. Map<String, String> params = {};
  532. if (!Utils.isEmpty(appliedIds)) {
  533. params["applied_ids"] = appliedIds!;
  534. }
  535. final result = await httpProvider.requestNetResult(
  536. ApiConstants.apiJobListAppliedApprove,
  537. isShowLoadingDialog: true,
  538. method: HttpMethod.POST,
  539. params: params,
  540. cancelToken: cancelToken,
  541. );
  542. //根据返回的结果,封装原始数据为Bean/Entity对象
  543. if (result.isSuccess) {
  544. //重新赋值data或list
  545. return result.convert();
  546. }
  547. return result.convert();
  548. }
  549. // 员工状态的工作流
  550. Future<HttpResult<JobListAppliedWorkFlowEntity>> fetchAppliedWorkFlow(
  551. String? appliedId, {
  552. CancelToken? cancelToken,
  553. }) async {
  554. //参数
  555. Map<String, String> params = {};
  556. if (!Utils.isEmpty(appliedId)) {
  557. params["applied_id"] = appliedId!;
  558. }
  559. final result = await httpProvider.requestNetResult(
  560. ApiConstants.apiJobListAppliedStaffStateWorkflow,
  561. params: params,
  562. cancelToken: cancelToken,
  563. );
  564. //根据返回的结果,封装原始数据为Bean/Entity对象
  565. if (result.isSuccess) {
  566. //重新赋值data或list
  567. final json = result.getDataJson();
  568. var data = JobListAppliedWorkFlowEntity.fromJson(json!);
  569. //重新赋值data或list
  570. return result.convert<JobListAppliedWorkFlowEntity>(data: data);
  571. }
  572. return result.convert();
  573. }
  574. // 员工的信息
  575. Future<HttpResult<StaffDetailEntity>> fetchStaffDetail(
  576. String? memberId, {
  577. CancelToken? cancelToken,
  578. }) async {
  579. //参数
  580. Map<String, String> params = {};
  581. if (!Utils.isEmpty(memberId)) {
  582. params["member_id"] = memberId!;
  583. }
  584. final result = await httpProvider.requestNetResult(
  585. ApiConstants.apiJobListStaffDetail,
  586. params: params,
  587. cancelToken: cancelToken,
  588. );
  589. //根据返回的结果,封装原始数据为Bean/Entity对象
  590. if (result.isSuccess) {
  591. //重新赋值data或list
  592. final json = result.getDataJson();
  593. var data = StaffDetailEntity.fromJson(json!);
  594. //重新赋值data或list
  595. return result.convert<StaffDetailEntity>(data: data);
  596. }
  597. return result.convert();
  598. }
  599. // 员工的历史申请记录
  600. Future<HttpResult<StaffLabourHistoryEntity>> fetchStaffLabourHistory(
  601. String? memberId,
  602. String? keyword, {
  603. required int curPage,
  604. CancelToken? cancelToken,
  605. }) async {
  606. //参数
  607. Map<String, String> params = {};
  608. params["cur_page"] = curPage.toString();
  609. params["page_size"] = "10";
  610. if (!Utils.isEmpty(memberId)) {
  611. params["member_id"] = memberId!;
  612. }
  613. if (!Utils.isEmpty(keyword)) {
  614. params["keyword"] = keyword!;
  615. }
  616. final result = await httpProvider.requestNetResult(
  617. ApiConstants.apiJobListStaffLabourHistory,
  618. params: params,
  619. cancelToken: cancelToken,
  620. );
  621. //根据返回的结果,封装原始数据为Bean/Entity对象
  622. if (result.isSuccess) {
  623. //重新赋值data或list
  624. final json = result.getDataJson();
  625. var data = StaffLabourHistoryEntity.fromJson(json!);
  626. //重新赋值data或list
  627. return result.convert<StaffLabourHistoryEntity>(data: data);
  628. }
  629. return result.convert();
  630. }
  631. // 员工的历史评价记录
  632. Future<HttpResult<StaffRemarkHistoryEntity>> fetchStaffRemarkHistory(
  633. String? memberId, {
  634. required int curPage,
  635. CancelToken? cancelToken,
  636. }) async {
  637. //参数
  638. Map<String, String> params = {};
  639. params["cur_page"] = curPage.toString();
  640. params["page_size"] = "10";
  641. if (!Utils.isEmpty(memberId)) {
  642. params["member_id"] = memberId!;
  643. }
  644. final result = await httpProvider.requestNetResult(
  645. ApiConstants.apiJobListStaffRemarkHistory,
  646. params: params,
  647. cancelToken: cancelToken,
  648. );
  649. //根据返回的结果,封装原始数据为Bean/Entity对象
  650. if (result.isSuccess) {
  651. //重新赋值data或list
  652. final json = result.getDataJson();
  653. var data = StaffRemarkHistoryEntity.fromJson(json!);
  654. //重新赋值data或list
  655. return result.convert<StaffRemarkHistoryEntity>(data: data);
  656. }
  657. return result.convert();
  658. }
  659. /// 考勤审核列表
  660. Future<HttpResult<AttendanceReviewEntity>> fetchAttendanceReviewList(
  661. String? keyword, {
  662. required int curPage,
  663. CancelToken? cancelToken,
  664. }) async {
  665. //参数
  666. Map<String, String> params = {};
  667. params["cur_page"] = curPage.toString();
  668. params["page_size"] = "20";
  669. if (!Utils.isEmpty(keyword)) {
  670. params["staff_name"] = keyword!;
  671. }
  672. final result = await httpProvider.requestNetResult(
  673. ApiConstants.apiAttendanceReviewTable,
  674. params: params,
  675. cancelToken: cancelToken,
  676. );
  677. //根据返回的结果,封装原始数据为Bean/Entity对象
  678. if (result.isSuccess) {
  679. //重新赋值data或list
  680. final json = result.getDataJson();
  681. var data = AttendanceReviewEntity.fromJson(json!);
  682. //重新赋值data或list
  683. return result.convert<AttendanceReviewEntity>(data: data);
  684. }
  685. return result.convert();
  686. }
  687. /// 考勤的批量同意
  688. Future<HttpResult> approveAttendanceReviews(
  689. String? recordIds, {
  690. CancelToken? cancelToken,
  691. }) async {
  692. //参数
  693. Map<String, String> params = {};
  694. params['record_ids'] = recordIds ?? "";
  695. final result = await httpProvider.requestNetResult(
  696. ApiConstants.apiAttendanceReviewApprove,
  697. method: HttpMethod.POST,
  698. params: params,
  699. networkDebounce: true,
  700. isShowLoadingDialog: true,
  701. cancelToken: cancelToken,
  702. );
  703. //根据返回的结果,封装原始数据为Bean/Entity对象
  704. if (result.isSuccess) {
  705. //重新赋值data或list
  706. return result.convert();
  707. }
  708. return result.convert();
  709. }
  710. /// 考勤的批量拒绝
  711. Future<HttpResult> rejectLabourReviews(
  712. String? recordIds,
  713. String? reason, {
  714. CancelToken? cancelToken,
  715. }) async {
  716. //参数
  717. Map<String, String> params = {};
  718. params['record_ids'] = recordIds ?? "";
  719. if (Utils.isNotEmpty(reason)) {
  720. params['audit_mark'] = reason ?? "";
  721. }
  722. final result = await httpProvider.requestNetResult(
  723. ApiConstants.apiAttendanceReviewReject,
  724. method: HttpMethod.POST,
  725. params: params,
  726. networkDebounce: true,
  727. isShowLoadingDialog: true,
  728. cancelToken: cancelToken,
  729. );
  730. //根据返回的结果,封装原始数据为Bean/Entity对象
  731. if (result.isSuccess) {
  732. //重新赋值data或list
  733. return result.convert();
  734. }
  735. return result.convert();
  736. }
  737. }