index.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  1. <template>
  2. <div :class="prefixCls" class="fixed-deposit-page">
  3. <div class="page-header">
  4. <div class="page-title">定期存取分析</div>
  5. <div class="page-subtitle">围绕定期存取相关交易做对象聚合与明细联动,便于快速识别异常存取行为。</div>
  6. </div>
  7. <div class="filter-bar">
  8. <div class="filter-item">
  9. <span class="filter-label">选择对象:</span>
  10. <Select
  11. v-model:value="filters.target"
  12. mode="multiple"
  13. allow-clear
  14. max-tag-count="responsive"
  15. class="filter-input"
  16. :options="targetOptions"
  17. placeholder="全部"
  18. />
  19. </div>
  20. <div class="filter-item">
  21. <span class="filter-label">交易日期:</span>
  22. <RangePicker v-model:value="filters.dateRange" class="filter-date" />
  23. </div>
  24. <div class="toolbar-actions">
  25. <div class="filter-actions">
  26. <Button type="primary" :loading="queryLoading" @click="handleSearch">查询</Button>
  27. <Button @click="handleReset">重置</Button>
  28. </div>
  29. <div class="extra-actions">
  30. <Button @click="openKeywordModal">关键词配置</Button>
  31. </div>
  32. </div>
  33. </div>
  34. <ConfigManageModal
  35. :open="keywordModalOpen"
  36. title="关键词管理"
  37. :width="960"
  38. wrapClassName="fixed-deposit-keyword-modal"
  39. summary="支持新增、编辑、删除定期存取关键词,统一分析入口配置"
  40. :refresh-loading="keywordLoading"
  41. :table-height="420"
  42. :total="keywordData.length"
  43. :current="keywordPagination.current"
  44. :total-pages="keywordTotalPages"
  45. :page-size="keywordPagination.pageSize"
  46. :page-size-options="pageSizeOptions"
  47. :jump-page="keywordJumpPage"
  48. @update:open="handleKeywordModalChange"
  49. @update:jumpPage="handleKeywordJumpPageInput"
  50. @create="openKeywordEditor()"
  51. @prev-page="handleKeywordPrevPage"
  52. @next-page="handleKeywordNextPage"
  53. @page-size-change="handleKeywordPageSizeChange"
  54. @jump-page="handleKeywordJumpPage"
  55. >
  56. <template #default="{ tableMaxHeight }">
  57. <BasicTable
  58. :columns="keywordColumns"
  59. :data-source="keywordPagedData"
  60. :loading="keywordLoading"
  61. :pagination="false"
  62. :show-table-setting="false"
  63. :table-setting="{ size: true, setting: true, redo: false, fullScreen: false }"
  64. :can-resize="true"
  65. :max-height="tableMaxHeight"
  66. row-key="rowKey"
  67. >
  68. <template #keywordAction="{ record }">
  69. <TableAction :actions="getKeywordActions(record)" />
  70. </template>
  71. </BasicTable>
  72. </template>
  73. </ConfigManageModal>
  74. <ConfigEditorModal
  75. v-model:open="keywordEditorOpen"
  76. :title="keywordEditorTitle"
  77. :confirmLoading="keywordSaving"
  78. wrapClassName="fixed-deposit-keyword-editor-modal"
  79. @ok="handleSaveKeyword"
  80. @cancel="closeKeywordEditor"
  81. >
  82. <Form layout="vertical" class="keyword-form">
  83. <Form.Item
  84. label="关键字"
  85. :validate-status="keywordFormErrors.fixedDepositKey ? 'error' : ''"
  86. :help="keywordFormErrors.fixedDepositKey"
  87. >
  88. <Input
  89. v-model:value="keywordForm.fixedDepositKey"
  90. :maxlength="100"
  91. placeholder="请输入定期理财关键字"
  92. allow-clear
  93. />
  94. </Form.Item>
  95. </Form>
  96. </ConfigEditorModal>
  97. <div class="content-layout">
  98. <div class="left-panel">
  99. <div class="panel-header">
  100. <div>
  101. <div class="panel-title">银行卡定期存取汇总</div>
  102. <div class="panel-desc">统计符合定期关键字的交易,右侧查看详情。</div>
  103. </div>
  104. <div class="panel-subtitle">共 {{ summaryCards.length }} 条流水摘要</div>
  105. </div>
  106. <div class="summary-list">
  107. <div
  108. v-for="item in summaryCards"
  109. :key="item.rowKey"
  110. class="summary-card"
  111. :class="{ active: selectedSummaryRow?.rowKey === item.rowKey }"
  112. @click="handleSummaryCardClick(item)"
  113. >
  114. <div class="summary-top">
  115. <div class="summary-name">{{ item.personName }}</div>
  116. <div class="summary-badge">{{
  117. selectedSummaryRow?.rowKey === item.rowKey ? '当前查看' : '查看明细'
  118. }}</div>
  119. </div>
  120. <div class="summary-metrics">
  121. <div class="summary-metric">
  122. <span class="summary-metric-label">卡余额:</span>
  123. <span class="summary-metric-value">{{ item.cardBalance }}</span>
  124. </div>
  125. <div class="summary-metric">
  126. <span class="summary-metric-label">定期存款总额:</span>
  127. <span class="summary-metric-value">{{ item.depositTotalAmount }}</span>
  128. </div>
  129. <div class="summary-metric">
  130. <span class="summary-metric-label">定期取款总额:</span>
  131. <span class="summary-metric-value">{{ item.withdrawTotalAmount }}</span>
  132. </div>
  133. </div>
  134. </div>
  135. <div v-if="!summaryCards.length" class="summary-empty">暂无汇总数据</div>
  136. </div>
  137. </div>
  138. <div class="right-panel">
  139. <div class="panel-header">
  140. <div>
  141. <div class="panel-title">定期存取记录</div>
  142. <div class="panel-desc">{{ detailSummaryText }}</div>
  143. </div>
  144. <div class="panel-subtitle">分页浏览</div>
  145. </div>
  146. <div v-if="!hasSearched" class="query-state-panel">
  147. <EmptyState
  148. variant="query"
  149. title="请点击查询"
  150. description="设置条件精细查询,也可点击查询展示所有信息"
  151. min-height="100%"
  152. description-width="min(100%, 420px)"
  153. />
  154. </div>
  155. <div v-else class="table-wrapper table-wrapper--detail">
  156. <BasicTable
  157. :columns="detailColumns"
  158. :data-source="detailTableData"
  159. :loading="detailLoading"
  160. :pagination="false"
  161. :show-table-setting="false"
  162. :table-setting="{ setting: true, size: true, redo: false, fullScreen: false }"
  163. :can-resize="true"
  164. :is-can-resize-parent="true"
  165. :resize-height-offset="32"
  166. row-key="rowKey"
  167. >
  168. <template #detailAction="{ record }">
  169. <Button type="link" size="small" @click.stop="handleViewDetail(record)">查看详情</Button>
  170. </template>
  171. </BasicTable>
  172. </div>
  173. <div v-if="showDetailPagination" class="pagination-bar">
  174. <AnalysisPagination
  175. :total="detailTotal"
  176. :current="detailPagination.current"
  177. :page-size="detailPagination.pageSize"
  178. :page-size-options="pageSizeOptions"
  179. :loading="detailLoading"
  180. @change="handleDetailPaginationChange"
  181. />
  182. </div>
  183. </div>
  184. </div>
  185. <TransRecordModal
  186. v-model:open="transRecordModalOpen"
  187. :base-query="transRecordBaseQuery"
  188. :hide-technical-id-columns="true"
  189. />
  190. </div>
  191. </template>
  192. <script lang="ts" setup name="ViewsFixedDepositIndex">
  193. import { computed, onMounted, reactive, ref } from 'vue';
  194. import { Select, Input, Button, DatePicker, Form } from 'ant-design-vue';
  195. import AnalysisPagination from '@jeesite/core/components/AnalysisPagination/src/AnalysisPagination.vue';
  196. import dayjs, { Dayjs } from 'dayjs';
  197. import { EmptyState } from '@jeesite/core/components/EmptyState';
  198. import { BasicTable, TableAction } from '@jeesite/core/components/Table';
  199. import type { BasicColumn } from '@jeesite/core/components/Table';
  200. import { useAnalysisRefreshPrompt } from '@jeesite/core/hooks/web/useAnalysisRefreshPrompt';
  201. import { useDesign } from '@jeesite/core/hooks/web/useDesign';
  202. import { useTableSkill } from '@jeesite/core/hooks/web/useTableSkill';
  203. import { useMessage } from '@jeesite/core/hooks/web/useMessage';
  204. import ConfigManageModal from '@jeesite/core/components/AnalysisConfigModal/src/ConfigManageModal.vue';
  205. import ConfigEditorModal from '@jeesite/core/components/AnalysisConfigModal/src/ConfigEditorModal.vue';
  206. import { pickDetailValue } from '@jeesite/core/utils/detailQuery';
  207. import componentSetting from '@jeesite/core/settings/componentSetting';
  208. import { getPersonOptions } from '@jeesite/person/api/personApi';
  209. import TransRecordModal from '../components/TransRecordModal.vue';
  210. import {
  211. createOrUpdateFixedDepositKey,
  212. deleteFixedDepositKey,
  213. listFixedDepositKeys,
  214. statFirstTransFixedDeposit,
  215. statSecondTransFixedDepositList,
  216. } from '@jeesite/trans/api/transApi';
  217. import type {
  218. TransFixedDepositKey,
  219. TransPersonFixedDepositDTO,
  220. TransPersonFixedDepositDetailDTO,
  221. } from '@jeesite/trans/api/types/dto';
  222. import type { TransFixedDepositQuery, TransRecordQuery } from '@jeesite/trans/api/types/query';
  223. interface FixedDepositSummaryRow {
  224. rowKey: string;
  225. personName: string;
  226. cardBalance: string;
  227. depositTotalAmount: string;
  228. withdrawTotalAmount: string;
  229. raw: TransPersonFixedDepositDTO;
  230. }
  231. interface FixedDepositDetailRow {
  232. rowKey: string;
  233. id: number;
  234. personName: string;
  235. personCardNo: string;
  236. transAmount: string;
  237. transBalance: string;
  238. transDateTime: string;
  239. debitCreditFlag: string;
  240. concatInfo: string;
  241. cardStatus: string;
  242. source: string;
  243. raw: TransPersonFixedDepositDetailDTO;
  244. }
  245. interface KeywordRow extends TransFixedDepositKey {
  246. rowKey: number | string;
  247. rowNo: number;
  248. }
  249. interface KeywordFormState {
  250. id?: number | string;
  251. fixedDepositKey: string;
  252. }
  253. const { prefixCls } = useDesign('fixed-deposit');
  254. const { queryLoading, runWithQueryLoading } = useTableSkill();
  255. const { createMessage } = useMessage();
  256. const RangePicker = DatePicker.RangePicker;
  257. type RangeValue = [Dayjs, Dayjs] | undefined;
  258. const filters = ref({
  259. target: [] as string[],
  260. dateRange: undefined as RangeValue,
  261. });
  262. const targetOptions = ref<Array<{ label: string; value: string }>>([]);
  263. const transRecordModalOpen = ref(false);
  264. const transRecordBaseQuery = ref<Partial<TransRecordQuery>>({});
  265. const normalizeSelectedTargets = (value?: string[] | string | null) => {
  266. if (Array.isArray(value)) {
  267. const list = value.map((item) => String(item).trim()).filter(Boolean);
  268. return list.length ? Array.from(new Set(list)) : [];
  269. }
  270. if (!value) return [];
  271. const list = String(value)
  272. .split(',')
  273. .map((item) => item.trim())
  274. .filter(Boolean);
  275. return list.length ? Array.from(new Set(list)) : [];
  276. };
  277. const detailPagination = ref({
  278. current: 1,
  279. pageSize: componentSetting.table.defaultPageSize,
  280. });
  281. const detailJumpPage = ref('1');
  282. const detailTotal = ref(0);
  283. const hasSearched = ref(false);
  284. const detailTableData = ref<FixedDepositDetailRow[]>([]);
  285. const summaryCards = ref<FixedDepositSummaryRow[]>([]);
  286. const { syncAnalysisDataRefreshState } = useAnalysisRefreshPrompt({
  287. refresh: () => fetchPageData(),
  288. hasData: () => hasSearched.value && summaryCards.value.length > 0,
  289. });
  290. const selectedSummaryRow = ref<FixedDepositSummaryRow | null>(null);
  291. const detailLoading = ref(false);
  292. const keywordModalOpen = ref(false);
  293. const keywordEditorOpen = ref(false);
  294. const keywordLoading = ref(false);
  295. const keywordSaving = ref(false);
  296. const keywordData = ref<KeywordRow[]>([]);
  297. const keywordJumpPage = ref('1');
  298. const keywordPagination = ref({
  299. current: 1,
  300. pageSize: componentSetting.table.defaultPageSize,
  301. });
  302. const keywordForm = reactive<KeywordFormState>({
  303. id: undefined,
  304. fixedDepositKey: '',
  305. });
  306. const keywordFormErrors = reactive({
  307. fixedDepositKey: '',
  308. });
  309. const pageSizeOptions = componentSetting.table.pageSizeOptions.map((value) => ({
  310. label: value,
  311. value: Number(value),
  312. }));
  313. const keywordEditorTitle = computed(() => (keywordForm.id ? '编辑关键词' : '新建关键词'));
  314. const detailColumns: BasicColumn[] = [
  315. { title: '序号', dataIndex: 'id', key: 'id', width: 70, align: 'center' },
  316. { title: '被调查对象姓名', dataIndex: 'personName', key: 'personName', width: 140, align: 'center' },
  317. { title: '被调查对象卡(账)号', dataIndex: 'personCardNo', key: 'personCardNo', width: 170, align: 'center' },
  318. { title: '交易金额', dataIndex: 'transAmount', key: 'transAmount', width: 120, align: 'center' },
  319. { title: '余额', dataIndex: 'transBalance', key: 'transBalance', width: 100, align: 'center' },
  320. { title: '发生日期', dataIndex: 'transDateTime', key: 'transDateTime', width: 170, align: 'center' },
  321. { title: '借贷标志', dataIndex: 'debitCreditFlag', key: 'debitCreditFlag', width: 90, align: 'center' },
  322. { title: '附属信息', dataIndex: 'concatInfo', key: 'concatInfo', width: 150 },
  323. { title: '卡状态', dataIndex: 'cardStatus', key: 'cardStatus', width: 80, align: 'center' },
  324. { title: '来源', dataIndex: 'source', key: 'source', width: 80, align: 'center' },
  325. {
  326. title: '操作',
  327. dataIndex: 'action',
  328. key: 'action',
  329. width: 110,
  330. align: 'center',
  331. fixed: 'right',
  332. slot: 'detailAction',
  333. },
  334. ];
  335. const keywordColumns: BasicColumn[] = [
  336. { title: '序号', dataIndex: 'rowNo', key: 'rowNo', width: 80, align: 'center' },
  337. { title: '关键字', dataIndex: 'fixedDepositKey', key: 'fixedDepositKey', width: 520, align: 'left' },
  338. {
  339. title: '操作',
  340. dataIndex: 'action',
  341. key: 'action',
  342. width: 160,
  343. align: 'center',
  344. slot: 'keywordAction',
  345. },
  346. ];
  347. const detailTotalPages = computed(() => {
  348. if (!detailTotal.value) return 1;
  349. return Math.max(1, Math.ceil(detailTotal.value / detailPagination.value.pageSize));
  350. });
  351. const showDetailPagination = computed(() => detailTableData.value.length > 0);
  352. const keywordTotalPages = computed(() => {
  353. if (!keywordData.value.length) return 1;
  354. return Math.max(1, Math.ceil(keywordData.value.length / keywordPagination.value.pageSize));
  355. });
  356. const keywordPagedData = computed(() => {
  357. const start = (keywordPagination.value.current - 1) * keywordPagination.value.pageSize;
  358. const end = start + keywordPagination.value.pageSize;
  359. return keywordData.value.slice(start, end);
  360. });
  361. const fixedDepositKeys = computed(() =>
  362. keywordData.value.map((item) => item.fixedDepositKey?.trim()).filter((item): item is string => !!item),
  363. );
  364. const detailSummaryText = computed(() => {
  365. if (!selectedSummaryRow.value?.personName) return '请选择左侧对象查看明细';
  366. return `当前查看 ${selectedSummaryRow.value.personName} 的定期存取记录`;
  367. });
  368. const normalizeSummaryList = (resp: any): TransPersonFixedDepositDTO[] => {
  369. if (Array.isArray(resp)) return resp;
  370. if (Array.isArray(resp?.records)) return resp.records;
  371. if (Array.isArray(resp?.data?.records)) return resp.data.records;
  372. if (Array.isArray(resp?.list)) return resp.list;
  373. if (Array.isArray(resp?.data?.list)) return resp.data.list;
  374. if (Array.isArray(resp?.data)) return resp.data;
  375. return [];
  376. };
  377. const normalizeKeywordList = (resp: any): TransFixedDepositKey[] => {
  378. if (Array.isArray(resp)) return resp;
  379. if (Array.isArray(resp?.data)) return resp.data;
  380. if (Array.isArray(resp?.list)) return resp.list;
  381. if (Array.isArray(resp?.data?.list)) return resp.data.list;
  382. return [];
  383. };
  384. const normalizeDetailList = (resp: any): TransPersonFixedDepositDetailDTO[] => {
  385. if (Array.isArray(resp)) return resp;
  386. if (Array.isArray(resp?.records)) return resp.records;
  387. if (Array.isArray(resp?.data?.records)) return resp.data.records;
  388. if (Array.isArray(resp?.list)) return resp.list;
  389. if (Array.isArray(resp?.data)) return resp.data;
  390. if (Array.isArray(resp?.data?.list)) return resp.data.list;
  391. return [];
  392. };
  393. const normalizeTotal = (resp: any, listLen: number) => {
  394. const t = resp?.total ?? resp?.data?.total ?? resp?.count ?? resp?.data?.count ?? resp?.data?.records?.length;
  395. return Number.isFinite(Number(t)) ? Number(t) : listLen;
  396. };
  397. const parseNumber = (value?: number | string | null) => {
  398. if (value === null || value === undefined || value === '') return undefined;
  399. const normalized = typeof value === 'string' ? value.replace(/,/g, '').trim() : value;
  400. const numericValue = Number(normalized);
  401. return Number.isFinite(numericValue) ? numericValue : undefined;
  402. };
  403. const formatAmount = (value?: number | string | null) => {
  404. const numericValue = parseNumber(value);
  405. if (numericValue === undefined) return '-';
  406. return numericValue.toLocaleString('zh-CN', {
  407. minimumFractionDigits: 2,
  408. maximumFractionDigits: 2,
  409. });
  410. };
  411. const formatCount = (value?: number | string | null) => {
  412. const numericValue = parseNumber(value);
  413. if (numericValue === undefined) return '-';
  414. return Number.isInteger(numericValue) ? String(numericValue) : numericValue.toFixed(0);
  415. };
  416. const formatCurrency = (value?: number | string | null) => {
  417. const amountText = formatAmount(value);
  418. return amountText === '-' ? '-' : `¥${amountText}`;
  419. };
  420. const formatSourceLabel = (value?: string | null) => {
  421. const source = String(value || '')
  422. .trim()
  423. .toLowerCase();
  424. if (!source) return '-';
  425. if (source === 'acct') return '开户信息';
  426. if (source === 'trans') return '交易记录';
  427. return String(value || '').trim() || '-';
  428. };
  429. const pickSummaryAmount = (
  430. item: TransPersonFixedDepositDTO,
  431. fieldNames: string[],
  432. fallback?: number | string | null,
  433. ) => {
  434. const source = item as Record<string, unknown>;
  435. for (const fieldName of fieldNames) {
  436. const value = source[fieldName];
  437. if (value !== undefined && value !== null && value !== '') {
  438. return value as number | string;
  439. }
  440. }
  441. return fallback;
  442. };
  443. const mapSummaryCard = (item: TransPersonFixedDepositDTO, index: number): FixedDepositSummaryRow => ({
  444. rowKey: `fixed-deposit-summary-${index}-${item.personName || ''}`,
  445. personName: item.personName || '-',
  446. cardBalance: formatAmount(
  447. pickSummaryAmount(
  448. item,
  449. ['cardBalance', 'balance', 'transBalance', 'totalBalance', 'accountBalance'],
  450. item.totalTransAmount,
  451. ),
  452. ),
  453. depositTotalAmount: formatAmount(
  454. pickSummaryAmount(
  455. item,
  456. ['depositTotalAmount', 'fixedDepositTotalAmount', 'incomeTotalAmount'],
  457. item.incomeTotalAmount,
  458. ),
  459. ),
  460. withdrawTotalAmount: formatAmount(
  461. pickSummaryAmount(
  462. item,
  463. ['withdrawTotalAmount', 'fixedWithdrawTotalAmount', 'expenseTotalAmount'],
  464. item.expenseTotalAmount,
  465. ),
  466. ),
  467. raw: item,
  468. });
  469. const mapKeywordRows = (list: TransFixedDepositKey[]): KeywordRow[] =>
  470. list.map((item, index) => ({
  471. ...item,
  472. rowKey: item.id ?? `fixed-deposit-key-${index}`,
  473. rowNo: index + 1,
  474. }));
  475. const mapDetailRow = (item: TransPersonFixedDepositDetailDTO, index: number): FixedDepositDetailRow => ({
  476. rowKey: `fixed-deposit-detail-${detailPagination.value.current}-${index}`,
  477. id: (detailPagination.value.current - 1) * detailPagination.value.pageSize + index + 1,
  478. personName: item.personName || '-',
  479. personCardNo: item.personCardNo || '-',
  480. transAmount: formatCurrency(item.transAmount),
  481. transBalance: formatCurrency(item.transBalance),
  482. transDateTime: item.transDateTime || '-',
  483. debitCreditFlag: item.debitCreditFlag || '-',
  484. concatInfo: item.concatInfo || '-',
  485. cardStatus: item.accountStatus || '-',
  486. source: formatSourceLabel(item.source),
  487. raw: item,
  488. });
  489. const resetDetailState = () => {
  490. detailTableData.value = [];
  491. detailTotal.value = 0;
  492. detailPagination.value.current = 1;
  493. detailJumpPage.value = '1';
  494. };
  495. const buildSummaryQuery = (): TransFixedDepositQuery => {
  496. const range = filters.value.dateRange as RangeValue;
  497. const selectedTargets = normalizeSelectedTargets(filters.value.target);
  498. return {
  499. page: 1,
  500. limit: 999,
  501. startDate: range?.[0] ? dayjs(range[0]).format('YYYY-MM-DD') : undefined,
  502. endDate: range?.[1] ? dayjs(range[1]).format('YYYY-MM-DD') : undefined,
  503. personNames: selectedTargets.length ? selectedTargets : undefined,
  504. depositKey: fixedDepositKeys.value.length ? fixedDepositKeys.value : undefined,
  505. };
  506. };
  507. const buildDetailQuery = (): TransFixedDepositQuery => {
  508. const range = filters.value.dateRange as RangeValue;
  509. const selectedTarget = normalizeSelectedTargets(filters.value.target)[0];
  510. const personName = selectedSummaryRow.value?.raw.personName || selectedTarget;
  511. return {
  512. page: detailPagination.value.current,
  513. limit: detailPagination.value.pageSize,
  514. startDate: range?.[0] ? dayjs(range[0]).format('YYYY-MM-DD') : undefined,
  515. endDate: range?.[1] ? dayjs(range[1]).format('YYYY-MM-DD') : undefined,
  516. personName,
  517. personNames: personName ? [personName] : undefined,
  518. depositKey: fixedDepositKeys.value.length ? fixedDepositKeys.value : undefined,
  519. orderKey: 'transDateTime',
  520. sort: 'DESC',
  521. };
  522. };
  523. const buildTransRecordBaseQuery = (record: FixedDepositDetailRow): Partial<TransRecordQuery> => {
  524. const detailQuery = buildDetailQuery();
  525. return {
  526. id: pickDetailValue(record.raw.id !== undefined && record.raw.id !== null ? String(record.raw.id) : undefined),
  527. personName: pickDetailValue(record.raw.personName, detailQuery.personName),
  528. personCardNo: pickDetailValue(record.raw.personCardNo),
  529. startDate: detailQuery.startDate,
  530. endDate: detailQuery.endDate,
  531. debitCreditFlag: pickDetailValue(record.raw.debitCreditFlag),
  532. };
  533. };
  534. const resetKeywordForm = () => {
  535. keywordForm.id = undefined;
  536. keywordForm.fixedDepositKey = '';
  537. keywordFormErrors.fixedDepositKey = '';
  538. };
  539. const getKeywordActions = (record: KeywordRow) => [
  540. {
  541. label: '编辑',
  542. onClick: () => openKeywordEditor(record),
  543. },
  544. {
  545. label: '删除',
  546. color: 'error' as const,
  547. popConfirm: {
  548. title: '是否确认删除该关键字?',
  549. confirm: () => handleDeleteKeyword(record),
  550. },
  551. },
  552. ];
  553. const loadKeywordList = async (showSuccessMessage = false) => {
  554. keywordLoading.value = true;
  555. try {
  556. const resp = await listFixedDepositKeys();
  557. keywordData.value = mapKeywordRows(normalizeKeywordList(resp));
  558. keywordPagination.value.current = 1;
  559. keywordJumpPage.value = '1';
  560. if (showSuccessMessage) {
  561. createMessage.success('关键词列表已刷新');
  562. }
  563. } catch (error) {
  564. keywordData.value = [];
  565. keywordPagination.value.current = 1;
  566. keywordJumpPage.value = '1';
  567. createMessage.warning('获取关键词失败');
  568. } finally {
  569. keywordLoading.value = false;
  570. }
  571. };
  572. const handleKeywordPrevPage = () => {
  573. if (keywordPagination.value.current <= 1) return;
  574. keywordPagination.value.current -= 1;
  575. keywordJumpPage.value = String(keywordPagination.value.current);
  576. };
  577. const handleKeywordNextPage = () => {
  578. if (keywordPagination.value.current >= keywordTotalPages.value) return;
  579. keywordPagination.value.current += 1;
  580. keywordJumpPage.value = String(keywordPagination.value.current);
  581. };
  582. const handleKeywordPageSizeChange = (value: string | number) => {
  583. keywordPagination.value.pageSize = Number(value);
  584. keywordPagination.value.current = 1;
  585. keywordJumpPage.value = '1';
  586. };
  587. const handleKeywordJumpPage = () => {
  588. const next = Number(keywordJumpPage.value);
  589. if (!Number.isInteger(next) || next < 1) {
  590. createMessage.warning('请输入正确页码');
  591. keywordJumpPage.value = String(keywordPagination.value.current);
  592. return;
  593. }
  594. keywordPagination.value.current = Math.min(next, keywordTotalPages.value);
  595. keywordJumpPage.value = String(keywordPagination.value.current);
  596. };
  597. const handleKeywordJumpPageInput = (value: string) => {
  598. keywordJumpPage.value = value;
  599. };
  600. const openKeywordModal = async () => {
  601. keywordModalOpen.value = true;
  602. await loadKeywordList();
  603. };
  604. const handleKeywordModalChange = async (open: boolean) => {
  605. keywordModalOpen.value = open;
  606. if (open && !keywordData.value.length) {
  607. await loadKeywordList();
  608. }
  609. };
  610. const openKeywordEditor = (record?: KeywordRow) => {
  611. resetKeywordForm();
  612. if (record) {
  613. keywordForm.id = record.id !== undefined && record.id !== null ? String(record.id) : undefined;
  614. keywordForm.fixedDepositKey = record.fixedDepositKey || '';
  615. }
  616. keywordEditorOpen.value = true;
  617. };
  618. const closeKeywordEditor = () => {
  619. keywordEditorOpen.value = false;
  620. resetKeywordForm();
  621. };
  622. const validateKeywordForm = () => {
  623. const fixedDepositKey = keywordForm.fixedDepositKey.trim();
  624. keywordFormErrors.fixedDepositKey = fixedDepositKey ? '' : '请输入关键字';
  625. if (!fixedDepositKey) return false;
  626. keywordForm.fixedDepositKey = fixedDepositKey;
  627. return true;
  628. };
  629. const handleSaveKeyword = async () => {
  630. if (!validateKeywordForm()) return;
  631. keywordSaving.value = true;
  632. try {
  633. await createOrUpdateFixedDepositKey({
  634. id: keywordForm.id,
  635. fixedDepositKey: keywordForm.fixedDepositKey,
  636. });
  637. createMessage.success(keywordForm.id ? '关键词更新成功' : '关键词新增成功');
  638. keywordEditorOpen.value = false;
  639. resetKeywordForm();
  640. await loadKeywordList();
  641. } catch (error) {
  642. createMessage.warning(keywordForm.id ? '关键词更新失败' : '关键词新增失败');
  643. } finally {
  644. keywordSaving.value = false;
  645. }
  646. };
  647. const handleDeleteKeyword = async (record: KeywordRow) => {
  648. if (!record.id) {
  649. createMessage.warning('缺少关键词ID,无法删除');
  650. return;
  651. }
  652. try {
  653. await deleteFixedDepositKey(String(record.id));
  654. createMessage.success('关键词删除成功');
  655. await loadKeywordList();
  656. } catch (error) {
  657. createMessage.warning('关键词删除失败');
  658. }
  659. };
  660. const fetchSummary = async () => {
  661. const resp = await statFirstTransFixedDeposit(buildSummaryQuery());
  662. const list = normalizeSummaryList(resp);
  663. summaryCards.value = list.map(mapSummaryCard);
  664. const selected = selectedSummaryRow.value?.raw.personName;
  665. selectedSummaryRow.value =
  666. summaryCards.value.find((item) => item.raw.personName === selected) || summaryCards.value[0] || null;
  667. };
  668. const fetchDetailTable = async () => {
  669. if (!selectedSummaryRow.value?.raw.personName && !selectedSummaryRow.value?.raw.personCardNo) {
  670. resetDetailState();
  671. return;
  672. }
  673. detailLoading.value = true;
  674. try {
  675. const resp = await statSecondTransFixedDepositList(buildDetailQuery());
  676. const list = normalizeDetailList(resp);
  677. detailTableData.value = list.map(mapDetailRow);
  678. detailTotal.value = normalizeTotal(resp, list.length);
  679. const current = Number((resp as any)?.current ?? (resp as any)?.data?.current ?? detailPagination.value.current);
  680. const size = Number((resp as any)?.size ?? (resp as any)?.data?.size ?? detailPagination.value.pageSize);
  681. if (Number.isFinite(current) && current > 0) detailPagination.value.current = current;
  682. if (Number.isFinite(size) && size > 0) detailPagination.value.pageSize = size;
  683. detailJumpPage.value = String(detailPagination.value.current);
  684. } catch (error) {
  685. detailTableData.value = [];
  686. detailTotal.value = 0;
  687. createMessage.warning('定期存取记录接口调用失败');
  688. } finally {
  689. detailLoading.value = false;
  690. }
  691. };
  692. const fetchPageData = async () => {
  693. if (!keywordData.value.length) {
  694. await loadKeywordList();
  695. }
  696. await runWithQueryLoading(async () => {
  697. await fetchSummary();
  698. hasSearched.value = true;
  699. syncAnalysisDataRefreshState(summaryCards.value.length > 0);
  700. if (!selectedSummaryRow.value) {
  701. resetDetailState();
  702. return;
  703. }
  704. detailPagination.value.current = 1;
  705. detailJumpPage.value = '1';
  706. await fetchDetailTable();
  707. });
  708. };
  709. const handleSummaryCardClick = async (item: FixedDepositSummaryRow) => {
  710. if (selectedSummaryRow.value?.rowKey === item.rowKey) return;
  711. selectedSummaryRow.value = item;
  712. detailPagination.value.current = 1;
  713. detailJumpPage.value = '1';
  714. await fetchDetailTable();
  715. };
  716. const handleSearch = async () => {
  717. detailPagination.value.current = 1;
  718. await fetchPageData();
  719. };
  720. const handleReset = async () => {
  721. filters.value = {
  722. target: [],
  723. dateRange: undefined,
  724. };
  725. detailPagination.value.current = 1;
  726. await fetchPageData();
  727. };
  728. const handleViewDetail = (record: FixedDepositDetailRow) => {
  729. if (!record?.raw.id && !record?.raw.personName && !record?.raw.personCardNo) {
  730. createMessage.warning('缺少详情定位信息');
  731. return;
  732. }
  733. transRecordBaseQuery.value = buildTransRecordBaseQuery(record);
  734. transRecordModalOpen.value = true;
  735. };
  736. const handleDetailPrevPage = async () => {
  737. if (detailLoading.value || detailPagination.value.current <= 1) return;
  738. detailPagination.value.current -= 1;
  739. await fetchDetailTable();
  740. };
  741. const handleDetailNextPage = async () => {
  742. if (detailLoading.value || detailPagination.value.current >= detailTotalPages.value) return;
  743. detailPagination.value.current += 1;
  744. await fetchDetailTable();
  745. };
  746. const handleDetailPaginationChange = async (page: number, pageSize: number) => {
  747. if (detailLoading.value) return;
  748. if (pageSize !== detailPagination.value.pageSize) {
  749. detailPagination.value.pageSize = pageSize;
  750. await handleDetailPageSizeChange();
  751. return;
  752. }
  753. if (page === detailPagination.value.current - 1) {
  754. await handleDetailPrevPage();
  755. return;
  756. }
  757. if (page === detailPagination.value.current + 1) {
  758. await handleDetailNextPage();
  759. return;
  760. }
  761. if (page === detailPagination.value.current) return;
  762. detailJumpPage.value = String(page);
  763. await handleDetailJumpPage();
  764. };
  765. const handleDetailPageSizeChange = async () => {
  766. detailPagination.value.current = 1;
  767. await fetchDetailTable();
  768. };
  769. const handleDetailJumpPage = async () => {
  770. const next = Number(detailJumpPage.value);
  771. if (!Number.isInteger(next) || next < 1) {
  772. createMessage.warning('请输入正确页码');
  773. detailJumpPage.value = String(detailPagination.value.current);
  774. return;
  775. }
  776. detailPagination.value.current = Math.min(next, detailTotalPages.value);
  777. await fetchDetailTable();
  778. };
  779. const fetchTargetOptions = async () => {
  780. try {
  781. targetOptions.value = await getPersonOptions(false);
  782. } catch (error) {
  783. targetOptions.value = [];
  784. }
  785. };
  786. onMounted(async () => {
  787. await fetchTargetOptions();
  788. });
  789. </script>
  790. <style lang="less">
  791. @import '../styles/trans-analysis-table-ui.less';
  792. @prefix-cls: ~'jeesite-fixed-deposit';
  793. .@{prefix-cls}.fixed-deposit-page {
  794. .analysis-page-frame();
  795. .filter-input {
  796. width: 180px;
  797. }
  798. .filter-date {
  799. width: 360px;
  800. }
  801. .toolbar-actions {
  802. display: flex;
  803. align-items: center;
  804. gap: 8px;
  805. margin-left: auto;
  806. flex-wrap: wrap;
  807. }
  808. .filter-actions {
  809. display: flex;
  810. gap: 8px;
  811. }
  812. .extra-actions {
  813. display: flex;
  814. }
  815. .keyword-form {
  816. padding-top: 8px;
  817. }
  818. .content-layout {
  819. display: flex;
  820. gap: 2px;
  821. align-items: stretch;
  822. flex: 1 1 auto;
  823. min-height: 0;
  824. overflow: hidden;
  825. padding: 2px;
  826. background: #edf2f7;
  827. box-sizing: border-box;
  828. }
  829. .left-panel {
  830. flex: 0 0 320px;
  831. .analysis-card-shell();
  832. }
  833. .right-panel {
  834. flex: 1;
  835. min-width: 0;
  836. .analysis-card-shell();
  837. }
  838. .panel-header {
  839. display: flex;
  840. align-items: flex-start;
  841. justify-content: space-between;
  842. gap: 12px;
  843. padding: 0 0 8px;
  844. border-bottom: 0;
  845. flex: 0 0 auto;
  846. flex-wrap: wrap;
  847. }
  848. .panel-title {
  849. font-size: 14px;
  850. font-weight: 600;
  851. color: #111827;
  852. line-height: 22px;
  853. }
  854. .panel-subtitle {
  855. color: #6b7280;
  856. font-size: 12px;
  857. line-height: 20px;
  858. }
  859. .panel-desc {
  860. margin-top: 4px;
  861. color: #6b7280;
  862. font-size: 12px;
  863. line-height: 20px;
  864. }
  865. .summary-list {
  866. display: flex;
  867. flex-direction: column;
  868. flex: 1 1 auto;
  869. gap: 8px;
  870. min-height: 0;
  871. padding: 0;
  872. overflow: auto;
  873. }
  874. .summary-card {
  875. border: 1px solid #e5e7eb;
  876. border-radius: 6px;
  877. background: transparent;
  878. padding: 10px 8px;
  879. cursor: pointer;
  880. transition:
  881. border-color 0.2s ease,
  882. box-shadow 0.2s ease,
  883. transform 0.2s ease;
  884. &:hover {
  885. border-color: #cbd5e1;
  886. box-shadow: none;
  887. transform: none;
  888. }
  889. &.active {
  890. border-color: #93c5fd;
  891. background: rgba(244, 248, 255, 0.72);
  892. box-shadow: none;
  893. }
  894. }
  895. .summary-top {
  896. display: flex;
  897. align-items: center;
  898. justify-content: space-between;
  899. gap: 12px;
  900. margin-bottom: 8px;
  901. }
  902. .summary-name {
  903. font-size: 15px;
  904. font-weight: 600;
  905. color: #111827;
  906. line-height: 1.4;
  907. }
  908. .summary-badge {
  909. flex: 0 0 auto;
  910. padding: 3px 8px;
  911. border-radius: 999px;
  912. background: #e2e8f0;
  913. color: #475569;
  914. font-size: 11px;
  915. line-height: 1.4;
  916. }
  917. .summary-card.active .summary-badge {
  918. background: #dbeafe;
  919. color: #1d4ed8;
  920. }
  921. .summary-metrics {
  922. display: flex;
  923. flex-direction: column;
  924. gap: 6px;
  925. margin-top: 8px;
  926. padding: 8px 0 0;
  927. border-radius: 0;
  928. background: transparent;
  929. border-top: 1px solid #eef2f7;
  930. }
  931. .summary-metric {
  932. display: flex;
  933. align-items: baseline;
  934. gap: 6px;
  935. color: #374151;
  936. font-size: 14px;
  937. line-height: 22px;
  938. word-break: break-word;
  939. }
  940. .summary-metric-label {
  941. color: #4b5563;
  942. white-space: nowrap;
  943. }
  944. .summary-metric-value {
  945. color: #111827;
  946. font-weight: 600;
  947. }
  948. .summary-empty {
  949. color: #94a3b8;
  950. font-size: 12px;
  951. padding: 28px 12px;
  952. text-align: center;
  953. border-top: 1px dashed #dbe4ee;
  954. border-radius: 0;
  955. background: transparent;
  956. }
  957. .query-state-panel {
  958. flex: 1 1 auto;
  959. min-height: 0;
  960. display: flex;
  961. align-items: center;
  962. justify-content: center;
  963. padding: 12px 0 0;
  964. }
  965. .table-wrapper {
  966. flex: 1 1 auto;
  967. min-height: 0;
  968. margin: 0;
  969. border-top: 1px solid #eef2f7;
  970. border-radius: 0;
  971. overflow: hidden;
  972. }
  973. .table-wrapper .jeesite-basic-table {
  974. height: 100%;
  975. display: flex;
  976. flex-direction: column;
  977. }
  978. .table-wrapper .ant-table-wrapper {
  979. height: 100%;
  980. min-height: 0;
  981. }
  982. .table-wrapper .ant-spin-nested-loading,
  983. .table-wrapper .ant-spin-container {
  984. height: 100%;
  985. min-height: 0;
  986. }
  987. .table-wrapper .ant-spin-container,
  988. .table-wrapper .ant-table,
  989. .table-wrapper .ant-table-container {
  990. height: 100%;
  991. min-height: 0;
  992. }
  993. .table-wrapper .ant-spin-container,
  994. .table-wrapper .ant-table,
  995. .table-wrapper .ant-table-container {
  996. display: flex;
  997. flex-direction: column;
  998. }
  999. .table-wrapper .ant-table-body {
  1000. max-height: 100% !important;
  1001. }
  1002. .table-wrapper .ant-table-body::-webkit-scrollbar {
  1003. width: 8px;
  1004. height: 8px;
  1005. }
  1006. .table-wrapper .ant-table-body::-webkit-scrollbar-thumb {
  1007. background: rgba(148, 163, 184, 0.6);
  1008. border-radius: 999px;
  1009. }
  1010. .table-wrapper .ant-table-body::-webkit-scrollbar-track {
  1011. background: transparent;
  1012. }
  1013. .table-wrapper .ant-table-cell {
  1014. font-size: 12px;
  1015. }
  1016. .table-wrapper .ant-table-thead > tr > th {
  1017. background: #f8fafc;
  1018. font-weight: 600;
  1019. color: #374151;
  1020. }
  1021. .table-wrapper .ant-table-tbody > tr > td {
  1022. color: #374151;
  1023. }
  1024. .table-wrapper .ant-table-tbody > tr:hover > td {
  1025. background: #f5f7ff;
  1026. }
  1027. .pagination-bar {
  1028. margin: 0;
  1029. padding: 0;
  1030. display: flex;
  1031. align-items: center;
  1032. justify-content: flex-end;
  1033. gap: 8px;
  1034. color: #6b7280;
  1035. font-size: 12px;
  1036. flex: 0 0 auto;
  1037. flex-wrap: wrap;
  1038. background: transparent;
  1039. }
  1040. :deep(.ant-select-selector),
  1041. :deep(.ant-input),
  1042. :deep(.ant-picker),
  1043. :deep(.ant-btn) {
  1044. border-radius: 8px;
  1045. }
  1046. .pagination-total {
  1047. margin-right: 0;
  1048. white-space: nowrap;
  1049. }
  1050. .pagination-size {
  1051. display: flex;
  1052. align-items: center;
  1053. gap: 6px;
  1054. white-space: nowrap;
  1055. }
  1056. .pagination-actions {
  1057. display: flex;
  1058. gap: 6px;
  1059. align-items: center;
  1060. white-space: nowrap;
  1061. }
  1062. .pagination-jump {
  1063. display: flex;
  1064. align-items: center;
  1065. gap: 6px;
  1066. white-space: nowrap;
  1067. }
  1068. .pagination-input {
  1069. width: 48px;
  1070. }
  1071. @media (max-width: 900px) {
  1072. .content-layout {
  1073. flex-direction: column;
  1074. }
  1075. .left-panel {
  1076. flex-basis: auto;
  1077. }
  1078. .summary-list {
  1079. max-height: none;
  1080. }
  1081. }
  1082. @media (max-width: 768px) {
  1083. .filter-bar {
  1084. gap: 10px;
  1085. }
  1086. .filter-input,
  1087. .filter-date {
  1088. width: 100%;
  1089. }
  1090. .filter-item {
  1091. width: 100%;
  1092. align-items: flex-start;
  1093. flex-direction: column;
  1094. }
  1095. .filter-actions {
  1096. margin-left: 0;
  1097. }
  1098. .toolbar-actions {
  1099. width: 100%;
  1100. margin-left: 0;
  1101. }
  1102. .extra-actions {
  1103. margin-left: 0;
  1104. width: 100%;
  1105. }
  1106. .summary-list {
  1107. padding: 0;
  1108. }
  1109. }
  1110. }
  1111. </style>