|
|
@@ -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"]}
|