Commit 83c9d9a7 by 张建升

菜品添加食材相關 代码同步

parent 2dd5c457
package com.gingersoft.supply_chain.mvp.bean;
import java.util.List;
import lombok.Data;
@Data
public class DishDetailBean {
private int id;
private int biFoodId;// 非必须 菜品ID
private String dishesName;// 非必须 菜品名称
private int brandId;// number 非必须
private int restaurantId;// number 非必须
private int purchaseFoodId;// number 非必须 食材编号
private String foodName;// string 非必须 食材名称
private int consumeQuantity;// number 非必须 消耗个数
private String basicUnitName;// string 非必须 配置单位
private String foodNo;// string 非必须 食材编号
private int type;// number 非必须 状态 0 食材 1 细项
private boolean deletes;// 非必须 删除 false 未删除 true 删除
private String foodBasicUnit;// string 非必须 食材基本单位
private List<DeputyUnitBean> foodUnits;
}
package com.gingersoft.supply_chain.mvp.bean;
import java.util.List;
import lombok.Data;
@Data
public class DishDetailResultBean {
private boolean success;
private long sysTime;
private String errMsg;
private List<DishDetailBean> data;
}
...@@ -7,7 +7,7 @@ import java.util.List; ...@@ -7,7 +7,7 @@ import java.util.List;
import lombok.Data; import lombok.Data;
@Data @Data
public class DishesResultBean { public class DishesResultBean { //Result
private boolean success; private boolean success;
private long sysTime; private long sysTime;
......
...@@ -2,7 +2,10 @@ package com.gingersoft.supply_chain.mvp.contract; ...@@ -2,7 +2,10 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean; import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean;
import com.gingersoft.supply_chain.mvp.bean.DishesResultBean; import com.gingersoft.supply_chain.mvp.bean.DishesResultBean;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode; import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
...@@ -21,21 +24,18 @@ public interface DishesContract { ...@@ -21,21 +24,18 @@ public interface DishesContract {
* 加載菜品組數據 * 加載菜品組數據
*/ */
void loadDishGroupInfo( List<DishesGroupNode> dishGroup); void loadDishGroupInfo( List<DishesGroupNode> dishGroup);
/* 查询菜品食材信息*/
void loadDishesInfo(DishesResultBean dishes); void loadDishesInfo(DishNode dishNode, DishDetailResultBean dishesDetail);
/** /**
* 加載失敗 * 加載失敗
*/ */
void loadFail(); void loadDishGroupFail();
/** void loadDishesFail();
* 結束加載並且沒有更多數據了
*/
void finishLoad(boolean noData);
/** /**
* 加載食品 * 加載/修改菜品食材信息
* *
* @param buyIngredientsBeans 顯示的食材 * @param buyIngredientsBeans 顯示的食材
*/ */
...@@ -49,9 +49,9 @@ public interface DishesContract { ...@@ -49,9 +49,9 @@ public interface DishesContract {
interface Model extends IModel { interface Model extends IModel {
Observable<DishesResultBean> getDishGroupData(Map<String, Object> map); Observable<DishesResultBean> getDishGroupData(Map<String, Object> map);
Observable<DishesResultBean> getDishesData(Map<String, Object> map); Observable<DishDetailResultBean> getDishesDetailData(Map<String, Object> map);
Observable<BaseResult> bindDishes(Map<String, Object> map); Observable<String> bindDishes(Map<String, Object> map);
} }
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ package com.gingersoft.supply_chain.mvp.model; ...@@ -3,6 +3,8 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean;
import com.gingersoft.supply_chain.mvp.bean.DishesResultBean; import com.gingersoft.supply_chain.mvp.bean.DishesResultBean;
import com.gingersoft.supply_chain.mvp.server.SupplierServer; import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -44,13 +46,16 @@ public class DishesModel extends BaseModel implements DishesContract.Model { ...@@ -44,13 +46,16 @@ public class DishesModel extends BaseModel implements DishesContract.Model {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getDishesList(map); return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getDishesList(map);
} }
@Override @Override
public Observable<DishesResultBean> getDishesData(Map<String, Object> map) { public Observable<DishDetailResultBean> getDishesDetailData(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getDishesList(map); return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getPurchaseDishesConversionList(map);
} }
@Override @Override
public Observable<BaseResult> bindDishes(Map<String, Object> map) { public Observable<String> bindDishes(Map<String, Object> map) {
return null; return mRepositoryManager.obtainRetrofitService(SupplierServer.class).bindFoods(map);
} }
} }
\ No newline at end of file
...@@ -3,9 +3,13 @@ package com.gingersoft.supply_chain.mvp.presenter; ...@@ -3,9 +3,13 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.common.constans.AppConstant; import com.gingersoft.gsa.cloud.common.constans.AppConstant;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean;
import com.gingersoft.supply_chain.mvp.bean.DishesResultBean; import com.gingersoft.supply_chain.mvp.bean.DishesResultBean;
import com.gingersoft.supply_chain.mvp.contract.DishesContract; import com.gingersoft.supply_chain.mvp.contract.DishesContract;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode;
import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode; import com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode;
import com.jess.arms.di.scope.FragmentScope; import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader; import com.jess.arms.http.imageloader.ImageLoader;
...@@ -56,11 +60,11 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC ...@@ -56,11 +60,11 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
} }
public void getDishesData() { public void getDishGroupData() {
Map<String, Object> map = new HashMap<>(2); Map<String, Object> map = new HashMap<>(2);
AppConstant.addBrandId(map); AppConstant.addBrandId(map);
AppConstant.addRestaurantId(map); AppConstant.addRestaurantId(map);
mModel.getDishesData(map)//發送請求 mModel.getDishGroupData(map)//發送請求
.subscribeOn(Schedulers.io())//切換到io異步線程 .subscribeOn(Schedulers.io())//切換到io異步線程
.doOnSubscribe(disposable -> mRootView.showLoading(AppConstant.GET_INFO_LOADING))//顯示加載提示框 .doOnSubscribe(disposable -> mRootView.showLoading(AppConstant.GET_INFO_LOADING))//顯示加載提示框
.subscribeOn(AndroidSchedulers.mainThread())//切換到主線程,上面的提示框就在主線程 .subscribeOn(AndroidSchedulers.mainThread())//切換到主線程,上面的提示框就在主線程
...@@ -70,12 +74,45 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC ...@@ -70,12 +74,45 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
.observeOn(AndroidSchedulers.mainThread())//切換到主線程 .observeOn(AndroidSchedulers.mainThread())//切換到主線程
.subscribe(new ErrorHandleSubscriber<DishesResultBean>(mErrorHandler) {//mErrorHandler是統一的錯誤處理 .subscribe(new ErrorHandleSubscriber<DishesResultBean>(mErrorHandler) {//mErrorHandler是統一的錯誤處理
@Override @Override
public void onNext(DishesResultBean orderCategoryBean) {//數據處理 public void onNext(DishesResultBean dishGroup) {//數據處理
if (orderCategoryBean.isSuccess()) { if (dishGroup.isSuccess()) {
List<DishesGroupNode> data = orderCategoryBean.getData(); List<DishesGroupNode> data = dishGroup.getData();
mRootView.loadDishGroupInfo(data); mRootView.loadDishGroupInfo(data);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) { } else if (TextUtil.isNotEmptyOrNullOrUndefined(dishGroup.getErrMsg())) {
mRootView.showMessage(orderCategoryBean.getErrMsg()); mRootView.showMessage(dishGroup.getErrMsg());
mRootView.loadDishGroupFail();
} else {
mRootView.showMessage(AppConstant.GET_INFO_ERROR);
mRootView.loadDishGroupFail();
}
}
});
}
public void getDishesDetailData(final DishNode dishNode) {
Map<String, Object> map = new HashMap<>(4);
map.put("biFoodId",String.valueOf(dishNode.getId()));
map.put("type","0");
AppConstant.addBrandId(map);
AppConstant.addRestaurantId(map);
mModel.getDishesDetailData(map)//發送請求
.subscribeOn(Schedulers.io())//切換到io異步線程
.doOnSubscribe(disposable -> mRootView.showLoading(AppConstant.GET_INFO_LOADING))//顯示加載提示框
.subscribeOn(AndroidSchedulers.mainThread())//切換到主線程,上面的提示框就在主線程
.observeOn(AndroidSchedulers.mainThread())//切換到主線程,隱藏提示框在主線程
.doAfterTerminate(() -> mRootView.hideLoading())//任務執行完成後,隱藏提示框
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))//綁定生命週期,頁面隱藏時斷開請求
.observeOn(AndroidSchedulers.mainThread())//切換到主線程
.subscribe(new ErrorHandleSubscriber<DishDetailResultBean>(mErrorHandler) {//mErrorHandler是統一的錯誤處理
@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());
} else { } else {
mRootView.showMessage(AppConstant.GET_INFO_ERROR); mRootView.showMessage(AppConstant.GET_INFO_ERROR);
} }
......
package com.gingersoft.supply_chain.mvp.server; package com.gingersoft.supply_chain.mvp.server;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean;
import com.gingersoft.supply_chain.mvp.bean.DishesResultBean; import com.gingersoft.supply_chain.mvp.bean.DishesResultBean;
import com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean; import com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean; import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
...@@ -557,16 +559,25 @@ public interface SupplierServer { ...@@ -557,16 +559,25 @@ public interface SupplierServer {
Observable<DishesResultBean> getDishesList(@QueryMap Map<String, Object> map); Observable<DishesResultBean> getDishesList(@QueryMap Map<String, Object> map);
/**
* 查询某个菜品和食材配置关系表
* biFoodId 是 菜品id
* type 是 消耗种类: 0菜品 1细项 目前只传 0
* brandId 是 品牌id
* restaurantId 是 餐厅id
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseDishesConversion/getPurchaseDishesConversionList" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<DishDetailResultBean> getPurchaseDishesConversionList(@QueryMap Map<String, Object> map);
/** /**
* 菜品綁定食材 * 菜品綁定食材
* http://a.ricepon.com:58201/ricepon-purchase/api/ *
* purchaseDishesConversion/getPurchaseDishesConversionDishes?
* parentId=9615&restaurantId=25
* isParent: 0
*/ */
@Headers({"Domain-Name: ricepon-purchase"}) @Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseDishesConversion/getPurchaseDishesConversionDishes" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @GET("purchaseDishesConversion/addPurchaseDishesConversion" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<DishesResultBean> bindFoods(@QueryMap Map<String, Object> map); Observable<String> bindFoods(@QueryMap Map<String, Object> map);
} }
package com.gingersoft.supply_chain.mvp.ui.adapter.dishes;
import android.content.Context;
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.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseWarehousingOrderDetailsVO;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author zjs.
* 菜品食材綁定列表
*/
public class DishDetailAdapter extends BaseQuickAdapter<DishDetailBean, BaseViewHolder> {
private Context context;
private int[] colors = new int[]{R.color.color_f9, R.color.white};
public DishDetailAdapter(Context context, List<DishDetailBean> foods) {
super(R.layout.item_dishes_foods, foods);
this.context = context;
addChildClickViewIds(R.id.tv_dishes_unit,R.id.tv_dishes_del);
// TODO: 2021/7/25 扶單位處理
}
@Override
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());//配置的單位
// 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
}
viewHolder.setText(R.id.tv_dishes_count, item.getConsumeQuantity());//消耗數量
}
}
...@@ -4,6 +4,7 @@ import androidx.annotation.Nullable; ...@@ -4,6 +4,7 @@ import androidx.annotation.Nullable;
import com.chad.library.adapter.base.entity.node.BaseExpandNode; import com.chad.library.adapter.base.entity.node.BaseExpandNode;
import com.chad.library.adapter.base.entity.node.BaseNode; import com.chad.library.adapter.base.entity.node.BaseNode;
import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -15,8 +16,11 @@ public class DishNode extends BaseExpandNode { ...@@ -15,8 +16,11 @@ public class DishNode extends BaseExpandNode {
private boolean isParent; private boolean isParent;
private int seqNo; private int seqNo;
private String foodName; private String foodName;
private boolean isSelect;
private List<BaseNode> childNode; private List<BaseNode> childNode;
//判断是否有配置过
private DishDetailResultBean detailBean;
public void addChildNode(BaseNode baseNode) { public void addChildNode(BaseNode baseNode) {
if (baseNode == null) { if (baseNode == null) {
...@@ -27,6 +31,23 @@ public class DishNode extends BaseExpandNode { ...@@ -27,6 +31,23 @@ public class DishNode extends BaseExpandNode {
} }
childNode.add(baseNode); childNode.add(baseNode);
} }
public boolean isSelect() {
return isSelect;
}
public DishDetailResultBean getDetailBean() {
return detailBean;
}
public void setDetailBean(DishDetailResultBean detailBean) {
this.detailBean = detailBean;
}
public void setSelect(boolean select) {
isSelect = select;
}
public int getId() { public int getId() {
return id; return id;
} }
......
...@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.ui.adapter.dishes; ...@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.ui.adapter.dishes;
import android.view.View; import android.view.View;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.entity.node.BaseNode; import com.chad.library.adapter.base.entity.node.BaseNode;
import com.chad.library.adapter.base.provider.BaseNodeProvider; import com.chad.library.adapter.base.provider.BaseNodeProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
...@@ -25,12 +27,12 @@ public class DishProvider extends BaseNodeProvider { ...@@ -25,12 +27,12 @@ public class DishProvider extends BaseNodeProvider {
public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) { public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) {
DishNode entity = (DishNode) data; DishNode entity = (DishNode) data;
helper.setText(R.id.tv_dish_title, entity.getFoodName()); helper.setText(R.id.tv_dish_title, entity.getFoodName());
LogUtil.e("zjs","isExpanded()="+entity.isExpanded()+" getFoodName"+entity.getFoodName()); if (entity.isSelect()) {
// if (entity.isExpanded()) { helper.setTextColor(R.id.tv_dish_title, ContextCompat.getColor(context, R.color.order_category_name_select_color));
// helper.setImageResource(R.id.iv_dishes_group_icon, R.drawable.ic_dishes_up); }else {
// } else { helper.setTextColor(R.id.tv_dish_title, ContextCompat.getColor(context, R.color.color_18));
// helper.setImageResource(R.id.iv_dishes_group_icon, R.drawable.ic_dishes_down); }
// }
} }
@Override @Override
......
...@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.ui.adapter.dishes; ...@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.ui.adapter.dishes;
import com.chad.library.adapter.base.entity.node.BaseExpandNode; import com.chad.library.adapter.base.entity.node.BaseExpandNode;
import com.chad.library.adapter.base.entity.node.BaseNode; import com.chad.library.adapter.base.entity.node.BaseNode;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
...@@ -15,10 +16,20 @@ public class DishesGroupNode extends BaseExpandNode{ ...@@ -15,10 +16,20 @@ public class DishesGroupNode extends BaseExpandNode{
private boolean isParent; private boolean isParent;
private int seqNo; private int seqNo;
private String foodName; private String foodName;
//子项目项目选中
private int pos;
private List<DishNode> child; private List<DishNode> child;
private List<BaseNode> childNode; private List<BaseNode> childNode;
public int getPos() {
return pos;
}
public void setPos(int pos) {
this.pos = pos;
}
public List<DishNode> getDishNodes() { public List<DishNode> getDishNodes() {
return child; return child;
} }
...@@ -97,19 +108,6 @@ public class DishesGroupNode extends BaseExpandNode{ ...@@ -97,19 +108,6 @@ public class DishesGroupNode extends BaseExpandNode{
return foodName; return foodName;
} }
@Override
public String toString() {
return "DishesGroupNode{" +
"id=" + id +
", parentId=" + parentId +
", restaurantId=" + restaurantId +
", isParent=" + isParent +
", seqNo=" + seqNo +
", foodName='" + foodName + '\'' +
", childNode=" + childNode +
'}';
}
@Nullable @Nullable
@Override @Override
public List<BaseNode> getChildNode() { public List<BaseNode> getChildNode() {
...@@ -117,6 +115,7 @@ public class DishesGroupNode extends BaseExpandNode{ ...@@ -117,6 +115,7 @@ public class DishesGroupNode extends BaseExpandNode{
childNode=new ArrayList<>(); childNode=new ArrayList<>();
} }
if ( child != null) { if ( child != null) {
childNode.clear();
childNode.addAll(child); childNode.addAll(child);
} }
return childNode; return childNode;
......
...@@ -12,6 +12,7 @@ import com.chad.library.adapter.base.entity.node.BaseNode; ...@@ -12,6 +12,7 @@ import com.chad.library.adapter.base.entity.node.BaseNode;
import com.chad.library.adapter.base.provider.BaseNodeProvider; import com.chad.library.adapter.base.provider.BaseNodeProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils; import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
...@@ -91,6 +92,22 @@ public class DishesGroupProvider extends BaseNodeProvider { ...@@ -91,6 +92,22 @@ public class DishesGroupProvider extends BaseNodeProvider {
@Override @Override
public void onClick(@NotNull BaseViewHolder helper, @NotNull View view, BaseNode data, int position) { public void onClick(@NotNull BaseViewHolder helper, @NotNull View view, BaseNode data, int position) {
// 这里使用payload进行增量刷新(避免整个item刷新导致的闪烁,不自然) // 这里使用payload进行增量刷新(避免整个item刷新导致的闪烁,不自然)
getAdapter().expandOrCollapse(position, true, true, DishesTreeAdapter.EXPAND_COLLAPSE_PAYLOAD);
DishesGroupNode groupNode= (DishesGroupNode)data;
List<DishNode> dishNodes= groupNode.getDishNodes();
LogUtil.e("zjs","父菜单点击 onClick position ="+position+" getFoodName"+groupNode.getFoodName()+" groupNode="+groupNode.isExpanded());
if (CollectionUtils.isNotNullOrEmpty(dishNodes)) {
if (groupNode.getPos()==0) {
groupNode.setPos(1);
dishNodes.get(0).setSelect(true);
}
}
if (groupNode.isExpanded()) {
getAdapter().expandOrCollapse(position, true, true, DishesTreeAdapter.EXPAND_COLLAPSE_PAYLOAD);
}else {
getAdapter().expandAndCollapseOther(position,true);
}
} }
} }
...@@ -11,11 +11,14 @@ import androidx.recyclerview.widget.LinearLayoutManager; ...@@ -11,11 +11,14 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.entity.node.BaseNode; import com.chad.library.adapter.base.entity.node.BaseNode;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil; import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2; import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerDishesComponent; import com.gingersoft.supply_chain.di.component.DaggerDishesComponent;
import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean; import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailBean;
import com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean;
import com.gingersoft.supply_chain.mvp.bean.DishesResultBean; import com.gingersoft.supply_chain.mvp.bean.DishesResultBean;
import com.gingersoft.supply_chain.mvp.contract.DishesContract; import com.gingersoft.supply_chain.mvp.contract.DishesContract;
import com.gingersoft.supply_chain.mvp.presenter.DishesPresenter; import com.gingersoft.supply_chain.mvp.presenter.DishesPresenter;
...@@ -44,7 +47,7 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp ...@@ -44,7 +47,7 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
RecyclerView rvDishesGroup; RecyclerView rvDishesGroup;
@BindView(R2.id.rv_dishes_food) @BindView(R2.id.rv_dishes_food)
RecyclerView rvDishes; RecyclerView rvDishes;
private DishesTreeAdapter dishesTreeAdapter;
public static DishesFragment newInstance() { public static DishesFragment newInstance() {
DishesFragment fragment = new DishesFragment(); DishesFragment fragment = new DishesFragment();
return fragment; return fragment;
...@@ -69,22 +72,37 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp ...@@ -69,22 +72,37 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
//setToolBarNoBack(toolbar, "Dishes"); //setToolBarNoBack(toolbar, "Dishes");
initTopBar(topbarFoodIngredients, getString(R.string.str_dishes)); initTopBar(topbarFoodIngredients, getString(R.string.str_dishes));
mPresenter.getDishesData(); mPresenter.getDishGroupData();
} }
private void initDishes( List<DishesGroupNode> dishesGroupNodes){ private void initDishes( List<DishesGroupNode> dishesGroupNodes){
final DishesTreeAdapter dishesTreeAdapter = new DishesTreeAdapter(); dishesTreeAdapter = new DishesTreeAdapter();
dishesTreeAdapter.setOnItemChildClickListener((adapter, view, position) -> { dishesTreeAdapter.setOnItemChildClickListener((adapter, view, position) -> {
BaseNode baseNode= dishesTreeAdapter.getItem(position); BaseNode baseNode= dishesTreeAdapter.getItem(position);
if (baseNode instanceof DishesGroupNode) { if (baseNode instanceof DishNode) {
DishesGroupNode groupNode= (DishesGroupNode) baseNode; DishNode curDishNode= (DishNode) baseNode;
LogUtil.e("ZJS"," groupNode position="+position +" getFoodName"+ groupNode.getFoodName()); int ppos= dishesTreeAdapter.findParentNode(position);
}else { DishesGroupNode pNode = (DishesGroupNode) dishesTreeAdapter.getItem(ppos);
DishNode dishNode= (DishNode) baseNode; if (pNode != null) {
LogUtil.e("ZJS"," onItemChildClick position="+position +" getFoodName"+ dishNode.getFoodName()); int lastPost = pNode.getPos()+ppos;
int myPostion=position-ppos;
boolean isCur=position ==lastPost;
LogUtil.e("ZJS"," lastPost="+lastPost+" myPostion="+myPostion+" isCur="+isCur );
if (!isCur) {//当前点击的不是上次点击的项目
DishNode lastDishNode= (DishNode) dishesTreeAdapter.getItem(lastPost);
lastDishNode.setSelect(false);
curDishNode.setSelect(true);
pNode.setPos(myPostion);
dishesTreeAdapter.notifyItemChanged(lastPost);
dishesTreeAdapter.notifyItemChanged(position);
DishDetailResultBean detailBean= curDishNode.getDetailBean();
LogUtil.e("ZJS"," detailBean="+(detailBean==null));
mPresenter.getDishesDetailData(curDishNode);
}
}
LogUtil.e("ZJS"," onItemChildClick position="+position+" 父节点="+ppos +" getFoodName"+ curDishNode.getFoodName());
} }
LogUtil.e("ZJS"," onItemChildClick position="+position );
}); });
dishesTreeAdapter.setList(dishesGroupNodes); dishesTreeAdapter.setList(dishesGroupNodes);
...@@ -98,17 +116,22 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp ...@@ -98,17 +116,22 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
} }
@Override @Override
public void loadDishesInfo(DishesResultBean dishes) { public void loadDishesInfo(DishNode dishNode,DishDetailResultBean dishesDetail) {
List<DishDetailBean> foods= dishesDetail.getData();
if (CollectionUtils.isNullOrEmpty(foods)) { //沒有加過食材 那麼只有add
}else {
}
} }
@Override @Override
public void loadFail() { public void loadDishGroupFail() {
killMyself();
} }
@Override @Override
public void finishLoad(boolean noData) { public void loadDishesFail() {
} }
......
...@@ -16,69 +16,132 @@ ...@@ -16,69 +16,132 @@
app:qmui_topbar_title_color="@color/theme_white_color" /> app:qmui_topbar_title_color="@color/theme_white_color" />
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="0dp"> android:orientation="horizontal">
<!--菜品--> <!--菜品-->
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_dishes" android:id="@+id/rv_dishes"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_height="match_parent"
android:layout_height="match_parent"> android:layout_weight="1">
</androidx.recyclerview.widget.RecyclerView> </androidx.recyclerview.widget.RecyclerView>
<!-- 食材 --> <!-- 食材 -->
<com.scwang.smartrefresh.layout.SmartRefreshLayout <LinearLayout
android:id="@+id/refreshLayout"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"
android:layout_height="match_parent"> android:orientation="vertical">
<com.scwang.smartrefresh.layout.header.ClassicsHeader <LinearLayout
android:id="@+id/fresh_header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dp_30" android:layout_height="wrap_content"
app:srlAccentColor="#aaa" android:background="@color/colorAccent">
app:srlDrawableArrow="@drawable/ic_pulling"
app:srlDrawableMarginRight="@dimen/dp_5"
app:srlDrawableSize="@dimen/dp_12"
app:srlEnableLastTime="false"
app:srlFinishDuration="300"
app:srlPrimaryColor="@color/trans"
app:srlTextFinish="加載完成"
app:srlTextPulling="下滑查看上一分類"
app:srlTextRefreshing="正在飛速加載..."
app:srlTextRelease="釋放查看上一分類"
app:srlTextSizeTitle="@dimen/dp_12" />
<com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout
android:id="@+id/view_stick_head"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView <TextView
android:id="@+id/rv_dishes_food" style="@style/WareHouse_item_TextStyle"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="食材名稱" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginBottom="@dimen/dp_2"
android:background="@color/supply_function_color" />
<TextView
style="@style/WareHouse_item_TextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="單位" />
<View
android:layout_width="1px"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> android:layout_marginTop="@dimen/dp_2"
android:layout_marginBottom="@dimen/dp_2"
android:background="@color/supply_function_color" />
<TextView
style="@style/WareHouse_item_TextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="數量" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginBottom="@dimen/dp_2"
android:background="@color/supply_function_color" />
<TextView
android:layout_width="@dimen/dp_64"
android:gravity="center"
android:textColor="@color/white"
android:layout_height="wrap_content"
android:text="操作" />
</com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout> </LinearLayout>
<com.scwang.smartrefresh.layout.footer.ClassicsFooter <com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dp_30" android:layout_height="wrap_content">
app:srlDrawableArrow="@drawable/ic_push"
app:srlDrawableMarginRight="@dimen/dp_5" <com.scwang.smartrefresh.layout.header.ClassicsHeader
app:srlDrawableSize="@dimen/dp_12" android:id="@+id/fresh_header"
app:srlTextFailed="加載完成" android:layout_width="match_parent"
app:srlTextLoading="正在飛速加載中..." android:layout_height="@dimen/dp_30"
app:srlTextPulling="上拉加載更多" app:srlAccentColor="#aaa"
app:srlTextRelease="釋放查看下一分類" app:srlDrawableArrow="@drawable/ic_pulling"
app:srlTextSizeTitle="@dimen/dp_12" /> app:srlDrawableMarginRight="@dimen/dp_5"
</com.scwang.smartrefresh.layout.SmartRefreshLayout> app:srlDrawableSize="@dimen/dp_12"
app:srlEnableLastTime="false"
app:srlFinishDuration="300"
app:srlPrimaryColor="@color/trans"
app:srlTextFinish="加載完成"
app:srlTextPulling="下滑查看上一分類"
app:srlTextRefreshing="正在飛速加載..."
app:srlTextRelease="釋放查看上一分類"
app:srlTextSizeTitle="@dimen/dp_12" />
<com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout
android:id="@+id/view_stick_head"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_dishes_food"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</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>
</LinearLayout> </LinearLayout>
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
android:id="@+id/tv_dish_title" android:id="@+id/tv_dish_title"
android:layout_marginLeft="@dimen/dp_16" android:layout_marginLeft="@dimen/dp_16"
android:padding="@dimen/dp_4" android:padding="@dimen/dp_4"
tools:text="1222"
android:textColor="@color/color_18"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tv_head_layout_res_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_dishes_name"
style="@style/WareHouse_item_TextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/color_18"
tools:text="食材名稱" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginBottom="@dimen/dp_2"
android:background="@color/supply_function_color" />
<TextView
android:id="@+id/tv_dishes_unit"
style="@style/WareHouse_item_TextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/color_18"
tools:text="單位" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginBottom="@dimen/dp_2"
android:background="@color/supply_function_color" />
<TextView
android:id="@+id/tv_dishes_count"
style="@style/WareHouse_item_TextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/color_18"
tools:text="數量" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginBottom="@dimen/dp_2"
android:background="@color/supply_function_color" />
<ImageView
android:id="@+id/tv_dishes_del"
android:layout_width="@dimen/dp_64"
android:padding="@dimen/dp_12"
android:drawablePadding="@dimen/dp_6"
android:layout_height="wrap_content"
android:src="@drawable/ic_delete"
tools:text="" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_dishes_foot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/white"
android:gravity="center"
android:padding="@dimen/dp_6"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_dish_add"
style="@style/WareHouse_item_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_16"
android:layout_marginRight="@dimen/dp_16"
android:padding="@dimen/dp_6"
android:text="+ 選擇食材"
android:textColor="@color/theme_color"
android:textSize="@dimen/sp_18"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_dish_done"
style="@style/WareHouse_item_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_16"
android:layout_marginRight="@dimen/dp_16"
android:padding="@dimen/dp_6"
android:text="完成"
android:textColor="@color/theme_color"
android:textSize="@dimen/sp_18"
android:textStyle="bold"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
\ No newline at end of file
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