Commit 94e2feb7 by Wyh

1、印單打印問題 2、供應鏈運費代碼

parent e9bb692c
......@@ -25,6 +25,8 @@ public class BillItemView extends LinearLayout {
public BillItemView(Context context, List<PrintBillItem> data) {
super(context);
this.data = data;
setOrientation(LinearLayout.VERTICAL);
init();
}
private void init() {
......
......@@ -24,6 +24,7 @@ public class BillTypeView extends LinearLayout {
public BillTypeView(Context context, List<PrintBillItem> data) {
super(context);
this.data = data;
setOrientation(LinearLayout.VERTICAL);
init();
}
......
......@@ -25,6 +25,7 @@ public class BillView extends LinearLayout {
public BillView(Context context, List<BillingBean> data) {
super(context);
this.data = data;
setOrientation(LinearLayout.VERTICAL);
init();
}
......
......@@ -34,6 +34,7 @@ public class PrintFoodView extends LinearLayout {
super(context);
this.showPrice = showPrice;
this.data = data;
setOrientation(LinearLayout.VERTICAL);
init(deviceBean);
}
......
......@@ -25,6 +25,10 @@ public class PurchaseFoodBean implements Serializable {
public static final String CATEGORY_DIVIDER = "-";
private Integer id;
private String supplierName;
/**
* 運費
*/
private double shipping;
private String images;
private String foodNo;
private String name;
......
......@@ -35,7 +35,15 @@ public class SupplierInfoBean implements Serializable {
private long createTime;
private long updateTime;
private Integer deletes;
/**
* 最低採購
*/
private double minimumAmount;
/**
* 運費
*/
private double shipping;
private List<SupplierContacts> supplierContacts;
......
......@@ -4,6 +4,8 @@ import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
......@@ -24,6 +26,8 @@ public interface WarehousingInventoryContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void updateSuccess();
void loadRecord();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......@@ -35,5 +39,13 @@ public interface WarehousingInventoryContract {
* @return
*/
Observable<BaseResult> consumeWareHousing(RequestBody requestBody);
/**
* 獲取庫存消耗記錄
*
* @param map
* @return
*/
Observable<BaseResult> getWarehousingRecord(Map<String, Object> map);
}
}
......@@ -14,6 +14,8 @@ import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
......@@ -53,4 +55,9 @@ public class WarehousingInventoryModel extends BaseModel implements WarehousingI
public Observable<BaseResult> consumeWareHousing(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).consumeWareHousing(requestBody);
}
@Override
public Observable<BaseResult> getWarehousingRecord(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getWarehousingRecord(map);
}
}
\ No newline at end of file
......@@ -284,7 +284,8 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
@Override
public void onNext(BaseResult baseResult) {
if (baseResult.isSuccess()) {
mRootView.addBasicUnit(new BasicUnitBean(content));
BasicUnitBean basicUnitBean = GsonUtils.GsonToBean(baseResult.getData(), BasicUnitBean.class);
mRootView.addBasicUnit(basicUnitBean);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
......
......@@ -88,14 +88,17 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
public final int addressIndex = 5;
public final int telephoneIndex = 6;
public final int lowPurchaseAmount = 7;
public final int emailIndex = 10;
public final int smsIndex = 15;
public final int remarkIndex = 18;
//運費
public final int shippingIndex = 8;
public final int WhatsAppIndex = 11;
public final int weChatIndex = 12;
public final int lineIndex = 13;
public final int kakaoIndex = 14;
public final int emailIndex = 11;
public final int smsIndex = 16;
public final int remarkIndex = 19;
public final int WhatsAppIndex = 12;
public final int weChatIndex = 13;
public final int lineIndex = 14;
public final int kakaoIndex = 15;
private InfoMultiAdapter infoMultiAdapter;
private SupplierInfoBean supplierBean;
......@@ -135,8 +138,8 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人", true, "請輸入聯繫人", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "詳細地址", true, "請輸入詳細地址", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人電話", true, "請輸入聯繫人電話", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 11)}, EditorInfo.TYPE_CLASS_PHONE));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "最低採購金額", false, "請輸入最低金額", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 7)}, EditorInfo.TYPE_CLASS_NUMBER));
// infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "運費", true, "請輸入運費", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 7)}, EditorInfo.TYPE_CLASS_NUMBER));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "最低採購金額", false, "請輸入最低金額", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 9)}, EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "運費", false, "請輸入運費", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 9)}, EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "接收方式"));
......@@ -175,6 +178,7 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
infoMultiBeans.get(addressIndex).setShowValue(supplierBean.getAddress());
infoMultiBeans.get(remarkIndex).setShowValue(supplierBean.getRemarks());
infoMultiBeans.get(lowPurchaseAmount).setShowValue(supplierBean.getMinimumAmount() + "");
infoMultiBeans.get(shippingIndex).setShowValue(supplierBean.getShipping() + "");
}
infoMultiAdapter = new InfoMultiAdapter(mContext, infoMultiBeans);
infoMultiAdapter.setOnItemChildClickListener((adapter, view, position) -> {
......@@ -498,18 +502,31 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
if (supplierInfoBean == null) {
supplierInfoBean = new SupplierInfoBean();
}
//供應商編號
supplierInfoBean.setSupplierNo(infoMultiBeans.get(supplierNoIndex).getShowValue());
//供應商名稱
supplierInfoBean.setSupplierName(infoMultiBeans.get(supplierNameIndex).getShowValue());
//聯繫人
supplierInfoBean.setContacts(infoMultiBeans.get(contactsIndex).getShowValue());
//手機號碼
String telephone = infoMultiBeans.get(telephoneIndex).getShowValue();
supplierInfoBean.setContactInformation(telephone);
//地址
supplierInfoBean.setAddress(infoMultiBeans.get(addressIndex).getShowValue());
//餐廳信息
supplierInfoBean.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
supplierInfoBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
//最低採購金額
String minimumAmount = infoMultiBeans.get(lowPurchaseAmount).getShowValue();
if (TextUtil.isNotEmptyOrNullOrUndefined(minimumAmount)) {
supplierInfoBean.setMinimumAmount(Double.parseDouble(minimumAmount));
}
//運費
String shipping = infoMultiBeans.get(shippingIndex).getShowValue();
if (TextUtil.isNotEmptyOrNullOrUndefined(shipping)) {
supplierInfoBean.setShipping(Double.parseDouble(shipping));
}
//供應商編號如果沒填,就設為空
if (TextUtil.isEmptyOrNullOrUndefined(supplierInfoBean.getSupplierNo())) {
supplierInfoBean.setSupplierNo(null);
}
......
......@@ -108,23 +108,28 @@ public class ShoppingCatPresenter extends BasePresenter<ShoppingCatContract.Mode
//統計當前供應商選中食材的種類
int supplierTotalSpecies = 0;
shoppingCartBean.setAllSelect(true);
double shipping = 0;
for (PurchaseFoodBean purchaseFoodBean : foods) {
if (purchaseFoodBean.isChecked()) {
supplierTotalAmount = MoneyUtil.sum(supplierTotalAmount, MoneyUtil.priceCalculation(purchaseFoodBean.getUnitPrice(), purchaseFoodBean.getFoodQuantity()));
supplierTotalSpecies++;
//有選中的食品才顯示運費
shipping = purchaseFoodBean.getShipping();
} else {
shoppingCartBean.setAllSelect(false);
}
}
//不滿足最低採購金額,不可點擊創建訂單按鈕
if (MoneyUtil.compareTo(shoppingCartBean.getMinimumAmount(), supplierTotalAmount) == 1) {
createBtnCheckable = false;
}
// shoppingCartBean.setShipping();運費
//運費
shoppingCartBean.setShipping(shipping);
shoppingCartBean.setInitialShippingTime(TimeUtils.getNextDay(1));
shoppingCartBean.setSelectFoodAmount(supplierTotalAmount);
shoppingCartBean.setSelectSpeciesNum(supplierTotalSpecies);
//統計所有供應商的選中的食材的總金額
totalPrice = MoneyUtil.sum(totalPrice, supplierTotalAmount);
//統計所有供應商的選中的食材的總金額,加上運費
totalPrice = MoneyUtil.sum(MoneyUtil.sum(totalPrice, supplierTotalAmount), shipping);
//統計所有供應商的選中的食材的種類數量
totalTypeNumber += supplierTotalSpecies;
shoppingCartBean.setFoodList(foods);
......@@ -177,6 +182,8 @@ public class ShoppingCatPresenter extends BasePresenter<ShoppingCatContract.Mode
}
if (checkState) {
shoppingCartBean.setSelectSpeciesNum(shoppingCartBean.getFoodList().size());
//總金額要加上運費
totalAmount = MoneyUtil.sum(totalAmount, shoppingCartBean.getShipping());
} else {
shoppingCartBean.setSelectSpeciesNum(0);
}
......
......@@ -21,6 +21,9 @@ import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.HashMap;
import java.util.Map;
/**
* ================================================
......@@ -95,4 +98,35 @@ public class WarehousingInventoryPresenter extends BasePresenter<WarehousingInve
}
});
}
/**
* 查詢庫存盤點記錄
*/
public void getWarehousingRecord(int pageIndex) {
Map<String, Object> map = new HashMap<>(4);
Constant.addRestaurantId(map);
Constant.addBrandId(map);
Constant.addPageSize(map);
map.put("pageIndex", pageIndex * Constant.PAGE_SIZE);
mModel.getWarehousingRecord(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.SAVE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
//消耗完之後,關閉頁面
mRootView.loadRecord();
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.SAVE_FAIL);
}
}
});
}
}
......@@ -438,4 +438,13 @@ public interface SupplierServer {
@GET("purchaseConsume/get/remaining/quantity" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehousingNum(@QueryMap Map<String, Object> map);
/**
* 查詢庫存消耗記錄
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsume/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehousingRecord(@QueryMap Map<String, Object> map);
}
......@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.animation.AnimatorSet;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
......@@ -13,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration;
import com.gingersoft.gsa.cloud.ui.utils.AnimateUtils;
......@@ -21,6 +24,7 @@ import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.ShoppingCartBean;
import com.google.android.material.internal.ViewUtils;
import com.google.android.material.textfield.TextInputEditText;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import org.jetbrains.annotations.NotNull;
......@@ -44,12 +48,15 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Base
private String amountUnitStr;
private String estimateDeliveryTimeStr;
private ShippingTextWatcher shippingTextWatcher;
public ShoppingCartAdapter(Context context, @Nullable List<ShoppingCartBean> data) {
super(R.layout.item_shopping_cart, data);
this.context = context;
dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL_LIST);
amountUnitStr = context.getString(R.string.amount_string);
estimateDeliveryTimeStr = context.getString(R.string.estimate_delivery_time);
shippingTextWatcher = new ShippingTextWatcher();
}
@Override
......@@ -59,13 +66,16 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Base
TextView tvMinMinimumAmount = viewHolder.getView(R.id.tv_minimumAmount);
viewHolder.setText(R.id.rv_purchase_shopping_estimate_delivery_time, String.format(estimateDeliveryTimeStr, shoppingCartBean.getInitialShippingTime()));
setTvMinimumAmount(shoppingCartBean, tvMinMinimumAmount, viewHolder.getView(R.id.rv_purchase_shopping_minimum_tip));
// viewHolder.setText(R.id.tv_order_item_freight, shoppingCartBean.getFoodList());
//選中食品的總價
setTotalAmount(viewHolder, shoppingCartBean.getSelectFoodAmount());
//運費
viewHolder.setText(R.id.tv_order_item_freight, String.format(amountUnitStr, shoppingCartBean.getShipping()));
TextInputEditText etShipping = viewHolder.getView(R.id.tv_order_item_freight);
etShipping.removeTextChangedListener(shippingTextWatcher);
viewHolder.setText(R.id.tv_order_item_freight, MoneyUtil.formatDouble(shoppingCartBean.getShipping()));
shippingTextWatcher.setViewHolder(viewHolder);
etShipping.addTextChangedListener(shippingTextWatcher);
//實際應付金額
setActualAmount(viewHolder, shoppingCartBean.getSelectFoodAmount());
setActualAmount(viewHolder, MoneyUtil.sum(shoppingCartBean.getSelectFoodAmount(), shoppingCartBean.getShipping()));
//選中食品的種類
TextView tvFoodTypeNumber = viewHolder.getView(R.id.tv_order_item_food_type_total);
tvFoodTypeNumber.setText(String.valueOf(shoppingCartBean.getSelectSpeciesNum()));
......@@ -175,6 +185,47 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Base
}
}
private class ShippingTextWatcher implements TextWatcher {
BaseViewHolder viewHolder;
public void setViewHolder(BaseViewHolder viewHolder) {
this.viewHolder = viewHolder;
}
@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 (viewHolder != null) {
//需要修改實際應付金額和activity的總金額
//拿到現在的金額,減去之前的金額
double nowShipping = 0;
if (TextUtil.isNotEmptyOrNullOrUndefined(s)) {
nowShipping = Double.parseDouble(s.toString());
}
ShoppingCartBean shoppingCartBean = getData().get(viewHolder.getAdapterPosition());
//修改實際應付金額
setActualAmount(viewHolder, MoneyUtil.sum(shoppingCartBean.getSelectFoodAmount(), shoppingCartBean.getShipping()));
//通知activity修改
// getData().get(viewHolder.getAdapterPosition()).setShipping(Integer.parseInt());
}
}
}
/**
* 修改總金額
*/
......@@ -283,7 +334,7 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Base
double currentPrice = MoneyUtil.sum(cartBean.getSelectFoodAmount(), MoneyUtil.priceCalculation(unitPrice, foodQuantity));
cartBean.setSelectFoodAmount(currentPrice);
setTotalAmount(viewHolder, currentPrice);
setActualAmount(viewHolder, currentPrice);
setActualAmount(viewHolder, MoneyUtil.sum(currentPrice, cartBean.getShipping()));
//傳遞回去
if (onInfoChangeListener != null) {
onInfoChangeListener.onInfoChange(MoneyUtil.priceCalculation(unitPrice, foodQuantity), species);
......@@ -301,11 +352,13 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Base
private void minusTotalPrice(BaseViewHolder viewHolder, ShoppingCartBean cartBean, double unitPrice, int foodQuantity, int species) {
//供應商總價減去-這個食品的總價=等於現價
double currentPrice = MoneyUtil.sub(cartBean.getSelectFoodAmount(), MoneyUtil.priceCalculation(unitPrice, foodQuantity));
//修改選中食品的金額
cartBean.setSelectFoodAmount(currentPrice);
String amountStr = String.format(amountUnitStr, currentPrice);
//修改顯示總金額
setTotalAmount(viewHolder, currentPrice);
viewHolder.setText(R.id.tv_order_item_actual_pay_amount, amountStr);
//傳遞回去
//修改實際應付金額
setActualAmount(viewHolder, MoneyUtil.sum(currentPrice, cartBean.getShipping()));
//傳遞回去,由於是減少食品,所以金額為負
if (onInfoChangeListener != null) {
onInfoChangeListener.onInfoChange(-MoneyUtil.priceCalculation(unitPrice, foodQuantity), species);
}
......
......@@ -147,7 +147,7 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
public void loadBasicUnitAdapter(List<BasicUnitBean> basicUnitBeans) {
basicUnitAdapter = new BasicUnitAdapter(basicUnitBeans);
//獲取到基礎單位之後,才在標題欄中添加刪除按鈕
topBar.addRightImageButton(R.drawable.ic_white_delete,R.id.btn_delete).setOnClickListener(v -> {
topBar.addRightImageButton(R.drawable.ic_white_delete, R.id.btn_delete).setOnClickListener(v -> {
//刪除
basicUnitAdapter.toggleDelete();
});
......@@ -183,7 +183,7 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
});
basicUnitAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if(view.getId() == R.id.iv_delete_basic_unit){
if (view.getId() == R.id.iv_delete_basic_unit) {
//刪除單位
mPresenter.deleteUnitKey(basicUnitAdapter.getItem(position).getId(), position);
}
......@@ -193,8 +193,8 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
@Override
public void addBasicUnit(BasicUnitBean basicUnitBean) {
if (basicUnitAdapter != null) {
int index = basicUnitAdapter.getItemCount() - 1;
basicUnitAdapter.addData(Math.max(index, 0), basicUnitBean);
basicUnitAdapter.addData(0, basicUnitBean);
rvBasicUnitList.scrollToPosition(0);
}
}
......
package com.gingersoft.supply_chain.mvp.ui.fragment.order;
import android.app.Dialog;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......
......@@ -14,6 +14,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
......@@ -49,12 +50,16 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
TextView tvWarehouseDifference;
@BindView(R2.id.ed_warehouse_loss)
EditText edWarehouseLoss;
@BindView(R2.id.rv_warehouse_inventory_record)
RecyclerView rvRecord;
/**
* 食品總庫存
*/
private int foodNum;
private String foodNo;
private int pageIndex;
public static WarehousingInventoryFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean purchaseWarehousingOrderDetailsVosBean) {
WarehousingInventoryFragment fragment = new WarehousingInventoryFragment();
Bundle bundle = new Bundle();
......@@ -86,70 +91,89 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments != null) {
//獲取庫存盤點記錄
getWarehousingRecord();
int foodId = arguments.getInt(WarehouseDetailsFragment.FOOD_ID_KEY);
//食品編號
foodNo = arguments.getString(WarehouseDetailsFragment.FOOD_NO_KEY);
String foodName = arguments.getString(WarehouseDetailsFragment.FOOD_NAME_KEY);
//食品庫存總數
foodNum = arguments.getInt(WarehouseDetailsFragment.FOOD_NUM_KEY);
ivWarehouseImg.post(() -> {
ViewGroup.LayoutParams layoutParams = ivWarehouseImg.getLayoutParams();
layoutParams.height = ivWarehouseImg.getWidth();
layoutParams.width = ivWarehouseImg.getWidth();
ivWarehouseImg.setLayoutParams(layoutParams);
String foodImageUrl = arguments.getString(WarehouseDetailsFragment.FOOD_IMAGE_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(foodImageUrl)) {
GlideUtils.display(requireContext(), ivWarehouseImg, foodImageUrl);
} else {
ivWarehouseImg.setImageResource(R.drawable.img_small_default);
}
});
//加載食品圖片
loadFoodImage(arguments);
//初始化標題
initTopBar(supplyTopBar, foodName);
Button btnSave = supplyTopBar.addRightTextButton(R.string.str_save, R.id.id_save);
btnSave.setTextColor(getColor(R.color.white));
btnSave.setOnClickListener(mOnClickListener);
//庫存數量
tvWarehouseTotal.setText(String.valueOf(foodNum));
tvWarehouseDifference.setText(String.valueOf(foodNum));
edWarehouseLoss.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus && edWarehouseLoss.getText().toString().equals("0")) {
edWarehouseLoss.setText("");
}
});
edWarehouseLoss.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
initTopBar(arguments);
//初始化數量和編輯監聽
initEdit();
} else {
showMessage("獲取食材信息失敗,請稍候重試");
killMyself();
}
}
}
private void getWarehousingRecord() {
mPresenter.getWarehousingRecord(pageIndex);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
private void initEdit() {
//庫存數量
tvWarehouseTotal.setText(String.valueOf(foodNum));
//庫存差異
tvWarehouseDifference.setText(String.valueOf(foodNum));
edWarehouseLoss.setOnFocusChangeListener((v, hasFocus) -> {
//當輸入框獲得焦點時,數量為0,去掉0
if (hasFocus && edWarehouseLoss.getText().toString().equals("0")) {
edWarehouseLoss.setText("");
}
});
edWarehouseLoss.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 (TextUtil.isNotEmptyOrNullOrUndefined(s + "")) {
//用戶輸入的盤點數量
int inventoryNum = Integer.parseInt(s + "");
}
@Override
public void afterTextChanged(Editable s) {
if (TextUtil.isNotEmptyOrNullOrUndefined(s + "")) {
//用戶輸入的盤點數量
int inventoryNum = Integer.parseInt(s + "");
// if (inventoryNum > foodNum) {
// inventoryNum = foodNum;
// showMessage("不能大於庫存數");
// edWarehouseLoss.setText(String.valueOf(foodNum));
// edWarehouseLoss.setSelection(edWarehouseLoss.getText().length());
// }
tvWarehouseDifference.setText(String.valueOf(Math.abs(foodNum - inventoryNum)));
} else {
tvWarehouseDifference.setText(String.valueOf(foodNum));
}
tvWarehouseDifference.setText(String.valueOf(Math.abs(foodNum - inventoryNum)));
} else {
tvWarehouseDifference.setText(String.valueOf(foodNum));
}
});
}
});
}
private void initTopBar(Bundle arguments) {
String foodName = arguments.getString(WarehouseDetailsFragment.FOOD_NAME_KEY);
//初始化標題
initTopBar(supplyTopBar, foodName);
//添加保存按鈕
Button btnSave = supplyTopBar.addRightTextButton(R.string.str_save, R.id.id_save);
btnSave.setTextColor(getColor(R.color.white));
btnSave.setOnClickListener(mOnClickListener);
}
private void loadFoodImage(Bundle arguments) {
String foodImageUrl = arguments.getString(WarehouseDetailsFragment.FOOD_IMAGE_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(foodImageUrl)) {
GlideUtils.display(requireContext(), ivWarehouseImg, foodImageUrl);
} else {
showMessage("獲取食材信息失敗,請稍候重試");
killMyself();
ivWarehouseImg.setImageResource(R.drawable.img_small_default);
}
}
private View.OnClickListener mOnClickListener = v -> {
if (v.getId() == R.id.id_save) {
//保存,調用庫存損耗
......@@ -174,4 +198,9 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
public void updateSuccess() {
setFragmentResult(RESULT_OK, null);
}
@Override
public void loadRecord() {
}
}
......@@ -3,94 +3,170 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/color_f0"
android:orientation="vertical">
<include layout="@layout/supply_chain_top_bar" />
<ImageView
android:id="@+id/iv_warehouse_img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_36"
android:layout_marginRight="@dimen/dp_36" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_5"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="庫存數量:"
android:textColor="@color/color_66"
android:textSize="@dimen/dp_17" />
<ImageView
android:id="@+id/iv_warehouse_img"
android:layout_width="@dimen/dp_77"
android:layout_height="@dimen/dp_77"
android:layout_margin="@dimen/dp_10" />
<TextView
android:id="@+id/tv_warehouse_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_17"
android:textStyle="bold"
tools:text="100" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_6"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_6"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="庫存差異:"
android:textColor="@color/color_66"
android:textSize="@dimen/dp_17" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_warehouse_difference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_17"
android:textStyle="bold"
tools:text="+100" />
<TextView
style="@style/WareHouse_Details_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="庫存:" />
<TextView
android:id="@+id/tv_warehouse_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/other_order_details_sure_btn_color"
android:textSize="@dimen/dp_19"
tools:text="100" />
<TextView
android:id="@+id/tv_food_unit"
style="@style/WareHouse_Details_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="盒" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/WareHouse_Details_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="庫存差異:" />
<TextView
android:id="@+id/tv_warehouse_difference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_17"
android:textStyle="bold"
tools:text="+100" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/WareHouse_Details_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="盤點庫存:"
android:textSize="@dimen/dp_15" />
<EditText
android:id="@+id/ed_warehouse_loss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_square_edit_border_aa"
android:gravity="center"
android:hint="請輸入"
android:inputType="number"
android:paddingTop="@dimen/dp_5"
android:paddingBottom="@dimen/dp_5"
android:text="0"
android:textColor="@color/theme_333_color"
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_18"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_20"
android:layout_height="@dimen/dp_38"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="盤點庫存:"
android:textColor="@color/color_66"
android:textSize="@dimen/dp_17" />
<EditText
android:id="@+id/ed_warehouse_loss"
android:layout_width="@dimen/dp_86"
android:layout_height="wrap_content"
android:background="@drawable/shape_square_edit_border_3c"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:background="@color/theme_color"
android:gravity="center"
android:hint="請輸入"
android:inputType="number"
android:paddingTop="@dimen/dp_9"
android:paddingBottom="@dimen/dp_9"
android:text="0"
android:textColor="@color/theme_333_color"
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
android:text="用戶名"
android:textColor="@color/white"
android:textSize="@dimen/dp_12" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_1"
android:layout_weight="0.3"
android:background="@color/theme_color"
android:gravity="center"
android:text="盤點"
android:textColor="@color/white"
android:textSize="@dimen/dp_12" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_1"
android:layout_weight="0.55"
android:background="@color/theme_color"
android:gravity="center"
android:text="操作日期"
android:textColor="@color/white"
android:textSize="@dimen/dp_12" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_warehouse_inventory_record"
android:layout_width="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
......@@ -11,7 +11,7 @@
android:layout_marginLeft="@dimen/dp_3"
android:layout_marginRight="@dimen/dp_3"
android:background="@color/white"
app:cardCornerRadius="@dimen/dp_8"
app:cardCornerRadius="@dimen/dp_4"
app:cardUseCompatPadding="true"
app:elevation="@dimen/dp_4">
......
......@@ -26,9 +26,9 @@
<CheckBox
android:id="@+id/cb_order_item_all_select"
android:layout_width="0dp"
android:layout_weight="6"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_12"
android:layout_weight="6"
android:button="@drawable/selector_checkbox"
android:textColor="@color/black"
android:textSize="@dimen/dp_16"
......@@ -41,10 +41,10 @@
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:layout_weight="4"
android:textSize="@dimen/dp_14"
android:gravity="right"
android:text="@string/minimumAmount"
android:textColor="@color/required_color" />
android:textColor="@color/required_color"
android:textSize="@dimen/dp_14" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
......@@ -117,11 +117,21 @@
android:textSize="@dimen/dp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$"
android:textColor="@color/required_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/tv_order_item_freight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="$0"
android:background="@null"
android:inputType="numberDecimal"
android:text="0"
android:textColor="@color/required_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
......
......@@ -79,7 +79,6 @@
android:id="@+id/slider_food_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.PrimaryPalette.Red"
android:valueFrom="0"
android:valueTo="11"
android:stepSize="1" />
......
......@@ -8,8 +8,8 @@
<item name="colorAccent">@color/table_colorAccent</item>
</style>
<style name="ThemeOverlay.PrimaryPalette.Red" parent="">
<item name="colorPrimary">#e53935</item>
<item name="colorPrimaryDark">#ab000d</item>
</style>
<!-- <style name="ThemeOverlay.PrimaryPalette.Red" parent="">-->
<!-- <item name="colorPrimary">#e53935</item>-->
<!-- <item name="colorPrimaryDark">#ab000d</item>-->
<!-- </style>-->
</resources>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_4" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/color_aaa" />
</shape>
\ No newline at end of file
......@@ -55,13 +55,14 @@ public class InputProvider<T extends InfoMultiBean> extends MyBaseItemProvider<T
InputViewHolder viewHolder = (InputViewHolder) baseViewHolder;
MultiInputBean infoMultiBean = (MultiInputBean) t;
viewHolder.removeTextWatcher();
TextInputEditText editText = baseViewHolder.getView(R.id.ed_multi_value);
editText.setError(null);
initEditFocusable(infoMultiBean, editText);
//設置輸入限制
setFilters(editText, infoMultiBean);
//刷新數據
viewHolder.updateView(infoMultiBean);
viewHolder.updateView();
//設置輸入框的值
initEditText(editText, infoMultiBean.getShowValue(), infoMultiBean.getHintText());
//添加焦點監聽
......@@ -95,6 +96,8 @@ public class InputProvider<T extends InfoMultiBean> extends MyBaseItemProvider<T
}
private void setFilters(EditText editText, MultiInputBean multiSelectBean) {
//先清空值,再
editText.setText("");
//輸入攔截器
editText.setFilters(multiSelectBean.getInputFilters());
//輸入類型限制
......@@ -110,17 +113,19 @@ public class InputProvider<T extends InfoMultiBean> extends MyBaseItemProvider<T
super(view);
ButterKnife.bind(this, view);
editText = view.findViewById(R.id.ed_multi_value);
editText.addTextChangedListener(inputTextWatcher);
}
public void updateView(MultiInputBean infoMultiBean) {
public void removeTextWatcher() {
editText.removeTextChangedListener(inputTextWatcher);
}
public void updateView() {
editText.addTextChangedListener(inputTextWatcher);
inputTextWatcher.inputViewHolder = this;
inputTextWatcher.infoMultiBean = infoMultiBean;
}
}
class InputTextWatcher implements TextWatcher {
MultiInputBean infoMultiBean;
InputViewHolder inputViewHolder;
@Override
......@@ -133,7 +138,8 @@ public class InputProvider<T extends InfoMultiBean> extends MyBaseItemProvider<T
@Override
public void afterTextChanged(Editable s) {
if (infoMultiBean != null) {
if (inputViewHolder != null) {
MultiInputBean infoMultiBean = (MultiInputBean) getAdapter().getItem(inputViewHolder.getAdapterPosition());
infoMultiBean.setShowValue(s + "");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment