QueryTableModal.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. <template>
  2. <BasicModal
  3. :open="open"
  4. :title="title"
  5. :showOkBtn="false"
  6. :showCancelBtn="false"
  7. :width="width"
  8. :zIndex="zIndex"
  9. :canFullscreen="canFullscreen"
  10. :centered="true"
  11. :wrapClassName="modalWrapClassName"
  12. @update:open="(v) => emit('update:open', v)"
  13. @cancel="emit('update:open', false)"
  14. >
  15. <div ref="wrapRef" class="query-table-wrap">
  16. <div ref="searchRef" class="query-table-search">
  17. <div v-if="switchOptions?.length" class="query-table-switches">
  18. <button
  19. v-for="option in switchOptions"
  20. :key="String(option.value)"
  21. type="button"
  22. class="query-table-switch"
  23. :class="{ active: activeSwitch === option.value, disabled: option.disabled }"
  24. :disabled="option.disabled"
  25. @click="emit('switch-change', option.value)"
  26. >
  27. {{ option.label }}
  28. </button>
  29. </div>
  30. <div
  31. v-for="item in filterSchema"
  32. :key="item.field"
  33. :class="['search-item', { 'search-item--compare-input': item.type === 'compare-input' }]"
  34. >
  35. <span class="label">{{ item.label }}:</span>
  36. <div v-if="item.type === 'compare-input'" class="compare-input-group">
  37. <Select
  38. :value="getFilterValue(item.operatorField)"
  39. :options="item.options ? [...item.options] : []"
  40. popupClassName="query-table-modal-popup"
  41. :getPopupContainer="getModalPopupContainer"
  42. :style="{ width: `${item.operatorWidth || 72}px`, maxWidth: `${item.operatorWidth || 72}px` }"
  43. @update:value="(value) => setFilterValue(item.operatorField, value)"
  44. />
  45. <Input
  46. v-model:value="filters[item.field]"
  47. :placeholder="item.placeholder || ''"
  48. :style="{
  49. width: `${item.inputWidth || 180}px`,
  50. maxWidth: `${item.inputMaxWidth || item.inputWidth || 180}px`,
  51. }"
  52. />
  53. </div>
  54. <Input
  55. v-else-if="item.type === 'input'"
  56. v-model:value="filters[item.field]"
  57. :placeholder="item.placeholder || ''"
  58. :style="{ width: `${item.width || 260}px`, maxWidth: `${item.maxWidth || 300}px` }"
  59. />
  60. <DatePicker
  61. v-else-if="item.type === 'date'"
  62. v-model:value="filters[item.field]"
  63. :placeholder="item.placeholder || ''"
  64. value-format="YYYY-MM-DD"
  65. popupClassName="query-table-modal-popup"
  66. :getPopupContainer="getModalPopupContainer"
  67. :style="{ width: `${item.width || 260}px`, maxWidth: `${item.maxWidth || 300}px` }"
  68. />
  69. <RangePicker
  70. v-else-if="item.type === 'date-range'"
  71. :value="getDateRangeValue(item)"
  72. :placeholder="item.rangePlaceholder || ['开始日期', '结束日期']"
  73. :value-format="item.valueFormat || 'YYYY-MM-DD'"
  74. popupClassName="query-table-modal-popup"
  75. :getPopupContainer="getModalPopupContainer"
  76. :style="{ width: `${item.width || 300}px`, maxWidth: `${item.maxWidth || 360}px` }"
  77. @update:value="(value) => handleDateRangeChange(item, value)"
  78. />
  79. <Select
  80. v-else-if="item.type === 'select'"
  81. v-model:value="filters[item.field]"
  82. :options="item.options ? [...item.options] : []"
  83. popupClassName="query-table-modal-popup"
  84. :getPopupContainer="getModalPopupContainer"
  85. :style="{ width: `${item.width || 260}px`, maxWidth: `${item.maxWidth || 300}px` }"
  86. />
  87. </div>
  88. <div class="search-actions">
  89. <Button type="primary" :loading="loading" @click="emit('search')">查询</Button>
  90. <Button @click="emit('reset')">重置</Button>
  91. </div>
  92. <div v-if="$slots.searchActions || isTableSettingReady" class="search-utility-actions">
  93. <div v-if="$slots.searchActions" class="search-extra-actions">
  94. <slot name="searchActions"></slot>
  95. </div>
  96. <div v-if="isTableSettingReady" class="search-table-setting">
  97. <TableSetting :setting="tableSetting" :getPopupContainer="getTableSettingPopupContainer" />
  98. </div>
  99. </div>
  100. </div>
  101. <div ref="contentRef" class="query-table-content">
  102. <BasicTable
  103. v-if="dataSource?.length"
  104. :columns="columns"
  105. :action-column="actionColumn"
  106. :data-source="dataSource"
  107. :row-selection="tableRowSelection"
  108. :pagination="false"
  109. :show-index-column="showIndexColumn"
  110. :index-column-props="indexColumnProps"
  111. :show-table-setting="false"
  112. :table-setting="tableSetting"
  113. :can-resize="true"
  114. :max-height="tableMaxHeight"
  115. row-key="rowKey"
  116. @register="handleTableRegister"
  117. @change="handleTableChange"
  118. />
  119. <div v-else class="query-table-empty">
  120. <EmptyState variant="compact" :min-height="Math.max(260, tableMaxHeight)" />
  121. </div>
  122. </div>
  123. </div>
  124. <template #footer>
  125. <div ref="paginationRef" class="pagination-bar">
  126. <div class="pagination-total">共 {{ pagination.total }} 条</div>
  127. <Select
  128. :value="pagination.limit"
  129. class="pagination-size-select"
  130. :options="pageSizeOptions"
  131. :getPopupContainer="getTableSettingPopupContainer"
  132. @change="handlePageSizeSelect"
  133. />
  134. <Pagination
  135. :current="pagination.page"
  136. :total="pagination.total"
  137. :page-size="pagination.limit"
  138. :show-size-changer="false"
  139. @change="handlePageChange"
  140. />
  141. <div class="pagination-jump">
  142. <span>前往</span>
  143. <Input v-model:value="jumpPage" class="pagination-jump-input" @pressEnter="handleJumpPage" />
  144. <span>页</span>
  145. </div>
  146. </div>
  147. </template>
  148. </BasicModal>
  149. </template>
  150. <script lang="ts" setup>
  151. import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
  152. import type { Dayjs } from 'dayjs';
  153. import { Button, DatePicker, Input, Pagination, Select } from 'ant-design-vue';
  154. import { EmptyState } from '@/core/components/EmptyState';
  155. import { BasicTable } from '@/core/components/Table';
  156. import { BasicModal } from '@/core/components/Modal';
  157. import TableSetting from '@/core/components/Table/src/components/settings/index.vue';
  158. import { createTableContext } from '@/core/components/Table/src/hooks/useTableContext';
  159. import { getModalPopupContainer as resolveModalPopupContainer } from '@/core/utils';
  160. const RangePicker = DatePicker.RangePicker;
  161. interface FilterItem {
  162. field: string;
  163. label: string;
  164. type: 'input' | 'date' | 'date-range' | 'select' | 'compare-input';
  165. placeholder?: string;
  166. width?: number;
  167. maxWidth?: number;
  168. options?: ReadonlyArray<{ label: string; value: string | number }>;
  169. operatorField?: string;
  170. operatorWidth?: number;
  171. inputWidth?: number;
  172. inputMaxWidth?: number;
  173. startField?: string;
  174. endField?: string;
  175. rangePlaceholder?: [string, string];
  176. valueFormat?: string;
  177. }
  178. interface SwitchOption {
  179. label: string;
  180. value: string | number;
  181. disabled?: boolean;
  182. }
  183. const props = defineProps<{
  184. open: boolean;
  185. title: string;
  186. width?: number;
  187. zIndex?: number;
  188. loading?: boolean;
  189. filters: Record<string, any>;
  190. filterSchema: ReadonlyArray<FilterItem>;
  191. columns: any[];
  192. actionColumn?: any;
  193. dataSource: any[];
  194. rowSelection?: any;
  195. pagination: { page: number; limit: number; total: number };
  196. totalPages: number;
  197. pageSizeOptions: Array<{ label: string | number; value: string | number }>;
  198. showIndexColumn?: boolean;
  199. showTableSetting?: boolean;
  200. tableSetting?: {
  201. size?: boolean;
  202. setting?: boolean;
  203. redo?: boolean;
  204. fullScreen?: boolean;
  205. };
  206. canFullscreen?: boolean;
  207. wrapClassName?: string;
  208. switchOptions?: ReadonlyArray<SwitchOption>;
  209. activeSwitch?: string | number;
  210. }>();
  211. const emit = defineEmits<{
  212. (e: 'update:open', v: boolean): void;
  213. (e: 'search'): void;
  214. (e: 'reset'): void;
  215. (e: 'prev-page'): void;
  216. (e: 'next-page'): void;
  217. (e: 'page-change', page: number, pageSize: number): void;
  218. (e: 'page-size-change', v: number): void;
  219. (e: 'switch-change', v: string | number): void;
  220. (e: 'sort-change', payload: { orderKey: string; sort: 'ASC' | 'DESC' }): void;
  221. }>();
  222. const handlePaginationChange = (page: number, pageSize: number) => {
  223. if (props.loading || (page === props.pagination.page && pageSize === props.pagination.limit)) return;
  224. emit('page-change', page, pageSize);
  225. };
  226. /** 分页条与数据页保持一致:总条数 + 每页条数下拉 + 原生页码 + 前往页输入框 */
  227. const jumpPage = ref(String(props.pagination.page || 1));
  228. watch(
  229. () => props.pagination.page,
  230. (page) => {
  231. jumpPage.value = String(page || 1);
  232. },
  233. );
  234. const handlePageChange = (page: number) => {
  235. handlePaginationChange(page, props.pagination.limit);
  236. };
  237. const handlePageSizeSelect = (value: any) => {
  238. const pageSize = Number(value);
  239. if (!Number.isFinite(pageSize) || pageSize === props.pagination.limit || props.loading) return;
  240. emit('page-change', 1, pageSize);
  241. };
  242. const handleJumpPage = () => {
  243. const maxPage = Math.max(1, Math.ceil(props.pagination.total / props.pagination.limit));
  244. let target = Math.max(1, Number(jumpPage.value) || 1);
  245. if (target > maxPage) {
  246. target = maxPage;
  247. }
  248. jumpPage.value = String(target);
  249. if (target !== props.pagination.page) {
  250. handlePaginationChange(target, props.pagination.limit);
  251. }
  252. };
  253. const handleTableChange = (_pagination: any, _filters: any, sorter: any) => {
  254. const currentSorter = Array.isArray(sorter) ? sorter[0] : sorter;
  255. if (!currentSorter?.order) return;
  256. const sort = currentSorter.order === 'ascend' ? 'ASC' : currentSorter.order === 'descend' ? 'DESC' : '';
  257. const orderKey = currentSorter?.column?.key || currentSorter?.field;
  258. if (!sort || !orderKey) return;
  259. emit('sort-change', { orderKey: String(orderKey), sort });
  260. };
  261. const width = props.width ?? 1100;
  262. const zIndex = props.zIndex;
  263. const canFullscreen = props.canFullscreen ?? true;
  264. const showTableSetting = props.showTableSetting ?? false;
  265. const showIndexColumn = ref(props.showIndexColumn ?? false);
  266. const modalWrapClassName = computed(() => ['query-table-modal', props.wrapClassName].filter(Boolean).join(' '));
  267. const wrapRef = ref<HTMLElement | null>(null);
  268. const searchRef = ref<HTMLElement | null>(null);
  269. const contentRef = ref<HTMLElement | null>(null);
  270. const paginationRef = ref<HTMLElement | null>(null);
  271. const tableAction = ref<any>(null);
  272. const tableMaxHeight = ref(420);
  273. const tableRowSelection = ref(props.rowSelection);
  274. const getContentContainer = () => {
  275. const scrollContainer = wrapRef.value?.closest('.scroll-container') as HTMLElement | null;
  276. const modalBody = wrapRef.value?.closest('.ant-modal-body') as HTMLElement | null;
  277. return scrollContainer || modalBody || wrapRef.value?.parentElement || null;
  278. };
  279. const getModalPopupContainer = (triggerNode?: HTMLElement) =>
  280. resolveModalPopupContainer(triggerNode || wrapRef.value || getContentContainer() || undefined);
  281. const getTableSettingPopupContainer = () =>
  282. (wrapRef.value?.closest('.ant-modal-wrap') as HTMLElement | null) ||
  283. (wrapRef.value?.closest('.ant-modal-root') as HTMLElement | null) ||
  284. document.body;
  285. let resizeObserver: ResizeObserver | null = null;
  286. const tableSetting = props.tableSetting ?? {
  287. size: true,
  288. setting: true,
  289. redo: false,
  290. fullScreen: false,
  291. };
  292. const handleTableRegister = (action: any) => {
  293. tableAction.value = action;
  294. scheduleTableHeightUpdate();
  295. };
  296. const isTableSettingReady = computed(() => showTableSetting && !!tableAction.value && !!props.dataSource?.length);
  297. const getTableColumns = (...args: any[]) => tableAction.value?.getColumns?.(...args) || [];
  298. const indexColumnProps = computed(() => ({
  299. width: 70,
  300. customRender: ({ index }: { index: number }) => (props.pagination.page - 1) * props.pagination.limit + index + 1,
  301. }));
  302. const setTableProps = (nextProps: any) => {
  303. const resolvedProps = { ...(nextProps || {}) };
  304. if (Object.prototype.hasOwnProperty.call(resolvedProps, 'showIndexColumn')) {
  305. showIndexColumn.value = resolvedProps.showIndexColumn ?? false;
  306. Reflect.deleteProperty(resolvedProps, 'showIndexColumn');
  307. }
  308. if (Object.prototype.hasOwnProperty.call(resolvedProps, 'rowSelection')) {
  309. tableRowSelection.value = resolvedProps.rowSelection ?? undefined;
  310. }
  311. if (Object.keys(resolvedProps).length) {
  312. tableAction.value?.setProps?.(resolvedProps);
  313. }
  314. };
  315. createTableContext({
  316. wrapRef,
  317. getBindValues: computed(() => ({
  318. columns: getTableColumns({ ignoreIndex: true, ignoreAction: true }),
  319. showIndexColumn: showIndexColumn.value,
  320. rowSelection: tableRowSelection.value,
  321. isTreeTable: false,
  322. })),
  323. getDefaultRowSelection: () => tableAction.value?.getDefaultRowSelection?.(),
  324. getColumns: getTableColumns,
  325. getCacheColumns: () => tableAction.value?.getCacheColumns?.() || [],
  326. setColumns: (nextColumns: any) => tableAction.value?.setColumns?.(nextColumns),
  327. setProps: setTableProps,
  328. } as any);
  329. const getTableExtraHeight = () => {
  330. const tableRoot = wrapRef.value?.querySelector('.query-table-content .jeesite-basic-table') as HTMLElement | null;
  331. if (!tableRoot) return 96;
  332. const toolbarHeight = (tableRoot.querySelector('.jeesite-basic-table-header-container') as HTMLElement | null)
  333. ?.offsetHeight;
  334. const tableHeadHeight = (tableRoot.querySelector('.ant-table-thead') as HTMLElement | null)?.offsetHeight;
  335. const wrapperPaddingHeight = 8;
  336. return (toolbarHeight ?? 0) + (tableHeadHeight ?? 40) + wrapperPaddingHeight;
  337. };
  338. const getWrapGap = () => {
  339. if (!wrapRef.value) return 12;
  340. const wrapStyle = window.getComputedStyle(wrapRef.value);
  341. const gapValue = wrapStyle.rowGap || wrapStyle.gap || '12px';
  342. const gap = Number.parseFloat(gapValue);
  343. return Number.isFinite(gap) ? gap : 12;
  344. };
  345. const getVerticalMargin = (element: HTMLElement | null) => {
  346. if (!element) return 0;
  347. const style = window.getComputedStyle(element);
  348. const marginTop = Number.parseFloat(style.marginTop || '0');
  349. const marginBottom = Number.parseFloat(style.marginBottom || '0');
  350. return (Number.isFinite(marginTop) ? marginTop : 0) + (Number.isFinite(marginBottom) ? marginBottom : 0);
  351. };
  352. const getContentBorderHeight = () => {
  353. if (!contentRef.value) return 2;
  354. return Math.max(0, contentRef.value.offsetHeight - contentRef.value.clientHeight);
  355. };
  356. const getDateRangeValue = (item: FilterItem): [string, string] | undefined => {
  357. if (item.type !== 'date-range' || !item.startField || !item.endField) return undefined;
  358. const startValue = props.filters[item.startField];
  359. const endValue = props.filters[item.endField];
  360. if (!startValue || !endValue) return undefined;
  361. return [String(startValue), String(endValue)];
  362. };
  363. const handleDateRangeChange = (item: FilterItem, value?: [string, string] | [Dayjs, Dayjs] | null) => {
  364. if (item.type !== 'date-range' || !item.startField || !item.endField) return;
  365. const startValue = Array.isArray(value) ? value[0] : undefined;
  366. const endValue = Array.isArray(value) ? value[1] : undefined;
  367. props.filters[item.startField] = typeof startValue === 'string' ? startValue : '';
  368. props.filters[item.endField] = typeof endValue === 'string' ? endValue : '';
  369. };
  370. const getFilterValue = (field?: string) => {
  371. if (!field) return undefined;
  372. return props.filters[field];
  373. };
  374. const setFilterValue = (field: string | undefined, value: unknown) => {
  375. if (!field) return;
  376. props.filters[field] = value;
  377. };
  378. const updateTableMaxHeight = () => {
  379. const contentHeight = getContentContainer()?.clientHeight ?? 0;
  380. if (!contentHeight) return;
  381. const searchHeight = searchRef.value?.offsetHeight ?? 0;
  382. const reservedGap = getWrapGap();
  383. const searchMarginHeight = getVerticalMargin(searchRef.value);
  384. const contentMarginHeight = getVerticalMargin(contentRef.value);
  385. const borderOffset = getContentBorderHeight();
  386. const availableHeight =
  387. contentHeight -
  388. searchHeight -
  389. searchMarginHeight -
  390. reservedGap -
  391. contentMarginHeight -
  392. borderOffset -
  393. getTableExtraHeight();
  394. tableMaxHeight.value = Math.max(260, availableHeight);
  395. };
  396. const scheduleTableHeightUpdate = () => {
  397. nextTick(() => {
  398. requestAnimationFrame(() => {
  399. updateTableMaxHeight();
  400. tableAction.value?.redoHeight?.();
  401. });
  402. });
  403. };
  404. const bindResizeObserver = () => {
  405. if (typeof ResizeObserver === 'undefined') return;
  406. resizeObserver?.disconnect();
  407. resizeObserver = new ResizeObserver(() => {
  408. scheduleTableHeightUpdate();
  409. });
  410. [getContentContainer(), wrapRef.value, searchRef.value, contentRef.value, paginationRef.value].forEach(
  411. (element) => {
  412. if (element) resizeObserver?.observe(element);
  413. },
  414. );
  415. };
  416. watch(
  417. () => props.showIndexColumn,
  418. (value) => {
  419. showIndexColumn.value = value ?? false;
  420. },
  421. );
  422. watch(
  423. () => props.rowSelection,
  424. (value) => {
  425. tableRowSelection.value = value;
  426. },
  427. );
  428. watch(
  429. () => props.open,
  430. (open) => {
  431. if (!open) {
  432. resizeObserver?.disconnect();
  433. return;
  434. }
  435. scheduleTableHeightUpdate();
  436. nextTick(() => {
  437. bindResizeObserver();
  438. scheduleTableHeightUpdate();
  439. });
  440. },
  441. );
  442. watch(
  443. () => props.dataSource?.length,
  444. (length) => {
  445. if (!length) {
  446. tableAction.value = null;
  447. }
  448. if (!props.open) return;
  449. scheduleTableHeightUpdate();
  450. },
  451. { flush: 'post' },
  452. );
  453. onBeforeUnmount(() => {
  454. resizeObserver?.disconnect();
  455. });
  456. </script>
  457. <style lang="less">
  458. .query-table-modal {
  459. .ant-modal {
  460. max-width: calc(100vw - 48px);
  461. }
  462. .ant-modal-body > .scroll-container,
  463. .ant-modal-body > .scroll-container > .scrollbar__wrap,
  464. .ant-modal-body > .scroll-container > .scrollbar__wrap > .scrollbar__view,
  465. .ant-modal-body > .scroll-container > .scrollbar__wrap > .scrollbar__view > div {
  466. height: 100%;
  467. min-height: 0 !important;
  468. max-height: none !important;
  469. }
  470. .ant-modal-body > .scroll-container > .scrollbar__wrap {
  471. overflow: hidden;
  472. }
  473. .ant-modal-body > .scroll-container > .scrollbar__wrap > .scrollbar__view {
  474. margin: 0 !important;
  475. }
  476. .ant-modal-body > .scroll-container > .scrollbar__bar.is-vertical,
  477. .ant-modal-body > .scroll-container > .is-vertical {
  478. display: none !important;
  479. opacity: 0 !important;
  480. pointer-events: none;
  481. }
  482. .ant-modal-close {
  483. display: flex;
  484. align-items: center;
  485. justify-content: flex-end;
  486. width: auto !important;
  487. height: auto !important;
  488. padding: 0;
  489. .jeesite-basic-modal-close {
  490. display: flex;
  491. align-items: center;
  492. gap: 2px;
  493. margin-right: 0;
  494. }
  495. }
  496. .ant-modal-content {
  497. border-radius: 6px;
  498. overflow: hidden;
  499. display: flex;
  500. flex-direction: column;
  501. height: min(720px, calc(100vh - 80px));
  502. max-height: min(720px, calc(100vh - 80px));
  503. }
  504. .query-table-modal-popup,
  505. .ant-select-dropdown,
  506. .ant-picker-dropdown,
  507. .ant-dropdown,
  508. .ant-tooltip {
  509. z-index: 1060;
  510. }
  511. .ant-modal-header {
  512. padding: 12px 16px;
  513. border-bottom: 1px solid #e5e7eb;
  514. flex: 0 0 auto;
  515. background: @modal-header-bg-color;
  516. }
  517. .ant-modal-footer {
  518. padding: 8px 16px 10px;
  519. margin-top: 0;
  520. border-top: 1px solid #e5e7eb;
  521. background: #fff;
  522. }
  523. .ant-modal-body {
  524. flex: 1 1 auto;
  525. min-height: 0;
  526. overflow: hidden;
  527. display: flex;
  528. flex-direction: column;
  529. padding: 16px;
  530. }
  531. }
  532. .fullscreen-modal.query-table-modal {
  533. .ant-modal-content {
  534. max-height: calc(100vh - 16px);
  535. height: calc(100vh - 16px);
  536. }
  537. }
  538. .query-table-wrap {
  539. display: flex;
  540. flex-direction: column;
  541. flex: 1 1 auto;
  542. gap: 12px;
  543. min-height: 0;
  544. min-width: 0;
  545. height: 100%;
  546. }
  547. .query-table-search {
  548. margin: 0;
  549. padding: 14px 16px;
  550. border: 1px solid #e2e8f0;
  551. border-radius: 6px;
  552. background: #fff;
  553. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  554. flex: 0 0 auto;
  555. display: flex;
  556. flex-wrap: wrap;
  557. align-items: center;
  558. gap: 8px 16px;
  559. .query-table-switches {
  560. width: 100%;
  561. display: flex;
  562. align-items: center;
  563. gap: 12px;
  564. margin-bottom: 2px;
  565. }
  566. .query-table-switch {
  567. height: 36px;
  568. padding: 0 18px;
  569. border: 1px solid #dbe3ee;
  570. border-radius: 999px;
  571. background: #fff;
  572. color: #64748b;
  573. font-size: 13px;
  574. font-weight: 600;
  575. cursor: pointer;
  576. transition: all 0.2s ease;
  577. &:hover:not(.disabled) {
  578. color: #2563eb;
  579. border-color: #93c5fd;
  580. }
  581. &.active {
  582. color: #fff;
  583. border-color: #315efb;
  584. background: #315efb;
  585. box-shadow: 0 6px 14px rgba(49, 94, 251, 0.18);
  586. }
  587. &.disabled {
  588. color: #94a3b8;
  589. background: #f8fafc;
  590. cursor: not-allowed;
  591. box-shadow: none;
  592. }
  593. }
  594. .search-item {
  595. display: flex;
  596. align-items: center;
  597. gap: 8px;
  598. .label {
  599. color: #475569;
  600. font-size: 12px;
  601. font-weight: 600;
  602. white-space: nowrap;
  603. }
  604. }
  605. .search-item--compare-input {
  606. .compare-input-group {
  607. display: flex;
  608. align-items: center;
  609. min-width: 0;
  610. .ant-select {
  611. flex: 0 0 auto;
  612. }
  613. .ant-select-selector {
  614. border-top-right-radius: 0 !important;
  615. border-bottom-right-radius: 0 !important;
  616. }
  617. .ant-input,
  618. .ant-input-affix-wrapper {
  619. border-top-left-radius: 0 !important;
  620. border-bottom-left-radius: 0 !important;
  621. margin-left: -1px;
  622. }
  623. }
  624. }
  625. .ant-input,
  626. .ant-input-affix-wrapper,
  627. .ant-picker,
  628. .ant-select-selector {
  629. border-radius: 6px !important;
  630. }
  631. .search-actions {
  632. display: flex;
  633. align-items: center;
  634. gap: 12px;
  635. .ant-btn {
  636. height: 36px;
  637. min-width: 76px;
  638. padding: 0 18px;
  639. border-radius: 18px;
  640. font-size: 15px;
  641. font-weight: 500;
  642. box-shadow: none;
  643. }
  644. .ant-btn-primary {
  645. border-color: #315efb;
  646. background: #315efb;
  647. }
  648. .ant-btn:not(.ant-btn-primary) {
  649. color: #1f2937;
  650. border-color: #d6dbe6;
  651. background: #ffffff;
  652. }
  653. }
  654. .search-utility-actions {
  655. margin-left: auto;
  656. display: flex;
  657. align-items: center;
  658. gap: 10px;
  659. flex-wrap: wrap;
  660. justify-content: flex-end;
  661. }
  662. .search-extra-actions {
  663. display: flex;
  664. align-items: center;
  665. gap: 8px;
  666. flex-wrap: wrap;
  667. }
  668. .search-table-setting {
  669. display: inline-flex;
  670. align-items: center;
  671. padding: 0 2px;
  672. }
  673. }
  674. /* 图分析详情表(g6-editor / 关系图详情)的搜索按钮改为 32px 紧凑高度;
  675. 其他使用 QueryTableModal 的页面仍保持 36px。 */
  676. .graph-analysis-detail-table-modal .query-table-search .search-actions .ant-btn {
  677. height: 32px;
  678. }
  679. .query-table-content {
  680. margin: 0;
  681. flex: 1 1 auto;
  682. min-height: 0;
  683. display: flex;
  684. overflow: hidden;
  685. box-sizing: border-box;
  686. border: 0;
  687. border-radius: 0;
  688. background: transparent;
  689. box-shadow: none;
  690. > .jeesite-basic-table,
  691. > .query-table-empty {
  692. flex: 1 1 auto;
  693. min-height: 0;
  694. width: 100%;
  695. }
  696. > .jeesite-basic-table,
  697. > .jeesite-basic-table > .ant-spin-nested-loading,
  698. > .jeesite-basic-table > .ant-spin-nested-loading > .ant-spin-container,
  699. > .jeesite-basic-table .ant-table-wrapper {
  700. height: 100%;
  701. min-height: 0;
  702. }
  703. .ant-table-thead > tr > th {
  704. background: #f8fafc;
  705. color: #334155;
  706. font-weight: 600;
  707. }
  708. .ant-table-tbody > tr:nth-child(even) > td {
  709. background: #fcfdff;
  710. }
  711. .ant-table-tbody > tr:hover > td {
  712. background: #eff6ff;
  713. }
  714. }
  715. .query-table-empty {
  716. display: flex;
  717. align-items: center;
  718. justify-content: center;
  719. background: #fff;
  720. }
  721. .pagination-bar {
  722. min-height: 32px;
  723. display: flex;
  724. align-items: center;
  725. justify-content: flex-end;
  726. gap: 12px;
  727. color: #98a2b3;
  728. font-size: 11px;
  729. flex-wrap: nowrap;
  730. .pagination-total {
  731. margin-right: 0;
  732. color: #98a2b3;
  733. white-space: nowrap;
  734. }
  735. .pagination-size-select {
  736. width: 112px;
  737. flex: 0 0 auto;
  738. }
  739. .ant-pagination.ant-pagination {
  740. margin: 0;
  741. .ant-pagination-item,
  742. .ant-pagination-prev,
  743. .ant-pagination-next,
  744. .ant-pagination-jump-prev,
  745. .ant-pagination-jump-next {
  746. min-width: 26px;
  747. height: 26px;
  748. border-radius: 6px;
  749. border-color: #e7ebf3;
  750. line-height: 24px;
  751. }
  752. .ant-pagination-item-active {
  753. border-color: #2a50ec;
  754. background: #eef2ff;
  755. a {
  756. color: #2a50ec;
  757. font-weight: 600;
  758. }
  759. }
  760. }
  761. .pagination-jump {
  762. display: flex;
  763. align-items: center;
  764. gap: 8px;
  765. white-space: nowrap;
  766. }
  767. .pagination-jump-input {
  768. width: 64px;
  769. flex: 0 0 auto;
  770. }
  771. }
  772. </style>