diff --git a/src/api/v1/financial/budgetCategory.ts b/src/api/v1/financial/budgetCategory.ts new file mode 100644 index 0000000..cd6dbff --- /dev/null +++ b/src/api/v1/financial/budgetCategory.ts @@ -0,0 +1,22 @@ +import { http } from '@/api/service/request'; +import type { BaseResult, ResultTable } from '@/api/service/types'; + +/** 预算分类表---获取预算分类表列表 */ +export const fetchGetBudgetCategoryList = (data: any) => { + return http.request>('get', `budgetCategory/getBudgetCategoryList/${data.currentPage}/${data.pageSize}`, { params: data }); +}; + +/** 预算分类表---添加预算分类表 */ +export const fetchAddBudgetCategory = (data: any) => { + return http.request>('post', 'budgetCategory/addBudgetCategory', { data }); +}; + +/** 预算分类表---更新预算分类表 */ +export const fetchUpdateBudgetCategory = (data: any) => { + return http.request>('put', 'budgetCategory/updateBudgetCategory', { data }); +}; + +/** 预算分类表---删除预算分类表 */ +export const fetchDeleteBudgetCategory = (data: any) => { + return http.request>('delete', 'budgetCategory/deleteBudgetCategory', { data }); +}; diff --git a/src/api/v1/financial/debtCollectionManagement.ts b/src/api/v1/financial/debtCollectionManagement.ts new file mode 100644 index 0000000..0e87b65 --- /dev/null +++ b/src/api/v1/financial/debtCollectionManagement.ts @@ -0,0 +1,24 @@ +import { http } from '@/api/service/request'; +import type { BaseResult, ResultTable } from '@/api/service/types'; + +/** 债务回收管理表---获取债务回收管理表列表 */ +export const fetchGetDebtCollectionManagementList = (data: any) => { + return http.request>('get', `debtCollectionManagement/getDebtCollectionManagementList/${data.currentPage}/${data.pageSize}`, { + params: data, + }); +}; + +/** 债务回收管理表---添加债务回收管理表 */ +export const fetchAddDebtCollectionManagement = (data: any) => { + return http.request>('post', 'debtCollectionManagement/addDebtCollectionManagement', { data }); +}; + +/** 债务回收管理表---更新债务回收管理表 */ +export const fetchUpdateDebtCollectionManagement = (data: any) => { + return http.request>('put', 'debtCollectionManagement/updateDebtCollectionManagement', { data }); +}; + +/** 债务回收管理表---删除债务回收管理表 */ +export const fetchDeleteDebtCollectionManagement = (data: any) => { + return http.request>('delete', 'debtCollectionManagement/deleteDebtCollectionManagement', { data }); +}; diff --git a/src/router/modules/bill.ts b/src/router/modules/bill.ts index 7dd7d67..8ee1634 100644 --- a/src/router/modules/bill.ts +++ b/src/router/modules/bill.ts @@ -28,6 +28,16 @@ export default { title: 'categoryUserManagement', }, }, + // 预算分类 + { + path: '/financial/budgetCategory', + name: 'budgetCategory', + component: () => import('@/views/financial/budgetCategory/index.vue'), + meta: { + icon: 'iconamoon:category', + title: 'budgetCategory', + }, + }, // 债务还款计划 { path: '/financial/debtRepaymentPlan', @@ -38,5 +48,15 @@ export default { title: 'debtRepaymentPlan', }, }, + // 债务回收管理 + { + path: '/financial/debtCollectionManagement', + name: 'debtRepaymentPlan', + component: () => import('@/views/financial/debtCollectionManagement/index.vue'), + meta: { + icon: 'iconamoon:category', + title: 'debtCollectionManagement', + }, + }, ], } satisfies RouteConfigsTable; diff --git a/src/store/financial/budgetCategory.ts b/src/store/financial/budgetCategory.ts new file mode 100644 index 0000000..93e7fc4 --- /dev/null +++ b/src/store/financial/budgetCategory.ts @@ -0,0 +1,79 @@ +import { defineStore } from 'pinia'; +import { fetchAddBudgetCategory, fetchDeleteBudgetCategory, fetchGetBudgetCategoryList, fetchUpdateBudgetCategory } from '@/api/v1/financial/budgetCategory'; +import { pageSizes } from '@/enums/baseConstant'; +import { storeMessage } from '@/utils/message'; +import { storePagination } from '@/store/useStorePagination'; + +/** + * 预算分类表 Store + */ +export const useBudgetCategoryStore = defineStore('budgetCategoryStore', { + state() { + return { + // 预算分类表列表 + datalist: [], + // 查询表单 + form: { + // 父级id + parentId: undefined, + // 绑定的用户id + userId: undefined, + // 分类名称 + categoryName: undefined, + // 预算名称 + budgetName: undefined, + // 完成状态 + statusType: undefined, + // 预算金额 + amount: undefined, + // 预算周期 + period: undefined, + }, + // 分页查询结果 + pagination: { + currentPage: 1, + pageSize: 30, + total: 1, + pageSizes, + }, + // 加载 + loading: false, + }; + }, + getters: {}, + actions: { + /** 获取预算分类表 */ + async getBudgetCategoryList() { + // 整理请求参数 + const data = { ...this.pagination, ...this.form }; + delete data.pageSizes; + delete data.total; + delete data.background; + + // 获取预算分类表列表 + const result = await fetchGetBudgetCategoryList(data); + + // 公共页面函数hook + const pagination = storePagination.bind(this); + return pagination(result); + }, + + /** 添加预算分类表 */ + async addBudgetCategory(data: any) { + const result = await fetchAddBudgetCategory(data); + return storeMessage(result); + }, + + /** 修改预算分类表 */ + async updateBudgetCategory(data: any) { + const result = await fetchUpdateBudgetCategory(data); + return storeMessage(result); + }, + + /** 删除预算分类表 */ + async deleteBudgetCategory(data: any) { + const result = await fetchDeleteBudgetCategory(data); + return storeMessage(result); + }, + }, +}); diff --git a/src/store/financial/debtCollectionManagement.ts b/src/store/financial/debtCollectionManagement.ts new file mode 100644 index 0000000..dae9c63 --- /dev/null +++ b/src/store/financial/debtCollectionManagement.ts @@ -0,0 +1,80 @@ +import { defineStore } from 'pinia'; +import { + fetchAddDebtCollectionManagement, + fetchDeleteDebtCollectionManagement, + fetchGetDebtCollectionManagementList, + fetchUpdateDebtCollectionManagement, +} from '@/api/v1/financial/debtCollectionManagement'; +import { pageSizes } from '@/enums/baseConstant'; +import { storeMessage } from '@/utils/message'; +import { storePagination } from '@/store/useStorePagination'; + +/** + * 债务回收管理表 Store + */ +export const useDebtCollectionManagementStore = defineStore('debtCollectionManagementStore', { + state() { + return { + // 债务回收管理表列表 + datalist: [], + // 查询表单 + form: { + // 债务ID + debtId: undefined, + // 回收日期 + recoveryDate: undefined, + // 回收金额 + recoveryAmount: undefined, + // 回收方式 + recoveryMethod: undefined, + // 备注 + notes: undefined, + }, + // 分页查询结果 + pagination: { + currentPage: 1, + pageSize: 30, + total: 1, + pageSizes, + }, + // 加载 + loading: false, + }; + }, + getters: {}, + actions: { + /** 获取债务回收管理表 */ + async getDebtCollectionManagementList() { + // 整理请求参数 + const data = { ...this.pagination, ...this.form }; + delete data.pageSizes; + delete data.total; + delete data.background; + + // 获取债务回收管理表列表 + const result = await fetchGetDebtCollectionManagementList(data); + + // 公共页面函数hook + const pagination = storePagination.bind(this); + return pagination(result); + }, + + /** 添加债务回收管理表 */ + async addDebtCollectionManagement(data: any) { + const result = await fetchAddDebtCollectionManagement(data); + return storeMessage(result); + }, + + /** 修改债务回收管理表 */ + async updateDebtCollectionManagement(data: any) { + const result = await fetchUpdateDebtCollectionManagement(data); + return storeMessage(result); + }, + + /** 删除债务回收管理表 */ + async deleteDebtCollectionManagement(data: any) { + const result = await fetchDeleteDebtCollectionManagement(data); + return storeMessage(result); + }, + }, +}); diff --git a/src/views/financial/budgetCategory/budget-category-dialog.vue b/src/views/financial/budgetCategory/budget-category-dialog.vue new file mode 100644 index 0000000..315de7c --- /dev/null +++ b/src/views/financial/budgetCategory/budget-category-dialog.vue @@ -0,0 +1,71 @@ + + + diff --git a/src/views/financial/budgetCategory/index.vue b/src/views/financial/budgetCategory/index.vue new file mode 100644 index 0000000..4f29d9e --- /dev/null +++ b/src/views/financial/budgetCategory/index.vue @@ -0,0 +1,152 @@ + + + diff --git a/src/views/financial/budgetCategory/utils/columns.ts b/src/views/financial/budgetCategory/utils/columns.ts new file mode 100644 index 0000000..47d03ae --- /dev/null +++ b/src/views/financial/budgetCategory/utils/columns.ts @@ -0,0 +1,46 @@ +import { reactive } from 'vue'; +import { $t } from '@/plugins/i18n'; +import type { FormRules } from 'element-plus'; + +// 表格列 +export const columns: TableColumnList = [ + { type: 'selection', align: 'left' }, + { type: 'index', index: (index: number) => index + 1, label: '序号', width: 60 }, + // 父级id + { label: $t('parentId'), prop: 'parentId' }, + // 绑定的用户id + { label: $t('userId'), prop: 'userId' }, + // 分类名称 + { label: $t('categoryName'), prop: 'categoryName' }, + // 预算名称 + { label: $t('budgetName'), prop: 'budgetName' }, + // 完成状态 + { label: $t('statusType'), prop: 'statusType' }, + // 预算金额 + { label: $t('amount'), prop: 'amount' }, + // 预算周期 + { label: $t('period'), prop: 'period' }, + { label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 }, + { label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160 }, + { label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 130 }, + { label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 130 }, + { label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' }, +]; + +// 添加规则 +export const rules = reactive({ + // 父级id + parentId: [{ required: true, message: `${$t('input')}${$t('parentId')}`, trigger: 'blur' }], + // 绑定的用户id + userId: [{ required: true, message: `${$t('input')}${$t('userId')}`, trigger: 'blur' }], + // 分类名称 + categoryName: [{ required: true, message: `${$t('input')}${$t('categoryName')}`, trigger: 'blur' }], + // 预算名称 + budgetName: [{ required: true, message: `${$t('input')}${$t('budgetName')}`, trigger: 'blur' }], + // 完成状态 + statusType: [{ required: true, message: `${$t('input')}${$t('statusType')}`, trigger: 'blur' }], + // 预算金额 + amount: [{ required: true, message: `${$t('input')}${$t('amount')}`, trigger: 'blur' }], + // 预算周期 + period: [{ required: true, message: `${$t('input')}${$t('period')}`, trigger: 'blur' }], +}); diff --git a/src/views/financial/budgetCategory/utils/hooks.ts b/src/views/financial/budgetCategory/utils/hooks.ts new file mode 100644 index 0000000..a1f1e49 --- /dev/null +++ b/src/views/financial/budgetCategory/utils/hooks.ts @@ -0,0 +1,136 @@ +import { addDialog } from '@/components/BaseDialog/index'; +import BudgetCategoryDialog from '@/views/financial/budgetCategory/budget-category-dialog.vue'; +import { useBudgetCategoryStore } from '@/store/financial/budgetCategory'; +import { h, ref } from 'vue'; +import { message, messageBox } from '@/utils/message'; +import type { FormItemProps } from '@/views/financial/budgetCategory/utils/types'; +import { $t } from '@/plugins/i18n'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; + +export const formRef = ref(); +// 删除ids +export const deleteIds = ref([]); +const budgetCategoryStore = useBudgetCategoryStore(); + +/** 搜索初始化预算分类表 */ +export async function onSearch() { + budgetCategoryStore.loading = true; + await budgetCategoryStore.getBudgetCategoryList(); + budgetCategoryStore.loading = false; +} + +/** 添加预算分类表 */ +export function onAdd() { + addDialog({ + title: `${$t('addNew')}${$t('budgetCategory')}`, + width: '30%', + props: { + formInline: { + parentId: undefined, + userId: undefined, + categoryName: undefined, + budgetName: undefined, + statusType: undefined, + amount: undefined, + period: undefined, + }, + }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(BudgetCategoryDialog, { ref: formRef }), + beforeSure: (done, { options }) => { + const form = options.props.formInline as FormItemProps; + formRef.value.formRef.validate(async (valid: any) => { + if (!valid) return; + + const result = await budgetCategoryStore.addBudgetCategory(form); + if (!result) return; + done(); + await onSearch(); + }); + }, + }); +} + +/** 更新预算分类表 */ +export function onUpdate(row: any) { + addDialog({ + title: `${$t('modify')}${$t('budgetCategory')}`, + width: '30%', + props: { + formInline: { + parentId: row.parentId, + userId: row.userId, + categoryName: row.categoryName, + budgetName: row.budgetName, + statusType: row.statusType, + amount: row.amount, + period: row.period, + }, + }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(BudgetCategoryDialog, { ref: formRef }), + beforeSure: (done, { options }) => { + const form = options.props.formInline as FormItemProps; + formRef.value.formRef.validate(async (valid: any) => { + if (!valid) return; + + const result = await budgetCategoryStore.updateBudgetCategory({ ...form, id: row.id }); + if (!result) return; + done(); + await onSearch(); + }); + }, + }); +} + +/** 删除预算分类表 */ +export const onDelete = async (row: any) => { + const id = row.id; + + // 是否确认删除 + const result = await messageBox({ + title: $t('confirmDelete'), + showMessage: false, + confirmMessage: undefined, + cancelMessage: $t('cancel_delete'), + }); + if (!result) return; + + // 删除数据 + await budgetCategoryStore.deleteBudgetCategory([id]); + await onSearch(); +}; + +/** 批量删除 */ +export const onDeleteBatch = async () => { + const ids = deleteIds.value; + const formDeletedBatchRef = ref(); + + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await budgetCategoryStore.deleteBudgetCategory(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, + }); +}; diff --git a/src/views/financial/budgetCategory/utils/types.ts b/src/views/financial/budgetCategory/utils/types.ts new file mode 100644 index 0000000..a1b35b5 --- /dev/null +++ b/src/views/financial/budgetCategory/utils/types.ts @@ -0,0 +1,22 @@ +// 添加或者修改表单元素 +export interface FormItemProps { + // 父级id + parentId: number; + // 绑定的用户id + userId: number; + // 分类名称 + categoryName: string; + // 预算名称 + budgetName: string; + // 完成状态 + statusType: string; + // 预算金额 + amount: any; + // 预算周期 + period: string; +} + +// 添加或修改表单Props +export interface FormProps { + formInline: FormItemProps; +} diff --git a/src/views/financial/debtCollectionManagement/debt-collection-management-dialog.vue b/src/views/financial/debtCollectionManagement/debt-collection-management-dialog.vue new file mode 100644 index 0000000..b8a2f39 --- /dev/null +++ b/src/views/financial/debtCollectionManagement/debt-collection-management-dialog.vue @@ -0,0 +1,56 @@ + + + diff --git a/src/views/financial/debtCollectionManagement/index.vue b/src/views/financial/debtCollectionManagement/index.vue new file mode 100644 index 0000000..ff95141 --- /dev/null +++ b/src/views/financial/debtCollectionManagement/index.vue @@ -0,0 +1,130 @@ + + + diff --git a/src/views/financial/debtCollectionManagement/utils/columns.ts b/src/views/financial/debtCollectionManagement/utils/columns.ts new file mode 100644 index 0000000..32a6896 --- /dev/null +++ b/src/views/financial/debtCollectionManagement/utils/columns.ts @@ -0,0 +1,36 @@ +import { reactive } from 'vue'; +import { $t } from '@/plugins/i18n'; +import type { FormRules } from 'element-plus'; + +// 表格列 +export const columns: TableColumnList = [ + { type: 'selection', align: 'left' }, + { type: 'index', index: (index: number) => index + 1, label: '序号', width: 60 }, + // 债务ID + { label: $t('debtId'), prop: 'debtId' }, + // 回收日期 + { label: $t('recoveryDate'), prop: 'recoveryDate' }, + // 回收金额 + { label: $t('recoveryAmount'), prop: 'recoveryAmount' }, + // 回收方式 + { label: $t('recoveryMethod'), prop: 'recoveryMethod' }, + // 备注 + { label: $t('notes'), prop: 'notes' }, + { label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 }, + { label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160 }, + { label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' }, +]; + +// 添加规则 +export const rules = reactive({ + // 债务ID + debtId: [{ required: true, message: `${$t('input')}${$t('debtId')}`, trigger: 'blur' }], + // 回收日期 + recoveryDate: [{ required: true, message: `${$t('input')}${$t('recoveryDate')}`, trigger: 'blur' }], + // 回收金额 + recoveryAmount: [{ required: true, message: `${$t('input')}${$t('recoveryAmount')}`, trigger: 'blur' }], + // 回收方式 + recoveryMethod: [{ required: true, message: `${$t('input')}${$t('recoveryMethod')}`, trigger: 'blur' }], + // 备注 + notes: [{ required: true, message: `${$t('input')}${$t('notes')}`, trigger: 'blur' }], +}); diff --git a/src/views/financial/debtCollectionManagement/utils/hooks.ts b/src/views/financial/debtCollectionManagement/utils/hooks.ts new file mode 100644 index 0000000..3bcce47 --- /dev/null +++ b/src/views/financial/debtCollectionManagement/utils/hooks.ts @@ -0,0 +1,132 @@ +import { addDialog } from '@/components/BaseDialog/index'; +import DebtCollectionManagementDialog from '@/views/financial/debtCollectionManagement/debt-collection-management-dialog.vue'; +import { useDebtCollectionManagementStore } from '@/store/financial/debtCollectionManagement'; +import { h, ref } from 'vue'; +import { message, messageBox } from '@/utils/message'; +import type { FormItemProps } from '@/views/financial/debtCollectionManagement/utils/types'; +import { $t } from '@/plugins/i18n'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; + +export const formRef = ref(); +// 删除ids +export const deleteIds = ref([]); +const debtCollectionManagementStore = useDebtCollectionManagementStore(); + +/** 搜索初始化债务回收管理表 */ +export async function onSearch() { + debtCollectionManagementStore.loading = true; + await debtCollectionManagementStore.getDebtCollectionManagementList(); + debtCollectionManagementStore.loading = false; +} + +/** 添加债务回收管理表 */ +export function onAdd() { + addDialog({ + title: `${$t('addNew')}${$t('debtCollectionManagement')}`, + width: '30%', + props: { + formInline: { + debtId: undefined, + recoveryDate: undefined, + recoveryAmount: undefined, + recoveryMethod: undefined, + notes: undefined, + }, + }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DebtCollectionManagementDialog, { ref: formRef }), + beforeSure: (done, { options }) => { + const form = options.props.formInline as FormItemProps; + formRef.value.formRef.validate(async (valid: any) => { + if (!valid) return; + + const result = await debtCollectionManagementStore.addDebtCollectionManagement(form); + if (!result) return; + done(); + await onSearch(); + }); + }, + }); +} + +/** 更新债务回收管理表 */ +export function onUpdate(row: any) { + addDialog({ + title: `${$t('modify')}${$t('debtCollectionManagement')}`, + width: '30%', + props: { + formInline: { + debtId: row.debtId, + recoveryDate: row.recoveryDate, + recoveryAmount: row.recoveryAmount, + recoveryMethod: row.recoveryMethod, + notes: row.notes, + }, + }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DebtCollectionManagementDialog, { ref: formRef }), + beforeSure: (done, { options }) => { + const form = options.props.formInline as FormItemProps; + formRef.value.formRef.validate(async (valid: any) => { + if (!valid) return; + + const result = await debtCollectionManagementStore.updateDebtCollectionManagement({ ...form, id: row.id }); + if (!result) return; + done(); + await onSearch(); + }); + }, + }); +} + +/** 删除债务回收管理表 */ +export const onDelete = async (row: any) => { + const id = row.id; + + // 是否确认删除 + const result = await messageBox({ + title: $t('confirmDelete'), + showMessage: false, + confirmMessage: undefined, + cancelMessage: $t('cancel_delete'), + }); + if (!result) return; + + // 删除数据 + await debtCollectionManagementStore.deleteDebtCollectionManagement([id]); + await onSearch(); +}; + +/** 批量删除 */ +export const onDeleteBatch = async () => { + const ids = deleteIds.value; + const formDeletedBatchRef = ref(); + + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await debtCollectionManagementStore.deleteDebtCollectionManagement(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, + }); +}; diff --git a/src/views/financial/debtCollectionManagement/utils/types.ts b/src/views/financial/debtCollectionManagement/utils/types.ts new file mode 100644 index 0000000..878a4b1 --- /dev/null +++ b/src/views/financial/debtCollectionManagement/utils/types.ts @@ -0,0 +1,18 @@ +// 添加或者修改表单元素 +export interface FormItemProps { + // 债务ID + debtId: number; + // 回收日期 + recoveryDate: any; + // 回收金额 + recoveryAmount: any; + // 回收方式 + recoveryMethod: string; + // 备注 + notes: string; +} + +// 添加或修改表单Props +export interface FormProps { + formInline: FormItemProps; +}