<template>
|
<InfiniteLoading
|
scrollViewClassName="life-page-infinite-scroll-list"
|
v-bind="infiniteLoadingProps"
|
>
|
<template #renderItem="{ item }">
|
<UserAccountCard
|
:title="TitleMap[item.lifePayType]"
|
:icon="TitleIconMap[item.lifePayType]"
|
:content="
|
item.lifePayType === LifeRechargeConstants.LifePayOrderTypeEnum.话费订单
|
? `${
|
BlLifeRecharge.constants.IspCodeText[
|
JSON.parse(item?.extraProperties)?.ispCode ?? ''
|
]
|
}-${item.content}`
|
: `${item.city}-${item.content}`
|
"
|
:remark="item.remark"
|
:style="{
|
marginBottom: Taro.pxTransform(32),
|
backgroundColor: '#ffffff',
|
}"
|
>
|
<template #action>
|
<div class="user-account-card-action" @click="handleEditUserAccount(item)">
|
<img :src="IconAccountEdit" class="user-account-card-action-icon" />
|
<span class="user-account-card-action-text">编辑</span>
|
</div>
|
<div class="user-account-card-action" @click="handleDeleteUserAccount(item)">
|
<img :src="IconAccountDelete" class="user-account-card-action-icon" />
|
<span class="user-account-card-action-text">删除</span>
|
</div>
|
</template>
|
</UserAccountCard>
|
</template>
|
</InfiniteLoading>
|
</template>
|
|
<script setup lang="ts">
|
import InfiniteLoading from '../../components/InfiniteLoading/InfiniteLoading.vue';
|
import {
|
BlLifeRecharge,
|
useLifeRechargeContext,
|
QueryUserAccountListInput,
|
LifeRechargeConstants,
|
UserAccountListOutput,
|
} from '@life-payment/core-vue';
|
import { useInfiniteLoading } from '../../hooks/infiniteLoading';
|
import { OrderInputType } from '../../constants';
|
import UserAccountCard from '../../components/Card/UserAccountCard.vue';
|
import IconAccountDelete from '../../assets/account/icon-account-delete.png';
|
import IconAccountEdit from '../../assets/account/icon-account-edit.png';
|
import { OssAssets } from '../../constants';
|
import Taro from '@tarojs/taro';
|
|
defineOptions({
|
name: 'UserAccountListView',
|
});
|
|
const emit = defineEmits<{
|
(e: 'goEdit', row: UserAccountListOutput): void;
|
}>();
|
|
const { blLifeRecharge } = useLifeRechargeContext();
|
|
const TitleMap = {
|
[LifeRechargeConstants.LifePayOrderTypeEnum.话费订单]: '话费',
|
[LifeRechargeConstants.LifePayOrderTypeEnum.电费订单]: '电费',
|
[LifeRechargeConstants.LifePayOrderTypeEnum.燃气订单]: '燃气费',
|
};
|
|
const TitleIconMap = {
|
[LifeRechargeConstants.LifePayOrderTypeEnum.话费订单]: OssAssets.accountCard.Phone,
|
[LifeRechargeConstants.LifePayOrderTypeEnum.电费订单]: OssAssets.accountCard.Electric,
|
[LifeRechargeConstants.LifePayOrderTypeEnum.燃气订单]: OssAssets.accountCard.Gas,
|
};
|
|
const { infiniteLoadingProps, invalidateQueries } = useInfiniteLoading(
|
({ pageParam }) => {
|
let params: QueryUserAccountListInput = {
|
pageModel: {
|
rows: 20,
|
page: pageParam,
|
orderInput: [{ property: 'creationTime', order: OrderInputType.Desc }],
|
},
|
userId: blLifeRecharge.accountModel.userId,
|
};
|
|
return blLifeRecharge.services.getUserAccountList(params, {
|
showLoading: false,
|
});
|
},
|
{
|
queryKey: ['blLifeRecharge/getUserAccountList', blLifeRecharge.accountModel.userId],
|
}
|
);
|
|
function handleEditUserAccount(row: UserAccountListOutput) {
|
emit('goEdit', row);
|
}
|
|
async function handleDeleteUserAccount(row: UserAccountListOutput) {
|
try {
|
const res = await Taro.showModal({
|
title: '提示',
|
content: '确定要删除该数据吗?',
|
confirmColor: '#028CFF',
|
});
|
if (res.confirm) {
|
await blLifeRecharge.services.deleteUserAccount({
|
id: row.id,
|
});
|
invalidateQueries();
|
}
|
} catch (error) {}
|
}
|
</script>
|