1
This commit is contained in:
@@ -74,9 +74,15 @@
|
||||
<FormItem label="朋友圈额度">
|
||||
<Input v-model="form.sns_quota" type="number" />
|
||||
</FormItem>
|
||||
<FormItem label="API调用上限">
|
||||
<Input v-model="form.api_call_quota" type="number" placeholder="0=不限制" />
|
||||
</FormItem>
|
||||
<FormItem label="功能点 JSON">
|
||||
<Input v-model="featuresText" type="textarea" :rows="4" placeholder='如 {"msg":true} 或 ["msg","mass"]' />
|
||||
</FormItem>
|
||||
<FormItem label="可用接口 JSON">
|
||||
<Input v-model="allowedApisText" type="textarea" :rows="4" placeholder='接口路径数组,如 ["/user/GetProfile","/message/SendText"],留空=不限制' />
|
||||
</FormItem>
|
||||
<FormItem label="状态" prop="status">
|
||||
<Select v-model="form.status" style="width: 100%">
|
||||
<Option value="active">上线</Option>
|
||||
@@ -106,6 +112,7 @@ export default {
|
||||
saving: false,
|
||||
form: {},
|
||||
featuresText: '{}',
|
||||
allowedApisText: '',
|
||||
rules: {
|
||||
plan_code: [{ required: true, message: '必填', trigger: 'blur' }],
|
||||
plan_name: [{ required: true, message: '必填', trigger: 'blur' }],
|
||||
@@ -120,6 +127,7 @@ export default {
|
||||
{ title: '编码', key: 'plan_code', width: 120 },
|
||||
{ title: '名称', key: 'plan_name', minWidth: 140 },
|
||||
{ title: '月费', key: 'monthly_price', width: 90 },
|
||||
{ title: 'API调用上限', key: 'api_call_quota', width: 120, render: (h, p) => h('span', p.row.api_call_quota > 0 ? p.row.api_call_quota : '不限') },
|
||||
{ title: '状态', key: 'status', width: 90 },
|
||||
{
|
||||
title: '操作',
|
||||
@@ -166,6 +174,12 @@ export default {
|
||||
: typeof row.enabled_features === 'string'
|
||||
? row.enabled_features
|
||||
: JSON.stringify(row.enabled_features, null, 2)
|
||||
this.allowedApisText =
|
||||
row.allowed_apis == null
|
||||
? ''
|
||||
: typeof row.allowed_apis === 'string'
|
||||
? row.allowed_apis
|
||||
: JSON.stringify(row.allowed_apis, null, 2)
|
||||
} else {
|
||||
this.form = {
|
||||
plan_code: '',
|
||||
@@ -178,9 +192,11 @@ export default {
|
||||
mass_quota: 0,
|
||||
friend_quota: 0,
|
||||
sns_quota: 0,
|
||||
api_call_quota: 0,
|
||||
status: 'active',
|
||||
}
|
||||
this.featuresText = '{}'
|
||||
this.allowedApisText = ''
|
||||
}
|
||||
this.modal = true
|
||||
},
|
||||
@@ -202,7 +218,23 @@ export default {
|
||||
return
|
||||
}
|
||||
}
|
||||
const payload = { ...this.form, enabled_features }
|
||||
let allowed_apis = null
|
||||
const apisStr = (this.allowedApisText || '').trim()
|
||||
if (apisStr) {
|
||||
try {
|
||||
allowed_apis = JSON.parse(apisStr)
|
||||
if (!Array.isArray(allowed_apis)) {
|
||||
this.$Message.error('可用接口必须是 JSON 数组')
|
||||
this.saving = false
|
||||
return
|
||||
}
|
||||
} catch (e) {
|
||||
this.$Message.error('可用接口 JSON 格式错误')
|
||||
this.saving = false
|
||||
return
|
||||
}
|
||||
}
|
||||
const payload = { ...this.form, enabled_features, allowed_apis }
|
||||
try {
|
||||
const res = this.form.id ? await planServer.edit(payload) : await planServer.add(payload)
|
||||
if (res && res.code === 0) {
|
||||
|
||||
Reference in New Issue
Block a user