diff --git a/src/api/v1/financialUser/savingGoalUser.ts b/src/api/v1/financialUser/savingGoalUser.ts new file mode 100644 index 0000000..01ef2a9 --- /dev/null +++ b/src/api/v1/financialUser/savingGoalUser.ts @@ -0,0 +1,22 @@ +import { http } from '@/api/service/request'; +import type { BaseResult, ResultTable } from '@/api/service/types'; + +/** 用户储值---获取用户储值列表 */ +export const fetchGetUserSavingGoalList = (data: any) => { + return http.request>('get', `savingGoal/noManage/getUserSavingGoalList/${data.currentPage}/${data.pageSize}`, { params: data }); +}; + +/** 用户储值---添加用户储值 */ +export const fetchAddUserSavingGoal = (data: any) => { + return http.request>('post', 'savingGoal/noManage/adduserSavingGoal', { data }); +}; + +/** 用户储值---更新用户储值 */ +export const fetchUpdateUserSavingGoal = (data: any) => { + return http.request>('put', 'savingGoal/noManage/updateUserSavingGoal', { data }); +}; + +/** 用户储值---删除用户储值 */ +export const fetchDeleteUserSavingGoal = (data: any) => { + return http.request>('delete', 'savingGoal/noManage/deleteUserSavingGoal', { data }); +}; diff --git a/src/store/financial/savingGoal.ts b/src/store/financial/savingGoal.ts index 16e909f..585501c 100644 --- a/src/store/financial/savingGoal.ts +++ b/src/store/financial/savingGoal.ts @@ -41,11 +41,13 @@ export const useSavingGoalStore = defineStore('savingGoalStore', { this.form.startDuration = this.form.duration[0]; this.form.endDuration = this.form.duration[1]; } + // 整理请求参数 const data = { ...this.pagination, ...this.form }; delete data.pageSizes; delete data.total; delete data.background; + delete data.duration; // 获取用户储值列表 const result = await fetchGetSavingGoalList(data); diff --git a/src/store/financialUser/budgetCategoryUser.ts b/src/store/financialUser/budgetCategoryUser.ts index 178a6d8..e1e2f2d 100644 --- a/src/store/financialUser/budgetCategoryUser.ts +++ b/src/store/financialUser/budgetCategoryUser.ts @@ -13,7 +13,7 @@ import { getDefaultDateRange } from '@/utils/date'; /** * 预算分类表 Store */ -export const userBudgetCategoryUser = defineStore('budgetCategoryUserStore', { +export const userBudgetCategoryUserStore = defineStore('budgetCategoryUserStore', { state() { return { // 预算分类表列表 diff --git a/src/store/financialUser/savingGoalUser.ts b/src/store/financialUser/savingGoalUser.ts new file mode 100644 index 0000000..cdf50fa --- /dev/null +++ b/src/store/financialUser/savingGoalUser.ts @@ -0,0 +1,84 @@ +import { defineStore } from 'pinia'; +import { pageSizes } from '@/enums/baseConstant'; +import { storeMessage } from '@/utils/message'; +import { storePagination } from '@/store/useStorePagination'; +import { + fetchAddUserSavingGoal, + fetchDeleteUserSavingGoal, + fetchGetUserSavingGoalList, + fetchUpdateUserSavingGoal, +} from '@/api/v1/financialUser/savingGoalUser'; +import { getDefaultDateRange } from '@/utils/date'; + +/** + * 用户储值 Store + */ +export const useSavingGoalUserStore = defineStore('savingGoalUserStore', { + state() { + return { + // 用户储值列表 + datalist: [], + // 查询表单 + form: { + userId: undefined, // 绑定的用户id + statusType: undefined, // 完成状态 + savingGoalName: undefined, // 储值目标名称 + amount: undefined, // 目标金额 + duration: getDefaultDateRange(2, 30), // 目标时长 + startDuration: undefined, // 开始目标时长 + endDuration: undefined, // 结束目标时长 + }, + // 分页查询结果 + pagination: { + currentPage: 1, + pageSize: 30, + total: 1, + pageSizes, + }, + // 加载 + loading: false, + }; + }, + getters: {}, + actions: { + /** 获取用户储值 */ + async getSavingGoalList() { + if (this.form.duration) { + this.form.startDuration = this.form.duration[0]; + this.form.endDuration = this.form.duration[1]; + } + + // 整理请求参数 + const data = { ...this.pagination, ...this.form }; + delete data.pageSizes; + delete data.total; + delete data.background; + delete data.duration; + + // 获取用户储值列表 + const result = await fetchGetUserSavingGoalList(data); + + // 公共页面函数hook + const pagination = storePagination.bind(this); + return pagination(result); + }, + + /** 添加用户储值 */ + async addSavingGoal(data: any) { + const result = await fetchAddUserSavingGoal(data); + return storeMessage(result); + }, + + /** 修改用户储值 */ + async updateSavingGoal(data: any) { + const result = await fetchUpdateUserSavingGoal(data); + return storeMessage(result); + }, + + /** 删除用户储值 */ + async deleteSavingGoal(data: any) { + const result = await fetchDeleteUserSavingGoal(data); + return storeMessage(result); + }, + }, +}); diff --git a/src/views/financial-user/budget-saving/budget-category/index.vue b/src/views/financial-user/budget-saving/budget-category/index.vue index a0a1ccb..b369491 100644 --- a/src/views/financial-user/budget-saving/budget-category/index.vue +++ b/src/views/financial-user/budget-saving/budget-category/index.vue @@ -15,7 +15,7 @@ import { FormInstance } from 'element-plus'; import { useAdminUserStore } from '@/store/system/adminUser'; import { budget } from '@/enums/bill/budget'; import { handleTree } from '@pureadmin/utils'; -import { userBudgetCategoryUser } from '@/store/financialUser/budgetCategoryUser'; +import { userBudgetCategoryUserStore } from '@/store/financialUser/budgetCategoryUser'; import { getDefaultDateRange } from '@/utils/date'; const tableRef = ref(); @@ -25,7 +25,7 @@ const userDataList = ref(); // 搜索用户加载 const loading = ref(false); const adminUserStore = useAdminUserStore(); -const budgetCategoryStore = userBudgetCategoryUser(); +const budgetCategoryStore = userBudgetCategoryUserStore(); const datalist = computed(() => handleTree(budgetCategoryStore.datalist)); /** 当前页改变时 */ diff --git a/src/views/financial-user/budget-saving/budget-category/utils/hooks.ts b/src/views/financial-user/budget-saving/budget-category/utils/hooks.ts index 4bf2794..a65348c 100644 --- a/src/views/financial-user/budget-saving/budget-category/utils/hooks.ts +++ b/src/views/financial-user/budget-saving/budget-category/utils/hooks.ts @@ -5,12 +5,12 @@ import { message, messageBox } from '@/utils/message'; import type { FormItemProps } from '@/views/financial-user/budget-saving/budget-category/utils/types'; import { $t } from '@/plugins/i18n'; import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; -import { userBudgetCategoryUser } from '@/store/financialUser/budgetCategoryUser'; +import { userBudgetCategoryUserStore } from '@/store/financialUser/budgetCategoryUser'; export const formRef = ref(); // 删除ids export const deleteIds = ref([]); -const budgetCategoryStore = userBudgetCategoryUser(); +const budgetCategoryStore = userBudgetCategoryUserStore(); /** 搜索初始化预算分类表 */ export async function onSearch() { diff --git a/src/views/financial-user/budget-saving/saving-goal/index.vue b/src/views/financial-user/budget-saving/saving-goal/index.vue index 7fde39a..bb775c1 100644 --- a/src/views/financial-user/budget-saving/saving-goal/index.vue +++ b/src/views/financial-user/budget-saving/saving-goal/index.vue @@ -1,22 +1,22 @@