SpecialDateConfigModal.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. <template>
  2. <ConfigManageModal
  3. :open="props.open"
  4. title="特殊日期管理"
  5. :width="1100"
  6. wrapClassName="special-date-config-modal"
  7. :summary="loading ? '正在同步特殊日期配置列表' : props.summary"
  8. :refresh-loading="loading"
  9. :show-refresh="false"
  10. create-text="新建日期"
  11. :table-height="420"
  12. :show-page-indicator="false"
  13. :total="total"
  14. :current="pagination.current"
  15. :total-pages="totalPages"
  16. :page-size="pagination.pageSize"
  17. :page-size-options="pageSizeOptions"
  18. :jump-page="jumpPage"
  19. @update:open="handleModalChange"
  20. @update:jumpPage="handleJumpPageInput"
  21. @cancel="closeModal"
  22. @create="openCreateModal"
  23. @prev-page="handlePrevPage"
  24. @next-page="handleNextPage"
  25. @page-size-change="handlePageSizeChange"
  26. @jump-page="handleJumpPage"
  27. >
  28. <template #default="{ tableMaxHeight }">
  29. <BasicTable
  30. v-if="rows.length"
  31. :columns="columns"
  32. :data-source="rows"
  33. :loading="loading"
  34. :pagination="false"
  35. :showIndexColumn="false"
  36. :show-table-setting="false"
  37. :table-setting="{ size: true, setting: true, redo: false, fullScreen: false }"
  38. :can-resize="true"
  39. :max-height="tableMaxHeight"
  40. row-key="rowKey"
  41. >
  42. <template #action="{ record }">
  43. <TableAction :actions="getActions(record)" :stopButtonPropagation="true" />
  44. </template>
  45. </BasicTable>
  46. <div v-else class="analysis-config-manage__empty special-date-modal__empty">
  47. <EmptyState
  48. :title="loading ? '正在加载特殊日期' : '暂无特殊日期'"
  49. :description="loading ? '请稍候...' : '接口返回后会在此展示列表'"
  50. variant="compact"
  51. :min-height="Math.max(240, tableMaxHeight)"
  52. />
  53. </div>
  54. </template>
  55. </ConfigManageModal>
  56. <ConfigEditorModal
  57. v-model:open="createOpen"
  58. :title="editorTitle"
  59. :confirmLoading="createSaving"
  60. :width="700"
  61. okText="保存"
  62. cancelText="取消"
  63. wrapClassName="special-date-editor-modal"
  64. @ok="handleSubmit"
  65. @cancel="closeCreateModal"
  66. >
  67. <Form class="special-date-form" :label-col="{ style: { width: '104px' } }">
  68. <div class="special-date-form__row">
  69. <Form.Item label="生效方式" required :validate-status="formErrors.type ? 'error' : ''" :help="formErrors.type">
  70. <div class="special-date-form__compact">
  71. <Select
  72. v-model:value="formState.type"
  73. class="special-date-form__field special-date-form__type-select"
  74. :options="typeOptions"
  75. placeholder="请选择生效方式"
  76. :getPopupContainer="getModalPopupContainer"
  77. @change="handleTypeChange"
  78. />
  79. </div>
  80. </Form.Item>
  81. </div>
  82. <div class="special-date-form__row">
  83. <Form.Item
  84. label="选择日期"
  85. required
  86. :validate-status="formErrors.specialDay ? 'error' : ''"
  87. :help="formErrors.specialDay"
  88. >
  89. <div class="special-date-form__compact special-date-form__date-selects">
  90. <Select
  91. v-model:value="formState.month"
  92. class="special-date-form__field special-date-form__date-select"
  93. :options="monthOptions"
  94. :placeholder="monthPlaceholder"
  95. :getPopupContainer="getModalPopupContainer"
  96. @change="handleMonthChange"
  97. />
  98. <Select
  99. v-model:value="formState.day"
  100. class="special-date-form__field special-date-form__date-select"
  101. :options="dayOptions"
  102. :placeholder="dayPlaceholder"
  103. :getPopupContainer="getModalPopupContainer"
  104. />
  105. </div>
  106. </Form.Item>
  107. </div>
  108. <div class="special-date-form__row">
  109. <Form.Item label="生效时长" :validate-status="formErrors.gap ? 'error' : ''" :help="formErrors.gap">
  110. <div class="special-date-form__compact special-date-form__duration">
  111. <span>前后</span>
  112. <InputNumber
  113. v-model:value="formState.gap"
  114. class="special-date-form__field special-date-form__duration-input"
  115. :min="0"
  116. :precision="0"
  117. placeholder="请输入生效时长"
  118. />
  119. <span>天</span>
  120. </div>
  121. </Form.Item>
  122. </div>
  123. <div class="special-date-form__row">
  124. <Form.Item label="说明">
  125. <Input.TextArea
  126. v-model:value="formState.name"
  127. class="special-date-form__textarea"
  128. :maxlength="50"
  129. :auto-size="{ minRows: 4, maxRows: 4 }"
  130. placeholder="请输入日期说明,例如生日、纪念日"
  131. />
  132. </Form.Item>
  133. </div>
  134. </Form>
  135. </ConfigEditorModal>
  136. </template>
  137. <script lang="ts" setup name="PersonSpecialDateConfigModal">
  138. import { computed, ref, watch } from 'vue';
  139. import { Select, Input, Form, InputNumber } from 'ant-design-vue';
  140. import { BasicTable, TableAction } from '@jeesite/core/components/Table';
  141. import { EmptyState } from '@jeesite/core/components/EmptyState';
  142. import { useMessage } from '@jeesite/core/hooks/web/useMessage';
  143. import { getModalPopupContainer as resolveModalPopupContainer } from '@jeesite/core/utils';
  144. import ConfigManageModal from '@jeesite/core/components/AnalysisConfigModal/src/ConfigManageModal.vue';
  145. import ConfigEditorModal from '@jeesite/core/components/AnalysisConfigModal/src/ConfigEditorModal.vue';
  146. import componentSetting from '@jeesite/core/settings/componentSetting';
  147. import {
  148. createSpecialDateConfig,
  149. deleteSpecialDateConfig,
  150. listSpecialDateConfig,
  151. updateSpecialDateConfig,
  152. } from '@jeesite/person/api/personApi';
  153. const props = withDefaults(
  154. defineProps<{
  155. open: boolean;
  156. summary?: string;
  157. }>(),
  158. {
  159. summary: '统一维护敏感日期分析使用的特殊日期配置',
  160. },
  161. );
  162. const emit = defineEmits<{
  163. (e: 'update:open', value: boolean): void;
  164. }>();
  165. const { createMessage } = useMessage();
  166. const getModalPopupContainer = (triggerNode?: HTMLElement) => resolveModalPopupContainer(triggerNode);
  167. const loading = ref(false);
  168. const sourceRows = ref<any[]>([]);
  169. const createOpen = ref(false);
  170. const createSaving = ref(false);
  171. const editId = ref('');
  172. const pagination = ref({
  173. current: 1,
  174. pageSize: componentSetting.table.defaultPageSize,
  175. });
  176. const jumpPage = ref('1');
  177. const typeOptions = [
  178. { label: '公历', value: 0 },
  179. { label: '农历', value: 1 },
  180. ];
  181. const solarMonthOptions = Array.from({ length: 12 }, (_, index) => {
  182. const value = String(index + 1).padStart(2, '0');
  183. return { label: value, value };
  184. });
  185. const lunarMonthLabels = [
  186. '正月',
  187. '二月',
  188. '三月',
  189. '四月',
  190. '五月',
  191. '六月',
  192. '七月',
  193. '八月',
  194. '九月',
  195. '十月',
  196. '冬月',
  197. '腊月',
  198. ];
  199. const lunarMonthParseLabels = [
  200. ['正月', '一月'],
  201. ['二月'],
  202. ['三月'],
  203. ['四月'],
  204. ['五月'],
  205. ['六月'],
  206. ['七月'],
  207. ['八月'],
  208. ['九月'],
  209. ['十月'],
  210. ['冬月', '十一月'],
  211. ['腊月', '十二月'],
  212. ];
  213. const lunarDayLabels = [
  214. '初一',
  215. '初二',
  216. '初三',
  217. '初四',
  218. '初五',
  219. '初六',
  220. '初七',
  221. '初八',
  222. '初九',
  223. '初十',
  224. '十一',
  225. '十二',
  226. '十三',
  227. '十四',
  228. '十五',
  229. '十六',
  230. '十七',
  231. '十八',
  232. '十九',
  233. '二十',
  234. '廿一',
  235. '廿二',
  236. '廿三',
  237. '廿四',
  238. '廿五',
  239. '廿六',
  240. '廿七',
  241. '廿八',
  242. '廿九',
  243. '三十',
  244. ];
  245. const formState = ref({
  246. name: '',
  247. month: undefined as string | undefined,
  248. day: undefined as string | undefined,
  249. flag: 1,
  250. innerFlag: 0,
  251. type: 0,
  252. gap: undefined as number | undefined,
  253. });
  254. const formErrors = ref({
  255. specialDay: '',
  256. type: '',
  257. gap: '',
  258. });
  259. const pageSizeOptions = componentSetting.table.pageSizeOptions.map((value) => ({
  260. label: value,
  261. value,
  262. }));
  263. const columns = [
  264. { title: '序号', dataIndex: 'serialNo', key: 'serialNo', width: 80 },
  265. { title: '特殊日期', dataIndex: 'specialDate', key: 'specialDate', width: 260 },
  266. { title: '生效时长', dataIndex: 'durationText', key: 'durationText', width: 220 },
  267. { title: '日期说明', dataIndex: 'description', key: 'description', width: 320 },
  268. { title: '操作', dataIndex: 'action', key: 'action', width: 160, fixed: 'right', align: 'center', slot: 'action' },
  269. ];
  270. const editorTitle = computed(() => (editId.value ? '编辑特殊日期' : '新建特殊日期'));
  271. const total = computed(() => sourceRows.value.length);
  272. const totalPages = computed(() => {
  273. if (!total.value) return 1;
  274. return Math.max(1, Math.ceil(total.value / pagination.value.pageSize));
  275. });
  276. const rows = computed(() => {
  277. const start = (pagination.value.current - 1) * pagination.value.pageSize;
  278. return sourceRows.value.slice(start, start + pagination.value.pageSize);
  279. });
  280. const normalizeObjectArray = (value: any): Record<string, any>[] => {
  281. if (Array.isArray(value)) return value;
  282. const candidates = [
  283. value?.records,
  284. value?.list,
  285. value?.data,
  286. value?.data?.records,
  287. value?.data?.list,
  288. value?.data?.data,
  289. value?.result,
  290. ];
  291. for (const item of candidates) {
  292. if (Array.isArray(item)) return item;
  293. }
  294. return [];
  295. };
  296. const fallbackText = (value: unknown) => {
  297. if (value === 0) return '0';
  298. if (value === null || value === undefined || value === '') return '-';
  299. return String(value);
  300. };
  301. const normalizeSpecialDateType = (value: unknown) => {
  302. if (value === null || value === undefined || value === '') return undefined;
  303. const text = String(value).trim();
  304. if (text === '0' || text.includes('公')) return 0;
  305. if (text === '1' || text.includes('农')) return 1;
  306. return undefined;
  307. };
  308. const parseLunarSpecialDate = (value: string) => {
  309. const text = value.trim();
  310. if (!text) return '';
  311. for (let monthIndex = 0; monthIndex < lunarMonthParseLabels.length; monthIndex += 1) {
  312. const monthLabels = lunarMonthParseLabels[monthIndex];
  313. const matchedMonthLabel = monthLabels.find((label) => text.startsWith(label));
  314. if (!matchedMonthLabel) continue;
  315. const restText = text.slice(matchedMonthLabel.length);
  316. const numericDay = restText.match(/^(\d{1,2})$/);
  317. if (numericDay) {
  318. return `${String(monthIndex + 1).padStart(2, '0')}-${numericDay[1].padStart(2, '0')}`;
  319. }
  320. const dayIndex = lunarDayLabels.findIndex((label) => label === restText);
  321. if (dayIndex >= 0) {
  322. return `${String(monthIndex + 1).padStart(2, '0')}-${String(dayIndex + 1).padStart(2, '0')}`;
  323. }
  324. }
  325. return '';
  326. };
  327. const normalizeSpecialDateValue = (row: Record<string, any>) => {
  328. const rawValue =
  329. row.specialDay ||
  330. row.spDate ||
  331. row.specialDate ||
  332. row.festivalDate ||
  333. row.date ||
  334. row.day ||
  335. row.holidayDate ||
  336. row.nMd;
  337. if (rawValue) {
  338. const text = String(rawValue).trim();
  339. const matched = text.match(/(\d{1,2})-(\d{1,2})/);
  340. if (matched) {
  341. return `${matched[1].padStart(2, '0')}-${matched[2].padStart(2, '0')}`;
  342. }
  343. const lunarValue = parseLunarSpecialDate(text);
  344. if (lunarValue) return lunarValue;
  345. }
  346. const gDatetime = String(row.gDatetime || row.gDate || '').trim();
  347. if (/^\d{4}-\d{2}-\d{2}$/.test(gDatetime)) return gDatetime.slice(5);
  348. return '';
  349. };
  350. const getSpecialDateMaxDay = (month?: string, type?: number) => {
  351. if (!month) return 31;
  352. if (type === 1) return 30;
  353. if (month === '02') return 29;
  354. if (['04', '06', '09', '11'].includes(month)) return 30;
  355. return 31;
  356. };
  357. const dayOptions = computed(() => {
  358. const maxDay = getSpecialDateMaxDay(formState.value.month, formState.value.type);
  359. return Array.from({ length: maxDay }, (_, index) => {
  360. const value = String(index + 1).padStart(2, '0');
  361. const label = formState.value.type === 1 ? lunarDayLabels[index] || value : value;
  362. return { label, value };
  363. });
  364. });
  365. const monthOptions = computed(() => {
  366. if (formState.value.type === 1) {
  367. return lunarMonthLabels.map((label, index) => ({ label, value: String(index + 1).padStart(2, '0') }));
  368. }
  369. return solarMonthOptions;
  370. });
  371. const monthPlaceholder = computed(() => (formState.value.type === 1 ? '请选择特殊月' : '请选择月份'));
  372. const dayPlaceholder = computed(() => (formState.value.type === 1 ? '请选择特殊日' : '请选择日期'));
  373. const formatSpecialDatePayloadValue = (month?: string, day?: string) => {
  374. if (!month || !day) return '';
  375. return `${month}-${day}`;
  376. };
  377. const formatSpecialDateText = (row: Record<string, any>) => {
  378. const dateText = normalizeSpecialDateValue(row) || '-';
  379. const calendarType =
  380. normalizeSpecialDateType(
  381. row.workType ?? row.type ?? row.calendarType ?? row.dateType ?? row.calType ?? row.specialDateType,
  382. ) ?? 0;
  383. const calendarLabel = calendarType === 1 ? '农历' : '公历';
  384. if (calendarType === 1 && dateText !== '-') {
  385. const [month, day] = dateText.split('-');
  386. const monthLabel = lunarMonthLabels[Number(month) - 1] || month;
  387. const dayLabel = lunarDayLabels[Number(day) - 1] || day;
  388. return `${monthLabel}${dayLabel}(${calendarLabel})`;
  389. }
  390. return `${dateText}(${calendarLabel})`;
  391. };
  392. const formatSpecialDateDuration = (row: Record<string, any>) => {
  393. const gap = row.dayGap ?? row.gap ?? row.duration ?? row.effectDuration ?? row.validDuration;
  394. if (gap === null || gap === undefined || gap === '') return '前后0天';
  395. return `前后${Number(gap) || 0}天`;
  396. };
  397. const formatSpecialDateDescription = (row: Record<string, any>) =>
  398. fallbackText(row.name || row.description || row.dateDesc || row.remark || row.festivalName || '-');
  399. const getSpecialDateDescriptionValue = (row?: Record<string, any>) =>
  400. String(row?.name || row?.description || row?.dateDesc || row?.remark || row?.festivalName || '').trim();
  401. const resetForm = () => {
  402. formState.value = {
  403. name: '',
  404. month: undefined,
  405. day: undefined,
  406. flag: 1,
  407. innerFlag: 0,
  408. type: 0,
  409. gap: undefined,
  410. };
  411. formErrors.value = {
  412. specialDay: '',
  413. type: '',
  414. gap: '',
  415. };
  416. };
  417. const validateForm = () => {
  418. const { month, day, type, gap } = formState.value;
  419. const maxDay = getSpecialDateMaxDay(month?.trim(), type);
  420. formErrors.value = {
  421. type: type === 0 || type === 1 ? '' : '请选择历法类型',
  422. specialDay: month && day && Number(day) >= 1 && Number(day) <= maxDay ? '' : '请选择正确的月日',
  423. gap: gap !== undefined && gap !== null && gap < 0 ? '请输入有效生效时长' : '',
  424. };
  425. return !Object.values(formErrors.value).some(Boolean);
  426. };
  427. const syncDay = () => {
  428. const day = formState.value.day;
  429. if (!day) return;
  430. const maxDay = getSpecialDateMaxDay(formState.value.month, formState.value.type);
  431. if (Number(day) > maxDay) {
  432. formState.value.day = String(maxDay).padStart(2, '0');
  433. }
  434. };
  435. const handleTypeChange = () => {
  436. syncDay();
  437. };
  438. const handleMonthChange = () => {
  439. syncDay();
  440. };
  441. const syncJumpPage = () => {
  442. jumpPage.value = String(pagination.value.current);
  443. };
  444. const loadList = async () => {
  445. loading.value = true;
  446. try {
  447. const response = await listSpecialDateConfig();
  448. const list = normalizeObjectArray(response);
  449. sourceRows.value = list.map((item, index) => ({
  450. rowKey: String(item.id ?? item.sdcId ?? index),
  451. serialNo: index + 1,
  452. specialDate: formatSpecialDateText(item),
  453. durationText: formatSpecialDateDuration(item),
  454. description: formatSpecialDateDescription(item),
  455. raw: item,
  456. }));
  457. pagination.value.current = Math.min(pagination.value.current, totalPages.value);
  458. syncJumpPage();
  459. } catch (error) {
  460. console.error('获取特殊日期列表失败', error);
  461. sourceRows.value = [];
  462. pagination.value.current = 1;
  463. syncJumpPage();
  464. createMessage.warning('特殊日期列表获取失败');
  465. } finally {
  466. loading.value = false;
  467. }
  468. };
  469. const openModal = async () => {
  470. pagination.value.current = 1;
  471. syncJumpPage();
  472. await loadList();
  473. };
  474. const closeModal = () => {
  475. emit('update:open', false);
  476. };
  477. const handleModalChange = (value: boolean) => {
  478. emit('update:open', value);
  479. };
  480. const openCreateModal = () => {
  481. resetForm();
  482. editId.value = '';
  483. createOpen.value = true;
  484. };
  485. const closeCreateModal = () => {
  486. createOpen.value = false;
  487. editId.value = '';
  488. resetForm();
  489. };
  490. const fillForm = (record?: Record<string, any>) => {
  491. const rawType =
  492. normalizeSpecialDateType(
  493. record?.workType ??
  494. record?.type ??
  495. record?.calendarType ??
  496. record?.dateType ??
  497. record?.calType ??
  498. record?.specialDateType,
  499. ) ?? 0;
  500. const specialDay = normalizeSpecialDateValue(record || {});
  501. const [month, day] = specialDay ? specialDay.split('-') : [undefined, undefined];
  502. const flag = record?.flag ?? 1;
  503. const innerFlag = record?.innerFlag ?? 0;
  504. formState.value = {
  505. name: getSpecialDateDescriptionValue(record),
  506. month,
  507. day,
  508. flag: Number.isFinite(Number(flag)) ? Number(flag) : 1,
  509. innerFlag: Number.isFinite(Number(innerFlag)) ? Number(innerFlag) : 0,
  510. type: rawType,
  511. gap:
  512. record?.dayGap !== undefined && record?.dayGap !== null
  513. ? Number(record.dayGap)
  514. : record?.gap !== undefined && record?.gap !== null
  515. ? Number(record.gap)
  516. : undefined,
  517. };
  518. formErrors.value = {
  519. specialDay: '',
  520. type: '',
  521. gap: '',
  522. };
  523. };
  524. const openEditModal = (row: any) => {
  525. const raw = row?.raw || {};
  526. const nextEditId = String(raw.id ?? raw.sdcId ?? '').trim();
  527. if (!nextEditId) {
  528. createMessage.warning('缺少特殊日期ID,暂无法编辑');
  529. return;
  530. }
  531. editId.value = nextEditId;
  532. fillForm(raw);
  533. createOpen.value = true;
  534. };
  535. const handleSubmit = async () => {
  536. if (!validateForm()) return;
  537. createSaving.value = true;
  538. try {
  539. const spDate = formatSpecialDatePayloadValue(formState.value.month, formState.value.day);
  540. const payload = {
  541. ...(editId.value ? { id: editId.value } : {}),
  542. name: formState.value.name.trim() || undefined,
  543. flag: formState.value.flag,
  544. type: formState.value.type,
  545. gap: formState.value.gap ?? 0,
  546. spDate,
  547. };
  548. if (editId.value) {
  549. await updateSpecialDateConfig(payload);
  550. } else {
  551. await createSpecialDateConfig(payload);
  552. }
  553. createMessage.success(editId.value ? '特殊日期更新成功' : '特殊日期新增成功');
  554. createOpen.value = false;
  555. await loadList();
  556. editId.value = '';
  557. resetForm();
  558. } catch (error) {
  559. console.error(editId.value ? '更新特殊日期失败' : '新增特殊日期失败', error);
  560. createMessage.warning(editId.value ? '特殊日期更新失败' : '特殊日期新增失败');
  561. } finally {
  562. createSaving.value = false;
  563. }
  564. };
  565. const handleDelete = async (row: any) => {
  566. const raw = row?.raw || {};
  567. const deleteId = String(raw.id ?? raw.sdcId ?? '').trim();
  568. if (!deleteId) {
  569. createMessage.warning('缺少特殊日期ID,暂无法删除');
  570. return;
  571. }
  572. try {
  573. await deleteSpecialDateConfig(deleteId);
  574. createMessage.success('特殊日期删除成功');
  575. await loadList();
  576. } catch (error) {
  577. console.error('删除特殊日期失败', error);
  578. createMessage.warning('特殊日期删除失败');
  579. }
  580. };
  581. const getActions = (row: any) => [
  582. {
  583. label: '编辑',
  584. onClick: () => openEditModal(row),
  585. },
  586. {
  587. label: '删除',
  588. color: 'error',
  589. popConfirm: {
  590. title: '确认删除特殊日期',
  591. content: `确定要删除“${row?.specialDate || formatSpecialDateText(row?.raw || {})}”吗?删除后无法恢复。`,
  592. placement: 'left',
  593. confirm: () => handleDelete(row),
  594. },
  595. },
  596. ];
  597. const handlePrevPage = () => {
  598. if (pagination.value.current <= 1) return;
  599. pagination.value.current -= 1;
  600. syncJumpPage();
  601. };
  602. const handleNextPage = () => {
  603. if (pagination.value.current >= totalPages.value) return;
  604. pagination.value.current += 1;
  605. syncJumpPage();
  606. };
  607. const handlePageSizeChange = (value: string | number) => {
  608. pagination.value.pageSize = Number(value);
  609. pagination.value.current = 1;
  610. syncJumpPage();
  611. };
  612. const handleJumpPage = () => {
  613. const next = Number(jumpPage.value);
  614. if (!Number.isInteger(next) || next < 1) {
  615. createMessage.warning('请输入正确页码');
  616. syncJumpPage();
  617. return;
  618. }
  619. pagination.value.current = Math.min(next, totalPages.value);
  620. syncJumpPage();
  621. };
  622. const handleJumpPageInput = (value: string) => {
  623. jumpPage.value = value;
  624. };
  625. watch(
  626. () => props.open,
  627. (value) => {
  628. if (value) {
  629. void openModal();
  630. } else {
  631. closeCreateModal();
  632. }
  633. },
  634. );
  635. </script>
  636. <style lang="less">
  637. .special-date-config-modal {
  638. .ant-modal {
  639. max-width: calc(100vw - 48px);
  640. }
  641. .ant-modal-content {
  642. max-height: min(720px, calc(100vh - 80px));
  643. display: flex;
  644. flex-direction: column;
  645. border-radius: 10px;
  646. overflow: hidden;
  647. }
  648. .ant-modal-header {
  649. flex: 0 0 auto;
  650. background: @modal-header-bg-color;
  651. }
  652. .ant-modal-body {
  653. flex: 1 1 auto;
  654. min-height: 0;
  655. overflow: hidden;
  656. padding: 16px;
  657. }
  658. }
  659. .special-date-modal {
  660. display: flex;
  661. flex-direction: column;
  662. gap: 16px;
  663. min-height: 0;
  664. overflow: hidden;
  665. &__empty {
  666. flex: 1 1 auto;
  667. min-height: 0;
  668. border: 1px dashed #dbe5ef;
  669. border-radius: 6px;
  670. background: #fafcff;
  671. }
  672. }
  673. .special-date-editor-modal {
  674. .ant-modal-content {
  675. border-radius: 10px;
  676. overflow: hidden;
  677. box-shadow: 0 18px 45px rgb(15 23 42 / 18%);
  678. }
  679. .ant-modal-header {
  680. padding: 12px 16px;
  681. border-bottom: 1px solid #e5e7eb;
  682. background: @modal-header-bg-color;
  683. }
  684. .ant-modal-body {
  685. padding: 16px;
  686. }
  687. .ant-modal-footer {
  688. padding: 8px 16px 10px;
  689. border-top: 1px solid #e5e7eb;
  690. }
  691. }
  692. .special-date-form {
  693. padding-top: 4px;
  694. &__row {
  695. margin-bottom: 22px;
  696. }
  697. .ant-form-item {
  698. margin-bottom: 0;
  699. }
  700. .ant-form-item-label > label {
  701. color: #111827;
  702. font-size: 14px;
  703. height: 40px;
  704. }
  705. .ant-form-item-explain-error {
  706. margin-top: 6px;
  707. font-size: 12px;
  708. }
  709. &__field,
  710. textarea.ant-input {
  711. border-radius: 8px;
  712. }
  713. &__compact {
  714. width: 476px;
  715. max-width: 476px;
  716. }
  717. &__date-selects {
  718. display: flex;
  719. gap: 16px;
  720. align-items: flex-start;
  721. flex-wrap: nowrap;
  722. width: 476px;
  723. max-width: 476px;
  724. }
  725. &__date-select {
  726. width: 230px;
  727. max-width: 230px;
  728. flex: 0 0 230px;
  729. min-width: 0;
  730. }
  731. &__type-select {
  732. width: 476px;
  733. max-width: 476px;
  734. }
  735. &__duration {
  736. display: flex;
  737. align-items: center;
  738. gap: 10px;
  739. color: #374151;
  740. }
  741. &__duration-input {
  742. width: 140px;
  743. }
  744. &__textarea {
  745. width: 540px;
  746. max-width: 540px;
  747. }
  748. .ant-select-selector,
  749. .ant-input-number,
  750. textarea.ant-input {
  751. min-height: 40px;
  752. border-color: #d1d5db;
  753. }
  754. .ant-select {
  755. width: 100%;
  756. }
  757. .ant-select-single .ant-select-selector {
  758. height: 40px;
  759. padding: 0 14px;
  760. align-items: center;
  761. }
  762. .ant-select-selection-item,
  763. .ant-select-selection-placeholder {
  764. line-height: 38px;
  765. }
  766. .ant-input-number {
  767. display: inline-flex;
  768. align-items: center;
  769. }
  770. .ant-input-number-input-wrap {
  771. height: 100%;
  772. }
  773. .ant-input-number-input {
  774. text-align: center;
  775. height: 38px;
  776. }
  777. textarea.ant-input {
  778. padding: 12px 16px;
  779. line-height: 22px;
  780. }
  781. }
  782. @media screen and (max-width: 640px) {
  783. .special-date-form__duration {
  784. width: 100%;
  785. }
  786. .special-date-form__compact,
  787. .special-date-form__type-select,
  788. .special-date-form__date-selects,
  789. .special-date-form__date-select,
  790. .special-date-form__duration-input,
  791. .special-date-form__textarea {
  792. width: 100%;
  793. max-width: none;
  794. }
  795. .special-date-form__date-selects {
  796. flex-direction: column;
  797. }
  798. .special-date-editor-modal .ant-modal-body,
  799. .special-date-editor-modal .ant-modal-footer {
  800. padding: 16px;
  801. }
  802. }
  803. </style>