|
|
@@ -1,7 +1,10 @@
|
|
|
package com.uas.jlt_storage.fragment;
|
|
|
|
|
|
+import android.content.Context;
|
|
|
+import android.graphics.Color;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
+import android.support.v4.content.ContextCompat;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.Editable;
|
|
|
@@ -9,6 +12,7 @@ import android.text.TextUtils;
|
|
|
import android.text.TextWatcher;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
+import android.view.WindowManager;
|
|
|
import android.widget.CheckBox;
|
|
|
import android.widget.CompoundButton;
|
|
|
import android.widget.TextView;
|
|
|
@@ -17,10 +21,25 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
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.column.ColumnInfo;
|
|
|
+import com.bin.david.form.data.format.bg.BaseCellBackgroundFormat;
|
|
|
+import com.bin.david.form.data.format.draw.ImageResDrawFormat;
|
|
|
+import com.bin.david.form.data.format.draw.TextImageDrawFormat;
|
|
|
+import com.bin.david.form.data.format.title.ImageResTitleDrawFormat;
|
|
|
+import com.bin.david.form.data.format.title.TitleImageDrawFormat;
|
|
|
+import com.bin.david.form.data.style.FontStyle;
|
|
|
+import com.bin.david.form.data.table.TableData;
|
|
|
+import com.bin.david.form.listener.OnColumnClickListener;
|
|
|
+import com.bin.david.form.listener.OnColumnItemClickListener;
|
|
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
import com.uas.jlt_storage.R;
|
|
|
import com.uas.jlt_storage.adapter.JltStorageInFilterAdapter;
|
|
|
import com.uas.jlt_storage.bean.JLTStorageInBean;
|
|
|
+import com.uas.jlt_storage.bean.JLTStorageModelBean;
|
|
|
import com.uas.jlt_storage.global.GloableParams;
|
|
|
import com.uas.jlt_storage.util.CommonUtil;
|
|
|
import com.uas.jlt_storage.util.FastjsonUtil;
|
|
|
@@ -39,16 +58,20 @@ import java.util.List;
|
|
|
* Desc: 入库单列表页面
|
|
|
*/
|
|
|
|
|
|
-public class JltStorageInFilterListFragment extends BaseFragment implements JLTStorageInBoxScanFragment.OnFinishListener {
|
|
|
+public class JltStorageInFilterListFragment extends BaseFragment implements JLTStorageInBoxScanFragment.OnFinishListener, OnColumnItemClickListener<String> {
|
|
|
private ClearableEditText mSearchCet;
|
|
|
private TextView mSearchTv, mMultipleTv;
|
|
|
- private RecyclerView mRecyclerView;
|
|
|
- private CheckBox mSelectAllCheckBox;
|
|
|
|
|
|
- private List<JLTStorageInBean> mStorageInBeans;
|
|
|
- private JltStorageInFilterAdapter mStorageInFilterAdapter;
|
|
|
+ private List<JLTStorageInBean> mStorageInBeans, mFilterStorageInBeans;
|
|
|
private boolean mIgnoreChange = false;
|
|
|
private String mSupplier = "", mWhcode = "", mStartDate = "", mEndDate = "";
|
|
|
+ private SmartTable mSmartTable;
|
|
|
+ private Column<Boolean> mCheckColumn;
|
|
|
+ private Column<Long> mPosColumn;
|
|
|
+ private Column<String> mNumColumn, mClassColumn, mStateColumn, mWhcodeColumn, mSupplierColumn;
|
|
|
+ private TableData<JLTStorageInBean> mTableData;
|
|
|
+ private boolean mIsAllSelect = false;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
@@ -61,54 +84,64 @@ public class JltStorageInFilterListFragment extends BaseFragment implements JLTS
|
|
|
|
|
|
mSearchCet = root.findViewById(R.id.jlt_storage_in_filter_list_search_cet);
|
|
|
mSearchTv = root.findViewById(R.id.jlt_storage_in_filter_list_search_tv);
|
|
|
- mRecyclerView = root.findViewById(R.id.jlt_storage_in_filter_list_rv);
|
|
|
mMultipleTv = root.findViewById(R.id.jlt_storage_in_filter_list_multiple_tv);
|
|
|
- mSelectAllCheckBox = root.findViewById(R.id.jlt_storage_in_filter_list_selectall_cb);
|
|
|
-
|
|
|
- mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
- mRecyclerView.addItemDecoration(new RecyclerItemDecoration(2));
|
|
|
|
|
|
mStorageInBeans = new ArrayList<>();
|
|
|
- mStorageInFilterAdapter = new JltStorageInFilterAdapter(mStorageInBeans);
|
|
|
- mRecyclerView.setAdapter(mStorageInFilterAdapter);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initEvents() {
|
|
|
- mStorageInFilterAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
- @Override
|
|
|
- public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
- rowClickEvent(position);
|
|
|
- }
|
|
|
- });
|
|
|
+ mFilterStorageInBeans = new ArrayList<>();
|
|
|
+
|
|
|
+ mSmartTable = root.findViewById(R.id.jlt_storage_in_filter_list_st);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- mStorageInFilterAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
|
|
- @Override
|
|
|
- public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
- switch (view.getId()) {
|
|
|
- case R.id.item_jlt_storage_in_filter_spread_iv:
|
|
|
- int pos = mStorageInFilterAdapter.getFilterList().get(position).getPOS();
|
|
|
- JLTStorageInBean storageInBean = mStorageInBeans.get(pos);
|
|
|
- storageInBean.setSpread(!storageInBean.isSpread());
|
|
|
- mStorageInFilterAdapter.notifyDataSetChanged();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ mCheckColumn = new Column<Boolean>("全选", "isSelect",
|
|
|
+ new ImageResDrawFormat<Boolean>(CommonUtil.dip2px(mActivity, 20), CommonUtil.dip2px(mActivity, 20)) {
|
|
|
+ @Override
|
|
|
+ protected Context getContext() {
|
|
|
+ return mActivity;
|
|
|
+ }
|
|
|
|
|
|
- mSelectAllCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
- @Override
|
|
|
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
- if (!mIgnoreChange) {
|
|
|
- for (int i = 0; i < mStorageInBeans.size(); i++) {
|
|
|
- mStorageInBeans.get(i).setSelect(isChecked);
|
|
|
+ @Override
|
|
|
+ protected int getResourceID(Boolean aBoolean, String value, int position) {
|
|
|
+ if (aBoolean) {
|
|
|
+ return R.drawable.ic_check;
|
|
|
+ } else {
|
|
|
+ return R.drawable.ic_uncheck;
|
|
|
+ }
|
|
|
}
|
|
|
- mStorageInFilterAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
+ });
|
|
|
+ mCheckColumn.setFixed(true);
|
|
|
+ mPosColumn = new Column<Long>("序号", "POS");
|
|
|
+ mPosColumn.setFixed(true);
|
|
|
+ mNumColumn = new Column<String>("单号", "PI_INOUTNO");
|
|
|
+ mClassColumn = new Column<String>("类型", "PI_CLASS");
|
|
|
+ mSupplierColumn = new Column<String>("供应商", "PI_TITLE");
|
|
|
+ mWhcodeColumn = new Column<String>("仓库", "PI_WHCODE");
|
|
|
+ mStateColumn = new Column<String>("状态", "PI_STATUS");
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
mMultipleTv.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
@@ -124,7 +157,19 @@ public class JltStorageInFilterListFragment extends BaseFragment implements JLTS
|
|
|
|
|
|
@Override
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
- mStorageInFilterAdapter.getFilter().filter(s.toString().trim());
|
|
|
+ String filter = s.toString().trim();
|
|
|
+ if (TextUtils.isEmpty(filter)) {
|
|
|
+ mFilterStorageInBeans = mStorageInBeans;
|
|
|
+ } else {
|
|
|
+ List<JLTStorageInBean> filteredList = new ArrayList<>();
|
|
|
+ for (JLTStorageInBean storageInBean : mStorageInBeans) {
|
|
|
+ if (storageInBean.getPI_INOUTNO().contains(filter)) {
|
|
|
+ filteredList.add(storageInBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mFilterStorageInBeans = filteredList;
|
|
|
+ }
|
|
|
+ setFilterTableData(mFilterStorageInBeans);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -133,35 +178,27 @@ public class JltStorageInFilterListFragment extends BaseFragment implements JLTS
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- mStorageInFilterAdapter.setOnItemCheckListener(new JltStorageInFilterAdapter.OnItemCheckListener() {
|
|
|
+ mCheckColumn.setOnColumnItemClickListener(new OnColumnItemClickListener<Boolean>() {
|
|
|
@Override
|
|
|
- public void onItemCheck(int positon, boolean isChecked) {
|
|
|
- mStorageInBeans.get(positon).setSelect(isChecked);
|
|
|
-// new Handler().post(new Runnable() {
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// mStorageInFilterAdapter.notifyDataSetChanged();
|
|
|
-// }
|
|
|
-// });
|
|
|
-
|
|
|
- mIgnoreChange = true;
|
|
|
- if (!isChecked) {
|
|
|
- if (mSelectAllCheckBox.isChecked()) {
|
|
|
- mSelectAllCheckBox.setChecked(false);
|
|
|
- }
|
|
|
- } else {
|
|
|
- boolean isAllSelect = true;
|
|
|
- for (int i = 0; i < mStorageInBeans.size(); i++) {
|
|
|
- if (!mStorageInBeans.get(i).isSelect()) {
|
|
|
- isAllSelect = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- mSelectAllCheckBox.setChecked(isAllSelect);
|
|
|
+ public void onClick(Column<Boolean> column, String value, Boolean aBoolean, int position) {
|
|
|
+ itemCheck(position);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mSmartTable.setOnColumnClickListener(new OnColumnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(ColumnInfo columnInfo) {
|
|
|
+ if (columnInfo.column == mCheckColumn) {
|
|
|
+ allCheck();
|
|
|
}
|
|
|
- mIgnoreChange = false;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ mNumColumn.setOnColumnItemClickListener(this);
|
|
|
+ mClassColumn.setOnColumnItemClickListener(this);
|
|
|
+ mSupplierColumn.setOnColumnItemClickListener(this);
|
|
|
+ mWhcodeColumn.setOnColumnItemClickListener(this);
|
|
|
+ mStateColumn.setOnColumnItemClickListener(this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -177,9 +214,57 @@ public class JltStorageInFilterListFragment extends BaseFragment implements JLTS
|
|
|
getInDataList();
|
|
|
}
|
|
|
|
|
|
+ private void allCheck() {
|
|
|
+ mIsAllSelect = !mIsAllSelect;
|
|
|
+
|
|
|
+ setAllSelect(mIsAllSelect);
|
|
|
+ for (int i = 0; i < mStorageInBeans.size(); i++) {
|
|
|
+ mStorageInBeans.get(i).setSelect(mIsAllSelect);
|
|
|
+ }
|
|
|
+ List<Boolean> datas = mCheckColumn.getDatas();
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ datas.set(i, mIsAllSelect);
|
|
|
+ }
|
|
|
+
|
|
|
+ mSmartTable.refreshDrawableState();
|
|
|
+ mSmartTable.invalidate();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void itemCheck(int position) {
|
|
|
+ int reaPos = mFilterStorageInBeans.get(position).getPOS();
|
|
|
+ boolean select = !mStorageInBeans.get(reaPos).isSelect();
|
|
|
+ mStorageInBeans.get(reaPos).setSelect(select);
|
|
|
+ mCheckColumn.getDatas().set(position, select);
|
|
|
+
|
|
|
+ if (!select) {
|
|
|
+ mIsAllSelect = false;
|
|
|
+ setAllSelect(false);
|
|
|
+ } else {
|
|
|
+ filterAllSelect();
|
|
|
+ }
|
|
|
+
|
|
|
+ mSmartTable.refreshDrawableState();
|
|
|
+ mSmartTable.invalidate();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void filterAllSelect() {
|
|
|
+ boolean isAllSelect = true;
|
|
|
+ if (mStorageInBeans.size() == 0) {
|
|
|
+ isAllSelect = false;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < mStorageInBeans.size(); i++) {
|
|
|
+ if (!mStorageInBeans.get(i).isSelect()) {
|
|
|
+ isAllSelect = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setAllSelect(isAllSelect);
|
|
|
+ }
|
|
|
+
|
|
|
private void getInDataList() {
|
|
|
progressDialog.show();
|
|
|
mStorageInBeans.clear();
|
|
|
+ mFilterStorageInBeans.clear();
|
|
|
VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
.url(GloableParams.ADDRESS_JLT_RECEIVING_GETINDATALIST)
|
|
|
.method(Request.Method.GET)
|
|
|
@@ -216,7 +301,8 @@ public class JltStorageInFilterListFragment extends BaseFragment implements JLTS
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- mStorageInFilterAdapter.notifyDataSetChanged();
|
|
|
+ mFilterStorageInBeans = mStorageInBeans;
|
|
|
+ setFilterTableData(mFilterStorageInBeans);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -225,14 +311,47 @@ public class JltStorageInFilterListFragment extends BaseFragment implements JLTS
|
|
|
@Override
|
|
|
public void onFail(int flag, String failStr) throws Exception {
|
|
|
progressDialog.dismiss();
|
|
|
- mStorageInFilterAdapter.notifyDataSetChanged();
|
|
|
CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+
|
|
|
+ mFilterStorageInBeans = mStorageInBeans;
|
|
|
+ setFilterTableData(mFilterStorageInBeans);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void multipleCollect() {
|
|
|
+ private void setFilterTableData(List<JLTStorageInBean> filterTableData) {
|
|
|
+ mTableData = new TableData<JLTStorageInBean>("入库单列表", filterTableData,
|
|
|
+ mCheckColumn, mNumColumn, mClassColumn, mSupplierColumn, mWhcodeColumn, mStateColumn);
|
|
|
+ mSmartTable.setTableData(mTableData);
|
|
|
+
|
|
|
+ filterAllSelect();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setAllSelect(boolean isAllSelect) {
|
|
|
+ mIsAllSelect = isAllSelect;
|
|
|
+ mTableData.setTitleDrawFormat(new TitleImageDrawFormat(CommonUtil.dip2px(mActivity, 20),
|
|
|
+ CommonUtil.dip2px(mActivity, 20), 10) {
|
|
|
+ @Override
|
|
|
+ protected Context getContext() {
|
|
|
+ return mActivity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getResourceID(Column column) {
|
|
|
+ if (column == mCheckColumn) {
|
|
|
+ if (isAllSelect) {
|
|
|
+ return R.drawable.ic_check;
|
|
|
+ } else {
|
|
|
+ return R.drawable.ic_uncheck;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ private void multipleCollect() {
|
|
|
StringBuffer pi_inoutno = new StringBuffer("");
|
|
|
StringBuffer pi_id = new StringBuffer("");
|
|
|
|
|
|
@@ -283,8 +402,13 @@ public class JltStorageInFilterListFragment extends BaseFragment implements JLTS
|
|
|
FragmentUtils.switchFragment(JltStorageInFilterListFragment.this, jltStorageInBoxScanFragment);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onClick(Column<String> column, String value, String s, int position) {
|
|
|
+ rowClickEvent(position);
|
|
|
+ }
|
|
|
+
|
|
|
private void rowClickEvent(final int i) {
|
|
|
- int pos = mStorageInFilterAdapter.getFilterList().get(i).getPOS();
|
|
|
+ int pos = mFilterStorageInBeans.get(i).getPOS();
|
|
|
String pi_inoutno = mStorageInBeans.get(pos).getPI_INOUTNO();
|
|
|
String pi_id = mStorageInBeans.get(pos).getPI_ID() + "";
|
|
|
String pi_class = mStorageInBeans.get(pos).getPI_CLASS();
|