PricingSearchBar.jsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React, { useMemo, useState } from 'react';
  16. import { Input, Button } from '@douyinfe/semi-ui';
  17. import { IconSearch, IconCopy, IconFilter } from '@douyinfe/semi-icons';
  18. import PricingFilterModal from './modal/PricingFilterModal';
  19. const PricingSearchBar = ({
  20. selectedRowKeys,
  21. copyText,
  22. handleChange,
  23. handleCompositionStart,
  24. handleCompositionEnd,
  25. isMobile,
  26. sidebarProps,
  27. t
  28. }) => {
  29. const [showFilterModal, setShowFilterModal] = useState(false);
  30. const SearchAndActions = useMemo(() => (
  31. <div className="flex items-center gap-4 w-full">
  32. {/* 搜索框 */}
  33. <div className="flex-1">
  34. <Input
  35. prefix={<IconSearch />}
  36. placeholder={t('模糊搜索模型名称')}
  37. onCompositionStart={handleCompositionStart}
  38. onCompositionEnd={handleCompositionEnd}
  39. onChange={handleChange}
  40. showClear
  41. />
  42. </div>
  43. {/* 操作按钮 */}
  44. <Button
  45. theme='outline'
  46. type='primary'
  47. icon={<IconCopy />}
  48. onClick={() => copyText(selectedRowKeys)}
  49. disabled={selectedRowKeys.length === 0}
  50. className="!bg-blue-500 hover:!bg-blue-600 text-white"
  51. >
  52. {t('复制')}
  53. </Button>
  54. {/* 移动端筛选按钮 */}
  55. {isMobile && (
  56. <Button
  57. theme="outline"
  58. type='tertiary'
  59. icon={<IconFilter />}
  60. onClick={() => setShowFilterModal(true)}
  61. >
  62. {t('筛选')}
  63. </Button>
  64. )}
  65. </div>
  66. ), [selectedRowKeys, t, handleCompositionStart, handleCompositionEnd, handleChange, copyText, isMobile]);
  67. return (
  68. <>
  69. {SearchAndActions}
  70. {/* 移动端筛选Modal */}
  71. {isMobile && (
  72. <PricingFilterModal
  73. visible={showFilterModal}
  74. onClose={() => setShowFilterModal(false)}
  75. sidebarProps={sidebarProps}
  76. t={t}
  77. />
  78. )}
  79. </>
  80. );
  81. };
  82. export default PricingSearchBar;