2025-04-16 10:43:54 +08:00
|
|
|
<template>
|
2025-06-18 21:47:27 +08:00
|
|
|
<div class="allUserPoerationModal" ref="allUserPoerationModal"></div>
|
|
|
|
|
<a-modal
|
|
|
|
|
class="allUserPoeration_modal generalModel"
|
|
|
|
|
v-model:visible="operationsModal"
|
|
|
|
|
:footer="null"
|
|
|
|
|
:get-container="() => $refs.allUserPoerationModal"
|
|
|
|
|
width="50%"
|
|
|
|
|
height="55rem"
|
|
|
|
|
:maskClosable="false"
|
|
|
|
|
:centered="true"
|
|
|
|
|
:closable="false"
|
|
|
|
|
:mask="true"
|
|
|
|
|
wrapClassName="#app"
|
|
|
|
|
:keyboard="false"
|
|
|
|
|
>
|
|
|
|
|
<div class="generalModel_btn">
|
|
|
|
|
<div class="generalModel_closeIcon" @click.stop="cancelDsign()">
|
|
|
|
|
<svg
|
2025-12-18 15:17:40 +08:00
|
|
|
width="100%"
|
|
|
|
|
height="100%"
|
2025-06-18 21:47:27 +08:00
|
|
|
viewBox="0 0 46 46"
|
|
|
|
|
fill="none"
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
>
|
2025-08-22 10:27:48 +08:00
|
|
|
<circle cx="23" cy="23" r="23" fill="black" fill-opacity="0.3" />
|
2025-06-18 21:47:27 +08:00
|
|
|
<rect
|
|
|
|
|
x="32.5063"
|
|
|
|
|
y="12"
|
|
|
|
|
width="3"
|
|
|
|
|
height="29"
|
|
|
|
|
rx="1.5"
|
|
|
|
|
transform="rotate(45 32.5063 12)"
|
|
|
|
|
fill="white"
|
|
|
|
|
/>
|
|
|
|
|
<rect
|
|
|
|
|
x="34.6274"
|
|
|
|
|
y="32.5059"
|
|
|
|
|
width="3"
|
|
|
|
|
height="29"
|
|
|
|
|
rx="1.5"
|
|
|
|
|
transform="rotate(135 34.6274 32.5059)"
|
|
|
|
|
fill="white"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal_title_text">
|
2025-09-08 14:50:59 +08:00
|
|
|
<div>{{ title.label }} {{ $t('admin.User') }}</div>
|
2025-06-18 21:47:27 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="allUserPoeration_center admin_page">
|
|
|
|
|
<div class="admin_state_item">
|
2025-12-18 15:17:40 +08:00
|
|
|
<span>
|
|
|
|
|
{{ $t('admin.UserName') }}:
|
|
|
|
|
<span>*</span>
|
|
|
|
|
</span>
|
2025-06-18 21:47:27 +08:00
|
|
|
<input
|
|
|
|
|
v-model="userName"
|
2025-09-08 14:50:59 +08:00
|
|
|
:placeholder="$t('admin.enterUserName')"
|
2025-06-18 21:47:27 +08:00
|
|
|
type="text"
|
|
|
|
|
style="width: 250px"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="admin_state_item">
|
2025-12-18 15:17:40 +08:00
|
|
|
<span>
|
|
|
|
|
{{ $t('admin.UserEmail') }}:
|
|
|
|
|
<span>*</span>
|
|
|
|
|
</span>
|
2025-06-18 21:47:27 +08:00
|
|
|
<input
|
|
|
|
|
v-model="userEmail"
|
2025-09-08 14:50:59 +08:00
|
|
|
:placeholder="$t('admin.enterEmail')"
|
2025-06-18 21:47:27 +08:00
|
|
|
type="text"
|
|
|
|
|
style="width: 250px"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="admin_state_item">
|
2025-12-18 15:17:40 +08:00
|
|
|
<span>
|
|
|
|
|
{{ $t('admin.Password') }}:
|
|
|
|
|
<span>*</span>
|
|
|
|
|
</span>
|
2025-06-18 21:47:27 +08:00
|
|
|
<input
|
|
|
|
|
@focus="focus"
|
|
|
|
|
@blur="blur"
|
|
|
|
|
v-model="password"
|
2025-09-08 14:50:59 +08:00
|
|
|
:placeholder="$t('admin.enterPassword')"
|
2025-06-18 21:47:27 +08:00
|
|
|
type="password"
|
|
|
|
|
style="width: 250px"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="admin_state_item">
|
2025-09-08 14:50:59 +08:00
|
|
|
<span>{{ $t('admin.MaximumCredits') }}:</span>
|
2025-06-18 21:47:27 +08:00
|
|
|
<input
|
|
|
|
|
v-model="credits"
|
2025-09-08 14:50:59 +08:00
|
|
|
:placeholder="$t('admin.enterCredits')"
|
2025-06-18 21:47:27 +08:00
|
|
|
type="text"
|
|
|
|
|
style="width: 250px"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-12-16 17:32:33 +08:00
|
|
|
<div class="admin_state_item" v-if="title?.value == 'Edit'">
|
2025-12-18 15:17:40 +08:00
|
|
|
<span>
|
|
|
|
|
{{ $t('admin.SubscribePlan') }}:
|
|
|
|
|
<span>*</span>
|
|
|
|
|
</span>
|
2025-12-16 17:32:33 +08:00
|
|
|
<a-select
|
|
|
|
|
v-model:value="subscriptionPlanId"
|
|
|
|
|
style="width: 250px"
|
2025-12-18 13:29:30 +08:00
|
|
|
:options="activePlanOptions"
|
2025-12-16 17:32:33 +08:00
|
|
|
:field-names="{ label: 'name', value: 'id' }"
|
|
|
|
|
:placeholder="$t('admin.SelectPlan')"
|
|
|
|
|
></a-select>
|
|
|
|
|
</div>
|
2025-06-18 21:47:27 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="allUserPoeration_btn admin_page">
|
2025-09-08 14:50:59 +08:00
|
|
|
<div class="admin_search_item" @click="cancelDsign">{{ $t('admin.Close') }}</div>
|
|
|
|
|
<div class="admin_search_item" @click="setOk">{{ $t('admin.OK') }}</div>
|
2025-06-18 21:47:27 +08:00
|
|
|
</div>
|
|
|
|
|
</a-modal>
|
|
|
|
|
<div class="mark_loading" v-show="loadingShow">
|
|
|
|
|
<a-spin size="large" />
|
|
|
|
|
</div>
|
2025-04-16 10:43:54 +08:00
|
|
|
</template>
|
2025-12-18 13:29:30 +08:00
|
|
|
<script lang="ts">
|
2025-06-18 21:47:27 +08:00
|
|
|
import {
|
|
|
|
|
defineComponent,
|
|
|
|
|
ref,
|
|
|
|
|
reactive,
|
|
|
|
|
watch,
|
|
|
|
|
onMounted,
|
|
|
|
|
nextTick,
|
|
|
|
|
toRefs,
|
2025-12-18 15:17:40 +08:00
|
|
|
computed
|
|
|
|
|
} from 'vue'
|
|
|
|
|
import { Https } from '@/tool/https'
|
|
|
|
|
import { Modal, message } from 'ant-design-vue'
|
|
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
|
|
|
|
import { formatTime, isEmail } from '@/tool/util'
|
|
|
|
|
import md5 from 'md5'
|
2025-09-10 16:33:40 +08:00
|
|
|
import { useI18n } from 'vue-i18n'
|
2025-04-16 10:43:54 +08:00
|
|
|
export default defineComponent({
|
2025-06-18 21:47:27 +08:00
|
|
|
components: {},
|
2025-12-16 17:32:33 +08:00
|
|
|
props: {
|
|
|
|
|
planOptions: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => []
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-12-18 15:17:40 +08:00
|
|
|
emits: ['searchHistoryList'],
|
2025-06-18 21:47:27 +08:00
|
|
|
setup(props, { emit }) {
|
2025-12-18 15:17:40 +08:00
|
|
|
const { t } = useI18n()
|
2025-12-16 17:32:33 +08:00
|
|
|
const { planOptions } = toRefs(props)
|
2025-12-18 13:29:30 +08:00
|
|
|
// 筛选出状态为 ACTIVE 的订阅计划
|
|
|
|
|
const activePlanOptions = computed(() => {
|
|
|
|
|
if (!planOptions.value || !Array.isArray(planOptions.value)) {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
return planOptions.value.filter((plan: any) => plan.status === 'ACTIVE')
|
|
|
|
|
})
|
2025-06-18 21:47:27 +08:00
|
|
|
let operations = reactive({
|
|
|
|
|
operationsModal: false,
|
|
|
|
|
operationsEdit: false,
|
|
|
|
|
loadingShow: false,
|
2025-12-18 15:17:40 +08:00
|
|
|
title: null
|
|
|
|
|
})
|
2025-06-18 21:47:27 +08:00
|
|
|
let operationsData = reactive({
|
|
|
|
|
accountId: -1,
|
2025-12-18 15:17:40 +08:00
|
|
|
userName: '',
|
|
|
|
|
userEmail: '',
|
|
|
|
|
password: '',
|
|
|
|
|
oldPassword: '',
|
|
|
|
|
credits: '',
|
|
|
|
|
subscriptionPlanId: '',
|
|
|
|
|
oldSubscriptionPlanId: ''
|
|
|
|
|
})
|
2025-06-18 21:47:27 +08:00
|
|
|
let state = ref([
|
|
|
|
|
{
|
2025-12-18 15:17:40 +08:00
|
|
|
label: 'visitor',
|
|
|
|
|
value: '0'
|
2025-06-18 21:47:27 +08:00
|
|
|
},
|
|
|
|
|
{
|
2025-12-18 15:17:40 +08:00
|
|
|
label: 'yearly',
|
|
|
|
|
value: '1'
|
2025-06-18 21:47:27 +08:00
|
|
|
},
|
|
|
|
|
{
|
2025-12-18 15:17:40 +08:00
|
|
|
label: 'monthly',
|
|
|
|
|
value: '2'
|
2025-06-18 21:47:27 +08:00
|
|
|
},
|
|
|
|
|
{
|
2025-12-18 15:17:40 +08:00
|
|
|
label: 'trial',
|
|
|
|
|
value: '3'
|
|
|
|
|
}
|
|
|
|
|
])
|
2025-06-18 21:47:27 +08:00
|
|
|
let init = (funStr, data) => {
|
2025-12-18 15:17:40 +08:00
|
|
|
operations.operationsModal = true
|
|
|
|
|
operations.operationsEdit = true
|
|
|
|
|
operations.title = funStr
|
|
|
|
|
if (funStr.value == 'Add') operations.operationsEdit = false
|
|
|
|
|
if (funStr.value == 'Edit') {
|
|
|
|
|
operationsData.accountId = data.id
|
|
|
|
|
operationsData.userName = data.userName
|
|
|
|
|
operationsData.userEmail = data.userEmail
|
|
|
|
|
operationsData.password = data.userPassword ? data.userPassword : null
|
|
|
|
|
operationsData.oldPassword = data.userPassword
|
2025-06-18 21:47:27 +08:00
|
|
|
// operationsData.validStartTime='2024-08-05T00:00:06'
|
|
|
|
|
// operationsData.validEndTime='2024-08-05T00:00:06'
|
2025-12-18 15:17:40 +08:00
|
|
|
operationsData.credits = data.creditsUsageLimit
|
|
|
|
|
operationsData.subscriptionPlanId = data.subscriptionPlanId || ''
|
|
|
|
|
operationsData.oldSubscriptionPlanId = data.subscriptionPlanId || ''
|
2025-06-18 21:47:27 +08:00
|
|
|
// operationsData.accountId = data.accountId
|
|
|
|
|
// operationsData.userName = data.userName
|
|
|
|
|
// operationsData.userEmail = data.userEmail
|
|
|
|
|
// operationsData.validStartTime = formatTime(data.validStartTime)
|
|
|
|
|
// operationsData.validEndTime = formatTime(data.validEndTime)
|
|
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
if (funStr.value == 'Add') {
|
|
|
|
|
operationsData.subscriptionPlanId = ''
|
|
|
|
|
operationsData.oldSubscriptionPlanId = ''
|
2025-12-16 17:32:33 +08:00
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
}
|
|
|
|
|
let focus = event => {
|
2025-06-18 21:47:27 +08:00
|
|
|
if (operationsData.password == operationsData.oldPassword) {
|
2025-12-18 15:17:40 +08:00
|
|
|
operationsData.password = ''
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
}
|
|
|
|
|
let blur = event => {
|
|
|
|
|
console.log(operationsData.password == '' && operationsData.oldPassword)
|
|
|
|
|
if (operationsData.password == '' && operationsData.oldPassword) {
|
|
|
|
|
operationsData.password = operationsData.oldPassword
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
}
|
2025-06-18 21:47:27 +08:00
|
|
|
let setAddData = () => {
|
|
|
|
|
return {
|
|
|
|
|
creditsUsageLimit: operationsData.credits,
|
|
|
|
|
userEmail: operationsData.userEmail,
|
2025-12-18 15:17:40 +08:00
|
|
|
userPassword: operationsData.password ? md5(operationsData.password + 'abc') : '',
|
2025-06-18 21:47:27 +08:00
|
|
|
userName: operationsData.userName,
|
2025-12-16 17:32:33 +08:00
|
|
|
subscriptionPlanId: operationsData.subscriptionPlanId
|
2025-12-18 15:17:40 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-06-18 21:47:27 +08:00
|
|
|
let setEditData = () => {
|
|
|
|
|
return {
|
|
|
|
|
id: operationsData.accountId,
|
|
|
|
|
creditsUsageLimit: operationsData.credits,
|
|
|
|
|
userName: operationsData.userName,
|
|
|
|
|
userEmail: operationsData.userEmail,
|
|
|
|
|
userPassword:
|
|
|
|
|
operationsData.password == operationsData.oldPassword
|
2025-09-01 14:03:30 +08:00
|
|
|
? null
|
2025-12-18 15:17:40 +08:00
|
|
|
: md5(operationsData.password + 'abc'),
|
2025-12-16 17:32:33 +08:00
|
|
|
subscriptionPlanId: operationsData.subscriptionPlanId
|
2025-12-18 15:17:40 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-06-18 21:47:27 +08:00
|
|
|
let cancelDsign = () => {
|
2025-12-18 15:17:40 +08:00
|
|
|
operationsData.accountId = -1
|
|
|
|
|
operationsData.userName = ''
|
|
|
|
|
operationsData.userEmail = ''
|
|
|
|
|
operationsData.password = ''
|
|
|
|
|
operationsData.credits = ''
|
|
|
|
|
operationsData.subscriptionPlanId = ''
|
|
|
|
|
operationsData.oldSubscriptionPlanId = ''
|
|
|
|
|
operations.operationsModal = false
|
|
|
|
|
}
|
2025-06-18 21:47:27 +08:00
|
|
|
let setOk = () => {
|
2025-12-18 15:17:40 +08:00
|
|
|
let data
|
|
|
|
|
if (operations.title?.value == 'Add') {
|
|
|
|
|
data = setAddData()
|
2025-06-18 21:47:27 +08:00
|
|
|
if (!isEmail(data.userEmail)) {
|
2025-12-18 15:17:40 +08:00
|
|
|
message.info(t('admin.jsContent1'))
|
|
|
|
|
return
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
if (!data.userName || !data.userEmail || !data.userPassword)
|
|
|
|
|
return message.warning(t('admin.jsContent2'))
|
|
|
|
|
Https.axiosPost(Https.httpUrls.addOrUpdateSubAccount, data).then(rv => {
|
|
|
|
|
if (rv) {
|
|
|
|
|
cancelDsign()
|
|
|
|
|
emit('searchHistoryList')
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
})
|
2025-06-18 21:47:27 +08:00
|
|
|
} else {
|
2025-12-18 15:17:40 +08:00
|
|
|
data = setEditData()
|
2025-06-18 21:47:27 +08:00
|
|
|
if (!isEmail(data.userEmail)) {
|
2025-12-18 15:17:40 +08:00
|
|
|
message.info('The email format is incorrect')
|
|
|
|
|
return
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
2025-12-16 17:32:33 +08:00
|
|
|
if (!data.userName || !data.userEmail || !data.subscriptionPlanId)
|
2025-12-18 15:17:40 +08:00
|
|
|
return message.warning('Please check the input box marked with *')
|
2025-12-16 17:32:33 +08:00
|
|
|
const needSwitchPlan =
|
|
|
|
|
operationsData.subscriptionPlanId &&
|
2025-12-18 15:17:40 +08:00
|
|
|
operationsData.subscriptionPlanId !== operationsData.oldSubscriptionPlanId
|
|
|
|
|
Https.axiosPost(Https.httpUrls.addOrUpdateSubAccount, data).then(async rv => {
|
|
|
|
|
if (rv) {
|
|
|
|
|
if (needSwitchPlan) {
|
|
|
|
|
await Https.axiosGet(Https.httpUrls.switchSubAccountSubscribePlan, {
|
|
|
|
|
params: {
|
|
|
|
|
targetSubscriptionPlanId: operationsData.subscriptionPlanId,
|
|
|
|
|
subAccId: operationsData.accountId
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
cancelDsign()
|
|
|
|
|
emit('searchHistoryList')
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
})
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
2025-12-18 15:17:40 +08:00
|
|
|
}
|
2025-06-18 21:47:27 +08:00
|
|
|
return {
|
|
|
|
|
...toRefs(operations),
|
|
|
|
|
...toRefs(operationsData),
|
|
|
|
|
state,
|
|
|
|
|
cancelDsign,
|
|
|
|
|
init,
|
|
|
|
|
focus,
|
|
|
|
|
blur,
|
|
|
|
|
setOk,
|
2025-12-16 17:32:33 +08:00
|
|
|
planOptions,
|
2025-12-18 13:29:30 +08:00
|
|
|
activePlanOptions
|
2025-12-18 15:17:40 +08:00
|
|
|
}
|
2025-06-18 21:47:27 +08:00
|
|
|
},
|
|
|
|
|
data() {
|
2025-12-18 15:17:40 +08:00
|
|
|
return {}
|
2025-06-18 21:47:27 +08:00
|
|
|
},
|
|
|
|
|
mounted() {},
|
2025-12-18 15:17:40 +08:00
|
|
|
methods: {}
|
|
|
|
|
})
|
2025-04-16 10:43:54 +08:00
|
|
|
</script>
|
|
|
|
|
<style lang="less" scoped>
|
2025-06-18 21:47:27 +08:00
|
|
|
:deep(.allUserPoeration_modal) {
|
|
|
|
|
.ant-modal-body {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
}
|
2025-04-16 10:43:54 +08:00
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.allUserPoeration_modal {
|
2025-06-18 21:47:27 +08:00
|
|
|
.closeIcon {
|
|
|
|
|
z-index: 2;
|
|
|
|
|
}
|
|
|
|
|
.allUserPoeration_btn {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
height: auto;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
padding: 1rem 0;
|
|
|
|
|
.admin_search_item {
|
|
|
|
|
margin-bottom: 0;
|
2025-04-16 10:43:54 +08:00
|
|
|
}
|
2025-06-18 21:47:27 +08:00
|
|
|
}
|
|
|
|
|
.allUserPoeration_center {
|
|
|
|
|
flex: 1;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
}
|
2025-04-16 10:43:54 +08:00
|
|
|
}
|
2025-06-18 21:47:27 +08:00
|
|
|
</style>
|