|
|
@@ -21,6 +21,7 @@ import android.widget.TextView;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
import com.common.LogUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
@@ -28,10 +29,12 @@ import com.common.data.StringUtil;
|
|
|
import com.common.system.DisplayUtil;
|
|
|
import com.core.app.MyApplication;
|
|
|
import com.core.base.BaseActivity;
|
|
|
+import com.core.model.Approval;
|
|
|
import com.core.model.SelectBean;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.ToastUtil;
|
|
|
import com.core.widget.VoiceSearchView;
|
|
|
+import com.core.widget.listener.EditChangeListener;
|
|
|
import com.core.widget.view.Activity.SelectActivity;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
@@ -39,6 +42,7 @@ import com.me.network.app.http.HttpClient;
|
|
|
import com.me.network.app.http.Method;
|
|
|
import com.me.network.app.http.rx.ResultListener;
|
|
|
import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
+import com.modular.apputils.activity.SelectNetAcitivty;
|
|
|
import com.uas.appworks.CRM.erp.adapter.CycleCountAdapter;
|
|
|
import com.uas.appworks.CRM.erp.model.CycleCount;
|
|
|
import com.uas.appworks.CRM.erp.model.CycleCountAdd;
|
|
|
@@ -124,7 +128,7 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
@Override
|
|
|
public void onResponse(Object o) {
|
|
|
try {
|
|
|
- handlePopData(TestStr.CYCLE_COUNT_ADD);
|
|
|
+ handlePopData(o.toString());
|
|
|
} catch (Exception e) {
|
|
|
if (e != null) {
|
|
|
LogUtil.i("e=" + e.getMessage());
|
|
|
@@ -134,9 +138,9 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
+ private boolean isSubmitl;
|
|
|
private void addCycle(List<CycleCountAdd> models) {
|
|
|
Map<String, Object> formStore = new HashMap<>();
|
|
|
-
|
|
|
for (CycleCountAdd e : models) {
|
|
|
if (!StringUtil.isEmpty(e.getValues())) {
|
|
|
formStore.put(e.getField(), e.getValues());
|
|
|
@@ -145,6 +149,9 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ if (isSubmitl)return;
|
|
|
+ isSubmitl=true;
|
|
|
+ progressDialog.show();
|
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
|
.url("mobile/device/saveAndSubmitDeviceStock.action")
|
|
|
.add("caller", "DeviceBatch!Stock")
|
|
|
@@ -154,11 +161,17 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
@Override
|
|
|
public void onResponse(Object o) {
|
|
|
try {
|
|
|
+ if (progressDialog!=null){
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
boolean success = JSONUtil.getBoolean(o.toString(), "success");
|
|
|
if (success) {
|
|
|
+ setResult(0x12);
|
|
|
ToastUtil.showToast(ct, "添加成功");
|
|
|
finish();
|
|
|
}
|
|
|
+ isSubmitl=false;
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
if (e != null) {
|
|
|
LogUtil.i("e=" + e.getMessage());
|
|
|
@@ -170,7 +183,8 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
|
|
|
private void handlePopData(String message) throws Exception {
|
|
|
cycleCountAdds = new ArrayList<>();
|
|
|
- JSONArray items = JSONUtil.getJSONArray(message, "items");
|
|
|
+ JSONObject data = JSONUtil.getJSONObject(message, "data");
|
|
|
+ JSONArray items = JSONUtil.getJSONArray(data, "formdetail");
|
|
|
for (int i = 0; i < items.size(); i++) {
|
|
|
cycleCountAdds.add(new CycleCountAdd(items.getJSONObject(i)));
|
|
|
}
|
|
|
@@ -187,12 +201,25 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
return models;
|
|
|
}
|
|
|
|
|
|
- public void updateValues(String field, String values) {
|
|
|
- for (int i = 0; i < models.size(); i++) {
|
|
|
- if (models.get(i).getField().equals(field)) {
|
|
|
- models.get(i).setValues(values);
|
|
|
- notifyItemChanged(i);
|
|
|
- break;
|
|
|
+ public void updateValues(int selectPosition, String values) {
|
|
|
+ if (ListUtils.getSize(models) > selectPosition) {
|
|
|
+ models.get(selectPosition).setValues(values);
|
|
|
+ notifyItemChanged(selectPosition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateValues(String message) {
|
|
|
+ if (!StringUtil.isEmpty(message) && JSONUtil.validateJSONObject(message)) {
|
|
|
+ JSONObject object = JSON.parseObject(message);
|
|
|
+ if (models != null) {
|
|
|
+ for (CycleCountAdd e : models) {
|
|
|
+ for (Map.Entry<String, Object> map : object.entrySet()) {
|
|
|
+ if (map.getKey().equals(e.getField()) && map.getValue() != null) {
|
|
|
+ e.setValues(map.getValue().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ notifyDataSetChanged();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -202,6 +229,26 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
drawable = getResources().getDrawable(R.drawable.ic_menu_retract);
|
|
|
}
|
|
|
|
|
|
+ private class TextChangListener extends EditChangeListener {
|
|
|
+ ViewHodler hodler;
|
|
|
+ private int position;
|
|
|
+
|
|
|
+ public TextChangListener(ViewHodler hodler, int position) {
|
|
|
+ this.hodler = hodler;
|
|
|
+ this.position = position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ if (this.position >= 0) {
|
|
|
+ if (this.hodler.valuesEd != null) {
|
|
|
+ String valueEt = this.hodler.valuesEd.getText().toString();
|
|
|
+ models.get(this.position).setValues(valueEt == null ? "" : valueEt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
|
return new ViewHodler(parent);
|
|
|
@@ -212,7 +259,7 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
CycleCountAdd model = models.get(position);
|
|
|
holder.captionTv.setText(model.getCaption());
|
|
|
holder.valuesEd.setText(model.getValues());
|
|
|
- if (model.getType().equals("DBFIND")) {
|
|
|
+ if (model.getType().equals("DBFIND") || model.getType().equals("C")) {
|
|
|
holder.valuesEd.setFocusableInTouchMode(false);
|
|
|
holder.valuesEd.setTag(R.id.tag_key, position);
|
|
|
holder.valuesEd.setTag(model);
|
|
|
@@ -222,6 +269,7 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
holder.valuesEd.setFocusableInTouchMode(true);
|
|
|
holder.valuesEd.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
|
|
}
|
|
|
+ holder.valuesEd.addTextChangedListener(new TextChangListener(holder, position));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -259,22 +307,37 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
try {
|
|
|
if (view.getId() == R.id.valuesEd) {
|
|
|
CycleCountAdd model = (CycleCountAdd) view.getTag();
|
|
|
- int position = (int) view.getTag(R.id.tag_key);
|
|
|
- HashMap param = new HashMap<>();
|
|
|
- param.put("which", model.getWhich());
|
|
|
- param.put("caller", "DeviceBatch!Stock");
|
|
|
- param.put("field", model.getField());
|
|
|
- param.put("pageSize", 1000);
|
|
|
- Bundle bundle = new Bundle();
|
|
|
- bundle.putSerializable("param", param);
|
|
|
+ selectPosition = (int) view.getTag(R.id.tag_key);
|
|
|
Intent intent = new Intent(ct, SelectActivity.class);
|
|
|
- intent.putExtra("type", 1);
|
|
|
- intent.putExtras(bundle);
|
|
|
- intent.putExtra("key", "datas");
|
|
|
- intent.putExtra("showKey", model.getField());
|
|
|
- intent.putExtra("action", "mobile/common/getDbfind.action");
|
|
|
intent.putExtra("title", model.getCaption());
|
|
|
- startActivityForResult(intent, 0x21);
|
|
|
+ if (model.getType().equals("C")) {
|
|
|
+ ArrayList<SelectBean> formBeaans = new ArrayList<>();
|
|
|
+ for (Approval.Data e : model.getDatas()) {
|
|
|
+ formBeaans.add(new SelectBean(e.display));
|
|
|
+ }
|
|
|
+ intent.putExtra("type", 2);
|
|
|
+ intent.putParcelableArrayListExtra("data", formBeaans);
|
|
|
+ startActivityForResult(intent, 0x21);
|
|
|
+ } else {
|
|
|
+ startActivityForResult(new Intent(ct, SelectNetAcitivty.class)
|
|
|
+ .putExtra("fieldKey", model.getField())
|
|
|
+ .putExtra("caller", "DeviceBatch!Stock")
|
|
|
+ .putExtra("isForm", true)
|
|
|
+ , 90);
|
|
|
+// HashMap param = new HashMap<>();
|
|
|
+// param.put("which", model.getWhich());
|
|
|
+// param.put("caller", "DeviceBatch!Stock");
|
|
|
+// param.put("field", model.getField());
|
|
|
+// param.put("pageSize", 1000);
|
|
|
+// Bundle bundle = new Bundle();
|
|
|
+// bundle.putSerializable("param", param);
|
|
|
+// intent.putExtra("type", 1);
|
|
|
+// intent.putExtras(bundle);
|
|
|
+// intent.putExtra("key", "datas");
|
|
|
+// intent.putExtra("showKey", model.getField());
|
|
|
+// intent.putExtra("action", "mobile/common/getDbfind.action");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
@@ -283,15 +346,23 @@ public class DeviceCycleCountAddActivity extends BaseActivity implements View.On
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ private int selectPosition;
|
|
|
|
|
|
@Override
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ LogUtil.i("selectPosition=" + selectPosition);
|
|
|
if (0x21 == requestCode && data != null) {
|
|
|
SelectBean b = data.getParcelableExtra("data");
|
|
|
LogUtil.d(JSON.toJSONString(b));
|
|
|
- if (b == null || StringUtil.isEmpty(b.getJson()) || popAdapter == null) return;
|
|
|
- popAdapter.updateValues(b.getFields(), b.getName());
|
|
|
+ if (b == null || popAdapter == null) return;
|
|
|
+ popAdapter.updateValues(selectPosition, b.getName());
|
|
|
+ } else if (90 == requestCode) {
|
|
|
+ String json = data.getStringExtra("data");
|
|
|
+ LogUtil.i("json=" + json);
|
|
|
+ if (popAdapter == null) return;
|
|
|
+ popAdapter.updateValues(json);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|