|
|
@@ -3,7 +3,9 @@ package com.modular.apputils.presenter;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.support.design.widget.TabLayout;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.view.View;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -42,16 +44,22 @@ import java.util.Map;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
+/**
|
|
|
+ * Created by RaoMeng
|
|
|
+ * Desc: 通用表单presenter操作类
|
|
|
+ */
|
|
|
public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListener {
|
|
|
public final int LOAD_FORM = 0x11;//获取配置接口
|
|
|
public final int SAVE_AND_SUBMIT = 0x12;//保存提交接口
|
|
|
public final int LOAD_JUDGE_APPROVAL = 0x13;//获取审批人员
|
|
|
public final int SELECT_APPROVAL = 0x14;//选择审批人
|
|
|
+ public final int SAVE_MAINTENANCE_BILL = 0x15;//养护管理保存
|
|
|
|
|
|
protected IBill iBill;
|
|
|
protected String mCaller;//当前单据的Caller
|
|
|
protected int mId;//当前单据拥有的id,新增默认为0 如果mid为-1,说明保存时候使用更新的接口
|
|
|
protected HashMap<String, String> hashMap;//从外面传进来的默认值
|
|
|
+ protected boolean mFormToGrid = false;
|
|
|
|
|
|
private String detailKeyField;//从表id字段
|
|
|
private String keyField;//主表id字段
|
|
|
@@ -99,48 +107,41 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
if (mTitle != null) {
|
|
|
iBill.setTitle(mTitle);
|
|
|
}
|
|
|
+ mFormToGrid = intent.getBooleanExtra(Constants.Intents.FORM_TO_GRID, false);
|
|
|
}
|
|
|
loadFormandGridDetail();
|
|
|
}
|
|
|
|
|
|
public void saveAndSubmit(List<BillGroupModel.BillModel> formFields, List<List<BillGroupModel.BillModel>> gridBillMap) {
|
|
|
- Map<String, Object> formStore = new HashMap<>();
|
|
|
- for (BillGroupModel.BillModel e : formFields) {
|
|
|
- if (TextUtils.isEmpty(e.getValue()) && e.getIsdefault() == -1 &&
|
|
|
- ("necessaryField".equals(e.getAllowBlank()) || "F".equals(e.getAllowBlank()))) {
|
|
|
- iBill.showToast(e.getCaption() + "为必填项");
|
|
|
- iBill.dimssLoading();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (isEnclosureNeedSubmit(e)) {
|
|
|
- pushEnclosure(e);
|
|
|
- return;
|
|
|
- }
|
|
|
- formStore.put(e.getField(), e.getDisplay());
|
|
|
+ saveAndSubmit(formFields, gridBillMap, "mobile/oa/commonSaveAndSubmit.action", "mobile/commonUpdate.action");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void saveAndSubmit(List<BillGroupModel.BillModel> formFields, List<List<BillGroupModel.BillModel>> gridBillMap,
|
|
|
+ String saveUrl, String updateUrl) {
|
|
|
+ Map<String, Object> formStore = analysisForm(formFields);
|
|
|
+ if (formStore == null) {
|
|
|
+ iBill.dimssLoading();
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> gridStoreList = analysisGrid(gridBillMap);
|
|
|
if (gridStoreList == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (formStore == null || gridStoreList == null) {
|
|
|
iBill.dimssLoading();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-// String formStoreStr = JSONUtil.map2JSON(formStore);
|
|
|
-// String gridStoreStr = JSONUtil.map2JSON(gridStoreList);
|
|
|
String formStoreStr = JSON.toJSONString(formStore);
|
|
|
String gridStoreStr = JSON.toJSONString(gridStoreList);
|
|
|
|
|
|
-// LogUtil.i("gong", "formStoreStr=" + formStoreStr);
|
|
|
-// LogUtil.i("gong", "gridStoreStr=" + gridStoreStr);
|
|
|
+ LogUtil.prinlnLongMsg("raomengForm", formStoreStr);
|
|
|
+ LogUtil.prinlnLongMsg("raomengGrid", gridStoreStr);
|
|
|
try {
|
|
|
requestCompanyHttp(new Parameter.Builder()
|
|
|
- .url(mId == 0 ? "mobile/oa/commonSaveAndSubmit.action" : "mobile/commonUpdate.action")
|
|
|
+ .url(mId == 0 ? saveUrl : updateUrl)
|
|
|
.addParams("caller", mCaller)
|
|
|
.mode(Method.POST)
|
|
|
.addParams("keyid", String.valueOf(mId))
|
|
|
+ .addParams("id", String.valueOf(mId))
|
|
|
.addParams("formStore", formStoreStr)
|
|
|
.addParams("gridStore", gridStoreStr)
|
|
|
.record(SAVE_AND_SUBMIT)
|
|
|
@@ -151,28 +152,62 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void saveAndSubmit(List<BillGroupModel.BillModel> formFields, List<BillGroupModel.GridTab> otherGridList, int flag) {
|
|
|
- Map<String, Object> formStore = new HashMap<>();
|
|
|
- for (BillGroupModel.BillModel e : formFields) {
|
|
|
- if (TextUtils.isEmpty(e.getValue()) && e.getIsdefault() == -1 &&
|
|
|
- ("necessaryField".equals(e.getAllowBlank()) || "F".equals(e.getAllowBlank()))) {
|
|
|
- iBill.showToast(e.getCaption() + "为必填项");
|
|
|
- iBill.dimssLoading();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (isEnclosureNeedSubmit(e)) {
|
|
|
- pushEnclosure(e);
|
|
|
- return;
|
|
|
- }
|
|
|
- formStore.put(e.getField(), e.getDisplay());
|
|
|
+ protected void saveAndSubmit(List<BillGroupModel.BillModel> formFields, List<BillGroupModel.GridTab> otherGridList, int flag) {
|
|
|
+ saveAndSubmit(formFields, otherGridList, flag, "mobile/oa/commonSaveAndSubmit.action", "mobile/commonUpdate.action");
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void saveAndSubmit(List<BillGroupModel.BillModel> formFields, List<BillGroupModel.GridTab> otherGridList, int flag,
|
|
|
+ String saveUrl, String updateUrl) {
|
|
|
+ if (flag <= 0) {
|
|
|
+ flag = SAVE_AND_SUBMIT;
|
|
|
+ }
|
|
|
+ Map<String, Object> formStore = analysisForm(formFields);
|
|
|
+
|
|
|
+ if (formStore == null) {
|
|
|
+ iBill.dimssLoading();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> otherGridStoreList = getOtherGirdList(otherGridList);
|
|
|
+ if (otherGridStoreList == null) {
|
|
|
+ iBill.dimssLoading();
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
+ String formStoreStr = JSON.toJSONString(formStore);
|
|
|
+ String otherGridStoreListStr = JSON.toJSONString(otherGridStoreList);
|
|
|
+
|
|
|
+ LogUtil.prinlnLongMsg("raomengForm", formStoreStr);
|
|
|
+ LogUtil.prinlnLongMsg("raomengGrid", otherGridStoreListStr);
|
|
|
+ try {
|
|
|
+ requestCompanyHttp(new Parameter.Builder()
|
|
|
+ .url(mId == 0 ? saveUrl : updateUrl)
|
|
|
+ .mode(Method.POST)
|
|
|
+ .addParams("caller", mCaller)
|
|
|
+ .addParams("keyid", String.valueOf(mId))
|
|
|
+ .addParams("id", String.valueOf(mId))
|
|
|
+ .addParams("formStore", formStoreStr)
|
|
|
+ .addParams("othergridStore", otherGridStoreListStr)
|
|
|
+ .record(flag)
|
|
|
+ , this);
|
|
|
+ } catch (Exception e) {
|
|
|
+ iBill.dimssLoading();
|
|
|
+ iBill.showToast("网络请求异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析多从表
|
|
|
+ *
|
|
|
+ * @param otherGridList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ protected List<Map<String, Object>> getOtherGirdList(List<BillGroupModel.GridTab> otherGridList) {
|
|
|
List<Map<String, Object>> otherGridStoreList = new ArrayList<>();
|
|
|
for (BillGroupModel.GridTab gridTab : otherGridList) {
|
|
|
if (gridTab != null) {
|
|
|
List<BillGroupModel> tabGroupModels = gridTab.getBillGroupModels();
|
|
|
String otherCaller = gridTab.getCaller();
|
|
|
- if (tabGroupModels != null && tabGroupModels.size() > 0) {
|
|
|
+ if (tabGroupModels != null) {
|
|
|
List<List<BillGroupModel.BillModel>> otherGridMap = new ArrayList<>();
|
|
|
for (BillGroupModel tabGroupModel : tabGroupModels) {
|
|
|
List<BillGroupModel.BillModel> otherGrid = new ArrayList<>();
|
|
|
@@ -189,9 +224,9 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
}
|
|
|
List<Map<String, Object>> otherGridStoreItem = analysisGrid(otherGridMap);
|
|
|
if (otherGridStoreItem == null) {
|
|
|
- return;
|
|
|
+ return null;
|
|
|
}
|
|
|
-// String otherGridStoreItemStr = JSONUtil.map2JSON(otherGridStoreItem);
|
|
|
+
|
|
|
String otherGridStoreItemStr = JSON.toJSONString(otherGridStoreItem);
|
|
|
JSONArray otherGridStoreItemArray = JSON.parseArray(otherGridStoreItemStr);
|
|
|
|
|
|
@@ -203,34 +238,29 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return otherGridStoreList;
|
|
|
+ }
|
|
|
|
|
|
-// String formStoreStr = JSONUtil.map2JSON(formStore);
|
|
|
-// String otherGridStoreListStr = JSONUtil.map2JSON(otherGridStoreList);
|
|
|
- String formStoreStr = JSON.toJSONString(formStore);
|
|
|
- String otherGridStoreListStr = JSON.toJSONString(otherGridStoreList);
|
|
|
-// LogUtil.prinlnLongMsg("billJson", formStoreStr);
|
|
|
-// LogUtil.prinlnLongMsg("billJson", otherGridStoreListStr);
|
|
|
-// LogUtil.prinlnLongMsg("billJson2", formStoreStr);
|
|
|
-// LogUtil.prinlnLongMsg("billJson2", otherGridStoreListStr);
|
|
|
-
|
|
|
- try {
|
|
|
- requestCompanyHttp(new Parameter.Builder()
|
|
|
- .url(mId == 0 ? "mobile/oa/commonSaveAndSubmit.action" : "mobile/commonUpdate.action")
|
|
|
- .mode(Method.POST)
|
|
|
- .addParams("caller", mCaller)
|
|
|
- .addParams("keyid", String.valueOf(mId))
|
|
|
- .addParams("formStore", formStoreStr)
|
|
|
- .addParams("othergridStore", otherGridStoreListStr)
|
|
|
- .record(SAVE_AND_SUBMIT)
|
|
|
- , this);
|
|
|
- } catch (Exception e) {
|
|
|
- iBill.dimssLoading();
|
|
|
- iBill.showToast("网络请求异常");
|
|
|
+ public Map<String, Object> analysisForm(List<BillGroupModel.BillModel> formFields) {
|
|
|
+ Map<String, Object> formStore = new HashMap<>();
|
|
|
+ for (BillGroupModel.BillModel e : formFields) {
|
|
|
+ if (TextUtils.isEmpty(e.getValue()) && e.getIsdefault() == -1 &&
|
|
|
+ ("necessaryField".equals(e.getAllowBlank()) || "F".equals(e.getAllowBlank()))) {
|
|
|
+ iBill.showToast(e.getCaption() + "为必填项");
|
|
|
+ iBill.dimssLoading();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (isEnclosureNeedSubmit(e)) {
|
|
|
+ pushEnclosure(e);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ formStore.put(e.getField(), e.getDisplay());
|
|
|
}
|
|
|
+ return formStore;
|
|
|
}
|
|
|
|
|
|
@Nullable
|
|
|
- private List<Map<String, Object>> analysisGrid(List<List<BillGroupModel.BillModel>> gridBillMap) {
|
|
|
+ public List<Map<String, Object>> analysisGrid(List<List<BillGroupModel.BillModel>> gridBillMap) {
|
|
|
List<Map<String, Object>> gridStoreList = new ArrayList<>();
|
|
|
for (List<BillGroupModel.BillModel> e : gridBillMap) {
|
|
|
if (!ListUtils.isEmpty(e)) {
|
|
|
@@ -256,43 +286,30 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
}
|
|
|
|
|
|
public void saveAndSubmit(List<BillGroupModel> mGroupModels) {
|
|
|
- iBill.showLoading();
|
|
|
- List<BillGroupModel.BillModel> formFields = new ArrayList<>();
|
|
|
- List<List<BillGroupModel.BillModel>> gridBillMap = new ArrayList<>();
|
|
|
- List<BillGroupModel.GridTab> otherGridList = new ArrayList<>();
|
|
|
- for (BillGroupModel e : mGroupModels) {
|
|
|
- if (e.isForm()) {
|
|
|
- if (e.getShowBillFields() != null) {
|
|
|
- formFields.addAll(e.getShowBillFields());
|
|
|
- }
|
|
|
- if (e.getHideBillFields() != null) {
|
|
|
- formFields.addAll(e.getHideBillFields());
|
|
|
- }
|
|
|
+ saveAndSubmit(mGroupModels, "mobile/oa/commonSaveAndSubmit.action", "mobile/commonUpdate.action");
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- List<BillGroupModel.GridTab> gridTabs = e.getGridTabs();
|
|
|
- if (gridTabs != null && gridTabs.size() > 0) {
|
|
|
- otherGridList = gridTabs;
|
|
|
- break;
|
|
|
- }
|
|
|
- List<BillGroupModel.BillModel> gridBillFields = new ArrayList<>();
|
|
|
- if (e.getShowBillFields() != null) {
|
|
|
- gridBillFields.addAll(e.getShowBillFields());
|
|
|
- }
|
|
|
- if (e.getHideBillFields() != null) {
|
|
|
- gridBillFields.addAll(e.getHideBillFields());
|
|
|
- }
|
|
|
- gridBillMap.add(gridBillFields);
|
|
|
- }
|
|
|
- }
|
|
|
+ public void saveAndSubmit(List<BillGroupModel> mGroupModels, int flag) {
|
|
|
+ saveAndSubmit(mGroupModels, flag, "mobile/oa/commonSaveAndSubmit.action", "mobile/commonUpdate.action");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void saveAndSubmit(List<BillGroupModel> mGroupModels, String saveUrl, String updateUrl) {
|
|
|
+ saveAndSubmit(mGroupModels, SAVE_AND_SUBMIT, saveUrl, updateUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void saveAndSubmit(List<BillGroupModel> mGroupModels, int flag, String saveUrl, String updateUrl) {
|
|
|
+ iBill.showLoading();
|
|
|
+ BillField billField = new BillField(mGroupModels).invoke();
|
|
|
+ List<BillGroupModel.BillModel> formFields = billField.getFormFields();
|
|
|
+ List<List<BillGroupModel.BillModel>> gridBillMap = billField.getGridBillMap();
|
|
|
+ List<BillGroupModel.GridTab> otherGridList = billField.getOtherGridList();
|
|
|
if (otherGridList == null || otherGridList.size() <= 0) {
|
|
|
- saveAndSubmit(formFields, gridBillMap);
|
|
|
+ saveAndSubmit(formFields, gridBillMap, saveUrl, updateUrl);
|
|
|
} else {
|
|
|
- saveAndSubmit(formFields, otherGridList, 0);
|
|
|
+ saveAndSubmit(formFields, otherGridList, flag, saveUrl, updateUrl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private Map<String, Object> getFormStore(List<BillGroupModel.BillModel> formFields) {
|
|
|
Map<String, Object> formStore = new HashMap<>();
|
|
|
for (BillGroupModel.BillModel e : formFields) {
|
|
|
@@ -439,13 +456,21 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
case SAVE_AND_SUBMIT:
|
|
|
if (JSONUtil.getBoolean(jsonObject, "success")) {
|
|
|
if (mId <= 0) {
|
|
|
- int keyvalue = JSONUtil.getInt(jsonObject, "keyvalue");
|
|
|
+ int keyvalue = JSONUtil.getInt(jsonObject, keyField, "keyvalue");
|
|
|
String formcode = JSONUtil.getText(jsonObject, "formcode");
|
|
|
- judgeApproval(keyvalue, formcode);
|
|
|
- iBill.showToast(R.string.save_success);
|
|
|
+ boolean isSave = JSONUtil.getBoolean(jsonObject, "isSave");//是否是保存操作,true:保存,false:提交
|
|
|
+ if (isSave) {
|
|
|
+ iBill.commitSuccess(keyvalue, formcode);
|
|
|
+ } else {
|
|
|
+ judgeApproval(keyvalue, formcode);
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(JSONUtil.getText(message, "exceptionInfo"))) {
|
|
|
+ iBill.showToast(JSONUtil.getText(message, "exceptionInfo"));
|
|
|
+ }
|
|
|
+ iBill.showToast(R.string.submit_success);
|
|
|
} else {
|
|
|
judgeApproval(mId, "");
|
|
|
- iBill.showToast(R.string.save_success);
|
|
|
+ iBill.showToast(R.string.submit_success);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -574,13 +599,14 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- protected void handlerMultiBill(JSONObject resultObject) {
|
|
|
-// String localJson = CommonUtil.getAssetsJson(ct, "bill.json");
|
|
|
-// LogUtil.prinlnLongMsg("billJson", localJson);
|
|
|
- try {
|
|
|
-// JSONObject resultObject = JSON.parseObject(localJson);
|
|
|
+ protected List<BillGroupModel> handlerMultiBill(JSONObject resultObject) {
|
|
|
+ return handlerMultiBill(resultObject, mFormToGrid, "");
|
|
|
+ }
|
|
|
|
|
|
- List<BillGroupModel> showBillModels = new ArrayList<>();
|
|
|
+ protected List<BillGroupModel> handlerMultiBill(JSONObject resultObject, boolean formToGrid, String formTitle) {
|
|
|
+ List<BillGroupModel> showBillModels = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ mFormToGrid = formToGrid;
|
|
|
JSONObject config = JSONUtil.getJSONObject(resultObject, "config");
|
|
|
detailKeyField = JSONUtil.getText(config, "fo_detailkeyfield");
|
|
|
keyField = JSONUtil.getText(config, "fo_keyfield");
|
|
|
@@ -590,24 +616,39 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
JSONObject data = JSONUtil.getJSONObject(resultObject, "data");
|
|
|
JSONArray formdetail = JSONUtil.getJSONArray(data, "formdetail");
|
|
|
Map<String, BillGroupModel> formdeMap = handlerFormdetail(formdetail);
|
|
|
+
|
|
|
+ List<BillGroupModel> formBillModels = new ArrayList<>();//主表显示字段
|
|
|
if (formdeMap != null && !formdeMap.isEmpty()) {
|
|
|
for (Map.Entry<String, BillGroupModel> entry : formdeMap.entrySet()) {
|
|
|
BillGroupModel entryValue = entry.getValue();
|
|
|
if (entryValue != null) {
|
|
|
//主表caller为单据caller
|
|
|
entryValue.setBillCaller(mCaller);
|
|
|
- showBillModels.add(entryValue);
|
|
|
+ formBillModels.add(entryValue);
|
|
|
}
|
|
|
}
|
|
|
- if (!ListUtils.isEmpty(showBillModels)) {
|
|
|
- Collections.sort(showBillModels, mComparator);
|
|
|
+ if (!ListUtils.isEmpty(formBillModels)) {
|
|
|
+ Collections.sort(formBillModels, mComparator);
|
|
|
}
|
|
|
}
|
|
|
multidetailgrid = JSONUtil.getBoolean(data, "multidetailgrid");
|
|
|
if (multidetailgrid) {
|
|
|
JSONArray othergridetail = JSONUtil.getJSONArray(data, "othergridetail");
|
|
|
if (othergridetail != null && othergridetail.size() > 0) {
|
|
|
- List<BillGroupModel.GridTab> otherGridTabs = handlerGirdTabs(showBillModels.size() + 1, othergridetail);
|
|
|
+ List<BillGroupModel.GridTab> otherGridTabs = new ArrayList<>();
|
|
|
+ if (formToGrid) {
|
|
|
+// showBillModels.addAll(formBillModels);
|
|
|
+ BillGroupModel.GridTab formGridTab = new BillGroupModel.GridTab();
|
|
|
+ formGridTab.setPosition(0);
|
|
|
+ formGridTab.setTitle(TextUtils.isEmpty(formTitle) ? "基础信息" : formTitle);
|
|
|
+ formGridTab.setCaller(mCaller);
|
|
|
+ formGridTab.setBillGroupModels(formBillModels);
|
|
|
+ otherGridTabs.add(formGridTab);
|
|
|
+ } else {
|
|
|
+ showBillModels.addAll(formBillModels);
|
|
|
+ }
|
|
|
+ otherGridTabs.addAll(
|
|
|
+ handlerGirdTabs(showBillModels.size() + 1, othergridetail, otherGridTabs.size()));
|
|
|
if (otherGridTabs.size() > 0) {
|
|
|
BillGroupModel billTab = new BillGroupModel();
|
|
|
billTab.setForm(false);
|
|
|
@@ -617,9 +658,31 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
showBillModels.add(billTab);
|
|
|
|
|
|
showBillModels.addAll(otherGridTabs.get(0).getBillGroupModels());
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 如果是多从表,则添加顶部悬浮的tablayout
|
|
|
+ */
|
|
|
+ View topLayout = View.inflate(ct, R.layout.item_bill_tab, null);
|
|
|
+ TabLayout tabLayout = topLayout.findViewById(R.id.bill_tab_tl);
|
|
|
+ if (tabLayout != null) {
|
|
|
+ for (int i = 0; i < otherGridTabs.size(); i++) {
|
|
|
+ tabLayout.addTab(tabLayout.newTab().setText(otherGridTabs.get(i).getTitle()));
|
|
|
+ }
|
|
|
+ if (tabLayout.getTabCount() > 4) {
|
|
|
+ tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
|
|
|
+ } else {
|
|
|
+ tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
|
|
+ }
|
|
|
+ if (tabLayout.getTabCount() > 0) {
|
|
|
+ tabLayout.getTabAt(0).select();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ iBill.addTopLayout(topLayout, tabLayout);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ showBillModels.addAll(formBillModels);
|
|
|
JSONArray gridetail = JSONUtil.getJSONArray(data, "gridetail");
|
|
|
Map<String, BillGroupModel> gridGroupModelMap = handlerGridetail(showBillModels.size(), gridetail);
|
|
|
if (gridGroupModelMap != null && !gridGroupModelMap.isEmpty()) {
|
|
|
@@ -636,36 +699,29 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
LogUtil.i("gong", "showBillModels=" + JSON.toJSONString(showBillModels));
|
|
|
iBill.setAdapter(showBillModels);
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+ return showBillModels;
|
|
|
}
|
|
|
|
|
|
- private List<BillGroupModel.GridTab> handlerGirdTabs(int index, JSONArray othergridetail) {
|
|
|
+ private List<BillGroupModel.GridTab> handlerGirdTabs(int index, JSONArray othergridetail, int position) {
|
|
|
List<BillGroupModel.GridTab> gridTabs = new ArrayList<>();
|
|
|
for (int i = 0; i < othergridetail.size(); i++) {
|
|
|
JSONObject otherGrid = othergridetail.getJSONObject(i);
|
|
|
if (otherGrid != null) {
|
|
|
JSONArray detailgrid = otherGrid.getJSONArray("detailgrid");
|
|
|
if (detailgrid != null && detailgrid.size() > 0) {
|
|
|
- BillGroupModel.GridTab gridTab = new BillGroupModel.GridTab();
|
|
|
String dgcaller = JSONUtil.getText(otherGrid, "dgcaller");
|
|
|
- gridTab.setTitle(JSONUtil.getText(otherGrid, "dgtitle"));
|
|
|
+ String dgtitle = JSONUtil.getText(otherGrid, "dgtitle");
|
|
|
+
|
|
|
+ BillGroupModel.GridTab gridTab = new BillGroupModel.GridTab();
|
|
|
+ gridTab.setTitle(dgtitle);
|
|
|
gridTab.setCaller(dgcaller);
|
|
|
- gridTab.setPosition(i);
|
|
|
+ gridTab.setPosition(position + i);
|
|
|
|
|
|
Map<String, BillGroupModel> gridGroupModelMap = handlerGridetail(index, detailgrid);
|
|
|
- if (gridGroupModelMap != null && !gridGroupModelMap.isEmpty()) {
|
|
|
- List<BillGroupModel> billGroupModels = new ArrayList<>();
|
|
|
- for (Map.Entry<String, BillGroupModel> entry : gridGroupModelMap.entrySet()) {
|
|
|
- BillGroupModel entryValue = entry.getValue();
|
|
|
- if (entryValue != null) {
|
|
|
- //多从表的情况下,从表caller与主表不同
|
|
|
- entryValue.setBillCaller(dgcaller);
|
|
|
- billGroupModels.add(entryValue);
|
|
|
- }
|
|
|
- }
|
|
|
- gridTab.setBillGroupModels(billGroupModels);
|
|
|
- }
|
|
|
+ List<BillGroupModel> billGroupModels = handleTabGroupModels(gridGroupModelMap, dgcaller, dgtitle);
|
|
|
+ gridTab.setBillGroupModels(billGroupModels);
|
|
|
|
|
|
gridTabs.add(gridTab);
|
|
|
}
|
|
|
@@ -674,6 +730,23 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
return gridTabs;
|
|
|
}
|
|
|
|
|
|
+ //返回多从表的某个从表内容
|
|
|
+ //可重写,控制某个从表内容
|
|
|
+ protected List<BillGroupModel> handleTabGroupModels(Map<String, BillGroupModel> gridGroupModelMap, String dgcaller, String dgtitle) {
|
|
|
+ List<BillGroupModel> billGroupModels = new ArrayList<>();
|
|
|
+ if (gridGroupModelMap != null && !gridGroupModelMap.isEmpty()) {
|
|
|
+ for (Map.Entry<String, BillGroupModel> entry : gridGroupModelMap.entrySet()) {
|
|
|
+ BillGroupModel entryValue = entry.getValue();
|
|
|
+ if (entryValue != null) {
|
|
|
+ //多从表的情况下,从表caller与主表不同
|
|
|
+ entryValue.setBillCaller(dgcaller);
|
|
|
+ billGroupModels.add(entryValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return billGroupModels;
|
|
|
+ }
|
|
|
+
|
|
|
//处理表单返回配置
|
|
|
protected void handlerBill(JSONObject object) {
|
|
|
LogUtil.i("gong", "object=" + object);
|
|
|
@@ -770,10 +843,11 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
* @param formdetail
|
|
|
* @return
|
|
|
*/
|
|
|
- private Map<String, BillGroupModel> handlerGridetail(int index, JSONArray formdetail) {
|
|
|
+ protected Map<String, BillGroupModel> handlerGridetail(int index, JSONArray formdetail) {
|
|
|
if (formdetail != null && !formdetail.isEmpty()) {
|
|
|
Map<String, BillGroupModel> modelMap = new LinkedHashMap<>();
|
|
|
if (mId <= 0) {
|
|
|
+ //id等于0,是新增单据,则默认添加一组从表
|
|
|
BillGroupModel mBillGroupModel = new BillGroupModel();
|
|
|
mBillGroupModel.setGroupIndex(index);
|
|
|
mBillGroupModel.setGridIndex(1);
|
|
|
@@ -796,12 +870,14 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
|
|
|
modelMap.put("明细1", mBillGroupModel);
|
|
|
} else {
|
|
|
+ //id大于0 ,说明是在录入单据,则将在录入数据先添加进从表
|
|
|
JSONObject object = null;
|
|
|
String oldGroup = null;
|
|
|
for (int i = 0; i < formdetail.size(); i++) {
|
|
|
object = formdetail.getJSONObject(i);
|
|
|
BillGroupModel.BillModel mBillModel = getBillModelByObject(object);
|
|
|
- String group = JSONUtil.getText(object, "dg_group");
|
|
|
+ String dg_group = JSONUtil.getText(object, "dg_group");
|
|
|
+ String group = TextUtils.isEmpty(dg_group) ? "0" : dg_group;//dg_group为0代表是新增的单据明细
|
|
|
|
|
|
if (modelMap.containsKey("明细" + group)) {
|
|
|
BillGroupModel mBillGroupModel = modelMap.get("明细" + group);
|
|
|
@@ -855,7 +931,7 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private BillGroupModel.BillModel getBillModelByObject(JSONObject object) {
|
|
|
+ protected BillGroupModel.BillModel getBillModelByObject(JSONObject object) {
|
|
|
BillGroupModel.BillModel mBillModel = new BillGroupModel.BillModel();
|
|
|
String caption = JSONUtil.getText(object, "fd_caption", "dg_caption");//字段名称
|
|
|
String value = JSONUtil.getText(object, "fd_value", "dg_value");//字段名称
|
|
|
@@ -867,12 +943,13 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
String dbfind = JSONUtil.getText(object, "fd_dbfind");//是否是dbfind字段判定
|
|
|
String type = JSONUtil.getText(object, "fd_type", "dg_type");//类型(标题类型为Constants.TYPE_TITLE,不触发点击事件等 )
|
|
|
String logicType = JSONUtil.getText(object, "fd_logictype", "dg_logictype");//logic类型
|
|
|
- String readOnly = JSONUtil.getText(object, "fd_readonly");//是否只读
|
|
|
+ String readOnly = JSONUtil.getText(object, "fd_readonly", "dg_editable");//是否只读
|
|
|
String field = JSONUtil.getText(object, "fd_field", "dg_field");//字段
|
|
|
String defValue = JSONUtil.getText(object, "fd_defaultvalue");//默认值
|
|
|
String allowBlank = JSONUtil.getText(object, "fd_allowblank");//是否允许为空(注:当作为标题的时候T:表示可以删除 F:表示不可删除)
|
|
|
String findFunctionName = JSONUtil.getText(object, "dg_findfunctionname");
|
|
|
String updatable = JSONUtil.getText(object, "fd_modify", "dg_modify");
|
|
|
+ String renderer = JSONUtil.getText(object, "dg_renderer");
|
|
|
|
|
|
if (TextUtils.isEmpty(defValue) && hashMap != null && hashMap.containsKey(field)) {
|
|
|
defValue = hashMap.get(field);
|
|
|
@@ -880,14 +957,23 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
if (logicType.equals("necessaryField")) {
|
|
|
allowBlank = "F";
|
|
|
}
|
|
|
+ String display = "";
|
|
|
JSONArray combostore = JSONUtil.getJSONArray(object, "COMBOSTORE");
|
|
|
if (!ListUtils.isEmpty(combostore)) {
|
|
|
List<BillGroupModel.LocalData> localDatas = new ArrayList<>();
|
|
|
for (int i = 0; i < combostore.size(); i++) {
|
|
|
JSONObject combosModel = combostore.getJSONObject(i);
|
|
|
BillGroupModel.LocalData mLocalData = new BillGroupModel.LocalData();
|
|
|
- mLocalData.display = JSONUtil.getText(combosModel, "DLC_DISPLAY");
|
|
|
- mLocalData.value = JSONUtil.getText(combosModel, "DLC_VALUE");
|
|
|
+ String dlc_display = JSONUtil.getText(combosModel, "DLC_DISPLAY");
|
|
|
+ String dlc_value = JSONUtil.getText(combosModel, "DLC_VALUE");
|
|
|
+ mLocalData.display = dlc_display;
|
|
|
+ mLocalData.value = dlc_value;
|
|
|
+ if ("C".equals(type)
|
|
|
+ && !TextUtils.isEmpty(value)
|
|
|
+ && (value.equals(dlc_display) || value.equals(dlc_value))) {
|
|
|
+ value = dlc_value;
|
|
|
+ display = dlc_display;
|
|
|
+ }
|
|
|
localDatas.add(mLocalData);
|
|
|
}
|
|
|
mBillModel.setLocalDatas(localDatas);
|
|
|
@@ -901,11 +987,23 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
// mBillModel.setDisplay(defValue);
|
|
|
// }
|
|
|
// }
|
|
|
+
|
|
|
+ //附件格式处理
|
|
|
+ /*String enclosureId = "";
|
|
|
+ if ((BillTypeChangeUtils.getItemViewType(type) == 2 || "detailAttach".equals(renderer)) && !TextUtils.isEmpty(value)) {
|
|
|
+ String[] valueArr = value.split(";");
|
|
|
+ if (valueArr != null && valueArr.length >= 2) {
|
|
|
+ value = valueArr[0];
|
|
|
+ enclosureId = valueArr[1];
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
mBillModel.setFindFunctionName(findFunctionName);
|
|
|
mBillModel.setDetno(fd_detno);
|
|
|
mBillModel.setCaption(caption);
|
|
|
mBillModel.setId(id);
|
|
|
mBillModel.setValue(value);
|
|
|
+ mBillModel.setDisplay(display);
|
|
|
mBillModel.setLength(length);
|
|
|
mBillModel.setAppwidth(appwidth);
|
|
|
mBillModel.setIsdefault(isdefault);
|
|
|
@@ -917,6 +1015,8 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
mBillModel.setDefValue(defValue);
|
|
|
mBillModel.setAllowBlank(allowBlank);
|
|
|
mBillModel.setUpdatable(updatable == "T");
|
|
|
+ mBillModel.setRenderer(renderer);
|
|
|
+// mBillModel.setEnclusureId(enclosureId);
|
|
|
return mBillModel;
|
|
|
}
|
|
|
|
|
|
@@ -928,4 +1028,80 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
|
|
|
public boolean isEnclosureNeedSubmit(BillGroupModel.BillModel billModel) {
|
|
|
return billModel.getType().equals("FF") && TextUtils.isEmpty(billModel.getValue()) && !ListUtils.isEmpty(billModel.getLocalDatas());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单据数据解析
|
|
|
+ */
|
|
|
+ public class BillField {
|
|
|
+ private List<BillGroupModel> mMGroupModels;
|
|
|
+ private List<BillGroupModel.BillModel> mFormFields;
|
|
|
+ private List<List<BillGroupModel.BillModel>> mGridBillMap;
|
|
|
+ private List<BillGroupModel.GridTab> mOtherGridList;
|
|
|
+
|
|
|
+ public BillField(List<BillGroupModel> mGroupModels) {
|
|
|
+ mMGroupModels = mGroupModels;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<BillGroupModel.BillModel> getFormFields() {
|
|
|
+ return mFormFields;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<List<BillGroupModel.BillModel>> getGridBillMap() {
|
|
|
+ return mGridBillMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<BillGroupModel.GridTab> getOtherGridList() {
|
|
|
+ return mOtherGridList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public BillField invoke() {
|
|
|
+ mFormFields = new ArrayList<>();
|
|
|
+ mGridBillMap = new ArrayList<>();
|
|
|
+ mOtherGridList = new ArrayList<>();
|
|
|
+ for (BillGroupModel e : mMGroupModels) {
|
|
|
+ if (e.isForm()) {
|
|
|
+ if (e.getShowBillFields() != null) {
|
|
|
+ mFormFields.addAll(e.getShowBillFields());
|
|
|
+ }
|
|
|
+ if (e.getHideBillFields() != null) {
|
|
|
+ mFormFields.addAll(e.getHideBillFields());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<BillGroupModel.GridTab> gridTabs = e.getGridTabs();
|
|
|
+ if (gridTabs != null && gridTabs.size() > 0) {
|
|
|
+ if (mFormToGrid) {//如果主表放入tab,则主表数据在gridtabs里
|
|
|
+ List<BillGroupModel> formGroupModels = gridTabs.get(0).getBillGroupModels();
|
|
|
+ if (formGroupModels != null && formGroupModels.size() > 0) {
|
|
|
+ for (BillGroupModel b : formGroupModels) {
|
|
|
+ if (b.isForm()) {
|
|
|
+ if (b.getShowBillFields() != null) {
|
|
|
+ mFormFields.addAll(b.getShowBillFields());
|
|
|
+ }
|
|
|
+ if (b.getHideBillFields() != null) {
|
|
|
+ mFormFields.addAll(b.getHideBillFields());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (gridTabs.size() > 1) {
|
|
|
+ mOtherGridList = gridTabs.subList(1, gridTabs.size());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mOtherGridList = gridTabs;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ List<BillGroupModel.BillModel> gridBillFields = new ArrayList<>();
|
|
|
+ if (e.getShowBillFields() != null) {
|
|
|
+ gridBillFields.addAll(e.getShowBillFields());
|
|
|
+ }
|
|
|
+ if (e.getHideBillFields() != null) {
|
|
|
+ gridBillFields.addAll(e.getHideBillFields());
|
|
|
+ }
|
|
|
+ mGridBillMap.add(gridBillFields);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|