|
|
@@ -1,15 +1,77 @@
|
|
|
package com.uas.uas_mes_zb_p.fragment;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.support.v4.content.ContextCompat;
|
|
|
+import android.support.v7.widget.DefaultItemAnimator;
|
|
|
+import android.support.v7.widget.DividerItemDecoration;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.util.Log;
|
|
|
+import android.util.SparseBooleanArray;
|
|
|
import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.view.WindowManager;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.bin.david.form.core.SmartTable;
|
|
|
+import com.bin.david.form.core.TableConfig;
|
|
|
+import com.bin.david.form.data.CellInfo;
|
|
|
+import com.bin.david.form.data.column.Column;
|
|
|
+import com.bin.david.form.data.format.bg.BaseCellBackgroundFormat;
|
|
|
+import com.bin.david.form.data.style.FontStyle;
|
|
|
+import com.bin.david.form.data.table.TableData;
|
|
|
+import com.bin.david.form.listener.OnColumnItemClickListener;
|
|
|
import com.uas.uas_mes_zb_p.R;
|
|
|
import com.uas.uas_mes_zb_p.activity.FunctionActivity;
|
|
|
+import com.uas.uas_mes_zb_p.bean.AddAndDeleteCodeBean;
|
|
|
+import com.uas.uas_mes_zb_p.global.GloableParams;
|
|
|
+import com.uas.uas_mes_zb_p.util.CameraUtil;
|
|
|
+import com.uas.uas_mes_zb_p.util.CommonUtil;
|
|
|
+import com.uas.uas_mes_zb_p.util.FastjsonUtil;
|
|
|
+import com.uas.uas_mes_zb_p.util.FragmentUtils;
|
|
|
+import com.uas.uas_mes_zb_p.util.HttpCallback;
|
|
|
+import com.uas.uas_mes_zb_p.util.HttpParams;
|
|
|
+import com.uas.uas_mes_zb_p.util.VolleyRequest;
|
|
|
+import com.uas.uas_mes_zb_p.view.ClearableEditText;
|
|
|
+import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
+import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
|
/**
|
|
|
* Created by cjh-sail on 2023-02-15
|
|
|
- * 拆分(有库存)
|
|
|
+ * 出库单列表物料变更
|
|
|
*/
|
|
|
-public class MaterialChangeFragment extends BaseFragment{
|
|
|
+public class MaterialChangeFragment extends BaseFragment implements OnColumnItemClickListener<String>{
|
|
|
+
|
|
|
+ private SmartTable mSmartTable;
|
|
|
+ private ClearableEditText storage_recharge_collect_ets;
|
|
|
+ private ImageView storage_recharge_scan_ivs;
|
|
|
+ private static final int SCAN_BARCODE_CODE = 222;
|
|
|
+ private int mFocusId;
|
|
|
+ private Column<String> va_codeColumn,deleteColumn;
|
|
|
+ private TableData<AddAndDeleteCodeBean> mTableData;
|
|
|
+ private Button btn_check_va_code;
|
|
|
+ private String va_code;
|
|
|
+ private ArrayList<AddAndDeleteCodeBean> arrayListlist;
|
|
|
+ private Fragment mFragment;
|
|
|
+ private RecyclerView ra_data;
|
|
|
+ private SelectAdapter selectAdapter;
|
|
|
+ private ArrayList<AddAndDeleteCodeBean> takeApartThePalletlist;
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_materialchage;
|
|
|
@@ -17,20 +79,212 @@ public class MaterialChangeFragment extends BaseFragment{
|
|
|
|
|
|
@Override
|
|
|
protected void initViews() {
|
|
|
- FunctionActivity.setTitle(getString(R.string.title_takeapartthepallet));
|
|
|
+ FunctionActivity.setTitle(getString(R.string.outboundlist));
|
|
|
((FunctionActivity) getActivity()).setListIconIvVisible(false);
|
|
|
+ mSmartTable = root.findViewById(R.id.mater_st);
|
|
|
+ storage_recharge_collect_ets = root.findViewById(R.id.storage_recharge_collect_ets);
|
|
|
+ storage_recharge_scan_ivs = root.findViewById(R.id.storage_recharge_scan_ivs);
|
|
|
+ btn_check_va_code = root.findViewById(R.id.btn_check_va_code);
|
|
|
+ ra_data = root.findViewById(R.id.ra_data);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void initEvents() {
|
|
|
+ storage_recharge_scan_ivs.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (CameraUtil.hasCamera()) {
|
|
|
+ if (root.findFocus() != null) {
|
|
|
+ mFocusId = root.findFocus().getId();
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(mActivity, CaptureActivity.class);
|
|
|
+ startActivityForResult(intent, SCAN_BARCODE_CODE);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请选择您要操作的输入框");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ arrayListlist = new ArrayList<>();
|
|
|
+ storage_recharge_collect_ets.requestFocus();
|
|
|
+ storage_recharge_collect_ets.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)) {
|
|
|
+ VerificationDatalistCodes(storage_recharge_collect_ets.getText().toString().trim());
|
|
|
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void initDatas() {
|
|
|
+ WindowManager wm = mActivity.getWindowManager();
|
|
|
+ int screenWith = wm.getDefaultDisplay().getWidth();
|
|
|
+ mSmartTable.getConfig().setMinTableWidth(screenWith)
|
|
|
+ .setShowXSequence(false)
|
|
|
+ .setShowYSequence(false)
|
|
|
+ .setShowTableTitle(false)
|
|
|
+ .setFixedTitle(true)
|
|
|
+ .setVerticalPadding(CommonUtil.dip2px(mActivity, 12))
|
|
|
+ .setColumnTitleVerticalPadding(CommonUtil.dip2px(mActivity, 12))
|
|
|
+ .setHorizontalPadding(CommonUtil.dip2px(mActivity, 10))
|
|
|
+ .setSequenceHorizontalPadding(CommonUtil.dip2px(mActivity, 10))
|
|
|
+ .setColumnTitleHorizontalPadding(CommonUtil.dip2px(mActivity, 10))
|
|
|
+ .setColumnTitleStyle(new FontStyle(CommonUtil.sp2px(mActivity, 15), Color.parseColor("#000000")))
|
|
|
+ .setContentCellBackgroundFormat(new BaseCellBackgroundFormat<CellInfo>() {
|
|
|
+ @Override
|
|
|
+ public int getBackGroundColor(CellInfo cellInfo) {
|
|
|
+ if (cellInfo.row % 2 == 0) {
|
|
|
+ return ContextCompat.getColor(mActivity, R.color.blue_50);
|
|
|
+ }
|
|
|
+ return TableConfig.INVALID_COLOR;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ va_codeColumn = new Column<String>("单号", "va_code");
|
|
|
+ deleteColumn = new Column<String>("操作", "va_delete");
|
|
|
+ deleteColumn.setFixed(true);
|
|
|
+ deleteColumn.setOnColumnItemClickListener(this);
|
|
|
+
|
|
|
+// deleteColumn.setOnColumnItemClickListener(new OnColumnItemClickListener<String>() {
|
|
|
+// @Override
|
|
|
+// public void onClick(Column<String> column, String value, String s, int position) {
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// });
|
|
|
+ takeApartThePalletlist = new ArrayList<>();
|
|
|
+
|
|
|
+ selectAdapter = new SelectAdapter(takeApartThePalletlist);
|
|
|
+ ra_data.addItemDecoration(new DividerItemDecoration(mActivity, LinearLayout.VERTICAL));
|
|
|
+ ra_data.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ //设置Item增加、移除动画
|
|
|
+ ra_data.setItemAnimator(new DefaultItemAnimator());
|
|
|
+ setAdapter(takeApartThePalletlist);
|
|
|
+ ra_data.setAdapter(selectAdapter);
|
|
|
+ btn_check_va_code.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getDatalistCodes();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ private void setAdapter(ArrayList<AddAndDeleteCodeBean> mList) {
|
|
|
+ selectAdapter = new SelectAdapter(mList);
|
|
|
+ ra_data.setAdapter(selectAdapter);
|
|
|
+
|
|
|
+ }
|
|
|
+ public void addDataCode(String va_code,String pi_id){
|
|
|
+ AddAndDeleteCodeBean addAndDeleteCodeBean=new AddAndDeleteCodeBean();
|
|
|
+ addAndDeleteCodeBean.setVa_code(va_code);
|
|
|
+ addAndDeleteCodeBean.setPi_id(pi_id);
|
|
|
+ addAndDeleteCodeBean.setVa_delete("×");
|
|
|
+ takeApartThePalletlist.add(addAndDeleteCodeBean);
|
|
|
+ setAdapter(takeApartThePalletlist);
|
|
|
+// setFilterTableData(mFilterStorageInBeans);
|
|
|
+ storage_recharge_collect_ets.setText("");
|
|
|
+ storage_recharge_collect_ets.setSelection(storage_recharge_collect_ets.getText().toString().length());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setFilterTableData(ArrayList<AddAndDeleteCodeBean> filterTableData) {
|
|
|
+ arrayListlist.clear();
|
|
|
+ arrayListlist.addAll(filterTableData);
|
|
|
+ try {
|
|
|
+ Log.i("size====",filterTableData.size()+"");
|
|
|
+ mTableData = new TableData<AddAndDeleteCodeBean>("出库单列表", arrayListlist,
|
|
|
+ va_codeColumn,deleteColumn);
|
|
|
+
|
|
|
+// new Handler().postDelayed(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// mSmartTable.postInvalidate();
|
|
|
+// }
|
|
|
+// }, 100);
|
|
|
+ mSmartTable.setTableData(mTableData);
|
|
|
+ new Thread(){
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ //需要在子线程中处理的逻辑
|
|
|
+// mSmartTable.postInvalidate();
|
|
|
+ mSmartTable.invalidate();
|
|
|
+ }
|
|
|
+ }.start();
|
|
|
+ }catch (IndexOutOfBoundsException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ Log.e("1Exception===",e.toString());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void getDatalistCodes(){
|
|
|
+ String sum ="";
|
|
|
+ if (takeApartThePalletlist.isEmpty()){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请采集条码");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i=0;i<takeApartThePalletlist.size();i++){
|
|
|
+ sum+=takeApartThePalletlist.get(i).getPi_id()+"|";
|
|
|
+ }
|
|
|
+ String substring = sum.substring(0, sum.length() - 1);//去除尾部
|
|
|
+
|
|
|
+ mFragment=new TakeApartThePalletFragment();
|
|
|
+ if (mFragment != null) {
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putString("pi_id", substring);
|
|
|
+ mFragment.setArguments(bundle);
|
|
|
+ FragmentUtils.switchFragment(MaterialChangeFragment.this, mFragment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void VerificationDatalistCodes(String pi_inoutno){
|
|
|
+ progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_ADDRESSTAIL_VERIFICATION)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .tag(TAG + "datalist")
|
|
|
+ .flag(0)
|
|
|
+ .addParam("pi_inoutno",pi_inoutno)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ String lotno = FastjsonUtil.getText(dataObject, "pi_id");
|
|
|
+ if (!lotno.isEmpty()){
|
|
|
+ addDataCode(pi_inoutno,lotno);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
return false;
|
|
|
@@ -46,9 +300,155 @@ public class MaterialChangeFragment extends BaseFragment{
|
|
|
if (hidden) {
|
|
|
((FunctionActivity) getActivity()).setListIconIvVisible(false);
|
|
|
} else {
|
|
|
- FunctionActivity.setTitle(getString(R.string.title_takeapartthepallet));
|
|
|
+ FunctionActivity.setTitle(getString(R.string.outboundlist));
|
|
|
((FunctionActivity) getActivity()).setListIconIvVisible(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (requestCode == SCAN_BARCODE_CODE && data != null) {
|
|
|
+ if (data.getExtras() != null) {
|
|
|
+ String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
|
|
|
+ if (mFocusId == R.id.storage_recharge_collect_ets) {
|
|
|
+ VerificationDatalistCodes(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(Column<String> column, String value, String s, int position) {
|
|
|
+ try {
|
|
|
+ takeApartThePalletlist.remove(position);
|
|
|
+ for (int i=0;i<takeApartThePalletlist.size();i++){
|
|
|
+ String va_code = takeApartThePalletlist.get(i).getVa_code();
|
|
|
+ Log.i("va_code===",va_code);
|
|
|
+ }
|
|
|
+ setFilterTableData(takeApartThePalletlist);
|
|
|
+ }catch (IndexOutOfBoundsException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public class SelectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
+
|
|
|
+ private ArrayList<AddAndDeleteCodeBean> mList = new ArrayList<>();
|
|
|
+
|
|
|
+ private SparseBooleanArray mSelectedPositions = new SparseBooleanArray();
|
|
|
+ private boolean mIsSelectable = false;
|
|
|
+
|
|
|
+
|
|
|
+ public SelectAdapter(ArrayList<AddAndDeleteCodeBean> list) {
|
|
|
+ if (list == null) {
|
|
|
+ throw new IllegalArgumentException("model Data must not be null");
|
|
|
+ }
|
|
|
+ mList = list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新adpter的数据和选择状态
|
|
|
+ public void updateDataSet(ArrayList<AddAndDeleteCodeBean> list) {
|
|
|
+ this.mList = list;
|
|
|
+ mSelectedPositions = new SparseBooleanArray();
|
|
|
+// ab.setTitle("已选择" + 0 + "项");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获得选中条目的结果
|
|
|
+ public ArrayList<AddAndDeleteCodeBean> getSelectedItem() {
|
|
|
+ ArrayList<AddAndDeleteCodeBean> selectList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < mList.size(); i++) {
|
|
|
+ if (isItemChecked(i)) {
|
|
|
+ selectList.add(mList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return selectList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
|
+ View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.materialchange_item, viewGroup, false);
|
|
|
+ return new ListItemViewHolder(itemView);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置给定位置条目的选择状态
|
|
|
+ private void setItemChecked(int position, boolean isChecked) {
|
|
|
+ mSelectedPositions.put(position, isChecked);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据位置判断条目是否选中
|
|
|
+ private boolean isItemChecked(int position) {
|
|
|
+ return mSelectedPositions.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据位置判断条目是否可选
|
|
|
+ private boolean isSelectable() {
|
|
|
+ return mIsSelectable;
|
|
|
+ }
|
|
|
+ //设置给定位置条目的可选与否的状态
|
|
|
+ private void setSelectable(boolean selectable) {
|
|
|
+ mIsSelectable = selectable;
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定界面,设置监听
|
|
|
+ @Override
|
|
|
+ public void onBindViewHolder(final RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") final int i) {
|
|
|
+ //设置条目状态
|
|
|
+ (( ListItemViewHolder) holder).tv_va_code.setText(mList.get(i).getVa_code());
|
|
|
+ (( ListItemViewHolder) holder).tv_va_delete.setText(mList.get(i).getVa_delete());
|
|
|
+ (( ListItemViewHolder) holder).tv_va_delete.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ takeApartThePalletlist.remove(i);
|
|
|
+ setAdapter(takeApartThePalletlist);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getItemCount() {
|
|
|
+ return mList == null ? 0 : mList.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ListItemViewHolder extends RecyclerView.ViewHolder{
|
|
|
+ //ViewHolder
|
|
|
+ TextView tv_va_code;
|
|
|
+ TextView tv_va_delete;
|
|
|
+
|
|
|
+
|
|
|
+ ListItemViewHolder(View view) {
|
|
|
+ super(view);
|
|
|
+ this.tv_va_code = (TextView) view.findViewById(R.id.tv_va_code);
|
|
|
+ this.tv_va_delete = (TextView) view.findViewById(R.id.tv_va_delete);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|