Commit 044908ec by 张建升

菜品食材綁定 代码同步

parent adb702b0
......@@ -24,7 +24,6 @@ public class DishDetailBean {
private boolean deletes;// 非必须 删除 false 未删除 true 删除
private String foodBasicUnit;// string 非必须 食材基本单位
private List<DeputyUnitBean> foodUnits;
private boolean show=true;
public DishDetailBean(PurchaseFoodBean foodBean , DishNode dishNode ) {
// this.id = foodBean.get; ///此时的 id 一定是null deletes必是f
......@@ -41,6 +40,5 @@ public class DishDetailBean {
this.foodNo = foodBean.getFoodNo();
this.type = 0;
this.foodUnits = foodBean.getFoodUnits();
this.show = true;
}
}
......@@ -97,7 +97,6 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
public void onError(@NotNull Throwable t) {
super.onError(t);
mRootView.loadDishGroupFail();
LogUtil.e("ZJS"," onError ");
}
});
}
......@@ -121,15 +120,22 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
@Override
public void onNext(DishDetailResultBean dishDetailBean) {//數據處理
if (dishDetailBean.isSuccess()) {
LogUtil.e("ZJS"," dishDetailBean"+dishDetailBean.toString());
dishNode.setDetailBean(dishDetailBean);
mRootView.loadDishesInfo(dishNode,dishDetailBean);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(dishDetailBean.getErrMsg())) {
mRootView.showMessage(dishDetailBean.getErrMsg());
mRootView.loadDishesFail();
} else {
mRootView.loadDishesFail();
mRootView.showMessage(AppConstant.GET_INFO_ERROR);
}
}
@Override
public void onError(@NotNull Throwable t) {
super.onError(t);
mRootView.loadDishesFail();
}
});
}
......@@ -147,7 +153,6 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
@Override
public void onNext(BaseResult bindResult) {//數據處理
if (bindResult.isSuccess()) {
LogUtil.e("ZJS"," 菜品食材綁定成功 bindResult"+bindResult.toString());
DishDetailResultBean dishDetailResultBean=new DishDetailResultBean();
dishDetailResultBean.setData(dishDetailBeans);
dishNode.setDetailBean(dishDetailResultBean);
......
package com.gingersoft.supply_chain.mvp.ui.adapter.dishes;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -19,7 +22,8 @@ import java.util.List;
*/
public class DishDetailAdapter extends BaseQuickAdapter<DishDetailBean, BaseViewHolder> {
public DishDetailAdapter(Context context, List<DishDetailBean> foods) {
private List<DishDetailBean> dels=new ArrayList<>();
public DishDetailAdapter( List<DishDetailBean> foods) {
super(R.layout.item_dishes_foods,foods);
addChildClickViewIds(R.id.tv_dishes_unit,R.id.tv_dishes_del);
}
......@@ -29,20 +33,54 @@ public class DishDetailAdapter extends BaseQuickAdapter<DishDetailBean, BaseView
protected void convert(@NotNull BaseViewHolder viewHolder, DishDetailBean item) {
viewHolder.setText(R.id.tv_dishes_name, item.getFoodName());//食材名字
viewHolder.setText(R.id.tv_dishes_unit, item.getBasicUnitName());//配置的單位
if (item.isShow()) {
// viewHolder.itemView.setVisibility(View.VISIBLE);
// viewHolder.setTextColor(R.id.tv_dishes_name, ArmsUtils.getColor(context, R.color.color_18));
} else {
// viewHolder.itemView.setVisibility(View.GONE);
// viewHolder.setTextColor(R.id.tv_dishes_name, ArmsUtils.getColor(context, R.color.switcher_off_color));
final EditText count=viewHolder.getView(R.id.et_dishes_count);
count.setTag(item);
count.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) {
}
// viewHolder.setText(R.id.tv_dishes_unit, item.getUnitName());
List<DeputyUnitBean> deputyUnitBeans= item.getFoodUnits();//副單位
if (CollectionUtils.isNullOrEmpty(deputyUnitBeans)) {
// addChildClickViewIds(R.id.tv_dishes_unit); consumeQuantity
@Override
public void afterTextChanged(Editable s) {
DishDetailBean tag= (DishDetailBean) count.getTag();
if (TextUtil.isEmptyOrNullOrUndefined(s)) {
ToastUtils.show(getContext(),"數量不能為空");
count.setText(String.valueOf(tag.getConsumeQuantity()));
count.setSelection(count.getText().toString().length());
}else {
tag.setConsumeQuantity(Integer.parseInt(s.toString()));
}
}
viewHolder.setText(R.id.tv_dishes_count, String.valueOf(item.getConsumeQuantity()));//消耗數量
});
count.setText(String.valueOf(item.getConsumeQuantity()));//消耗數量
}
public void addDel(DishDetailBean del){
dels.add(del);
}
public List<DishDetailBean> getDels() {
return dels;
}
public void removeDel(DishDetailBean remove){
for (int i = 0; i < dels.size(); i++) {
DishDetailBean del=dels.get(i);
if (remove.getPurchaseFoodId()==del.getPurchaseFoodId()) {
dels.remove(del);
}
}
}
public void clearDel(){
dels.clear();
}
}
......@@ -38,8 +38,6 @@ public class DishProvider extends BaseNodeProvider {
@Override
public void onClick(@NotNull BaseViewHolder helper, @NotNull View view, BaseNode data, int position) {
DishNode entity = (DishNode) data;
LogUtil.e("zjs"," onClick entity.isExpanded()="+entity.toString());
if (entity.isExpanded()) {
getAdapter().collapse(position);
} else {
......
......@@ -95,7 +95,7 @@ public class DishesGroupProvider extends BaseNodeProvider {
DishesGroupNode groupNode= (DishesGroupNode)data;
List<DishNode> dishNodes= groupNode.getDishNodes();
LogUtil.e("zjs","父菜单点击 onClick position ="+position+" getFoodName"+groupNode.getFoodName()+" groupNode="+groupNode.isExpanded());
// LogUtil.e("zjs","父菜单点击 onClick position ="+position+" getFoodName"+groupNode.getFoodName()+" groupNode="+groupNode.isExpanded());
if (CollectionUtils.isNotNullOrEmpty(dishNodes)) {
if (groupNode.getPos()==0) {
groupNode.setPos(1);
......
......@@ -452,7 +452,6 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction
protected void confirm() {
ArrayList<PurchaseFoodBean> purchaseFood = mPresenter.getPurchaseFood();
if (CollectionUtils.isNotNullOrEmpty(purchaseFood)) {
LogUtil.e("zjs"," purchaseFood "+purchaseFood.size());
Bundle bundle = new Bundle();
bundle.putSerializable("zjs", purchaseFood);
setFragmentResult(RESULT_OK, bundle);
......
......@@ -94,14 +94,14 @@
</LinearLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:id="@+id/dish_refreshLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:id="@+id/fresh_header"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_30"
android:layout_height="@dimen/dp_48"
app:srlAccentColor="#aaa"
app:srlDrawableArrow="@drawable/ic_pulling"
app:srlDrawableMarginRight="@dimen/dp_5"
......@@ -113,7 +113,7 @@
app:srlTextPulling="下滑查看上一分類"
app:srlTextRefreshing="正在飛速加載..."
app:srlTextRelease="釋放查看上一分類"
app:srlTextSizeTitle="@dimen/dp_12" />
app:srlTextSizeTitle="@dimen/dp_16" />
<com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout
android:id="@+id/view_stick_head"
......@@ -128,17 +128,6 @@
</com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout>
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="@dimen/dp_30"
app:srlDrawableArrow="@drawable/ic_push"
app:srlDrawableMarginRight="@dimen/dp_5"
app:srlDrawableSize="@dimen/dp_12"
app:srlTextFailed="加載完成"
app:srlTextLoading="正在飛速加載中..."
app:srlTextPulling="上拉加載更多"
app:srlTextRelease="釋放查看下一分類"
app:srlTextSizeTitle="@dimen/dp_12" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
......
......@@ -30,6 +30,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="@dimen/dp_4"
android:paddingRight="@dimen/dp_4"
android:textColor="@color/color_18"
tools:text="單位" />
......@@ -40,14 +42,24 @@
android:layout_marginBottom="@dimen/dp_2"
android:background="@color/supply_function_color" />
<TextView
android:id="@+id/tv_dishes_count"
style="@style/WareHouse_item_TextStyle"
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_dishes_count"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="@dimen/dp_6"
android:layout_marginRight="@dimen/dp_6"
android:layout_marginTop="@dimen/dp_4"
android:layout_marginBottom="@dimen/dp_4"
android:textColor="@color/color_18"
tools:text="數量" />
android:background="@drawable/shape_border_bg_c8"
android:gravity="center"
android:inputType="numberDecimal"
android:maxLines="1"
android:textColorHighlight="@color/theme_color"
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_15"
tools:text="2" />
<View
android:layout_width="1px"
......
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