bugfix: 教育管理员编辑用户之后刷新列表
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
<div class="generalModel_btn">
|
||||
<div class="generalModel_closeIcon" @click.stop="cancelDsign()">
|
||||
<svg
|
||||
width="100%" height="100%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
viewBox="0 0 46 46"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@@ -49,7 +50,10 @@
|
||||
</div>
|
||||
<div class="allUserPoeration_center admin_page">
|
||||
<div class="admin_state_item">
|
||||
<span>{{ $t('admin.UserName') }}: <span>*</span></span>
|
||||
<span>
|
||||
{{ $t('admin.UserName') }}:
|
||||
<span>*</span>
|
||||
</span>
|
||||
<input
|
||||
v-model="userName"
|
||||
:placeholder="$t('admin.enterUserName')"
|
||||
@@ -58,7 +62,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="admin_state_item">
|
||||
<span>{{ $t('admin.UserEmail') }}: <span>*</span></span>
|
||||
<span>
|
||||
{{ $t('admin.UserEmail') }}:
|
||||
<span>*</span>
|
||||
</span>
|
||||
<input
|
||||
v-model="userEmail"
|
||||
:placeholder="$t('admin.enterEmail')"
|
||||
@@ -67,7 +74,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="admin_state_item">
|
||||
<span>{{ $t('admin.Password') }}: <span>*</span></span>
|
||||
<span>
|
||||
{{ $t('admin.Password') }}:
|
||||
<span>*</span>
|
||||
</span>
|
||||
<input
|
||||
@focus="focus"
|
||||
@blur="blur"
|
||||
@@ -87,7 +97,10 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="admin_state_item" v-if="title?.value == 'Edit'">
|
||||
<span>{{ $t('admin.SubscribePlan') }}: <span>*</span></span>
|
||||
<span>
|
||||
{{ $t('admin.SubscribePlan') }}:
|
||||
<span>*</span>
|
||||
</span>
|
||||
<a-select
|
||||
v-model:value="subscriptionPlanId"
|
||||
style="width: 250px"
|
||||
@@ -115,13 +128,13 @@ import {
|
||||
onMounted,
|
||||
nextTick,
|
||||
toRefs,
|
||||
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";
|
||||
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'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
export default defineComponent({
|
||||
components: {},
|
||||
@@ -131,9 +144,9 @@ export default defineComponent({
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
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: {}
|
||||
})
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
:deep(.allUserPoeration_modal) {
|
||||
|
||||
@@ -171,7 +171,6 @@ import {
|
||||
computed,
|
||||
reactive,
|
||||
toRefs,
|
||||
onMounted,
|
||||
unref,
|
||||
watch
|
||||
} from 'vue'
|
||||
@@ -650,12 +649,35 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let historyTable: any = this.$refs.historyTable
|
||||
this.historyTableHeight = historyTable.clientHeight - 200
|
||||
this.updateTableHeight()
|
||||
window.addEventListener('resize', this.updateTableHeight)
|
||||
},
|
||||
beforeUnmount() {
|
||||
window.removeEventListener('resize', this.updateTableHeight)
|
||||
},
|
||||
methods: {
|
||||
updateTableHeight() {
|
||||
const historyTable: any = this.$refs.historyTable
|
||||
if (historyTable) {
|
||||
// 为底部分页器预留固定空间,使表格部分高度固定且分页器始终可见
|
||||
this.historyTableHeight = historyTable.clientHeight - 200
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.admin_page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
.admin_table_content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.admin_page .admin_table_search .admin_state {
|
||||
display: flex;
|
||||
width: 70%;
|
||||
|
||||
@@ -249,6 +249,7 @@
|
||||
value-format="X"
|
||||
style="width: 250px"
|
||||
:disabledDate="disabledDate"
|
||||
:show-time="{ format: 'HH:mm' }"
|
||||
class="range_picker"
|
||||
placeholder="Select the start time"
|
||||
>
|
||||
@@ -265,6 +266,8 @@
|
||||
<a-date-picker
|
||||
v-model:value="formState.currentPeriodEnd"
|
||||
value-format="X"
|
||||
:show-time="{ format: 'HH:mm' }"
|
||||
:disabledDate="disabledDate"
|
||||
style="width: 250px"
|
||||
class="range_picker"
|
||||
placeholder="Select the end time"
|
||||
|
||||
Reference in New Issue
Block a user