diff --git a/src/component/Administrator/SE/allUser/addAllUser.vue b/src/component/Administrator/SE/allUser/addAllUser.vue index e7d934ba..91dce0ee 100644 --- a/src/component/Administrator/SE/allUser/addAllUser.vue +++ b/src/component/Administrator/SE/allUser/addAllUser.vue @@ -17,7 +17,8 @@
- {{ $t('admin.UserName') }}: * + + {{ $t('admin.UserName') }}: + * +
- {{ $t('admin.UserEmail') }}: * + + {{ $t('admin.UserEmail') }}: + * +
- {{ $t('admin.Password') }}: * + + {{ $t('admin.Password') }}: + * +
- {{ $t('admin.SubscribePlan') }}: * + + {{ $t('admin.SubscribePlan') }}: + * + [] } }, - emits: ["searchHistoryList"], + emits: ['searchHistoryList'], setup(props, { emit }) { - const {t} = useI18n() + const { t } = useI18n() const { planOptions } = toRefs(props) // 筛选出状态为 ACTIVE 的订阅计划 const activePlanOptions = computed(() => { @@ -146,83 +159,83 @@ export default defineComponent({ operationsModal: false, operationsEdit: false, loadingShow: false, - title: null, - }); + title: null + }) let operationsData = reactive({ accountId: -1, - userName: "", - userEmail: "", - password: "", - oldPassword: "", - credits: "", - subscriptionPlanId: "", - oldSubscriptionPlanId: "" - }); + userName: '', + userEmail: '', + password: '', + oldPassword: '', + credits: '', + subscriptionPlanId: '', + oldSubscriptionPlanId: '' + }) let state = ref([ { - label: "visitor", - value: "0", + label: 'visitor', + value: '0' }, { - label: "yearly", - value: "1", + label: 'yearly', + value: '1' }, { - label: "monthly", - value: "2", + label: 'monthly', + value: '2' }, { - label: "trial", - value: "3", - }, - ]); + label: 'trial', + value: '3' + } + ]) let init = (funStr, data) => { - 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; + 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 // operationsData.validStartTime='2024-08-05T00:00:06' // operationsData.validEndTime='2024-08-05T00:00:06' - operationsData.credits = data.creditsUsageLimit; - operationsData.subscriptionPlanId = data.subscriptionPlanId || ""; - operationsData.oldSubscriptionPlanId = data.subscriptionPlanId || ""; + operationsData.credits = data.creditsUsageLimit + operationsData.subscriptionPlanId = data.subscriptionPlanId || '' + operationsData.oldSubscriptionPlanId = data.subscriptionPlanId || '' // operationsData.accountId = data.accountId // operationsData.userName = data.userName // operationsData.userEmail = data.userEmail // operationsData.validStartTime = formatTime(data.validStartTime) // operationsData.validEndTime = formatTime(data.validEndTime) } - if (funStr.value == "Add") { - operationsData.subscriptionPlanId = ""; - operationsData.oldSubscriptionPlanId = ""; + if (funStr.value == 'Add') { + operationsData.subscriptionPlanId = '' + operationsData.oldSubscriptionPlanId = '' } - }; - let focus = (event) => { + } + let focus = event => { if (operationsData.password == operationsData.oldPassword) { - operationsData.password = ""; + operationsData.password = '' } - }; - let blur = (event) => { - console.log(operationsData.password == "" && operationsData.oldPassword); - if (operationsData.password == "" && operationsData.oldPassword) { - operationsData.password = operationsData.oldPassword; + } + let blur = event => { + console.log(operationsData.password == '' && operationsData.oldPassword) + if (operationsData.password == '' && operationsData.oldPassword) { + operationsData.password = operationsData.oldPassword } - }; + } let setAddData = () => { return { creditsUsageLimit: operationsData.credits, userEmail: operationsData.userEmail, - userPassword: operationsData.password?md5(operationsData.password + "abc"):'', + userPassword: operationsData.password ? md5(operationsData.password + 'abc') : '', userName: operationsData.userName, subscriptionPlanId: operationsData.subscriptionPlanId - }; - }; + } + } let setEditData = () => { return { id: operationsData.accountId, @@ -232,75 +245,63 @@ export default defineComponent({ userPassword: operationsData.password == operationsData.oldPassword ? null - : md5(operationsData.password + "abc"), + : md5(operationsData.password + 'abc'), subscriptionPlanId: operationsData.subscriptionPlanId - }; - }; + } + } let cancelDsign = () => { - operationsData.accountId = -1; - operationsData.userName = ""; - operationsData.userEmail = ""; - operationsData.password = ""; - operationsData.credits = ""; - operationsData.subscriptionPlanId = ""; - operationsData.oldSubscriptionPlanId = ""; - operations.operationsModal = false; - }; + operationsData.accountId = -1 + operationsData.userName = '' + operationsData.userEmail = '' + operationsData.password = '' + operationsData.credits = '' + operationsData.subscriptionPlanId = '' + operationsData.oldSubscriptionPlanId = '' + operations.operationsModal = false + } let setOk = () => { - let data; - if (operations.title?.value == "Add") { - data = setAddData(); + let data + if (operations.title?.value == 'Add') { + data = setAddData() if (!isEmail(data.userEmail)) { - message.info(t('admin.jsContent1')); - return; + message.info(t('admin.jsContent1')) + return } - 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"); - } + 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') } - ); + }) } else { - data = setEditData(); + data = setEditData() if (!isEmail(data.userEmail)) { - message.info("The email format is incorrect"); - return; + message.info('The email format is incorrect') + return } if (!data.userName || !data.userEmail || !data.subscriptionPlanId) - return message.warning("Please check the input box marked with *"); + return message.warning('Please check the input box marked with *') const needSwitchPlan = operationsData.subscriptionPlanId && - operationsData.subscriptionPlanId !== - operationsData.oldSubscriptionPlanId; - Https.axiosPost(Https.httpUrls.addOrUpdateSubAccount, data).then( - (rv) => { - if (rv) { - if (needSwitchPlan) { - Https.axiosGet( - Https.httpUrls.switchSubAccountSubscribePlan, - { - params: { - targetSubscriptionPlanId: operationsData.subscriptionPlanId, - subAccId: operationsData.accountId, - }, - } - ); - } - cancelDsign(); - emit("searchHistoryList"); + 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 + } + }) } + cancelDsign() + emit('searchHistoryList') } - ); + }) } - }; + } return { ...toRefs(operations), ...toRefs(operationsData), @@ -312,14 +313,14 @@ export default defineComponent({ setOk, planOptions, activePlanOptions - }; + } }, data() { - return {}; + return {} }, mounted() {}, - methods: {}, -}); + methods: {} +})