From abdfbe7b00360e6120362ed5ff49f897e0b91206 Mon Sep 17 00:00:00 2001 From: lq1405 <2769838458@qq.com> Date: Fri, 7 Feb 2025 15:57:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AF=95=E7=94=A8=20?= =?UTF-8?q?=E6=9B=B4=E5=85=B7=E8=AE=BE=E7=BD=AE=E7=9A=84=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SofrwareControlManagement.tsx | 27 +++++++++++++++++-- src/services/services/software.ts | 5 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/pages/Software/SofrwareControl/SofrwareControlManagement.tsx b/src/pages/Software/SofrwareControl/SofrwareControlManagement.tsx index e8914c1..a4fce7d 100644 --- a/src/pages/Software/SofrwareControl/SofrwareControlManagement.tsx +++ b/src/pages/Software/SofrwareControl/SofrwareControlManagement.tsx @@ -7,6 +7,8 @@ import { FilterValue, SorterResult, TableCurrentDataSource, TablePaginationConfi import { Software, SoftwareControl } from '@/services/services/software'; import moment from 'moment'; import { DeleteOutlined, EditOutlined, MenuOutlined, PlusSquareOutlined } from '@ant-design/icons'; +import { GetOptions, getOptionsStringValue } from '@/services/services/options/optionsTool'; +import { useSoftStore } from '@/store/software'; interface SoftwareControlManagementProps { @@ -30,6 +32,7 @@ const SoftwareControlManagement: FC = () => { totalBoundaryShowSizeChanger: true, }, }); + const { setTopSpinning, setTopSpinTip } = useSoftStore(); @@ -109,6 +112,16 @@ const SoftwareControlManagement: FC = () => { messageApi.warning("暂不支持编辑"); } }, + { + key: 'addTrail', + label: '添加试用', + style: { color: '#faad14' }, + icon: , + onClick: async () => { + // 添加试用 + await AddSoftwareControlExpirationTime(record.id, 1, true); + } + }, { key: 'addMouth', label: '添加月付', @@ -199,15 +212,24 @@ const SoftwareControlManagement: FC = () => { } } - async function AddSoftwareControlExpirationTime(id: string, days: number) { + async function AddSoftwareControlExpirationTime(id: string, days: number, isTry = false) { try { + if (isTry) { + setTopSpinning(true); + setTopSpinTip("加载信息中"); + let LaiToolTrialDays = 1; + let res = await GetOptions("trial"); + days = Number(getOptionsStringValue(res, 'LaiToolTrialDays', "") || LaiToolTrialDays); + setTopSpinning(false); + } + const confirmed = await modalApi.confirm({ title: "确认添加", content: `确认添加 ${days == 0 ? "永久" : days + " 天"} 吗?` }); if (confirmed) { setLoading(true); - await SoftwareControl.AddSoftwareControlExpirationTime(id, days, days == 0); + await SoftwareControl.AddSoftwareControlExpirationTime(id, days, days == 0, isTry); // 重新查询 await QueryUserSoftwareControlCollection(tableParams, form.getFieldsValue()); if (days == 0) { @@ -222,6 +244,7 @@ const SoftwareControlManagement: FC = () => { messageApi.error(error.message); } finally { setLoading(false); + setTopSpinning(false); } } diff --git a/src/services/services/software.ts b/src/services/services/software.ts index 5e0b85b..cffc5ab 100644 --- a/src/services/services/software.ts +++ b/src/services/services/software.ts @@ -55,12 +55,13 @@ async function GetUserSoftwareControlCollection(tableParams: TableModel.TablePar return res.data; } -async function AddSoftwareControlExpirationTime(id: string, days: number, isForever: boolean) { +async function AddSoftwareControlExpirationTime(id: string, days: number, isForever: boolean, isTry = false) { let res = await request>(`/lms/SoftWare/ModifySoftwareControlValidity/${id}`, { method: 'POST', data: { expirationTime: days, - isForever: isForever + isForever: isForever, + isTry: isTry } }); if (res.code != 1) {