feat: 🚀 修改账单提醒

This commit is contained in:
Bunny 2024-12-19 13:27:20 +08:00
parent a1eb4acacd
commit 3bab8ae601
8 changed files with 125 additions and 140 deletions

View File

@ -114,6 +114,16 @@ export const fetchUploadAvatarByAdmin = (data: any) => {
return http.request<BaseResult<UserResult>>('put', 'user/uploadAvatarByAdmin', { data }, { headers: { 'Content-Type': 'multipart/form-data' } });
};
/** 用户管理---更新用户账单是否启用 */
export const fetchUpdateUserBillReportByLocalUser = (data: any) => {
return http.request<BaseResult<UserResult>>(
'put',
'user/noManage/updateUserBillReportByLocalUser',
{ data },
{ headers: { 'Content-Type': 'multipart/form-data' } },
);
};
/** 用户管理---强制用户下线 */
export const fetchForcedOffline = (data: any) => {
return http.request<BaseResult<UserResult>>('put', 'user/forcedOffline', { data });

View File

@ -10,6 +10,7 @@ import {
fetchQueryUser,
fetchUpdateAdminUser,
fetchUpdateAdminUserByLocalUser,
fetchUpdateUserBillReportByLocalUser,
fetchUpdateUserPasswordByAdmin,
fetchUpdateUserPasswordByLocalUser,
fetchUpdateUserStatusByAdmin,
@ -125,5 +126,11 @@ export const useAdminUserStore = defineStore('adminUserStore', {
const result = await fetchForcedOffline(data);
return storeMessage(result);
},
/** 更新用户周账单是否启用 */
async updateUserBillReportByLocalUser(data: any) {
const result = await fetchUpdateUserBillReportByLocalUser(data);
return storeMessage(result);
},
},
});

View File

@ -7,26 +7,16 @@ import { useAdminUserStore } from '@/store/system/adminUser';
import ResetPasswordDialog from '@/components/Table/ResetPasswords.vue';
import { removeToken } from '@/utils/auth';
import { useRouter } from 'vue-router';
import { switchLoadMapControl, usePublicHooks } from '@/views/hooks';
import { messageBox } from '@/utils/message';
import { usePublicHooks } from '@/views/hooks';
import { switchLoadMap, updateUserReportStatusByMouth, updateUserReportStatusByWeek, userInfos } from '@/views/account-settings/utils/hooks';
//
const { switchStyle } = usePublicHooks();
//
const switchLoadMap = ref({});
// Ref
const ruleFormByRestPasswordRef = ref();
const router = useRouter();
const adminUserStore = useAdminUserStore();
//
const { switchStyle } = usePublicHooks();
const ruleFormByRestPasswordRef = ref();
const restPasswordForm = reactive({
password: '',
});
//
const reminderStatus = reactive({
week: false, //
mouth: false, //
});
/** 重置密码 */
const onResetPassword = () => {
@ -55,74 +45,6 @@ const onResetPassword = () => {
},
});
};
/** 更新用户周账单提醒是否开启 */
const updateUserReportStatusByWeek = async (index: number) => {
// loading
switchLoadMapControl(switchLoadMap, index, true);
//
const confirm = await messageBox({
title: $t('confirm_update_status'),
showMessage: false,
confirmMessage: undefined,
cancelMessage: $t('cancel'),
});
//
if (!confirm) {
reminderStatus.week = !reminderStatus.week;
switchLoadMapControl(switchLoadMap, index, false);
return;
}
//
// const data = { userId: row.id, status: row.status };
// const result = await adminUserStore.updateUserStatusByAdmin(data);
// if (!result) {
// row.status = !row.status;
// switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
// loading: false,
// });
// return;
// }
// await onSearch();
switchLoadMapControl(switchLoadMap, index, false);
};
/** 更新用户周账单提醒是否开启 */
const updateUserReportStatusByMouth = async (index: number) => {
// loading
switchLoadMapControl(switchLoadMap, index, true);
//
const confirm = await messageBox({
title: $t('confirm_update_status'),
showMessage: false,
confirmMessage: undefined,
cancelMessage: $t('cancel'),
});
//
if (!confirm) {
reminderStatus.week = !reminderStatus.week;
switchLoadMapControl(switchLoadMap, index, false);
return;
}
//
// const data = { userId: row.id, status: row.status };
// const result = await adminUserStore.updateUserStatusByAdmin(data);
// if (!result) {
// row.status = !row.status;
// switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
// loading: false,
// });
// return;
// }
// await onSearch();
switchLoadMapControl(switchLoadMap, index, false);
};
</script>
<template>
@ -146,16 +68,18 @@ const updateUserReportStatusByMouth = async (index: number) => {
<el-text class="mx-1" type="info">是否开启周账单提醒(需要保证有邮箱)</el-text>
</div>
<el-switch
v-model="reminderStatus.week"
v-model="userInfos.weekBillReport"
:active-text="$t('enable')"
:active-value="false"
:active-value="true"
:inactive-text="$t('disable')"
:inactive-value="true"
:inactive-value="false"
:loading="switchLoadMap[0]?.loading"
:style="switchStyle"
inline-prompt
@click="updateUserReportStatusByWeek(0)"
/>
<el-divider direction="vertical" />
<el-link :underline="false" type="primary" @click="onResetPassword">接受测试</el-link>
</li>
<el-divider />
@ -166,16 +90,18 @@ const updateUserReportStatusByMouth = async (index: number) => {
<el-text class="mx-1" type="info">是否开启月账单提醒(需要保证有邮箱)</el-text>
</div>
<el-switch
v-model="reminderStatus.mouth"
v-model="userInfos.mouthBillReport"
:active-text="$t('enable')"
:active-value="false"
:active-value="true"
:inactive-text="$t('disable')"
:inactive-value="true"
:inactive-value="false"
:loading="switchLoadMap[1]?.loading"
:style="switchStyle"
inline-prompt
@click="updateUserReportStatusByMouth(1)"
/>
<el-divider direction="vertical" />
<el-link :underline="false" type="primary" @click="onResetPassword">接受测试</el-link>
</li>
<el-divider />
</ul>

View File

@ -2,17 +2,26 @@ import { useUserStore } from '@/store/system/user';
import { reactive, ref } from 'vue';
import { createFormData } from '@pureadmin/utils';
import { fetchUploadFile } from '@/api/v1/system/system';
import { message } from '@/utils/message';
import { message, messageBox } from '@/utils/message';
import { $t } from '@/plugins/i18n';
import { switchLoadMapControl } from '@/views/hooks';
import { useAdminUserStore } from '@/store/system/adminUser';
// 剪裁完成后头像数据
export const cropperBlob = ref();
// 上传地址路径
export const uploadAvatarSrc = ref();
// 剪裁头像是否显示
export const isShow = ref(false);
// 用户是否停用加载集合
export const switchLoadMap = ref({});
// 用户仓库
const userStore = useUserStore();
const adminUserStore = useAdminUserStore();
// 用户信息内容
export const userInfos = reactive({
@ -24,20 +33,14 @@ export const userInfos = reactive({
summary: '',
password: '',
sex: '',
weekBillReport: undefined,
mouthBillReport: undefined,
});
/** 获取用户信息内容 */
export const onSearchByUserinfo = async () => {
const data = await userStore.getUserinfo();
userInfos.summary = data.personDescription;
userInfos.avatar = data.avatar;
userInfos.username = data.username;
userInfos.nickname = data.nickname;
userInfos.email = data.email;
userInfos.phone = data.phone;
userInfos.nickname = data.nickname;
userInfos.password = data.password;
userInfos.sex = data.sex;
Object.assign(userInfos, data);
};
/** 修改头像 */
@ -59,3 +62,66 @@ export const handleSubmitImage = async () => {
isShow.value = false;
}
};
/** 更新用户周账单提醒是否开启 */
export const updateUserReportStatusByWeek = async (index: number) => {
// 点击时开始loading加载
switchLoadMapControl(switchLoadMap, index, true);
// 是否确认修改弹窗内容
const confirm = await messageBox({
title: $t('confirm_update_status'),
showMessage: false,
confirmMessage: undefined,
cancelMessage: $t('cancel'),
});
// 如果不修改将值恢复到之前状态
if (!confirm) {
userInfos.weekBillReport = !userInfos.weekBillReport;
switchLoadMapControl(switchLoadMap, index, false);
return;
}
// 修改用户状态
const data = { type: 'week', status: userInfos.weekBillReport };
const result = await adminUserStore.updateUserBillReportByLocalUser(data);
if (!result) {
userInfos.weekBillReport = !userInfos.weekBillReport;
switchLoadMapControl(switchLoadMap, index, false);
return;
}
switchLoadMapControl(switchLoadMap, index, false);
};
/** 更新用户周账单提醒是否开启 */
export const updateUserReportStatusByMouth = async (index: number) => {
// 点击时开始loading加载
switchLoadMapControl(switchLoadMap, index, true);
// 是否确认修改弹窗内容
const confirm = await messageBox({
title: $t('confirm_update_status'),
showMessage: false,
confirmMessage: undefined,
cancelMessage: $t('cancel'),
});
// 如果不修改将值恢复到之前状态
if (!confirm) {
userInfos.mouthBillReport = !userInfos.mouthBillReport;
switchLoadMapControl(switchLoadMap, index, false);
return;
}
// 修改用户状态
const data = { type: 'mouth', status: userInfos.mouthBillReport };
const result = await adminUserStore.updateUserBillReportByLocalUser(data);
if (!result) {
userInfos.mouthBillReport = !userInfos.mouthBillReport;
switchLoadMapControl(switchLoadMap, index, false);
return;
}
switchLoadMapControl(switchLoadMap, index, false);
};

View File

@ -6,6 +6,7 @@ import { message, messageBox } from '@/utils/message';
import type { FormItemProps } from '@/views/configuration/emailUsers/utils/types';
import { $t } from '@/plugins/i18n';
import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue';
import { switchLoadMapControl } from '@/views/hooks';
export const formRef = ref();
// 用户是否停用加载集合
@ -145,9 +146,7 @@ export const onDeleteBatch = async () => {
*/
export const onChangeDefault = async (row: any, index: number) => {
// 点击时开始loading加载
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: true,
});
switchLoadMapControl(switchLoadMap, index, true);
// 是否确认修改弹窗内容
const confirm = await messageBox({
@ -160,9 +159,7 @@ export const onChangeDefault = async (row: any, index: number) => {
// 如果不修改将值恢复到之前状态
if (!confirm) {
row.isDefault = !row.isDefault;
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
return;
}
@ -170,14 +167,10 @@ export const onChangeDefault = async (row: any, index: number) => {
const result = await emailUsersStore.updateEmailUserStatus({ id: row.id, isDefault: row.isDefault });
if (!result) {
row.isDefault = !row.isDefault;
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
return;
}
await onSearch();
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
};

View File

@ -6,6 +6,7 @@ import { message, messageBox } from '@/utils/message';
import type { FormItemProps } from '@/views/financial/account-bill/category/utils/types';
import { $t } from '@/plugins/i18n';
import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue';
import { switchLoadMapControl } from '@/views/hooks';
export const formRef = ref();
// 删除ids
@ -131,9 +132,7 @@ export const onDeleteBatch = async () => {
/** 修改是否是系统内置字段 */
export const onUpdateIsBuiltin = async (row: any, index: number) => {
// 点击时开始loading加载
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: true,
});
switchLoadMapControl(switchLoadMap, index, true);
// 是否确认修改显示状态
const confirm = await messageBox({
@ -146,9 +145,7 @@ export const onUpdateIsBuiltin = async (row: any, index: number) => {
// 取消修改
if (!confirm) {
row.isBuiltin = !row.isBuiltin;
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
return;
}
@ -162,7 +159,5 @@ export const onUpdateIsBuiltin = async (row: any, index: number) => {
await categoryStore.updateCategory(data);
await onSearch();
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
};

View File

@ -15,6 +15,7 @@ import { useUserStore } from '@/store/system/user';
import { useDeptStore } from '@/store/system/dept';
import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue';
import { UserAvatar } from '@/enums/baseConstant';
import { switchLoadMapControl } from '@/views/hooks';
const adminUserStore = useAdminUserStore();
const userStore = useUserStore();
@ -183,9 +184,7 @@ export const onDeleteBatch = async () => {
*/
export const updateUserStatus = async (row: any, index: number) => {
// 点击时开始loading加载
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: true,
});
switchLoadMapControl(switchLoadMap, index, true);
// 是否确认修改弹窗内容
const confirm = await messageBox({
@ -198,9 +197,7 @@ export const updateUserStatus = async (row: any, index: number) => {
// 如果不修改将值恢复到之前状态
if (!confirm) {
row.status = !row.status;
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
return;
}
@ -209,15 +206,11 @@ export const updateUserStatus = async (row: any, index: number) => {
const result = await adminUserStore.updateUserStatusByAdmin(data);
if (!result) {
row.status = !row.status;
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
return;
}
await onSearch();
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
};
/**

View File

@ -9,6 +9,7 @@ import AssignRouterToRole from '@/views/system/menu/assign-router-to-role.vue';
import { messageBox } from '@/utils/message';
import { formatHigherMenuOptions } from '@/views/system/menu/utils/columns';
import { ElText } from 'element-plus';
import { switchLoadMapControl } from '@/views/hooks';
// 用户是否停用加载集合
export const switchLoadMap = ref({});
@ -144,9 +145,7 @@ export const onDelete = async row => {
*/
export const onchangeVisible = async (row: any, index: number) => {
// 点击时开始loading加载
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: true,
});
switchLoadMapControl(switchLoadMap, index, true);
// 是否确认修改显示状态
const confirm = await messageBox({
@ -159,9 +158,7 @@ export const onchangeVisible = async (row: any, index: number) => {
// 取消修改
if (!confirm) {
row.visible = !row.visible;
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
return;
}
@ -177,9 +174,7 @@ export const onchangeVisible = async (row: any, index: number) => {
await routerStore.updateMenu(data);
await onSearch();
switchLoadMap.value[index] = Object.assign({}, switchLoadMap.value[index], {
loading: false,
});
switchLoadMapControl(switchLoadMap, index, false);
};
/**