feat(recycle): update order recycle page
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@
|
|||||||
"less": "^4.3.0",
|
"less": "^4.3.0",
|
||||||
"pinia": "^3.0.2",
|
"pinia": "^3.0.2",
|
||||||
"tdesign-mobile-vue": "^1.17.1",
|
"tdesign-mobile-vue": "^1.17.1",
|
||||||
"timi-tdesign-mobile": "^1.4.0",
|
"timi-tdesign-mobile": "^1.5.0",
|
||||||
"timi-ts": "^1.0.0",
|
"timi-ts": "^1.0.0",
|
||||||
"timi-web": "^1.0.2",
|
"timi-web": "^1.0.2",
|
||||||
"timi-web-api": "^1.0.2",
|
"timi-web-api": "^1.0.2",
|
||||||
|
|||||||
Generated
+5
-5
@@ -44,8 +44,8 @@ importers:
|
|||||||
specifier: ^1.17.1
|
specifier: ^1.17.1
|
||||||
version: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
version: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
||||||
timi-tdesign-mobile:
|
timi-tdesign-mobile:
|
||||||
specifier: ^1.4.0
|
specifier: ^1.5.0
|
||||||
version: 1.4.0(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3))
|
version: 1.5.0(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3))
|
||||||
timi-ts:
|
timi-ts:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
@@ -2742,8 +2742,8 @@ packages:
|
|||||||
through2@4.0.2:
|
through2@4.0.2:
|
||||||
resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==}
|
resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==}
|
||||||
|
|
||||||
timi-tdesign-mobile@1.4.0:
|
timi-tdesign-mobile@1.5.0:
|
||||||
resolution: {integrity: sha512-d7HQIW0MqXjPv8hkNWwBlv9UviXesvEG42z7qNemJcSOWSUVg1b59O+DbuEajgmnJGeZ9DqMdbm+x0eHd9l11A==}
|
resolution: {integrity: sha512-zp5yGlZaiJsf4QuREbBK7qjqQNteAB7PtWWG98rwGPzEwou6Q/45nEc1CJq47BFsuxjCq+7XIhCFl3eX7GgN6w==}
|
||||||
engines: {node: '>=20.0.0'}
|
engines: {node: '>=20.0.0'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.5.0
|
vue: ^3.5.0
|
||||||
@@ -5836,7 +5836,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
readable-stream: 3.6.2
|
readable-stream: 3.6.2
|
||||||
|
|
||||||
timi-tdesign-mobile@1.4.0(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3)):
|
timi-tdesign-mobile@1.5.0(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
tdesign-mobile-vue: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
tdesign-mobile-vue: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
||||||
timi-web: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
timi-web: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
||||||
|
|||||||
+31
-9
@@ -26,6 +26,7 @@ import { getCurrentStoreId, withCurrentStoreId } from "@/utils/store";
|
|||||||
const CONFIG_URI = "/gao/recycle/config";
|
const CONFIG_URI = "/gao/recycle/config";
|
||||||
const EXCHANGE_URI = "/gao/recycle/exchange";
|
const EXCHANGE_URI = "/gao/recycle/exchange";
|
||||||
const ACCOUNT_URI = "/gao/recycle/account";
|
const ACCOUNT_URI = "/gao/recycle/account";
|
||||||
|
const LEDGER_URI = "/gao/recycle/ledger";
|
||||||
const PAYMENT_URI = "/gao/recycle/payment";
|
const PAYMENT_URI = "/gao/recycle/payment";
|
||||||
const STAT_URI = "/gao/recycle/stat";
|
const STAT_URI = "/gao/recycle/stat";
|
||||||
|
|
||||||
@@ -119,9 +120,11 @@ async function accountList(customerId: string): Promise<RecycleAccount[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 按客户分页查询有余额的回收物及全门店汇总。 */
|
/** 按客户分页查询有余额的回收物及全门店汇总。 */
|
||||||
async function accountCustomers(offset: number, limit: number, recycleItemId?: string, keyword?: string, customerIds?: string[]): Promise<RecycleCustomerAccountPage> {
|
async function accountCustomers(index: number, size: number, recycleItemId?: string, keyword?: string, customerIds?: string[]): Promise<RecycleCustomerAccountPage> {
|
||||||
return await axios.post(`${ACCOUNT_URI}/customers`, undefined, {
|
return await axios.post(`${ACCOUNT_URI}/customers`, {
|
||||||
params: { storeId: getCurrentStoreId() || undefined, offset, limit, recycleItemId: recycleItemId || undefined, keyword: keyword || undefined, customerIds: customerIds?.length ? customerIds.join(",") : undefined }
|
storeId: getCurrentStoreId() || undefined, index, size,
|
||||||
|
recycleItemId: recycleItemId || undefined, keyword: keyword || undefined,
|
||||||
|
customerIds: customerIds?.length ? customerIds : undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,11 +133,27 @@ async function accountItems(): Promise<RecycleItem[]> {
|
|||||||
return await axios.post(`${ACCOUNT_URI}/items`, undefined, { params: { storeId: getCurrentStoreId() || undefined } });
|
return await axios.post(`${ACCOUNT_URI}/items`, undefined, { params: { storeId: getCurrentStoreId() || undefined } });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 额度流水,服务端当前最多返回 100 条。 */
|
/** 分页查询回收物额度流水。 */
|
||||||
async function accountLedger(customerId: string): Promise<RecycleLedger[]> {
|
async function ledgerList(page: {
|
||||||
return await axios.post(`${ACCOUNT_URI}/ledger`, undefined, {
|
index: number; size: number; customerId?: string; recycleItemId?: string; keyword?: string;
|
||||||
params: { storeId: getCurrentStoreId() || undefined, customerId }
|
bizType?: string; beginAt?: number; endAt?: number;
|
||||||
});
|
}): Promise<RecyclePageResult<RecycleLedger>> {
|
||||||
|
return await axios.post(`${LEDGER_URI}/list`, { ...page, storeId: getCurrentStoreId() || undefined });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询回收物额度流水详情。 */
|
||||||
|
async function ledgerDetail(id: string): Promise<RecycleLedger> {
|
||||||
|
return await axios.post(`${LEDGER_URI}/detail`, undefined, { params: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询回收物支付详情。 */
|
||||||
|
async function paymentDetail(id: string): Promise<RecyclePayment> {
|
||||||
|
return await axios.post(`${PAYMENT_URI}/detail`, undefined, { params: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按客户分页查询额度流水。 */
|
||||||
|
async function accountLedger(customerId: string, index: number, size: number): Promise<RecyclePageResult<RecycleLedger>> {
|
||||||
|
return await ledgerList({ customerId, index, size });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,7 +162,7 @@ async function accountLedger(customerId: string): Promise<RecycleLedger[]> {
|
|||||||
* 减少不能超过可用额度;调整只动账面,不代表门店收到实物。
|
* 减少不能超过可用额度;调整只动账面,不代表门店收到实物。
|
||||||
*/
|
*/
|
||||||
async function accountAdjust(request: RecycleAccountAdjustRequest): Promise<void> {
|
async function accountAdjust(request: RecycleAccountAdjustRequest): Promise<void> {
|
||||||
await axios.post(`${ACCOUNT_URI}/adjust`, withCurrentStoreId(request));
|
await axios.post(`${LEDGER_URI}/adjust`, withCurrentStoreId(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 某 SKU 的回收物产出配置。 */
|
/** 某 SKU 的回收物产出配置。 */
|
||||||
@@ -260,6 +279,9 @@ export default {
|
|||||||
accountCustomers,
|
accountCustomers,
|
||||||
accountItems,
|
accountItems,
|
||||||
accountLedger,
|
accountLedger,
|
||||||
|
ledgerList,
|
||||||
|
ledgerDetail,
|
||||||
|
paymentDetail,
|
||||||
accountAdjust,
|
accountAdjust,
|
||||||
yieldList,
|
yieldList,
|
||||||
yieldProductList,
|
yieldProductList,
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ html.theme-dark body {
|
|||||||
--td-search-square-radius: 1rem;
|
--td-search-square-radius: 1rem;
|
||||||
|
|
||||||
top: -1rem;
|
top: -1rem;
|
||||||
margin: -1rem 0 1rem 0;
|
margin: -1rem 0 0 0;
|
||||||
padding: 1rem 1rem 0 1rem;
|
padding: 1rem 1rem 0 1rem;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
@@ -156,8 +156,11 @@ html.theme-dark body {
|
|||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
.t-pull-down-refresh__track {
|
.t-pull-down-refresh__track {
|
||||||
|
gap: 1rem;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
display: flex;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.has-dropdown-menu-navbar {
|
&.has-dropdown-menu-navbar {
|
||||||
|
|||||||
@@ -1,58 +1,105 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tui-page-layout tui-navbar customer-recycle-list">
|
<div class="tui-page-layout tui-navbar customer-recycle-list">
|
||||||
<t-navbar fixed :z-index="20" title="客户回收物" left-arrow @left-click="$router.back()" />
|
<t-navbar
|
||||||
<main v-can="permissionCodes.recycleAccount.read" class="tui-page-content scroll column">
|
fixed
|
||||||
<t-pull-down-refresh v-model="refreshing" class="pull-refresh" :refresh-timeout="30000" @refresh="reload"
|
:z-index="20"
|
||||||
@scrolltolower="loadMore">
|
title="客户回收物"
|
||||||
|
left-arrow
|
||||||
|
@left-click="$router.back()"
|
||||||
|
/>
|
||||||
|
<master-detail-page
|
||||||
|
v-can="permissionCodes.recycleAccount.read"
|
||||||
|
class="list"
|
||||||
|
:split="isWide"
|
||||||
|
:selected="!!selectedCustomerId"
|
||||||
|
:direction="paneDirection"
|
||||||
|
>
|
||||||
|
<template #master>
|
||||||
|
<t-pull-down-refresh
|
||||||
|
v-model="refreshing"
|
||||||
|
class="pull-refresh"
|
||||||
|
:refresh-timeout="30000"
|
||||||
|
@refresh="reload"
|
||||||
|
@scrolltolower="loadMore"
|
||||||
|
>
|
||||||
<div class="filters glass">
|
<div class="filters glass">
|
||||||
<t-input v-model.trim="keyword" type="search" borderless clearable placeholder="搜索客户姓名、拼音、编码">
|
<t-input v-model.trim="keyword" type="search" borderless clearable placeholder="搜索客户姓名、拼音、编码">
|
||||||
<template #suffix-icon>
|
<template #suffix-icon>
|
||||||
<t-button size="extra-small" theme="primary" variant="outline" :content="customerIds.length ? `已选 ${customerIds.length} 人` : '选择客户'" @click.stop="customerVisible = true" />
|
<t-button
|
||||||
|
size="extra-small"
|
||||||
|
theme="primary"
|
||||||
|
variant="outline"
|
||||||
|
:content="customerIds.length ? `已选 ${customerIds.length} 人` : '选择客户'"
|
||||||
|
@click.stop="customerVisible = true"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</t-input>
|
</t-input>
|
||||||
<t-dropdown-menu ref="filterMenuRef" class="menus">
|
<t-dropdown-menu ref="filterMenuRef" class="menus">
|
||||||
<t-dropdown-item :label="selectedName" :options="[]" @open="openItemPicker" />
|
<t-dropdown-item :label="selectedName" :options="[]" @open="openItemPicker" />
|
||||||
</t-dropdown-menu>
|
</t-dropdown-menu>
|
||||||
</div>
|
</div>
|
||||||
<t-cell-group theme="card">
|
<div class="list-wrap">
|
||||||
<t-cell title="汇总">
|
<t-cell-group theme="card">
|
||||||
<template v-if="selectedId" #note>
|
<t-cell title="汇总">
|
||||||
<t-button size="extra-small" variant="outline" content="清除" @click="clearItem" />
|
<template #note>
|
||||||
</template>
|
<t-button v-if="selectedId" size="extra-small" variant="outline" content="清除" @click="clearItem" />
|
||||||
<template #description>
|
<div class="tags">
|
||||||
<div class="tags">
|
<t-tag
|
||||||
<t-tag v-for="item in displayedTotals" :key="item.recycleItemId" theme="primary"
|
v-for="item in displayedTotals" :key="item.recycleItemId" theme="primary"
|
||||||
variant="light"
|
variant="light"
|
||||||
:content="accountText(item)" />
|
:content="accountText(item)"
|
||||||
<span v-if="!displayedTotals.length" v-text="loading ? '正在加载' : '暂无回收物'" />
|
/>
|
||||||
</div>
|
<span v-if="!displayedTotals.length" v-text="loading ? '正在加载' : '暂无回收物'" />
|
||||||
</template>
|
</div>
|
||||||
</t-cell>
|
</template>
|
||||||
</t-cell-group>
|
</t-cell>
|
||||||
<t-cell-group v-if="items.length" theme="card" class="fix-last-cell-line">
|
</t-cell-group>
|
||||||
<customer-cell v-for="row in items" :key="row.customer.id" :customer="row.customer" arrow hover
|
<t-cell-group v-if="items.length" theme="card" class="fix-last-cell-line">
|
||||||
@click="openCustomer(row.customer)">
|
<customer-cell
|
||||||
<template #description>
|
v-for="row in items"
|
||||||
<div class="tags">
|
:key="row.customer.id"
|
||||||
<t-tag v-for="account in row.accounts" :key="account.recycleItemId" theme="primary"
|
:customer="row.customer"
|
||||||
variant="light"
|
arrow
|
||||||
:content="accountText(account)" />
|
hover
|
||||||
</div>
|
@click="openCustomer(row.customer)"
|
||||||
</template>
|
>
|
||||||
</customer-cell>
|
<template #description>
|
||||||
</t-cell-group>
|
<div class="tags">
|
||||||
<center-tips v-else :content="loading ? '正在加载客户回收物' : '暂无客户回收物'" />
|
<t-tag
|
||||||
<center-tips v-if="items.length"
|
v-for="account in row.accounts"
|
||||||
:content="loading ? '正在加载' : noMore ? `共 ${total} 位客户` : '上拉加载更多'" />
|
:key="account.recycleItemId" theme="primary"
|
||||||
|
size="small"
|
||||||
|
variant="light"
|
||||||
|
:content="accountText(account)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</customer-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
<center-tips
|
||||||
|
v-else
|
||||||
|
:content="loading ? '正在加载客户回收物' : '暂无客户回收物'"
|
||||||
|
/>
|
||||||
|
<center-tips
|
||||||
|
v-if="items.length"
|
||||||
|
:content="loading ? '正在加载' : noMore ? `共 ${total} 位客户` : '上拉加载更多'"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</t-pull-down-refresh>
|
</t-pull-down-refresh>
|
||||||
</main>
|
</template>
|
||||||
|
<template #detail>
|
||||||
|
<recycle-account-page :key="selectedCustomerId" :initial-customer-id="selectedCustomerId" />
|
||||||
|
</template>
|
||||||
|
</master-detail-page>
|
||||||
<customer-selector v-model="customerIds" v-model:visible="customerVisible" :initial-keyword="keyword" selection-mode="multiple" />
|
<customer-selector v-model="customerIds" v-model:visible="customerVisible" :initial-keyword="keyword" selection-mode="multiple" />
|
||||||
<recycle-item-picker-popup v-model:visible="filterVisible" :selected-id="selectedId" account-items @select="selectItem" />
|
<recycle-item-picker-popup v-model:visible="filterVisible" :selected-id="selectedId" account-items @select="selectItem" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
||||||
import RecycleAPI from "@/api/RecycleAPI";
|
import RecycleAPI from "@/api/RecycleAPI";
|
||||||
|
import RecycleAccountPage from "@/pages/recycle/RecycleAccount.vue";
|
||||||
import RecycleItemPickerPopup from "@/pages/recycle/components/RecycleItemPickerPopup.vue";
|
import RecycleItemPickerPopup from "@/pages/recycle/components/RecycleItemPickerPopup.vue";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
import type { Customer } from "@/types/Customer";
|
import type { Customer } from "@/types/Customer";
|
||||||
@@ -63,7 +110,11 @@ import { permissionCodes } from "@/utils/permission";
|
|||||||
import { getRecycleQuantityText } from "@/utils/recycle";
|
import { getRecycleQuantityText } from "@/utils/recycle";
|
||||||
|
|
||||||
defineOptions({ name: "CustomerRecycleList" });
|
defineOptions({ name: "CustomerRecycleList" });
|
||||||
const router = useRouter();
|
const route = useRoute();
|
||||||
|
const { selectedId: selectedCustomerId, isWide, paneDirection, openDetail } = useMasterDetailPane({
|
||||||
|
path: "/management/customer-recycle-accounts",
|
||||||
|
detail: id => `/management/recycle-accounts?customerId=${encodeURIComponent(id)}&transitionDepth=${Number(route.meta.depth ?? 0) + 1}`
|
||||||
|
});
|
||||||
const items = ref<RecycleCustomerAccountPage["list"]>([]);
|
const items = ref<RecycleCustomerAccountPage["list"]>([]);
|
||||||
const totals = ref<RecycleAccount[]>([]);
|
const totals = ref<RecycleAccount[]>([]);
|
||||||
const selectedId = ref("");
|
const selectedId = ref("");
|
||||||
@@ -79,6 +130,7 @@ const refreshing = ref(false);
|
|||||||
const noMore = ref(false);
|
const noMore = ref(false);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
let version = 0;
|
let version = 0;
|
||||||
|
let pageIndex = 0;
|
||||||
const selectedName = computed(() => selectedItem.value?.name || "全部回收物");
|
const selectedName = computed(() => selectedItem.value?.name || "全部回收物");
|
||||||
const displayedTotals = computed(() => selectedId.value ? totals.value.filter(item => item.recycleItemId === selectedId.value) : totals.value);
|
const displayedTotals = computed(() => selectedId.value ? totals.value.filter(item => item.recycleItemId === selectedId.value) : totals.value);
|
||||||
|
|
||||||
@@ -89,15 +141,16 @@ function accountText(account: RecycleAccount): string {
|
|||||||
async function fetchPage(reset: boolean): Promise<void> {
|
async function fetchPage(reset: boolean): Promise<void> {
|
||||||
if (!reset && (loading.value || noMore.value)) return;
|
if (!reset && (loading.value || noMore.value)) return;
|
||||||
const token = reset ? ++version : version;
|
const token = reset ? ++version : version;
|
||||||
const offset = reset ? 0 : items.value.length;
|
const index = reset ? 0 : pageIndex;
|
||||||
if (reset) {
|
if (reset) {
|
||||||
items.value = [];
|
items.value = [];
|
||||||
noMore.value = false;
|
noMore.value = false;
|
||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const result = await RecycleAPI.accountCustomers(offset, 20, selectedId.value, keyword.value, customerIds.value);
|
const result = await RecycleAPI.accountCustomers(index, 20, selectedId.value, keyword.value, customerIds.value);
|
||||||
if (token !== version) return;
|
if (token !== version) return;
|
||||||
|
pageIndex = index + 1;
|
||||||
items.value = reset ? result.list : [...items.value, ...result.list];
|
items.value = reset ? result.list : [...items.value, ...result.list];
|
||||||
totals.value = result.totals;
|
totals.value = result.totals;
|
||||||
total.value = result.total;
|
total.value = result.total;
|
||||||
@@ -159,8 +212,8 @@ onUnmounted(() => {
|
|||||||
if (searchTimer) clearTimeout(searchTimer);
|
if (searchTimer) clearTimeout(searchTimer);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function openCustomer(customer: Customer): Promise<void> {
|
function openCustomer(customer: Customer): void {
|
||||||
if (customer.id) await router.push({ name: "RecycleAccount", query: { customerId: customer.id } });
|
if (customer.id) openDetail(customer.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
let wasDeactivated = false;
|
let wasDeactivated = false;
|
||||||
@@ -175,11 +228,18 @@ onActivated(async () => {
|
|||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.customer-recycle-list {
|
.customer-recycle-list {
|
||||||
.tags {
|
|
||||||
gap: .375rem;
|
.list-wrap {
|
||||||
|
gap: 1rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: .25rem 0;
|
flex-direction: column;
|
||||||
flex-wrap: wrap;
|
|
||||||
|
.tags {
|
||||||
|
gap: .375rem;
|
||||||
|
display: flex;
|
||||||
|
padding: .25rem 0;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</dropdown-menu-navbar>
|
</dropdown-menu-navbar>
|
||||||
<div class="list-wrap">
|
|
||||||
<t-cell-group v-if="isCustomDate || filteredSku" class="summary" theme="card">
|
<t-cell-group v-if="isCustomDate || filteredSku" class="summary" theme="card">
|
||||||
<template v-if="isCustomDate">
|
<template v-if="isCustomDate">
|
||||||
<t-cell
|
<t-cell
|
||||||
@@ -166,7 +165,6 @@
|
|||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<center-tips v-else :content="emptyText" />
|
<center-tips v-else :content="emptyText" />
|
||||||
<center-tips v-if="recordList.length" :content="loadStateText" />
|
<center-tips v-if="recordList.length" :content="loadStateText" />
|
||||||
</div>
|
|
||||||
</t-pull-down-refresh>
|
</t-pull-down-refresh>
|
||||||
</template>
|
</template>
|
||||||
<template #detail>
|
<template #detail>
|
||||||
@@ -211,7 +209,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { type DropdownValue } from "tdesign-mobile-vue";
|
import { type DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
||||||
import { TimeLabel, Time } from "timi-web";
|
import { Time, TimeLabel } from "timi-web";
|
||||||
import { UserAPI } from "timi-web-api";
|
import { UserAPI } from "timi-web-api";
|
||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
import ProductAPI from "@/api/ProductAPI";
|
import ProductAPI from "@/api/ProductAPI";
|
||||||
@@ -222,13 +220,27 @@ import type { ProductSkuSelectionValue } from "@/types/ProductSkuSelection";
|
|||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { getProductBaseUnitName, getProductPhotoURL, getProductQuantityText, getProductSkuSpecEntries, getProductTypeText, getStockOperationText } from "@/utils/product";
|
import {
|
||||||
|
getProductBaseUnitName,
|
||||||
|
getProductPhotoURL,
|
||||||
|
getProductQuantityText,
|
||||||
|
getProductSkuSpecEntries,
|
||||||
|
getProductTypeText,
|
||||||
|
getStockOperationText
|
||||||
|
} from "@/utils/product";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
import { buildFallbackAvatar } from "@/utils/avatar";
|
import { buildFallbackAvatar } from "@/utils/avatar";
|
||||||
|
|
||||||
import type { Product, ProductSelection, ProductSku, StockOperationType, StockRecord, StockRecordDirection } from "@/types/Product";
|
import type {
|
||||||
|
Product,
|
||||||
|
ProductSelection,
|
||||||
|
ProductSku,
|
||||||
|
StockOperationType,
|
||||||
|
StockRecord,
|
||||||
|
StockRecordDirection
|
||||||
|
} from "@/types/Product";
|
||||||
|
|
||||||
defineOptions({ name: "ProductStockRecordList" });
|
defineOptions({ name: "ProductStockRecordList" });
|
||||||
|
|
||||||
@@ -676,162 +688,153 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.product-stock-record-list {
|
.product-stock-record-list {
|
||||||
display: flex;
|
|
||||||
padding: var(--tui-nav-height) 0 1rem;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.list-wrap {
|
.summary {
|
||||||
gap: 1rem;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.summary {
|
:deep(.t-cell__title) {
|
||||||
|
flex: 0 0 4.5rem;
|
||||||
:deep(.t-cell__title) {
|
|
||||||
flex: 0 0 4.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.t-cell__note) {
|
|
||||||
flex: 1 1 0;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-align: right;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sku {
|
:deep(.t-cell__note) {
|
||||||
--td-tag-square-border-radius: .5rem;
|
flex: 1 1 0;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-align: right;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sku {
|
||||||
|
--td-tag-square-border-radius: .5rem;
|
||||||
|
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
:deep(.t-cell__title) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
width: 2rem;
|
||||||
|
height: 2rem;
|
||||||
|
border-radius: .5rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.list {
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
.item {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
min-width: 0;
|
||||||
:deep(.t-cell__title) {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
width: 2rem;
|
width: 3.5rem;
|
||||||
height: 2rem;
|
height: 3.5rem;
|
||||||
border-radius: .5rem !important;
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
width: 2.25rem;
|
||||||
|
height: 2.25rem;
|
||||||
|
display: inline-flex;
|
||||||
|
background: var(--td-bg-color-secondarycontainer);
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
|
gap: .25rem;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
font-size: .75rem;
|
||||||
|
align-items: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
.actor {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
color: var(--td-text-color-brand);
|
||||||
|
}
|
||||||
|
|
||||||
|
.operation {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
color: var(--operation-color, var(--td-text-color-secondary));
|
||||||
|
font-weight: 700;
|
||||||
|
|
||||||
|
&.initial-in {
|
||||||
|
--operation-color: #2563eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.manual-in {
|
||||||
|
--operation-color: #15803d;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.manual-out {
|
||||||
|
--operation-color: #c2410c;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.manual-revoke {
|
||||||
|
--operation-color: #be123c;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.order-reserve {
|
||||||
|
--operation-color: #7c3aed;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.order-release {
|
||||||
|
--operation-color: #0891b2;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.order-out {
|
||||||
|
--operation-color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.order-revoke {
|
||||||
|
--operation-color: #4f46e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.stocktake-gain {
|
||||||
|
--operation-color: #0f766e;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.stocktake-loss {
|
||||||
|
--operation-color: #a16207;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-name {
|
||||||
|
flex: 0 1 auto;
|
||||||
|
color: var(--td-text-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.quantity {
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
flex: 0 0 auto;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
gap: .5rem;
|
gap: .5rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
min-width: 0;
|
font-size: .75rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
justify-content: space-between;
|
||||||
}
|
|
||||||
|
|
||||||
.list {
|
.delta {
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
.item {
|
.value {
|
||||||
padding: 10px;
|
font-size: 1.25rem;
|
||||||
min-width: 0;
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 3.5rem;
|
|
||||||
height: 3.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
width: 2.25rem;
|
|
||||||
height: 2.25rem;
|
|
||||||
display: inline-flex;
|
|
||||||
background: var(--td-bg-color-secondarycontainer);
|
|
||||||
align-items: center;
|
|
||||||
border-radius: 50%;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
gap: .25rem;
|
|
||||||
min-width: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
font-size: .75rem;
|
|
||||||
align-items: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
.actor {
|
|
||||||
flex: 0 0 auto;
|
|
||||||
color: var(--td-text-color-brand);
|
|
||||||
}
|
|
||||||
|
|
||||||
.operation {
|
|
||||||
flex: 0 0 auto;
|
|
||||||
color: var(--operation-color, var(--td-text-color-secondary));
|
|
||||||
font-weight: 700;
|
|
||||||
|
|
||||||
&.initial-in {
|
|
||||||
--operation-color: #2563eb;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.manual-in {
|
|
||||||
--operation-color: #15803d;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.manual-out {
|
|
||||||
--operation-color: #c2410c;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.manual-revoke {
|
|
||||||
--operation-color: #be123c;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.order-reserve {
|
|
||||||
--operation-color: #7c3aed;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.order-release {
|
|
||||||
--operation-color: #0891b2;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.order-out {
|
|
||||||
--operation-color: #dc2626;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.order-revoke {
|
|
||||||
--operation-color: #4f46e5;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.stocktake-gain {
|
|
||||||
--operation-color: #0f766e;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.stocktake-loss {
|
|
||||||
--operation-color: #a16207;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.product-name {
|
|
||||||
flex: 0 1 auto;
|
|
||||||
color: var(--td-text-color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quantity {
|
|
||||||
color: var(--td-text-color-secondary);
|
|
||||||
flex: 0 0 auto;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
|
||||||
gap: .5rem;
|
|
||||||
display: flex;
|
|
||||||
font-size: .75rem;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.delta {
|
|
||||||
|
|
||||||
.value {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<customer-profile-card
|
<customer-profile-card
|
||||||
class="customer"
|
class="customer"
|
||||||
:customer="customer"
|
:customer="customer"
|
||||||
|
v-entrance-transition
|
||||||
/>
|
/>
|
||||||
<template v-if="customerId">
|
<template v-if="customerId">
|
||||||
<t-cell-group title="额度账户" theme="card" v-entrance-transition>
|
<t-cell-group title="额度账户" theme="card" v-entrance-transition>
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
</t-cell>
|
</t-cell>
|
||||||
<t-cell v-if="!accountList.length" title="暂无额度" :note="accountLoading ? '正在加载' : '该客户还没有回收物额度'" />
|
<t-cell v-if="!accountList.length" title="暂无额度" :note="accountLoading ? '正在加载' : '该客户还没有回收物额度'" />
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<t-cell-group theme="card">
|
<t-cell-group theme="card" v-entrance-transition>
|
||||||
<t-cell v-if="canAdjust" title="调整额度" arrow @click="adjustPopup?.open()" />
|
<t-cell v-if="canAdjust" title="调整额度" arrow @click="adjustPopup?.open()" />
|
||||||
<t-cell title="回收流水" arrow @click="openPayments" />
|
<t-cell title="回收流水" arrow @click="openPayments" />
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
@@ -127,7 +128,7 @@ async function openPayments(): Promise<void> {
|
|||||||
const queryDepth = Number(Array.isArray(route.query.transitionDepth) ? route.query.transitionDepth[0] : route.query.transitionDepth);
|
const queryDepth = Number(Array.isArray(route.query.transitionDepth) ? route.query.transitionDepth[0] : route.query.transitionDepth);
|
||||||
const currentDepth = route.query.transitionDepth && Number.isInteger(queryDepth) && 0 <= queryDepth && !(20 < queryDepth)
|
const currentDepth = route.query.transitionDepth && Number.isInteger(queryDepth) && 0 <= queryDepth && !(20 < queryDepth)
|
||||||
? queryDepth : Number(route.meta.depth ?? 0);
|
? queryDepth : Number(route.meta.depth ?? 0);
|
||||||
await router.push({ name: "RecyclePaymentAll", query: { customerId: customerId.value, transitionDepth: String(currentDepth + 1) } });
|
await router.push({ name: "RecycleLedgerList", query: { customerId: customerId.value, transitionDepth: String(currentDepth + 1) } });
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBack(): void {
|
function goBack(): void {
|
||||||
|
|||||||
@@ -0,0 +1,243 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tui-page-layout tui-navbar recycle-ledger-detail">
|
||||||
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="回收物流水详情"
|
||||||
|
left-arrow
|
||||||
|
@left-click="goBack"
|
||||||
|
/>
|
||||||
|
<main
|
||||||
|
v-can="permissionCodes.recycleAccount.read"
|
||||||
|
class="tui-page-content scroll column"
|
||||||
|
>
|
||||||
|
<t-loading v-if="loading" class="loading" size="32px" />
|
||||||
|
<template v-else-if="record">
|
||||||
|
<section class="head" v-entrance-transition>
|
||||||
|
<div class="eyebrow">客户回收物</div>
|
||||||
|
<h2 v-text="record.recycleName || '回收物'" />
|
||||||
|
<div class="meta">
|
||||||
|
<span v-text="record.customerName || record.customerCode || '未知客户'" />
|
||||||
|
<t-tag variant="light-outline" :content="getRecycleLedgerTypeText(record.bizType)" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<card-container description="额度变动信息" v-entrance-transition>
|
||||||
|
<div class="data">
|
||||||
|
<div class="card">
|
||||||
|
<span>余额变动</span>
|
||||||
|
<strong
|
||||||
|
:class="deltaClass(record.balanceDelta)"
|
||||||
|
v-text="deltaText(record.balanceDelta)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<span>预占变动</span>
|
||||||
|
<strong
|
||||||
|
:class="deltaClass(record.reservedDelta)"
|
||||||
|
v-text="deltaText(record.reservedDelta)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</card-container>
|
||||||
|
<t-cell-group title="额度快照" theme="card" v-entrance-transition>
|
||||||
|
<t-cell title="余额" :note="snapshot(record.balanceAfter, record.balanceDelta)" />
|
||||||
|
<t-cell title="预占" :note="snapshot(record.reservedAfter, record.reservedDelta)" />
|
||||||
|
</t-cell-group>
|
||||||
|
<t-cell-group title="流水信息" theme="card" v-entrance-transition>
|
||||||
|
<t-cell title="业务类型" :note="getRecycleLedgerTypeText(record.bizType)" />
|
||||||
|
<t-cell
|
||||||
|
v-if="record.customerId"
|
||||||
|
title="客户回收物账户"
|
||||||
|
note="查看账户"
|
||||||
|
arrow
|
||||||
|
@click="openAccount"
|
||||||
|
/>
|
||||||
|
<t-cell v-if="orderId" title="关联回收兑换单" note="查看订单详情" arrow @click="openOrder" />
|
||||||
|
<t-cell title="发生时间">
|
||||||
|
<template #note>
|
||||||
|
<time-label :timestamp="record.createdAt" underline />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell
|
||||||
|
title="操作人"
|
||||||
|
:note="record.operator?.nick || record.operator?.name || '未知操作人'"
|
||||||
|
/>
|
||||||
|
<t-cell v-if="record.reason" title="备注" :note="record.reason" />
|
||||||
|
</t-cell-group>
|
||||||
|
</template>
|
||||||
|
<t-empty v-else description="回收物流水不存在或加载失败" />
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
|
||||||
|
import { TimeLabel } from "timi-web";
|
||||||
|
import { useUserStore } from "timi-web-api";
|
||||||
|
import RecycleAPI from "@/api/RecycleAPI";
|
||||||
|
import { buildOrderPaneView } from "@/pages/salesOrder/component/orderPane";
|
||||||
|
import type { RecycleLedger } from "@/types/Recycle";
|
||||||
|
import { getErrorMessage } from "@/utils/error";
|
||||||
|
import { Message } from "@/utils/message";
|
||||||
|
import { permissionCodes } from "@/utils/permission";
|
||||||
|
import { getRecycleLedgerTypeText, getRecycleQuantityText } from "@/utils/recycle";
|
||||||
|
|
||||||
|
defineOptions({ name: "RecycleLedgerDetail" });
|
||||||
|
const props = withDefaults(defineProps<{ recordId?: string }>(), { recordId: "" });
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
const pane = usePane();
|
||||||
|
const resolveId = (): string => props.recordId || String(route.params.id || "");
|
||||||
|
useExpandToMaster({
|
||||||
|
path: "/product/recycle-payments",
|
||||||
|
id: resolveId,
|
||||||
|
query: {
|
||||||
|
...(typeof route.query.customerId === "string" ? { customerId: route.query.customerId } : {}),
|
||||||
|
...(typeof route.query.transitionDepth === "string" ? { transitionDepth: String(Math.max(0, Number(route.query.transitionDepth) - 1)) } : {})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function goBack(): void {
|
||||||
|
if (pane) pane.close();
|
||||||
|
else void router.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const record = ref<RecycleLedger>();
|
||||||
|
const orderId = ref("");
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
function deltaClass(value?: number | string): string {
|
||||||
|
const amount = Number(value || 0);
|
||||||
|
return 0 < amount ? "positive" : amount < 0 ? "negative" : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function deltaText(value?: number | string): string {
|
||||||
|
return `${0 < Number(value || 0) ? "+" : ""}${getRecycleQuantityText(value ?? 0, record.value?.recycleUnit)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function snapshot(after?: number | string, delta?: number | string): string {
|
||||||
|
if ((after === null || after === undefined) || (delta === null || delta === undefined)) return "-";
|
||||||
|
const before = (Number(after) - Number(delta)).toFixed(3);
|
||||||
|
return `${getRecycleQuantityText(before, record.value?.recycleUnit)} → ${getRecycleQuantityText(after, record.value?.recycleUnit)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openAccount(): Promise<void> {
|
||||||
|
if (!record.value?.customerId) return;
|
||||||
|
if (pane?.openSub(`recycle-account:${record.value.customerId}`)) return;
|
||||||
|
const depth = Number(route.query.transitionDepth || route.meta.depth || 0);
|
||||||
|
await router.push({
|
||||||
|
name: "RecycleAccount",
|
||||||
|
query: { customerId: record.value.customerId, transitionDepth: String(depth + 1) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openOrder(): Promise<void> {
|
||||||
|
if (!orderId.value) return;
|
||||||
|
if (pane?.openSub(buildOrderPaneView(orderId.value))) return;
|
||||||
|
const depth = Number(route.query.transitionDepth || route.meta.depth || 0);
|
||||||
|
await router.push({
|
||||||
|
name: "SalesOrderDetail",
|
||||||
|
params: { id: orderId.value },
|
||||||
|
query: { transitionDepth: String(depth + 1) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadData(): Promise<void> {
|
||||||
|
loading.value = true;
|
||||||
|
record.value = undefined;
|
||||||
|
orderId.value = "";
|
||||||
|
try {
|
||||||
|
const result = await RecycleAPI.ledgerDetail(resolveId());
|
||||||
|
record.value = result;
|
||||||
|
if (result.bizType?.startsWith("PAYMENT_") && result.bizId
|
||||||
|
&& userStore.hasPermissions(permissionCodes.fundRecord.read) && userStore.hasPermissions(permissionCodes.salesOrder.read)) {
|
||||||
|
try {
|
||||||
|
const payment = await RecycleAPI.paymentDetail(result.bizId);
|
||||||
|
orderId.value = payment.orderId || "";
|
||||||
|
} catch (error) {
|
||||||
|
Message.error(getErrorMessage(error, "关联订单加载失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Message.error(getErrorMessage(error, "回收物流水加载失败"));
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => await loadData());
|
||||||
|
watch(resolveId, async (id, previousId) => {
|
||||||
|
if (id && id !== previousId) await loadData();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.recycle-ledger-detail {
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
margin: 3rem auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.head {
|
||||||
|
margin: 0 1rem;
|
||||||
|
padding: 1rem;
|
||||||
|
background: var(--td-bg-color-container);
|
||||||
|
box-shadow: var(--td-shadow-1);
|
||||||
|
border-radius: 1rem;
|
||||||
|
|
||||||
|
.eyebrow {
|
||||||
|
color: var(--td-brand-color);
|
||||||
|
font-size: .75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: .5rem 0;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.data {
|
||||||
|
gap: .75rem;
|
||||||
|
display: grid;
|
||||||
|
padding: .75rem;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
|
||||||
|
.card {
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
padding: .75rem;
|
||||||
|
background: var(--td-bg-color-secondarycontainer);
|
||||||
|
border-radius: .75rem;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
font-size: .75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
word-break: break-all;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.positive {
|
||||||
|
color: var(--td-success-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.negative {
|
||||||
|
color: var(--td-error-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
@@ -0,0 +1,394 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tui-page-layout tui-navbar recycle-ledger-list">
|
||||||
|
<t-navbar fixed :z-index="20" title="回收物流水" left-arrow @left-click="$router.back()" />
|
||||||
|
<master-detail-page v-can="permissionCodes.recycleAccount.read" class="list" :split="isWide" :selected="!!selectedId" :direction="paneDirection" :sub="!!orderPane?.view">
|
||||||
|
<template #master>
|
||||||
|
<t-pull-down-refresh
|
||||||
|
v-model="refreshing"
|
||||||
|
class="pull-refresh"
|
||||||
|
:refresh-timeout="30000"
|
||||||
|
@refresh="reload"
|
||||||
|
@scrolltolower="loadMore"
|
||||||
|
>
|
||||||
|
<div class="filters glass">
|
||||||
|
<t-input
|
||||||
|
v-model="keyword"
|
||||||
|
borderless
|
||||||
|
clearable
|
||||||
|
placeholder="搜索客户姓名、拼音或编码"
|
||||||
|
@enter="reload"
|
||||||
|
>
|
||||||
|
<template #suffix-icon>
|
||||||
|
<t-button
|
||||||
|
size="extra-small"
|
||||||
|
theme="primary"
|
||||||
|
variant="outline"
|
||||||
|
:content="customerId ? '更换客户' : '选择客户'"
|
||||||
|
@click.stop="customerVisible = true"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</t-input>
|
||||||
|
<t-dropdown-menu class="menus">
|
||||||
|
<t-dropdown-item
|
||||||
|
v-model="dateType"
|
||||||
|
:label="dateLabel"
|
||||||
|
:options="dateOptions"
|
||||||
|
@change="selectDate"
|
||||||
|
/>
|
||||||
|
<t-dropdown-item
|
||||||
|
v-model="bizType"
|
||||||
|
label="流水类型"
|
||||||
|
:options="typeOptions"
|
||||||
|
@change="reload"
|
||||||
|
/>
|
||||||
|
</t-dropdown-menu>
|
||||||
|
</div>
|
||||||
|
<t-cell-group v-if="customerId || dateType === 'custom'" theme="card">
|
||||||
|
<t-cell v-if="customerId" title="已选择客户" note="清除" arrow @click="clearCustomer" />
|
||||||
|
<template v-if="dateType === 'custom'">
|
||||||
|
<t-cell title="开始时间" :note="dateRange[0] || '-'" arrow @click="openDate(false)" />
|
||||||
|
<t-cell title="结束时间" :note="dateRange[1] || '-'" arrow @click="openDate(true)" />
|
||||||
|
</template>
|
||||||
|
</t-cell-group>
|
||||||
|
<t-cell-group v-if="records.length" class="records empty-cell-title-margin" theme="card">
|
||||||
|
<t-cell v-for="record in records" :key="record.id" class="item" :arrow="!!record.id" :hover="!!record.id" @click="openRecord(record)" v-entrance-transition="{ step: 30 }">
|
||||||
|
<template #leftIcon>
|
||||||
|
<t-image
|
||||||
|
v-if="getCustomerPhotoURL(record.customer ?? undefined, 64)"
|
||||||
|
class="avatar"
|
||||||
|
:src="getCustomerPhotoURL(record.customer ?? undefined, 64)"
|
||||||
|
:alt="record.customerName || record.customerCode || '客户头像'"
|
||||||
|
fit="cover"
|
||||||
|
/>
|
||||||
|
<div v-else class="avatar fallback" v-text="(record.customerName || record.customerCode || '客').slice(0, 1)" />
|
||||||
|
</template>
|
||||||
|
<template #title>
|
||||||
|
<div class="title">
|
||||||
|
<span class="actor" v-text="record.customerName || record.customerCode || '未知客户'" />
|
||||||
|
<strong class="operation" :class="getTypeClass(record.bizType)" v-text="getRecycleLedgerTypeText(record.bizType)" />
|
||||||
|
<strong class="name clip-text" v-text="record.recycleName || '回收物'" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #description>
|
||||||
|
<div class="description">
|
||||||
|
<time-label :timestamp="record.createdAt" underline />
|
||||||
|
<div class="deltas">
|
||||||
|
<span v-if="!isReservation(record.bizType)">余额 <span class="value" :class="getDeltaClass(record.balanceDelta)" v-text="quantityText(record.balanceDelta, record.recycleUnit)" /></span>
|
||||||
|
<span v-else>预占 <span class="value" :class="getDeltaClass(record.reservedDelta)" v-text="quantityText(record.reservedDelta, record.recycleUnit)" /></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="record.reason" class="reason" v-text="record.reason" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
<center-tips v-else :content="loading ? '正在加载回收物流水' : '暂无回收物流水'" />
|
||||||
|
<center-tips
|
||||||
|
v-if="records.length"
|
||||||
|
:content="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'"
|
||||||
|
/>
|
||||||
|
</t-pull-down-refresh>
|
||||||
|
</template>
|
||||||
|
<template #detail>
|
||||||
|
<sales-order-detail v-if="orderPane" :key="`order-${orderPane.orderId}`" :order-id="orderPane.orderId" />
|
||||||
|
<recycle-account v-else-if="accountId" :key="`account-${accountId}`" :initial-customer-id="accountId" />
|
||||||
|
<recycle-ledger-detail v-else :key="`detail-${selectedId}-${detailVersion}`" :record-id="selectedId" />
|
||||||
|
</template>
|
||||||
|
<template #sub>
|
||||||
|
<sales-order-sub-view
|
||||||
|
v-if="orderPane?.view"
|
||||||
|
:key="`sub-${orderPane.view}`"
|
||||||
|
:view="orderPane.view"
|
||||||
|
:order-id="orderPane.orderId"
|
||||||
|
@saved="handleOrderSubSaved"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</master-detail-page>
|
||||||
|
<customer-selector
|
||||||
|
v-model="customerId"
|
||||||
|
v-model:visible="customerVisible"
|
||||||
|
@change="reload"
|
||||||
|
/>
|
||||||
|
<t-popup v-model="dateVisible" placement="bottom">
|
||||||
|
<t-date-time-picker
|
||||||
|
v-if="dateVisible"
|
||||||
|
v-model="dateDraft"
|
||||||
|
format="YYYY-MM-DD HH:mm"
|
||||||
|
:mode="['date', 'minute']"
|
||||||
|
:title="editingEnd ? '结束时间' : '开始时间'"
|
||||||
|
@cancel="dateVisible = false" @confirm="confirmDate"
|
||||||
|
/>
|
||||||
|
</t-popup>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { MasterDetailPage, providePane, useMasterDetailPane } from "timi-tdesign-mobile";
|
||||||
|
import RecycleLedgerDetail from "@/pages/recycle/RecycleLedgerDetail.vue";
|
||||||
|
import RecycleAccount from "@/pages/recycle/RecycleAccount.vue";
|
||||||
|
import SalesOrderDetail from "@/pages/salesOrder/SalesOrderDetail.vue";
|
||||||
|
import SalesOrderSubView from "@/pages/salesOrder/component/SalesOrderSubView.vue";
|
||||||
|
import { buildOrderPaneView, getOrderPaneRoute, parseOrderPaneView } from "@/pages/salesOrder/component/orderPane";
|
||||||
|
import type { DropdownValue } from "tdesign-mobile-vue";
|
||||||
|
import { Time, TimeLabel } from "timi-web";
|
||||||
|
import RecycleAPI from "@/api/RecycleAPI";
|
||||||
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
|
import type { RecycleLedger } from "@/types/Recycle";
|
||||||
|
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
|
import { getErrorMessage } from "@/utils/error";
|
||||||
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
|
import { Message } from "@/utils/message";
|
||||||
|
import { permissionCodes } from "@/utils/permission";
|
||||||
|
import { getRecycleLedgerTypeText, getRecycleQuantityText } from "@/utils/recycle";
|
||||||
|
|
||||||
|
defineOptions({ name: "RecycleLedgerList" });
|
||||||
|
const route = useRoute();
|
||||||
|
const customerId = ref(typeof route.query.customerId === "string" ? route.query.customerId : "");
|
||||||
|
const { selectedId, detailVersion, subView, paneDirection, isWide, openDetail, openSub, close } = useMasterDetailPane({
|
||||||
|
path: "/product/recycle-payments",
|
||||||
|
detail: id => {
|
||||||
|
const order = parseOrderPaneView(subView.value || "");
|
||||||
|
if (order) return getOrderPaneRoute(order);
|
||||||
|
if (accountId.value) return `/management/recycle-accounts?customerId=${encodeURIComponent(accountId.value)}`;
|
||||||
|
const query = new URLSearchParams();
|
||||||
|
if (customerId.value) query.set("customerId", customerId.value);
|
||||||
|
const depth = Number(route.query.transitionDepth || route.meta.depth || 0);
|
||||||
|
query.set("transitionDepth", String(depth + 1));
|
||||||
|
return `/product/recycle-ledgers/${encodeURIComponent(id)}?${query}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const orderPane = computed(() => parseOrderPaneView(subView.value || ""));
|
||||||
|
const accountId = computed(() => {
|
||||||
|
const view = subView.value || "";
|
||||||
|
return view.startsWith("recycle-account:") ? view.slice("recycle-account:".length) : "";
|
||||||
|
});
|
||||||
|
|
||||||
|
providePane({
|
||||||
|
close: saved => close(saved),
|
||||||
|
openSub: view => openSub(orderPane.value && !parseOrderPaneView(view) ? buildOrderPaneView(orderPane.value.orderId, view) : view)
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(orderPane, (next, previous) => {
|
||||||
|
if (previous?.view && !next?.view) paneDirection.value = "back";
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleOrderSubSaved(kind: string, id: string): void {
|
||||||
|
const order = orderPane.value;
|
||||||
|
if (!order || !id) return;
|
||||||
|
if (kind === "fulfillment-create") openSub(buildOrderPaneView(order.orderId, `fulfillment-detail:${id}`));
|
||||||
|
if (kind === "recycle-register") openSub(buildOrderPaneView(order.orderId, `recycle-payment-detail:${order.view.split(":")[1] || ""}:${id}`));
|
||||||
|
}
|
||||||
|
|
||||||
|
const customerVisible = ref(false);
|
||||||
|
const keyword = ref("");
|
||||||
|
const bizType = ref("ALL");
|
||||||
|
const dateType = ref<DateFilterType>("all");
|
||||||
|
const dateRange = ref<[string, string]>(["", ""]);
|
||||||
|
const dateVisible = ref(false);
|
||||||
|
const dateDraft = ref("");
|
||||||
|
const editingEnd = ref(false);
|
||||||
|
const dateLabel = computed(() => dateOptions.find(item => item.value === dateType.value)?.label || "时间范围");
|
||||||
|
const typeOptions = [
|
||||||
|
{ label: "全部类型", value: "ALL" }, ...[
|
||||||
|
"FULFILLMENT_YIELD",
|
||||||
|
"FULFILLMENT_REVOKE",
|
||||||
|
"MANUAL",
|
||||||
|
"PAYMENT_RESERVE",
|
||||||
|
"PAYMENT_RELEASE",
|
||||||
|
"PAYMENT_VERIFY",
|
||||||
|
"PAYMENT_REVOKE"
|
||||||
|
].map(value => ({ label: getRecycleLedgerTypeText(value), value }))
|
||||||
|
];
|
||||||
|
const records = ref<RecycleLedger[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const refreshing = ref(false);
|
||||||
|
const noMore = ref(false);
|
||||||
|
let version = 0;
|
||||||
|
let index = 0;
|
||||||
|
|
||||||
|
function openRecord(record: RecycleLedger): void {
|
||||||
|
if (record.id) openDetail(record.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isReservation(type?: string): boolean {
|
||||||
|
return type === "PAYMENT_RESERVE" || type === "PAYMENT_RELEASE";
|
||||||
|
}
|
||||||
|
|
||||||
|
function quantityText(value?: number | string, unit?: string): string {
|
||||||
|
return `${0 < Number(value ?? 0) ? "+" : ""}${getRecycleQuantityText(value ?? 0, unit)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDeltaClass(value?: number | string): string {
|
||||||
|
const amount = Number(value ?? 0);
|
||||||
|
return 0 < amount ? "positive" : amount < 0 ? "negative" : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTypeClass(type?: string): string {
|
||||||
|
return ({
|
||||||
|
FULFILLMENT_YIELD: "yield",
|
||||||
|
FULFILLMENT_REVOKE: "fulfillment-revoke",
|
||||||
|
MANUAL: "manual",
|
||||||
|
ADJUST: "manual",
|
||||||
|
PAYMENT_RESERVE: "reserve",
|
||||||
|
PAYMENT_RELEASE: "release",
|
||||||
|
PAYMENT_VERIFY: "verify",
|
||||||
|
PAYMENT_REVOKE: "payment-revoke"
|
||||||
|
} as Record<string, string>)[type || ""] || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadMore(): Promise<void> {
|
||||||
|
if (loading.value || noMore.value) return;
|
||||||
|
const token = version;
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const result = await RecycleAPI.ledgerList({
|
||||||
|
index, size: 20, customerId: customerId.value || undefined, keyword: keyword.value || undefined,
|
||||||
|
bizType: bizType.value === "ALL" ? undefined : bizType.value,
|
||||||
|
beginAt: dateRange.value[0] ? Time.toTimestamp(parseDateTime(dateRange.value[0], false)) : undefined,
|
||||||
|
endAt: dateRange.value[1] ? Time.toTimestamp(parseDateTime(dateRange.value[1], true)) : undefined
|
||||||
|
});
|
||||||
|
if (token !== version) return;
|
||||||
|
records.value.push(...result.list);
|
||||||
|
index++;
|
||||||
|
noMore.value = !(records.value.length < result.total) || !result.list.length;
|
||||||
|
} catch (error) {
|
||||||
|
if (token === version) Message.error(getErrorMessage(error, "回收物流水加载失败"));
|
||||||
|
} finally {
|
||||||
|
if (token === version) {
|
||||||
|
loading.value = false;
|
||||||
|
refreshing.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reload(): Promise<void> {
|
||||||
|
version++;
|
||||||
|
index = 0;
|
||||||
|
records.value = [];
|
||||||
|
loading.value = false;
|
||||||
|
noMore.value = false;
|
||||||
|
await loadMore();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function clearCustomer(): Promise<void> {
|
||||||
|
customerId.value = "";
|
||||||
|
await reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function selectDate(value: DropdownValue): Promise<void> {
|
||||||
|
if (Array.isArray(value)) return;
|
||||||
|
dateType.value = String(value) as DateFilterType;
|
||||||
|
dateRange.value = dateType.value === "custom" ? ["", ""] : buildPresetDateRange(dateType.value);
|
||||||
|
await reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function openDate(end: boolean): void {
|
||||||
|
editingEnd.value = end;
|
||||||
|
dateDraft.value = dateRange.value[end ? 1 : 0];
|
||||||
|
dateVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmDate(value?: string | number): Promise<void> {
|
||||||
|
dateVisible.value = false;
|
||||||
|
const next = String(value || dateDraft.value);
|
||||||
|
const [begin, end] = editingEnd.value ? [dateRange.value[0], next] : [next, dateRange.value[1]];
|
||||||
|
if (begin && end && parseDateTime(end, true) < parseDateTime(begin, false)) {
|
||||||
|
Message.warning("结束时间不能早于开始时间");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dateRange.value = [begin, end];
|
||||||
|
await reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => await reload());
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.recycle-ledger-list {
|
||||||
|
.records {
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
padding: .625rem;
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
width: 3.5rem;
|
||||||
|
height: 3.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
gap: .25rem;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
font-size: .75rem;
|
||||||
|
align-items: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
.actor {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
color: var(--td-text-color-brand);
|
||||||
|
}
|
||||||
|
|
||||||
|
.operation {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
color: var(--operation-color, var(--td-text-color-secondary));
|
||||||
|
font-weight: 700;
|
||||||
|
|
||||||
|
&.yield { --operation-color: #15803d; }
|
||||||
|
&.fulfillment-revoke { --operation-color: #c2410c; }
|
||||||
|
&.manual { --operation-color: #2563eb; }
|
||||||
|
&.reserve { --operation-color: #7c3aed; }
|
||||||
|
&.release { --operation-color: #0891b2; }
|
||||||
|
&.verify { --operation-color: #dc2626; }
|
||||||
|
&.payment-revoke { --operation-color: #4f46e5; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
flex: 0 1 auto;
|
||||||
|
color: var(--td-text-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
font-size: .75rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.deltas {
|
||||||
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.value { font-size: 1.25rem; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.reason {
|
||||||
|
color: var(--td-text-color-secondary);
|
||||||
|
font-size: .75rem;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.positive { color: var(--td-success-color); }
|
||||||
|
.negative { color: var(--td-error-color); }
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(html.theme-dark) .recycle-ledger-list .operation {
|
||||||
|
&.yield { --operation-color: #86efac; }
|
||||||
|
&.fulfillment-revoke { --operation-color: #fdba74; }
|
||||||
|
&.manual { --operation-color: #93c5fd; }
|
||||||
|
&.reserve { --operation-color: #c4b5fd; }
|
||||||
|
&.release { --operation-color: #67e8f9; }
|
||||||
|
&.verify { --operation-color: #fca5a5; }
|
||||||
|
&.payment-revoke { --operation-color: #a5b4fc; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+206
-107
@@ -1,6 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tui-page-layout tui-navbar recycle-payment-list">
|
<div class="tui-page-layout tui-navbar recycle-order-payment-list">
|
||||||
<t-navbar fixed :z-index="20" title="回收流水" left-arrow @left-click="exit">
|
<t-navbar
|
||||||
|
fixed
|
||||||
|
:z-index="20"
|
||||||
|
title="订单回收流水"
|
||||||
|
left-arrow
|
||||||
|
@left-click="exit"
|
||||||
|
>
|
||||||
<template #right>
|
<template #right>
|
||||||
<t-button
|
<t-button
|
||||||
v-if="canRegister"
|
v-if="canRegister"
|
||||||
@@ -12,13 +18,14 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</t-navbar>
|
</t-navbar>
|
||||||
<main class="tui-page-content list">
|
<main class="tui-page-content column scroll list">
|
||||||
<t-pull-down-refresh
|
<t-pull-down-refresh
|
||||||
class="pull-refresh"
|
class="pull-refresh"
|
||||||
v-model="refreshing"
|
v-model="refreshing"
|
||||||
:refresh-timeout="30000"
|
:refresh-timeout="30000"
|
||||||
@refresh="reload"
|
@refresh="reload"
|
||||||
@scrolltolower="loadMore">
|
@scrolltolower="loadMore"
|
||||||
|
>
|
||||||
<div class="filters glass">
|
<div class="filters glass">
|
||||||
<t-input
|
<t-input
|
||||||
class="customer"
|
class="customer"
|
||||||
@@ -59,30 +66,53 @@
|
|||||||
/>
|
/>
|
||||||
<t-dropdown-item
|
<t-dropdown-item
|
||||||
v-model="status"
|
v-model="status"
|
||||||
label="状态"
|
label="支付状态"
|
||||||
:options="statusOptions"
|
:options="statusOptions"
|
||||||
@change="reload"
|
@change="reload"
|
||||||
/>
|
/>
|
||||||
|
<t-dropdown-item
|
||||||
|
v-if="customerId && !currentId"
|
||||||
|
v-model="ledgerType"
|
||||||
|
label="额度类型"
|
||||||
|
:options="ledgerTypeOptions"
|
||||||
|
/>
|
||||||
</t-dropdown-menu>
|
</t-dropdown-menu>
|
||||||
</div>
|
</div>
|
||||||
<t-cell-group v-if="dateType === 'custom'" class="date-summary" theme="card">
|
<t-cell-group v-if="dateType === 'custom'" class="date-summary" theme="card">
|
||||||
<t-cell title="开始时间" :note="dateRange[0] || '-'" arrow @click="openDate(false)" />
|
<t-cell title="开始时间" :note="dateRange[0] || '-'" arrow @click="openDate(false)" />
|
||||||
<t-cell title="结束时间" :note="dateRange[1] || '-'" arrow @click="openDate(true)" />
|
<t-cell title="结束时间" :note="dateRange[1] || '-'" arrow @click="openDate(true)" />
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<t-cell-group
|
<t-cell-group v-if="exchange" theme="card" v-entrance-transition>
|
||||||
v-if="paymentList.length"
|
<t-cell title="订单号" :note="order?.orderNo || '-'" />
|
||||||
class="empty-cell-title-margin"
|
<t-cell :note="exchange.recycleNameSnapshot || '回收物'">
|
||||||
theme="card"
|
<template #title>
|
||||||
>
|
<t-image v-if="recyclePhotoId" class="recycle-avatar" :src="getAttachmentReadURL(recyclePhotoId, 96)" :alt="exchange.recycleNameSnapshot || '回收物'" fit="cover" />
|
||||||
|
<span v-else class="recycle-avatar fallback" v-text="(exchange.recycleNameSnapshot || '回').slice(0, 1)" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell title="总回收量" :note="getRecycleQuantityText(exchange.recycleQuantity, exchange.recycleUnitSnapshot)" />
|
||||||
|
<t-cell title="剩余回收" :note="getRecycleQuantityText(remaining.toFixed(3), exchange.recycleUnitSnapshot)" />
|
||||||
|
</t-cell-group>
|
||||||
|
<t-cell-group v-if="filteredLedgerRecords.length" title="额度流水" theme="card">
|
||||||
<t-cell
|
<t-cell
|
||||||
class="item"
|
v-for="record in filteredLedgerRecords"
|
||||||
v-for="payment in paymentList"
|
:key="record.id"
|
||||||
:key="payment.id"
|
:title="recycleItems.get(record.recycleItemId || '')?.name || '回收物'"
|
||||||
arrow
|
:note="ledgerQuantity(record)"
|
||||||
v-entrance-transition
|
|
||||||
@click="openDetail(payment)"
|
|
||||||
>
|
>
|
||||||
<template #leftIcon>
|
<template #description>
|
||||||
|
<div v-text="getRecycleLedgerTypeText(record.bizType)" />
|
||||||
|
<div v-if="record.reason" v-text="record.reason" />
|
||||||
|
<time-label :timestamp="record.createdAt" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
<center-tips v-else-if="customerId && !currentId && !ledgerLoading" content="暂无符合条件的额度流水" />
|
||||||
|
<t-cell v-if="customerId && !currentId && ledgerHasMore" :title="ledgerLoading ? '正在加载额度流水' : '加载更多额度流水'" :arrow="!ledgerLoading" @click="loadMoreLedger" />
|
||||||
|
<center-tips v-if="customerId && !currentId && ledgerHasMore && (ledgerType !== 'ALL' || dateType !== 'all')" content="筛选仅作用于已加载的额度流水" />
|
||||||
|
<div v-if="paymentList.length" class="records">
|
||||||
|
<div v-for="payment in paymentList" :key="payment.id" class="item" v-entrance-transition="{ step: 30 }">
|
||||||
|
<div class="header">
|
||||||
<t-image
|
<t-image
|
||||||
v-if="getCustomerPhotoURL(payment.customer, 64)"
|
v-if="getCustomerPhotoURL(payment.customer, 64)"
|
||||||
class="avatar"
|
class="avatar"
|
||||||
@@ -91,48 +121,32 @@
|
|||||||
fit="cover"
|
fit="cover"
|
||||||
/>
|
/>
|
||||||
<div v-else class="avatar fallback" v-text="customerName(payment).slice(0, 1)" />
|
<div v-else class="avatar fallback" v-text="customerName(payment).slice(0, 1)" />
|
||||||
</template>
|
<div class="main">
|
||||||
<template #title>
|
<div class="customer-status">
|
||||||
<div class="title">
|
<strong class="customer clip-text" v-text="customerName(payment)" />
|
||||||
<span class="customer clip-text" v-text="customerName(payment)" />
|
<div class="tags">
|
||||||
<span
|
<t-tag size="small" variant="light" :theme="payment.sourcePaymentId ? 'danger' : 'success'" :content="payment.sourcePaymentId ? '回收冲正' : '回收登记'" />
|
||||||
class="type"
|
<t-tag size="small" variant="light-outline" :content="getRecyclePaymentStatusText(payment.status)" :theme="getRecyclePaymentStatusTheme(payment.status)" />
|
||||||
:class="payment.sourcePaymentId ? 'revoke' : 'receive'"
|
|
||||||
v-text="payment.sourcePaymentId ? '回收冲正' : '回收登记'"
|
|
||||||
/>
|
|
||||||
<t-tag
|
|
||||||
:content="getRecyclePaymentStatusText(payment.status)"
|
|
||||||
:theme="getRecyclePaymentStatusTheme(payment.status)"
|
|
||||||
size="small"
|
|
||||||
variant="light-outline"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template #description>
|
|
||||||
<div class="description">
|
|
||||||
<div class="operator">
|
|
||||||
<div class="field"><span class="label">发起人</span><span class="text-bold"
|
|
||||||
v-text="payment.operator?.nick || payment.operator?.name || '未知'" />
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="payment.verifierUserId" class="field">
|
|
||||||
<span
|
|
||||||
class="label"
|
|
||||||
v-text="payment.status === 'VERIFIED' ? '核销人' : '处理人'" />
|
|
||||||
<span
|
|
||||||
class="text-bold"
|
|
||||||
v-text="payment.verifier?.nick || payment.verifier?.name || '未知'"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<time-label :timestamp="payment.occurredAt" underline />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="quantity">
|
<div class="record-line">
|
||||||
<strong class="red" v-text="paymentQuantity(payment)" />
|
<time-label class="time" :timestamp="payment.occurredAt" underline />
|
||||||
|
<strong class="quantity red" v-text="paymentQuantity(payment)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</div>
|
||||||
</t-cell>
|
<t-divider />
|
||||||
</t-cell-group>
|
<div class="people-actions">
|
||||||
<center-tips v-else :content="loading ? '正在加载回收流水' : '暂无回收流水'" />
|
<div class="person"><span class="label">发起人</span><strong v-text="payment.operator?.nick || payment.operator?.name || payment.operatorUserId || '未知'" /></div>
|
||||||
|
<div v-if="payment.verifierUserId" class="person">
|
||||||
|
<span class="label" v-text="payment.status === 'VERIFIED' ? '核销人' : '处理人'" />
|
||||||
|
<strong v-text="payment.verifier?.nick || payment.verifier?.name || payment.verifierUserId || '未知'" />
|
||||||
|
</div>
|
||||||
|
<div class="actions"><t-button theme="primary" size="extra-small" content="详情" @click.stop="openDetail(payment)" /></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<center-tips v-else :content="loading ? '正在加载回收支付记录' : '暂无回收支付记录'" />
|
||||||
<center-tips
|
<center-tips
|
||||||
v-if="paymentList.length"
|
v-if="paymentList.length"
|
||||||
:content="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'"
|
:content="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'"
|
||||||
@@ -165,18 +179,21 @@ import { Time, TimeLabel } from "timi-web";
|
|||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import RecycleAPI from "@/api/RecycleAPI";
|
import RecycleAPI from "@/api/RecycleAPI";
|
||||||
|
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
import type { Customer } from "@/types/Customer";
|
import type { Customer } from "@/types/Customer";
|
||||||
import type { RecycleExchange, RecyclePayment } from "@/types/Recycle";
|
import type { SalesOrder } from "@/types/SalesOrder";
|
||||||
|
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||||
|
import type { RecycleExchange, RecycleItem, RecycleLedger, RecyclePayment } from "@/types/Recycle";
|
||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
||||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { getRecyclePaymentStatusText, getRecyclePaymentStatusTheme, getRecycleQuantityText } from "@/utils/recycle";
|
import { getRecycleLedgerTypeText, getRecyclePaymentStatusText, getRecyclePaymentStatusTheme, getRecycleQuantityText } from "@/utils/recycle";
|
||||||
|
|
||||||
defineOptions({ name: "RecyclePaymentList" });
|
defineOptions({ name: "RecycleOrderPaymentList" });
|
||||||
const props = withDefaults(defineProps<{ exchangeId?: string }>(), { exchangeId: "" });
|
const props = withDefaults(defineProps<{ exchangeId?: string }>(), { exchangeId: "" });
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -184,8 +201,15 @@ const pane = usePane();
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentId = computed(() => props.exchangeId || (typeof route.params.id === "string" ? route.params.id : ""));
|
const currentId = computed(() => props.exchangeId || (typeof route.params.id === "string" ? route.params.id : ""));
|
||||||
const exchange = ref<RecycleExchange>();
|
const exchange = ref<RecycleExchange>();
|
||||||
|
const order = ref<SalesOrder>();
|
||||||
|
const recyclePhotoId = computed(() => exchange.value?.recycleItemAttachments?.find(item => item.id && item.mimeType?.startsWith("image/"))?.id || "");
|
||||||
const remaining = ref(0);
|
const remaining = ref(0);
|
||||||
const paymentList = ref<RecyclePayment[]>([]);
|
const paymentList = ref<RecyclePayment[]>([]);
|
||||||
|
const ledgerRecords = ref<RecycleLedger[]>([]);
|
||||||
|
const ledgerLoading = ref(false);
|
||||||
|
const ledgerHasMore = ref(false);
|
||||||
|
let ledgerIndex = 0;
|
||||||
|
const recycleItems = ref(new Map<string, RecycleItem>());
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const refreshing = ref(false);
|
const refreshing = ref(false);
|
||||||
const noMore = ref(false);
|
const noMore = ref(false);
|
||||||
@@ -194,6 +218,7 @@ const selectedCustomer = ref<Customer>();
|
|||||||
const customerSearchKeyword = ref("");
|
const customerSearchKeyword = ref("");
|
||||||
const customerSelectorVisible = ref(false);
|
const customerSelectorVisible = ref(false);
|
||||||
const status = ref("ALL");
|
const status = ref("ALL");
|
||||||
|
const ledgerType = ref("ALL");
|
||||||
const dateType = ref<DateFilterType>("all");
|
const dateType = ref<DateFilterType>("all");
|
||||||
const dateRange = ref<[string, string]>(["", ""]);
|
const dateRange = ref<[string, string]>(["", ""]);
|
||||||
const dateVisible = ref(false);
|
const dateVisible = ref(false);
|
||||||
@@ -204,10 +229,68 @@ const statusOptions = [
|
|||||||
{ label: "已核销", value: "VERIFIED" }, { label: "已拒绝", value: "REJECTED" },
|
{ label: "已核销", value: "VERIFIED" }, { label: "已拒绝", value: "REJECTED" },
|
||||||
{ label: "已撤销", value: "CANCELLED" }, { label: "已冲正", value: "REVOKED" }
|
{ label: "已撤销", value: "CANCELLED" }, { label: "已冲正", value: "REVOKED" }
|
||||||
];
|
];
|
||||||
|
const ledgerTypeOptions = [
|
||||||
|
{ label: "全部额度类型", value: "ALL" },
|
||||||
|
...[
|
||||||
|
"FULFILLMENT_YIELD", "FULFILLMENT_REVOKE", "MANUAL",
|
||||||
|
"PAYMENT_RESERVE", "PAYMENT_RELEASE", "PAYMENT_VERIFY", "PAYMENT_REVOKE"
|
||||||
|
].map(value => ({ label: getRecycleLedgerTypeText(value), value }))
|
||||||
|
];
|
||||||
const dateLabel = computed(() => dateOptions.find(item => item.value === dateType.value)?.label || "时间范围");
|
const dateLabel = computed(() => dateOptions.find(item => item.value === dateType.value)?.label || "时间范围");
|
||||||
const canRegister = computed(() => !!exchange.value && 0 < remaining.value && userStore.hasPermissions(permissionCodes.fundReceive.create));
|
const canRegister = computed(() => !!exchange.value && 0 < remaining.value && userStore.hasPermissions(permissionCodes.fundReceive.create));
|
||||||
|
const filteredLedgerRecords = computed(() => {
|
||||||
|
if (currentId.value || !customerId.value) return [];
|
||||||
|
const begin = dateRange.value[0] ? Time.toTimestamp(parseDateTime(dateRange.value[0], false)) : 0;
|
||||||
|
const end = dateRange.value[1] ? Time.toTimestamp(parseDateTime(dateRange.value[1], true)) : Infinity;
|
||||||
|
return ledgerRecords.value.filter(item => (ledgerType.value === "ALL" || item.bizType === ledgerType.value
|
||||||
|
|| (ledgerType.value === "MANUAL" && item.bizType === "ADJUST"))
|
||||||
|
&& (item.createdAt ? !(item.createdAt < begin) && !(end < item.createdAt) : !dateRange.value[0] && !dateRange.value[1]));
|
||||||
|
});
|
||||||
let requestVersion = 0;
|
let requestVersion = 0;
|
||||||
|
|
||||||
|
function ledgerQuantity(record: RecycleLedger): string {
|
||||||
|
const item = recycleItems.value.get(record.recycleItemId || "");
|
||||||
|
const format = (value: number | string | undefined): string => {
|
||||||
|
const quantity = Number(value ?? 0);
|
||||||
|
return `${0 < quantity ? "+" : ""}${getRecycleQuantityText(value ?? 0, item?.unitName)}`;
|
||||||
|
};
|
||||||
|
return `余额 ${format(record.balanceDelta)},预占 ${format(record.reservedDelta)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadLedger(version: number): Promise<void> {
|
||||||
|
if (currentId.value || !customerId.value) return;
|
||||||
|
ledgerLoading.value = true;
|
||||||
|
try {
|
||||||
|
const [result, items] = await Promise.all([RecycleAPI.accountLedger(customerId.value, 0, 20), RecycleAPI.accountItems()]);
|
||||||
|
if (version !== requestVersion) return;
|
||||||
|
ledgerRecords.value = result.list;
|
||||||
|
ledgerIndex = 1;
|
||||||
|
ledgerHasMore.value = result.list.length < result.total && 0 < result.list.length;
|
||||||
|
recycleItems.value = new Map(items.filter(item => item.id).map(item => [item.id!, item]));
|
||||||
|
} catch (error) {
|
||||||
|
if (version === requestVersion) Message.error(getErrorMessage(error, "额度流水加载失败"));
|
||||||
|
} finally {
|
||||||
|
if (version === requestVersion) ledgerLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadMoreLedger(): Promise<void> {
|
||||||
|
if (ledgerLoading.value || !ledgerHasMore.value || !customerId.value) return;
|
||||||
|
const version = requestVersion;
|
||||||
|
ledgerLoading.value = true;
|
||||||
|
try {
|
||||||
|
const result = await RecycleAPI.accountLedger(customerId.value, ledgerIndex, 20);
|
||||||
|
if (version !== requestVersion) return;
|
||||||
|
ledgerRecords.value.push(...result.list);
|
||||||
|
ledgerIndex++;
|
||||||
|
ledgerHasMore.value = ledgerRecords.value.length < result.total && 0 < result.list.length;
|
||||||
|
} catch (error) {
|
||||||
|
if (version === requestVersion) Message.error(getErrorMessage(error, "额度流水加载失败"));
|
||||||
|
} finally {
|
||||||
|
if (version === requestVersion) ledgerLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function exit(): void {
|
function exit(): void {
|
||||||
if (pane) {
|
if (pane) {
|
||||||
pane.close();
|
pane.close();
|
||||||
@@ -256,10 +339,15 @@ async function reload(): Promise<void> {
|
|||||||
requestVersion += 1;
|
requestVersion += 1;
|
||||||
const version = requestVersion;
|
const version = requestVersion;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
ledgerLoading.value = false;
|
||||||
paymentList.value = [];
|
paymentList.value = [];
|
||||||
|
ledgerRecords.value = [];
|
||||||
|
ledgerHasMore.value = false;
|
||||||
|
ledgerIndex = 0;
|
||||||
noMore.value = false;
|
noMore.value = false;
|
||||||
if (currentId.value) {
|
if (currentId.value) {
|
||||||
exchange.value = undefined;
|
exchange.value = undefined;
|
||||||
|
order.value = undefined;
|
||||||
try {
|
try {
|
||||||
const result = await RecycleAPI.detail(currentId.value);
|
const result = await RecycleAPI.detail(currentId.value);
|
||||||
if (version !== requestVersion) return;
|
if (version !== requestVersion) return;
|
||||||
@@ -269,8 +357,12 @@ async function reload(): Promise<void> {
|
|||||||
refreshing.value = false;
|
refreshing.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const payments = await RecycleAPI.paymentList(exchange.value.salesOrderId);
|
const [payments, salesOrder] = await Promise.all([
|
||||||
|
RecycleAPI.paymentList(exchange.value.salesOrderId),
|
||||||
|
SalesOrderAPI.detail(exchange.value.salesOrderId)
|
||||||
|
]);
|
||||||
if (version !== requestVersion) return;
|
if (version !== requestVersion) return;
|
||||||
|
order.value = salesOrder;
|
||||||
const reserved = payments.filter(item => item.status === "PENDING" || (item.status === "VERIFIED" && !item.sourcePaymentId))
|
const reserved = payments.filter(item => item.status === "PENDING" || (item.status === "VERIFIED" && !item.sourcePaymentId))
|
||||||
.reduce((sum, item) => sum + Number(item.quantity ?? 0), 0);
|
.reduce((sum, item) => sum + Number(item.quantity ?? 0), 0);
|
||||||
remaining.value = Math.max(Number(exchange.value.recycleQuantity ?? 0) - reserved, 0);
|
remaining.value = Math.max(Number(exchange.value.recycleQuantity ?? 0) - reserved, 0);
|
||||||
@@ -282,7 +374,7 @@ async function reload(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else exchange.value = undefined;
|
} else exchange.value = undefined;
|
||||||
await loadMore();
|
await Promise.all([loadMore(), loadLedger(version)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleCustomerChange(value: string | string[]): Promise<void> {
|
async function handleCustomerChange(value: string | string[]): Promise<void> {
|
||||||
@@ -380,69 +472,76 @@ onActivated(reload);
|
|||||||
watch(currentId, reload);
|
watch(currentId, reload);
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.recycle-payment-list {
|
.recycle-order-payment-list {
|
||||||
|
|
||||||
|
.recycle-avatar {
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 2.5rem;
|
||||||
|
border-radius: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.records {
|
||||||
|
gap: 1rem;
|
||||||
|
margin: 0 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
padding: 10px;
|
gap: .5rem;
|
||||||
|
display: flex;
|
||||||
|
padding: .625rem;
|
||||||
|
background: var(--td-bg-color-container);
|
||||||
|
border-radius: 1rem;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
.avatar {
|
.header {
|
||||||
width: 3.5rem;
|
gap: .5rem;
|
||||||
height: 3.5rem;
|
display: flex;
|
||||||
|
|
||||||
|
.avatar { width: 3.5rem; height: 3.5rem; }
|
||||||
|
.main { gap: .5rem; flex: 1; display: flex; min-width: 0; flex-direction: column; }
|
||||||
|
.customer-status, .record-line { gap: .5rem; display: flex; align-items: center; justify-content: space-between; }
|
||||||
|
.customer { min-width: 0; }
|
||||||
|
.tags { gap: .5rem; display: flex; align-items: center; }
|
||||||
|
.time { color: var(--td-text-color-secondary); font-size: .75rem; }
|
||||||
|
.quantity { font-size: 1.25rem; white-space: nowrap; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.people-actions {
|
||||||
gap: .25rem;
|
gap: .75rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
font-size: .75rem;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
.customer { font-weight: 600; }
|
.person {
|
||||||
.type {
|
gap: .25rem;
|
||||||
font-weight: 700;
|
|
||||||
|
|
||||||
&.receive { color: #15803d; }
|
|
||||||
&.revoke { color: #7c3aed; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
|
||||||
display: flex;
|
|
||||||
align-items: start;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.operator {
|
|
||||||
color: var(--td-text-color-secondary);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
font-size: .75rem;
|
font-size: .75rem;
|
||||||
line-height: 1.5;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field {
|
|
||||||
gap: .25rem;
|
|
||||||
display: inline-flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
|
||||||
color: var(--td-text-color-placeholder);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quantity {
|
|
||||||
gap: .25rem;
|
|
||||||
display: flex;
|
|
||||||
font-size: 1.25rem;
|
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
white-space: nowrap;
|
|
||||||
|
.label { flex: 0 0 auto; color: var(--td-text-color-secondary); }
|
||||||
|
strong { overflow: hidden; max-width: 10rem; white-space: nowrap; text-overflow: ellipsis; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
--td-button-border-radius: .5rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: end;
|
||||||
|
|
||||||
|
.t-button { padding-left: 1.5rem; padding-right: 1.5rem; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(html.theme-dark) .recycle-payment-list {
|
:deep(.avatar .t-image__img) {
|
||||||
.type {
|
width: 100%;
|
||||||
&.receive { color: #86efac; }
|
height: 100%;
|
||||||
&.revoke { color: #c4b5fd; }
|
object-fit: cover;
|
||||||
}
|
border-radius: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:global(html.theme-dark) .recycle-payment-list .fallback { background: #115e59; }
|
||||||
</style>
|
</style>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
embedded
|
embedded
|
||||||
@saved="id => emit('saved', kind, id || '')"
|
@saved="id => emit('saved', kind, id || '')"
|
||||||
/>
|
/>
|
||||||
<recycle-payment-list
|
<recycle-order-payment-list
|
||||||
v-else-if="kind === 'recycle-payments'"
|
v-else-if="kind === 'recycle-payments'"
|
||||||
:exchange-id="arg"
|
:exchange-id="arg"
|
||||||
/>
|
/>
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import RecycleRuleDetail from "@/pages/recycle/RecycleRuleDetail.vue";
|
import RecycleRuleDetail from "@/pages/recycle/RecycleRuleDetail.vue";
|
||||||
import RecyclePaymentList from "@/pages/recycle/RecyclePaymentList.vue";
|
import RecycleOrderPaymentList from "@/pages/recycle/RecycleOrderPaymentList.vue";
|
||||||
import RecyclePaymentDetail from "@/pages/recycle/RecyclePaymentDetail.vue";
|
import RecyclePaymentDetail from "@/pages/recycle/RecyclePaymentDetail.vue";
|
||||||
import RecyclePaymentRevoke from "@/pages/recycle/RecyclePaymentRevoke.vue";
|
import RecyclePaymentRevoke from "@/pages/recycle/RecyclePaymentRevoke.vue";
|
||||||
import RecyclePaymentCreate from "@/pages/recycle/RecyclePaymentCreate.vue";
|
import RecyclePaymentCreate from "@/pages/recycle/RecyclePaymentCreate.vue";
|
||||||
|
|||||||
@@ -10,10 +10,16 @@ function meta(depth = 3): RouteRecordRaw["meta"] {
|
|||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
path: "/product/recycle-payments",
|
path: "/product/recycle-payments",
|
||||||
name: "RecyclePaymentAll",
|
name: "RecycleLedgerList",
|
||||||
component: () => import("@/pages/recycle/RecyclePaymentList.vue"),
|
component: () => import("@/pages/recycle/RecycleLedgerList.vue"),
|
||||||
meta: meta()
|
meta: meta()
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/product/recycle-ledgers/:id",
|
||||||
|
name: "RecycleLedgerDetail",
|
||||||
|
component: () => import("@/pages/recycle/RecycleLedgerDetail.vue"),
|
||||||
|
meta: meta(4)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/product/recycle-exchanges",
|
path: "/product/recycle-exchanges",
|
||||||
name: "RecycleExchangeList",
|
name: "RecycleExchangeList",
|
||||||
@@ -53,7 +59,7 @@ export default [
|
|||||||
{
|
{
|
||||||
path: "/product/recycle-exchanges/:id/payments",
|
path: "/product/recycle-exchanges/:id/payments",
|
||||||
name: "RecyclePaymentList",
|
name: "RecyclePaymentList",
|
||||||
component: () => import("@/pages/recycle/RecyclePaymentList.vue"),
|
component: () => import("@/pages/recycle/RecycleOrderPaymentList.vue"),
|
||||||
meta: meta(5)
|
meta: meta(5)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -201,6 +201,11 @@ export type RecycleCustomerAccountPage = {
|
|||||||
* `bizType` 决定来源语义:履约产生、人工调整、支付预占与释放、支付核销、冲正返还。
|
* `bizType` 决定来源语义:履约产生、人工调整、支付预占与释放、支付核销、冲正返还。
|
||||||
*/
|
*/
|
||||||
export type RecycleLedger = {
|
export type RecycleLedger = {
|
||||||
|
customer?: Customer | null;
|
||||||
|
customerName?: string;
|
||||||
|
customerCode?: string;
|
||||||
|
recycleName?: string;
|
||||||
|
recycleUnit?: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
accountId?: string;
|
accountId?: string;
|
||||||
storeId?: string;
|
storeId?: string;
|
||||||
@@ -214,6 +219,7 @@ export type RecycleLedger = {
|
|||||||
balanceAfter?: number | string;
|
balanceAfter?: number | string;
|
||||||
reservedAfter?: number | string;
|
reservedAfter?: number | string;
|
||||||
operatorUserId?: string | null;
|
operatorUserId?: string | null;
|
||||||
|
operator?: Partial<User> | null;
|
||||||
reason?: string | null;
|
reason?: string | null;
|
||||||
createdAt?: number;
|
createdAt?: number;
|
||||||
};
|
};
|
||||||
@@ -280,6 +286,10 @@ export type RecyclePayment = {
|
|||||||
/** 服务端回填的回收物名称与单位,仅展示用 */
|
/** 服务端回填的回收物名称与单位,仅展示用 */
|
||||||
recycleName?: string | null;
|
recycleName?: string | null;
|
||||||
recycleUnit?: string | null;
|
recycleUnit?: string | null;
|
||||||
|
/** 订单当前成交金额,单位分 */
|
||||||
|
salesOrderAmount?: number | null;
|
||||||
|
/** 订单当前剩余待收金额,单位分 */
|
||||||
|
salesOrderUnpaidAmount?: number | null;
|
||||||
attachmentList?: Attachment[];
|
attachmentList?: Attachment[];
|
||||||
operator?: Partial<User>;
|
operator?: Partial<User>;
|
||||||
verifier?: Partial<User>;
|
verifier?: Partial<User>;
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ export function getRecyclePaymentStatusTheme(status?: RecyclePaymentStatus): "su
|
|||||||
export function getRecycleLedgerTypeText(bizType?: string): string {
|
export function getRecycleLedgerTypeText(bizType?: string): string {
|
||||||
return ({
|
return ({
|
||||||
FULFILLMENT_YIELD: "履约产生",
|
FULFILLMENT_YIELD: "履约产生",
|
||||||
|
FULFILLMENT_REVOKE: "履约冲正",
|
||||||
|
MANUAL: "人工调整",
|
||||||
ADJUST: "人工调整",
|
ADJUST: "人工调整",
|
||||||
PAYMENT_RESERVE: "支付预占",
|
PAYMENT_RESERVE: "支付预占",
|
||||||
PAYMENT_RELEASE: "释放预占",
|
PAYMENT_RELEASE: "释放预占",
|
||||||
@@ -130,7 +132,10 @@ export function isPaymentVerified(payment?: RecyclePayment): boolean {
|
|||||||
|
|
||||||
/** 拼接「数量 + 单位」,后端 BigDecimal 可能是字符串。 */
|
/** 拼接「数量 + 单位」,后端 BigDecimal 可能是字符串。 */
|
||||||
export function getRecycleQuantityText(value: number | string | null | undefined, unit?: string | null): string {
|
export function getRecycleQuantityText(value: number | string | null | undefined, unit?: string | null): string {
|
||||||
const quantityText = getPackageQuantityText(value);
|
const text = String(value ?? "").trim();
|
||||||
|
const negative = text.startsWith("-");
|
||||||
|
const quantity = getPackageQuantityText(negative ? text.slice(1) : value);
|
||||||
|
const quantityText = negative && quantity !== "0" ? `-${quantity}` : quantity;
|
||||||
return unit ? `${quantityText} ${unit}` : quantityText;
|
return unit ? `${quantityText} ${unit}` : quantityText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user