|
|
@@ -1,330 +1,430 @@
|
|
|
+/* eslint-disable no-else-return */
|
|
|
+/* eslint-disable prefer-const */
|
|
|
+/* eslint-disable react/jsx-one-expression-per-line */
|
|
|
/* eslint-disable no-underscore-dangle */
|
|
|
/* eslint-disable no-shadow */
|
|
|
import * as WebBrowser from "expo-web-browser";
|
|
|
import * as React from "react";
|
|
|
-import {
|
|
|
- StyleSheet,
|
|
|
-} from "react-native";
|
|
|
+import { StyleSheet, View } from "react-native";
|
|
|
import { useModel } from "flooks";
|
|
|
import {
|
|
|
- Layout,
|
|
|
- Text,
|
|
|
- useTheme,
|
|
|
- Button,
|
|
|
- Input,
|
|
|
+ Layout,
|
|
|
+ Text,
|
|
|
+ useTheme,
|
|
|
+ Button,
|
|
|
+ Input,
|
|
|
+ Toggle,
|
|
|
} from "@ui-kitten/components";
|
|
|
import { useFocusEffect, useRoute } from "@react-navigation/native";
|
|
|
import ActionButton from "react-native-action-button";
|
|
|
import ListComponent from "../../components/ListComponent";
|
|
|
import NavHeaderBar from "../../components/NavHeaderBar";
|
|
|
|
|
|
-
|
|
|
-
|
|
|
const styles = StyleSheet.create({
|
|
|
- lay: {
|
|
|
- backgroundColor: "#fff",
|
|
|
- flex: 1,
|
|
|
- },
|
|
|
- padBot: {
|
|
|
- paddingBottom: 100,
|
|
|
- },
|
|
|
- list: {
|
|
|
- paddingVertical: 10,
|
|
|
- paddingHorizontal: 15,
|
|
|
- backgroundColor: "transparent",
|
|
|
- flex: 0,
|
|
|
- },
|
|
|
- item: {
|
|
|
- flexDirection: "row",
|
|
|
- alignItems: "center",
|
|
|
- paddingVertical: 10,
|
|
|
- },
|
|
|
- input: {
|
|
|
- marginHorizontal: 5,
|
|
|
- minWidth: 49,
|
|
|
- },
|
|
|
- text: {
|
|
|
- flex: 1,
|
|
|
- },
|
|
|
- flexRow: {
|
|
|
- flexDirection: "row",
|
|
|
- alignItems: "center",
|
|
|
- },
|
|
|
- buttonlast: {
|
|
|
- marginLeft: 10,
|
|
|
- },
|
|
|
- button: {
|
|
|
- alignSelf: "flex-start",
|
|
|
- },
|
|
|
- money: {
|
|
|
- marginLeft: 10,
|
|
|
- },
|
|
|
+ lay: {
|
|
|
+ backgroundColor: "#fff",
|
|
|
+ flex: 1,
|
|
|
+ },
|
|
|
+ padBot: {
|
|
|
+ paddingBottom: 100,
|
|
|
+ },
|
|
|
+ list: {
|
|
|
+ paddingVertical: 10,
|
|
|
+ paddingHorizontal: 15,
|
|
|
+ backgroundColor: "transparent",
|
|
|
+ flex: 0,
|
|
|
+ },
|
|
|
+ item: {
|
|
|
+ flexDirection: "row",
|
|
|
+ alignItems: "center",
|
|
|
+ paddingVertical: 10,
|
|
|
+ },
|
|
|
+ input: {
|
|
|
+ marginHorizontal: 5,
|
|
|
+ minWidth: 49,
|
|
|
+ // width: 49,
|
|
|
+ },
|
|
|
+ text: {
|
|
|
+ flex: 1,
|
|
|
+ },
|
|
|
+ flexRow: {
|
|
|
+ flexDirection: "row",
|
|
|
+ alignItems: "center",
|
|
|
+ },
|
|
|
+ buttonlast: {
|
|
|
+ marginLeft: 10,
|
|
|
+ },
|
|
|
+ button: {
|
|
|
+ alignSelf: "flex-start",
|
|
|
+ },
|
|
|
+ money: {
|
|
|
+ marginLeft: 10,
|
|
|
+ },
|
|
|
+ addNew2: {
|
|
|
+ width: 80,
|
|
|
+ alignSelf: "center",
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
-
|
|
|
export default function GoodsSpecificationScreen() {
|
|
|
- const theme = useTheme();
|
|
|
- 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(false);
|
|
|
- const [isNew, changeIsNew] = React.useState(false);
|
|
|
+ const theme = useTheme();
|
|
|
+ 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 {
|
|
|
- delText,
|
|
|
- editText,
|
|
|
- confirm,
|
|
|
- cancel,
|
|
|
- successText,
|
|
|
- removeTips,
|
|
|
- } = useModel("wordsModel");
|
|
|
- const { addClassGoods } = useModel("goodsModel");
|
|
|
- useFocusEffect(
|
|
|
- React.useCallback(() => {
|
|
|
- changeBackground(theme["color-primary-500"]);
|
|
|
- }, [])
|
|
|
- );
|
|
|
+ const {
|
|
|
+ delText,
|
|
|
+ editText,
|
|
|
+ confirm,
|
|
|
+ cancel,
|
|
|
+ successText,
|
|
|
+ removeTips,
|
|
|
+ } = useModel("wordsModel");
|
|
|
+ const { addClassGoods } = useModel("goodsModel");
|
|
|
+ useFocusEffect(
|
|
|
+ React.useCallback(() => {
|
|
|
+ changeBackground(theme["color-primary-500"]);
|
|
|
+ }, [])
|
|
|
+ );
|
|
|
|
|
|
- const route = useRoute();
|
|
|
+ const route = useRoute();
|
|
|
|
|
|
- function getList() {
|
|
|
- const { params } = route;
|
|
|
- const { goodsId } = params || {};
|
|
|
- setGoodsId(goodsId);
|
|
|
- return httpGet(
|
|
|
- "/goodsSpecification/byGoodsId",
|
|
|
- {
|
|
|
- goodsId: goodsId || 0,
|
|
|
- },
|
|
|
- true
|
|
|
- ).then(res => {
|
|
|
- changeState(false);
|
|
|
- if (res.length === 0) {
|
|
|
- changeIsNew(true);
|
|
|
- } else {
|
|
|
- changeIsNew(false);
|
|
|
- }
|
|
|
- const content = res || [];
|
|
|
- if (isNew || addNew) {
|
|
|
- content.push({ name: "", amount: "" });
|
|
|
- }
|
|
|
-
|
|
|
- return Promise.resolve({
|
|
|
- content: content.map(item => {
|
|
|
- const _info = { ...item, amount: item.amount.toString() };
|
|
|
-
|
|
|
- if (!_info.id || editList.indexOf(_info.id) !== -1) {
|
|
|
- _info.edit = true;
|
|
|
- } else {
|
|
|
- _info.edit = false;
|
|
|
- }
|
|
|
- return _info;
|
|
|
- }),
|
|
|
- last: true,
|
|
|
- });
|
|
|
+ function getList() {
|
|
|
+ const { params } = route;
|
|
|
+ const { goodsId } = params || {};
|
|
|
+ setGoodsId(goodsId);
|
|
|
+ return httpGet(
|
|
|
+ "/goodsSpecification/byGoodsId",
|
|
|
+ {
|
|
|
+ goodsId: goodsId || 0,
|
|
|
+ },
|
|
|
+ true
|
|
|
+ ).then(res => {
|
|
|
+ changeState(false);
|
|
|
+ let isNew = false;
|
|
|
+ if (res.length === 0) {
|
|
|
+ isNew = true;
|
|
|
+ changeNew([]);
|
|
|
+ } else {
|
|
|
+ isNew = false;
|
|
|
+ }
|
|
|
+ let content = [];
|
|
|
+ if (res.length > 0) {
|
|
|
+ let parents = res.filter(item => {
|
|
|
+ return !item.parent;
|
|
|
});
|
|
|
- }
|
|
|
-
|
|
|
- const editInfo = id => {
|
|
|
- const _editList = [...editList];
|
|
|
- _editList.push(id);
|
|
|
- setEditList(_editList);
|
|
|
- changeState(true);
|
|
|
- };
|
|
|
- const delInfo = (info) => {
|
|
|
- showDialog({
|
|
|
- bodyText: removeTips,
|
|
|
- status: "danger",
|
|
|
- cancelable: true,
|
|
|
- confirmCallback: () => {
|
|
|
- httpPost(`/goodsSpecification/del/${ info.id}`)
|
|
|
- .then(() => {
|
|
|
- success(successText);
|
|
|
- changeState(true);
|
|
|
- })
|
|
|
- .catch(e => {
|
|
|
- warnning(e.error);
|
|
|
- });
|
|
|
- },
|
|
|
+ parents.forEach(item => {
|
|
|
+ content.push(item);
|
|
|
+ let _children = res.filter(_f => {
|
|
|
+ return _f.parent === item.id;
|
|
|
+ });
|
|
|
+ content = content.concat(_children);
|
|
|
});
|
|
|
- };
|
|
|
- // 取消
|
|
|
- const cancelInfo = info => {
|
|
|
- const _editInfo = { ...allEditInfo };
|
|
|
- _editInfo[info.id || "new"] = {};
|
|
|
- setEdit(_editInfo);
|
|
|
+ }
|
|
|
|
|
|
- if (info.id) {
|
|
|
- let _editList = [...editList];
|
|
|
- _editList = _editList.filter(item => {
|
|
|
- return item !== info.id;
|
|
|
+ if (isNew) {
|
|
|
+ content.push({ name: "", multiple: false });
|
|
|
+ } else {
|
|
|
+ addNew.forEach((item, index) => {
|
|
|
+ if (item.addType === "1") {
|
|
|
+ content.push({ name: "", multiple: false, addIndex: index });
|
|
|
+ } else {
|
|
|
+ let _index = content.findIndex(_i => {
|
|
|
+ return _i.id === item.parent;
|
|
|
});
|
|
|
- setEditList(_editList);
|
|
|
- } else if (!isNew) {
|
|
|
- changeNew(false);
|
|
|
- }
|
|
|
- changeState(true);
|
|
|
- };
|
|
|
- // 保存
|
|
|
- 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,
|
|
|
- name,
|
|
|
- amount,
|
|
|
- goodsId,
|
|
|
+ content.splice(_index + 1, 0, {
|
|
|
+ name: "",
|
|
|
+ amount: "",
|
|
|
+ parent: item.parent,
|
|
|
+ addIndex: index,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ content = content.map(item => {
|
|
|
+ const _info = {
|
|
|
+ ...item,
|
|
|
+ amount: item.amount ? item.amount.toString() : "",
|
|
|
};
|
|
|
- if (!info.id && !isNew) {
|
|
|
- changeNew(false);
|
|
|
+ if (!_info.id || editList.indexOf(_info.id) !== -1) {
|
|
|
+ _info.edit = true;
|
|
|
+ } else {
|
|
|
+ _info.edit = false;
|
|
|
}
|
|
|
+ return _info;
|
|
|
+ });
|
|
|
+ setEdit(content);
|
|
|
|
|
|
- addClassGoods(data).then(res => {
|
|
|
- _editInfo.new = {};
|
|
|
- _editInfo[res.id] = {};
|
|
|
- setEdit(_editInfo);
|
|
|
- let _editList = [...editList];
|
|
|
- _editList = _editList.filter(item => {
|
|
|
- return item !== res.id;
|
|
|
+ return Promise.resolve({
|
|
|
+ content,
|
|
|
+ last: true,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ const editInfo = id => {
|
|
|
+ const _editList = [...editList];
|
|
|
+ _editList.push(id);
|
|
|
+ setEditList(_editList);
|
|
|
+ changeState(true);
|
|
|
+ };
|
|
|
+ const delInfo = info => {
|
|
|
+ showDialog({
|
|
|
+ bodyText: removeTips,
|
|
|
+ status: "danger",
|
|
|
+ cancelable: true,
|
|
|
+ confirmCallback: () => {
|
|
|
+ if (!info.parent) {
|
|
|
+ let _allEditInfo = [...allEditInfo];
|
|
|
+ let _children = _allEditInfo.filter(item => {
|
|
|
+ return item.parent === info.id;
|
|
|
+ });
|
|
|
+ if (_children.length > 0) {
|
|
|
+ showDialog({
|
|
|
+ bodyText: "当前分类存在规格,请删除规格后再删除",
|
|
|
+ status: "danger",
|
|
|
});
|
|
|
- setEditList(_editList);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ httpPost(`/goodsSpecification/del/${info.id}`)
|
|
|
+ .then(() => {
|
|
|
+ success(successText);
|
|
|
changeState(true);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- const saveItem = (info, index) => (
|
|
|
- <Layout style={styles.item}>
|
|
|
- <Layout style={[styles.text, styles.flexRow]}>
|
|
|
- <Text category='c1'>
|
|
|
- 添加
|
|
|
- {info.name}
|
|
|
- </Text>
|
|
|
- <Layout style={styles.money}>
|
|
|
- <Text category='c1'>
|
|
|
- ¥
|
|
|
- {info.amount}
|
|
|
- </Text>
|
|
|
- </Layout>
|
|
|
- </Layout>
|
|
|
-
|
|
|
- <Button
|
|
|
- size='small'
|
|
|
- appearance='outline'
|
|
|
- onPress={() => editInfo(info.id)}
|
|
|
- >
|
|
|
- {editText}
|
|
|
- </Button>
|
|
|
- <Button
|
|
|
- size='small'
|
|
|
- status='danger'
|
|
|
- style={styles.buttonlast}
|
|
|
- onPress={() => delInfo(info, index)}
|
|
|
- >
|
|
|
- {delText}
|
|
|
- </Button>
|
|
|
- </Layout>
|
|
|
- );
|
|
|
-
|
|
|
- const editItem = (info, index) => (
|
|
|
- <Layout style={styles.item}>
|
|
|
- <Layout style={[styles.text, styles.flexRow]}>
|
|
|
- <Text>规格</Text>
|
|
|
- <Input
|
|
|
- size='small'
|
|
|
- defaultValue={info.name}
|
|
|
- style={styles.input}
|
|
|
- key={`${index }_0`}
|
|
|
- keyboardType='numeric'
|
|
|
- onChangeText={text => {
|
|
|
- const _editInfo = { ...allEditInfo } || {};
|
|
|
- if (!_editInfo[info.id || "new"]) {
|
|
|
- _editInfo[info.id || "new"] = {};
|
|
|
- }
|
|
|
- _editInfo[info.id || "new"].name = text;
|
|
|
- setEdit(_editInfo);
|
|
|
- }}
|
|
|
- />
|
|
|
- <Text>价钱</Text>
|
|
|
- <Input
|
|
|
- size='small'
|
|
|
- defaultValue={info.amount}
|
|
|
- style={styles.input}
|
|
|
- key={`${index }_1`}
|
|
|
- keyboardType='numeric'
|
|
|
- onChangeText={text => {
|
|
|
- const _editInfo = { ...allEditInfo } || {};
|
|
|
- if (!_editInfo[info.id || "new"]) {
|
|
|
- _editInfo[info.id || "new"] = {};
|
|
|
- }
|
|
|
- _editInfo[info.id || "new"].amount = text;
|
|
|
- setEdit(_editInfo);
|
|
|
- }}
|
|
|
- />
|
|
|
- </Layout>
|
|
|
-
|
|
|
- <Button size='small' onPress={() => saveInfo(info)}>
|
|
|
- {confirm}
|
|
|
- </Button>
|
|
|
- <Button
|
|
|
- size='small'
|
|
|
- appearance='outline'
|
|
|
- style={styles.buttonlast}
|
|
|
- onPress={() => cancelInfo(info)}
|
|
|
- >
|
|
|
- {cancel}
|
|
|
- </Button>
|
|
|
- </Layout>
|
|
|
- );
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ warnning(e.error);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ };
|
|
|
+ // 取消
|
|
|
+ const cancelInfo = info => {
|
|
|
+ if (info.id) {
|
|
|
+ let _editList = [...editList];
|
|
|
+ _editList = _editList.filter(item => {
|
|
|
+ return item !== info.id;
|
|
|
+ });
|
|
|
+ setEditList(_editList);
|
|
|
+ } else {
|
|
|
+ let _addNew = [...addNew];
|
|
|
+ _addNew.splice(info.addIndex, 1);
|
|
|
+ changeNew(_addNew);
|
|
|
+ }
|
|
|
+ changeState(true);
|
|
|
+ };
|
|
|
|
|
|
- const renderItem = ({ item, index }) => {
|
|
|
- if (!item.id || item.edit) {
|
|
|
- return editItem(item, index);
|
|
|
- }
|
|
|
- return saveItem(item);
|
|
|
-
|
|
|
+ // 保存
|
|
|
+ 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(() => {
|
|
|
+ if (info.id) {
|
|
|
+ let _editList = [...editList];
|
|
|
+ _editList = _editList.filter(item => {
|
|
|
+ return item !== info.id;
|
|
|
+ });
|
|
|
+ setEditList(_editList);
|
|
|
+ } else {
|
|
|
+ let _addNew = [...addNew];
|
|
|
+ _addNew.splice(info.addIndex, 1);
|
|
|
+ changeNew(_addNew);
|
|
|
+ }
|
|
|
+ changeState(true);
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
-
|
|
|
+ //
|
|
|
+ const addFullReduction = info => {
|
|
|
+ let list = [...addNew];
|
|
|
+ let hasType1 = list.find(item => {
|
|
|
+ return item.addType === "1";
|
|
|
+ });
|
|
|
|
|
|
-
|
|
|
- //
|
|
|
- const addFullReduction = () => {
|
|
|
- changeNew(true);
|
|
|
+ if (info && info.parent) {
|
|
|
+ let hasParent = list.find(item => {
|
|
|
+ return item.parent === info.parent;
|
|
|
+ });
|
|
|
+ if (!hasParent) {
|
|
|
+ list.push(info);
|
|
|
+ changeNew(list);
|
|
|
changeState(true);
|
|
|
- };
|
|
|
+ }
|
|
|
+ } else if (!info && !hasType1) {
|
|
|
+ list.push({
|
|
|
+ addType: "1",
|
|
|
+ });
|
|
|
+ console.log(list);
|
|
|
+ changeNew(list);
|
|
|
+ changeState(true);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
+ const saveItem = (info, index) => {
|
|
|
+ let editNowInfo = { ...info };
|
|
|
return (
|
|
|
- <>
|
|
|
- <NavHeaderBar title='商品规格编辑' />
|
|
|
+ <View Key={index}>
|
|
|
+ <Layout style={styles.item}>
|
|
|
+ <Layout style={[styles.text, styles.flexRow]}>
|
|
|
+ {editNowInfo.parent ? (
|
|
|
+ <Text category="c1">添加{editNowInfo.name}</Text>
|
|
|
+ ) : (
|
|
|
+ <Text category="s1">分类名:{editNowInfo.name}</Text>
|
|
|
+ )}
|
|
|
+ {!!editNowInfo.parent && (
|
|
|
+ <Layout style={styles.money}>
|
|
|
+ <Text category="c1">¥{editNowInfo.amount}</Text>
|
|
|
+ </Layout>
|
|
|
+ )}
|
|
|
+ {!editNowInfo.parent && (
|
|
|
+ <Layout style={styles.money}>
|
|
|
+ <Text category="s1">
|
|
|
+ {editNowInfo.multiple ? "多选" : "单选"}
|
|
|
+ </Text>
|
|
|
+ </Layout>
|
|
|
+ )}
|
|
|
+ </Layout>
|
|
|
|
|
|
- <Layout style={[styles.lay]}>
|
|
|
- <ListComponent
|
|
|
- getInfo={getList}
|
|
|
- renderItem={renderItem}
|
|
|
- style={styles.list}
|
|
|
- separatorStyle={styles.separatorStyle}
|
|
|
- showEmpty
|
|
|
- extraData={{ allEditInfo }}
|
|
|
- startState={startState}
|
|
|
- />
|
|
|
- <ActionButton
|
|
|
- buttonColor={theme["color-primary-500"]}
|
|
|
- onPress={addFullReduction}
|
|
|
- position='left'
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ appearance="outline"
|
|
|
+ onPress={() => editInfo(editNowInfo.id)}
|
|
|
+ >
|
|
|
+ {editText}
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ status="danger"
|
|
|
+ style={styles.buttonlast}
|
|
|
+ onPress={() => delInfo(editNowInfo, index)}
|
|
|
+ >
|
|
|
+ {delText}
|
|
|
+ </Button>
|
|
|
+ </Layout>
|
|
|
+ {!editNowInfo.parent && (
|
|
|
+ <Button
|
|
|
+ style={styles.addNew2}
|
|
|
+ onPress={() =>
|
|
|
+ addFullReduction({ addType: "2", parent: editNowInfo.id })
|
|
|
+ }
|
|
|
+ >
|
|
|
+ 添加规格
|
|
|
+ </Button>
|
|
|
+ )}
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ const editItem = (info, index) => {
|
|
|
+ let _allEditInfo = [...allEditInfo];
|
|
|
+ let editNowInfo = { ..._allEditInfo[index] };
|
|
|
+ return (
|
|
|
+ <Layout style={styles.item}>
|
|
|
+ <Layout style={[styles.text, styles.flexRow]}>
|
|
|
+ <Text>{editNowInfo.parent ? "规格" : "类名"}</Text>
|
|
|
+ <Input
|
|
|
+ size="small"
|
|
|
+ defaultValue={editNowInfo.name}
|
|
|
+ style={styles.input}
|
|
|
+ key={`${index}_0`}
|
|
|
+ onChangeText={text => {
|
|
|
+ editNowInfo.name = text;
|
|
|
+ _allEditInfo.splice(index, 1, editNowInfo);
|
|
|
+ setEdit(_allEditInfo);
|
|
|
+ }}
|
|
|
/>
|
|
|
+ {!!editNowInfo.parent && (
|
|
|
+ <>
|
|
|
+ <Text>价钱</Text>
|
|
|
+ <Input
|
|
|
+ size="small"
|
|
|
+ defaultValue={info.amount}
|
|
|
+ style={styles.input}
|
|
|
+ key={`${index}_2`}
|
|
|
+ keyboardType="numeric"
|
|
|
+ onChangeText={text => {
|
|
|
+ editNowInfo.amount = text;
|
|
|
+ _allEditInfo.splice(index, 1, editNowInfo);
|
|
|
+ setEdit(_allEditInfo);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ {!editNowInfo.parent && (
|
|
|
+ <>
|
|
|
+ <Text>是否多选</Text>
|
|
|
+ <Toggle
|
|
|
+ key="Toggle"
|
|
|
+ checked={editNowInfo.multiple}
|
|
|
+ onChange={checked => {
|
|
|
+ editNowInfo.multiple = checked;
|
|
|
+ _allEditInfo.splice(index, 1, editNowInfo);
|
|
|
+ setEdit(_allEditInfo);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ )}
|
|
|
</Layout>
|
|
|
- </>
|
|
|
+
|
|
|
+ <Button size="small" onPress={() => saveInfo(editNowInfo)}>
|
|
|
+ {confirm}
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ appearance="outline"
|
|
|
+ style={styles.buttonlast}
|
|
|
+ onPress={() => cancelInfo(editNowInfo)}
|
|
|
+ >
|
|
|
+ {cancel}
|
|
|
+ </Button>
|
|
|
+ </Layout>
|
|
|
);
|
|
|
+ };
|
|
|
+
|
|
|
+ const renderItem = ({ item, index }) => {
|
|
|
+ if (!item.id || item.edit) {
|
|
|
+ return editItem(item, index);
|
|
|
+ }
|
|
|
+ return saveItem(item);
|
|
|
+ };
|
|
|
+
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <NavHeaderBar title="商品规格编辑" />
|
|
|
+
|
|
|
+ <Layout style={[styles.lay]}>
|
|
|
+ <ListComponent
|
|
|
+ getInfo={getList}
|
|
|
+ renderItem={renderItem}
|
|
|
+ style={styles.list}
|
|
|
+ separatorStyle={styles.separatorStyle}
|
|
|
+ showEmpty
|
|
|
+ extraData={{ allEditInfo }}
|
|
|
+ startState={startState}
|
|
|
+ />
|
|
|
+ <ActionButton
|
|
|
+ buttonColor={theme["color-primary-500"]}
|
|
|
+ onPress={addFullReduction}
|
|
|
+ position="left"
|
|
|
+ />
|
|
|
+ </Layout>
|
|
|
+ </>
|
|
|
+ );
|
|
|
}
|