|
@@ -2,7 +2,9 @@ import 'dart:io';
|
|
|
|
|
|
import 'package:cpt_uk/modules/job/labour_request_add/widget/labour_request_interface.dart';
|
|
|
import 'package:cpt_uk/modules/job/labour_request_add/widget/uploadFileField.dart';
|
|
|
+import 'package:domain/entity/response/uk_lab_req_show_template_entity.dart';
|
|
|
import 'package:domain/entity/response/uk_labour_request_detail_entity.dart';
|
|
|
+import 'package:domain/entity/response/uk_template_detail_index_entity.dart';
|
|
|
import 'package:domain/repository/labour_repository.dart';
|
|
|
import 'package:domain/repository/uk_job_repository.dart';
|
|
|
import 'package:domain/repository/uk_labour_repository.dart';
|
|
@@ -10,6 +12,7 @@ import 'package:flutter/cupertino.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/loading/loading_engine.dart';
|
|
|
import 'package:plugin_platform/engine/notify/notify_engine.dart';
|
|
|
import 'package:plugin_platform/engine/toast/toast_engine.dart';
|
|
|
import 'package:plugin_platform/http/http_result.dart';
|
|
@@ -44,11 +47,10 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
Future<HttpResult<UkLabourRequestDetailEntity>> taskFuture;
|
|
|
// Log.d("请求的state.appliedId ${state.appliedId}");
|
|
|
if (Utils.isNotEmpty(state.appliedId) && state.appliedId != "0") {
|
|
|
- // 编辑
|
|
|
- // Log.d("请求的state.appliedId3333 ${state.appliedId}");
|
|
|
+ // 非新增获取详情
|
|
|
taskFuture = _ukLabourRepository.fetchLabourRequestDetail(state.appliedId);
|
|
|
} else {
|
|
|
- // 新增时获取详情
|
|
|
+ // 新增时获取选项
|
|
|
taskFuture = _ukLabourRepository.fetchLabourRequestAddOption();
|
|
|
}
|
|
|
|
|
@@ -65,8 +67,8 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
state.selectedDate = state.labReqOption?.jobStart == null ? null : DateTimeUtils.getDateTime(state.labReqOption!.jobStart!);
|
|
|
state.selectedStartTime = state.labReqOption?.jobStart == null ? null : DateTimeUtils.getDateTime(state.labReqOption!.jobStart!);
|
|
|
state.selectedEndTime = state.labReqOption?.jobEnd == null ? null : DateTimeUtils.getDateTime(state.labReqOption!.jobEnd!);
|
|
|
- state.location = state.labReqOption?.location ?? '';
|
|
|
|
|
|
+ state.location = state.labReqOption?.location ?? '';
|
|
|
|
|
|
Log.d("获取到的 atturl ${state.labReqOption?.attUrl}");
|
|
|
|
|
@@ -136,6 +138,9 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
// 新增
|
|
|
state.noStaff = '';
|
|
|
state.amount = '';
|
|
|
+ state.selectedCountryStr = '';
|
|
|
+ state.selectedCityStr = '';
|
|
|
+ state.location = '';
|
|
|
|
|
|
// choose Type 下拉里面 永远只有一个选项 所以默认选择第一个
|
|
|
if (state.labReqOption?.employmentList != null && state.labReqOption!.employmentList!.isNotEmpty) {
|
|
@@ -146,6 +151,30 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
state.noStaff = state.labReqOption?.needNum?.toString() == "0" ? "" : state.labReqOption?.needNum.toString();
|
|
|
state.amount = state.labReqOption?.amount?.toString() == "0" ? "" : state.labReqOption?.amount.toString();
|
|
|
|
|
|
+ // state.labReqOption.countryList 中找到 selected 为 true 的项
|
|
|
+ int? countryIndex = state.labReqOption?.countryList?.indexWhere((e) => e.selected == "selected") ?? -1;
|
|
|
+ if(countryIndex != -1){
|
|
|
+ state.selectedCountryStr = state.labReqOption?.countryList?[countryIndex].txt.toString();
|
|
|
+
|
|
|
+ // state.labReqOption?.countryList 遍历后 创建 state.countryOptionEntityList
|
|
|
+ state.countryOptionEntityList = state.labReqOption?.countryList
|
|
|
+ ?.map((item) => UkLabReqShowTemplateCountryList()
|
|
|
+ ..id = item.value
|
|
|
+ ..name = item.txt
|
|
|
+ ).toList();
|
|
|
+ }
|
|
|
+
|
|
|
+ // state.labReqOption.cityList 中找到 selected 为 true 的项
|
|
|
+ int? cityIndex = state.labReqOption?.cityList?.indexWhere((e) => e.selected == "selected") ?? -1;
|
|
|
+ if(cityIndex != -1){
|
|
|
+ state.selectedCityStr = state.labReqOption?.cityList?[cityIndex].txt.toString();
|
|
|
+ state.cityOptionEntityList = state.labReqOption?.cityList
|
|
|
+ ?.map((item) => UkLabReqShowTemplateCityList()
|
|
|
+ ..id = item.value
|
|
|
+ ..name = item.txt
|
|
|
+ ).toList();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
var needNumController = state.formData['no_of_staff']!['controller'];
|
|
@@ -347,6 +376,8 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
"challenge25": state.selectedChallenge25Id?? "",
|
|
|
"vehicle": state.selectedVehicleList?.join(",")??"",
|
|
|
"description": remark,
|
|
|
+ "countryId": state.selectedCountryId,
|
|
|
+ "cityId": state.selectedCityId,
|
|
|
"location": location,
|
|
|
"employmentType": state.selectedTypeId,
|
|
|
"eventName": event,
|
|
@@ -378,6 +409,8 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
needNum: params['needNum'],
|
|
|
salaryBy: params['salaryBy'],
|
|
|
amount: params['amount'],
|
|
|
+ countryId: params['countryId'],
|
|
|
+ cityId: params['cityId'],
|
|
|
location: params['location'],
|
|
|
certificate: params['certificate'],
|
|
|
challenge25: params['challenge25'],
|
|
@@ -414,6 +447,8 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
"vehicle": state.selectedVehicleList?.join(",")??"",
|
|
|
"jobApplyPreId": state.preSelectedIds,
|
|
|
"description": remark,
|
|
|
+ "countryId": state.selectedCountryId,
|
|
|
+ "cityId": state.selectedCityId,
|
|
|
"location": location,
|
|
|
"employmentType": state.selectedTypeId,
|
|
|
"eventName": event,
|
|
@@ -442,6 +477,8 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
salaryBy: params['salaryBy'],
|
|
|
repeatDateStr: params['repeatDateStr'],
|
|
|
amount: params['amount'],
|
|
|
+ countryId: params['countryId'],
|
|
|
+ cityId: params['cityId'],
|
|
|
location: params['location'],
|
|
|
certificate: params['certificate'],
|
|
|
challenge25: params['challenge25'],
|
|
@@ -519,7 +556,7 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
"";
|
|
|
positionController.text = state.position;
|
|
|
|
|
|
- // 并且需要根据 state.selectedTemplateId调用 接口 回显 证书 、vehicle
|
|
|
+ // 并且需要根据 state.selectedTemplateId调用 接口 回显 证书 、vehicle、country city location等
|
|
|
await _getShowTemplateData(state.selectedTemplateId!);
|
|
|
|
|
|
},
|
|
@@ -573,6 +610,24 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
Log.d("切换模板后, 证书的回显 vehicleList: ${state.labReqOption?.challenge25List}");
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ // 回显 国家 城市 location
|
|
|
+ if(state.showTemplateData?.countryId != null){
|
|
|
+ state.location = state.showTemplateData?.location.toString();
|
|
|
+
|
|
|
+ state.selectedCountryStr = state.showTemplateData?.countryList?.firstWhere(
|
|
|
+ (element) => element.id.toString() == state.showTemplateData?.countryId.toString(),
|
|
|
+ orElse: () => UkLabReqShowTemplateCountryList(),
|
|
|
+ )?.name;
|
|
|
+ state.countryOptionEntityList = state.showTemplateData?.countryList??[];
|
|
|
+
|
|
|
+ state.selectedCityStr = state.showTemplateData?.cityList?.firstWhere(
|
|
|
+ (element) => element.id.toString() == state.showTemplateData?.cityId.toString(),
|
|
|
+ orElse: () => UkLabReqShowTemplateCityList(),
|
|
|
+ )?.name;
|
|
|
+ state.cityOptionEntityList = state.showTemplateData?.cityList??[];
|
|
|
+
|
|
|
+ }
|
|
|
// 更新
|
|
|
update();
|
|
|
}
|
|
@@ -757,13 +812,135 @@ class LabourRequestAddController extends GetxController with DioCancelableMixin
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 编辑状态时 修改 开始日期时间 YYYY-MM-DD HH:mm
|
|
|
+ @override
|
|
|
+ void pickJobStart() {
|
|
|
+ // TODO: implement pickJobStart
|
|
|
+ DatePickerUtil.showCupertinoDatePicker(
|
|
|
+ title: "Job Start".tr,
|
|
|
+ selectedDateTime: state.jobStart,
|
|
|
+ mode: CupertinoDatePickerMode.dateAndTime,
|
|
|
+ onDateTimeChanged: (date) {
|
|
|
+ Log.d("选取的开始日期时间:${date.toString()}");
|
|
|
+ Log.d("----------${DateTimeUtils.formatDate(date, format: 'yyyy-MM-dd HH:mm')}");
|
|
|
+ state.jobSelectJobStart = DateTimeUtils.formatDate(date, format: 'yyyy-MM-dd HH:mm');
|
|
|
+ update();
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 编辑状态时 修改 结束日期时间 YYYY-MM-DD HH:mm
|
|
|
@override
|
|
|
void pickJobEnd() {
|
|
|
// TODO: implement pickJobEnd
|
|
|
+ DatePickerUtil.showCupertinoDatePicker(
|
|
|
+ title: "Job End".tr,
|
|
|
+ selectedDateTime: state.jobStart,
|
|
|
+ mode: CupertinoDatePickerMode.dateAndTime,
|
|
|
+ onDateTimeChanged: (date) {
|
|
|
+ Log.d("选取的结束日期时间:${date.toString()}");
|
|
|
+ state.jobSelectJobEnd = DateTimeUtils.formatDate(date, format: 'yyyy-MM-dd HH:mm');
|
|
|
+ update();
|
|
|
+ },
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // 新增时 选择 country
|
|
|
@override
|
|
|
- void pickJobStart() {
|
|
|
- // TODO: implement pickJobStart
|
|
|
+ void showChooseCountryPicker(){
|
|
|
+ if(Utils.isEmpty(state.selectedTemplateId)){
|
|
|
+ return ToastEngine.show("Please select jobTitle");
|
|
|
+ }
|
|
|
+ int selectedOptionsIndex;
|
|
|
+ if (state.selectedCountryStr == null) {
|
|
|
+ selectedOptionsIndex = 0;
|
|
|
+ } else {
|
|
|
+ selectedOptionsIndex = state.countryOptionEntityList?.indexWhere((e) => e.name.toString() == state.selectedCountryStr)?? 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (selectedOptionsIndex < 0) {
|
|
|
+ selectedOptionsIndex = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ OptionPickerUtil.showCupertinoOptionPicker(
|
|
|
+ items: state.countryOptionEntityList?.map((e) => e.name.toString()).toList(growable: false)?? [],
|
|
|
+ initialSelectIndex: selectedOptionsIndex,
|
|
|
+ onPickerChanged: (_, index) async {
|
|
|
+ String lastSelectedOptionsStr = state.selectedCountryStr?? "";
|
|
|
+ String curSelectedStr = state.countryOptionEntityList?[index].name.toString() ?? "";
|
|
|
+ Log.d("当前选择的国家:$curSelectedStr");
|
|
|
+ if(lastSelectedOptionsStr != curSelectedStr){
|
|
|
+ state.selectedCountryStr = curSelectedStr;
|
|
|
+ state.selectedCityStr = "";
|
|
|
+ update();
|
|
|
+ // 需要调接口来获取工作标题的数据源
|
|
|
+ await _fetchCityOptionsList(null);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
}
|
|
|
+
|
|
|
+ @override
|
|
|
+ // 新增时 选择 city
|
|
|
+ void showChooseCityPicker(){
|
|
|
+ if(Utils.isEmpty(state.selectedCountryStr)){
|
|
|
+ return ToastEngine.show("Please select country first");
|
|
|
+ }
|
|
|
+ int selectedOptionsIndex;
|
|
|
+ if (state.selectedCityStr == null) {
|
|
|
+ selectedOptionsIndex = 0;
|
|
|
+ } else {
|
|
|
+ selectedOptionsIndex = state.cityOptionEntityList?.indexWhere((e) => e.name?.toString() == state.selectedCityStr)?? 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (selectedOptionsIndex < 0) {
|
|
|
+ selectedOptionsIndex = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ OptionPickerUtil.showCupertinoOptionPicker(
|
|
|
+ items: state.cityOptionEntityList?.map((e) => e.name.toString()).toList(growable: false)?? [],
|
|
|
+ initialSelectIndex: selectedOptionsIndex,
|
|
|
+ onPickerChanged: (_, index) {
|
|
|
+ String lastSelectedOptionsStr = state.selectedCityStr?? "";
|
|
|
+ String curSelectedStr = state.cityOptionEntityList?[index].name.toString() ?? "";
|
|
|
+ if(lastSelectedOptionsStr != curSelectedStr){
|
|
|
+ state.selectedCityStr = curSelectedStr;
|
|
|
+ update();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 获取城市的数据源
|
|
|
+ Future _fetchCityOptionsList(String? cityId) async {
|
|
|
+ LoadingEngine.show();
|
|
|
+ try {
|
|
|
+ // 获取到数据
|
|
|
+ HttpResult<UkTemplateDetailIndexCountryList> taskResult;
|
|
|
+ taskResult = await _ukJobRepository.fetchCityOptiosByCountry(
|
|
|
+ state.selectedCountryId!,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+ if (taskResult.isSuccess) {
|
|
|
+ state.cityOptionEntityList = taskResult.list!.map((e) => UkLabReqShowTemplateCityList.fromJson(e.toJson())).toList();
|
|
|
+ // 当前的 selectedCityStr
|
|
|
+ if(Utils.isEmpty(cityId)){
|
|
|
+ state.selectedCityStr = "";
|
|
|
+ }else {
|
|
|
+ state.selectedCityStr = taskResult.list?.firstWhere((e) => e.id.toString() == cityId, orElse: () => UkTemplateDetailIndexCountryList()).name ?? "";
|
|
|
+ }
|
|
|
+ update();
|
|
|
+ } else {
|
|
|
+ ToastEngine.show(taskResult.errorMsg ?? "Network Load Error".tr);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ // Log.e(e);
|
|
|
+ } finally {
|
|
|
+ LoadingEngine.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|