|
@@ -1,7 +1,9 @@
|
|
import 'package:domain/entity/response/labour_request_s_g_list_entity.dart';
|
|
import 'package:domain/entity/response/labour_request_s_g_list_entity.dart';
|
|
|
|
+import 'package:domain/entity/response/position_table_entity.dart';
|
|
import 'package:domain/repository/labour_sg_repository.dart';
|
|
import 'package:domain/repository/labour_sg_repository.dart';
|
|
|
|
|
|
import 'package:domain/entity/response/labour_request_index_entity.dart';
|
|
import 'package:domain/entity/response/labour_request_index_entity.dart';
|
|
|
|
+import 'package:domain/repository/sg_agency_repository.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
|
|
import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
|
|
import 'package:plugin_platform/engine/notify/notify_engine.dart';
|
|
import 'package:plugin_platform/engine/notify/notify_engine.dart';
|
|
@@ -17,7 +19,7 @@ import '../position_add/position_add_page.dart';
|
|
import 'position_list_state.dart';
|
|
import 'position_list_state.dart';
|
|
|
|
|
|
class PositionListController extends GetxController with DioCancelableMixin {
|
|
class PositionListController extends GetxController with DioCancelableMixin {
|
|
- final LabourSGRepository _labourRepository = Get.find();
|
|
|
|
|
|
+ final SGAgencyRepository _agencyRepository = Get.find();
|
|
final PositionListState state = PositionListState();
|
|
final PositionListState state = PositionListState();
|
|
|
|
|
|
var _curPage = 1;
|
|
var _curPage = 1;
|
|
@@ -64,33 +66,12 @@ class PositionListController extends GetxController with DioCancelableMixin {
|
|
changeLoadingState(LoadState.State_Loading);
|
|
changeLoadingState(LoadState.State_Loading);
|
|
}
|
|
}
|
|
|
|
|
|
- // 并发执行两个请求
|
|
|
|
- var futures = [
|
|
|
|
- _labourRepository.fetchLabourRequestSGList(
|
|
|
|
- state.keyword,
|
|
|
|
- "",
|
|
|
|
- "",
|
|
|
|
- "",
|
|
|
|
- "",
|
|
|
|
- curPage: _curPage,
|
|
|
|
- cancelToken: cancelToken,
|
|
|
|
- ),
|
|
|
|
- state.indexOptions == null
|
|
|
|
- ? _labourRepository.fetchLabourRequestSGIndex(
|
|
|
|
- cancelToken: cancelToken,
|
|
|
|
- )
|
|
|
|
- : Future(() => HttpResult(isSuccess: true).convert(data: state.indexOptions!)),
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
//拿到结果
|
|
//拿到结果
|
|
- var results = await Future.wait(futures);
|
|
|
|
- var listResult = results[0] as HttpResult<LabourRequestSGListEntity>;
|
|
|
|
- var optionResult = results[1] as HttpResult<LabourRequestIndexEntity>;
|
|
|
|
-
|
|
|
|
- //选项数据
|
|
|
|
- if (state.indexOptions == null && optionResult.isSuccess) {
|
|
|
|
- state.indexOptions = optionResult.data!;
|
|
|
|
- }
|
|
|
|
|
|
+ var listResult = await _agencyRepository.fetchPositionTable(
|
|
|
|
+ curPage: _curPage,
|
|
|
|
+ keyword: state.keyword,
|
|
|
|
+ cancelToken: cancelToken,
|
|
|
|
+ );
|
|
|
|
|
|
// 处理数据
|
|
// 处理数据
|
|
if (listResult.isSuccess) {
|
|
if (listResult.isSuccess) {
|
|
@@ -105,7 +86,7 @@ class PositionListController extends GetxController with DioCancelableMixin {
|
|
}
|
|
}
|
|
|
|
|
|
// 处理数据与展示的逻辑
|
|
// 处理数据与展示的逻辑
|
|
- void handleList(List<LabourRequestSGListRows>? list) {
|
|
|
|
|
|
+ void handleList(List<PositionTableRows>? list) {
|
|
if (list != null && list.isNotEmpty) {
|
|
if (list != null && list.isNotEmpty) {
|
|
//有数据,判断是刷新还是加载更多的数据
|
|
//有数据,判断是刷新还是加载更多的数据
|
|
if (_curPage == 1) {
|
|
if (_curPage == 1) {
|
|
@@ -153,27 +134,27 @@ class PositionListController extends GetxController with DioCancelableMixin {
|
|
|
|
|
|
/// 根据ID获取Item对象,用于刷新
|
|
/// 根据ID获取Item对象,用于刷新
|
|
void fetchItemByIdAndRefreshItem(String requestId) async {
|
|
void fetchItemByIdAndRefreshItem(String requestId) async {
|
|
- var result = await _labourRepository.fetchItemByRequestId(
|
|
|
|
- requestId,
|
|
|
|
- cancelToken: cancelToken,
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- //处理数据
|
|
|
|
- if (result.isSuccess) {
|
|
|
|
- var data = result.data;
|
|
|
|
- if (data != null && data.rows != null && data.rows!.isNotEmpty) {
|
|
|
|
- final requestItem = data.rows![0];
|
|
|
|
-
|
|
|
|
- //找到当前数据中的此 requestId,并替换对象,再刷新
|
|
|
|
- var index = state.datas.indexWhere((element) => element.requestId == requestItem.requestId);
|
|
|
|
- if (index >= 0) {
|
|
|
|
- state.datas[index] = requestItem;
|
|
|
|
- update();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
|
|
|
|
- }
|
|
|
|
|
|
+ // var result = await _labourRepository.fetchItemByRequestId(
|
|
|
|
+ // requestId,
|
|
|
|
+ // cancelToken: cancelToken,
|
|
|
|
+ // );
|
|
|
|
+ //
|
|
|
|
+ // //处理数据
|
|
|
|
+ // if (result.isSuccess) {
|
|
|
|
+ // var data = result.data;
|
|
|
|
+ // if (data != null && data.rows != null && data.rows!.isNotEmpty) {
|
|
|
|
+ // final requestItem = data.rows![0];
|
|
|
|
+ //
|
|
|
|
+ // //找到当前数据中的此 requestId,并替换对象,再刷新
|
|
|
|
+ // var index = state.datas.indexWhere((element) => element.requestId == requestItem.requestId);
|
|
|
|
+ // if (index >= 0) {
|
|
|
|
+ // state.datas[index] = requestItem;
|
|
|
|
+ // update();
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // } else {
|
|
|
|
+ // ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -188,40 +169,36 @@ class PositionListController extends GetxController with DioCancelableMixin {
|
|
super.onClose();
|
|
super.onClose();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//跳转到添加页面
|
|
//跳转到添加页面
|
|
void gotoAddAgencyPage() {
|
|
void gotoAddAgencyPage() {
|
|
- SGPositionAddPage.startInstance("", (result) {
|
|
|
|
|
|
+ SGPositionAddPage.startInstance("", "", (result) {
|
|
if (result != null) {
|
|
if (result != null) {
|
|
refreshController.callRefresh();
|
|
refreshController.callRefresh();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//去编辑页面
|
|
//去编辑页面
|
|
- void gotoEditPage(LabourRequestSGListRows data) {
|
|
|
|
- SGPositionAddPage.startInstance(data.requestId, (result) {
|
|
|
|
- if (result != null) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ void gotoEditPage(PositionTableRows data) {
|
|
|
|
+ SGPositionAddPage.startInstance(data.id, data.name, (result) {
|
|
|
|
+ if (result != null) {}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
//删除labourRequest
|
|
//删除labourRequest
|
|
- void doDelete(String? requestId, int index) {
|
|
|
|
|
|
+ void doDelete(String? positionId, int index) {
|
|
DialogEngine.show(
|
|
DialogEngine.show(
|
|
widget: AppDefaultDialog(
|
|
widget: AppDefaultDialog(
|
|
title: "Confirmation".tr,
|
|
title: "Confirmation".tr,
|
|
message: "Are you sure you want to delete this position?".tr,
|
|
message: "Are you sure you want to delete this position?".tr,
|
|
confirmAction: () {
|
|
confirmAction: () {
|
|
- _submitDeleteRequest(requestId, index);
|
|
|
|
|
|
+ _submitDeleteRequest(positionId, index);
|
|
},
|
|
},
|
|
));
|
|
));
|
|
}
|
|
}
|
|
|
|
|
|
- void _submitDeleteRequest(String? requestId, int index) async {
|
|
|
|
- var result = await _labourRepository.deleteLabourRequestSG(requestId, cancelToken: cancelToken);
|
|
|
|
|
|
+ void _submitDeleteRequest(String? positionId, int index) async {
|
|
|
|
+ var result = await _agencyRepository.deletePositionSubmit(positionId: positionId, cancelToken: cancelToken);
|
|
|
|
|
|
if (result.isSuccess) {
|
|
if (result.isSuccess) {
|
|
NotifyEngine.showSuccess("Successful".tr);
|
|
NotifyEngine.showSuccess("Successful".tr);
|
|
@@ -236,5 +213,4 @@ class PositionListController extends GetxController with DioCancelableMixin {
|
|
ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
|
|
ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|