提交 e10c8eb3 authored 作者: lgd's avatar lgd

1.修改内部交易

上级 504525cc
......@@ -135,6 +135,24 @@ public class TradingBean {
private Object quantityDetailList;
private Object quantityFlowList;
private String chooseNum;
private String chooseName;
private ProductBean.RecordsBean changePro;
public ProductBean.RecordsBean getChangePro() {
return changePro;
}
public void setChangePro(ProductBean.RecordsBean changePro) {
this.changePro = changePro;
}
public String getChooseName() {
return chooseName;
}
public void setChooseName(String chooseName) {
this.chooseName = chooseName;
}
public String getChooseNum() {
return chooseNum;
......
......@@ -41,7 +41,7 @@ public interface BatChooseInfoContract {
void getStock(List<StockBean> dataList);
void getTradingPro(TradingBean.RecordsBean code, List<ProductBean.RecordsBean> dataList);
void getTradingPro( List<ProductBean.RecordsBean> dataList);
void getTradingProList(List<TradingBean.RecordsBean> dataList);
}
......@@ -55,7 +55,7 @@ public interface BatChooseInfoContract {
void getStock(Map<String,Object> param);
void getTradingPro(TradingBean.RecordsBean code);
void getTradingPro(String code);
void getTradingProList(Map<String,Object> param);
}
......
......@@ -114,9 +114,9 @@ public class BatChooseInfoPresenter extends BasePresenter<BatChooseInfoContract.
}
@Override
public void getTradingPro(TradingBean.RecordsBean code) {
public void getTradingPro(String code) {
mView.showLoading();
mModel.getTradingPro(code.getProductSoleCode()).compose(Transformer.schedule()).subscribe(new WorkObserver<BaseBean>() {
mModel.getTradingPro(code).compose(Transformer.schedule()).subscribe(new WorkObserver<BaseBean>() {
@Override
public void doOnSubscribe(Disposable d) {
mDisposable.add(d);
......@@ -135,8 +135,7 @@ public class BatChooseInfoPresenter extends BasePresenter<BatChooseInfoContract.
mView.onError(data.getMessage());
return;
}
List<ProductBean.RecordsBean> productBean = JSON.parseArray(data.getData().toString(), ProductBean.RecordsBean.class);
mView.getTradingPro(code, JSON.parseArray(data.getData().toString(), ProductBean.RecordsBean.class));
mView.getTradingPro(JSON.parseArray(data.getData().toString(), ProductBean.RecordsBean.class));
}
});
}
......
......@@ -4,6 +4,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
......@@ -113,12 +114,15 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
private List<StockBean> stockList = new ArrayList<>();
private List<String> stockNameList = new ArrayList<>();
private StockBean chooseStock;
Map<String, Object> carMap = new HashMap<>();
// Map<String, Object> carMap = new HashMap<>();
private List<TradingBean.RecordsBean> tradingProductList;
private TradingProductAdapter tradingProductAdapter;
private Map<String, Object> tradeParam;
private StockBean chooseSendStock;
private BadgeCarProvider mActionProvider;
private TradingProDetailAdapter tradingProDetailAdapter;
private List<ProductBean.RecordsBean> changeProList;
private List<TradingBean.RecordsBean> tradingCarList = new ArrayList<>();
@Override
protected void initView() {
......@@ -218,7 +222,7 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
if (TextUtils.equals("6", type)) {
batChooseInfoPresenter.getTradingPro(tradingProductList.get(position));
openDialogInside(tradingProductList.get(position));
} else {
openDialog(proList.get(position));
}
......@@ -228,7 +232,7 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
tradingProductAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
batChooseInfoPresenter.getTradingPro(tradingProductList.get(position));
openDialogInside(tradingProductList.get(position));
}
});
}
......@@ -264,12 +268,12 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
toast("请选择入库仓库");
return true;
}
if (!carMap.containsKey("pro")) {
if (tradingCarList.size()==0) {
toast("购物车没有产品");
return true;
}
startActivity(StoreTradingCarActivity.class,
"pro", JSON.toJSONString(carMap),
"pro", JSON.toJSONString(tradingCarList),
"supplierId", supplyId == null ? "" : supplyId.toString(),
"subProcess", chooseProcess == null ? "" : chooseProcess.getName(),
"subProcessId", chooseProcess == null ? "" : chooseProcess.getId() + "",
......@@ -625,8 +629,11 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
}
@Override
public void getTradingPro(TradingBean.RecordsBean data, List<ProductBean.RecordsBean> list) {
openDialogInside(data, list);
public void getTradingPro(List<ProductBean.RecordsBean> list) {
toast("搜索完成");
changeProList.clear();
changeProList.addAll(list);
tradingProDetailAdapter.notifyDataSetChanged();
}
@Override
......@@ -788,25 +795,35 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
* 内部交易选择产品
*
* @param quantity
* @param data
*/
private void openDialogInside(TradingBean.RecordsBean quantity, List<ProductBean.RecordsBean> data) {
private void openDialogInside(TradingBean.RecordsBean quantity) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = LayoutInflater.from(this).inflate(R.layout.view_add_cart_trading, null);
TextView tvOk = view.findViewById(R.id.tv_ok);
TextView tvCancel = view.findViewById(R.id.tv_cancel);
TextView tvSearch = view.findViewById(R.id.iv_search);
EditText tvKey = view.findViewById(R.id.et_key);
AddAndReduceView useNum = view.findViewById(R.id.ar_use_num);
useNum.setMaxNum(quantity.getQuantity());
AddAndReduceView num = view.findViewById(R.id.ar_num);
RecyclerView rvProduct = view.findViewById(R.id.rv_pro);
rvProduct.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
List<ProductBean.RecordsBean> dataList = new ArrayList<>();
dataList.addAll(data);
TradingProDetailAdapter tradingProDetailAdapter = new TradingProDetailAdapter(R.layout.item_trading_product_dialog, dataList);
changeProList = new ArrayList<>();
tradingProDetailAdapter = new TradingProDetailAdapter(R.layout.item_trading_product_dialog, changeProList);
tradingProDetailAdapter.bindToRecyclerView(rvProduct);
builder.setView(view);
AlertDialog addCartDialog = builder.create();
tvSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (TextUtils.isEmpty(tvKey.getText().toString())){
toast("请输入搜索关键字");
return;
}
batChooseInfoPresenter.getTradingPro(tvKey.getText().toString());
}
});
tvOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -815,18 +832,12 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
toast("请选择使用数量");
return;
}
Map<Integer, Boolean> isChoose = tradingProDetailAdapter.getIsChoose();
List<ProductBean.RecordsBean> info = new ArrayList<>();
for (Map.Entry<Integer, Boolean> entry : isChoose.entrySet()) {
if (entry.getValue()) {
ProductBean.RecordsBean recordsBean = dataList.get(entry.getKey());
info.add(recordsBean);
}
}
if (info.size() == 0) {
if (tradingProDetailAdapter.getChoosePos() == -1) {
toast("请选择置换产品");
return;
}
info.add(changeProList.get(tradingProDetailAdapter.getChoosePos()));
quantity.setChooseNum(String.valueOf(useNum.getNumber()));
addCartInside(quantity, info, num.getNumber());
addCartDialog.dismiss();
......@@ -845,14 +856,18 @@ public class ChooseInfoActivity extends WorkToolBarActivity implements BatChoose
for (ProductBean.RecordsBean bean : data) {
bean.setCarNum(number);
}
carMap.put("pro", JSON.toJSONString(quantity));
carMap.put("proDetail", JSON.toJSONString(data));
quantity.setChangePro(data.get(0));
quantity.setChooseName(data.get(0).getName());
tradingCarList.add(quantity);
// carMap.put("pro", JSON.toJSONString(quantity));
// carMap.put("proDetail", JSON.toJSONString(data));
if (data.size() > 0) {
mActionProvider.setBadgeVisibility(View.VISIBLE);
} else {
mActionProvider.setBadgeVisibility(View.GONE);
}
toast("加入购物车成功");
tradingProductAdapter.notifyDataSetChanged();
}
private void changeCarBadge() {
......
package com.wd.workoffice.ui.activity.bat.store;
import android.os.Bundle;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.ProductBean;
import com.wd.workoffice.bean.TradingBean;
import com.wd.workoffice.bean.event.ModifyCarEvent;
import com.wd.workoffice.ui.adapter.TradingProCarAdapter;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.widget.AddAndReduceView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
......@@ -19,7 +18,6 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
......@@ -34,7 +32,6 @@ import butterknife.OnClick;
* github: https://github.com/FlexibleXd
**/
public class StoreTradingCarActivity extends WorkToolBarActivity {
@BindView(R.id.tv_num)
TextView tvNum;
@BindView(R.id.tv_price)
......@@ -43,24 +40,10 @@ public class StoreTradingCarActivity extends WorkToolBarActivity {
TextView tvOk;
@BindView(R.id.ll_bottom)
RelativeLayout llBottom;
@BindView(R.id.tv_name)
TextView tvName;
@BindView(R.id.tv_card)
TextView tvCard;
@BindView(R.id.tv_card_name)
TextView tvCardName;
@BindView(R.id.tv_dept)
TextView tvDept;
@BindView(R.id.tv_apply_num)
TextView tvApplyNum;
@BindView(R.id.ar_use_num)
AddAndReduceView arUseNum;
@BindView(R.id.rv_product)
RecyclerView rvProduct;
private List<ProductBean.RecordsBean> productList;
private List<TradingBean.RecordsBean> productList;
private TradingProCarAdapter productAdapter;
private Map data;
private TradingBean.RecordsBean pro;
@Override
protected void initView() {
......@@ -70,31 +53,17 @@ public class StoreTradingCarActivity extends WorkToolBarActivity {
@Override
protected void initData() {
data = JSON.parseObject(getIntent().getStringExtra("pro"), Map.class);
pro = JSON.parseObject(data.get("pro").toString(), TradingBean.RecordsBean.class);
tvName.setText(pro.getProductName());
tvCard.setText(pro.getProductSimpleCode());
tvCardName.setText(pro.getProductSoleCode());
tvApplyNum.setText(MathUtils.converData(pro.getQuantity(),3));
tvDept.setText(pro.getDeptName());
arUseNum.setMaxNum(pro.getQuantity());
arUseNum.setNumber(pro.getChooseNum());
productList = new ArrayList<>();
productAdapter = new TradingProCarAdapter(R.layout.item_trading_product_car, productList);
productAdapter.bindToRecyclerView(rvProduct);
productList.addAll(JSON.parseArray(data.get("proDetail").toString(), ProductBean.RecordsBean.class));
productList.addAll(JSON.parseArray(getIntent().getStringExtra("pro"), TradingBean.RecordsBean.class));
productAdapter.notifyDataSetChanged();
changeNumAndPrice();
}
@Override
protected void initEvent() {
arUseNum.setOnNumberChangedListener(new AddAndReduceView.OnNumberChangedListener() {
@Override
public void OnNumberChanged(String vs) {
pro.setChooseNum(vs);
}
});
// productAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
// @Override
// public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
......@@ -125,13 +94,11 @@ public class StoreTradingCarActivity extends WorkToolBarActivity {
@OnClick(R.id.tv_ok)
public void onViewClicked() {
String allPrice = "";
for (ProductBean.RecordsBean recordsBean : productList) {
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getCarNum()
, MathUtils.converData(recordsBean.getInternalPrice(),3), 3), 3);
for (TradingBean.RecordsBean recordsBean : productList) {
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getChangePro().getCarNum()
, MathUtils.converData(recordsBean.getChangePro().getInternalPrice(), 3), 3), 3);
}
data.put("proDetail",productList);
data.put("pro",pro);
startActivity(StoreTradingConfirmActivity.class, "pro",JSON.toJSONString(data),
startActivity(StoreTradingConfirmActivity.class, "pro", JSON.toJSONString(productList),
"subProcess", getIntent().getStringExtra("subProcess"),
"supplierId", getIntent().getStringExtra("supplierId"),
"inStockId", getIntent().getStringExtra("inStockId"),
......@@ -161,8 +128,8 @@ public class StoreTradingCarActivity extends WorkToolBarActivity {
private void changeNumAndPrice() {
tvNum.setText("共 ".concat(productList.size() + "").concat(" 件"));
String allPrice = "";
for (ProductBean.RecordsBean recordsBean : productList) {
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getCarNum(), recordsBean.getInternalPrice() + "", 3),
for (TradingBean.RecordsBean recordsBean : productList) {
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getChangePro().getCarNum(), recordsBean.getChangePro().getInternalPrice() + "", 3),
3);
}
tvPrice.setText("总计: ¥ ".concat(allPrice));
......
......@@ -5,14 +5,11 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......@@ -24,7 +21,6 @@ import com.tbruyelle.rxpermissions2.RxPermissions;
import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseBean;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.ProductBean;
import com.wd.workoffice.bean.TradingBean;
import com.wd.workoffice.bean.workEnum.PermissionType;
import com.wd.workoffice.retrofit.ApiService;
......@@ -57,9 +53,7 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
import flexible.xd.android_base.network.rtfhttp.RtfHelper;
import flexible.xd.android_base.network.rtfhttp.Transformer;
import flexible.xd.android_base.utils.LogUtils;
import flexible.xd.android_base.utils.TimeUtils;
import flexible.xd.android_base.utils.constant.TimeConstants;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import okhttp3.MediaType;
......@@ -73,7 +67,6 @@ import okhttp3.RequestBody;
* github: https://github.com/FlexibleXd
**/
public class StoreTradingConfirmActivity extends WorkToolBarActivity {
@BindView(R.id.tv_num)
TextView tvNum;
@BindView(R.id.tv_price)
......@@ -114,11 +107,7 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
EditText etInput5;
@BindView(R.id.tv_input5)
TextView tvInput5;
@BindView(R.id.tv_card)
TextView tvCard;
@BindView(R.id.tv_use_num)
TextView tvUseNum;
private List<ProductBean.RecordsBean> proList;
private List<TradingBean.RecordsBean> proList;
private TradingConfimProAdapter proAdapter;
private QMUIDialog.MenuDialogBuilder setDialog;
private String[] setArray = new String[]{"钢控", "锆碳"};
......@@ -150,14 +139,10 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
@Override
protected void initData() {
Map data = JSON.parseObject(getIntent().getStringExtra("pro"), Map.class);
pro = JSON.parseObject(data.get("pro").toString(), TradingBean.RecordsBean.class);
tvCard.setText(pro.getProductName());
tvUseNum.setText(pro.getChooseNum());
proList = new ArrayList<>();
proAdapter = new TradingConfimProAdapter(R.layout.item_trading_confirm_pro, proList);
proAdapter.bindToRecyclerView(rvPro);
proList.addAll(JSON.parseArray(data.get("proDetail").toString(), ProductBean.RecordsBean.class));
proList.addAll(JSON.parseArray(getIntent().getStringExtra("pro"), TradingBean.RecordsBean.class));
proAdapter.notifyDataSetChanged();
changeNumAndPrice();
param = new HashMap<>();
......@@ -188,17 +173,17 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
* @param proList
* @return
*/
private List<JSONObject> coverProInfo(List<ProductBean.RecordsBean> proList) {
private List<JSONObject> coverProInfo(List<TradingBean.RecordsBean> proList) {
List<JSONObject> orderItems = new ArrayList<>();
for (ProductBean.RecordsBean recordsBean : proList) {
for (TradingBean.RecordsBean recordsBean : proList) {
JSONObject data = new JSONObject();
data.put("productId", recordsBean.getId());
data.put("productCount", recordsBean.getCarNum());
data.put("productId", recordsBean.getChangePro().getId());
data.put("productCount", recordsBean.getChangePro().getCarNum());
data.put("type", "PDS");
data.put("sourceProductId", pro.getProductId());
data.put("sourceProductCount", pro.getChooseNum());
data.put("stockId", pro.getStockId());
data.put("annex", recordsBean.getUrl());
data.put("sourceProductId", recordsBean.getProductId());
data.put("sourceProductCount", recordsBean.getChooseNum());
data.put("stockId", recordsBean.getStockId());
data.put("annex", recordsBean.getChangePro().getUrl());
orderItems.add(data);
}
return orderItems;
......@@ -232,7 +217,7 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
* @param tv
*/
private void addNumListener(EditText et, TextView tv) {
WorkUtils.addNumListener(et,tv);
WorkUtils.addNumListener(et, tv);
}
@Override
......@@ -350,8 +335,8 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
private void changeNumAndPrice() {
tvNum.setText("共 ".concat(proList.size() + "").concat(" 件"));
String allPrice = "";
for (ProductBean.RecordsBean recordsBean : proList) {
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getCarNum() , MathUtils.converData(recordsBean.getInternalPrice(),3), 3), 3);
for (TradingBean.RecordsBean recordsBean : proList) {
allPrice = MathUtils.add(allPrice, MathUtils.multiply(recordsBean.getChangePro().getCarNum(), MathUtils.converData(recordsBean.getChangePro().getInternalPrice(), 3), 3), 3);
}
tvPrice.setText("总计: ¥ ".concat(allPrice));
}
......@@ -363,8 +348,8 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
Integer clientId = data.getIntExtra("id", 0);
String name = data.getStringExtra("name");
Integer position = Integer.valueOf(data.getStringExtra("position"));
proList.get(position).setFactoryId(clientId);
proList.get(position).setFactoryName(name);
proList.get(position).getChangePro().setFactoryId(clientId);
proList.get(position).getChangePro().setFactoryName(name);
proAdapter.notifyItemChanged(position);
} else if (requestCode == 10002 && resultCode == RESULT_OK) {
if (Matisse.obtainResult(data).size() != 0) {
......@@ -393,7 +378,7 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
return;
}
toast("上传成功");
proList.get(choosePosition).setUrl(jsonObject.getString("data"));
proList.get(choosePosition).getChangePro().setUrl(jsonObject.getString("data"));
coverProInfo(proList);
proAdapter.notifyDataSetChanged();
}
......@@ -428,4 +413,11 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
}
......@@ -110,14 +110,14 @@ public class StoreTradingProductActivity extends WorkToolBarActivity {
toast("请选择使用数量");
return;
}
Map<Integer, Boolean> isChoose = tradingProDetailAdapter.getIsChoose();
// Map<Integer, Boolean> isChoose = tradingProDetailAdapter.getIsChoose();
List<ProductBean.RecordsBean> info = new ArrayList<>();
for (Map.Entry<Integer, Boolean> entry : isChoose.entrySet()) {
if (entry.getValue()) {
ProductBean.RecordsBean recordsBean = dataList.get(entry.getKey());
info.add(recordsBean);
}
}
// for (Map.Entry<Integer, Boolean> entry : isChoose.entrySet()) {
// if (entry.getValue()) {
// ProductBean.RecordsBean recordsBean = dataList.get(entry.getKey());
// info.add(recordsBean);
// }
// }
if (info.size() == 0) {
toast("请选择置换产品");
return;
......
......@@ -11,6 +11,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.ProductBean;
import com.wd.workoffice.bean.TradingBean;
import com.wd.workoffice.bean.event.ModifyCarEvent;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.widget.AddAndReduceView;
......@@ -25,7 +26,7 @@ import flexible.xd.android_base.utils.ToastUtil;
* Created by flexible on 2018/8/13.
*/
public class TradingConfimProAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, BaseViewHolder> {
public class TradingConfimProAdapter extends BaseQuickAdapter<TradingBean.RecordsBean, BaseViewHolder> {
public TradingConfimProAdapter(int layoutResId, List data) {
super(layoutResId, data);
......@@ -33,12 +34,18 @@ public class TradingConfimProAdapter extends BaseQuickAdapter<ProductBean.Record
@Override
protected void convert(BaseViewHolder helper, ProductBean.RecordsBean item) {
helper.setText(R.id.tv_name, item.getName());
helper.setText(R.id.tv_num, String.valueOf(item.getCarNum()));
helper.setText(R.id.tv_all_price, MathUtils.multiply(item.getCarNum() , MathUtils.converData(item.getInternalPrice(),3), 3));
protected void convert(BaseViewHolder helper, TradingBean.RecordsBean item) {
helper.setText(R.id.tv_card, item.getProductName());
helper.setText(R.id.tv_use_num, MathUtils.converData(item.getChooseNum(),3));
helper.setText(R.id.tv_name, item.getChangePro().getName());
helper.setText(R.id.tv_num, MathUtils.converData(item.getChangePro().getCarNum(),3));
helper.setText(R.id.tv_all_price, MathUtils.multiply(item.getChangePro().getCarNum() ,
MathUtils.converData(item.getChangePro().getInternalPrice(),3), 3));
helper.addOnClickListener(R.id.rl_upload);
if (!TextUtils.isEmpty(item.getUrl())){
if (!TextUtils.isEmpty(item.getChangePro().getUrl())){
helper.setText(R.id.tv_upload, "已上传,点击替换");
}
}
......
package com.wd.workoffice.ui.adapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import com.alibaba.fastjson.JSON;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.ProductBean;
import com.wd.workoffice.bean.TradingBean;
import com.wd.workoffice.bean.event.ModifyCarEvent;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.widget.AddAndReduceView;
import org.greenrobot.eventbus.EventBus;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by flexible on 2018/8/13.
*/
public class TradingProCarAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, BaseViewHolder> {
public class TradingProCarAdapter extends BaseQuickAdapter<TradingBean.RecordsBean, BaseViewHolder> {
public TradingProCarAdapter(int layoutResId, List data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, ProductBean.RecordsBean item) {
helper.setText(R.id.tv_name, item.getName());
helper.setText(R.id.tv_card, item.getSoleCode());
helper.setText(R.id.tv_card_name, item.getSoleCode());
helper.setText(R.id.tv_spec, item.getSpec());
helper.setText(R.id.tv_price, MathUtils.converData(item.getInternalPrice(),3));
helper.setText(R.id.tv_all_price, "小计:"+MathUtils.multiply(item.getCarNum(), MathUtils.converData(item.getInternalPrice(),3), 3));
protected void convert(BaseViewHolder helper, TradingBean.RecordsBean item) {
helper.setText(R.id.tv_top_name, item.getProductName());
helper.setText(R.id.tv_top_card, item.getProductSimpleCode());
helper.setText(R.id.tv_top_card_name, item.getProductSoleCode());
helper.setText(R.id.tv_apply_num, MathUtils.converData(item.getQuantity(),3));
helper.setText(R.id.tv_dept, item.getDeptName());
AddAndReduceView userNum = helper.getView(R.id.ar_use_num);
userNum.setNumber(item.getChooseNum());
userNum.setMaxNum(item.getQuantity());
userNum.setOnNumberChangedListener(new AddAndReduceView.OnNumberChangedListener() {
@Override
public void OnNumberChanged(String vs) {
item.setChooseNum(vs);
}
});
helper.setText(R.id.tv_name, item.getChangePro().getName());
helper.setText(R.id.tv_card, item.getChangePro().getSoleCode());
helper.setText(R.id.tv_card_name, item.getChangePro().getSoleCode());
helper.setText(R.id.tv_spec, item.getChangePro().getSpec());
helper.setText(R.id.tv_price, MathUtils.converData(item.getChangePro().getInternalPrice(),3));
helper.setText(R.id.tv_all_price, "小计:"+MathUtils.multiply(item.getChangePro().getCarNum(), MathUtils.converData(item.getChangePro().getInternalPrice(),3), 3));
AddAndReduceView num = helper.getView(R.id.ar_num);
num.setNumber(item.getCarNum());
num.setNumber(item.getChangePro().getCarNum());
num.setOnNumberChangedListener(new AddAndReduceView.OnNumberChangedListener() {
@Override
public void OnNumberChanged(String vs) {
item.setCarNum(vs);
helper.setText(R.id.tv_all_price, "小计:"+MathUtils.multiply(vs , MathUtils.converData(item.getInternalPrice(),3), 3));
item.getChangePro().setCarNum(vs);
helper.setText(R.id.tv_all_price, "小计:"+MathUtils.multiply(vs , MathUtils.converData(item.getChangePro().getInternalPrice(),3), 3));
EventBus.getDefault().post(new ModifyCarEvent(JSON.toJSONString(getData())));
}
......
package com.wd.workoffice.ui.adapter;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
......@@ -21,38 +22,53 @@ import java.util.Map;
public class TradingProDetailAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, BaseViewHolder> {
Map<Integer, Boolean> isChoose = new HashMap<>();
int choosePos = -1;
public TradingProDetailAdapter(int layoutResId, List data) {
super(layoutResId, data);
for (int i = 0; i < isChoose.entrySet().size(); i++) {
isChoose.put(i, false);
}
}
@Override
protected void convert(BaseViewHolder helper, ProductBean.RecordsBean item) {
helper.setText(R.id.tv_name,item.getName() );
helper.setText(R.id.tv_card, item.getSoleCode() );
helper.setText(R.id.tv_name, item.getName());
helper.setText(R.id.tv_card, item.getSoleCode());
helper.setText(R.id.tv_card_name, item.getSoleCode());
helper.setText(R.id.tv_spec,item.getSpec());
helper.setText(R.id.tv_price, MathUtils.converData(item.getInternalPrice(),3));
helper.setText(R.id.tv_spec, item.getSpec());
helper.setText(R.id.tv_price, MathUtils.converData(item.getInternalPrice(), 3));
CheckBox cbChoose = helper.getView(R.id.cb_check);
cbChoose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
if (helper.getAdapterPosition() == choosePos) {
cbChoose.setChecked(true);
} else {
cbChoose.setChecked(false);
}
cbChoose.setOnClickListener(new View.OnClickListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
isChoose.put(helper.getAdapterPosition(), cbChoose.isChecked());
public void onClick(View v) {
if (choosePos ==helper.getAdapterPosition()){
}else {
choosePos = helper.getAdapterPosition();
notifyDataSetChanged();
}
}
});
// cbChoose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
// @Override
// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// notifyItemChanged(choosePos);
// choosePos = helper.getAdapterPosition();
//// cbChoose.setChecked(isChecked);
// }
// });
}
public Map<Integer, Boolean> getIsChoose() {
return isChoose;
public int getChoosePos() {
return choosePos;
}
public void setIsChoose(Map<Integer, Boolean> isChoose) {
this.isChoose = isChoose;
public void setChoosePos(int choosePos) {
this.choosePos = choosePos;
}
}
package com.wd.workoffice.ui.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.ProductBean;
import com.wd.workoffice.bean.TradingBean;
import com.wd.workoffice.util.MathUtils;
import java.util.List;
......@@ -26,6 +29,13 @@ public class TradingProductAdapter extends BaseQuickAdapter<TradingBean.RecordsB
helper.setText(R.id.tv_card_name, item.getProductSoleCode());
helper.setText(R.id.tv_num, String.valueOf(item.getQuantity()));
helper.setText(R.id.tv_dept, item.getDeptName());
if (!TextUtils.isEmpty(item.getChooseNum())) {
helper.setVisible(R.id.ll_car,true);
helper.setText(R.id.tv_pro,item.getChooseName());
helper.setText(R.id.tv_car_num, MathUtils.converData(item.getChooseNum(), 3));
}else{
helper.setVisible(R.id.ll_car,false);
}
helper.addOnClickListener(R.id.tv_cart);
}
}
......
......@@ -79,67 +79,6 @@
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FCFCFD"
android:orientation="vertical"
android:paddingHorizontal="20mm"
android:paddingVertical="10mm">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="使用数量"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_use_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm"
android:gravity="center"
android:text="置换产品信息"
android:textSize="17sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_pro"
android:layout_width="match_parent"
......
......@@ -59,145 +59,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:paddingHorizontal="20mm"
android:paddingVertical="10mm">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图号TH82739857"
android:textColor="@color/black"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14mm"
android:background="#FCFCFD"
android:orientation="vertical"
android:padding="10mm">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="图号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_card_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="来源仓库"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_dept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="可申请数量"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_apply_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="使用数量"
android:textColor="@color/flexible_text_sup"
android:textSize="16sp" />
<com.wd.workoffice.widget.AddAndReduceView
android:id="@+id/ar_use_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10mm" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_product"
......
......@@ -7,7 +7,66 @@
android:orientation="vertical"
android:paddingHorizontal="20mm"
android:paddingVertical="10mm">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FCFCFD"
android:orientation="vertical"
android:paddingHorizontal="20mm"
android:paddingVertical="10mm">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="使用数量"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_use_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm"
android:gravity="center"
android:text="置换产品信息"
android:textSize="17sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
......
......@@ -116,11 +116,57 @@
</LinearLayout>
<TextView
android:id="@+id/tv_cart"
android:layout_width="90mm"
android:layout_height="26mm"
android:layout_gravity="right"
android:layout_marginTop="10mm"
android:background="@mipmap/product_add_cart" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/ll_car"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用数量:"
android:textColor="@color/red_btn_bg"
android:textSize="13sp" />
<TextView
android:id="@+id/tv_car_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="100mm"
android:textColor="@color/red_btn_bg"
android:textSize="13sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15mm"
android:text="置换产品:"
android:textColor="@color/red_btn_bg"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_pro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="100mm"
android:textColor="@color/red_btn_bg"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="@+id/tv_cart"
android:layout_width="90mm"
android:layout_height="26mm"
android:layout_gravity="right"
android:background="@mipmap/product_add_cart" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -4,9 +4,155 @@
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:layout_marginTop="10mm"
android:paddingHorizontal="20mm"
android:paddingVertical="10mm">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:paddingHorizontal="20mm"
android:paddingVertical="10mm">
<TextView
android:id="@+id/tv_top_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图号TH82739857"
android:textColor="@color/black"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14mm"
android:background="#FCFCFD"
android:orientation="vertical"
android:padding="10mm">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_top_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="图号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_top_card_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="来源仓库"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_dept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="可申请数量"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_apply_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="品号"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10mm"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="使用数量"
android:textColor="@color/flexible_text_sup"
android:textSize="16sp" />
<com.wd.workoffice.widget.AddAndReduceView
android:id="@+id/ar_use_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10mm" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="置换产品信息"
android:layout_marginTop="10mm"
android:textColor="@color/black"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
......
......@@ -48,11 +48,38 @@
android:text="选择置换产品"
android:textSize="17sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="10mm"
android:gravity="center"
android:paddingVertical="5mm">
<EditText
android:id="@+id/et_key"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingVertical="5mm"
android:paddingHorizontal="3mm"
android:hint="搜索置换产品"
android:textSize="14sp"
android:background="@drawable/shape_client_search" />
<TextView
android:id="@+id/iv_search"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:paddingHorizontal="8mm"
android:text="搜索"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_pro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="200mm"
android:layout_marginTop="5mm" />
<LinearLayout
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论