|
|
@@ -3,8 +3,13 @@ package com.uas.appworks.crm3_0.activity;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
+import android.view.MenuItem;
|
|
|
import android.widget.PopupWindow;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baidu.mapapi.model.LatLng;
|
|
|
+import com.common.LogUtil;
|
|
|
import com.common.data.DateFormatUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
@@ -42,6 +47,26 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
|
|
|
private final int TAG_COMPANY_SELECT = 0x651;
|
|
|
private PopupWindow popupWindow;
|
|
|
private int keyValue;
|
|
|
+ private SelectAimModel address;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
+ if (item.getItemId() == R.id.saveAndSubmit) {
|
|
|
+ if (address != null && address.getLatLng() != null) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("company", address.getName());
|
|
|
+ map.put("companyAddress", address.getAddress());
|
|
|
+ map.put("visitTime", DateFormatUtil.long2Str(DateFormatUtil.YMD_HMS));
|
|
|
+ map.put("latitude", address.getLatLng().latitude);
|
|
|
+ map.put("longitude", address.getLatLng().longitude);
|
|
|
+ saveOutAddress(map);
|
|
|
+ }
|
|
|
+ mBillPresenter.saveAndSubmit(mBillAdapter.getBillGroupModels());
|
|
|
+ } else if (item.getItemId() == com.modular.apputils.R.id.list) {
|
|
|
+ toDataFormList();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void setAdapter(List<BillGroupModel> groupModels) {
|
|
|
@@ -142,6 +167,22 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void handlerSelectDbFind(JSONObject object, int groupId) {
|
|
|
+ super.handlerSelectDbFind(object, groupId);
|
|
|
+ String mp_cuname = JSONUtil.getText(object, "mp_cuname");
|
|
|
+ String mp_address = JSONUtil.getText(object, "mp_address");
|
|
|
+ if (!StringUtil.isEmpty(mp_cuname) || !StringUtil.isEmpty(mp_address)) {
|
|
|
+ if (address == null) {
|
|
|
+ address = new SelectAimModel();
|
|
|
+ }
|
|
|
+ address.setName(mp_cuname);
|
|
|
+ address.setAddress(mp_address);
|
|
|
+ loadLatLng(StringUtil.isEmpty(mp_address) ? mp_cuname : mp_address);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void sureSelectAim(SelectAimModel entity) {
|
|
|
if (entity == null || selectPosition < 0 || selectPosition > ListUtils.getSize(mBillAdapter.getBillGroupModels())) {
|
|
|
selectPosition = -1;
|
|
|
@@ -181,13 +222,28 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void commitSuccess(int keyValue, String code) {
|
|
|
+ public void commitSuccess(final int keyValue, String code) {
|
|
|
this.keyValue = keyValue;
|
|
|
- saveAddress();
|
|
|
+ ToastMessage("提交成功!");
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (mContext == null) return;
|
|
|
+ startActivity(new Intent(ct, CustomerVisitDetailsActivity.class)
|
|
|
+ .putExtra(Constants.Intents.TITLE, "客户拜访详情")
|
|
|
+ .putExtra(Constants.Intents.MY_DOIT, true)
|
|
|
+ .putExtra(Constants.Intents.STATUS, "已提交")
|
|
|
+ .putExtra(Constants.Intents.ID, keyValue)
|
|
|
+ .putExtra(Constants.Intents.CALLER, "MobileOutPlans"));
|
|
|
+ finish();
|
|
|
+ overridePendingTransition(com.modular.apputils.R.anim.anim_activity_in, com.modular.apputils.R.anim.anim_activity_out);
|
|
|
+ }
|
|
|
+ }, 2000);
|
|
|
}
|
|
|
|
|
|
|
|
|
private void saveAddress() {
|
|
|
+ if (1 == 1) return;
|
|
|
if (mUUHttpHelper == null) {
|
|
|
mUUHttpHelper = new UUHttpHelper(CommonUtil.getAppBaseUrl(ct));
|
|
|
}
|
|
|
@@ -216,11 +272,11 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
|
|
|
public void run() {
|
|
|
if (mContext == null) return;
|
|
|
startActivity(new Intent(ct, CustomerVisitDetailsActivity.class)
|
|
|
- .putExtra(Constants.Intents.TITLE, "客户拜访详情")
|
|
|
- .putExtra(Constants.Intents.MY_DOIT, true)
|
|
|
- .putExtra(Constants.Intents.STATUS, "已提交")
|
|
|
- .putExtra(Constants.Intents.ID,keyValue)
|
|
|
- .putExtra(Constants.Intents.CALLER, "MobileOutPlans"));
|
|
|
+ .putExtra(Constants.Intents.TITLE, "客户拜访详情")
|
|
|
+ .putExtra(Constants.Intents.MY_DOIT, true)
|
|
|
+ .putExtra(Constants.Intents.STATUS, "已提交")
|
|
|
+ .putExtra(Constants.Intents.ID, keyValue)
|
|
|
+ .putExtra(Constants.Intents.CALLER, "MobileOutPlans"));
|
|
|
finish();
|
|
|
overridePendingTransition(com.modular.apputils.R.anim.anim_activity_in, com.modular.apputils.R.anim.anim_activity_out);
|
|
|
}
|
|
|
@@ -230,6 +286,20 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void loadLatLng(String address) {
|
|
|
+ if (StringUtil.isEmpty(address))return;
|
|
|
+ if (mUUHttpHelper == null) {
|
|
|
+ mUUHttpHelper = new UUHttpHelper(CommonUtil.getAppBaseUrl(ct));
|
|
|
+ }
|
|
|
+ mUUHttpHelper.requestCompanyHttp(new Parameter.Builder()
|
|
|
+ .url("mobile/crm/getLngAndLat.action")
|
|
|
+ .addParams("address", address.trim())
|
|
|
+ .record(11)
|
|
|
+ .mode(Method.GET)
|
|
|
+ , mOnSmartHttpListener
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
//保存外勤计划目的地
|
|
|
private void saveOutAddress(Map<String, Object> tagMap) {
|
|
|
String company = (String) tagMap.get("company");
|
|
|
@@ -253,7 +323,7 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
|
|
|
mUUHttpHelper.requestCompanyHttp(new Parameter.Builder()
|
|
|
.url("mobile/addOutAddress.action")
|
|
|
.addParams("caller", "lp")
|
|
|
- .mode(Method.POST)
|
|
|
+ .mode(Method.POST).record(13)
|
|
|
.addParams("formStore", JSONUtil.map2JSON(formStore))
|
|
|
, mOnSmartHttpListener
|
|
|
);
|
|
|
@@ -262,12 +332,28 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
|
|
|
private OnSmartHttpListener mOnSmartHttpListener = new OnSmartHttpListener() {
|
|
|
@Override
|
|
|
public void onSuccess(int what, String message, Tags tag) throws Exception {
|
|
|
- saveAddress();
|
|
|
+ switch (what) {
|
|
|
+ case 11:
|
|
|
+ LogUtil.i("gong", "message=" + message);
|
|
|
+ JSONObject object = JSON.parseObject(message);
|
|
|
+ float lat = JSONUtil.getFloat(object, "lat");
|
|
|
+ float lng = JSONUtil.getFloat(object, "lng");
|
|
|
+ if (lat != 0 || lat != 0) {
|
|
|
+ LatLng latLng = new LatLng(lat, lng);
|
|
|
+ address.setLatLng(latLng);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 13:
|
|
|
+ saveAddress();
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onFailure(int what, String message, Tags tag) throws Exception {
|
|
|
- saveAddress();
|
|
|
+ if (what == 13) {
|
|
|
+ saveAddress();
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|