ClassificationManageScreen.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import * as WebBrowser from "expo-web-browser";
  2. import * as React from "react";
  3. import { useModel } from "flooks";
  4. import {
  5. Layout,
  6. Input,
  7. Button,
  8. Text,
  9. ListItem,
  10. Icon,
  11. } from "@ui-kitten/components";
  12. import { StyleSheet, View } from "react-native";
  13. import ListUtil from "../../Utils/ListUtil";
  14. import { ClassificationUtil } from "../../Utils/SystemRuleUtil";
  15. import ListComponent from "../../components/ListComponent";
  16. import TipNavHeader from "../../components/TipNavHeader";
  17. const ForwardIcon = props => (
  18. <Icon
  19. {...props}
  20. name="arrow-ios-forward"
  21. fill="#B4B4B4"
  22. style={{ width: 15, height: 15, fontWeight: 500 }}
  23. />
  24. );
  25. // 分类设置
  26. export default function ClassificationManageScreen({ navigation, route }) {
  27. const {
  28. ClassificationManage,
  29. ClassificationManageText1,
  30. ClassificationManageText2,
  31. ClassificationManageText3,
  32. ClassificationManageText4,
  33. ClassificationManageText5,
  34. } = useModel("wordsModel");
  35. const {
  36. getUserInfo,
  37. startingAmount,
  38. preparationTime,
  39. updateMerchant,
  40. } = useModel("userModel");
  41. const { success } = useModel("loadingModel");
  42. const { httpGet } = useModel("httpModel");
  43. function getList() {
  44. return httpGet("/classification/my").then(res => {
  45. return Promise.resolve({
  46. content: res,
  47. last: true,
  48. });
  49. });
  50. }
  51. const renderItem = ({ item, index }) => (
  52. <ListItem
  53. title={item.name}
  54. key={index}
  55. onPress={() => {
  56. if (new ClassificationUtil(item).checkSystem()) {
  57. navigation.navigate("SystemClassificationEdit", {
  58. classifyId: item.id,
  59. classifyTitle: item.name,
  60. });
  61. } else {
  62. navigation.navigate("ClassificationEdit", {
  63. classifyId: item.id,
  64. classifyTitle: item.name,
  65. });
  66. }
  67. }}
  68. accessoryRight={props => (
  69. <View style={styles.right}>
  70. {new ClassificationUtil(item).checkSystem() ? (
  71. <Text category="c1" status="info">
  72. {item.isOpen ? "已启动" : "未启动"}
  73. </Text>
  74. ) : (
  75. <Text category="c1" status="info">
  76. {new ListUtil(item.goodsIds).getLength()}件商品
  77. </Text>
  78. )}
  79. <ForwardIcon {...props} />
  80. </View>
  81. )}
  82. />
  83. );
  84. return (
  85. <>
  86. <TipNavHeader title={ClassificationManage}>
  87. <Text>{ClassificationManageText1}</Text>
  88. <Text style={styles.text1}>{ClassificationManageText2}</Text>
  89. <Text style={styles.text1}>{ClassificationManageText3}</Text>
  90. <Text style={styles.text1}>{ClassificationManageText4}</Text>
  91. </TipNavHeader>
  92. <Layout style={styles.top}>
  93. <Text category="h6">{ClassificationManageText5}</Text>
  94. </Layout>
  95. <ListComponent
  96. getInfo={getList}
  97. renderItem={renderItem}
  98. separatorStyle={styles.separatorStyle}
  99. showEmpty={true}
  100. style={styles.list}
  101. ListFooterComponent={() => (
  102. <Button
  103. style={styles.addGoods}
  104. appearance="classification"
  105. status="danger"
  106. accessoryLeft={StarIcon}
  107. onPress={() => {
  108. navigation.navigate("AddNewClass");
  109. }}
  110. />
  111. )}
  112. />
  113. </>
  114. );
  115. }
  116. const StarIcon = props => <Icon {...props} name="plus" />;
  117. const styles = StyleSheet.create({
  118. text1: {
  119. marginTop: 10,
  120. marginLeft: 57,
  121. maxWidth: 200,
  122. },
  123. list: {
  124. backgroundColor: "#fff",
  125. },
  126. separatorStyle: {
  127. height: 0,
  128. },
  129. right: {
  130. flexDirection: "row",
  131. alignItems: "center",
  132. },
  133. addGoods: {
  134. width: 33,
  135. margin: 15,
  136. },
  137. top: {
  138. marginTop: 7,
  139. paddingTop: 20,
  140. paddingBottom: 10,
  141. paddingHorizontal: 13,
  142. },
  143. });