|
|
@@ -12,6 +12,7 @@ import android.text.Editable;
|
|
|
import android.text.TextWatcher;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ArrayAdapter;
|
|
|
@@ -94,6 +95,10 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
private ClearableEditText ce_moju;
|
|
|
private TextView tv_mju;
|
|
|
private LinearLayout line_mju;
|
|
|
+ private boolean chentrueorflase;
|
|
|
+ private TextView text_moju;
|
|
|
+ private LinearLayout line_moju;
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_gd_work_switch;
|
|
|
@@ -124,7 +129,8 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
mOlNextEt = root.findViewById(R.id.ol_next_et);
|
|
|
ce_moju = root.findViewById(R.id.ce_moju);
|
|
|
tv_mju = root.findViewById(R.id.tv_mju);
|
|
|
-
|
|
|
+ text_moju = root.findViewById(R.id.text_moju);
|
|
|
+ line_moju = root.findViewById(R.id.line_moju);
|
|
|
root.findViewById(R.id.scan_code_im).setOnClickListener(this);
|
|
|
root.findViewById(R.id.ol_next_im).setOnClickListener(this);
|
|
|
tv_gangwei=root.findViewById(R.id.tv_gangwei);
|
|
|
@@ -188,14 +194,62 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //----------模具模糊搜索------------------------
|
|
|
+ ce_moju.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_DONE
|
|
|
+ || actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ String data = ce_moju.getText().toString().trim();
|
|
|
+ fuzzySearchMould(data);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ ce_moju.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) { }
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ if (s.length() >= 3) {
|
|
|
+ String mSearchStr = s.toString().trim();
|
|
|
+ LogUtil.i("mSearchStr",mSearchStr);
|
|
|
+ fuzzySearchMould(mSearchStr);
|
|
|
+ } else {
|
|
|
+ fuzzyBeans.clear();
|
|
|
+ setfuzzyAdapter(fuzzyBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
fuzzyAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
FuzzyBean bean = fuzzyAdapter.getBeanByPositon(position);
|
|
|
String macode = bean.getMA_CODE();
|
|
|
- if (macode.length() > 0){
|
|
|
- getLastBean(macode);
|
|
|
- mSearch.setText("");
|
|
|
+ if (chentrueorflase){
|
|
|
+ if (macode.length() > 0){
|
|
|
+ line_moju.setVisibility(View.VISIBLE);
|
|
|
+ text_moju.setText(macode);
|
|
|
+ mSearch.requestFocus();
|
|
|
+ mSearch.setSelection(mSearch.getText().length());
|
|
|
+ ce_moju.setText("");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (macode.length() > 0){
|
|
|
+ getLastBean(macode);
|
|
|
+ mSearch.setText("");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -327,6 +381,7 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
@Override
|
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
|
// progressDialog.dismiss();
|
|
|
+ chentrueorflase = false;
|
|
|
Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
if (isSuccess){
|
|
|
JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(),"data");
|
|
|
@@ -365,6 +420,58 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ //查询模具
|
|
|
+ private void fuzzySearchMould(String code){
|
|
|
+ VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_FUZZYSEARCHMOULD)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "fuzzySearchMa")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("mouldcode", code)
|
|
|
+ .addParam("sc_code", sc_code)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ chentrueorflase = true;
|
|
|
+ Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
+ if (isSuccess){
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(),"data");
|
|
|
+ if (dataArray == null || dataArray.size() == 0){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity,"未搜索到匹配数据");
|
|
|
+ setfuzzyAdapter(fuzzyBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ FuzzyBean bean = null;
|
|
|
+ if (fuzzyBeans.size() > 0) fuzzyBeans.clear();
|
|
|
+ for (Object index : dataArray){
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+ bean = new FuzzyBean(data.getString("DE_CODE"),data.getString("DE_NAME"));
|
|
|
+ fuzzyBeans.add(bean);
|
|
|
+ }
|
|
|
+ setfuzzyAdapter(fuzzyBeans);
|
|
|
+ startLlS.setVisibility(View.GONE);
|
|
|
+ fuzzyRv.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
+ }else {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void upDateUnitNumber() {
|
|
|
if (StringUtil.isEmpty(unitSelctStr)) {
|
|
|
unitSelctStr = "PCS";
|
|
|
@@ -388,7 +495,7 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
private void doExChangeClick() {
|
|
|
if (!StringUtil.isEmpty(ifneedmj)){
|
|
|
if(!ifneedmj.equals("0")){
|
|
|
- if (ce_moju.getText().toString().trim().isEmpty()){
|
|
|
+ if (text_moju.getText().toString().trim().isEmpty()){
|
|
|
CommonUtil.toastNoRepeat(mActivity, "请输入模具编号");
|
|
|
return;
|
|
|
}
|
|
|
@@ -405,6 +512,7 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
.addParam("ma_code", mOlIdTv.getText().toString())
|
|
|
.addParam("sc_code", sc_code)
|
|
|
.addParam("next_macode", gongdanhaoTv.getText().toString())
|
|
|
+ .addParam("mouldcode",text_moju.getText().toString().trim())
|
|
|
.build(), new HttpCallback() {
|
|
|
@Override
|
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
|
@@ -433,6 +541,7 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
if (!StringUtil.isEmpty(ifneedmj)){
|
|
|
if (!ifneedmj.equals("0")){
|
|
|
line_mju.setVisibility(View.VISIBLE);
|
|
|
+ text_moju.setVisibility(View.VISIBLE);
|
|
|
tv_mju.setTextColor(getResources().getColor(R.color.red));
|
|
|
ce_moju.requestFocus();
|
|
|
}else {
|
|
|
@@ -615,7 +724,11 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
}
|
|
|
@Override
|
|
|
protected void convert(BaseViewHolder helper,FuzzyBean item) {
|
|
|
- helper.setText(R.id.macode_Tv,item.getMA_CODE());
|
|
|
+ if (StringUtil.isEmpty(item.getDE_NAME())){
|
|
|
+ helper.setText(R.id.macode_Tv,item.getMA_CODE());
|
|
|
+ }else {
|
|
|
+ helper.setText(R.id.macode_Tv,item.getMA_CODE()+"-"+item.getDE_NAME());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -624,11 +737,18 @@ public class GdWorkSwitchFragment extends BaseFragment implements View.OnClickLi
|
|
|
|
|
|
private class FuzzyBean{
|
|
|
String MA_CODE = null;
|
|
|
-
|
|
|
+ String DE_NAME = null;
|
|
|
public FuzzyBean(String MA_CODE) {
|
|
|
this.MA_CODE = MA_CODE;
|
|
|
}
|
|
|
+ public FuzzyBean(String MA_CODE, String DE_NAME) {
|
|
|
+ this.MA_CODE = MA_CODE;
|
|
|
+ this.DE_NAME = DE_NAME;
|
|
|
+ }
|
|
|
|
|
|
+ public String getDE_NAME() {
|
|
|
+ return DE_NAME;
|
|
|
+ }
|
|
|
public String getMA_CODE() {
|
|
|
return MA_CODE;
|
|
|
}
|