|
@@ -1,3 +1,4 @@
|
|
|
|
+import 'package:domain/entity/response/index_option_entity.dart';
|
|
import 'package:domain/entity/response/job_template_edit_index_entity.dart';
|
|
import 'package:domain/entity/response/job_template_edit_index_entity.dart';
|
|
import 'package:domain/repository/labour_sg_repository.dart';
|
|
import 'package:domain/repository/labour_sg_repository.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get/get.dart';
|
|
@@ -7,6 +8,7 @@ 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/log_utils.dart';
|
|
import 'package:shared/utils/log_utils.dart';
|
|
import 'package:shared/utils/util.dart';
|
|
import 'package:shared/utils/util.dart';
|
|
|
|
+import 'package:widgets/picker/option_pick_util.dart';
|
|
|
|
|
|
import 'job_template_add_state.dart';
|
|
import 'job_template_add_state.dart';
|
|
|
|
|
|
@@ -45,12 +47,16 @@ class JobTemplateAddController extends GetxController with DioCancelableMixin {
|
|
|
|
|
|
//默认赋值
|
|
//默认赋值
|
|
state.selectedAgeList = state.indexEntity?.ageList.where((e) => e.checked == "checked").map((e) => e.value!).toList() ?? [];
|
|
state.selectedAgeList = state.indexEntity?.ageList.where((e) => e.checked == "checked").map((e) => e.value!).toList() ?? [];
|
|
- Log.d("当前选中的年龄1:${ state.selectedAgeList}");
|
|
|
|
|
|
+ Log.d("当前选中的年龄1:${state.selectedAgeList}");
|
|
state.selectedLanguageList = state.indexEntity?.languageList.where((e) => e.checked == "checked").map((e) => e.value!).toList() ?? [];
|
|
state.selectedLanguageList = state.indexEntity?.languageList.where((e) => e.checked == "checked").map((e) => e.value!).toList() ?? [];
|
|
- Log.d("当前选中的语言1:${ state.selectedLanguageList}");
|
|
|
|
|
|
+ Log.d("当前选中的语言1:${state.selectedLanguageList}");
|
|
state.foodCert = state.indexEntity?.withFoodCert.toString();
|
|
state.foodCert = state.indexEntity?.withFoodCert.toString();
|
|
// state.gender = state.indexEntity?.sexList.firstWhere((e) => e.checked == "checked").value;
|
|
// state.gender = state.indexEntity?.sexList.firstWhere((e) => e.checked == "checked").value;
|
|
|
|
|
|
|
|
+ state.positionList = state.indexEntity?.positionList ?? [];
|
|
|
|
+ state.positionId = state.indexEntity?.positionList.firstWhere((e) => e.selected == "selected", orElse: () => IndexOptionEntity()).value ?? "";
|
|
|
|
+ state.positionName = state.indexEntity?.positionList.firstWhere((e) => e.selected == "selected", orElse: () => IndexOptionEntity()).txt ?? "";
|
|
|
|
+
|
|
update();
|
|
update();
|
|
} else {
|
|
} else {
|
|
ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
|
|
ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
|
|
@@ -77,11 +83,17 @@ class JobTemplateAddController extends GetxController with DioCancelableMixin {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (Utils.isEmpty(state.positionId)) {
|
|
|
|
+ ToastEngine.show("Choose Position".tr);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
Future<HttpResult> taskFuture;
|
|
Future<HttpResult> taskFuture;
|
|
if (Utils.isNotEmpty(state.templateId) && state.templateId != "0") {
|
|
if (Utils.isNotEmpty(state.templateId) && state.templateId != "0") {
|
|
taskFuture = _labourRepository.editJobTemplateSubmit(
|
|
taskFuture = _labourRepository.editJobTemplateSubmit(
|
|
state.templateId,
|
|
state.templateId,
|
|
templateName,
|
|
templateName,
|
|
|
|
+ state.positionId,
|
|
contact,
|
|
contact,
|
|
contactNo,
|
|
contactNo,
|
|
desc,
|
|
desc,
|
|
@@ -95,6 +107,7 @@ class JobTemplateAddController extends GetxController with DioCancelableMixin {
|
|
} else {
|
|
} else {
|
|
taskFuture = _labourRepository.addJobTemplateSubmit(
|
|
taskFuture = _labourRepository.addJobTemplateSubmit(
|
|
templateName,
|
|
templateName,
|
|
|
|
+ state.positionId,
|
|
contact,
|
|
contact,
|
|
contactNo,
|
|
contactNo,
|
|
desc,
|
|
desc,
|
|
@@ -127,4 +140,28 @@ class JobTemplateAddController extends GetxController with DioCancelableMixin {
|
|
super.onReady();
|
|
super.onReady();
|
|
_fetchAddEditIndexDetail();
|
|
_fetchAddEditIndexDetail();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 选择职位
|
|
|
|
+ void pickPosition() {
|
|
|
|
+ int selectedIndex;
|
|
|
|
+ if (state.positionId == null) {
|
|
|
|
+ selectedIndex = 0;
|
|
|
|
+ } else {
|
|
|
|
+ selectedIndex = state.positionList.indexWhere((department) => department.value.toString() == state.positionId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (selectedIndex < 0) {
|
|
|
|
+ selectedIndex = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OptionPickerUtil.showCupertinoOptionPicker(
|
|
|
|
+ items: state.positionList.map((e) => e.txt!).toList(growable: false),
|
|
|
|
+ initialSelectIndex: selectedIndex,
|
|
|
|
+ onPickerChanged: (_, index) {
|
|
|
|
+ state.positionName = state.positionList[index].txt;
|
|
|
|
+ state.positionId = state.positionList[index].value;
|
|
|
|
+ update();
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|