Commit 2194c6e3 by 宁斌

Merge branch 'dev' of http://gitlab.ricepon.com/ningbin/GSA-Cloud into dev

 Conflicts:
	library-common/build.gradle
parents 476dc755 09fb6511
......@@ -63,14 +63,8 @@ public class OrderListPresenter extends BasePresenter<OrderListContract.Model, O
}
private List<OrderList.DataBeanX.DataBean> orderList = new ArrayList<>();
private Disposable disposable;
public void getOrderList(int restaurantId, int page, String status, String type, String phone) {
if (disposable != null) {
if (!disposable.isDisposed()) {
return;
}
}
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", restaurantId + "")
.add("page", page + "")
......@@ -91,13 +85,10 @@ public class OrderListPresenter extends BasePresenter<OrderListContract.Model, O
@Override
public void onSubscribe(Disposable d) {
super.onSubscribe(d);
disposable = d;
}
@Override
public void onNext(@NonNull OrderList info) {
disposable.dispose();
disposable = null;
if (page == 1) {
orderList.clear();
}
......
......@@ -53,23 +53,16 @@ import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.popup.QMUIPopup;
import com.qmuiteam.qmui.widget.popup.QMUIPopups;
import com.xuexiang.rxutil2.exception.RxException;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.subsciber.BaseSubscriber;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import static androidx.fragment.app.FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -85,7 +78,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
TabLayout tabLayout;
@BindView(R2.id.tv_balance)
TextView tvBalance;
@BindView(R2.id.cold_chain_takeaway_progress)
ProgressBar mTakeAwayPb;
@BindView(R2.id.tv_cold_chain_takeaway_num)
......@@ -161,7 +153,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
initService();
initHearBroadcast();
autoReceivingOrders.setChecked(RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false));
autoReceivingOrders.setOnCheckedChangeListener((buttonView, isChecked) -> {
RestaurantExpandInfoUtils.setValue(ExpandConstant.FrozenChainAutoOrder, isChecked);
if (autoOrderDisposable != null && !autoOrderDisposable.isDisposed()) {
......@@ -174,6 +165,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
mPresenter.stopAutoReceivingOrders();
}
});
autoReceivingOrders.setChecked(RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false));
}
public void getNumByOrderTypeInvoke(String functionName) {
......@@ -261,9 +253,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
if (type == 3 || type == 6 || type == 7) {
getNumByOrderTypeInvoke("loadNumber");
}
if (autoReceivingOrders.isChecked()) {
mPresenter.startToBeConfirmedOrderList(restaurantId);
}
});
bind.execute(aBoolean -> null);
bind.setJumpActivity(ColdChainMainActivity.class);
......
......@@ -200,7 +200,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
super.onResume();
initFuncationData();
if (((int) SPUtils.get("isFormal", 0)) != 0) {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this) + "\u1500Beta");
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this) + "\u3000Beta");
} else {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this));
}
......
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_20"
android:gravity="center"
......@@ -18,10 +18,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLength="4"
android:layout_marginTop="@dimen/dp_8"
android:text="餐檯模式"
android:singleLine="true"
android:ellipsize="marquee"
android:ellipsize="end"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_12" />
......
......@@ -151,8 +151,9 @@ public class PrintServe extends PrinterRoot<PrintServingPaperContent> {
//訂單信息
layout.addView(getDiningTableOrderInfo(mContext, "餐檯:" + mPrintServingPaperContent.getTableName(), "人數:" + mPrintServingPaperContent.getPerson(), orderNo, "日期:" + TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)));
layout.addView(getLine(mContext));
//食品
layout.addView(getDiningFoodList(mContext, foodItemList, printerDeviceBean, 0, false));
//打印紙
layout.addView(getLine(mContext));
layout.addView(getTextView(mContext, "Thank you!", Gravity.CENTER_HORIZONTAL, getDimensionPixelSize(mContext, R.dimen.dp_8)));
layout.addView(getTextView(mContext, TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT), Gravity.CENTER_HORIZONTAL, getDimensionPixelSize(mContext, R.dimen.dp_8)));
......
......@@ -76,6 +76,10 @@ import com.joe.print.mvp.ui.adapter.BillAdapter;
import com.joe.print.mvp.ui.adapter.BillItemAdapter;
import com.joe.print.mvp.ui.adapter.BillTypeAdapter;
import com.joe.print.mvp.ui.adapter.FoodAdapter;
import com.joe.print.mvp.ui.view.BillItemView;
import com.joe.print.mvp.ui.view.BillTypeView;
import com.joe.print.mvp.ui.view.BillView;
import com.joe.print.mvp.ui.view.PrintFoodView;
import com.sunmi.peripheral.printer.InnerResultCallbcak;
import java.io.IOException;
......@@ -732,7 +736,8 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
}
protected View getTakeawayBillInfoView(Context mContext, List<PrintBillItem> data) {
return getVerticalRecyclerView(mContext, new BillItemAdapter(data));
// return getVerticalRecyclerView(mContext, new BillItemAdapter(data));
return new BillItemView(mContext, data);
}
protected void addTakeawayPayViews(Context mContext, ViewGroup parent, List<OrderDetails.DataBean.PayMultiple> payMultiples, double payAmount) {
......@@ -825,40 +830,63 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
}
/**
* 獲取食品列表
* 結賬單、印單。外送都用這個
* @param mContext
* @param foodList
* @param deviceBean
* @param foodList 食品信息
* @param deviceBean 打印設備
* @param type 0 食品清單,1 結賬單
* @param showPrice 是否顯示價格
* @return
*/
public View getDiningFoodList(Context mContext, List<PrintFoodItem> foodList, PrinterDeviceBean deviceBean, int type, boolean showPrice) {
// List<OrderDetail> newsFoodList = new ArrayList<>();
// for (OrderDetail orderDetail : foodList) {
// //如果食品設置了0元不打印並且食品等於0元,或者設置了不打印到單,就不打印
// if (!(orderDetail.getPrintToBill() == 0 && orderDetail.getPrice() == 0)
// || OrderDetail.isPrint((int) orderDetail.getPrintTo(), type)) {
// newsFoodList.add(orderDetail);
// }
// }
return getVerticalRecyclerView(mContext, new FoodAdapter(foodList, deviceBean, showPrice));
//// List<OrderDetail> newsFoodList = new ArrayList<>();
//// for (OrderDetail orderDetail : foodList) {
//// //如果食品設置了0元不打印並且食品等於0元,或者設置了不打印到單,就不打印
//// if (!(orderDetail.getPrintToBill() == 0 && orderDetail.getPrice() == 0)
//// || OrderDetail.isPrint((int) orderDetail.getPrintTo(), type)) {
//// newsFoodList.add(orderDetail);
//// }
//// }
// return getVerticalRecyclerView(mContext, new FoodAdapter(foodList, deviceBean, showPrice));
return new PrintFoodView(mContext, foodList, deviceBean, showPrice);
}
/**
* 結賬單和印單
* @param mContext
* @param billingBeans
* @return
*/
public View getDiningBillInfo(Context mContext, List<BillingBean> billingBeans) {
return getVerticalRecyclerView(mContext, new BillAdapter(billingBeans));
// return getVerticalRecyclerView(mContext, new BillAdapter(billingBeans));
return new BillView(mContext, billingBeans);
}
/**
* 結賬單,支付方式
* @param mContext
* @param payBillMoneys 支付方式數據
* @return
*/
public View getDiningBillPayMethod(Context mContext, List<PrintBillItem> payBillMoneys) {
return getVerticalRecyclerView(mContext, new BillTypeAdapter(payBillMoneys));
// return getVerticalRecyclerView(mContext, new BillTypeAdapter(payBillMoneys));
return new BillTypeView(mContext, payBillMoneys);
}
/**
* 不用recyclerview,recyclerview可能會導致食品顯示不出來
*
* @param mContext
* @param adapter
* @return
*/
@Deprecated
public View getVerticalRecyclerView(Context mContext, RecyclerView.Adapter adapter) {
RecyclerView recyclerView = new RecyclerView(mContext);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setAdapter(adapter);
return recyclerView;
}
public View getAmountText(Context mContext, String text) {
......
......@@ -121,10 +121,6 @@ public class FoodAdapter extends BaseQuickAdapter<PrintFoodItem, BaseViewHolder>
tvNum.setTypeface(null, Typeface.NORMAL);
tvPrice.setTypeface(null, Typeface.NORMAL);
}
// tvFoodName.setTypeface(null, Typeface.BOLD_ITALIC);
// tvFoodName.setTypeface(null, Typeface.BOLD);
// tvFoodName.setTypeface(null, Typeface.ITALIC);
// tvFoodName.setTypeface(null, Typeface.NORMAL);
tvNum.setText("X" + item.getNum());
tvPrice.setText("$" + item.getPrice());
}
......
package com.joe.print.mvp.ui.view;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.gingersoft.gsa.cloud.print.bean.base.PrintFoodItem;
import com.joe.print.R;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/30
* Time: 11:00
* Use:
*/
public class BillItemView extends LinearLayout {
private List<PrintBillItem> data;
public BillItemView(Context context, List<PrintBillItem> data) {
super(context);
this.data = data;
}
private void init() {
for (PrintBillItem item : data) {
View view = View.inflate(getContext(), R.layout.print_bill_adapter_item_bill, null);
TextView billNam = view.findViewById(R.id.print_bill_name);
TextView billValue = view.findViewById(R.id.print_bill_value);
billNam.setText(item.getBillName());
billValue.setText(item.getBillAmount());
addView(view);
}
}
}
package com.joe.print.mvp.ui.view;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.joe.print.R;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/30
* Time: 11:16
* Use:結賬單,支付方式的view
*/
public class BillTypeView extends LinearLayout {
private List<PrintBillItem> data;
public BillTypeView(Context context, List<PrintBillItem> data) {
super(context);
this.data = data;
init();
}
private void init() {
for (PrintBillItem item : data) {
View view = View.inflate(getContext(), R.layout.base_print_item_bill_type, null);
TextView tvBillTotalText = view.findViewById(R.id.tv_total_amount_text);
TextView tvBillTotal = view.findViewById(R.id.tv_total_amount);
tvBillTotalText.setText(item.getBillName());
tvBillTotal.setText("$" + item.getBillAmount());
addView(view);
}
}
}
package com.joe.print.mvp.ui.view;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.joe.print.R;
import com.joe.print.mvp.model.bean.BillingBean;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/30
* Time: 11:12
* Use:結賬單和印單的賬單信息
*/
public class BillView extends LinearLayout {
private List<BillingBean> data;
public BillView(Context context, List<BillingBean> data) {
super(context);
this.data = data;
init();
}
private void init() {
for (BillingBean item : data) {
View view = View.inflate(getContext(), R.layout.base_print_bill_adapter_item_bill, null);
TextView tvBillTotalText = view.findViewById(R.id.tv_bill_total_text);
TextView tvBillTotal = view.findViewById(R.id.tv_bill_total);
tvBillTotalText.setText(item.getOptionName());
if (item.getTotalAmount() < 0) {
tvBillTotal.setText("-$" + Math.abs(item.getTotalAmount()));
} else if (item.getTotalAmount() > 0) {
tvBillTotal.setText("$" + item.getTotalAmount());
}
addView(view);
}
}
}
\ No newline at end of file
package com.joe.print.mvp.ui.view;
import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.bean.base.PrintFoodItem;
import com.joe.print.R;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/30
* Time: 10:40
* Use:
*/
public class PrintFoodView extends LinearLayout {
private int foodFontSize = 24;
private int modifierFontSize = 24;
private int foodIsBold = 2;
private int modifierIsBold = 2;
private int foodIsItalic = 2;
private int modifierIsItalic = 2;
private int numberIsFlip = 2;//熱敏打印沒有顏色,翻轉用不了
private boolean showPrice = true;
private List<PrintFoodItem> data;
public PrintFoodView(Context context, List<PrintFoodItem> data, PrinterDeviceBean deviceBean, boolean showPrice) {
super(context);
this.showPrice = showPrice;
this.data = data;
init(deviceBean);
}
public void init(PrinterDeviceBean deviceBean) {
try {
this.foodFontSize = Integer.parseInt(deviceBean.getFoodFont()) * 2;//36
this.modifierFontSize = Integer.parseInt(deviceBean.getModifierFont()) * 2;
} catch (NumberFormatException e) {
e.printStackTrace();
}
this.foodIsBold = deviceBean.getFoodIsBold();
this.modifierIsBold = deviceBean.getModifierIsBold();
this.foodIsItalic = deviceBean.getFoodIsItalic();
this.modifierIsItalic = deviceBean.getModifierIsItalic();
this.numberIsFlip = deviceBean.getNumberIsFlip();
initView();
}
private void initView() {
for (PrintFoodItem item : data) {
View view = View.inflate(getContext(), R.layout.print_item_food, null);
TextView tvFoodName = view.findViewById(R.id.tv_food_name);
TextView tvNum = view.findViewById(R.id.tv_food_quantity);
TextView tvPrice = view.findViewById(R.id.tv_food_price);
if (showPrice) {
tvPrice.setVisibility(View.VISIBLE);
} else {
tvPrice.setVisibility(View.GONE);
}
boolean isBold, isItalic;
if (item.getItemType() == 2) {
//細項,縮進
tvFoodName.setText("\u3000" + item.getName());
tvFoodName.setTextSize(modifierFontSize);
tvNum.setTextSize(modifierFontSize);
tvPrice.setTextSize(modifierFontSize);
isBold = modifierIsBold == 1;
isItalic = modifierIsItalic == 1;
} else if (item.getItemType() == 3) {
//細項,縮進
tvFoodName.setText("\u3000\u3000" + item.getName());
tvFoodName.setTextSize(modifierFontSize);
tvNum.setTextSize(modifierFontSize);
tvPrice.setTextSize(modifierFontSize);
isBold = modifierIsBold == 1;
isItalic = modifierIsItalic == 1;
} else {
tvFoodName.setText(item.getName());
tvFoodName.setTextSize(foodFontSize);
tvNum.setTextSize(foodFontSize);
tvPrice.setTextSize(foodFontSize);
isBold = foodIsBold == 1;
isItalic = foodIsItalic == 1;
}
if (isBold && isItalic) {
tvFoodName.setTypeface(null, Typeface.BOLD_ITALIC);
tvNum.setTypeface(null, Typeface.BOLD_ITALIC);
tvPrice.setTypeface(null, Typeface.BOLD_ITALIC);
} else if (isBold) {
tvFoodName.setTypeface(null, Typeface.BOLD);
tvNum.setTypeface(null, Typeface.BOLD);
tvPrice.setTypeface(null, Typeface.BOLD);
} else if (isItalic) {
tvFoodName.setTypeface(null, Typeface.ITALIC);
tvNum.setTypeface(null, Typeface.ITALIC);
tvPrice.setTypeface(null, Typeface.ITALIC);
} else {
tvFoodName.setTypeface(null, Typeface.NORMAL);
tvNum.setTypeface(null, Typeface.NORMAL);
tvPrice.setTypeface(null, Typeface.NORMAL);
}
tvNum.setText("X" + item.getNum());
tvPrice.setText("$" + item.getPrice());
addView(view);
}
}
}
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/25
* Time: 11:54
* Use: 庫存消耗原因實體
*/
@Data
public class ConsumeReasonBean {
private int id;
private String description;
}
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/26
* Time: 11:23
* Use:庫存消耗流水
*/
@Data
public class ConsumeWareHousingBean {
private String name;
private String unitName;
private String foodCategoryName;
private String dates;
private String description;
private int quantity;
}
......@@ -41,7 +41,6 @@ public class FoodCategoryResultBean {
* createTime : 1605944097385
* updateTime : 1605944097044
*/
private int id;
private int uid;
private int brandId;
......
package com.gingersoft.supply_chain.mvp.bean;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
......@@ -12,7 +13,7 @@ import lombok.Data;
* Use: 下單頁面的分類
*/
@Data
public class OrderCategoryBean {
public class OrderCategoryBean implements Serializable {
private boolean success;
private long sysTime;
......@@ -25,5 +26,13 @@ public class OrderCategoryBean {
private String name;
private int parentId;
private List<FoodCategoryTrees> foodCategoryTrees;
public FoodCategoryTrees() {
}
public FoodCategoryTrees(int id) {
this.id = id;
}
}
}
......@@ -2,6 +2,11 @@ package com.gingersoft.supply_chain.mvp.bean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.List;
......@@ -18,7 +23,7 @@ import lombok.Data;
public class PurchaseFoodBean implements Serializable {
private static final long serialVersionUID = 7084280906070243339L;
public static final String CATEGORY_DIVIDER = "-";
private int id;
private Integer id;
private String supplierName;
private String images;
private String foodNo;
......@@ -59,12 +64,12 @@ public class PurchaseFoodBean implements Serializable {
/**
* 分類id
*/
private int foodCategoryId;
private Integer foodCategoryId;
/**
* 所屬供應商id
*/
private int supplierId;
private Integer supplierId;
/**
* 是否選中
*/
......@@ -72,7 +77,6 @@ public class PurchaseFoodBean implements Serializable {
/**
* 是否刪除
* {@link Constant.DELETE,Constant.NORMAL}
*
*/
private int deletes;
private int restaurantId;
......@@ -83,7 +87,7 @@ public class PurchaseFoodBean implements Serializable {
* 預警的信息,獲取詳情接口返回的不是對象,傳遞給後台時需要轉為對象
* 所以需要在這裡建這幾個字段,用於接收
*/
private int inventoryWarningId;
private Integer inventoryWarningId;
private boolean reviews;
private int minimumInventory;
private int shelfLife;
......@@ -93,8 +97,8 @@ public class PurchaseFoodBean implements Serializable {
* 庫存預警 模塊
*/
@Data
public static class InventoryAlarm {
private int id;
public static class InventoryAlarm implements Serializable {
private Integer id;
/**
* 是否審核 0否 1是
*/
......@@ -125,4 +129,26 @@ public class PurchaseFoodBean implements Serializable {
public void setChecked(boolean checked) {
isChecked = checked;
}
/**
* 复制一個類
* @param old
* @return
*/
public static Object copy(Object old) {
Object clazz = null;
try {
// 写入字节流
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(old);
// 读取字节流
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
clazz = (Object) ois.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return clazz;
}
}
......@@ -35,7 +35,22 @@ public class PurchaseOrderDetailsBean {
private double totalAmount;
private int shipping;
private double actualPayment;
/**
* 入库单号
*/
private String warehousingOrderNo;
/**
* 入庫備註
*/
private String warehousingRemarks;
/**
* 下採購單時的備註
*/
private String remarks;
/**
* 收貨時上傳的圖片,可以多張,用逗號隔開
*/
private String files;
/**
* 狀態:0全部 1待收貨 2部分收貨 3已完成 4拒收
......@@ -101,6 +116,9 @@ public class PurchaseOrderDetailsBean {
*/
private int foodQuantity;
private double foodPrice;
/**
* 看上面{@link WAIT_RECEIVED}
*/
private int status;
private int purchaseFoodId;
private String images;
......@@ -135,7 +153,7 @@ public class PurchaseOrderDetailsBean {
/**
* 已入庫數量
*/
private int warehousingQuantity;
private double warehousingQuantity;
// List<DeputyUnitBean> deputyUnitBeans;
/**
* 沒有入庫單號,暫時用訂單編號
......
......@@ -83,14 +83,15 @@ public class WareHouseListBean {
* foodAmount : 267
*/
private int id;
private String foodNo;
private String name;
private String cateName;
private String supplierName;
private String basicUnitName;
private String foodCategoryName;
// private String supplierName;
private String unitName;
private double foodPrice;
private int foodNum;
private double foodAmount;
private String images;
}
}
}
package com.gingersoft.supply_chain.mvp.bean;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
......@@ -13,32 +14,67 @@ import lombok.Data;
*/
@Data
public class WarehouseDetailsBean {
/**
* foodNum : 151
* purchaseWarehousingOrderDetailsContents : [{"name":"去微软","purchase":"採購入庫","orderNo":"JK11820389311","foodQuantity":17,"totalPrice":102,"createTime":2021,"warningDays":""},{"name":"去微软","purchase":"採購入庫","orderNo":"JK11820389311","foodQuantity":17,"totalPrice":102,"createTime":2021,"warningDays":""}]
* name : 去微软
* purchase : 採購入庫
* orderNo : JK11820389311
* foodQuantity : 17
* totalPrice : 102.0
* createTime : 2021
* warningDays :
*/
private String name;
private String purchase;
private String orderNo;
private double foodQuantity;
private double totalPrice;
// private String createTime;
private String supplierName;
/**
* 單位
*/
private String unitName;
private String foodCategoryName;
/**
* 入庫時間
*/
private String warehousingTime;
/**
* 採購時間
*/
private String images;
private int foodNum;
private List<PurchaseWarehousingOrderDetailsContentsBean> purchaseWarehousingOrderDetailsContents;
private String purchaseTime;
/**
* 還有多少天過期,如果是負的,則是已經過期了
*/
private int distanceExpiresTime;
/**
* 預警天數
*/
private int warningDays;
/**
* 消耗狀態,1從未被消耗,2消耗了一部分,3完全消耗
*/
private int consumeStatus;
public final static int WAREHOUSE_STATE_NEVER_CONSUMED = 1;
public final static int WAREHOUSE_STATE_PART_CONSUMED = 2;
public final static int WAREHOUSE_STATE_ALL_CONSUMED = 3;
public static WarehouseDetailsBean getWarehousingByConsume(ConsumeWareHousingBean consumeWareHousingBean) {
WarehouseDetailsBean warehousingBean = new WarehouseDetailsBean();
warehousingBean.name = consumeWareHousingBean.getName();
warehousingBean.unitName = consumeWareHousingBean.getUnitName();
warehousingBean.foodCategoryName = consumeWareHousingBean.getFoodCategoryName();
warehousingBean.purchase = consumeWareHousingBean.getDescription();
warehousingBean.foodQuantity = consumeWareHousingBean.getQuantity();
warehousingBean.purchaseTime = consumeWareHousingBean.getDates();
return warehousingBean;
}
@Data
public static class PurchaseWarehousingOrderDetailsContentsBean {
/**
* name : 去微软
* purchase : 採購入庫
* orderNo : JK11820389311
* foodQuantity : 17
* totalPrice : 102.0
* createTime : 2021
* warningDays :
*/
private String name;
private String purchase;
private String orderNo;
private int foodQuantity;
private double totalPrice;
private int createTime;
private String warningDays;
public static List<WarehouseDetailsBean> getWarehousingByConsumes(List<ConsumeWareHousingBean> consumeWareHousingBeans) {
List<WarehouseDetailsBean> warehousings = new ArrayList<>();
for (ConsumeWareHousingBean consumeWareHousingBean : consumeWareHousingBeans) {
warehousings.add(getWarehousingByConsume(consumeWareHousingBean));
}
return warehousings;
}
}
......@@ -6,6 +6,9 @@ import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import java.util.Map;
import lombok.NonNull;
import okhttp3.FormBody;
/**
* @author 宇航.
* User: admin
......@@ -16,8 +19,12 @@ import java.util.Map;
public class Constant {
public static final int PAGE_SIZE = 10;
public static final int PURCHASE_FOOD_MAX = 9999;
/**
* 庫存消耗——盤點消耗的id
*/
public static final int INVENTORY_CONSUME_ID = 5;
public static final int UPDATE = 2;
public static final int DELETE = 1;
public static final int NORMAL = 0;
/**
......@@ -37,7 +44,6 @@ public class Constant {
public static final String IMG_UPLOAD_LOADING = "圖片上傳中...";
public static final String IMG_UPLOAD_FAIL = "圖片上傳失敗,請稍後重試";
public static final String NULL_INFO_ERROR = "未獲取到數據,請退出後重試";
public static final String SAVE_LOADING = "保存中...";
public static final String SAVE_SUCCESS = "保存成功";
......@@ -49,14 +55,23 @@ public class Constant {
public static final String DELETE_LOADING = "刪除中...";
public static final String DELETE_SUCCESS = "刪除成功";
public static final String DELETE_FAIL = "刪除失敗,請稍後重試";
public static void addBrandId(Map<String, Object> map) {
public static void addBrandId(@NonNull Map<String, Object> map) {
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
}
public static void addRestaurantId(Map<String, Object> map) {
public static void addRestaurantId(@NonNull Map<String, Object> map) {
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
}
public static void addBrandId(@NonNull FormBody.Builder builder) {
builder.add("brandId", String.valueOf(RestaurantInfoManager.newInstance().getBrandId()));
}
public static void addRestaurantId(@NonNull FormBody.Builder builder) {
builder.add("restaurantId", String.valueOf(RestaurantInfoManager.newInstance().getRestaurantId()));
}
public static void addPageSize(Map<String, Object> map) {
map.put("pageSize", PAGE_SIZE);
}
......
package com.gingersoft.supply_chain.mvp.content;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Observable;
/**
* @author 宇航.
......@@ -22,8 +25,6 @@ public class SupplyShoppingCart {
private static SupplyShoppingCart shoppingCart;
private int goodsNumber = 0;
public static SupplyShoppingCart getInstance() {
if (shoppingCart == null) {
shoppingCart = new SupplyShoppingCart();
......@@ -35,12 +36,120 @@ public class SupplyShoppingCart {
if (cartFoods == null) {
cartFoods = new ArrayList<>();
}
if (cartFoods.size() != goodsNumber) {
goodsNumber = cartFoods.size();
}
return cartFoods;
}
public void clear() {
if (cartFoods == null) {
return;
}
cartFoods.clear();
cartFoods = null;
}
public void removeFoodsByFoodId(int foodId) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
//刪除供應商成功後,需要從購物車數據中將這個供應商的食材都刪除掉
List<PurchaseFoodBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
Iterator<PurchaseFoodBean> iterator = cartFoods.iterator();
while (iterator.hasNext()) {
PurchaseFoodBean next = iterator.next();
if (next.getId() != null && next.getId() == foodId) {
iterator.remove();
break;
}
}
return null;
}
});
}
public void removeFoodsBySupplier(int supplierId) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
//刪除供應商成功後,需要從購物車數據中將這個供應商的食材都刪除掉
List<PurchaseFoodBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
Iterator<PurchaseFoodBean> iterator = cartFoods.iterator();
while (iterator.hasNext()) {
PurchaseFoodBean next = iterator.next();
if (next.getSupplierId() != null && next.getSupplierId() == supplierId) {
iterator.remove();
}
}
return null;
}
});
}
public void removeFoodsByCategoryId(int categoryId) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
//刪除供應商成功後,需要從購物車數據中將這個供應商的食材都刪除掉
List<PurchaseFoodBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
Iterator<PurchaseFoodBean> iterator = cartFoods.iterator();
while (iterator.hasNext()) {
PurchaseFoodBean next = iterator.next();
if (next.getFoodCategoryId() != null && next.getFoodCategoryId() == categoryId) {
iterator.remove();
}
}
return null;
}
});
}
public void removeFoodsByCategoryTress(OrderCategoryBean.FoodCategoryTrees foodCategoryTrees) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
//刪除分類成功後,需要從購物車數據中將這個分類的食材都刪除掉
List<PurchaseFoodBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
Iterator<PurchaseFoodBean> iterator = cartFoods.iterator();
while (iterator.hasNext()) {
PurchaseFoodBean next = iterator.next();
if (next.getFoodCategoryId() != null && next.getFoodCategoryId() == foodCategoryTrees.getId()) {
iterator.remove();
}
}
//分類中的刪除完了,需要刪除分類下子分類的食材
List<OrderCategoryBean.FoodCategoryTrees> childCategory = foodCategoryTrees.getFoodCategoryTrees();
if (childCategory != null) {
//遍歷二級分類
for (OrderCategoryBean.FoodCategoryTrees categoryTrees : childCategory) {
for (PurchaseFoodBean cartFood : cartFoods) {
if (cartFood.getFoodCategoryId() == categoryTrees.getId()) {
cartFoods.remove(cartFood);
break;
}
}
//對三級分類進行遍歷
List<OrderCategoryBean.FoodCategoryTrees> thirdCategory = categoryTrees.getFoodCategoryTrees();
removeFoodsByCategoryTress(thirdCategory);
}
}
return null;
}
});
}
public void removeFoodsByCategoryTress(List<OrderCategoryBean.FoodCategoryTrees> thirdCategory) {
if (thirdCategory != null) {
for (OrderCategoryBean.FoodCategoryTrees trees : thirdCategory) {
for (PurchaseFoodBean cartFood : cartFoods) {
if (cartFood.getFoodCategoryId() == trees.getId()) {
cartFoods.remove(cartFood);
}
}
}
}
}
public void setCartFoods(List<PurchaseFoodBean> cartFoods) {
SupplyShoppingCart.cartFoods = cartFoods;
}
......
......@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
......@@ -27,19 +29,54 @@ import okhttp3.RequestBody;
public interface CategoryContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadCategoryInfo(List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list, int hierarchy);
/**
* 加載一級級分類,用於新增、修改、刪除分類後,刷新頁面
*
* @param data 分類
*/
void loadCategoryInfo(List<OrderCategoryBean.FoodCategoryTrees> data);
void refreshInfo(int hierarchy, int position);
/**
* 加載二級分類,用於新增、修改、刪除二級分類後,刷新頁面
*
* @param data 分類
*/
void loadSecondCategory(List<OrderCategoryBean.FoodCategoryTrees> data);
void loadCategoryFail();
/**
* 加載三級分類,用於新增、修改、刪除三級分類後,刷新頁面
*
* @param data 分類
*/
void loadThirdCategory(List<OrderCategoryBean.FoodCategoryTrees> data);
void loadCategoryError();
/**
* 新增分類
*
* @param categoryTrees 分類信息
* @param hierarchy 新增的是第幾級分類
*/
void addCategory(OrderCategoryBean.FoodCategoryTrees categoryTrees, int hierarchy);
/**
* 修改或刪除分類
*
* @param type 操作類型:刪除或修改 Constant.DELETE Constant.UPDATE
* @param hierarchy 第幾級分類
* @param position 分類下標
* @param categoryName 分類名稱
*/
void updateCategory(int type, int hierarchy, String categoryName, int position);
void onError();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map);
Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map);
Observable<BaseResult> createFoodCategory(RequestBody requestBody);
Observable<BaseResult> updateFoodCategory(RequestBody requestBody);
......
......@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import com.qmuiteam.qmui.widget.section.QMUISection;
......@@ -27,12 +28,13 @@ import io.reactivex.Observable;
public interface CategorySelectContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadFoodCategory(List<QMUISection<SectionCheckItem, SectionCheckItem>> sections);
void loadFoodCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map);
Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map);
}
}
......@@ -31,8 +31,16 @@ import okhttp3.RequestBody;
public interface FoodIngredientsContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
/**
* 加載左側供應商
* @param categoryBeans 供應商
*/
void loadLeftSupplierInfo(List<CategoryBean> categoryBeans);
/**
* 加載右側食品
* @param purchaseFoodListVOS 食品信息
*/
void loadRightFoodIngredients(List<PurchaseFoodBean> purchaseFoodListVOS);
/**
......@@ -49,8 +57,15 @@ public interface FoodIngredientsContract {
*/
void loadCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees);
/**
* 加載失敗
*/
void loadFail();
/**
* 修改當前供應商名稱
* @param name 供應商名稱
*/
void setCurrentSupplierName(String name);
}
......
package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.jess.arms.mvp.IView;
......@@ -10,6 +11,7 @@ import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -29,17 +31,50 @@ public interface WarehouseDetailsContract {
interface View extends IView {
/**
* 加載入庫信息和列表
*
* @param warehouseDetailsBean
*/
void loadWarehousing(WarehouseDetailsBean warehouseDetailsBean);
void loadAdapter(List<WarehouseDetailsBean> warehouseDetailsBean);
void loadAdapter(List<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean> purchaseWarehousingOrderDetailsContents);
/**
* 加載消耗原因
*
* @param consumeReasonBeans
*/
void loadConsumeReason(List<ConsumeReasonBean> consumeReasonBeans);
/**
* 獲取頁面數據
*/
void getPageInfo();
/**
* 修改庫存數量
*/
void setWarehousingNum(int num);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<BaseResult> getWarehousingOrderDetails(Map<String, Object> map);
Observable<BaseResult> getOutStockDetails(Map<String, Object> map);
Observable<BaseResult> getWarehouseInventoryReason();
/**
* 庫存消耗
*
* @param requestBody
* @return
*/
Observable<BaseResult> consumeWareHousing(RequestBody requestBody);
/**
* 獲取庫存數量
*/
Observable<BaseResult> getWarehousingNum(Map<String, Object> map);
}
}
package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
......@@ -19,11 +23,17 @@ import com.jess.arms.mvp.IModel;
public interface WarehousingInventoryContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void updateSuccess();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
/**
* 庫存消耗
*
* @param requestBody
* @return
*/
Observable<BaseResult> consumeWareHousing(RequestBody requestBody);
}
}
......@@ -4,6 +4,7 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.contract.CategoryContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
......@@ -57,6 +58,11 @@ public class CategoryModel extends BaseModel implements CategoryContract.Model {
}
@Override
public Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getCategoryTrees(map);
}
@Override
public Observable<BaseResult> createFoodCategory(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).addFoodCategory(requestBody);
}
......
......@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.contract.CategorySelectContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
......@@ -52,4 +53,9 @@ public class CategorySelectModel extends BaseModel implements CategorySelectCont
public Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getFoodCategoryList(map);
}
@Override
public Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getCategoryTrees(map);
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -56,7 +57,24 @@ public class WarehouseDetailsModel extends BaseModel implements WarehouseDetails
}
@Override
public Observable<BaseResult> getOutStockDetails(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getOutStockDetails(map);
}
@Override
public Observable<BaseResult> getWarehouseInventoryReason() {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getWarehouseInventoryReason();
}
@Override
public Observable<BaseResult> consumeWareHousing(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).consumeWareHousing(requestBody);
}
@Override
public Observable<BaseResult> getWarehousingNum(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getWarehousingNum(map);
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
......@@ -12,6 +14,9 @@ import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
......@@ -43,4 +48,9 @@ public class WarehousingInventoryModel extends BaseModel implements WarehousingI
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<BaseResult> consumeWareHousing(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).consumeWareHousing(requestBody);
}
}
\ No newline at end of file
......@@ -149,7 +149,7 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
}
public void addDeputyUnit(List<DeputyUnitBean> data) {
//新增為true,修改為false
//新增為false,修改為true
if (isUpdate) {
if (data == null) {
mRootView.callBackDeputyUnit(null);
......@@ -158,11 +158,13 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
}
} else {
//如果是新增食材,那麼單位返回到新增食材頁面就好,不用做其他處理
Iterator<DeputyUnitBean> iterator = data.iterator();
while (iterator.hasNext()) {
if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) {
//單位為空,移除掉
iterator.remove();
if (data != null) {
Iterator<DeputyUnitBean> iterator = data.iterator();
while (iterator.hasNext()) {
if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) {
//單位為空,移除掉
iterator.remove();
}
}
}
mRootView.callBackDeputyUnit(data);
......@@ -248,12 +250,13 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
/**
* 添加基本單位-快捷輸入
* @param content 新增的基本單位
*
* @param content 新增的基本單位
* @param basicUnitBeans 已有的基本單位——需要判斷是否已經存在了
*/
public void addBasicUnit(String content, List<BasicUnitBean> basicUnitBeans) {
for (BasicUnitBean basicUnitBean : basicUnitBeans) {
if(basicUnitBean.getContent().equals(content)){
if (basicUnitBean.getContent().equals(content)) {
mRootView.showMessage("此單位已存在,不能重複添加");
return;
}
......
......@@ -22,8 +22,10 @@ import com.gingersoft.gsa.cloud.ui.adapter.bean.MultiSelectBean;
import com.gingersoft.gsa.cloud.ui.adapter.multi.InfoMultiAdapter;
import com.gingersoft.gsa.cloud.ui.adapter.multi.RemarkProvider;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.NewSupplierContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -31,6 +33,8 @@ import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.EnAndNumInputFilter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -176,22 +180,27 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
infoMultiAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if (view.getId() == R.id.cb_multi_check) {
// 聯繫方式的選中
//先找到之前的默認聯繫方式
List<InfoMultiBean> data = infoMultiAdapter.getData();
InfoMultiBean infoMultiBean = data.get(position);
if (infoMultiBean instanceof MultiCheckInputBean) {
int lastDefault = emailIndex;
for (int i = emailIndex; i < smsIndex + 1; i++) {
//從email開始,到sms,是所有的聯繫方式
//將聯繫方式的選中設為false
InfoMultiBean infoMultiBean = data.get(i);
//拿到對象,找到上一次被設為默認的那個聯繫方式,修改為false
MultiCheckInputBean multiCheckInputBean = (MultiCheckInputBean) infoMultiBean;
int index = contactInfo.indexOf(multiCheckInputBean);
if (index >= 0) {
MultiCheckInputBean multiCheckInputBean1 = contactInfo.get(index);
if (multiCheckInputBean1 != null) {
for (MultiCheckInputBean checkInputBean : contactInfo) {
checkInputBean.setDefault(false);
}
multiCheckInputBean1.setDefault(true);
}
if (multiCheckInputBean.isDefault()) {
lastDefault = i;
multiCheckInputBean.setDefault(false);
break;
}
infoMultiAdapter.notifyDataSetChanged();
}
//然後再將本次選中的設為true,刷新這兩個item
InfoMultiBean infoMultiBean = data.get(position);
MultiCheckInputBean multiCheckInputBean = (MultiCheckInputBean) infoMultiBean;
multiCheckInputBean.setDefault(true);
infoMultiAdapter.notifyItemChanged(lastDefault);
infoMultiAdapter.notifyItemChanged(position);
}
});
return infoMultiAdapter;
......@@ -202,11 +211,10 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
if (v instanceof EditText) {
if (!hasFocus) {
EditText editText = (EditText) v;
if (TextUtil.isNotEmptyOrNullOrUndefined(editText)) {
if(TextUtil.isNotEmptyOrNullOrUndefined(supplierName)){
if (TextUtil.isNotEmptyOrNullOrUndefined(supplierName)) {
//當供應商名稱不為空時,是修改供應商
if(!editText.getText().toString().equals(supplierName)){
if (!editText.getText().toString().equals(supplierName)) {
//輸入的供應商名稱和之前的名稱不相同,說明進行了修改,需要進行查詢
getSupplierInfo(editText, editText.getText().toString());
}
......@@ -300,7 +308,7 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
public void deleteSupplier(int supplierId) {
mModel.deleteSupplier(supplierId)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("保存中..."))
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.SAVE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......@@ -311,11 +319,12 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
SupplyShoppingCart.getInstance().removeFoodsBySupplier(supplierId);
mRootView.saveSuccess();
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
mRootView.showMessage(Constant.SAVE_FAIL);
}
}
}
......
......@@ -347,15 +347,8 @@ public class ShoppingCatPresenter extends BasePresenter<ShoppingCatContract.Mode
ShoppingCartBean shoppingCartBean = shoppingCartBeans.get(i);
//判斷選中了多少個商品,如果這個供應商的食品一個都沒被選中,就不用管
if (shoppingCartBean.getSelectSpeciesNum() > 0) {
//計算已選中食品的總金額
double totalAmount = 0;
for (PurchaseFoodBean purchaseFoodBean : shoppingCartBean.getFoodList()) {
if (purchaseFoodBean.isChecked()) {
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(purchaseFoodBean.getUnitPrice(), purchaseFoodBean.getFoodQuantity()));
}
}
//判斷總金額是否滿足最低採購金額
if (MoneyUtil.compareTo(totalAmount, shoppingCartBean.getMinimumAmount()) == -1) {
if (MoneyUtil.compareTo(shoppingCartBean.getSelectFoodAmount(), shoppingCartBean.getMinimumAmount()) == -1) {
//不滿足最低採購金額
return false;
}
......
......@@ -6,9 +6,11 @@ import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierResultBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.SupplierListContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -17,9 +19,11 @@ import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxAsyncTask;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -125,7 +129,7 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
RxJavaUtils.executeAsyncTask(new RxAsyncTask<Object, Integer>(1) {
@Override
public void doInUIThread(Integer o) {
if(o != null){
if (o != null) {
mRootView.setSelectIndex(o);
}
}
......@@ -164,7 +168,8 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
/**
* 刪除供應商
* @param id 供應商id
*
* @param id 供應商id
* @param position 所刪除的供應商下標
*/
public void deleteSupplier(int id, int position) {
......@@ -181,6 +186,7 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
SupplyShoppingCart.getInstance().removeFoodsBySupplier(id);
mRootView.deleteSuccess(position);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
......
......@@ -3,8 +3,11 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.gingersoft.supply_chain.mvp.bean.ConsumeWareHousingBean;
import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
......@@ -18,6 +21,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import javax.inject.Inject;
......@@ -25,6 +30,7 @@ import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -66,12 +72,16 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
this.mApplication = null;
}
public void getWarehousingOrderDetails(int foodId, String basicUnitName) {
/**
* 獲取入庫訂單流水
*
* @param foodNo 食材編號
*/
public void getWarehousingOrderDetails(String foodNo) {
Map<String, Object> map = new HashMap<>(4);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("id", foodId);
map.put("basicUnitName", basicUnitName);
map.put("foodNo", foodNo);
mModel.getWarehousingOrderDetails(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
......@@ -83,9 +93,41 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
WarehouseDetailsBean warehouseDetailsBean = GsonUtils.GsonToBean(baseResult.getData(), WarehouseDetailsBean.class);
mRootView.loadWarehousing(warehouseDetailsBean);
} else if(baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
List<WarehouseDetailsBean> warehouseDetailsBean = GsonUtils.jsonToList(baseResult.getData(), WarehouseDetailsBean.class);
mRootView.loadAdapter(warehouseDetailsBean);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
});
}
/**
* 獲取出庫庫訂單流水
*
* @param foodNo
*/
public void getOutStockDetails(String foodNo) {
Map<String, Object> map = new HashMap<>(4);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("foodNo", foodNo);
mModel.getOutStockDetails(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_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()) {
List<ConsumeWareHousingBean> consumeWareHousingBeans = GsonUtils.GsonToList(baseResult.getData(), ConsumeWareHousingBean.class);
mRootView.loadAdapter(WarehouseDetailsBean.getWarehousingByConsumes(consumeWareHousingBeans));
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
......@@ -97,7 +139,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
/**
* 獲取庫存消耗原因
*/
public void getWarehouseInventoryReason(){
public void getWarehouseInventoryReason() {
mModel.getWarehouseInventoryReason()
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
......@@ -109,8 +151,49 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
List<ConsumeReasonBean> consumeReasonBeans = GsonUtils.GsonToList(baseResult.getData(), ConsumeReasonBean.class);
mRootView.loadConsumeReason(consumeReasonBeans);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
});
}
} else if(baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
/**
* 庫存消耗
*
* @param foodNo 食材編號
* @param consumeQuantity 消耗數量
* @param purchaseConsumeReasonId 原因id
* @param remarks 備註
*/
public void consumeWareHousing(String foodNo, int consumeQuantity, int purchaseConsumeReasonId, String remarks) {
FormBody.Builder formBody = new FormBody.Builder()
.add("foodNo", foodNo)
.add("consumeQuantity", String.valueOf(consumeQuantity))
.add("purchaseConsumeReasonId", String.valueOf(purchaseConsumeReasonId))
.add("remarks", remarks);
Constant.addRestaurantId(formBody);
Constant.addBrandId(formBody);
mModel.consumeWareHousing(formBody.build())
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.UPDATE_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.getPageInfo();
//重新獲取庫存數量
getWarehousingNum(foodNo);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
......@@ -119,4 +202,33 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
});
}
/**
* 獲取庫存數量
*/
public void getWarehousingNum(String foodNo) {
Map<String, Object> map = new HashMap<>(3);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("foodNo", foodNo);
mModel.getWarehousingNum(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.QUERY_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()) {
try {
mRootView.setWarehousingNum((int) Double.parseDouble(GsonUtils.GsonString(baseResult.getData())));
} catch (NumberFormatException e) {
mRootView.killMyself();
e.printStackTrace();
}
}
}
});
}
}
......@@ -2,16 +2,24 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import com.jess.arms.utils.RxLifecycleUtils;
/**
......@@ -50,4 +58,41 @@ public class WarehousingInventoryPresenter extends BasePresenter<WarehousingInve
this.mImageLoader = null;
this.mApplication = null;
}
/**
* 庫存消耗
*
* @param foodNo 食材編號
* @param consumeQuantity 消耗數量
*/
public void consumeWareHousing(String foodNo, int consumeQuantity) {
FormBody.Builder formBody = new FormBody.Builder()
.add("foodNo", foodNo)
.add("consumeQuantity", String.valueOf(consumeQuantity))
.add("purchaseConsumeReasonId", String.valueOf(Constant.INVENTORY_CONSUME_ID));
Constant.addRestaurantId(formBody);
Constant.addBrandId(formBody);
mModel.consumeWareHousing(formBody.build())
.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.showMessage(Constant.SAVE_SUCCESS);
mRootView.updateSuccess();
mRootView.killMyself();
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.SAVE_FAIL);
}
}
});
}
}
......@@ -402,11 +402,31 @@ public interface SupplierServer {
Observable<BaseResult> getWarehousingOrderDetails(@QueryMap Map<String, Object> map);
/**
* 查詢出庫流水
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsume/get/running/water" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getOutStockDetails(@QueryMap Map<String, Object> map);
/**
* 查詢庫存消耗原因
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsumeReason/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehouseInventoryReason();
/**
* 庫存消耗
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("purchaseConsume/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> consumeWareHousing(@Body RequestBody requestBody);
/**
* 查詢庫存數量
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsume/get/remaining/quantity" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehousingNum(@QueryMap Map<String, Object> map);
}
......@@ -10,9 +10,11 @@ import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.ui.adapter.multi.InfoMultiAdapter;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.di.component.DaggerSupplyChainMainComponent;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.SupplyChainMainContract;
import com.gingersoft.supply_chain.mvp.presenter.SupplyChainMainPresenter;
import com.gingersoft.supply_chain.mvp.ui.fragment.FunctionListFragment;
......@@ -54,14 +56,17 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if(getTopFragment() instanceof NotDispatchListener){
if (getTopFragment() instanceof NotDispatchListener) {
return super.dispatchTouchEvent(ev);
}
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
// 获得当前得到焦点的View,一般情况下就是EditText(特殊情况就是轨迹求或者实体案件会移动焦点)
View v = getCurrentFocus();
if(v != null && v.getTag() != null && v.getTag() == InfoMultiAdapter.NOT_HIDE_KEYBOARD){
return super.dispatchTouchEvent(ev);
}
if (isShouldHideInput(v, ev)) {
if(v instanceof EditText){
if (v instanceof EditText) {
//不然不會觸發焦點監聽事件
v.clearFocus();
}
......@@ -147,6 +152,12 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
}
@Override
protected void onDestroy() {
super.onDestroy();
SupplyShoppingCart.getInstance().clear();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
......
package com.gingersoft.gsa.cloud.ui.adapter;
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
......@@ -11,6 +11,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/28
* Time: 11:45
* Use: 編輯分類,一級分類適配器
*/
public class CategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int selectedIndex = 0;
private Drawable selectedBg;
private Drawable unSelectedBg;
private int selectColor = -1;
private int unSelectColor = -1;
private boolean showDelete = false;
public CategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data, Context context) {
super(R.layout.item_category, data);
addChildClickViewIds(R.id.iv_category_delete);
selectedBg = ContextCompat.getDrawable(context, R.drawable.shape_left_radio_shadow);
unSelectedBg = ContextCompat.getDrawable(context, R.color.trans);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees categoryBean) {
TextView tvCategoryName = viewHolder.getView(R.id.tv_category_name);
tvCategoryName.setText(categoryBean.getName());
CardView view = viewHolder.getView(R.id.layout_category);
if (viewHolder.getAdapterPosition() == selectedIndex) {
if (selectedBg != null) {
view.setBackground(selectedBg);
}
if (selectColor != -1) {
tvCategoryName.setTextColor(selectColor);
}
tvCategoryName.setSelected(true);
} else {
tvCategoryName.setSelected(false);
if (unSelectedBg != null) {
view.setBackground(unSelectedBg);
}
if (unSelectColor != -1) {
tvCategoryName.setTextColor(unSelectColor);
}
}
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
public void setShowDelete(boolean showDelete) {
this.showDelete = showDelete;
notifyDataSetChanged();
}
public CategoryAdapter setSelectedBg(Drawable selectedBg) {
this.selectedBg = selectedBg;
return this;
}
public CategoryAdapter setUnSelectedBg(Drawable unSelectedBg) {
this.unSelectedBg = unSelectedBg;
return this;
}
public CategoryAdapter setSelectColor(int selectColor) {
this.selectColor = selectColor;
return this;
}
public CategoryAdapter setUnSelectColor(int unSelectColor) {
this.unSelectColor = unSelectColor;
return this;
}
public void setSelectedIndex(int selectedIndex) {
this.selectedIndex = selectedIndex;
notifyDataSetChanged();
}
public int getSelectedIndex() {
return selectedIndex;
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -21,7 +24,7 @@ import java.util.List;
* Time: 15:41
* Use:
*/
public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBean.DataBean.FoodCategoryBean, BaseViewHolder> {
public class FoodCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int selectIndex = 0;
private Drawable checkedBg;
......@@ -31,36 +34,43 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
private int unCheckedTextColor;
private boolean showDelete = false;
public SecondCategoryAdapter(@Nullable List<FoodCategoryResultBean.DataBean.FoodCategoryBean> data) {
public FoodCategoryAdapter(int layoutId, @Nullable List<OrderCategoryBean.FoodCategoryTrees> data) {
super(layoutId, data);
addChildClickViewIds(R.id.iv_category_delete);
}
public FoodCategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data) {
super(R.layout.item_second_category, data);
addChildClickViewIds(R.id.iv_category_delete);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, FoodCategoryResultBean.DataBean.FoodCategoryBean categoryBean) {
protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees categoryBean) {
viewHolder.setText(R.id.tv_second_category_title, categoryBean.getName());
TextView tvName = viewHolder.getView(R.id.tv_second_category_title);
CardView cardView = viewHolder.getView(R.id.card_purchase_category);
if (categoryBean.getId() == -1) {
cardView.setVisibility(View.GONE);
return;
} else {
cardView.setVisibility(View.VISIBLE);
}
viewHolder.setVisible(R.id.tv_second_category_title, TextUtil.isNotEmptyOrNullOrUndefined(categoryBean.getName()));
if (viewHolder.getAdapterPosition() == selectIndex) {
if (checkedBg != null) {
tvName.setBackground(checkedBg);
cardView.setBackground(checkedBg);
}
if (checkedTextColor != 0) {
tvName.setTextColor(checkedTextColor);
}
} else {
if (unCheckedBg != null) {
tvName.setBackground(unCheckedBg);
cardView.setBackground(unCheckedBg);
}
if (unCheckedTextColor != 0) {
tvName.setTextColor(unCheckedTextColor);
}
}
if (viewHolder.getAdapterPosition() == 0) {
viewHolder.setGone(R.id.iv_category_delete, true);
} else {
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
}
public void setShowDelete(boolean showDelete) {
......@@ -68,28 +78,34 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
notifyDataSetChanged();
}
public SecondCategoryAdapter setCheckedBg(Drawable checkedBg) {
public FoodCategoryAdapter setCheckedBg(Drawable checkedBg) {
this.checkedBg = checkedBg;
return this;
}
public SecondCategoryAdapter setUnCheckedBg(Drawable unCheckedBg) {
public FoodCategoryAdapter setUnCheckedBg(Drawable unCheckedBg) {
this.unCheckedBg = unCheckedBg;
return this;
}
public SecondCategoryAdapter setSelectIndex(int selectIndex) {
public FoodCategoryAdapter setSelectIndex(int selectIndex) {
int lastIndex = this.selectIndex;
this.selectIndex = selectIndex;
notifyDataSetChanged();
if (lastIndex >= 0 && lastIndex < getItemCount()) {
notifyItemChanged(lastIndex);
}
if (this.selectIndex >= 0 && this.selectIndex < getItemCount()) {
notifyItemChanged(this.selectIndex);
}
return this;
}
public SecondCategoryAdapter setCheckedTextColor(int checkedTextColor) {
public FoodCategoryAdapter setCheckedTextColor(int checkedTextColor) {
this.checkedTextColor = checkedTextColor;
return this;
}
public SecondCategoryAdapter setUnCheckedTextColor(int unCheckedTextColor) {
public FoodCategoryAdapter setUnCheckedTextColor(int unCheckedTextColor) {
this.unCheckedTextColor = unCheckedTextColor;
return this;
}
......@@ -98,7 +114,4 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
return selectIndex;
}
public FoodCategoryResultBean.DataBean.FoodCategoryBean getSelectData() {
return getData().get(selectIndex);
}
}
......@@ -17,6 +17,8 @@ import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment;
import com.google.android.material.textfield.TextInputEditText;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -160,7 +162,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
*/
private void setEdit(@NotNull BaseViewHolder viewHolder, PurchaseFoodBean foodInfoBean) {
//食品數量
EditText editText = viewHolder.getView(R.id.ed_food_ingredient_number);
TextInputEditText editText = viewHolder.getView(R.id.ed_food_ingredient_number);
//當前食品總價
TextView mTvTotalAmount = viewHolder.getViewOrNull(R.id.tv_food_item_total_amount);
//從緩存中取出這個食品信息,如果沒有對應的食品信息,說明沒操作過這個食品
......@@ -200,7 +202,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
viewHolder.getView(R.id.btn_food_operation_sub).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Log.e("eee", "長按:" + System.currentTimeMillis());
// Log.e("eee", "長按:" + System.currentTimeMillis());
return false;
}
});
......@@ -208,7 +210,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
viewHolder.getView(R.id.btn_food_operation_add).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Log.e("eee", "長按:" + System.currentTimeMillis());
// Log.e("eee", "長按:" + System.currentTimeMillis());
return false;
}
});
......@@ -249,12 +251,15 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
};
editText.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
// if ("0".equals(editText.getText() + "")) {
// editText.setText("");
// }
editText.addTextChangedListener(foodNumTextWatcher);
} else {
//當失去焦點時,輸入框沒有值,詢問是否刪除食材
if (TextUtil.isEmptyOrNullOrUndefined(editText)) {
PurchaseFoodBean purchaseFoodBean = getData().get(viewHolder.getAdapterPosition());
if (onNumberChangeListener != null) {
if (adapterType == FoodIngredientsFragment.ORDER_TYPE) {
//購物車走這個方法
onNumberChangeListener.onChanged(purchaseFoodBean.getFoodQuantity(), 0, viewHolder.getAdapterPosition());
} else {
......
......@@ -16,13 +16,17 @@ import org.jetbrains.annotations.NotNull;
*/
public class ImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public ImageAdapter() {
private boolean notShowDelete;
public ImageAdapter(boolean notShowDelete) {
super(R.layout.item_image);
addChildClickViewIds(R.id.iv_img, R.id.iv_img_delete);
this.notShowDelete = notShowDelete;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
GlideUtils.display(getContext(), viewHolder.getView(R.id.iv_img), s);
viewHolder.setGone(R.id.iv_img_delete, notShowDelete);
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/25
* Time: 9:20
* Use:
*/
public class SelectCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int bgColor;
/**
* 記錄當前第幾級分類
*/
private int level;
private OnChildSelectListener onChildSelectListener;
/**
* 當前選中的下標集合
*/
private int[] positions;
/**
* 標題的縮進
*/
private String indentation;
/**
* @param data 分類數據
* @param bgColor 當前背景色
* @param level 當前是第幾級分類
* @param positions 選中下標集合 positions[level]表示獲取第level級選中的分類的下標
*/
public SelectCategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data, int bgColor, int level, int[] positions) {
super(R.layout.item_select_category, data);
this.bgColor = bgColor;
this.level = level;
this.positions = positions;
indentation = "";
}
public SelectCategoryAdapter setIndentation(String indentation) {
this.indentation = indentation;
return this;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees foodCategoryTrees) {
viewHolder.setText(R.id.tv_radio_section_title, indentation + foodCategoryTrees.getName());
viewHolder.setBackgroundColor(R.id.layout_item_select_category, bgColor);
CheckBox checkBox = viewHolder.getView(R.id.cb_radio_section);
if (level < positions.length) {
//當前分類已選中,要默認展開
if (viewHolder.getAdapterPosition() == positions[level]) {
checkBox.setChecked(true);
setChildState(viewHolder, foodCategoryTrees, false);
} else {
checkBox.setChecked(false);
viewHolder.setGone(R.id.rv_select_category, true);
}
} else {
checkBox.setChecked(false);
viewHolder.setGone(R.id.rv_select_category, true);
}
//選中狀態切換
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (buttonView.isPressed()) {
//將低於此級別的都設置為未選中
for (int i = level; i < positions.length; i++) {
positions[i] = -1;
}
if (isChecked) {
//沒選中的情況下,才設置為選中
//當前級別存下
positions[level] = viewHolder.getAdapterPosition();
} else {
positions[level] = -1;
}
//通知父類選中或沒選中
onChildSelectListener.onSelect(viewHolder.getAdapterPosition(), isChecked);
}
});
//設置當前item點擊顯示或隱藏
LinearLayout layout = viewHolder.getView(R.id.layout_item_select_category);
layout.setOnClickListener(v -> {
//顯示就隱藏,隱藏就顯示
RecyclerView rvNextLevelCategory = viewHolder.getView(R.id.rv_select_category);
setChildState(viewHolder, foodCategoryTrees, rvNextLevelCategory.getVisibility() == View.VISIBLE);
});
}
/**
* 子類選中時的接口
*/
public interface OnChildSelectListener {
/**
* 選中時調用
*
* @param position 分類下標
* @param isChecked 選中狀態
*/
void onSelect(int position, boolean isChecked);
}
public void setOnChildSelectListener(OnChildSelectListener onChildSelectListener) {
this.onChildSelectListener = onChildSelectListener;
}
/**
* 設置子分類顯示狀態
*
* @param viewHolder
* @param foodCategoryTrees 父分類
*/
private void setChildState(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees foodCategoryTrees, boolean notShowChild) {
RecyclerView rvNextLevelCategory = viewHolder.getView(R.id.rv_select_category);
if (foodCategoryTrees.getFoodCategoryTrees() != null) {
viewHolder.setGone(R.id.rv_select_category, notShowChild);
SelectCategoryAdapter selectCategoryAdapter = new SelectCategoryAdapter(foodCategoryTrees.getFoodCategoryTrees(), bgColor == Color.WHITE ? ContextCompat.getColor(getContext(), R.color.color_ccc) : getBgColor(bgColor), level + 1, positions);
rvNextLevelCategory.setAdapter(selectCategoryAdapter.setIndentation(indentation + "\u3000"));
selectCategoryAdapter.setOnChildSelectListener((position, isChecked) -> {
//子類被選中了,父類也要被選中
positions[level] = viewHolder.getAdapterPosition();
onChildSelectListener.onSelect(viewHolder.getAdapterPosition(), isChecked);
});
rvNextLevelCategory.setTag(selectCategoryAdapter);
} else {
viewHolder.setGone(R.id.rv_select_category, true);
}
}
private int getBgColor(int backgroundColor) {
int alpha = Color.alpha(backgroundColor) + 20;
int red = Color.red(backgroundColor) + 20;
int green = Color.green(backgroundColor) + 20;
int blue = Color.blue(backgroundColor) + 20;
if (alpha < 0 || alpha > 255) {
alpha = 0;
}
if (red < 0 || red > 255) {
red = 0;
}
if (green < 0 || green > 255) {
green = 0;
}
if (blue < 0 || blue > 255) {
blue = 0;
}
return Color.argb(alpha, red, green, blue);
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
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.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WarehouseDetailsFragment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -17,27 +26,104 @@ import java.util.List;
* Time: 14:45
* Use:
*/
public class WareHousingDetailsAdapter extends BaseQuickAdapter<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean, BaseViewHolder> {
public class WareHousingDetailsAdapter extends BaseQuickAdapter<WarehouseDetailsBean, BaseViewHolder> {
/**
* 入庫還是出庫
* 入庫顯示+,出庫顯示-
*/
private int type;
/**
* 已消耗的背景色
*/
private Drawable allConsumeBg;
/**
* 已過期的背景
*/
private Drawable expiredBg;
/**
* 即將過期背景
*/
private Drawable willExpireSoonBg;
public WareHousingDetailsAdapter(@Nullable List<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean> data) {
public WareHousingDetailsAdapter(Context context, @Nullable List<WarehouseDetailsBean> data, int type) {
super(R.layout.item_warehouse_details, data);
this.type = type;
allConsumeBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_48);
expiredBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_red_wine);
willExpireSoonBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_bright_orange);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean purchaseWarehousingOrderDetailsContentsBean) {
protected void convert(@NotNull BaseViewHolder viewHolder, WarehouseDetailsBean purchaseWarehousingOrderDetailsContentsBean) {
//食品名
viewHolder.setText(R.id.tv_warehouse_details_food_name, purchaseWarehousingOrderDetailsContentsBean.getName());
//入庫單位
viewHolder.setText(R.id.tv_warehouse_details_food_unit, "單位");
viewHolder.setText(R.id.tv_warehouse_details_food_unit, purchaseWarehousingOrderDetailsContentsBean.getUnitName());
//入庫食品數量
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_positive), purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity()));
// if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() > 0) {
if (type == WarehouseDetailsFragment.WAREHOUSE_TYPE) {
// 入庫,顯示+
if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() >= 0) {
//如果大於0,前面顯示+號
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_positive), MoneyUtil.formatDouble(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity())));
} else {
//小於0,直接顯示負數
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.valueOf(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity()));
}
viewHolder.setGone(R.id.tv_warehouse_time_text, false);
viewHolder.setText(R.id.tv_warehouse_order_time_text, "下單日期:");
//入庫日期
viewHolder.setText(R.id.tv_warehouse_details_time, purchaseWarehousingOrderDetailsContentsBean.getWarehousingTime());
viewHolder.setGone(R.id.tv_warehouse_details_time, false);
} else {
//出庫,顯示-
if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() >= 0) {
//如果大於0,前面顯示-號
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_less), MoneyUtil.formatDouble(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity())));
} else {
//小於0,顯示正數,負負得正
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_positive), MoneyUtil.formatDouble(Math.abs(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity()))));
}
// 入庫顯示消耗日期,不顯示入庫日期
viewHolder.setGone(R.id.tv_warehouse_time_text, true);
//消耗日期
viewHolder.setText(R.id.tv_warehouse_order_time_text, "消耗日期:");
viewHolder.setGone(R.id.tv_warehouse_details_time, true);
}
//下單時間
viewHolder.setText(R.id.tv_warehouse_details_order_time, "下單時間");
viewHolder.setText(R.id.tv_warehouse_details_order_time, purchaseWarehousingOrderDetailsContentsBean.getPurchaseTime());
//供應商
viewHolder.setText(R.id.tv_warehouse_details_supplier, purchaseWarehousingOrderDetailsContentsBean.getName());
//入庫日期
viewHolder.setText(R.id.tv_warehouse_details_time, "入庫日期");
viewHolder.setText(R.id.tv_warehouse_details_supplier, purchaseWarehousingOrderDetailsContentsBean.getSupplierName());
//入庫來源
viewHolder.setText(R.id.tv_warehouse_details_reason, purchaseWarehousingOrderDetailsContentsBean.getPurchase());
//設置狀態
TextView tvState = viewHolder.getView(R.id.tv_warehouse_state);
tvState.setVisibility(View.VISIBLE);
if (purchaseWarehousingOrderDetailsContentsBean.getConsumeStatus() == WarehouseDetailsBean.WAREHOUSE_STATE_ALL_CONSUMED) {
//全部消耗了
tvState.setBackground(allConsumeBg);
tvState.setText("庫存已使用");
} else {
//未消耗或消耗部分的
if (purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime() >= 0) {
//即將過期天數大於等於0
if (purchaseWarehousingOrderDetailsContentsBean.getWarningDays() > purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime()) {
//在預警天數內
//顯示即將過期
tvState.setBackground(willExpireSoonBg);
tvState.setText("即将過期:" + purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime() + "日");
} else {
tvState.setVisibility(View.GONE);
}
} else {
//天數為負,則是已過期
tvState.setBackground(expiredBg);
tvState.setText("已過期:" + Math.abs(purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime()) + "日");
}
}
}
public void setType(int type) {
this.type = type;
}
}
......@@ -34,9 +34,9 @@ public class WarehousingQueryAdapter extends BaseQuickAdapter<WareHouseListBean.
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean item) {
viewHolder.setText(R.id.tv_warehouse_item_ingredients_name, item.getName());
viewHolder.setText(R.id.tv_warehouse_item_ingredients_species, item.getCateName());
viewHolder.setText(R.id.tv_warehouse_item_supplier, item.getSupplierName());
viewHolder.setText(R.id.tv_warehouse_item_unit, item.getBasicUnitName());
viewHolder.setText(R.id.tv_warehouse_item_ingredients_species, item.getFoodCategoryName());
// viewHolder.setText(R.id.tv_warehouse_item_supplier, item.getSupplierName());
viewHolder.setText(R.id.tv_warehouse_item_unit, item.getUnitName());
viewHolder.setText(R.id.tv_warehouse_item_unit_price, item.getFoodPrice() + "");
viewHolder.setText(R.id.tv_warehouse_item_inventory_quantity, item.getFoodNum() + "");
viewHolder.setText(R.id.tv_warehouse_item_total_amount, item.getFoodAmount() + "");
......
......@@ -4,11 +4,15 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.common.BuildConfig;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
......@@ -28,8 +32,10 @@ import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WareHouseListFragment;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import static com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment.FOOD_INGREDIENTS;
......@@ -92,6 +98,9 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
List<Function> storage = new ArrayList<>();
storage.add(new Function("庫存查詢", R.drawable.ic_purchase_order));
if (BuildConfig.DEBUG) {
storage.add(new Function("切換環境", R.drawable.ic_seekbar_btn));
}
purchaseFunctionBeans.add(new PurchaseFunctionBean("庫存管理", storage));
PurchaseFunctionAdapter purchaseFunctionAdapter = new PurchaseFunctionAdapter(mContext, purchaseFunctionBeans);
......@@ -120,6 +129,16 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
case "庫存查詢":
start(WareHouseListFragment.newInstance());
break;
case "切換環境":
int format = (int) SPUtils.get("isFormal", 3);
if (format == 3) {
showMessage("已切換到測試環境,重啟生效");
SPUtils.put("isFormal", 1);
} else {
showMessage("已切換到本地環境,重啟生效");
SPUtils.put("isFormal", 3);
}
break;
default:
break;
......
......@@ -78,18 +78,21 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
* 食品id
*/
public final static String FOOD_ID_KEY = "foodIdKey";
/**
* @param basicUnit 基本單位
* @param deputyUnitBeans 副單位集合
* @return
*/
public static FoodUnitPageFragment newInstance(String basicUnit, List<DeputyUnitBean> deputyUnitBeans, boolean isUpdateUnit, int foodId) {
public static FoodUnitPageFragment newInstance(String basicUnit, List<DeputyUnitBean> deputyUnitBeans, boolean isUpdateUnit, Integer foodId) {
FoodUnitPageFragment fragment = new FoodUnitPageFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans);
bundle.putString(BASIC_UNIT_KEY, basicUnit);
bundle.putBoolean(UPDATE_UNIT_KEY, isUpdateUnit);
bundle.putInt(FOOD_ID_KEY, foodId);
if (foodId != null) {
bundle.putInt(FOOD_ID_KEY, foodId);
}
fragment.setArguments(bundle);
return fragment;
}
......@@ -130,25 +133,11 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
edBasicUnit.setError("請輸入基本單位");
return;
}
if (deputyUnitAdapter != null) {
if (deputyUnitAdapter != null && deputyUnitAdapter.getItemCount() > 0) {
mPresenter.addDeputyUnit(deputyUnitAdapter.getData());
} else {
mPresenter.addDeputyUnit(null);
}
// Bundle result = new Bundle();
// result.putString(BASIC_UNIT_KEY, basicUnit);
// if (deputyUnitAdapter != null) {
// //拿到副單位集合
// List<DeputyUnitBean> data = deputyUnitAdapter.getData();
// Iterator<DeputyUnitBean> iterator = data.iterator();
// while (iterator.hasNext()) {
// if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) {
// //單位為空,移除掉
// iterator.remove();
// }
// }
// result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) data);
// }
// setFragmentResult(RESULT_OK, result);
// killMyself();
}
}
......@@ -227,7 +216,9 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
Bundle result = new Bundle();
result.putString(BASIC_UNIT_KEY, basicUnit);
result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans);
if (deputyUnitBeans != null) {
result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans);
}
setFragmentResult(RESULT_OK, result);
killMyself();
}
......
......@@ -35,6 +35,7 @@ import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerNewFoodIngredientsComponent;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.contract.NewFoodIngredientsContract;
......@@ -55,6 +56,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
......@@ -112,11 +115,11 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
return fragment;
}
public static NewFoodIngredientsFragment newInstance(String supplierName, List<String> categoryNames) {
public static NewFoodIngredientsFragment newInstance(String supplierName, String categoryName) {
NewFoodIngredientsFragment fragment = new NewFoodIngredientsFragment();
Bundle bundle = new Bundle();
bundle.putString(SUPPLIER_NAME_KEY, supplierName);
bundle.putSerializable(CATEGORY_NAME_KEY, (Serializable) categoryNames);
bundle.putString(CATEGORY_NAME_KEY, categoryName);
fragment.setArguments(bundle);
return fragment;
}
......@@ -158,16 +161,13 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
initTopBar(topbarNewFoodIngredients, "新增食材");
purchaseFoodBean = new PurchaseFoodBean();
//拿到分類集合
List<String> categoryNames = (List<String>) arguments.getSerializable(CATEGORY_NAME_KEY);
if (categoryNames != null && categoryNames.size() > 0) {
String categoryName = arguments.getString(CATEGORY_NAME_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(categoryName)) {
//分類不為空,設置分類信息
List<String> categoryNames= new ArrayList<>();
categoryNames.add(categoryName);
mPresenter.setCategoryNames(categoryNames);
StringBuilder category = new StringBuilder();
for (String categoryName : categoryNames) {
category.append(categoryName).append(PurchaseFoodBean.CATEGORY_DIVIDER);
}
category.deleteCharAt(category.lastIndexOf(PurchaseFoodBean.CATEGORY_DIVIDER));
purchaseFoodBean.setFoodCategoryName(category.toString());
purchaseFoodBean.setFoodCategoryName(categoryName);
}
//供應商名稱
purchaseFoodBean.setSupplierName(arguments.getString(SUPPLIER_NAME_KEY));
......@@ -197,7 +197,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
startForResult(SupplierListFragment.newInstance(true, multiBean.getShowValue()), multiBean.getRequestCode());
} else if (infoMultiBean.getFragment() == CategorySelectFragment.class) {
//選擇分類
startForResult(CategorySelectFragment.newInstance(), multiBean.getRequestCode());
startForResult(CategorySelectFragment.newInstance(mPresenter.getCategoryName()), multiBean.getRequestCode());
} else if (infoMultiBean.getFragment() == FoodUnitPageFragment.class) {
//食品單位
startForResult(FoodUnitPageFragment.newInstance(mPresenter.getBasicUnit(data), mPresenter.getDeputyUnitBeans(), isUpdate, mPresenter.getFoodId()), multiBean.getRequestCode());
......@@ -248,7 +248,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
mPresenter.setPackingInfo(basicUnitName, deputyUnitBeans, infoMultiAdapter.getData());
} else if (requestCode == SELECT_FOOD_CATEGORY_REQUEST_CODE) {
//選擇食材類別
List<SectionCheckItem> sectionCheckItems = (List<SectionCheckItem>) data.get(SELECT_CATEGORY_DATA_KEY);
List<OrderCategoryBean.FoodCategoryTrees> sectionCheckItems = (List<OrderCategoryBean.FoodCategoryTrees>) data.get(SELECT_CATEGORY_DATA_KEY);
if (sectionCheckItems != null) {
mPresenter.setCategoryInfo(sectionCheckItems, infoMultiAdapter.getData());
}
......
......@@ -81,8 +81,8 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
ScreenView screenView;
@BindView(R2.id.view_load_bg)
View loadBg;
@BindView(R2.id.ed_food_ingredients_search)
EditText edSearch;
// @BindView(R2.id.ed_food_ingredients_search)
// EditText edSearch;
@BindView(R2.id.srl_purchase_list)
SmartRefreshLayout refreshPurchaseList;
......@@ -124,7 +124,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
public void initData(@Nullable Bundle savedInstanceState) {
refreshPurchaseList.setPrimaryColorsId(R.color.trans, R.color.black);
btnNewOrder.setText("+新增訂單");
edSearch.setFilters(new InputFilter[]{InputFilterUtils.getChAndEnAndNumInputFilter(mContext), InputFilterUtils.getLengthFilter(mContext, 20)});
// edSearch.setFilters(new InputFilter[]{InputFilterUtils.getChAndEnAndNumInputFilter(mContext), InputFilterUtils.getLengthFilter(mContext, 20)});
btnNewOrder.setOnClickListener(v -> {
//跳轉到下單頁面
startForResult(FoodIngredientsFragment.newInstance(ADD_ORDER), REQUEST_ORDER_DETAILS_CODE);
......@@ -144,7 +144,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
}
private void getOrderList() {
mPresenter.getOrderList(edSearch.getText() + "", orderState[orderStateIndex], pageIndex);
mPresenter.getOrderList("", orderState[orderStateIndex], pageIndex);
}
@Override
......@@ -190,7 +190,18 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
.asCustom(new PurchaseListMorePopup(mContext)
//, "再次购买" , R.drawable.ic_purchase_buy_again
.setStringData(new String[]{"删除", "发送"}, new int[]{R.drawable.ic_purchase_delete, R.drawable.ic_purchase_send})
.setOnSelectListener(mOnSelectListener))
.setOnSelectListener((popupPosition, text) -> {
if (popupPosition == 0) {
//刪除
AppDialog.getInstance().showWaringDialog(mContext, "是否刪除訂單", (view1, dialog) -> {
dialog.dismiss();
mPresenter.deleteOrder(position, purchaseOrderAdapter.getData().get(position).getId());
});
} else if (popupPosition == 1) {
//發送採購單
sendPurchase(position);
}
}))
.show();
}
});
......@@ -228,22 +239,6 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
});
}
private OnSelectListener mOnSelectListener = new OnSelectListener() {
@Override
public void onSelect(int position, String text) {
if (position == 0) {
//刪除
AppDialog.getInstance().showWaringDialog(mContext, "是否刪除訂單", (view1, dialog) -> {
dialog.dismiss();
mPresenter.deleteOrder(position, purchaseOrderAdapter.getData().get(position).getId());
});
} else if (position == 1) {
//發送採購單
sendPurchase(position);
}
}
};
private void sendPurchase(int position) {
List<OrderBean> data = purchaseOrderAdapter.getData();
OrderBean orderBean = data.get(position);
......
......@@ -100,10 +100,10 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTopBar(topBar, "採購單");
mPresenter.organizeShopCartData();
canClick = ContextCompat.getDrawable(requireContext(), R.drawable.shape_app_btn);
notCanClick = ContextCompat.getDrawable(requireContext(), R.drawable.shape_btn_unclick);
initTopBar(topBar, "採購單");
mPresenter.organizeShopCartData();
cbOrderContentAllSelect.setOnCheckedChangeListener((buttonView, isChecked) -> {
//全選
......@@ -214,7 +214,7 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres
@Override
public void setCreateBtnState(boolean checkable) {
// tvConfirm.setBackground(checkable ? canClick : notCanClick);
// tvConfirm.setClickable(checkable);
tvConfirm.setBackground(checkable ? canClick : notCanClick);
tvConfirm.setClickable(checkable);
}
}
......@@ -186,6 +186,8 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
bundle.putSerializable(SELECT_SUPPLIER_DATA, supplierInfoBean);
setFragmentResult(SELECT_SUPPLIER_RESULTCODE, bundle);
killMyself();
} else {
showMessage("請選擇供應商");
}
}
}
......@@ -196,6 +198,7 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
super.onFragmentResult(requestCode, resultCode, data);
if (requestCode == SUPPLIER_LIST && resultCode == RESULT_OK) {
//新增或編輯了供應商,重新獲取所有供應商數據
pageIndex = 0;
getSupplierList();
}
}
......
......@@ -80,7 +80,10 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
*/
private boolean isAscending = false;
private int pageIndex = 0;
/**
* 調整到其他頁面,用於回來是否刷新數據
*/
private final int UPDATE_KEY = 1001;
private WarehousingQueryAdapter warehousingQueryAdapter;
public static WareHouseListFragment newInstance() {
......@@ -185,18 +188,27 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
warehousingQueryAdapter = new WarehousingQueryAdapter(mContext, purchaseWarehousingOrderDetailsVos);
rvWarehouseList.setLayoutManager(new LinearLayoutManager(mContext));
rvWarehouseList.setAdapter(warehousingQueryAdapter);
warehousingQueryAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if(view.getId() == R.id.tv_warehouse_item_inventory_quantity){
//點擊庫存數量,進入庫存盤點
start(WarehousingInventoryFragment.newInstance(warehousingQueryAdapter.getItem(position)));
startForResult(WarehousingInventoryFragment.newInstance(warehousingQueryAdapter.getItem(position)), UPDATE_KEY);
}
});
warehousingQueryAdapter.setOnItemClickListener((adapter, view, position) -> {
//進入庫存詳情
start(WarehouseDetailsFragment.newInstance(warehousingQueryAdapter.getItem(position)));
startForResult(WarehouseDetailsFragment.newInstance(warehousingQueryAdapter.getItem(position)), UPDATE_KEY);
});
} else {
warehousingQueryAdapter.setList(purchaseWarehousingOrderDetailsVos);
}
}
@Override
public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
super.onFragmentResult(requestCode, resultCode, data);
if(requestCode == UPDATE_KEY && resultCode == RESULT_OK){
getWarehousing();
}
}
}
package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerWarehousingInventoryComponent;
......@@ -19,7 +25,11 @@ import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import com.gingersoft.supply_chain.mvp.presenter.WarehousingInventoryPresenter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.zhy.autolayout.utils.ScreenUtils;
import org.w3c.dom.Text;
import butterknife.BindView;
......@@ -39,17 +49,20 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
TextView tvWarehouseDifference;
@BindView(R2.id.ed_warehouse_loss)
EditText edWarehouseLoss;
private final static String FOOD_NAME_KEY = "foodNameKey";
private final static String FOOD_ID_KEY = "foodIdKey";
private final static String FOOD_NUM_KEY = "foodNumKey";
/**
* 食品總庫存
*/
private int foodNum;
private String foodNo;
public static WarehousingInventoryFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean purchaseWarehousingOrderDetailsVosBean) {
WarehousingInventoryFragment fragment = new WarehousingInventoryFragment();
Bundle bundle = new Bundle();
bundle.putString(FOOD_NAME_KEY, purchaseWarehousingOrderDetailsVosBean.getName());
bundle.putInt(FOOD_ID_KEY, purchaseWarehousingOrderDetailsVosBean.getId());
bundle.putInt(FOOD_NUM_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNum());
bundle.putString(WarehouseDetailsFragment.FOOD_NAME_KEY, purchaseWarehousingOrderDetailsVosBean.getName());
bundle.putInt(WarehouseDetailsFragment.FOOD_ID_KEY, purchaseWarehousingOrderDetailsVosBean.getId());
bundle.putInt(WarehouseDetailsFragment.FOOD_NUM_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNum());
bundle.putString(WarehouseDetailsFragment.FOOD_NO_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNo());
bundle.putString(WarehouseDetailsFragment.FOOD_IMAGE_KEY, purchaseWarehousingOrderDetailsVosBean.getImages());
fragment.setArguments(bundle);
return fragment;
}
......@@ -73,15 +86,63 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments != null) {
int foodId = arguments.getInt(FOOD_ID_KEY);
String foodName = arguments.getString(FOOD_NAME_KEY);
int foodNum = arguments.getInt(FOOD_NUM_KEY);
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);
}
});
//初始化標題
initTopBar(supplyTopBar, foodName);
supplyTopBar.addRightTextButton(R.string.str_save, R.id.id_save).setOnClickListener(mOnClickListener);
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) {
}
@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 + "");
// 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));
}
}
});
} else {
showMessage("獲取食材信息失敗,請稍候重試");
killMyself();
......@@ -90,9 +151,27 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
private View.OnClickListener mOnClickListener = v -> {
if(v.getId() == R.id.id_save){
//保存
// edWarehouseLoss.getText()
if (v.getId() == R.id.id_save) {
//保存,調用庫存損耗
if (TextUtil.isEmptyOrNullOrUndefined(edWarehouseLoss)) {
showMessage("請輸入盤點庫存數量");
edWarehouseLoss.requestFocus();
} else {
//盤點數量
int inventoryNum = Integer.parseInt(edWarehouseLoss.getText().toString());
if (inventoryNum <= 0) {
showMessage("請輸入盤點庫存數量");
edWarehouseLoss.requestFocus();
} else {
int remainingAmount = foodNum - inventoryNum;
mPresenter.consumeWareHousing(foodNo, remainingAmount);
}
}
}
};
@Override
public void updateSuccess() {
setFragmentResult(RESULT_OK, null);
}
}
......@@ -28,6 +28,7 @@ public class CategoryPopup extends ConfirmPopupView {
private EditText et_input;
private OnClickListener onDeleteListener;
private String inputText;
private final int nameMaxLength = 4;
public CategoryPopup(@NonNull Context context, CharSequence title, CharSequence content, CharSequence hint, String inputText, boolean showDelete) {
super(context, R.layout.dialog_new_category);
......@@ -44,11 +45,15 @@ public class CategoryPopup extends ConfirmPopupView {
tvDelete.setVisibility(showDelete ? View.VISIBLE : GONE);
tvDelete.setOnClickListener(onDeleteListener);
et_input = findViewById(R.id.et_input);
et_input.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), 4), InputFilterUtils.getChAndEnAndNumInputFilter(getContext())});
if (TextUtil.isNotEmptyOrNullOrUndefined(inputText)) {
et_input.setText(inputText);
et_input.setSelection(inputText.length());
if (inputText.length() > nameMaxLength) {
et_input.setText(inputText.substring(0, 4));
} else {
et_input.setText(inputText);
}
et_input.setSelection(et_input.length());
}
et_input.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), 4), InputFilterUtils.getChAndEnAndNumInputFilter(getContext())});
}
public EditText getEditText() {
......
package com.gingersoft.supply_chain.mvp.ui.widget;
import android.content.Context;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.supply_chain.R;
import com.lxj.xpopup.animator.PopupAnimator;
import com.lxj.xpopup.animator.ScrollScaleAnimator;
import com.lxj.xpopup.enums.PopupAnimation;
import com.lxj.xpopup.impl.AttachListPopupView;
import com.lxj.xpopup.interfaces.OnSelectListener;
import com.lxj.xpopup.widget.VerticalRecyclerView;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/29
* Time: 16:45
* Use:
*/
public class ChooseUnitPopup extends AttachListPopupView {
private OnSelectListener selectListener;
private RecyclerView recyclerView;
private int width;
/**
* @param context
*/
public ChooseUnitPopup(@NonNull Context context) {
super(context, 0, R.layout.popup_choose_unit);
}
@Override
protected void onCreate() {
recyclerView = findViewById(R.id.recyclerView);
width = popupInfo.atView.getMeasuredWidth();
recyclerView.setHasFixedSize(false);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
ChooseUnitAdapter adapter = new ChooseUnitAdapter();
adapter.setOnItemClickListener((a, view, position) -> {
if (selectListener != null) {
selectListener.onSelect(position, adapter.getItem(position));
}
if (popupInfo.autoDismiss) {
dismiss();
}
});
recyclerView.setAdapter(adapter);
applyTheme();
}
private List<String> data;
public ChooseUnitPopup setStringData(List<String> data) {
this.data = data;
return this;
}
@Override
protected PopupAnimator getPopupAnimator() {
PopupAnimator animator;
if (isShowUpToTarget()) {
// 在上方展示
animator = new ScrollScaleAnimator(getPopupContentView(), PopupAnimation.ScrollAlphaFromBottom);
} else {
// 在下方展示
animator = new ScrollScaleAnimator(getPopupContentView(), PopupAnimation.ScrollAlphaFromTop);
}
return animator;
}
@Override
protected void applyDarkTheme() {
((VerticalRecyclerView)recyclerView).setupDivider(true);
}
@Override
protected void applyLightTheme() {
((VerticalRecyclerView)recyclerView).setupDivider(false);
}
@Override
public ChooseUnitPopup setOnSelectListener(OnSelectListener selectListener) {
this.selectListener = selectListener;
return this;
}
public class ChooseUnitAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public ChooseUnitAdapter() {
super(R.layout.popup_choose_unit, data);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
viewHolder.setText(R.id.tv_text, s);
LinearLayout layout = viewHolder.getView(R.id.layout_choose_unit);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(layoutParams);
}
}
}
......@@ -16,6 +16,8 @@ import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.lxj.xpopup.impl.ConfirmPopupView;
import com.lxj.xpopup.impl.InputConfirmPopupView;
import org.jetbrains.annotations.NotNull;
......@@ -29,61 +31,65 @@ import java.util.List;
* Time: 10:47
* Use: 庫存消耗彈窗
*/
public class InventoryConsumptionPopup extends InputConfirmPopupView {
public class InventoryConsumptionPopup extends ConfirmPopupView {
/**
* 庫存損耗原因
*/
private List<String> consumptionReasons;
private List<ConsumeReasonBean> consumptionReasons;
private EditText edRemarks;
private EditText edInput;
private RecyclerView rvConsumptionReason;
private OnConfirmClickListener onConfirmClickListener;
private int maxConsumption;
/**
* @param context
* @param consumptionReasons 庫存消耗原因
* @param maxConsumption 最大消耗數
* @param onConfirmClickListener 確認按鈕回調
* @param consumeReasonBeans 庫存消耗原因
* @param maxConsumption 最大消耗數
*/
public InventoryConsumptionPopup(@NonNull Context context, List<String> consumptionReasons, int maxConsumption, OnConfirmClickListener onConfirmClickListener) {
public InventoryConsumptionPopup(@NonNull Context context, List<ConsumeReasonBean> consumeReasonBeans, int maxConsumption) {
super(context, R.layout.popup_inventory_consumption);
this.consumptionReasons = consumptionReasons;
this.onConfirmClickListener = onConfirmClickListener;
this.consumptionReasons = consumeReasonBeans;
this.maxConsumption = maxConsumption;
}
public void setOnConfirmClickListener(OnConfirmClickListener onConfirmClickListener) {
this.onConfirmClickListener = onConfirmClickListener;
}
@Override
protected void onCreate() {
super.onCreate();
edRemarks = findViewById(R.id.ed_inventory_consumption_remark);
edInput = findViewById(R.id.et_input);
rvConsumptionReason = findViewById(R.id.rv_inventory_consumption_reason);
ConsumptionReasonAdapter consumptionReasonAdapter = new ConsumptionReasonAdapter();
consumptionReasonAdapter.setOnItemClickListener((adapter, view, position) -> consumptionReasonAdapter.setSelectIndex(position));
consumptionReasonAdapter.setOnItemChildClickListener((adapter, view, position) -> consumptionReasonAdapter.setSelectIndex(position));
rvConsumptionReason.setLayoutManager(new GridLayoutManager(getContext(), 2));
rvConsumptionReason.setAdapter(consumptionReasonAdapter);
findViewById(R.id.tv_confirm).setOnClickListener(v -> {
if (onConfirmClickListener != null) {
String s = getEditText().getText().toString();
String s = edInput.getText().toString();
try {
int i = Integer.parseInt(s);
if (i > 0) {
if (i > maxConsumption) {
getEditText().setError("不能超過當前庫存數量:" + maxConsumption);
edInput.setError("不能超過當前庫存數量:" + maxConsumption);
} else {
onConfirmClickListener.onConfirm(i, consumptionReasonAdapter.getSelectIndex(), edRemarks.getText().toString());
}
} else {
ToastUtils.show(getContext(), "請輸入消耗庫存數");
getEditText().setError("請輸入消耗庫存數");
edInput.setError("請輸入消耗庫存數");
}
} catch (NumberFormatException e) {
e.printStackTrace();
ToastUtils.show(getContext(), "請輸入消耗庫存數");
getEditText().setError("請輸入消耗庫存數");
edInput.setError("請輸入消耗庫存數");
}
}
});
getEditText().addTextChangedListener(new TextWatcher() {
edInput.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -99,7 +105,7 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
try {
int i = Integer.parseInt(s.toString());
if (i > maxConsumption) {
getEditText().setError("不能超過當前庫存數量:" + maxConsumption);
edInput.setError("不能超過當前庫存數量:" + maxConsumption);
}
} catch (NumberFormatException e) {
e.printStackTrace();
......@@ -111,6 +117,7 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
public interface OnConfirmClickListener {
/**
* 確認時,將消耗的庫存,原因,備註傳遞回去
*
* @param consumptionNum 消耗的庫存數量
* @param reasonIndex 原因下標
* @param remarks 備註
......@@ -118,17 +125,18 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
void onConfirm(int consumptionNum, int reasonIndex, String remarks);
}
private class ConsumptionReasonAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
private class ConsumptionReasonAdapter extends BaseQuickAdapter<ConsumeReasonBean, BaseViewHolder> {
private int selectIndex = 0;
public ConsumptionReasonAdapter() {
super(R.layout.item_consumption_reason, consumptionReasons);
addChildClickViewIds(R.id.cb_consumption_reason);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
protected void convert(@NotNull BaseViewHolder viewHolder, ConsumeReasonBean consumeReasonBean) {
AppCompatCheckBox compatCheckBox = viewHolder.getView(R.id.cb_consumption_reason);
compatCheckBox.setText(s);
compatCheckBox.setText(consumeReasonBean.getDescription());
compatCheckBox.setChecked(viewHolder.getAdapterPosition() == selectIndex);
}
......@@ -137,10 +145,11 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
}
public void setSelectIndex(int selectIndex) {
if (this.selectIndex < getData().size()) {
notifyItemChanged(this.selectIndex);
}
int lastSelect = this.selectIndex;
this.selectIndex = selectIndex;
if (lastSelect < getData().size()) {
notifyItemChanged(lastSelect);
}
if (this.selectIndex < getData().size()) {
notifyItemChanged(this.selectIndex);
}
......
......@@ -137,6 +137,7 @@
style="@style/Second_Category_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_8"
android:background="@drawable/shape_border_white_bg"
......@@ -167,6 +168,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_13"
android:layout_marginTop="@dimen/dp_8"
android:visibility="gone"
android:background="@drawable/shape_color_da_stoke_fifteen_corners"
android:gravity="center"
android:text="+新增類別"
......
......@@ -10,24 +10,25 @@
android:id="@+id/food_ingredients_category_topbar"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:fitsSystemWindows="true"
android:background="@color/theme_color"
android:fitsSystemWindows="true"
app:qmui_topbar_title_color="@color/theme_white_color" />
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id="@+id/food_ingredients_category_section_layout"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_select_category"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/dp_20"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10"
android:layout_height="wrap_content">
android:layout_marginRight="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_20"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm"
......@@ -44,9 +45,9 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_weight="1"
android:textColor="@color/color_3c"
android:background="@drawable/shape_black_border_small_radius"
android:text="取消" />
android:text="取消"
android:textColor="@color/color_3c" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -23,9 +23,9 @@
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:layout_margin="@dimen/dp_10"
android:visibility="gone"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:layout_width="@dimen/dp_20"
......@@ -156,14 +156,39 @@
android:textSize="@dimen/dp_16"
android:visibility="gone" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm"
style="@style/Save_Btn_Style"
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="確定"
android:visibility="visible" />
android:layout_weight="1">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm"
style="@style/Save_Btn_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:text="確定"
android:visibility="visible" />
<TextView
android:id="@+id/tv_ingredients_food_num"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_gravity="right"
android:autoSizeMaxTextSize="@dimen/dp_8"
android:autoSizeMinTextSize="@dimen/dp_4"
android:background="@drawable/ui_shape_red_oval"
android:gravity="center"
android:text="3"
android:textColor="@color/white"
android:textSize="@dimen/dp_12"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/iv_shopping_cart"
app:layout_constraintTop_toTopOf="@id/iv_shopping_cart" />
</FrameLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_cancel"
......@@ -171,6 +196,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:layout_weight="1"
android:text="取消"
android:visibility="visible" />
......
......@@ -62,7 +62,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_9"
android:text="採購單號:"
tools:text="採購單號:"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" />
......@@ -71,8 +71,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="入庫單號:"
tools:text="入庫單號:"
android:textColor="@color/color_3c"
android:visibility="gone"
android:textSize="@dimen/dp_14" />
<LinearLayout
......@@ -136,8 +137,7 @@
android:layout_width="@dimen/dp_52"
android:layout_height="@dimen/dp_46"
android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/dp_32"
android:src="@drawable/img_partial_receipt" />
android:layout_marginLeft="@dimen/dp_25" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
......
......@@ -19,6 +19,7 @@
android:paddingBottom="@dimen/dp_10">
<ImageView
android:id="@+id/iv_warehouse_img"
android:layout_width="@dimen/dp_77"
android:layout_height="@dimen/dp_77"
android:layout_marginLeft="@dimen/dp_13" />
......@@ -50,10 +51,11 @@
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"
android:text="盒" />
tools:text="盒" />
<View
android:layout_width="0dp"
......@@ -81,7 +83,7 @@
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
tools:text="單價:$10.00" />
tools:text="最新單價:$10.00" />
<TextView
android:id="@+id/tv_warehouse_total_amount"
......
......@@ -12,12 +12,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_36"
android:layout_marginRight="@dimen/dp_36"
android:scaleType="fitXY" />
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_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_20"
android:orientation="horizontal">
<TextView
......@@ -37,6 +39,11 @@
android:textStyle="bold"
tools:text="100" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -54,11 +61,12 @@
tools:text="+100" />
</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:orientation="horizontal">
<TextView
......@@ -73,9 +81,16 @@
android:layout_width="@dimen/dp_86"
android:layout_height="wrap_content"
android:background="@drawable/shape_square_edit_border_3c"
android:text="2"
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:textSize="@dimen/dp_14" />
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatCheckBox
......@@ -9,7 +9,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_10"
android:text="正常消耗" />
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_purchase_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_10"
app:elevation="@dimen/dp_10">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_second_category_title"
style="@style/Second_Category_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/s_3c_to_white"
android:textSize="@dimen/dp_14"
tools:text="瓜果類" />
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
android:id="@+id/iv_category_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="@drawable/ic_red_circular_delete"
android:visibility="gone" />
</androidx.cardview.widget.CardView>
\ No newline at end of file
......@@ -58,8 +58,8 @@
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:visibility="gone"
android:textSize="@dimen/dp_12"
android:visibility="gone"
tools:text="SP001" />
<TextView
......@@ -155,20 +155,24 @@
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_gray_sub" />
<EditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_food_ingredient_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_4"
android:layout_marginRight="@dimen/dp_4"
android:background="@null"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:inputType="number"
android:maxLength="4"
android:paddingLeft="@dimen/dp_4"
android:paddingRight="@dimen/dp_4"
android:text="0"
android:maxLines="1"
android:minWidth="@dimen/dp_30"
android:textColor="@color/black"
android:textSize="@dimen/dp_22" />
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_22"
tools:text="10" />
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_food_operation_add"
......
......@@ -13,9 +13,9 @@
<ImageView
android:id="@+id/iv_img_delete"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_width="@dimen/dp_17"
android:layout_height="@dimen/dp_17"
android:layout_gravity="right"
android:src="@drawable/icon_dialog_close" />
android:src="@drawable/ic_red_delete_pic" />
</FrameLayout>
\ No newline at end of file
......@@ -128,11 +128,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:background="@null"
android:gravity="end|center_vertical"
android:inputType="numberDecimal"
android:maxLines="1"
android:paddingRight="@dimen/dp_10"
android:textColor="@color/color_3c"
android:textColorHighlight="@color/theme_color"
android:textCursorDrawable="@drawable/cursor_theme"
......@@ -163,13 +163,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:background="@null"
android:textCursorDrawable="@drawable/cursor_theme"
android:paddingRight="@dimen/dp_10"
android:gravity="end|center_vertical"
android:inputType="numberDecimal"
android:maxLines="1"
android:textColor="@color/color_3c"
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_15"
android:textStyle="bold"
tools:text="2" />
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_purchase_category"
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/dp_3"
android:layout_marginTop="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_4"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_second_category_title"
style="@style/Second_Category_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_3"
android:layout_marginTop="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_4"
android:background="@drawable/s_app_color_to_bf"
android:gravity="center"
android:textColor="@color/s_3c_to_white"
android:textSize="@dimen/dp_14"
......@@ -23,6 +22,7 @@
android:id="@+id/iv_category_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="right"
android:src="@drawable/ic_red_circular_delete" />
</FrameLayout>
\ No newline at end of file
</androidx.cardview.widget.CardView>
\ No newline at end of file
......@@ -11,9 +11,9 @@
android:layout_width="match_parent"
android:layout_height="@dimen/dp_55"
android:gravity="center_vertical"
android:layout_marginBottom="@dimen/dp_1"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_18"
android:paddingRight="@dimen/dp_18">
android:paddingLeft="@dimen/dp_18">
<TextView
android:id="@+id/tv_radio_section_title"
......@@ -26,8 +26,10 @@
<CheckBox
android:id="@+id/cb_radio_section"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:layout_width="wrap_content"
android:paddingRight="@dimen/dp_18"
android:gravity="center"
android:layout_height="match_parent"
android:button="@drawable/selector_radio_circle_bg" />
</LinearLayout>
......
......@@ -189,7 +189,7 @@
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_gray_sub" />
<EditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_food_ingredient_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -4,11 +4,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_eight_corners_bg"
android:elevation="@dimen/dp_10"
android:orientation="vertical">
android:orientation="vertical"
android:paddingBottom="@dimen/dp_4">
<LinearLayout
android:layout_width="match_parent"
......@@ -51,17 +51,18 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_9"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_9"
android:paddingRight="@dimen/dp_9"
android:orientation="horizontal">
android:paddingTop="@dimen/dp_9"
android:paddingRight="@dimen/dp_9">
<TextView
android:id="@+id/tv_warehouse_order_time_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下單日期:"
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16"
tools:text="下單日期:" />
android:textSize="@dimen/sp_16" />
<TextView
android:id="@+id/tv_warehouse_details_order_time"
......@@ -86,18 +87,19 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_9"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_9"
android:paddingRight="@dimen/dp_9"
android:paddingBottom="@dimen/dp_10"
android:orientation="horizontal">
android:paddingTop="@dimen/dp_9"
android:layout_marginBottom="@dimen/dp_6"
android:paddingRight="@dimen/dp_9">
<TextView
android:id="@+id/tv_warehouse_time_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="入庫日期:"
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16"
tools:text="入庫日期:" />
android:textSize="@dimen/sp_16" />
<TextView
android:id="@+id/tv_warehouse_details_time"
......@@ -118,4 +120,21 @@
android:textSize="@dimen/sp_14"
tools:text="採購入庫" />
</LinearLayout>
<TextView
android:id="@+id/tv_warehouse_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="@dimen/dp_4"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
android:paddingTop="@dimen/dp_4"
android:paddingBottom="@dimen/dp_4"
android:privateImeOptions="@dimen/dp_10"
android:textColor="@color/white"
android:textSize="@dimen/dp_14"
android:visibility="gone"
tools:text="即將過期:3日" />
</LinearLayout>
\ No newline at end of file
......@@ -51,7 +51,8 @@
<TextView
android:id="@+id/tv_warehouse_item_total_amount"
style="@style/WareHouse_item_TextStyle"
android:layout_width="@dimen/dp_55"
android:layout_width="wrap_content"
android:minWidth="@dimen/dp_55"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_0"
android:text="總價" />
......
......@@ -53,7 +53,8 @@
<TextView
android:id="@+id/tv_warehouse_item_total_amount"
style="@style/WareHouse_item_TextStyle"
android:layout_width="@dimen/dp_55"
android:layout_width="wrap_content"
android:minWidth="@dimen/dp_55"
android:drawableRight="@drawable/ic_sort"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_0"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_choose_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="@dimen/dp_7"
android:paddingBottom="@dimen/dp_7">
<ImageView
android:id="@+id/iv_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="但"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
</LinearLayout>
\ No newline at end of file
......@@ -25,15 +25,18 @@
<EditText
android:id="@+id/et_input"
android:layout_width="@dimen/dp_70"
android:layout_height="@dimen/dp_21"
android:layout_height="wrap_content"
android:maxLines="1"
android:background="@drawable/shape_login_edit_border"
android:drawablePadding="@dimen/dp_3"
android:paddingTop="@dimen/dp_2"
android:paddingBottom="@dimen/dp_2"
android:textCursorDrawable="@drawable/cursor_theme"
android:paddingLeft="@dimen/dp_5"
android:paddingRight="@dimen/dp_5"
android:background="@drawable/selector_edit_48_aaa_bg"
android:inputType="number"
android:text=""
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
......@@ -79,7 +82,7 @@
android:gravity="center"
android:paddingTop="@dimen/dp_12"
android:paddingBottom="@dimen/dp_12"
android:text="確定" />
android:text="@string/str_determine" />
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_cancel"
......@@ -91,7 +94,7 @@
android:gravity="center"
android:paddingTop="@dimen/dp_12"
android:paddingBottom="@dimen/dp_12"
android:text="確定" />
android:text="@string/str_cancel" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -11,6 +11,10 @@
<string name="str_supplier">供應商</string>
<string name="str_species">種類</string>
<string name="str_inventory_consumption">庫存消耗</string>
<string name="str_consumption_inventory">消耗庫存:</string>
<string name="str_manual_input">手動輸入</string>
<string name="str_remark">備註</string>
<string name="str_remark_colon">備註:</string>
<string name="str_save">保存</string>
......@@ -18,5 +22,14 @@
<string name="str_format_purchase_no">採購單號:%1$s</string>
<string name="str_format_warehouse_no">入庫單號:%1$s</string>
<string name="str_format_remark">備註:%1$d</string>
<string name="str_format_positive">+%1$d</string>
<string name="str_format_positive">+%1$s</string>
<string name="str_format_less">-%1$s</string>
<string name="str_unit_price_colon">單價:$%1$.2f</string>
<string name="str_latest_unit_price_colon">最新單價:$%1$.2f</string>
<string name="str_total_amount_colon">總價:$%1$.2f</string>
<string name="str_cancel">取消</string>
<string name="str_determine">確定</string>
<string name="str_delete_category_tip">是否確認刪除該類別【%1$s】,子類和食材將一同刪除?</string>
</resources>
\ No newline at end of file
......@@ -35,6 +35,7 @@ ext {
//support
"appcompat-v7" : 'androidx.appcompat:appcompat:1.0.2',//不要超過1.0.2,不然android5.1.1用webview會有問題
"design" : 'com.google.android.material:material:1.0.0',
"support-design" : 'com.android.support:design:28.0.0',
"support-v4" : 'androidx.legacy:legacy-support-v4:1.0.0',
"cardview-v7" : 'androidx.cardview:cardview:1.0.0',
"annotations" : 'androidx.annotation:annotation:1.0.0',
......
......@@ -58,6 +58,7 @@ dependencies {
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
}
api rootProject.ext.dependencies["support-design"]
api rootProject.ext.dependencies["annotations"]
//view
api(rootProject.ext.dependencies["autolayout"]) {
......
......@@ -39,6 +39,7 @@ import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
......@@ -85,6 +86,9 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem
return mCache;
}
public int getColor(int colorId){
return ContextCompat.getColor(requireContext(), colorId);
}
@NonNull
@Override
......
......@@ -128,7 +128,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.gcssloop.recyclerview:pagerlayoutmanager:2.3.8'
//陰影背景
api 'com.github.lihangleo2:ShadowLayout:2.1.6'
......
......@@ -6,6 +6,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
......@@ -63,7 +64,7 @@ public class GsonUtils {
if (gson != null) {
t = gson.fromJson(gsonString, cls);
}
} catch (JSONException e) {
} catch (JSONException | JsonSyntaxException | IllegalStateException e) {
e.printStackTrace();
}
return t;
......
......@@ -3,8 +3,10 @@ package com.gingersoft.gsa.cloud.common.utils.inputFilter;
import android.content.Context;
import android.text.InputFilter;
import android.util.Log;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -94,15 +96,15 @@ public class InputFilterUtils {
public static InputFilter getMaxLengthFilterDisChAndEn(int maxLength) {
return (source, start, end, dest, dstart, dend) -> {
if (dest != null) {
int beforeLength = TextUtil.getStringLength(dest.toString());
int sourceLength = TextUtil.getStringLength(source.toString());
int beforeLength = dest.length();
int sourceLength = source.length();
int keep = maxLength - beforeLength;
if (keep <= 0) {
return "";
} else if (keep >= sourceLength) {
return null; // keep original
} else {
keep += sourceLength;
keep += start;
if (Character.isHighSurrogate(source.charAt(keep - 1))) {
--keep;
if (keep == sourceLength) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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