新增试用 更具设置的试用时间
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 { Software, SoftwareControl } from '@/services/services/software';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { DeleteOutlined, EditOutlined, MenuOutlined, PlusSquareOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, EditOutlined, MenuOutlined, PlusSquareOutlined } from '@ant-design/icons';
|
||||||
|
import { GetOptions, getOptionsStringValue } from '@/services/services/options/optionsTool';
|
||||||
|
import { useSoftStore } from '@/store/software';
|
||||||
|
|
||||||
|
|
||||||
interface SoftwareControlManagementProps {
|
interface SoftwareControlManagementProps {
|
||||||
@ -30,6 +32,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
|
|||||||
totalBoundaryShowSizeChanger: true,
|
totalBoundaryShowSizeChanger: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const { setTopSpinning, setTopSpinTip } = useSoftStore();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -109,6 +112,16 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
|
|||||||
messageApi.warning("暂不支持编辑");
|
messageApi.warning("暂不支持编辑");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'addTrail',
|
||||||
|
label: '添加试用',
|
||||||
|
style: { color: '#faad14' },
|
||||||
|
icon: <PlusSquareOutlined />,
|
||||||
|
onClick: async () => {
|
||||||
|
// 添加试用
|
||||||
|
await AddSoftwareControlExpirationTime(record.id, 1, true);
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'addMouth',
|
key: 'addMouth',
|
||||||
label: '添加月付',
|
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 {
|
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({
|
const confirmed = await modalApi.confirm({
|
||||||
title: "确认添加",
|
title: "确认添加",
|
||||||
content: `确认添加 ${days == 0 ? "永久" : days + " 天"} 吗?`
|
content: `确认添加 ${days == 0 ? "永久" : days + " 天"} 吗?`
|
||||||
});
|
});
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
await SoftwareControl.AddSoftwareControlExpirationTime(id, days, days == 0);
|
await SoftwareControl.AddSoftwareControlExpirationTime(id, days, days == 0, isTry);
|
||||||
// 重新查询
|
// 重新查询
|
||||||
await QueryUserSoftwareControlCollection(tableParams, form.getFieldsValue());
|
await QueryUserSoftwareControlCollection(tableParams, form.getFieldsValue());
|
||||||
if (days == 0) {
|
if (days == 0) {
|
||||||
@ -222,6 +244,7 @@ const SoftwareControlManagement: FC<SoftwareControlManagementProps> = () => {
|
|||||||
messageApi.error(error.message);
|
messageApi.error(error.message);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
setTopSpinning(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,12 +55,13 @@ async function GetUserSoftwareControlCollection(tableParams: TableModel.TablePar
|
|||||||
return res.data;
|
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}`, {
|
let res = await request<ApiResponse.SuccessItem<null>>(`/lms/SoftWare/ModifySoftwareControlValidity/${id}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
expirationTime: days,
|
expirationTime: days,
|
||||||
isForever: isForever
|
isForever: isForever,
|
||||||
|
isTry: isTry
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (res.code != 1) {
|
if (res.code != 1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user