ClassificationManageScreen.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 { httpGet } = useModel("httpModel");
  36. function getList() {
  37. return httpGet("/classification/my").then(res => {
  38. return Promise.resolve({
  39. content: res,
  40. last: true,
  41. });
  42. });
  43. }
  44. const renderItem = ({ item, index }) => (
  45. <ListItem
  46. title={item.name}
  47. key={index}
  48. onPress={() => {
  49. if (new ClassificationUtil(item).checkSystem()) {
  50. navigation.navigate("SystemClassificationEdit", {
  51. classifyId: item.id,
  52. classifyTitle: item.name,
  53. });
  54. } else {
  55. navigation.navigate("ClassificationEdit", {
  56. classifyId: item.id,
  57. classifyTitle: item.name,
  58. });
  59. }
  60. }}
  61. accessoryRight={props => (
  62. <View style={styles.right}>
  63. {new ClassificationUtil(item).checkSystem() ? (
  64. <Text category="c1" status="info">
  65. {item.isOpen ? "已启动" : "未启动"}
  66. </Text>
  67. ) : (
  68. <Text category="c1" status="info">
  69. {new ListUtil(item.goodsIds).getLength()}
  70. 件商品
  71. </Text>
  72. )}
  73. <ForwardIcon {...props} />
  74. </View>
  75. )}
  76. />
  77. );
  78. return (
  79. <>
  80. <TipNavHeader title={ClassificationManage}>
  81. <Text>{ClassificationManageText1}</Text>
  82. <Text style={styles.text1}>{ClassificationManageText2}</Text>
  83. <Text style={styles.text1}>{ClassificationManageText3}</Text>
  84. <Text style={styles.text1}>{ClassificationManageText4}</Text>
  85. </TipNavHeader>
  86. <Layout style={styles.top}>
  87. <Text category="h6">{ClassificationManageText5}</Text>
  88. </Layout>
  89. <ListComponent
  90. getInfo={getList}
  91. renderItem={renderItem}
  92. separatorStyle={styles.separatorStyle}
  93. showEmpty
  94. style={styles.list}
  95. ListFooterComponent={() => (
  96. <Button
  97. style={styles.addGoods}
  98. appearance="classification"
  99. status="danger"
  100. accessoryLeft={StarIcon}
  101. onPress={() => {
  102. navigation.navigate("AddNewClass");
  103. }}
  104. />
  105. )}
  106. />
  107. </>
  108. );
  109. }
  110. const StarIcon = props => <Icon {...props} name="plus" />;
  111. const styles = StyleSheet.create({
  112. text1: {
  113. marginTop: 10,
  114. marginLeft: 57,
  115. maxWidth: 200,
  116. },
  117. list: {
  118. backgroundColor: "#fff",
  119. },
  120. separatorStyle: {
  121. height: 0,
  122. },
  123. right: {
  124. flexDirection: "row",
  125. alignItems: "center",
  126. },
  127. addGoods: {
  128. width: 33,
  129. margin: 15,
  130. },
  131. top: {
  132. marginTop: 7,
  133. paddingTop: 20,
  134. paddingBottom: 10,
  135. paddingHorizontal: 13,
  136. },
  137. });