|
@@ -1,26 +1,23 @@
|
|
-import 'package:domain/entity/response/labour_request_s_g_list_entity.dart';
|
|
|
|
-import 'package:domain/repository/labour_sg_repository.dart';
|
|
|
|
|
|
+import 'package:domain/entity/response/agency_option_entity.dart';
|
|
|
|
+import 'package:domain/entity/response/agency_table_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_basic/constants/app_constant.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';
|
|
import 'package:plugin_platform/engine/toast/toast_engine.dart';
|
|
import 'package:plugin_platform/engine/toast/toast_engine.dart';
|
|
import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
|
|
import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
|
|
import 'package:plugin_platform/http/http_result.dart';
|
|
import 'package:plugin_platform/http/http_result.dart';
|
|
-import 'package:shared/utils/date_time_utils.dart';
|
|
|
|
-import 'package:shared/utils/event_bus.dart';
|
|
|
|
-import 'package:shared/utils/util.dart';
|
|
|
|
import 'package:widgets/dialog/app_default_dialog.dart';
|
|
import 'package:widgets/dialog/app_default_dialog.dart';
|
|
import 'package:widgets/load_state_layout.dart';
|
|
import 'package:widgets/load_state_layout.dart';
|
|
|
|
+import 'package:widgets/picker/option_pick_util.dart';
|
|
import 'package:widgets/widget_export.dart';
|
|
import 'package:widgets/widget_export.dart';
|
|
|
|
|
|
import '../agency_add/agency_add_page.dart';
|
|
import '../agency_add/agency_add_page.dart';
|
|
import 'agency_list_state.dart';
|
|
import 'agency_list_state.dart';
|
|
|
|
|
|
class AgencyListController extends GetxController with DioCancelableMixin {
|
|
class AgencyListController extends GetxController with DioCancelableMixin {
|
|
- final LabourSGRepository _labourRepository = Get.find();
|
|
|
|
|
|
+ final SGAgencyRepository _agencyRepository = Get.find();
|
|
final AgencyListState state = AgencyListState();
|
|
final AgencyListState state = AgencyListState();
|
|
|
|
|
|
var _curPage = 1;
|
|
var _curPage = 1;
|
|
@@ -45,41 +42,38 @@ class AgencyListController extends GetxController with DioCancelableMixin {
|
|
// Refresh 刷新事件
|
|
// Refresh 刷新事件
|
|
Future onRefresh() async {
|
|
Future onRefresh() async {
|
|
_curPage = 1;
|
|
_curPage = 1;
|
|
- fetchLabourRequestList();
|
|
|
|
|
|
+ fetchTableList();
|
|
}
|
|
}
|
|
|
|
|
|
// Refresh 加载事件
|
|
// Refresh 加载事件
|
|
Future loadMore() async {
|
|
Future loadMore() async {
|
|
_curPage++;
|
|
_curPage++;
|
|
- fetchLabourRequestList();
|
|
|
|
|
|
+ fetchTableList();
|
|
}
|
|
}
|
|
|
|
|
|
// 重试请求
|
|
// 重试请求
|
|
Future retryRequest() async {
|
|
Future retryRequest() async {
|
|
_curPage = 1;
|
|
_curPage = 1;
|
|
_needShowPlaceholder = true;
|
|
_needShowPlaceholder = true;
|
|
- fetchLabourRequestList();
|
|
|
|
|
|
+ fetchTableList();
|
|
}
|
|
}
|
|
|
|
|
|
/// 获取列表数据
|
|
/// 获取列表数据
|
|
- Future fetchLabourRequestList() async {
|
|
|
|
|
|
+ Future fetchTableList() async {
|
|
if (_needShowPlaceholder) {
|
|
if (_needShowPlaceholder) {
|
|
changeLoadingState(LoadState.State_Loading);
|
|
changeLoadingState(LoadState.State_Loading);
|
|
}
|
|
}
|
|
|
|
|
|
// 并发执行两个请求
|
|
// 并发执行两个请求
|
|
var futures = [
|
|
var futures = [
|
|
- _labourRepository.fetchLabourRequestSGList(
|
|
|
|
- state.keyword,
|
|
|
|
- "",
|
|
|
|
- "",
|
|
|
|
- state.selectedStatusId,
|
|
|
|
- "",
|
|
|
|
|
|
+ _agencyRepository.fetchAgencyTable(
|
|
|
|
+ keyword: state.keyword,
|
|
|
|
+ status: state.selectedStatusId,
|
|
curPage: _curPage,
|
|
curPage: _curPage,
|
|
cancelToken: cancelToken,
|
|
cancelToken: cancelToken,
|
|
),
|
|
),
|
|
state.indexOptions == null
|
|
state.indexOptions == null
|
|
- ? _labourRepository.fetchLabourRequestSGIndex(
|
|
|
|
|
|
+ ? _agencyRepository.fetchAgencyOption(
|
|
cancelToken: cancelToken,
|
|
cancelToken: cancelToken,
|
|
)
|
|
)
|
|
: Future(() => HttpResult(isSuccess: true).convert(data: state.indexOptions!)),
|
|
: Future(() => HttpResult(isSuccess: true).convert(data: state.indexOptions!)),
|
|
@@ -87,8 +81,8 @@ class AgencyListController extends GetxController with DioCancelableMixin {
|
|
|
|
|
|
//拿到结果
|
|
//拿到结果
|
|
var results = await Future.wait(futures);
|
|
var results = await Future.wait(futures);
|
|
- var listResult = results[0] as HttpResult<LabourRequestSGListEntity>;
|
|
|
|
- var optionResult = results[1] as HttpResult<LabourRequestIndexEntity>;
|
|
|
|
|
|
+ var listResult = results[0] as HttpResult<AgencyTableEntity>;
|
|
|
|
+ var optionResult = results[1] as HttpResult<AgencyOptionEntity>;
|
|
|
|
|
|
//选项数据
|
|
//选项数据
|
|
if (state.indexOptions == null && optionResult.isSuccess) {
|
|
if (state.indexOptions == null && optionResult.isSuccess) {
|
|
@@ -108,7 +102,7 @@ class AgencyListController extends GetxController with DioCancelableMixin {
|
|
}
|
|
}
|
|
|
|
|
|
// 处理数据与展示的逻辑
|
|
// 处理数据与展示的逻辑
|
|
- void handleList(List<LabourRequestSGListRows>? list) {
|
|
|
|
|
|
+ void handleList(List<AgencyTableRows>? list) {
|
|
if (list != null && list.isNotEmpty) {
|
|
if (list != null && list.isNotEmpty) {
|
|
//有数据,判断是刷新还是加载更多的数据
|
|
//有数据,判断是刷新还是加载更多的数据
|
|
if (_curPage == 1) {
|
|
if (_curPage == 1) {
|
|
@@ -150,6 +144,8 @@ class AgencyListController extends GetxController with DioCancelableMixin {
|
|
state.keyword = "";
|
|
state.keyword = "";
|
|
state.searchController.text = "";
|
|
state.searchController.text = "";
|
|
state.selectedStatusId = null;
|
|
state.selectedStatusId = null;
|
|
|
|
+ state.selectedStatusTxt = null;
|
|
|
|
+ update();
|
|
|
|
|
|
//赋值之后刷新
|
|
//赋值之后刷新
|
|
refreshController.callRefresh();
|
|
refreshController.callRefresh();
|
|
@@ -157,33 +153,33 @@ class AgencyListController 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
|
|
void onReady() {
|
|
void onReady() {
|
|
super.onReady();
|
|
super.onReady();
|
|
- fetchLabourRequestList();
|
|
|
|
|
|
+ fetchTableList();
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -192,7 +188,6 @@ class AgencyListController extends GetxController with DioCancelableMixin {
|
|
super.onClose();
|
|
super.onClose();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//跳转到添加页面
|
|
//跳转到添加页面
|
|
void gotoAddAgencyPage() {
|
|
void gotoAddAgencyPage() {
|
|
SGAgencyAddPage.startInstance("", (result) {
|
|
SGAgencyAddPage.startInstance("", (result) {
|
|
@@ -203,31 +198,31 @@ class AgencyListController extends GetxController with DioCancelableMixin {
|
|
}
|
|
}
|
|
|
|
|
|
//去详情页面
|
|
//去详情页面
|
|
- void gotoDetailPage(LabourRequestSGListRows data) {}
|
|
|
|
|
|
+ void gotoDetailPage(AgencyTableRows data) {}
|
|
|
|
|
|
//去编辑页面
|
|
//去编辑页面
|
|
- void gotoEditPage(LabourRequestSGListRows data) {
|
|
|
|
- SGAgencyAddPage.startInstance("123", (result) {
|
|
|
|
|
|
+ void gotoEditPage(AgencyTableRows data) {
|
|
|
|
+ SGAgencyAddPage.startInstance(data.pivotId ?? "", (result) {
|
|
if (result != null) {
|
|
if (result != null) {
|
|
- fetchItemByIdAndRefreshItem(data.requestId.toString());
|
|
|
|
|
|
+ fetchItemByIdAndRefreshItem(data.pivotId ?? "");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
//删除labourRequest
|
|
//删除labourRequest
|
|
- void doDelete(String? requestId, int index) {
|
|
|
|
|
|
+ void doDelete(String? pivotId, 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 agency?".tr,
|
|
message: "Are you sure you want to delete this agency?".tr,
|
|
confirmAction: () {
|
|
confirmAction: () {
|
|
- _submitDeleteRequest(requestId, index);
|
|
|
|
|
|
+ _submitDeleteRequest(pivotId, index);
|
|
},
|
|
},
|
|
));
|
|
));
|
|
}
|
|
}
|
|
|
|
|
|
- void _submitDeleteRequest(String? requestId, int index) async {
|
|
|
|
- var result = await _labourRepository.deleteLabourRequestSG(requestId, cancelToken: cancelToken);
|
|
|
|
|
|
+ void _submitDeleteRequest(String? pivotId, int index) async {
|
|
|
|
+ var result = await _agencyRepository.deleteAgencySubmit(pivotId, cancelToken: cancelToken);
|
|
|
|
|
|
if (result.isSuccess) {
|
|
if (result.isSuccess) {
|
|
NotifyEngine.showSuccess("Successful".tr);
|
|
NotifyEngine.showSuccess("Successful".tr);
|
|
@@ -244,5 +239,30 @@ class AgencyListController extends GetxController with DioCancelableMixin {
|
|
}
|
|
}
|
|
|
|
|
|
/// 选择中介公司状态
|
|
/// 选择中介公司状态
|
|
- void pickAgencyStatus() {}
|
|
|
|
|
|
+ void pickAgencyStatus() {
|
|
|
|
+ if (state.indexOptions == null) return;
|
|
|
|
+
|
|
|
|
+ int selectedIndex;
|
|
|
|
+ if (state.selectedStatusId == null) {
|
|
|
|
+ selectedIndex = 0;
|
|
|
|
+ } else {
|
|
|
|
+ selectedIndex = state.indexOptions!.statusList!.indexWhere((department) => department.value.toString() == state.selectedStatusId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (selectedIndex < 0) {
|
|
|
|
+ selectedIndex = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OptionPickerUtil.showCupertinoOptionPicker(
|
|
|
|
+ items: state.indexOptions!.statusList!.map((e) => e.txt!.tr).toList(growable: false),
|
|
|
|
+ initialSelectIndex: selectedIndex,
|
|
|
|
+ onPickerChanged: (_, index) {
|
|
|
|
+ state.selectedStatusId = state.indexOptions!.statusList![index].value!.toString();
|
|
|
|
+ state.selectedStatusTxt = state.indexOptions!.statusList![index].txt!.toString();
|
|
|
|
+ update();
|
|
|
|
+
|
|
|
|
+ refreshController.callRefresh();
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|