|
|
@@ -9,7 +9,10 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
+import com.common.data.StringUtil;
|
|
|
import com.core.app.Constants;
|
|
|
+import com.core.app.MyApplication;
|
|
|
+import com.core.utils.CommonUtil;
|
|
|
import com.me.network.app.http.Method;
|
|
|
import com.modular.apputils.model.BillGroupModel;
|
|
|
import com.modular.apputils.network.Parameter;
|
|
|
@@ -30,6 +33,8 @@ public class CustomerContactBillPresenter extends BillPresenter {
|
|
|
private final int LOAD_FORM_DETAILS = 0x32;
|
|
|
private final int DELETE_DETAIL = 0x33;
|
|
|
private final int TAG_DELETE_INDEX = 0x41;
|
|
|
+ private final int LOAD_FILE_PATHS = 0x42;
|
|
|
+ private final int TAG_GROUP_INDEX = 0x43;
|
|
|
|
|
|
|
|
|
public CustomerContactBillPresenter(Context ct, IBill iBill, IContact iContact) {
|
|
|
@@ -143,6 +148,21 @@ public class CustomerContactBillPresenter extends BillPresenter {
|
|
|
, this);
|
|
|
}
|
|
|
|
|
|
+ /*获取附件 */
|
|
|
+ private void loadFilePaths(int mGroupIndex, String attachs) {
|
|
|
+ if (StringUtil.isEmpty(attachs) || "null".equals(attachs)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ iBill.showLoading();
|
|
|
+ requestCompanyHttp(new Parameter.Builder()
|
|
|
+ .url("common/getFilePaths.action")
|
|
|
+ .addParams("field", "fb_attach")
|
|
|
+ .addParams("id", attachs)
|
|
|
+ .addTag(TAG_GROUP_INDEX, mGroupIndex)
|
|
|
+ .record(LOAD_FILE_PATHS)
|
|
|
+ , this);
|
|
|
+ }
|
|
|
+
|
|
|
public void deleteDetail(int groupIndex, int ctId) {
|
|
|
iBill.showLoading();
|
|
|
requestCompanyHttp(new Parameter.Builder()
|
|
|
@@ -171,16 +191,53 @@ public class CustomerContactBillPresenter extends BillPresenter {
|
|
|
iContact.deleteDetailOk(deleteIndex);
|
|
|
}
|
|
|
break;
|
|
|
+ case LOAD_FILE_PATHS:
|
|
|
+ int mGroupIndex = 0;
|
|
|
+ if (tag != null && tag.get(TAG_GROUP_INDEX) != null && tag.get(TAG_GROUP_INDEX) instanceof Integer) {
|
|
|
+ mGroupIndex = (int) tag.get(TAG_GROUP_INDEX);
|
|
|
+ }
|
|
|
+ handlerEnclosure(mGroupIndex, JSONUtil.getJSONArray(JSON.parseObject(message), "files"));
|
|
|
+ break;
|
|
|
default:
|
|
|
super.onSuccess(what, message, tag);
|
|
|
|
|
|
}
|
|
|
iBill.dimssLoading();
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onFailure(int what, String message, Tags tag) throws Exception {
|
|
|
+ if (LOAD_FILE_PATHS != what) {
|
|
|
+ super.onFailure(what, message, tag);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ private void handlerEnclosure(final int mGroupIndex, final JSONArray array) throws Exception {
|
|
|
+ List<BillGroupModel.LocalData> mLocalDatas = new ArrayList<>();
|
|
|
+ if (!ListUtils.isEmpty(array)) {
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
+ JSONObject o = array.getJSONObject(i);
|
|
|
+ if (o == null) continue;
|
|
|
+ BillGroupModel.LocalData mLocalData = new BillGroupModel.LocalData();
|
|
|
+ int id = JSONUtil.getInt(o, "fp_id");
|
|
|
+ mLocalData.value = JSONUtil.getText(o, "fp_name");
|
|
|
+ mLocalData.display = getImageUrl(id);
|
|
|
+ mLocalDatas.add(mLocalData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!ListUtils.isEmpty(mLocalDatas)) {
|
|
|
+ iContact.setFilePaths(mGroupIndex, mLocalDatas);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private String getImageUrl(int id) {
|
|
|
+ return CommonUtil.getAppBaseUrl(MyApplication.getInstance()) + "common/downloadbyId.action?id=" + id + "&sessionId=" +
|
|
|
+ CommonUtil.getSharedPreferences(MyApplication.getInstance(), "sessionId") +
|
|
|
+ "&sessionUser=" + CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_username") +
|
|
|
+ "&master=" + CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_master");
|
|
|
+ }
|
|
|
+
|
|
|
private void handlerFormData(JSONObject datas) throws Exception {
|
|
|
String status = null;
|
|
|
List<BillGroupModel> mBillGroupModels = new ArrayList<>();
|
|
|
@@ -246,6 +303,9 @@ public class CustomerContactBillPresenter extends BillPresenter {
|
|
|
mBillModel.setField(field);
|
|
|
mBillModel.setAllowBlank(allowBlank);
|
|
|
mBillModel.setValue(JSONUtil.getText(object, field));
|
|
|
+ if ("ct_attach".equals(mBillModel.getField())) {
|
|
|
+ mBillModel.setType("FF");
|
|
|
+ }
|
|
|
if (!ListUtils.isEmpty(combostore)) {
|
|
|
List<BillGroupModel.LocalData> localDatas = new ArrayList<>();
|
|
|
for (int j = 0; j < combostore.size(); j++) {
|
|
|
@@ -258,6 +318,9 @@ public class CustomerContactBillPresenter extends BillPresenter {
|
|
|
mBillModel.setLocalDatas(localDatas);
|
|
|
}
|
|
|
if (mBillModel.getIsdefault() == -1 && !mBillModel.getType().equals("H")) {
|
|
|
+ if ("FF".equals(mBillModel.getType()) && !StringUtil.isEmpty(mBillModel.getValue())) {
|
|
|
+ loadFilePaths(mBillModel.getGroupIndex(), mBillModel.getValue());
|
|
|
+ }
|
|
|
mGroupModel.addShow(mBillModel);
|
|
|
} else {
|
|
|
mGroupModel.addHide(mBillModel);
|