新增试用 更具设置的试用时间
This commit is contained in:
parent
94958d1c83
commit
abdfbe7b00
@ -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<SoftwareControlManagementProps> = () => {
|
||||
totalBoundaryShowSizeChanger: true,
|
||||
},
|
||||
});
|
||||
const { setTopSpinning, setTopSpinTip } = useSoftStore();
|
||||
|
||||
|
||||
|
||||
@ -109,6 +112,16 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
|
||||
messageApi.warning("暂不支持编辑");
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'addTrail',
|
||||
label: '添加试用',
|
||||
style: { color: '#faad14' },
|
||||
icon: <PlusSquareOutlined />,
|
||||
onClick: async () => {
|
||||
// 添加试用
|
||||
await AddSoftwareControlExpirationTime(record.id, 1, true);
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'addMouth',
|
||||
label: '添加月付',
|
||||
@ -199,15 +212,24 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
|
||||
}
|
||||
}
|
||||
|
||||
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<SoftwareControlManagementProps> = () => {
|
||||
messageApi.error(error.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
setTopSpinning(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<ApiResponse.SuccessItem<null>>(`/lms/SoftWare/ModifySoftwareControlValidity/${id}`, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
expirationTime: days,
|
||||
isForever: isForever
|
||||
isForever: isForever,
|
||||
isTry: isTry
|
||||
}
|
||||
});
|
||||
if (res.code != 1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user