ClassificationSelect.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import * as React from "react";
  2. import { StyleSheet } from "react-native";
  3. import { Cascader, BottomModal } from "beeshell";
  4. import { useModel } from "flooks";
  5. const styles = StyleSheet.create({
  6. inputContainer: {
  7. flexDirection: "row",
  8. alignItems: "center",
  9. paddingVertical: 10,
  10. paddingHorizontal: 4,
  11. },
  12. input: {
  13. flex: 1,
  14. },
  15. label: {
  16. width: 80,
  17. marginRight: 19,
  18. flexShrink: 0,
  19. },
  20. labelleft: {
  21. width: 73,
  22. flexShrink: 0,
  23. },
  24. right: {
  25. flexDirection: "row",
  26. },
  27. code: {
  28. paddingHorizontal: 5,
  29. marginLeft: 5,
  30. },
  31. selectContent: {
  32. backgroundColor: "#F0F0F0",
  33. },
  34. titleStyle: {
  35. fontSize: 15,
  36. },
  37. leftLabelTextStyle: {
  38. fontSize: 13,
  39. },
  40. rightLabelTextStyle: {
  41. fontSize: 13,
  42. },
  43. sub: {
  44. color: "#787878",
  45. position: "absolute",
  46. left: 90,
  47. zIndex: 2,
  48. },
  49. upload: {
  50. marginTop: 20,
  51. width: 67,
  52. height: 67,
  53. },
  54. });
  55. export default function OpenTimeCom(props) {
  56. const { selectTitle, list, node$, defaultValue, submit } = props;
  57. const [Node, setNode] = React.useState();
  58. const { cancel, confirm } = useModel("wordsModel");
  59. const [selectVal, setSelectVal] = React.useState("");
  60. const [selectInfo, setSelectInfo] = React.useState({});
  61. if (node$) {
  62. node$.useSubscription(() => {
  63. setSelectVal(defaultValue);
  64. Node.open();
  65. });
  66. }
  67. return (
  68. <BottomModal
  69. ref={c => {
  70. setNode(c);
  71. }}
  72. title={selectTitle}
  73. titleStyle={styles.titleStyle}
  74. cancelable
  75. leftLabelText={cancel}
  76. leftLabelTextStyle={styles.leftLabelTextStyle}
  77. rightLabelText={confirm}
  78. rightLabelTextStyle={styles.rightLabelTextStyle}
  79. rightCallback={() => {
  80. Node.close();
  81. submit(selectInfo);
  82. }}
  83. >
  84. <Cascader
  85. style={{
  86. width: "100%",
  87. height: 200,
  88. marginBottom: 50,
  89. minHeight: 200,
  90. }}
  91. data={list}
  92. fieldKeys={{
  93. labelKey: "name",
  94. idKey: "id",
  95. activeKey: "choose",
  96. }}
  97. onChange={(value, info) => {
  98. setSelectVal(value[0]);
  99. setSelectInfo(info[info.length - 1]);
  100. }}
  101. />
  102. </BottomModal>
  103. );
  104. }