completepage: 🍻 债务追踪和部分bug修复

This commit is contained in:
Bunny 2024-11-16 23:57:50 +08:00
parent e4d81d0357
commit fe5a9c10e1
10 changed files with 181 additions and 143 deletions

View File

@ -0,0 +1,22 @@
import { http } from '@/api/service/request';
import type { BaseResult, ResultTable } from '@/api/service/types';
/** 债务追踪---获取债务追踪列表 */
export const fetchGetUserDebtTrackingList = (data: any) => {
return http.request<BaseResult<ResultTable>>('get', `debtTracking/noManage/getUserDebtTrackingList/${data.currentPage}/${data.pageSize}`, { params: data });
};
/** 债务追踪---添加债务追踪 */
export const fetchAddUserDebtTracking = (data: any) => {
return http.request<BaseResult<object>>('post', 'debtTracking/noManage/addUserDebtTracking', { data });
};
/** 债务追踪---更新债务追踪 */
export const fetchUpdateUserDebtTracking = (data: any) => {
return http.request<BaseResult<object>>('put', 'debtTracking/noManage/updateUserDebtTracking', { data });
};
/** 债务追踪---删除债务追踪 */
export const fetchDeleteUserDebtTracking = (data: any) => {
return http.request<BaseResult<object>>('delete', 'debtTracking/noManage/deleteUserDebtTracking', { data });
};

View File

@ -1,5 +1,5 @@
export default [
// 财务管理
// financial管理
{
path: '/financial-user',
name: 'FinancialUser',
@ -32,7 +32,7 @@ export default [
},
],
},
// 预算和储值
// budget和savingGoal
{
path: '/budget-saving-user',
name: 'BudgetSavingsUser',
@ -65,36 +65,37 @@ export default [
},
],
},
// // 账务管理
// {
// path: '/debtManagement',
// name: 'DebtManagement',
// redirect: '/debtManagement/debtRepaymentPlan',
// meta: {
// icon: 'arcticons:debtcalc',
// title: 'debtManagement',
// },
// children: [
// // 债务还款计划
// {
// path: '/debtManagement/debtRepaymentPlan',
// name: 'debtRepaymentPlan',
// component: () => import('@/views/financial/debtRepaymentPlan/index.vue'),
// meta: {
// icon: 'stash:plan-light',
// title: 'debtRepaymentPlan',
// },
// },
// // 债务追踪
// {
// path: '/debtManagement/debtTracking',
// name: 'debtTracking',
// component: () => import('@/views/financial/debtTracking/index.vue'),
// meta: {
// icon: 'ic:outline-spatial-tracking',
// title: 'debtTracking',
// },
// },
// ],
// },
// Debt管理
{
path: '/debt-user',
name: 'DebtManagementUser',
redirect: '/debt-user/debt-tracking',
meta: {
icon: 'arcticons:debtcalc',
title: 'debtManagement',
rank: 1,
},
children: [
// 债务还款计划
{
path: '/debt-user/debt-repayment-plan',
name: 'debtRepaymentPlanUser',
component: () => import('@/views/financial-user/debt/debt-repayment-plan/index.vue'),
meta: {
icon: 'stash:plan-light',
title: 'debtRepaymentPlan',
},
},
// 债务追踪
{
path: '/debt-user/debt-tracking',
name: 'debtTrackingUser',
component: () => import('@/views/financial-user/debt/debt-tracking/index.vue'),
meta: {
icon: 'ic:outline-spatial-tracking',
title: 'debtTracking',
},
},
],
},
] satisfies Array<RouteConfigsTable>;

View File

@ -0,0 +1,80 @@
import { defineStore } from 'pinia';
import { pageSizes } from '@/enums/baseConstant';
import { storeMessage } from '@/utils/message';
import { storePagination } from '@/store/useStorePagination';
import {
fetchAddUserDebtTracking,
fetchDeleteUserDebtTracking,
fetchGetUserDebtTrackingList,
fetchUpdateUserDebtTracking,
} from '@/api/v1/financialUser/debtTrackingUser';
/**
* Store
*/
export const useDebtTrackingUserStore = defineStore('debtTrackingUserStore', {
state() {
return {
// 债务追踪列表
datalist: [],
// 查询表单
form: {
// 债务人姓名
debtorName: undefined,
// 债务金额
debtAmount: undefined,
// 债务类型
debtType: undefined,
// 债务状态
debtStatus: undefined,
// 还款截止日期
dueDate: undefined,
},
// 分页查询结果
pagination: {
currentPage: 1,
pageSize: 30,
total: 1,
pageSizes,
},
// 加载
loading: false,
};
},
getters: {},
actions: {
/** 获取债务追踪 */
async getDebtTrackingList() {
// 整理请求参数
const data = { ...this.pagination, ...this.form };
delete data.pageSizes;
delete data.total;
delete data.background;
// 获取债务追踪列表
const result = await fetchGetUserDebtTrackingList(data);
// 公共页面函数hook
const pagination = storePagination.bind(this);
return pagination(result);
},
/** 添加债务追踪 */
async addDebtTracking(data: any) {
const result = await fetchAddUserDebtTracking(data);
return storeMessage(result);
},
/** 修改债务追踪 */
async updateDebtTracking(data: any) {
const result = await fetchUpdateUserDebtTracking(data);
return storeMessage(result);
},
/** 删除债务追踪 */
async deleteDebtTracking(data: any) {
const result = await fetchDeleteUserDebtTracking(data);
return storeMessage(result);
},
},
});

View File

@ -26,7 +26,6 @@ export function onAdd() {
width: '30%',
props: {
formInline: {
userId: undefined,
statusType: undefined,
savingGoalName: undefined,
amount: undefined,
@ -62,7 +61,6 @@ export function onUpdate(row: any) {
width: '30%',
props: {
formInline: {
userId: row.userId,
statusType: row.statusType,
savingGoalName: row.savingGoalName,
amount: row.amount,

View File

@ -1,17 +1,14 @@
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { ref } from 'vue';
import { FormInstance } from 'element-plus';
import { rules } from '@/views/financial/debt/debt-tracking/utils/columns';
import { FormProps } from '@/views/financial/debt/debt-tracking/utils/types';
import { rules } from '@/views/financial-user/debt/debt-tracking/utils/columns';
import { FormProps } from '@/views/financial-user/debt/debt-tracking/utils/types';
import { $t } from '@/plugins/i18n';
import { debtTracking, debtType } from '@/enums/bill/debtTracking';
import LoadingSvg from '@/assets/svg/loading.svg';
import { useAdminUserStore } from '@/store/system/adminUser';
const props = withDefaults(defineProps<FormProps>(), {
formInline: () => ({
//
userId: undefined,
//
debtorName: undefined,
//
@ -33,43 +30,11 @@ const userDataList = ref();
const loading = ref(false);
const adminUserStore = useAdminUserStore();
/** 搜索 */
const onSearchUserinfo = async (keyword: string) => {
loading.value = true;
userDataList.value = await adminUserStore.queryUser({ keyword });
loading.value = false;
};
onMounted(() => {
onSearchUserinfo();
});
defineExpose({ formRef });
</script>
<template>
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
<!-- 绑定的用户 -->
<el-form-item :label="$t('user')" prop="userId">
<el-select
v-model="form.userId"
:loading="loading"
:placeholder="$t('user')"
:remote-method="onSearchUserinfo"
clearable
filterable
remote
remote-show-suffix
>
<el-option v-for="item in userDataList" :key="item.id" :label="item.username" :value="item.id" />
<template #loading>
<el-icon class="is-loading">
<LoadingSvg />
</el-icon>
</template>
</el-select>
</el-form-item>
<!-- 债务人姓名 -->
<el-form-item :label="$t('debtorName')" prop="debtorName">
<el-input v-model="form.debtorName" :placeholder="$t('input') + $t('debtorName')" autocomplete="off" type="text" />

View File

@ -1,21 +1,20 @@
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { columns } from '@/views/financial/debt/debt-tracking/utils/columns';
import { columns } from '@/views/financial-user/debt/debt-tracking/utils/columns';
import PureTableBar from '@/components/TableBar/src/bar';
import AddFill from '@iconify-icons/ri/add-circle-line';
import PureTable from '@pureadmin/table';
import { deleteIds, onAdd, onDelete, onDeleteBatch, onSearch, onUpdate } from '@/views/financial/debt/debt-tracking/utils/hooks';
import { deleteIds, onAdd, onDelete, onDeleteBatch, onSearch, onUpdate } from '@/views/financial-user/debt/debt-tracking/utils/hooks';
import Delete from '@iconify-icons/ep/delete';
import EditPen from '@iconify-icons/ep/edit-pen';
import Refresh from '@iconify-icons/ep/refresh';
import { $t } from '@/plugins/i18n';
import { useDebtTrackingStore } from '@/store/financial/debtTracking';
import { useRenderIcon } from '@/components/CommonIcon/src/hooks';
import { FormInstance } from 'element-plus';
import { selectUserinfo } from '@/components/Table/Userinfo/columns';
import LoadingSvg from '@/assets/svg/loading.svg';
import { useAdminUserStore } from '@/store/system/adminUser';
import { debtTracking, debtType } from '@/enums/bill/debtTracking';
import { useDebtTrackingUserStore } from '@/store/financialUser/debtTrackingUser';
const tableRef = ref();
const formRef = ref();
@ -24,17 +23,17 @@ const userDataList = ref();
//
const loading = ref(false);
const adminUserStore = useAdminUserStore();
const debtTrackingStore = useDebtTrackingStore();
const debtTrackingUserStore = useDebtTrackingUserStore();
/** 当前页改变时 */
const onCurrentPageChange = async (value: number) => {
debtTrackingStore.pagination.currentPage = value;
debtTrackingUserStore.pagination.currentPage = value;
await onSearch();
};
/** 当分页发生变化 */
const onPageSizeChange = async (value: number) => {
debtTrackingStore.pagination.pageSize = value;
debtTrackingUserStore.pagination.pageSize = value;
await onSearch();
};
@ -50,13 +49,6 @@ const resetForm = async (formEl: FormInstance | undefined) => {
await onSearch();
};
/** 搜索 */
const onSearchUserinfo = async (keyword: string) => {
loading.value = true;
userDataList.value = await adminUserStore.queryUser({ keyword });
loading.value = false;
};
onMounted(() => {
onSearch();
});
@ -64,49 +56,35 @@ onMounted(() => {
<template>
<div class="main">
<el-form ref="formRef" :inline="true" :model="debtTrackingStore.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
<!-- 绑定的用户 -->
<el-form-item :label="$t('user')" prop="userId">
<el-select
v-model="debtTrackingStore.form.userId"
:loading="loading"
:placeholder="$t('user')"
:remote-method="onSearchUserinfo"
class="!w-[180px]"
clearable
filterable
remote
remote-show-suffix
>
<el-option v-for="item in userDataList" :key="item.id" :label="item.username" :value="item.id" />
<template #loading>
<el-icon class="is-loading">
<LoadingSvg />
</el-icon>
</template>
</el-select>
</el-form-item>
<el-form ref="formRef" :inline="true" :model="debtTrackingUserStore.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
<!-- 债务人姓名 -->
<el-form-item :label="$t('debtorName')" prop="debtorName">
<el-input v-model="debtTrackingStore.form.debtorName" :placeholder="`${$t('input')}${$t('debtorName')}`" class="!w-[180px]" clearable />
<el-input v-model="debtTrackingUserStore.form.debtorName" :placeholder="`${$t('input')}${$t('debtorName')}`" class="!w-[180px]" clearable />
</el-form-item>
<!-- 债务金额 -->
<el-form-item :label="$t('debtAmount')" prop="debtAmount">
<el-input v-model="debtTrackingStore.form.debtAmount" :placeholder="`${$t('input')}${$t('debtAmount')}`" class="!w-[180px]" clearable />
<el-input v-model="debtTrackingUserStore.form.debtAmount" :placeholder="`${$t('input')}${$t('debtAmount')}`" class="!w-[180px]" clearable />
</el-form-item>
<!-- 债务类型 -->
<el-form-item :label="$t('debtType')" prop="debtType">
<el-select v-model="debtTrackingStore.form.debtType" :placeholder="$t('debtType')" class="!w-[180px]" clearable filterable remote remote-show-suffix>
<el-select v-model="debtTrackingUserStore.form.debtType" :placeholder="$t('debtType')" class="!w-[180px]" clearable filterable remote remote-show-suffix>
<el-option v-for="item in debtType" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<!-- 债务状态 -->
<el-form-item :label="$t('debtStatus')" prop="debtStatus">
<el-select v-model="debtTrackingStore.form.debtStatus" :placeholder="$t('debtStatus')" class="!w-[180px]" clearable filterable remote remote-show-suffix>
<el-select
v-model="debtTrackingUserStore.form.debtStatus"
:placeholder="$t('debtStatus')"
class="!w-[180px]"
clearable
filterable
remote
remote-show-suffix
>
<el-option v-for="item in debtTracking" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
@ -114,19 +92,22 @@ onMounted(() => {
<!-- 还款截止日期 -->
<el-form-item :label="$t('dueDate')" prop="dueDate">
<el-date-picker
v-model="debtTrackingStore.form.dueDate"
v-model="debtTrackingUserStore.form.dueDate"
:end-placeholder="$t('endTime')"
:placeholder="$t('dueDate')"
:start-placeholder="$t('startTime')"
class="!w-[210px]"
time-format="YYYY-MM-DD"
type="daterange"
type="date"
value-format="YYYY-MM-DD"
/>
</el-form-item>
<!-- 搜索和重置 -->
<el-form-item>
<el-button :icon="useRenderIcon('ri:search-line')" :loading="debtTrackingStore.loading" type="primary" @click="onSearch"> {{ $t('search') }} </el-button>
<el-button :icon="useRenderIcon('ri:search-line')" :loading="debtTrackingUserStore.loading" type="primary" @click="onSearch">
{{ $t('search') }}
</el-button>
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> {{ $t('buttons.reset') }}</el-button>
</el-form-item>
</el-form>
@ -146,10 +127,10 @@ onMounted(() => {
ref="tableRef"
:adaptiveConfig="{ offsetBottom: 96 }"
:columns="dynamicColumns"
:data="debtTrackingStore.datalist"
:data="debtTrackingUserStore.datalist"
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
:loading="debtTrackingStore.loading"
:pagination="debtTrackingStore.pagination"
:loading="debtTrackingUserStore.loading"
:pagination="debtTrackingUserStore.pagination"
:size="size"
adaptive
align-whole="center"

View File

@ -41,17 +41,11 @@ export const columns: TableColumnList = [
},
{ label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 },
{ label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160 },
// 绑定的用户
{ label: $t('username'), prop: 'username', slot: 'username', width: 130 },
{ 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<FormRules>({
// 绑定的用户
userId: [{ required: true, message: `${$t('input')}${$t('userId')}`, trigger: 'blur' }],
// 债务人姓名
debtorName: [{ required: true, message: `${$t('input')}${$t('debtorName')}`, trigger: 'blur' }],
// 债务金额

View File

@ -1,22 +1,22 @@
import { addDialog } from '@/components/BaseDialog/index';
import DebtTrackingDialog from '@/views/financial/debt/debt-tracking/debt-tracking-dialog.vue';
import { useDebtTrackingStore } from '@/store/financial/debtTracking';
import DebtTrackingDialog from '@/views/financial-user/debt/debt-tracking/debt-tracking-dialog.vue';
import { h, ref } from 'vue';
import { message, messageBox } from '@/utils/message';
import type { FormItemProps } from '@/views/financial/debt/debt-tracking/utils/types';
import type { FormItemProps } from '@/views/financial-user/debt/debt-tracking/utils/types';
import { $t } from '@/plugins/i18n';
import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue';
import { useDebtTrackingUserStore } from '@/store/financialUser/debtTrackingUser';
export const formRef = ref();
// 删除ids
export const deleteIds = ref([]);
const debtTrackingStore = useDebtTrackingStore();
const debtTrackingUserStore = useDebtTrackingUserStore();
/** 搜索初始化债务追踪 */
export async function onSearch() {
debtTrackingStore.loading = true;
await debtTrackingStore.getDebtTrackingList();
debtTrackingStore.loading = false;
debtTrackingUserStore.loading = true;
await debtTrackingUserStore.getDebtTrackingList();
debtTrackingUserStore.loading = false;
}
/** 添加债务追踪 */
@ -26,7 +26,6 @@ export function onAdd() {
width: '30%',
props: {
formInline: {
userId: undefined,
debtorName: undefined,
debtAmount: undefined,
debtType: undefined,
@ -43,7 +42,7 @@ export function onAdd() {
formRef.value.formRef.validate(async (valid: any) => {
if (!valid) return;
const result = await debtTrackingStore.addDebtTracking(form);
const result = await debtTrackingUserStore.addDebtTracking(form);
if (!result) return;
done();
await onSearch();
@ -59,7 +58,6 @@ export function onUpdate(row: any) {
width: '30%',
props: {
formInline: {
userId: row.userId,
debtorName: row.debtorName,
debtAmount: row.debtAmount,
debtType: row.debtType,
@ -76,7 +74,7 @@ export function onUpdate(row: any) {
formRef.value.formRef.validate(async (valid: any) => {
if (!valid) return;
const result = await debtTrackingStore.updateDebtTracking({ ...form, id: row.id });
const result = await debtTrackingUserStore.updateDebtTracking({ ...form, id: row.id });
if (!result) return;
done();
await onSearch();
@ -99,7 +97,7 @@ export const onDelete = async (row: any) => {
if (!result) return;
// 删除数据
await debtTrackingStore.deleteDebtTracking([id]);
await debtTrackingUserStore.deleteDebtTracking([id]);
await onSearch();
};
@ -123,7 +121,7 @@ export const onDeleteBatch = async () => {
const text = options.props.formInline.confirmText.toLowerCase();
if (text === 'yes' || text === 'y') {
// 删除数据
await debtTrackingStore.deleteDebtTracking(ids);
await debtTrackingUserStore.deleteDebtTracking(ids);
await onSearch();
done();

View File

@ -1,7 +1,5 @@
// 添加或者修改表单元素
export interface FormItemProps {
// 绑定的用户
userId: number;
// 债务人姓名
debtorName: string;
// 债务金额

View File

@ -116,10 +116,11 @@ onMounted(() => {
<el-date-picker
v-model="debtTrackingStore.form.dueDate"
:end-placeholder="$t('endTime')"
:placeholder="$t('dueDate')"
:start-placeholder="$t('startTime')"
class="!w-[210px]"
time-format="YYYY-MM-DD"
type="daterange"
type="date"
value-format="YYYY-MM-DD"
/>
</el-form-item>