123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717 |
- import 'package:domain/entity/response/labour_request_edit_index_entity.dart';
- import 'package:domain/entity/response/labour_request_index_entity.dart';
- import 'package:domain/entity/response/labour_request_list_entity.dart';
- import 'package:domain/entity/response/labour_request_work_flow_entity.dart';
- import 'package:get/get.dart';
- import 'package:plugin_platform/dio_export.dart';
- import 'package:plugin_platform/http/http_provider.dart';
- import 'package:plugin_platform/http/http_result.dart';
- import 'package:shared/utils/util.dart';
- import '../constants/api_constants.dart';
- import '../entity/response/job_template_edit_index_entity.dart';
- import '../entity/response/labour_review_list_entity.dart';
- import '../entity/response/labour_review_status_entity.dart';
- /// 用工请求相关
- class LabourRepository extends GetxService {
- HttpProvider httpProvider;
- LabourRepository({required this.httpProvider});
- /// 获取用工请求的筛选选项
- Future<HttpResult<LabourRequestIndexEntity>> fetchLabourRequestIndex({
- CancelToken? cancelToken,
- }) async {
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestIndex,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourRequestIndexEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourRequestIndexEntity>(data: data);
- }
- return result.convert();
- }
- /// 获取用工请求的主列表
- Future<HttpResult<LabourRequestListEntity>> fetchLabourRequestList(
- String? keyword,
- String? startDate,
- String? endDate,
- String? statusId,
- String? departmentId, {
- required int curPage,
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = curPage.toString();
- params["page_size"] = "20";
- if (!Utils.isEmpty(keyword)) {
- params["job_title"] = keyword!;
- }
- if (!Utils.isEmpty(startDate)) {
- params["job_start"] = startDate!;
- }
- if (!Utils.isEmpty(endDate)) {
- params["job_end"] = endDate!;
- }
- if (!Utils.isEmpty(statusId)) {
- params["co_status"] = statusId!;
- }
- if (!Utils.isEmpty(departmentId)) {
- params["co_department_id"] = departmentId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestList,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourRequestListEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourRequestListEntity>(data: data);
- }
- return result.convert();
- }
- /// 根据ID获取主列表的Item数据,用于刷新Item
- Future<HttpResult<LabourRequestListEntity>> fetchItemByRequestId(
- String? requestId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = "1";
- params["page_size"] = "1";
- if (!Utils.isEmpty(requestId)) {
- params["request_id"] = requestId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestList,
- params: params,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourRequestListEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourRequestListEntity>(data: data);
- }
- return result.convert();
- }
- /// 添加用工的选项
- Future<HttpResult<LabourRequestEditIndexEntity>> fetchLabourRequestAddOption({
- CancelToken? cancelToken,
- }) async {
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestAddOption,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourRequestEditIndexEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourRequestEditIndexEntity>(data: data);
- }
- return result.convert();
- }
- /// 添加用工请求发布
- Future<HttpResult> addLabourRequestSubmit(
- String? templateId,
- String? jobStart,
- String? jobEnd,
- String? departmentId,
- String? needNum,
- String? salaryBy,
- String? amount, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['template_id'] = templateId ?? "";
- params['job_start'] = jobStart ?? "";
- params['job_end'] = jobEnd ?? "";
- params['need_num'] = needNum ?? "";
- if (!Utils.isEmpty(departmentId)) {
- params["co_department_id"] = departmentId!;
- }
- params['salary_by'] = salaryBy ?? "";
- if (!Utils.isEmpty(amount)) {
- params["amount"] = amount!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestAddSubmit,
- method: HttpMethod.POST,
- params: params,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 用工的编辑详情
- Future<HttpResult<LabourRequestEditIndexEntity>> fetchLabourRequestEditDetail(
- String? requestId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['request_id'] = requestId ?? "";
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestEditDetail,
- params: params,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourRequestEditIndexEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourRequestEditIndexEntity>(data: data);
- }
- return result.convert();
- }
- /// 编辑用工请求发布
- Future<HttpResult> editLabourRequestSubmit(
- String? requestId,
- String? templateId,
- String? jobStart,
- String? jobEnd,
- String? departmentId,
- String? needNum,
- String? salaryBy,
- String? amount, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['request_id'] = requestId ?? "";
- params['template_id'] = templateId ?? "";
- params['job_start'] = jobStart ?? "";
- params['job_end'] = jobEnd ?? "";
- params['need_num'] = needNum ?? "";
- if (!Utils.isEmpty(departmentId)) {
- params["co_department_id"] = departmentId!;
- }
- params['salary_by'] = salaryBy ?? "";
- if (!Utils.isEmpty(amount)) {
- params["amount"] = amount!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestEditSubmit,
- method: HttpMethod.POST,
- params: params,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 撤回用工请求
- Future<HttpResult> recallLabourRequest(
- String? requestId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['request_id'] = requestId ?? "";
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestRecall,
- method: HttpMethod.POST,
- params: params,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 用工的审核详情工作流列表
- Future<HttpResult<LabourRequestWorkFlowEntity>> fetchLabourRequestWorkFlow(
- String? requestId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(requestId)) {
- params["request_id"] = requestId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourRequestStateWorkFlow,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourRequestWorkFlowEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourRequestWorkFlowEntity>(data: data);
- }
- return result.convert();
- }
- /// 添加工作模板的详情或选项数据
- Future<HttpResult<JobTemplateEditIndexEntity>> fetchJobTemplateAddIndex({
- CancelToken? cancelToken,
- }) async {
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobTemplateAddIndexSG,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobTemplateEditIndexEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobTemplateEditIndexEntity>(data: data);
- }
- return result.convert();
- }
- /// 编辑工作模板的详情或选项数据
- Future<HttpResult<JobTemplateEditIndexEntity>> fetchJobTemplateEditIndex(
- String? templateId, {
- CancelToken? cancelToken,
- }) async {
- Map<String, String> params = {};
- params["template_id"] = templateId ?? "";
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobTemplateEditIndexSG,
- params: params,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobTemplateEditIndexEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobTemplateEditIndexEntity>(data: data);
- }
- return result.convert();
- }
- /// 添加工作模板的提交
- Future<HttpResult> addLabourTemplateSubmit(
- String? name,
- String? description,
- String? note,
- String? age,
- String? sex,
- String? language, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['job_title'] = name ?? "";
- if (!Utils.isEmpty(description)) {
- params["description"] = description!;
- }
- if (!Utils.isEmpty(note)) {
- params["note"] = note!;
- }
- if (!Utils.isEmpty(age)) {
- params["age"] = age!;
- }
- if (!Utils.isEmpty(sex)) {
- params["gender"] = sex!;
- }
- if (!Utils.isEmpty(language)) {
- params["language"] = language!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobTemplateAddSubmitSG,
- method: HttpMethod.POST,
- params: params,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 编辑工作模板的提交
- Future<HttpResult> editLabourTemplateSubmit(
- String? templateId,
- String? name,
- String? description,
- String? note,
- String? age,
- String? sex,
- String? language, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['job_title'] = name ?? "";
- params['template_id'] = templateId ?? "";
- if (!Utils.isEmpty(description)) {
- params["description"] = description!;
- }
- if (!Utils.isEmpty(note)) {
- params["note"] = note!;
- }
- if (!Utils.isEmpty(age)) {
- params["age"] = age!;
- }
- if (!Utils.isEmpty(sex)) {
- params["gender"] = sex!;
- }
- if (!Utils.isEmpty(language)) {
- params["language"] = language!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobTemplateEditSubmitSG,
- method: HttpMethod.POST,
- params: params,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 用工审核选项
- Future<HttpResult<LabourRequestIndexEntity>> fetchLabourReviewIndex({
- CancelToken? cancelToken,
- }) async {
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourReviewIndex,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourRequestIndexEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourRequestIndexEntity>(data: data);
- }
- return result.convert();
- }
- /// 用工审核列表
- Future<HttpResult<LabourReviewListEntity>> fetchLabourReviewList(
- String? keyword,
- String? startDate,
- String? endDate,
- String? departmentId, {
- required int curPage,
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = curPage.toString();
- params["page_size"] = "20";
- if (!Utils.isEmpty(keyword)) {
- params["job_title"] = keyword!;
- }
- if (!Utils.isEmpty(startDate)) {
- params["job_start"] = startDate!;
- }
- if (!Utils.isEmpty(endDate)) {
- params["job_end"] = endDate!;
- }
- if (!Utils.isEmpty(departmentId)) {
- params["department_id"] = departmentId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourReviewTable,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourReviewListEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourReviewListEntity>(data: data);
- }
- return result.convert();
- }
- /// 根据ID获取主列表的Item数据,用于刷新审核列表Item
- Future<HttpResult<LabourReviewListEntity>> fetchItemByRecordId(
- String? recordId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = "1";
- params["page_size"] = "1";
- if (!Utils.isEmpty(recordId)) {
- params["record_id"] = recordId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourReviewTable,
- params: params,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourReviewListEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourReviewListEntity>(data: data);
- }
- return result.convert();
- }
- /// 用工审核的编辑详情
- Future<HttpResult<LabourRequestEditIndexEntity>> fetchLabourReviewDetail(
- String? requestId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['request_id'] = requestId ?? "";
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourReviewDetail,
- params: params,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourRequestEditIndexEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourRequestEditIndexEntity>(data: data);
- }
- return result.convert();
- }
- /// 用工审核的编辑提交
- Future<HttpResult> editLabourReviewSubmit(
- String? requestId,
- String? templateId,
- String? jobStart,
- String? jobEnd,
- String? departmentId,
- String? needNum,
- String? salaryBy,
- String? amount, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['request_id'] = requestId ?? "";
- params['template_id'] = templateId ?? "";
- params['job_start'] = jobStart ?? "";
- params['job_end'] = jobEnd ?? "";
- params['need_num'] = needNum ?? "";
- if (!Utils.isEmpty(departmentId)) {
- params["co_department_id"] = departmentId!;
- }
- params['salary_by'] = salaryBy ?? "";
- if (!Utils.isEmpty(amount)) {
- params["amount"] = amount!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourReviewEdit,
- method: HttpMethod.POST,
- params: params,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 用工审核的审核流程列表
- Future<HttpResult<LabourReviewStatusEntity>> fetchLabourReviewStatusView(
- String? requestId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['request_id'] = requestId ?? "";
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourReviewStatusView,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = LabourReviewStatusEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourReviewStatusEntity>(data: data);
- }
- return result.convert();
- }
- /// 用工审核的批量同意
- Future<HttpResult> approveLabourReviews(
- String? recordIds, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['record_ids'] = recordIds ?? "";
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourReviewApprove,
- method: HttpMethod.POST,
- params: params,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 用工审核的批量拒绝
- Future<HttpResult> rejectLabourReviews(
- String? recordIds,
- String? reason, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['record_ids'] = recordIds ?? "";
- if (Utils.isNotEmpty(reason)) {
- params['audit_mark'] = reason ?? "";
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiLabourReviewReject,
- method: HttpMethod.POST,
- params: params,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- }
|