ClassificationSelect.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 { cancel, confirm } = useModel("wordsModel");
  58. const [selectVal, setSelectVal] = React.useState("");
  59. const [selectInfo, setSelectInfo] = React.useState({});
  60. const bottomRef = React.useRef();
  61. if (node$) {
  62. node$.useSubscription(() => {
  63. setSelectVal(defaultValue);
  64. bottomRef.current.open();
  65. });
  66. }
  67. return (
  68. <BottomModal
  69. ref={bottomRef}
  70. title={selectTitle}
  71. titleStyle={styles.titleStyle}
  72. cancelable
  73. leftLabelText={cancel}
  74. leftLabelTextStyle={styles.leftLabelTextStyle}
  75. rightLabelText={confirm}
  76. rightLabelTextStyle={styles.rightLabelTextStyle}
  77. rightCallback={() => {
  78. bottomRef.current.close();
  79. submit(selectInfo);
  80. }}
  81. >
  82. <Cascader
  83. style={{
  84. width: "100%",
  85. height: 200,
  86. marginBottom: 50,
  87. minHeight: 200,
  88. }}
  89. data={list}
  90. fieldKeys={{
  91. labelKey: "name",
  92. idKey: "id",
  93. activeKey: "choose",
  94. }}
  95. onChange={(value, info) => {
  96. setSelectVal(value[0]);
  97. setSelectInfo(info[info.length - 1]);
  98. }}
  99. />
  100. </BottomModal>
  101. );
  102. }