|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
|
import { useNavigate, useParams } from 'react-router-dom';
|
|
|
|
|
import { ArrowLeft, Info, RadioTower } from 'lucide-react';
|
|
|
|
|
import { ArrowLeft, Info, RadioTower, RefreshCw } from 'lucide-react';
|
|
|
|
|
import { adminApi, type ChannelGroup, type DictionaryItem, type EnterpriseApplication } from '@/api/adminApi';
|
|
|
|
|
import { Breadcrumb, Button, Input, Select, Tag } from '@/components/ui';
|
|
|
|
|
|
|
|
|
@@ -23,6 +23,8 @@ export function AdminSmsApplicationFormPage() {
|
|
|
|
|
const [customerUnitPrice, setCustomerUnitPrice] = useState('0.0300');
|
|
|
|
|
const [queuePriority, setQueuePriority] = useState<QueuePriority>('normal');
|
|
|
|
|
const [cmppAccount, setCmppAccount] = useState('');
|
|
|
|
|
const [cmppEnterpriseCode, setCmppEnterpriseCode] = useState('');
|
|
|
|
|
const [passwordCipher, setPasswordCipher] = useState(() => generateApplicationPassword());
|
|
|
|
|
const [cmppMaxConnections, setCmppMaxConnections] = useState('1');
|
|
|
|
|
const [cmppWindowSize, setCmppWindowSize] = useState('16');
|
|
|
|
|
const [phoneDailyLimit, setPhoneDailyLimit] = useState('10');
|
|
|
|
@@ -79,6 +81,8 @@ export function AdminSmsApplicationFormPage() {
|
|
|
|
|
setCustomerUnitPrice(((application.customerUnitPrice ?? 0) / 100).toFixed(4));
|
|
|
|
|
setQueuePriority(application.queuePriority === 'priority' ? 'priority' : 'normal');
|
|
|
|
|
setCmppAccount(application.cmppAccount ?? '');
|
|
|
|
|
setCmppEnterpriseCode(application.cmppEnterpriseCode ?? application.tenant?.code ?? '');
|
|
|
|
|
setPasswordCipher('');
|
|
|
|
|
setCmppMaxConnections(String(application.cmppMaxConnections ?? 1));
|
|
|
|
|
setCmppWindowSize(String(application.cmppWindowSize ?? 16));
|
|
|
|
|
setPhoneDailyLimit(application.maxPhonesPerTask ? String(application.maxPhonesPerTask) : '');
|
|
|
|
@@ -117,6 +121,8 @@ export function AdminSmsApplicationFormPage() {
|
|
|
|
|
customerUnitPrice: Math.round(Number(customerUnitPrice || 0) * 100),
|
|
|
|
|
queuePriority,
|
|
|
|
|
cmppAccount: cmppAccount.trim() || undefined,
|
|
|
|
|
cmppEnterpriseCode: cmppEnterpriseCode.trim() || undefined,
|
|
|
|
|
passwordCipher: passwordCipher.trim() || undefined,
|
|
|
|
|
cmppMaxConnections: Number(cmppMaxConnections) || 1,
|
|
|
|
|
cmppWindowSize: Number(cmppWindowSize) || 16,
|
|
|
|
|
maxPhonesPerTask: Number(phoneDailyLimit) || undefined,
|
|
|
|
@@ -177,6 +183,15 @@ export function AdminSmsApplicationFormPage() {
|
|
|
|
|
<Input label="日发送数量限制" onChange={(event) => setDailyLimit(event.target.value)} placeholder="100000" required value={dailyLimit} />
|
|
|
|
|
<Input label="客户单价(元/条)" onChange={(event) => setCustomerUnitPrice(event.target.value)} placeholder="0.0300" required value={customerUnitPrice} />
|
|
|
|
|
<Input label="CMPP 6位账号" onChange={(event) => setCmppAccount(event.target.value)} placeholder="留空自动生成" value={cmppAccount} />
|
|
|
|
|
<Input label="企业代码" onChange={(event) => setCmppEnterpriseCode(event.target.value)} placeholder="请输入客户侧企业代码" value={cmppEnterpriseCode} />
|
|
|
|
|
<Input
|
|
|
|
|
hint={isEdit ? '留空则不修改接口密码;填写 16 位字符后覆盖。' : '默认随机生成,可按需修改。'}
|
|
|
|
|
label="接口密码"
|
|
|
|
|
onChange={(event) => setPasswordCipher(event.target.value)}
|
|
|
|
|
placeholder="16 位接口密码"
|
|
|
|
|
suffix={<button aria-label="随机生成接口密码" className="icon-button" onClick={() => setPasswordCipher(generateApplicationPassword())} type="button"><RefreshCw size={15} /></button>}
|
|
|
|
|
value={passwordCipher}
|
|
|
|
|
/>
|
|
|
|
|
<Input label="客户最大连接数" onChange={(event) => setCmppMaxConnections(event.target.value)} placeholder="1" required value={cmppMaxConnections} />
|
|
|
|
|
<Input label="客户提交窗口" onChange={(event) => setCmppWindowSize(event.target.value)} placeholder="16" required value={cmppWindowSize} />
|
|
|
|
|
<div className="admin-app-form-row admin-app-form-row--wide">
|
|
|
|
@@ -267,3 +282,10 @@ function parseIpAllowlist(value: string) {
|
|
|
|
|
.map((item) => item.trim())
|
|
|
|
|
.filter(Boolean);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateApplicationPassword() {
|
|
|
|
|
if (typeof crypto !== 'undefined' && 'randomUUID' in crypto) {
|
|
|
|
|
return crypto.randomUUID().replace(/-/g, '').slice(0, 16);
|
|
|
|
|
}
|
|
|
|
|
return Array.from({ length: 16 }, () => Math.floor(Math.random() * 16).toString(16)).join('');
|
|
|
|
|
}
|
|
|
|
|