|
|
@@ -28,16 +28,24 @@ import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONException;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.andreabaccega.widget.FormEditText;
|
|
|
+import com.lidroid.xutils.HttpUtils;
|
|
|
import com.lidroid.xutils.ViewUtils;
|
|
|
+import com.lidroid.xutils.exception.HttpException;
|
|
|
+import com.lidroid.xutils.http.RequestParams;
|
|
|
+import com.lidroid.xutils.http.ResponseInfo;
|
|
|
+import com.lidroid.xutils.http.callback.RequestCallBack;
|
|
|
+import com.lidroid.xutils.http.client.HttpRequest;
|
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
|
import com.xzjmyk.pm.activity.AppConstant;
|
|
|
+import com.xzjmyk.pm.activity.MyApplication;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.bean.oa.CostBean;
|
|
|
import com.xzjmyk.pm.activity.bean.oa.CostSingleBean;
|
|
|
@@ -65,6 +73,9 @@ import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
import com.xzjmyk.pm.activity.view.MyGridView;
|
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
import com.xzjmyk.pm.activity.view.SquareCenterImageView;
|
|
|
+import com.xzjmyk.pm.activity.wxapi.ApiConfig;
|
|
|
+import com.xzjmyk.pm.activity.wxapi.ApiPlatform;
|
|
|
+import com.xzjmyk.pm.activity.wxapi.ApiUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -72,6 +83,8 @@ import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.CUPCAKE)
|
|
|
/**
|
|
|
@@ -104,7 +117,6 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
private static final int SELECT_CURRENCY = 4;
|
|
|
private PopupWindow setWindow = null;//
|
|
|
private PopupWindow setCalculatorWindow = null;
|
|
|
- private Boolean initDetailDatas_initialization = false;
|
|
|
private Button btn_sure;
|
|
|
private int VERSION_CODES;
|
|
|
@ViewInject(R.id.table_details_list)
|
|
|
@@ -113,7 +125,6 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
private TextView add_details_tv;
|
|
|
private DetailsTableAdapter dtAdapter;
|
|
|
private GridDataAdapter gAdapter;
|
|
|
-// private List<String> detailsData; // popwindow要展示的消费明细类型
|
|
|
private List<String> selected_detailsData; //点击后要返回的消费明细类型
|
|
|
private double sum_money = 0.0; // 最后算的的总金额
|
|
|
private List<CostFormModel> costFormModel_list;
|
|
|
@@ -129,6 +140,10 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
private CostBean mCostBean;
|
|
|
private List<CostBean.DataBean.FormdetailBean> mFormconfigsBean;
|
|
|
private List<CostBean.DataBean.GridetailBean> mGridconfigsBean;
|
|
|
+
|
|
|
+ private CostBean m2CostBean;
|
|
|
+ private List<CostBean.DataBean.FormdetailBean> m2FormconfigsBean;
|
|
|
+ private List<CostBean.DataBean.GridetailBean> m2GridconfigsBean;
|
|
|
private AddCostBean mAddCostBean;
|
|
|
private List<AddCostBean> mAddCost_list; // popwindow要展示的消费明细类型
|
|
|
|
|
|
@@ -138,6 +153,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
private CostSingleBean money_combdatas;
|
|
|
private String deparmentname;
|
|
|
private int keyValue;
|
|
|
+ private int formid; //重新提交带过来的id
|
|
|
|
|
|
private Handler erhandler = new Handler(){
|
|
|
@Override
|
|
|
@@ -172,24 +188,41 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
|
|
|
case 0x05:
|
|
|
if (!StringUtils.isEmpty(result)){
|
|
|
- /*
|
|
|
- {
|
|
|
- "fp_id": 38366,
|
|
|
- "success": true,
|
|
|
- "fpd_id": [
|
|
|
- [
|
|
|
- 28859,
|
|
|
- 1
|
|
|
- ]
|
|
|
- ]
|
|
|
- }
|
|
|
-
|
|
|
- * */
|
|
|
+ //{"fp_id": 38366,"success": true,"fpd_id": [[28859,1]]}
|
|
|
keyValue = JSON.parseObject(result).getIntValue("fp_id");
|
|
|
- commitSuccess(keyValue);
|
|
|
+ sendPicture();
|
|
|
+ //TODO 测试接口返回数据
|
|
|
+ getUpdateData(keyValue);
|
|
|
}
|
|
|
LogUtil.prinlnLongMsg("0x05result",result);
|
|
|
break;
|
|
|
+
|
|
|
+ case 0x06:
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ handleUpdateData(result);
|
|
|
+ }
|
|
|
+ LogUtil.prinlnLongMsg("0x06result",result);
|
|
|
+ break;
|
|
|
+ case 0x07:
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ Log.i("0x07result", result);
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Toast.makeText(ct,getString(R.string.fangkui_success),Toast.LENGTH_LONG).show();
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ commitSuccess(keyValue);
|
|
|
+ }
|
|
|
+ },1000);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 0x08:
|
|
|
+ if (!StringUtils.isEmpty(result)) {
|
|
|
+ JSONObject resultJsonObject = JSON.parseObject(result);
|
|
|
+ cb_id = resultJsonObject.getInteger("id");
|
|
|
+ Log.i("0x08result", result + "");
|
|
|
+ }
|
|
|
+ break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
btn_save.setEnabled(true);
|
|
|
if (new JsonValidator().validate(result)) {
|
|
|
@@ -203,6 +236,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
};
|
|
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -249,7 +283,36 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
|
|
|
mAddCostBean = new AddCostBean();
|
|
|
mAddCost_list = new ArrayList<>();
|
|
|
+
|
|
|
+ Intent intent = getIntent();
|
|
|
+ formid = 0;
|
|
|
+ formid = intent.getIntExtra("id", 0);
|
|
|
+ if (formid != 0){
|
|
|
+ getUpdateData(formid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新提交操作根据id,获取单据内容
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ private void getUpdateData(int id) {
|
|
|
+// progressDialog.show();
|
|
|
+ if (!CommonUtil.isNetWorkConnected(mContext)) {
|
|
|
+ ToastMessage("网络未连接!");
|
|
|
+ }
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "mobile/getformandgriddetail.action";
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("caller", caller);
|
|
|
+ params.put("condition", "1=1");
|
|
|
+ params.put("id", id);
|
|
|
+ params.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, erhandler, headers, 0x06, null, null, "get");
|
|
|
}
|
|
|
+
|
|
|
private void commitSuccess(final int id) {
|
|
|
ToastMessage("提交成功!");
|
|
|
erhandler.postDelayed(new Runnable() {
|
|
|
@@ -301,6 +364,71 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 更新时录入界面数据的处理初始化
|
|
|
+ * @param result
|
|
|
+ */
|
|
|
+ private void handleUpdateData(String result) {
|
|
|
+ m2CostBean = new CostBean();
|
|
|
+ m2GridconfigsBean = new ArrayList<>();
|
|
|
+ m2FormconfigsBean = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ JSONObject amresultJsonObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObjecty = amresultJsonObject.getJSONObject("data");
|
|
|
+ JSONArray formdataArray = dataObjecty.getJSONArray("formdetail");
|
|
|
+ JSONArray griddataArray = dataObjecty.getJSONArray("gridetail");
|
|
|
+
|
|
|
+ if (formdataArray == null || griddataArray == null) {
|
|
|
+ // TODO
|
|
|
+ } else {
|
|
|
+ m2CostBean = JSON.parseObject(amresultJsonObject.toString(), CostBean.class);
|
|
|
+ if (m2CostBean.getData().getFormdetail() != null && m2CostBean.getData().getGridetail() != null) {
|
|
|
+ int allFormconfigs_num = m2CostBean.getData().getFormdetail().size();
|
|
|
+ for (int i = 0; i < allFormconfigs_num; i++) {
|
|
|
+ String fd_caption = m2CostBean.getData().getFormdetail().get(i).getFd_caption();
|
|
|
+ String fd_field = m2CostBean.getData().getFormdetail().get(i).getFd_field();
|
|
|
+ int mfd_isdefault = m2CostBean.getData().getFormdetail().get(i).getMfd_isdefault();
|
|
|
+ if (mfd_isdefault == -1 && fd_caption != null && fd_field != null) {
|
|
|
+ m2FormconfigsBean.add(m2CostBean.getData().getFormdetail().get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ LogUtil.prinlnLongMsg("m2FormconfigsBean", JSON.toJSONString(m2FormconfigsBean));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取需要显示的从表单配置数据属性保存到mGridconfigsBean中
|
|
|
+ if (m2CostBean.getData().getGridetail() != null && m2CostBean.getData().getGridetail() != null) {
|
|
|
+ int allGridconfigs_num = m2CostBean.getData().getGridetail().size();
|
|
|
+ for (int i = 0; i < allGridconfigs_num; i++) {
|
|
|
+ String dg_caption = m2CostBean.getData().getGridetail().get(i).getDg_caption();
|
|
|
+ String dg_field = m2CostBean.getData().getGridetail().get(i).getDg_field();
|
|
|
+ int mdg_isdefault = m2CostBean.getData().getGridetail().get(i).getMdg_isdefault();
|
|
|
+ if (mdg_isdefault == -1 && dg_caption != null && dg_field != null) {
|
|
|
+ m2GridconfigsBean.add(m2CostBean.getData().getGridetail().get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LogUtil.prinlnLongMsg("m2GridconfigsBean", JSON.toJSONString(m2GridconfigsBean));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ showUpdateData(m2FormconfigsBean,m2GridconfigsBean);
|
|
|
+ }
|
|
|
+ },1000);
|
|
|
+ }catch (JSONException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showUpdateData(List<CostBean.DataBean.FormdetailBean> m2Form_update, List<CostBean.DataBean.GridetailBean> m2Grid_update) {
|
|
|
+ LogUtil.prinlnLongMsg("m2Form_update", JSON.toJSONString(m2Form_update));
|
|
|
+ LogUtil.prinlnLongMsg("m2Grid_update", JSON.toJSONString(m2Grid_update));
|
|
|
+ }
|
|
|
+
|
|
|
private void handleTypeAndM(String result) {
|
|
|
try {
|
|
|
JSONObject amresultJsonObject = JSON.parseObject(result);
|
|
|
@@ -1125,4 +1253,103 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
}
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|
|
|
+// private String cb_emcode;
|
|
|
+ private void sendPicture() {
|
|
|
+ if (ListUtils.isEmpty(mPhotoList)) {
|
|
|
+ commitSuccess(keyValue);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CommonUtil.getCommonId("http://218.18.115.198:8888/ERP/",ct, "Commentsback_mobile_SEQ", erhandler, 0x08);
|
|
|
+// cb_emcode = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_username");
|
|
|
+ for (int i = 0; i < mPhotoList.size(); i++) {
|
|
|
+ String path = mPhotoList.get(i);
|
|
|
+ sendPictureRequest(path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private Boolean platform = ApiUtils.getApiModel() instanceof ApiPlatform;
|
|
|
+ private int sended_p = 0;
|
|
|
+ private String update = "";
|
|
|
+ private int cb_id;
|
|
|
+
|
|
|
+ private void sendPictureRequest(String path) {
|
|
|
+ if (com.xzjmyk.pm.activity.ui.erp.util.StringUtils.isEmpty(path)) return;
|
|
|
+ File waterBitmapToFile= new File(path);
|
|
|
+ if (!waterBitmapToFile.isFile())return;
|
|
|
+ RequestParams params = new RequestParams();
|
|
|
+ if (platform){
|
|
|
+ params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "companyEnUu"));
|
|
|
+ params.addHeader("Cookie", "JSESSIONID=" + ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().getCookie());
|
|
|
+ params.addBodyParameter("em_code", CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "b2b_uu"));
|
|
|
+
|
|
|
+ }else {
|
|
|
+ params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(ct, "erp_master"));
|
|
|
+ params.addHeader("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ params.addBodyParameter("em_code", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
+ }
|
|
|
+ params.addBodyParameter("type", "common");
|
|
|
+ params.addBodyParameter("img", waterBitmapToFile);
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "mobile/uploadEmployeeAttach.action";
|
|
|
+ final HttpUtils http = new HttpUtils();
|
|
|
+ http.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
|
|
|
+ @Override
|
|
|
+ public void onStart() {
|
|
|
+ progressDialog.show();
|
|
|
+ ViewUtil.ToastMessage(ct, "正在上传图片...");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLoading(long total, long current, boolean isUploading) {
|
|
|
+ if (isUploading) {
|
|
|
+ } else {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSuccess(ResponseInfo<String> responseInfo) {
|
|
|
+ ViewUtil.ToastMessage(ct, getString(R.string.Uploaded_successfully));
|
|
|
+ JsonValidator validator = new JsonValidator();
|
|
|
+ if (validator.validate(responseInfo.result) && JSON.parseObject(responseInfo.result).getBoolean("success")) {
|
|
|
+ sended_p ++;
|
|
|
+ update = update + getID(JSON.parseObject(responseInfo.result).getString("id"))+";";
|
|
|
+ Log.i("update_cb_attch",update+"");
|
|
|
+ if (sended_p == mPhotoList.size()){
|
|
|
+ //TODO 更新附件ID接口
|
|
|
+ doUpdateId(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpException error, String msg) {
|
|
|
+ ViewUtil.ToastMessage(ct, getString(R.string.common_save_failed) + msg);
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ private void doUpdateId(String update) {
|
|
|
+ String url = "http://218.18.115.198:8888/ERP/common/attach/change.action";
|
|
|
+ Map<String,Object> params = new HashMap<>();
|
|
|
+ params.put("caller","Commentsback_mobile");
|
|
|
+ params.put("table","Commentsback_mobile");
|
|
|
+ params.put("update","fb_attach = '"+update+"'"); // TODO 附件字段fb_attach
|
|
|
+ params.put("condition","cb_id = '"+cb_id+"'");
|
|
|
+ params.put("type","添加附件");
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ if (platform){
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().getCookie());
|
|
|
+ }else {
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ }
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, erhandler, headers, 0x07, null, null, "post");
|
|
|
+ }
|
|
|
+ private int getID(String chche) {
|
|
|
+ if (com.xzjmyk.pm.activity.ui.erp.util.StringUtils.isEmpty(chche)) return 0;
|
|
|
+ Pattern p = Pattern.compile("(\\d+)");
|
|
|
+ Matcher m = p.matcher(chche);
|
|
|
+ if (m.find()) {
|
|
|
+ return Integer.parseInt(m.group(0));
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
}
|