Ver Fonte

新增商品添加规格

panhui há 5 anos atrás
pai
commit
014389cc1c

+ 1 - 1
components/ClassificationSelect.js

@@ -1,5 +1,5 @@
 import * as React from "react";
-import { View, StyleSheet, TouchableWithoutFeedback } from "react-native";
+import {  StyleSheet } from "react-native";
 import { Cascader, BottomModal } from "beeshell";
 import { useModel } from "flooks";
 

+ 28 - 29
components/ListComponentParent.js

@@ -5,11 +5,10 @@ import * as React from "react";
 import { Divider, List, Layout } from "@ui-kitten/components";
 import { useFocusEffect } from "@react-navigation/native";
 import { useModel } from "flooks";
-import { useBoolean } from "@umijs/hooks";
+import { useBoolean, useCreation } from "@umijs/hooks";
 import EmptyComponent from "./EmptyComponent";
 
 export default function ListComponent(props) {
-  const { clearLoading } = useModel("loadingModel");
   const loading = useBoolean();
   const refreshing = useBoolean();
 
@@ -22,39 +21,15 @@ export default function ListComponent(props) {
     separatorStyle,
     ListFooterComponent,
     showEmpty,
-    emptyEvent,
     showList,
     extraData,
-    delId,
-    startState, // 父级调刷新
     initialNumToRender,
-    saveList, // 保持状态
     list$,
   } = props;
 
-  function setList(newList) {
-    dispatch({
-      type: "setInfo",
-      payload: { list: newList, finish: true },
-    });
-  }
-
   function getList() {
     if (getInfo != null) {
-      return getInfo(page, size).then(res => {
-        if (emptyEvent) {
-          if (res.numberOfElements === 0) {
-            emptyEvent(true);
-          } else {
-            emptyEvent(false);
-          }
-        }
-
-        dispatch({
-          type: "setInfo",
-          payload: { list: res.content, finish: res.last },
-        });
-      });
+      return getInfo();
     }
     return Promise.reject();
   }
@@ -78,10 +53,34 @@ export default function ListComponent(props) {
 
   useFocusEffect(
     React.useCallback(() => {
-      // onRefresh();
+      onRefresh();
     }, [])
   );
 
+  const showdataList = useCreation(() => {
+    const returnList = [];
+    console.log(dataList);
+    dataList.forEach(value => {
+      returnList.push(value);
+      if (value.children.length > 0) {
+        returnList.push(
+          value.children.map((item, index) => {
+            return { ...item, childIndex: index };
+          })
+        );
+      }
+    });
+
+    return [
+      ...returnList.flat().map(item => {
+        if (item.amount != null) {
+          item.amount = item.amount.toString();
+        }
+        return item;
+      }),
+    ];
+  }, [dataList]);
+
   const changePorps = React.useMemo(() => {
     let _props = { renderItem: () => <Layout /> };
     if (showList !== false) {
@@ -108,7 +107,7 @@ export default function ListComponent(props) {
     <List
       refreshing={refreshing.state}
       style={[style]}
-      data={dataList}
+      data={showdataList}
       removeClippedSubviews
       initialNumToRender={initialNumToRender || 10}
       ListHeaderComponent={ListHeaderComponent}

+ 10 - 13
components/TabBarIcon.js

@@ -2,18 +2,15 @@
 import * as React from "react";
 import { Icon, useTheme } from "@ui-kitten/components";
 
-
 export default function TabBarIcon(props) {
-    const theme = useTheme();
-    return (
-      <Icon
-        name={props.name}
-        style={{ width: 30, height: 30 }}
-        fill={
-                props.focused
-                    ? theme["color-primary-500"]
-                    : theme["color-basic-600"]
-            }
-      />
-    );
+  const theme = useTheme();
+  return (
+    <Icon
+      name={props.name}
+      style={{ width: 30, height: 30 }}
+      fill={
+        props.focused ? theme["color-primary-500"] : theme["color-basic-600"]
+      }
+    />
+  );
 }

+ 259 - 252
language/zh.js

@@ -1,272 +1,279 @@
 export default {
-    // 页面的文字
+  // 页面的文字
 
-    welcom: "欢迎使用叮咚外卖平台",
-    login_form_1: "手机号",
-    login_pla_1: "输入商家手机号",
-    login_form_2: "密码",
-    login_pla_2: "输入密码",
-    login_form_3: "验证码",
-    login_pla_3: "输入验证码",
-    login_tab_1: "密码登录",
-    login_tab_2: "验证码登陆",
-    login_btn_code_1: "发送验证码",
-    login_btn_code_2: "已发送",
-    login_btn_sub: "登录",
-    login_btn_forget: "忘记密码",
-    login_btn_rej: "商户注册",
-    register_form_1: "商家名称",
-    register_pla_1: "输入商家名称",
-    register_form_2: "显示名称",
-    register_pla_2: "输入显示名称",
-    register_form_3: "确认密码",
-    register_pla_3: "再次输入确认密码",
-    register_form_4: "手机号",
-    register_pla_4: "输入手机号",
+  welcom: "欢迎使用叮咚外卖平台",
+  login_form_1: "手机号",
+  login_pla_1: "输入商家手机号",
+  login_form_2: "密码",
+  login_pla_2: "输入密码",
+  login_form_3: "验证码",
+  login_pla_3: "输入验证码",
+  login_tab_1: "密码登录",
+  login_tab_2: "验证码登陆",
+  login_btn_code_1: "发送验证码",
+  login_btn_code_2: "已发送",
+  login_btn_sub: "登录",
+  login_btn_forget: "忘记密码",
+  login_btn_rej: "商户注册",
+  register_form_1: "商家名称",
+  register_pla_1: "输入商家名称",
+  register_form_2: "显示名称",
+  register_pla_2: "输入显示名称",
+  register_form_3: "确认密码",
+  register_pla_3: "再次输入确认密码",
+  register_form_4: "手机号",
+  register_pla_4: "输入手机号",
 
-    guideHome_title1: "很好!恭喜您已经完成了叮咚合作商家的第一步!",
-    guideHome_title2: "为了用户更好地认识您,请认真填写!",
-    guideHome_form_1: "商家品类",
-    guideHome_form_2: "商家地址",
-    guideHome_form_3: "商家电话",
-    guideHome_form_4: "营业时间",
-    guideHome_form_5: "营业资质",
-    guideHome_form_6: "商家性质",
-    guideHome_form_7: "上传logo",
-    guideHome_pla_1: "输入您的电话号码",
-    guideHome_pla_2: "(可后面再填)",
-    guideHome_pla_3: "(一旦选择不可更改)",
-    guide1_title1: "太好了!您已经在叮咚的外卖版图上站有一席之地了!",
-    guide1_form_1: "商品名称",
-    guide1_pla_1: "输入商品名称",
-    guide1_form_2: "商品价格",
-    guide1_pla_2: "输入商品价格",
-    guide1_form_3: "优惠价格",
-    guide1_pla_3: "输入优惠价格",
-    guide1_form_4: "每日供应数量",
-    guide1_pla_4: "输入每日供应数量",
-    guide1_form_5: "供应时间",
-    guide1_pla_5: "添加商品简介(不超过50字)",
-    guide2_title1:
-        "woo!您的商品看上去就会很畅销!您可以再软件内添加更多的商品。",
-    guide2_title2:
-        "woo!为了用户更好地认识您,请为这些商品建立分类。分类将在商品的左侧栏!",
-    guide2_form_1: "类别名称",
-    guide2_pla_1: "输入类别名称",
-    guide2_pla_2: "比如单人套餐、前菜、主食等等",
-    guide2_form_2: "显示排序",
-    guide2_form_3: "包含商品",
-    guide3_title1: "woo!太好了!您已经在叮咚的外卖版图上站有一席之地了!",
-    guide3_title2: "为了用户更好地认识您,请认真填写!",
-    guide3_form_1: "支付宝账号",
-    guide3_pla_1: "输入支付宝账号",
-    guide3_form_2: "支付宝账户名",
-    guide3_pla_2: "输入支付宝账账户名",
-    guide4_title1: "完美!您已经完成了本向导!",
-    guide4_title2: "完整的信息您可以在后续陆续添加。祝您轻松赚钱,开心生活",
+  guideHome_title1: "很好!恭喜您已经完成了叮咚合作商家的第一步!",
+  guideHome_title2: "为了用户更好地认识您,请认真填写!",
+  guideHome_form_1: "商家品类",
+  guideHome_form_2: "商家地址",
+  guideHome_form_3: "商家电话",
+  guideHome_form_4: "营业时间",
+  guideHome_form_5: "营业资质",
+  guideHome_form_6: "商家性质",
+  guideHome_form_7: "上传logo",
+  guideHome_pla_1: "输入您的电话号码",
+  guideHome_pla_2: "(可后面再填)",
+  guideHome_pla_3: "(一旦选择不可更改)",
+  guide1_title1: "太好了!您已经在叮咚的外卖版图上站有一席之地了!",
+  guide1_form_1: "商品名称",
+  guide1_pla_1: "输入商品名称",
+  guide1_form_2: "商品价格",
+  guide1_pla_2: "输入商品价格",
+  guide1_form_3: "优惠价格",
+  guide1_pla_3: "输入优惠价格",
+  guide1_form_4: "每日供应数量",
+  guide1_pla_4: "输入每日供应数量",
+  guide1_form_5: "供应时间",
+  guide1_pla_5: "添加商品简介(不超过50字)",
+  guide2_title1: "woo!您的商品看上去就会很畅销!您可以再软件内添加更多的商品。",
+  guide2_title2:
+    "woo!为了用户更好地认识您,请为这些商品建立分类。分类将在商品的左侧栏!",
+  guide2_form_1: "类别名称",
+  guide2_pla_1: "输入类别名称",
+  guide2_pla_2: "比如单人套餐、前菜、主食等等",
+  guide2_form_2: "显示排序",
+  guide2_form_3: "包含商品",
+  guide3_title1: "woo!太好了!您已经在叮咚的外卖版图上站有一席之地了!",
+  guide3_title2: "为了用户更好地认识您,请认真填写!",
+  guide3_form_1: "支付宝账号",
+  guide3_pla_1: "输入支付宝账号",
+  guide3_form_2: "支付宝账户名",
+  guide3_pla_2: "输入支付宝账账户名",
+  guide4_title1: "完美!您已经完成了本向导!",
+  guide4_title2: "完整的信息您可以在后续陆续添加。祝您轻松赚钱,开心生活",
 
-    goodsClassificationTitle1: "分类下的商品",
-    goodsClassificationTitle2: "已选择的商品",
-    goodsClassificationTitle3: "未选择的商品",
-    systemClassification1:
-        "该分类为系统预制分类,主要用于提醒用户相关的信息,您可以放餐具以及点单必读等信息。",
-    systemClassification2:
-        "如果您没有放置点单必读商品,系统将不显示该分类。所以,如果暂时没有符合标准的产品,也建议您打开。",
-    systemClassification3:
-        "该分类为系统预制分类,自动罗列了商户中的畅销产品和好评度高的产品,系统会根据销售和评价动态更新。",
-    systemClassification4: "所以,如果暂时没有符合标准的产品,也建议您打开。",
-    systemClassification5:
-        "该分类为系统预制分类,自动罗列了已设置的折扣商品,如果没有折扣商品,系统将不显示该分类。",
-    systemClassification6: "您可以在“我的”->“我的优惠活动”中配置折扣商品。",
-    systemClassTips1: "确定要关闭该系统分类吗?",
+  goodsClassificationTitle1: "分类下的商品",
+  goodsClassificationTitle2: "已选择的商品",
+  goodsClassificationTitle3: "未选择的商品",
+  systemClassification1:
+    "该分类为系统预制分类,主要用于提醒用户相关的信息,您可以放餐具以及点单必读等信息。",
+  systemClassification2:
+    "如果您没有放置点单必读商品,系统将不显示该分类。所以,如果暂时没有符合标准的产品,也建议您打开。",
+  systemClassification3:
+    "该分类为系统预制分类,自动罗列了商户中的畅销产品和好评度高的产品,系统会根据销售和评价动态更新。",
+  systemClassification4: "所以,如果暂时没有符合标准的产品,也建议您打开。",
+  systemClassification5:
+    "该分类为系统预制分类,自动罗列了已设置的折扣商品,如果没有折扣商品,系统将不显示该分类。",
+  systemClassification6: "您可以在“我的”->“我的优惠活动”中配置折扣商品。",
+  systemClassTips1: "确定要关闭该系统分类吗?",
 
-    storeAudio: "审核店铺",
-    storeAudioText1: "您的店铺正在审核中",
-    storeAudioText2: "请耐心等待...",
-    storeAudioText3: "恭喜!!!",
-    storeAudioText4: "您的店铺审核成功!",
-    addGoods: "编辑(新增)商品",
-    addGoods2: "新增商品",
-    takeOff: "下架",
-    takeUp: "上架",
+  storeAudio: "审核店铺",
+  storeAudioText1: "您的店铺正在审核中",
+  storeAudioText2: "请耐心等待...",
+  storeAudioText3: "恭喜!!!",
+  storeAudioText4: "您的店铺审核成功!",
+  addGoods: "编辑(新增)商品",
+  addGoods2: "新增商品",
+  takeOff: "下架",
+  takeUp: "上架",
 
-    homeBar: "我的店面",
-    homeTip1: "添加banner",
-    homeTitle1: "店主推荐",
-    homeTitle2: "编辑分类",
-    homeTip2: "月售",
-    homeTip3: "公告",
-    homeTitle3: "公告编辑",
-    homeTab1: "点餐",
-    homeTab2: "评价",
-    homeTab3: "商家",
+  homeBar: "我的店面",
+  homeTip1: "添加banner",
+  homeTitle1: "店主推荐",
+  homeTitle2: "编辑分类",
+  homeTip2: "月售",
+  homeTip3: "公告",
+  homeTitle3: "公告编辑",
+  homeTab1: "点餐",
+  homeTab2: "评价",
+  homeTab3: "商家",
 
-    home3Title1: "商家故事",
-    home3Title2: "文字介绍/品牌故事等等,最多500字",
+  home3Title1: "商家故事",
+  home3Title2: "文字介绍/品牌故事等等,最多500字",
 
-    bannerTitle: "banner",
-    logoTitle: "商家头像",
-    qualificationTitle: "营业资质",
-    userTitle1: "基本信息",
-    userTitle2: "我的优惠",
-    userTitle3: "我的商品",
-    userTitle4: "订单",
-    userTitle5: "评价",
-    userTitle6: "我的叮咚币",
-    userTitle21: "满减",
-    userTitle22: "折扣商品",
-    userTitle23: "首单",
-    userTitle24: "优惠券管理",
-    userTitle31: "编辑商品",
-    userTitle32: "商品分类",
-    userTitle33: "招牌商品",
-    userTitle34: "我的推荐位",
-    userTitle41: "自动接单、订单语音设置",
-    userTitle42: "我的对账单",
-    userTitle61: "账单查询",
-    userTitle62: "我的银行卡",
+  bannerTitle: "banner",
+  logoTitle: "商家头像",
+  qualificationTitle: "营业资质",
+  userTitle1: "基本信息",
+  userTitle2: "我的优惠",
+  userTitle3: "我的商品",
+  userTitle4: "订单",
+  userTitle5: "评价",
+  userTitle6: "我的叮咚币",
+  userTitle21: "满减",
+  userTitle22: "折扣商品",
+  userTitle23: "首单",
+  userTitle24: "优惠券管理",
+  userTitle31: "编辑商品",
+  userTitle32: "商品分类",
+  userTitle33: "招牌商品",
+  userTitle34: "我的推荐位",
+  userTitle41: "自动接单、订单语音设置",
+  userTitle42: "我的对账单",
+  userTitle61: "账单查询",
+  userTitle62: "我的银行卡",
 
-    orderTitleBtn1: "手动接单",
-    orderTitleBtn2: "编辑语音",
+  orderTitleBtn1: "手动接单",
+  orderTitleBtn2: "编辑语音",
 
-    orderInfo1: "流水号",
-    orderInfo2: "订单时间",
-    orderInfo3: "联系客户",
-    orderInfo4: "详细地址",
-    orderInfo5: "订单商品",
-    orderInfo6: "备注",
-    orderButton1: "拒单",
-    orderButton2: "接单",
-    overTips: "确定要拒单吗?",
-    orderSuceess: "操作成功",
+  orderInfo1: "流水号",
+  orderInfo2: "订单时间",
+  orderInfo3: "联系客户",
+  orderInfo4: "详细地址",
+  orderInfo5: "订单商品",
+  orderInfo6: "备注",
+  orderButton1: "拒单",
+  orderButton2: "接单",
+  overTips: "确定要拒单吗?",
+  orderSuceess: "操作成功",
 
-    // 银行卡
-    bankMainTitle: "选择银行卡",
-    bindBankText1: "绑定银行卡",
-    bankTitle1: "银行",
-    bankTitle2: "卡号",
-    bankTitle3: "姓名",
-    bankTitle4: "身份证号",
-    bankPla1: "输入银行名称",
-    bankPla2: "输入银行卡号",
-    bankPla3: "输入银行名称",
-    bankPla4: "输入银行名称",
-    bankTitle5: "同意《叮咚外卖快捷支付服务协议》",
-    rechargeBtnText: "预计两小时内到账,确认提现",
-    // 设置
+  // 银行卡
+  bankMainTitle: "选择银行卡",
+  bindBankText1: "绑定银行卡",
+  bankTitle1: "银行",
+  bankTitle2: "卡号",
+  bankTitle3: "姓名",
+  bankTitle4: "身份证号",
+  bankPla1: "输入银行名称",
+  bankPla2: "输入银行卡号",
+  bankPla3: "输入银行名称",
+  bankPla4: "输入银行名称",
+  bankTitle5: "同意《叮咚外卖快捷支付服务协议》",
+  rechargeBtnText: "预计两小时内到账,确认提现",
+  // 设置
 
-    automaticText1: "自动评价回复",
-    automaticText2: "好评自动评价回复",
-    automaticText3: "差评自动评价回复",
-    automaticText4: "添加回复(不超过100字)",
+  automaticText1: "自动评价回复",
+  automaticText2: "好评自动评价回复",
+  automaticText3: "差评自动评价回复",
+  automaticText4: "添加回复(不超过100字)",
 
-    distributionTitle: "配送设置",
-    distributionText1: "起送金额",
-    distributionText2: "每餐平均准备时间",
-    distributionText3: "输入金额",
-    distributionText4: "输入时间",
-    distributionText5: "温馨提示",
-    distributionText6:
-        "起送金额为店铺外送起送金额,每餐平均准备时间用于计算商品配送时间,请根据店铺实际餐品准备情况设置。",
+  distributionTitle: "配送设置",
+  distributionText1: "起送金额",
+  distributionText2: "每餐平均准备时间",
+  distributionText3: "输入金额",
+  distributionText4: "输入时间",
+  distributionText5: "温馨提示",
+  distributionText6:
+    "起送金额为店铺外送起送金额,每餐平均准备时间用于计算商品配送时间,请根据店铺实际餐品准备情况设置。",
 
-    // 我的分类
-    ClassificationManage: "我的分类",
-    ClassificationManageText1: "合理的设置分类具有如下好处",
-    ClassificationManageText2: "(1)可以让用户快速找到适合的商品",
-    ClassificationManageText3:
-        "(2)可以让用户知道商家对于某一样商品的看法和态度",
-    ClassificationManageText4: "同一种商品可以置于不同的分类下。",
-    ClassificationManageText5: "当前有的分类",
-    ClassificationManageText6: "该分类包含了以下商品",
-    // 公共的文字
+  // 我的分类
+  ClassificationManage: "我的分类",
+  ClassificationManageText1: "合理的设置分类具有如下好处",
+  ClassificationManageText2: "(1)可以让用户快速找到适合的商品",
+  ClassificationManageText3:
+    "(2)可以让用户知道商家对于某一样商品的看法和态度",
+  ClassificationManageText4: "同一种商品可以置于不同的分类下。",
+  ClassificationManageText5: "当前有的分类",
+  ClassificationManageText6: "该分类包含了以下商品",
+  // 公共的文字
 
-    saveSuccess: "保存成功",
-    editSuccess: "修改成功",
-    yuan: "元",
-    changeToEnglish: "切换到泰文",
-    changeToChinese: "切换到中文",
-    appName: "叮咚外卖",
-    connect: "联系客服",
-    next: "下一步",
-    pass: "跳过",
-    cancel: "取消",
-    save: "保存",
-    confirm: "确认",
-    MONDAY: "周一",
-    TUESDAY: "周二",
-    WEDNESDAY: "周三",
-    THURSDAY: "周四",
-    FRIDAY: "周五",
-    SATURDAY: "周六",
-    SUNDAY: "周日",
-    every: "每天",
-    start: "开始时间",
-    end: "结束时间",
-    hour: "时",
-    min: "分",
-    minutes: "分钟",
-    weekName: "周期",
-    tip: "提示",
-    passTips: "确认要跳过吗?",
-    add: "添加",
-    remove: "移除",
-    complete: "完成",
-    tab1: "店面",
-    tab2: "订单",
-    tab3: "我的",
-    editText: "编辑",
-    uplaodText: "上传",
-    uplaodImg: "上传图片",
-    removeTips: "确定要移除吗?移除后不可恢复",
-    takeOffTips: "确定要下架该商品吗?",
-    autoBackText: "自动回复",
-    editAutoBack: "编辑自动回复",
-    storeBackInfo: "商家回复",
-    delText: "删除",
-    successText: "成功",
-    addClassTips: "当前已经有两个推荐商品,请先移除后添加。",
-    nothingTips: "暂无数据",
-    fullReduction1: "满",
-    fullReduction2: "减",
-    loading: "加载中",
-    sendCode: "发送验证码",
-    applySuccess: "申请成功",
-    rechargeTime: "预计到账时间",
-    rechargeTitle2: "银行卡",
-    rechargeTitle3: "提现金额",
+  saveSuccess: "保存成功",
+  editSuccess: "修改成功",
+  yuan: "元",
+  changeToEnglish: "切换到泰文",
+  changeToChinese: "切换到中文",
+  appName: "叮咚外卖",
+  connect: "联系客服",
+  next: "下一步",
+  pass: "跳过",
+  cancel: "取消",
+  save: "保存",
+  confirm: "确认",
+  MONDAY: "周一",
+  TUESDAY: "周二",
+  WEDNESDAY: "周三",
+  THURSDAY: "周四",
+  FRIDAY: "周五",
+  SATURDAY: "周六",
+  SUNDAY: "周日",
+  every: "每天",
+  start: "开始时间",
+  end: "结束时间",
+  hour: "时",
+  min: "分",
+  minutes: "分钟",
+  weekName: "周期",
+  tip: "提示",
+  passTips: "确认要跳过吗?",
+  add: "添加",
+  remove: "移除",
+  complete: "完成",
+  tab1: "店面",
+  tab2: "订单",
+  tab3: "我的",
+  editText: "编辑",
+  uplaodText: "上传",
+  uplaodImg: "上传图片",
+  removeTips: "确定要移除吗?移除后不可恢复",
+  takeOffTips: "确定要下架该商品吗?",
+  autoBackText: "自动回复",
+  editAutoBack: "编辑自动回复",
+  storeBackInfo: "商家回复",
+  delText: "删除",
+  successText: "成功",
+  addClassTips: "当前已经有两个推荐商品,请先移除后添加。",
+  nothingTips: "暂无数据",
+  fullReduction1: "满",
+  fullReduction2: "减",
+  loading: "加载中",
+  sendCode: "发送验证码",
+  applySuccess: "申请成功",
+  rechargeTime: "预计到账时间",
+  rechargeTitle2: "银行卡",
+  rechargeTitle3: "提现金额",
 
-    // 订单状态
-    NOT_RECEIVED: "未接单",
-    RECEIVED: "已接单",
-    REJECTED: "退单",
-    COMPLETED: "已完成",
-    UNPAID: "未支付",
-    PAID: "已支付",
-    RATED: "待评价",
-    CANCELLED: "已取消",
-    REFUNDED_PENDING: "申请退款中",
-    REFUNDED: "已退款",
-    ALI_PAY: "支付宝",
-    CASH_DELIVERY: "货到付款",
-    CREDIT_CARD: "信用卡",
-    Re_RECEIVED: "待取餐",
-    TAKE_MEAL: "已到店",
-    MEAL_DELIVERY: "正在配送中",
-    CARRY_OUT: "送达",
+  // 订单状态
+  NOT_RECEIVED: "未接单",
+  RECEIVED: "已接单",
+  REJECTED: "退单",
+  COMPLETED: "已完成",
+  UNPAID: "未支付",
+  PAID: "已支付",
+  RATED: "待评价",
+  CANCELLED: "已取消",
+  REFUNDED_PENDING: "申请退款中",
+  REFUNDED: "已退款",
+  ALI_PAY: "支付宝",
+  CASH_DELIVERY: "货到付款",
+  CREDIT_CARD: "信用卡",
+  Re_RECEIVED: "待取餐",
+  TAKE_MEAL: "已到店",
+  MEAL_DELIVERY: "正在配送中",
+  CARRY_OUT: "送达",
 
-    // 账单状态
-    BUY: "购买",
-    INCOME: "收入",
-    REFUND: "退款",
-    WITHDRAW: "提现",
+  // 账单状态
+  BUY: "购买",
+  INCOME: "收入",
+  REFUND: "退款",
+  WITHDRAW: "提现",
 
-    // 提现状态
-    Apply_SUCCESS: "提现成功",
-    Apply_PENDING: "提现处理中",
-    Apply_FAIL: "提现失败",
+  // 提现状态
+  Apply_SUCCESS: "提现成功",
+  Apply_PENDING: "提现处理中",
+  Apply_FAIL: "提现失败",
 
-    // myRecord
-    selectTiltle1: "全部账单",
-    selectTiltle2: "收入账单",
-    selectTiltle3: "提现账单",
+  // myRecord
+  selectTiltle1: "全部账单",
+  selectTiltle2: "收入账单",
+  selectTiltle3: "提现账单",
+
+  statePENDING: "待审核",
+  stateDENY: "审核未通过",
+  buy: "月售",
+  Complaintlist: "我的投诉",
+  EmailDetail1: "系统邮箱",
+  LegalPerson1: "编辑法人信息",
+  LegalPerson2: "法人姓名:",
 };

+ 76 - 5
models/goodsModel.js

@@ -1,3 +1,4 @@
+/* eslint-disable no-else-return */
 /* eslint-disable no-underscore-dangle */
 import ListUtil from "../Utils/ListUtil";
 
@@ -6,6 +7,7 @@ export default {
     selectInfos: [],
     Classifications: [], // 商户分类列表
     classificationId: 0, // 当前操作的商品分类
+    editGoodsMap: new Map(),
   },
   actions: ({ model, setState }) => ({
     // 商家分类选择商品
@@ -103,12 +105,61 @@ export default {
         },
       });
     },
+    // 获取商品分类
+    getGoodsClassParent(goodsId) {
+      const { editGoodsMap } = model();
+      if (goodsId && editGoodsMap.get(goodsId)) {
+        const list = editGoodsMap.get(goodsId);
+        const dataMap = new Map();
+        list.forEach(item => {
+          dataMap.set(item.id, item);
+        });
+        return Promise.resolve(dataMap);
+      } else if (goodsId === "NEW") {
+        editGoodsMap.set(goodsId, []);
+        setState({
+          editGoodsMap,
+        });
+        return Promise.resolve(new Map());
+      } else {
+        const { httpGet } = model("httpModel");
+        return httpGet(
+          "/goodsSpecification/parent",
+          {
+            goodsId,
+          },
+          true
+        ).then(res => {
+          const dataMap = new Map();
+          res.forEach(item => {
+            dataMap.set(item.id, item);
+          });
+          return Promise.resolve(dataMap);
+        });
+      }
+    },
+    // 添加修改的分类
+    setGoodsClassMap(key, map) {
+      let list = [];
+      Array.from(map.values()).forEach(item => {
+        list.push(item);
+        if (item.children.length > 0) {
+          list.push(item.children);
+        }
+      });
+
+      list = list.flat();
+      const { editGoodsMap } = model();
+      editGoodsMap.set(key, list);
+      setState({ editGoodsMap });
+    },
+    removeGoodsClassMap() {
+      setState({ editGoodsMap: new Map() });
+    },
     // 添加分类商品
     addClassGoods(info) {
-      const { successText } = model("wordsModel");
-      const { success, loading } = model("loadingModel");
-      const { httpPost} = model("httpModel");
-      loading();
+      //   const { successText } = model("wordsModel");
+      const { httpPost } = model("httpModel");
       return httpPost(
         "/goodsSpecification/save",
         info,
@@ -117,7 +168,6 @@ export default {
         },
         true
       ).then(res => {
-        success(successText);
         return Promise.resolve(res);
       });
     },
@@ -200,5 +250,26 @@ export default {
 
       return backList;
     },
+
+    // 批量保存规格
+    saveClassByList(list, goodsId) {
+      const { httpPost } = model("httpModel");
+      if (list.length > 0) {
+        return httpPost(
+          "/goodsSpecification/saveAll",
+          {
+            spec: JSON.stringify(
+              list.map(item => {
+                return { ...item, goodsId };
+              })
+            ),
+          },
+          {},
+          true
+        );
+      } else {
+        return Promise.resolve();
+      }
+    },
   }),
 };

+ 37 - 41
screens/Appraisal/ComplaintlistScreen.js

@@ -1,9 +1,7 @@
 import * as WebBrowser from "expo-web-browser";
 import * as React from "react";
 import { useModel } from "flooks";
-import {
-    StyleSheet,
-} from "react-native";
+import { StyleSheet } from "react-native";
 import { useTheme } from "@ui-kitten/components";
 import { useFocusEffect } from "@react-navigation/native";
 import NavHeaderBar from "../../components/NavHeaderBar";
@@ -12,50 +10,48 @@ import Complaint from "../../components/Complaint";
 import ListComponent from "../../components/ListComponent";
 
 const styles = StyleSheet.create({
-    top: {
-        alignItems: "center",
-        paddingVertical: 10,
-        marginBottom: 10,
-    },
-    list: {
-        flex: 1,
-        backgroundColor: "rgb(242, 242, 242)",
-        paddingHorizontal: 15,
-        paddingTop: 20,
-    },
-    separatorStyle: {
-        marginHorizontal: 13,
-    },
+  top: {
+    alignItems: "center",
+    paddingVertical: 10,
+    marginBottom: 10,
+  },
+  list: {
+    flex: 1,
+    backgroundColor: "rgb(242, 242, 242)",
+    paddingHorizontal: 15,
+    paddingTop: 20,
+  },
+  separatorStyle: {
+    marginHorizontal: 13,
+  },
 });
 
 // 余额
 export default function CouponListScreen() {
-    const theme = useTheme();
-    const { changeBackground } = useModel("barModel");
+  const theme = useTheme();
+  const { changeBackground } = useModel("barModel");
 
-    // const {} = useModel("wordsModel");
-    const { getMyList } = useModel("complaintModel");
+//   const { Complaintlist } = useModel("wordsModel");
+  const { getMyList } = useModel("complaintModel");
 
-    useFocusEffect(
-        React.useCallback(() => {
-            changeBackground(theme["color-primary-500"]);
-        }, [])
-    );
+  useFocusEffect(
+    React.useCallback(() => {
+      changeBackground(theme["color-primary-500"]);
+    }, [])
+  );
 
-    const walletItem = ({ item, index }) => (
-      <Complaint key={index} info={item} />
-    );
+  const walletItem = ({ item, index }) => <Complaint key={index} info={item} />;
 
-    return (
-      <>
-        <NavHeaderBar title='我的投诉' />
-        <ListComponent
-          getInfo={getMyList}
-          renderItem={walletItem}
-          style={styles.list}
-          separatorStyle={styles.separatorStyle}
-          showEmpty
-        />
-      </>
-    );
+  return (
+    <>
+      <NavHeaderBar title="我的投诉" />
+      <ListComponent
+        getInfo={getMyList}
+        renderItem={walletItem}
+        style={styles.list}
+        separatorStyle={styles.separatorStyle}
+        showEmpty
+      />
+    </>
+  );
 }

+ 221 - 250
screens/Goods/GoodsSpecificationScreenNew.js

@@ -16,7 +16,7 @@ import {
   Toggle,
 } from "@ui-kitten/components";
 import { useFocusEffect, useRoute } from "@react-navigation/native";
-import { useEventEmitter } from "@umijs/hooks";
+import { useEventEmitter, useCreation, useMap, useUnmount } from "@umijs/hooks";
 import ActionButton from "react-native-action-button";
 import ListComponent from "../../components/ListComponentParent";
 import NavHeaderBar from "../../components/NavHeaderBar";
@@ -75,119 +75,62 @@ export default function GoodsSpecificationScreen() {
   const { changeBackground } = useModel("barModel", true);
   // const { mid } = useModel("userModel");
   const { httpGet, httpPost } = useModel("httpModel", true);
-  const { success, warnning } = useModel("loadingModel", true);
   const { showDialog } = useModel("dialogModel");
-  const [allEditInfo, setEdit] = React.useState([]);
   const [goodsId, setGoodsId] = React.useState(0);
-  const [startState, changeState] = React.useState(true);
-  const [editList, setEditList] = React.useState([]);
-  const [addNew, changeNew] = React.useState([]);
-  const [dataList, setDataList] = React.useState([]);
   const list$ = useEventEmitter();
+  const [dataMap, dataMapAction] = useMap();
+  const [editMap, editMapAction] = useMap();
 
-  const {
-    delText,
-    editText,
-    confirm,
-    cancel,
-    successText,
-    removeTips,
-  } = useModel("wordsModel");
-  const { addClassGoods } = useModel("goodsModel");
+  const parentIds = useCreation(() => {
+    return Array.from(dataMap.keys());
+  }, [dataMap]);
+
+  const { delText, editText, confirm, cancel, removeTips } = useModel(
+    "wordsModel"
+  );
+
+  const { addClassGoods, getGoodsClassParent, setGoodsClassMap } = useModel(
+    "goodsModel"
+  );
   useFocusEffect(
     React.useCallback(() => {
       changeBackground(theme["color-primary-500"]);
     }, [])
   );
 
+  useUnmount(() => {
+    setGoodsClassMap(goodsId, dataMap);
+  });
+
   const route = useRoute();
 
   function getList() {
     const { params } = route;
     const { goodsId } = params || {};
-    setGoodsId(goodsId);
-    return httpGet(
-      "/goodsSpecification/parent",
-      {
-        goodsId: goodsId || 0,
-      },
-      true
-    ).then(res => {
-      setDataList(res);
-      return Promise.resolve({
-        content: res,
-        last: true,
-      });
+    setGoodsId(goodsId || "NEW");
+    return getGoodsClassParent(goodsId || "NEW").then(res => {
+      console.log(res);
+      dataMapAction.setAll(res);
+      return Promise.resolve();
     });
   }
 
-  const listByOrder = (list1, list2, type, extra) => {
-    let list = [...list1];
-    if (type === "add") {
-      list2.forEach((item, index) => {
-        if (item.addType === "1") {
-          list.push({ name: "", multiple: false, addIndex: index });
-        } else {
-          let _index = list.findIndex(_i => {
-            return _i.id === item.parent;
-          });
-          list.splice(_index + 1, 0, {
-            name: "",
-            amount: "",
-            parent: item.parent,
-            addIndex: index,
-          });
-        }
-      });
-    } else if (type === "save") {
-      list = list.map(item => {
-        if (
-          (item.addIndex === extra && extra != null) ||
-          item.id === list2[0].id
-        ) {
-          item = { ...list2[0] };
-        }
-        return item;
-      });
-    } else if (type === "edit") {
-      list = list.map(item => {
-        if (item.id === extra) {
-          item = {
-            ...item,
-            edit: true,
-          };
-        }
-        return item;
-      });
-    } else if (type === "cancel" && extra.id) {
-      list = list.map(item => {
-        if (item.id === extra.id) {
-          item.edit = false;
-        }
-        return item;
-      });
-    } else if (type === "del" || (!extra.id && type === "cancel")) {
-      list = list.filter(item => {
-        return (
-          (extra.id && item.id !== extra.id) ||
-          (!extra.id && item.addIndex !== extra.addIndex)
-        );
+  const editInfo = info => {
+    if (!info.parent) {
+      dataMapAction.set(info.id, {
+        ...info,
+        edit: true,
       });
+    } else {
+      let parentinfo = dataMapAction.get(info.parent);
+      parentinfo.children[info.childIndex].edit = true;
+      dataMapAction.set(info.parent, parentinfo);
+    }
+    if (info.id) {
+      editMapAction.set(info.id, info);
+    } else {
+      editMapAction.set(`${info.parent}_${info.childIndex}`, info);
     }
-    setEdit(list);
-    return list;
-  };
-
-  const editInfo = id => {
-    const _editList = [...editList];
-    _editList.push(id);
-    setEditList(_editList);
-    list$.emit({
-      type: "edit",
-      list: [],
-      changeEvent: listByOrder,
-      extra: id,
-    });
   };
   const delInfo = info => {
     showDialog({
@@ -196,166 +139,175 @@ export default function GoodsSpecificationScreen() {
       cancelable: true,
       confirmCallback: () => {
         if (!info.parent) {
-          let _allEditInfo = [...allEditInfo];
-          let _children = _allEditInfo.filter(item => {
-            return item.parent === info.id;
-          });
-          if (_children.length > 0) {
+          let parent = dataMapAction.get(info.id);
+          if (parent.children.length > 0) {
             showDialog({
               bodyText: "当前分类存在规格,请删除规格后再删除",
               status: "danger",
             });
             return;
           }
+          dataMapAction.remove(info.id);
+        } else {
+          let parent = dataMapAction.get(info.parent);
+          parent.children.splice(info.childIndex, 1);
+          dataMapAction.set(info.parent, parent);
+        }
+
+        if (info.id && info.id > 0) {
+          httpPost(`/goodsSpecification/del/${info.id}`, {}, {}, true);
         }
-        httpPost(`/goodsSpecification/del/${info.id}`)
-          .then(() => {
-            success(successText);
-            // changeState(true);
-            list$.emit({
-              type: "del",
-              list: [],
-              changeEvent: listByOrder,
-              extra: info,
-            });
-          })
-          .catch(e => {
-            warnning(e.error);
-          });
       },
     });
   };
   // 取消
   const cancelInfo = info => {
-    if (info.id) {
-      let _editList = [...editList];
-      _editList = _editList.filter(item => {
-        return item !== info.id;
-      });
-      setEditList(_editList);
-      list$.emit({
-        type: "cancel",
-        list: [],
-        changeEvent: listByOrder,
-        extra: info,
-      });
+    // 处理dataMap
+    if (info.parent) {
+      let parent = dataMapAction.get(info.parent);
+      if (info.isNew) {
+        parent.children = parent.children.filter((item, index) => {
+          return index !== info.childIndex;
+        });
+      } else {
+        parent.children = parent.children.map((item, index) => {
+          if (index === info.childIndex) {
+            return {
+              ...item,
+              edit: false,
+            };
+          } else {
+            return item;
+          }
+        });
+      }
+      dataMapAction.set(info.parent, parent);
+    } else if (info.isNew) {
+      dataMapAction.remove(info.id);
     } else {
-      let _addNew = [...addNew];
-      _addNew.splice(info.addIndex, 1);
-      changeNew(_addNew);
-
-      list$.emit({
-        type: "cancel",
-        list: [],
-        changeEvent: listByOrder,
-        extra: info,
+      dataMapAction.set(info.id, {
+        ...info,
+        edit: true,
       });
     }
-    // changeState(true);
+
+    // 处理editMap
+    if (info.id) {
+      editMapAction.remove(info.id);
+    } else {
+      editMapAction.remove(`${info.parent}_${info.childIndex}`);
+    }
   };
 
   // 保存
   const saveInfo = info => {
-    // const _editInfo = { ...allEditInfo };
-    // let name = "";
-    // let amount = "";
-    // if (_editInfo[info.id || "new"]) {
-    //   name = _editInfo[info.id || "new"].name;
-    //   amount = _editInfo[info.id || "new"].amount;
-    // }
-    const data = {
-      ...info,
-      goodsId,
-    };
-    delete data.addIndex;
-    addClassGoods(data).then(res => {
-      if (info.id) {
-        let _editList = [...editList];
-        _editList = _editList.filter(item => {
-          return item !== info.id;
-        });
-        setEditList(_editList);
-        list$.emit({
-          type: "save",
-          list: [res],
-          changeEvent: listByOrder,
-        });
-      } else {
-        let _addNew = [...addNew];
-        _addNew.splice(info.addIndex, 1);
-        changeNew(_addNew);
-        list$.emit({
-          type: "save",
-          list: [res],
-          extra: info.addIndex,
-          changeEvent: listByOrder,
-        });
-      }
-    });
+    let saveData = {};
+    if (info.id) {
+      saveData = editMapAction.get(info.id);
+    } else {
+      saveData = editMapAction.get(`${info.parent}_${info.childIndex}`);
+    }
+    delete saveData.isNew;
+    if (saveData.parent) {
+      let parent = dataMapAction.get(saveData.parent);
+      parent.children[saveData.childIndex] = {
+        ...saveData,
+        edit: false,
+      };
+      dataMapAction.set(saveData.parent, parent);
+    } else {
+      dataMapAction.set(info.id, {
+        ...saveData,
+        edit: false,
+      });
+    }
+
+    // 处理editMap
+    if (info.id) {
+      editMapAction.remove(info.id);
+    } else {
+      editMapAction.remove(`${info.parent}_${info.childIndex}`);
+    }
+
+    if (saveData.id && saveData.id > 0) {
+      const data = {
+        ...saveData,
+        goodsId,
+      };
+      delete data.addIndex;
+      addClassGoods(data);
+    }
   };
 
-  //
-  const addFullReduction = info => {
-    let list = [...addNew];
-    let hasType1 = list.find(item => {
-      return item.addType === "1";
-    });
+  function getRandomId() {
+    const id = 0 - Math.floor(Math.random() * 100 + 1);
+    if (parentIds.includes(id)) {
+      return getRandomId();
+    } else {
+      return id;
+    }
+  }
 
-    if (info && info.parent) {
-      let hasParent = list.find(item => {
-        return item.parent === info.parent;
+  // 添加新类
+  const addFullReduction = info => {
+    if (info) {
+      // 二级分类
+      let parentInfo = dataMapAction.get(info.parent);
+      let hasNew = parentInfo.children.some(item => {
+        return item.isNew;
       });
-      if (!hasParent) {
-        list.push(info);
-        changeNew(list);
-        list$.emit({
-          type: "add",
-          list: [
-            {
-              ...info,
-            },
-          ],
-          changeEvent: listByOrder,
-        });
+      if (!hasNew) {
+        info = {
+          parent: info.parent,
+          name: "",
+          amount: "",
+          edit: true,
+          isNew: true,
+          childIndex: parentInfo.children.length,
+        };
+        parentInfo.children.push(info);
+        dataMapAction.set(info.parent, parentInfo);
+        editMapAction.set(`${info.parent}_${info.childIndex}`, info);
       }
-    } else if (!info && !hasType1) {
-      list.push({
-        addType: "1",
-      });
-      changeNew(list);
-      list$.emit({
-        type: "add",
-        list: [
-          {
-            addType: "1",
-          },
-        ],
-        changeEvent: listByOrder,
+    } else {
+      // 一级分类
+      let hasNew = Array.from(dataMap.values()).some(item => {
+        return item.isNew;
       });
+      if (!hasNew) {
+        let newKey = getRandomId();
+        let newInfo = {
+          name: "",
+          multiple: false,
+          edit: true,
+          isNew: true,
+          children: [],
+          id: newKey,
+        };
+        dataMapAction.set(newKey, newInfo);
+        editMapAction.set(newKey, newInfo);
+      }
     }
   };
 
   const saveItem = (info, index) => {
-    let editNowInfo = { ...info };
     return (
       <View Key={index}>
         <Layout style={styles.item}>
           <Layout style={[styles.text, styles.flexRow]}>
-            {editNowInfo.parent ? (
-              <Text category="c1">添加{editNowInfo.name}</Text>
+            {info.parent ? (
+              <Text category="c1">添加{info.name}</Text>
             ) : (
-              <Text category="s1">分类名:{editNowInfo.name}</Text>
+              <Text category="s1">分类名:{info.name}</Text>
             )}
-            {!!editNowInfo.parent && (
+            {!!info.parent && (
               <Layout style={styles.money}>
-                <Text category="c1">¥{editNowInfo.amount}</Text>
+                <Text category="c1">¥{info.amount}</Text>
               </Layout>
             )}
-            {!editNowInfo.parent && (
+            {!info.parent && (
               <Layout style={styles.money}>
-                <Text category="s1">
-                  {editNowInfo.multiple ? "多选" : "单选"}
-                </Text>
+                <Text category="s1">{info.multiple ? "多选" : "单选"}</Text>
               </Layout>
             )}
           </Layout>
@@ -363,7 +315,7 @@ export default function GoodsSpecificationScreen() {
           <Button
             size="small"
             appearance="outline"
-            onPress={() => editInfo(editNowInfo.id)}
+            onPress={() => editInfo(info)}
           >
             {editText}
           </Button>
@@ -371,16 +323,16 @@ export default function GoodsSpecificationScreen() {
             size="small"
             status="danger"
             style={styles.buttonlast}
-            onPress={() => delInfo(editNowInfo, index)}
+            onPress={() => delInfo(info)}
           >
             {delText}
           </Button>
         </Layout>
-        {!editNowInfo.parent && (
+        {!info.parent && (
           <Button
             style={styles.addNew2}
             onPress={() =>
-              addFullReduction({ addType: "2", parent: editNowInfo.id })
+              addFullReduction({ addType: "2", parent: info.id, index })
             }
           >
             添加规格
@@ -390,51 +342,74 @@ export default function GoodsSpecificationScreen() {
     );
   };
 
-  const editItem = (info, index) => {
-    let _allEditInfo = [...allEditInfo];
-    let editNowInfo = { ..._allEditInfo[index] };
+  const editItem = info => {
+    let editData = {};
+    if (info.id) {
+      editData = editMapAction.get(info.id);
+    } else {
+      editData = editMapAction.get(`${info.parent}_${info.childIndex}`);
+    }
     return (
       <Layout style={styles.item}>
         <Layout style={[styles.text, styles.flexRow]}>
-          <Text>{editNowInfo.parent ? "规格" : "类名"}</Text>
+          <Text>{info.parent ? "规格" : "类名"}</Text>
           <Input
             size="small"
-            defaultValue={editNowInfo.name}
+            defaultValue={editData.name}
             style={styles.input}
-            key={`${index}_0`}
+            key={`${info.id ? info.id : `${info.parent}_${info.childIndex}`}_0`}
             onChangeText={text => {
-              editNowInfo.name = text;
-              _allEditInfo.splice(index, 1, editNowInfo);
-              setEdit(_allEditInfo);
+              if (info.id) {
+                editMapAction.set(info.id, {
+                  ...editData,
+                  name: text,
+                });
+              } else {
+                editMapAction.set(`${info.parent}_${info.childIndex}`, {
+                  ...editData,
+                  name: text,
+                });
+              }
             }}
           />
-          {!!editNowInfo.parent && (
+          {!!info.parent && (
             <>
               <Text>价钱</Text>
               <Input
                 size="small"
-                defaultValue={info.amount}
+                defaultValue={editData.amount}
                 style={styles.input}
-                key={`${index}_2`}
+                key={`${
+                  info.id ? info.id : `${info.parent}_${info.childIndex}`
+                }_1`}
                 keyboardType="numeric"
                 onChangeText={text => {
-                  editNowInfo.amount = text;
-                  _allEditInfo.splice(index, 1, editNowInfo);
-                  setEdit(_allEditInfo);
+                  if (info.id) {
+                    editMapAction.set(info.id, {
+                      ...editData,
+                      amount: text.toString(),
+                    });
+                  } else {
+                    editMapAction.set(`${info.parent}_${info.childIndex}`, {
+                      ...editData,
+                      amount: text.toString(),
+                    });
+                  }
                 }}
               />
             </>
           )}
-          {!editNowInfo.parent && (
+          {!info.parent && (
             <>
               <Text>是否多选</Text>
               <Toggle
                 key="Toggle"
-                checked={editNowInfo.multiple}
+                checked={editData.multiple}
                 onChange={checked => {
-                  editNowInfo.multiple = checked;
-                  _allEditInfo.splice(index, 1, editNowInfo);
-                  setEdit(_allEditInfo);
+                  editMapAction.set(info.id, {
+                    ...editData,
+                    multiple: checked,
+                  });
                 }}
               />
             </>
@@ -442,12 +417,9 @@ export default function GoodsSpecificationScreen() {
         </Layout>
 
         <Button
-          disabled={
-            !editNowInfo.name ||
-            (!!editNowInfo.parent && editNowInfo.amount === "")
-          }
+          disabled={!editData.name || (!editData.amount && !!editData.parent)}
           size="small"
-          onPress={() => saveInfo(editNowInfo)}
+          onPress={() => saveInfo(info)}
         >
           {confirm}
         </Button>
@@ -455,7 +427,7 @@ export default function GoodsSpecificationScreen() {
           size="small"
           appearance="outline"
           style={styles.buttonlast}
-          onPress={() => cancelInfo(editNowInfo)}
+          onPress={() => cancelInfo(info)}
         >
           {cancel}
         </Button>
@@ -464,10 +436,10 @@ export default function GoodsSpecificationScreen() {
   };
 
   const renderItem = ({ item, index }) => {
-    if (!item.id || item.edit) {
+    if (item.edit) {
       return editItem(item, index);
     }
-    return saveItem(item);
+    return saveItem(item, index);
   };
 
   return (
@@ -477,14 +449,13 @@ export default function GoodsSpecificationScreen() {
       <Layout style={[styles.lay]}>
         <ListComponent
           getInfo={getList}
-          dataList={dataList}
+          dataList={dataMap}
           renderItem={renderItem}
           style={styles.list}
           separatorStyle={styles.separatorStyle}
           showEmpty
-          extraData={{ allEditInfo }}
-          startState={startState}
           list$={list$}
+          extraData={{ dataMap, editMap }}
         />
         <ActionButton
           buttonColor={theme["color-primary-500"]}

+ 1 - 1
screens/Goods/index.js

@@ -1,7 +1,7 @@
 import * as WebBrowser from "expo-web-browser";
 import * as React from "react";
 import SearchScreen from "./SearchScreen";
-import GoodsSpecificationScreen from "./GoodsSpecificationScreen";
+import GoodsSpecificationScreen from "./GoodsSpecificationScreenNew";
 
 export default function GoodsConfig(Screen) {
     return (

+ 63 - 47
screens/Guide1Screen.js

@@ -7,6 +7,7 @@ import { StyleSheet } from "react-native";
 import { Layout, Text, useTheme, Button, Card } from "@ui-kitten/components";
 import { useModel } from "flooks";
 import { useFocusEffect, useRoute } from "@react-navigation/native";
+import { useCreation, useUnmount } from "@umijs/hooks";
 import moment from "moment";
 import Textarea from "react-native-textarea";
 import ScrollPage from "../components/ScrollPage";
@@ -77,10 +78,12 @@ export default function Guide1Screen({ navigation }) {
   const { httpGet, httpPost } = useModel("httpModel", true);
   const { success, loading } = useModel("loadingModel", true);
   const { mid, changeGuideStep } = useModel("userModel", true);
-  const { addClassification, sortClassification } = useModel(
-    "goodsModel",
-    true
-  );
+  const {
+    addClassification,
+    editGoodsMap,
+    saveClassByList,
+    removeGoodsClassMap,
+  } = useModel("goodsModel");
 
   const {
     guide1_title1,
@@ -122,6 +125,18 @@ export default function Guide1Screen({ navigation }) {
 
   const [img, changeImg] = React.useState();
 
+  // 需要批量提交的规格
+  const postByList = useCreation(() => {
+    return goodsSpecification.filter(item => {
+      return !item.id || item.id < 0;
+    });
+  }, [goodsSpecification]);
+
+  useUnmount(() => {
+	removeGoodsClassMap();
+	console.log('离开')
+  });
+
   function getInfo(res) {
     changeName(res.name || "");
     if (res.discountAmount) {
@@ -153,38 +168,36 @@ export default function Guide1Screen({ navigation }) {
   }
   useFocusEffect(
     React.useCallback(() => {
-      console.log(route);
       changeBackground(theme["color-primary-500"]);
       const { params, name } = route;
-      setRouteName(name);
+	  setRouteName(name);
       if (params) {
         if (params.id) {
           changeId(params.id);
           loading();
           httpGet(`/goods/get/${params.id}`).then(res => {
             getInfo(res);
-          });
 
-          httpGet(
-            "/goodsSpecification/byGoodsId",
-            {
-              goodsId: params.id,
-            },
-            true
-          ).then(res => {
-            changeGoodsSpecification(sortClassification(res));
+            if (editGoodsMap.has(params.id)) {
+              changeGoodsSpecification(editGoodsMap.get(params.id));
+            } else {
+              changeGoodsSpecification(res.specifications);
+            }
           });
         }
       } else {
         getInfo({});
+        if (editGoodsMap.has("NEW")) {
+          changeGoodsSpecification(editGoodsMap.get("NEW"));
+        }
       }
     }, [])
   );
 
   const specify = () => {
-    return goodsSpecification.map(item => {
+    return goodsSpecification.map((item, index) => {
       return (
-        <Layout key={item.id} style={styles.lay}>
+        <Layout key={index} style={styles.lay}>
           {item.parent ? (
             <Text category="h1">
               添加
@@ -269,22 +282,19 @@ export default function Guide1Screen({ navigation }) {
               onChange={changeDiscountAmount}
               textAlign="right"
             />
-            {!!id && (
-              <>
-                {/* 商品规格 */}
-                <FormInput
-                  label="商品规格"
-                  type="url"
-                  changePath={() => {
-                    navigation.navigate("GoodsSpecification", {
-                      goodsId: id,
-                    });
-                  }}
-                  textAlign="right"
-                />
-                {specify()}
-              </>
-            )}
+
+            {/* 商品规格 */}
+            <FormInput
+              label="商品规格"
+              type="url"
+              changePath={() => {
+                navigation.navigate("GoodsSpecification", {
+                  goodsId: id,
+                });
+              }}
+              textAlign="right"
+            />
+            {specify()}
 
             {/* 每日供应数量 */}
             <FormInput
@@ -332,6 +342,7 @@ export default function Guide1Screen({ navigation }) {
                 status="primary"
                 disabled={!canNext}
                 onPress={() => {
+                  loading();
                   httpPost(
                     "/goods/save",
                     {
@@ -349,21 +360,26 @@ export default function Guide1Screen({ navigation }) {
                     },
                     { body: "json" },
                     true
-                  ).then(res => {
-                    if (!id) {
-                      const { params } = route;
-                      const { classifyId } = params || {};
-                      if (classifyId) {
-                        addClassification(classifyId, res.id);
+                  )
+                    .then(res => {
+                      if (!id) {
+                        const { params } = route;
+                        const { classifyId } = params || {};
+                        if (classifyId) {
+                          addClassification(classifyId, res.id);
+                        }
+                      }
+
+                      return saveClassByList(postByList, res.id);
+                    })
+                    .then(() => {
+                      success(`${id ? "修改" : "添加"}成功`);
+                      if (routeName !== "AddGoods") {
+                        changeGuideStep("2");
+                      } else {
+                        navigation.goBack();
                       }
-                    }
-                    success(`${id ? "修改" : "添加"}成功`);
-                    if (routeName !== "AddGoods") {
-                      changeGuideStep("2");
-                    } else {
-                      navigation.goBack();
-                    }
-                  });
+                    });
                 }}
               >
                 {routeName !== "AddGoods" ? next : confirm}