|
@@ -23,7 +23,7 @@ class ContractAddController extends GetxController with DioCancelableMixin {
|
|
|
void _fetchAddEditIndexDetail() async {
|
|
|
// //获取到数据
|
|
|
Future<HttpResult<ContractDetailEntity>> taskFuture;
|
|
|
- if (Utils.isNotEmpty(state.contractId) && state.contractId != "0") {
|
|
|
+ if (state.type != 0) {
|
|
|
//编辑
|
|
|
taskFuture = _agencyRepository.fetchContractEditDetail(contractId: state.contractId, cancelToken: cancelToken);
|
|
|
} else {
|
|
@@ -37,16 +37,17 @@ class ContractAddController extends GetxController with DioCancelableMixin {
|
|
|
if (result.isSuccess) {
|
|
|
state.detailOption = result.data;
|
|
|
|
|
|
- state.selectedStartTime = result.data?.row?.startDate == null ? null : DateTimeUtils.getDateTime(result.data!.row!.startDate!);
|
|
|
- state.selectedEndTime = result.data?.row?.endDate == null ? null : DateTimeUtils.getDateTime(result.data!.row!.endDate!);
|
|
|
-
|
|
|
state.agencyList = state.detailOption?.agencyList ?? [];
|
|
|
-
|
|
|
state.selectedAgencyId = state.detailOption?.agencyList.firstWhere((e) => e.selected == "selected", orElse: () => IndexOptionEntity()).value;
|
|
|
state.selectedAgencyTxt = state.detailOption?.agencyList.firstWhere((e) => e.selected == "selected", orElse: () => IndexOptionEntity()).txt;
|
|
|
|
|
|
- if(Utils.isNotEmpty(state.detailOption?.row?.file)){
|
|
|
- List<String> images = [state.detailOption!.row!.file!];
|
|
|
+ if (state.type == 1){
|
|
|
+ state.selectedStartTime = result.data?.row?.startDate == null ? null : DateTimeUtils.getDateTime(result.data!.row!.startDate!);
|
|
|
+ state.selectedEndTime = result.data?.row?.endDate == null ? null : DateTimeUtils.getDateTime(result.data!.row!.endDate!);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Utils.isNotEmpty(state.detailOption?.row?.file) && state.type == 1) {
|
|
|
+ List<String> images = [state.detailOption!.row!.file!];
|
|
|
state.selectedPaths = images;
|
|
|
}
|
|
|
|
|
@@ -59,7 +60,16 @@ class ContractAddController extends GetxController with DioCancelableMixin {
|
|
|
/// 提交
|
|
|
void doSubmit() async {
|
|
|
Future<HttpResult> taskFuture;
|
|
|
- if (Utils.isNotEmpty(state.contractId) && state.contractId != "0") {
|
|
|
+ if (state.type == 0) {
|
|
|
+ taskFuture = _agencyRepository.addContractSubmit(
|
|
|
+ agencyId: state.selectedAgencyId,
|
|
|
+ startDate: DateTimeUtils.formatDate(state.selectedStartTime!, format: 'yyyy-MM-dd'),
|
|
|
+ endDate: DateTimeUtils.formatDate(state.selectedEndTime!, format: 'yyyy-MM-dd'),
|
|
|
+ paths: state.selectedPaths,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ } else if (state.type == 1){
|
|
|
taskFuture = _agencyRepository.editContractSubmit(
|
|
|
contractId: state.contractId,
|
|
|
agencyId: state.selectedAgencyId,
|
|
@@ -68,8 +78,9 @@ class ContractAddController extends GetxController with DioCancelableMixin {
|
|
|
paths: state.selectedPaths,
|
|
|
cancelToken: cancelToken,
|
|
|
);
|
|
|
- } else {
|
|
|
- taskFuture = _agencyRepository.addContractSubmit(
|
|
|
+ }else{
|
|
|
+ taskFuture = _agencyRepository.renewContractSubmit(
|
|
|
+ contractId: state.contractId,
|
|
|
agencyId: state.selectedAgencyId,
|
|
|
startDate: DateTimeUtils.formatDate(state.selectedStartTime!, format: 'yyyy-MM-dd'),
|
|
|
endDate: DateTimeUtils.formatDate(state.selectedEndTime!, format: 'yyyy-MM-dd'),
|