ClassificationManageScreen.js 3.7 KB

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