v1.3.1 #9
@@ -51,6 +51,89 @@ jobs:
|
||||
echo "publish=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# 从 CHANGELOG.md 提取当前版本的说明,落到 release-note.txt
|
||||
# 用文件而不是 step output 传递:note 是多行文本,多行 output 在各版本 runner 上行为不一致
|
||||
- name: Resolve release note
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
if [ ! -f CHANGELOG.md ]; then
|
||||
echo "WARN: 缺少 CHANGELOG.md,本次发布不带变更说明"
|
||||
: > release-note.txt
|
||||
exit 0
|
||||
fi
|
||||
node --input-type=module <<'NODE'
|
||||
import fs from "node:fs";
|
||||
|
||||
const version = process.env.VERSION;
|
||||
const heading = "## v" + version;
|
||||
const lines = fs.readFileSync("CHANGELOG.md", "utf8").split(/\r?\n/);
|
||||
const start = lines.findIndex(line => line.trim() === heading);
|
||||
|
||||
if (start < 0) {
|
||||
console.error("WARN: CHANGELOG.md 中没有 " + heading + ",本次发布不带变更说明");
|
||||
fs.writeFileSync("release-note.txt", "");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const LIMIT = 480;
|
||||
const picked = [];
|
||||
let inComment = false;
|
||||
for (let i = start + 1; i < lines.length; i += 1) {
|
||||
const raw = lines[i];
|
||||
if (/^##\s/.test(raw)) {
|
||||
break;
|
||||
}
|
||||
// 跳过 HTML 注释,避免注释内容占掉长度
|
||||
if (inComment) {
|
||||
if (raw.includes("-->")) {
|
||||
inComment = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (raw.includes("<!--")) {
|
||||
if (!raw.includes("-->")) {
|
||||
inComment = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (raw.trim() === "") {
|
||||
// 连续空行压成一个,只用于分隔段落
|
||||
if (picked.length > 0 && picked[picked.length - 1] !== "") {
|
||||
picked.push("");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// 去掉行尾空白,保留行首缩进(嵌套列表)
|
||||
picked.push(raw.replace(/\s+$/, ""));
|
||||
}
|
||||
while (picked.length > 0 && picked[picked.length - 1] === "") {
|
||||
picked.pop();
|
||||
}
|
||||
|
||||
if (picked.length === 0) {
|
||||
console.error("WARN: " + heading + " 下没有内容,本次发布不带变更说明");
|
||||
}
|
||||
|
||||
// 按行累积到上限,不切半行,避免出现断句
|
||||
const kept = [];
|
||||
let total = 0;
|
||||
for (const line of picked) {
|
||||
const length = Array.from(line).length + (kept.length > 0 ? 1 : 0);
|
||||
if (LIMIT < total + length) {
|
||||
console.error("WARN: 内容超过 " + LIMIT + " 字,截断到第 " + kept.length + " 行");
|
||||
break;
|
||||
}
|
||||
kept.push(line);
|
||||
total += length;
|
||||
}
|
||||
|
||||
// 尖括号转义:note 最终走 v-html 渲染,不能让 CHANGELOG 里的 HTML 被执行
|
||||
const note = kept.join("\n").replace(/</g, "<");
|
||||
fs.writeFileSync("release-note.txt", note);
|
||||
console.log("变更说明(" + Array.from(note).length + " 字):\n" + (note === "" ? "(空)" : note));
|
||||
NODE
|
||||
|
||||
- name: Configure nexus auth
|
||||
env:
|
||||
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
@@ -149,13 +232,17 @@ jobs:
|
||||
ARTIFACT_SIZE: ${{ steps.bundle.outputs.size }}
|
||||
SHA256: ${{ steps.bundle.outputs.sha256 }}
|
||||
ATTACHMENT_ID: ${{ steps.upload.outputs.attachment_id }}
|
||||
NOTE_FILE: release-note.txt
|
||||
run: |
|
||||
if [ -z "$PRODUCT_ID" ]; then
|
||||
echo "FAIL: 缺少 vars.APP_PRODUCT_ID"
|
||||
exit 1
|
||||
fi
|
||||
payload=$(node -e "
|
||||
const fs = require('fs');
|
||||
const minCode = Number(process.env.MIN_VERSION_CODE || '1');
|
||||
const noteFile = process.env.NOTE_FILE || 'release-note.txt';
|
||||
const note = fs.existsSync(noteFile) ? fs.readFileSync(noteFile, 'utf8') : '';
|
||||
process.stdout.write(JSON.stringify({
|
||||
productId: process.env.PRODUCT_ID,
|
||||
kind: 'BUNDLE',
|
||||
@@ -164,7 +251,7 @@ jobs:
|
||||
attachmentId: process.env.ATTACHMENT_ID,
|
||||
artifactSize: Number(process.env.ARTIFACT_SIZE),
|
||||
sha256: process.env.SHA256,
|
||||
note: 'CI 构建 ${{ github.sha }}'.slice(0, 500)
|
||||
note
|
||||
}));
|
||||
")
|
||||
response=$(curl -sS -X POST "$API_BASE_URL/app/release/create" \
|
||||
@@ -207,6 +294,13 @@ jobs:
|
||||
echo "需要上线时调用 /app/release/publish?releaseId=${{ steps.create.outputs.release_id }}"
|
||||
fi
|
||||
echo "-----"
|
||||
echo "变更说明(写入 App 更新日志):"
|
||||
if [ -s release-note.txt ]; then
|
||||
cat release-note.txt
|
||||
else
|
||||
echo "(空)CHANGELOG.md 中没有 v${{ steps.version.outputs.version }} 一节,本次发布不带更新说明"
|
||||
fi
|
||||
echo "-----"
|
||||
echo "热更兼容最低原生版本:${{ vars.APP_MIN_VERSION_CODE }}"
|
||||
echo "只有原生壳升级(增删原生插件)时才需要提高这个值,纯 JS 改动不用管"
|
||||
echo "本次产物大小:${{ steps.bundle.outputs.size }} 字节"
|
||||
|
||||
@@ -131,6 +131,8 @@ dist
|
||||
dist-ssr
|
||||
coverage
|
||||
*.local
|
||||
# CI 从 CHANGELOG.md 提取的中间产物,发版 job 内生成
|
||||
release-note.txt
|
||||
|
||||
# ---> WorkBuddy 本地工作目录
|
||||
# 内含 AI 工作记忆与每日日志:写明本机绝对路径与调试上下文,且每次会话都在追加,
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# 更新日志
|
||||
|
||||
<!--
|
||||
本文件用于 App 内的「版本更新」展示。
|
||||
|
||||
CI 规则(.gitea/workflows/release.yml):
|
||||
1. 按 `## v<版本号>` 精确匹配 package.json 里的 version,例如 `## v1.3.0`
|
||||
2. 提取该节的全部内容(到下一个 `## ` 为止),写入 app_release.note
|
||||
3. 最多 480 字,超出按整行截断,不切半句;缺失该节时不阻断发版,只打印警告
|
||||
|
||||
写作约定:
|
||||
1. 只写用户能感知的变化:新增功能、行为变更、影响使用的修复。
|
||||
重构、依赖升级、CI 调整、内部样式整理不用写
|
||||
2. 推荐用 `- ` 列表,一条一行。也支持段落、`###` 小标题、加粗,
|
||||
前端按 markdown 渲染;HTML 标签会被转义成文本显示
|
||||
3. 整节控制在 480 字以内,超出部分会被丢掉
|
||||
4. 面向店员,不写文件路径、组件名、接口名
|
||||
5. 已发布的段落不可修改:note 是发版瞬间的快照,改文件不会影响线上,
|
||||
需要更正请发补丁版本
|
||||
-->
|
||||
|
||||
## v1.3.1
|
||||
|
||||
### 新增
|
||||
|
||||
- 系统更新日志
|
||||
- 回收兑换单支持快速履约
|
||||
- 新增回收兑换单时,选择了客户、回收物后显示客户可用额度
|
||||
- 库存日历的流水增加汇总,支持切换单位
|
||||
- 客户回收物列表
|
||||
|
||||
### 调整
|
||||
|
||||
- 更新提醒不再是按钮,而是通知栏
|
||||
- 回收兑换单的详情不再显示无意义的金额
|
||||
|
||||
### 修复
|
||||
|
||||
- 兑换模板列表没有显示兑换物照片
|
||||
- 登录/注册页在平板模式下用户协议窗口过小
|
||||
- 部分页面样式
|
||||
Vendored
-1
@@ -45,7 +45,6 @@ declare module 'vue' {
|
||||
SegmentedSlider: typeof import('./src/components/SegmentedSlider.vue')['default']
|
||||
StoreRemoveDialog: typeof import('./src/components/StoreRemoveDialog.vue')['default']
|
||||
TagSelector: typeof import('./src/components/TagSelector.vue')['default']
|
||||
TAvatar: typeof import('tdesign-mobile-vue')['Avatar']
|
||||
TBadge: typeof import('tdesign-mobile-vue')['Badge']
|
||||
TButton: typeof import('tdesign-mobile-vue')['Button']
|
||||
TCalendar: typeof import('tdesign-mobile-vue')['Calendar']
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "gao-customer-h5",
|
||||
"private": true,
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
@@ -30,7 +30,7 @@
|
||||
"less": "^4.3.0",
|
||||
"pinia": "^3.0.2",
|
||||
"tdesign-mobile-vue": "^1.17.1",
|
||||
"timi-tdesign-mobile": "^1.1.1",
|
||||
"timi-tdesign-mobile": "^1.2.0",
|
||||
"timi-ts": "^1.0.0",
|
||||
"timi-web": "^1.0.2",
|
||||
"timi-web-api": "^1.0.2",
|
||||
|
||||
Generated
+5
-5
@@ -47,8 +47,8 @@ importers:
|
||||
specifier: ^1.17.1
|
||||
version: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
|
||||
timi-tdesign-mobile:
|
||||
specifier: ^1.1.1
|
||||
version: 1.1.1(@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))
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.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:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
@@ -2748,8 +2748,8 @@ packages:
|
||||
through2@4.0.2:
|
||||
resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==}
|
||||
|
||||
timi-tdesign-mobile@1.1.1:
|
||||
resolution: {integrity: sha512-aR6SKu8zVbaqHRJHRtria3amvp9UKS6jTT99FNei38ZrP1sJDBsvCoQmWi0xzUD3F/wkGnSECWWrJQToqso6PQ==}
|
||||
timi-tdesign-mobile@1.2.0:
|
||||
resolution: {integrity: sha512-FW9LyZlh+aSjaG3tEXBf3+YYmm+OruYVH+atQMFmlCT33q3e6Gt0rr6n6d4vLH5n0tzyidlAJ0hmrvKspKKDdw==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
peerDependencies:
|
||||
vue: ^3.5.0
|
||||
@@ -5849,7 +5849,7 @@ snapshots:
|
||||
dependencies:
|
||||
readable-stream: 3.6.2
|
||||
|
||||
timi-tdesign-mobile@1.1.1(@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.2.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:
|
||||
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))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { axios } from "timi-web-api";
|
||||
import type { AppUpdateNotesQuery, AppUpdateNotesResult } from "@/types/AppUpdate";
|
||||
|
||||
const URI = "/app/update";
|
||||
|
||||
/**
|
||||
* 查询更新日志
|
||||
*
|
||||
* 区间为「当前版本 → 通道当前版本」,与灰度无关,免登录态
|
||||
*
|
||||
* @param query 查询参数,versionName 传当前运行的 Web 包版本
|
||||
* @returns 变更说明列表,按版本号从新到旧
|
||||
*/
|
||||
async function notes(query: AppUpdateNotesQuery): Promise<AppUpdateNotesResult> {
|
||||
const { appId, versionName, versionCode, platform, channel } = query;
|
||||
// 后端按 Capgo 插件的上报协议接收下划线字段,只在这一层转换
|
||||
/* eslint-disable camelcase */
|
||||
const payload = {
|
||||
app_id: appId,
|
||||
version_name: versionName,
|
||||
version_code: versionCode,
|
||||
platform,
|
||||
channel
|
||||
};
|
||||
/* eslint-enable camelcase */
|
||||
return await axios.post(`${URI}/notes`, payload);
|
||||
}
|
||||
|
||||
export default {
|
||||
notes
|
||||
};
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
OrderTransaction,
|
||||
RecycleAccount,
|
||||
RecycleAccountAdjustRequest,
|
||||
RecycleCustomerAccountPage,
|
||||
RecycleExchange,
|
||||
RecycleExchangeCreateRequest,
|
||||
RecycleExchangeDetail,
|
||||
@@ -117,6 +118,18 @@ async function accountList(customerId: string): Promise<RecycleAccount[]> {
|
||||
});
|
||||
}
|
||||
|
||||
/** 按客户分页查询有余额的回收物及全门店汇总。 */
|
||||
async function accountCustomers(offset: number, limit: number, recycleItemId?: string, keyword?: string, customerIds?: string[]): Promise<RecycleCustomerAccountPage> {
|
||||
return await axios.post(`${ACCOUNT_URI}/customers`, undefined, {
|
||||
params: { storeId: getCurrentStoreId() || undefined, offset, limit, recycleItemId: recycleItemId || undefined, keyword: keyword || undefined, customerIds: customerIds?.length ? customerIds.join(",") : undefined }
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取额度查询可用的回收物选项。 */
|
||||
async function accountItems(): Promise<RecycleItem[]> {
|
||||
return await axios.post(`${ACCOUNT_URI}/items`, undefined, { params: { storeId: getCurrentStoreId() || undefined } });
|
||||
}
|
||||
|
||||
/** 额度流水,服务端当前最多返回 100 条。 */
|
||||
async function accountLedger(customerId: string): Promise<RecycleLedger[]> {
|
||||
return await axios.post(`${ACCOUNT_URI}/ledger`, undefined, {
|
||||
@@ -244,6 +257,8 @@ export default {
|
||||
create,
|
||||
detail,
|
||||
accountList,
|
||||
accountCustomers,
|
||||
accountItems,
|
||||
accountLedger,
|
||||
accountAdjust,
|
||||
yieldList,
|
||||
|
||||
@@ -6,11 +6,23 @@ import { ref } from "vue";
|
||||
/** 自动更新的存储键 */
|
||||
export const AUTO_UPDATE_KEY = "app.autoUpdate";
|
||||
|
||||
/** Capacitor appId,与 capacitor.config.ts 保持一致 */
|
||||
export const APP_ID = "com.imyeyu.gao.customer";
|
||||
|
||||
/**
|
||||
* 服务端下发的更新信息
|
||||
*
|
||||
* 在插件协议基础上多一个 note:更新说明由后端附加,插件不识别但会原样透传
|
||||
*/
|
||||
export type UpdateInfo = LatestVersion & {
|
||||
note?: string;
|
||||
};
|
||||
|
||||
// 模块级状态,页面与启动逻辑共享同一份
|
||||
const supported = Capacitor.isNativePlatform();
|
||||
const currentVersion = ref("");
|
||||
const nativeVersion = ref("");
|
||||
const latest = ref<LatestVersion | null>(null);
|
||||
const latest = ref<UpdateInfo | null>(null);
|
||||
const checking = ref(false);
|
||||
const downloading = ref(false);
|
||||
const percent = ref(0);
|
||||
@@ -34,7 +46,7 @@ async function loadCurrent(): Promise<void> {
|
||||
}
|
||||
|
||||
/** 查询服务端最新版本 */
|
||||
async function check(): Promise<LatestVersion | null> {
|
||||
async function check(): Promise<UpdateInfo | null> {
|
||||
if (!supported) {
|
||||
error.value = "仅在 App 内可用";
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div class="tui-page-layout tui-navbar customer-recycle-list">
|
||||
<t-navbar fixed :z-index="20" title="客户回收物" left-arrow @left-click="$router.back()" />
|
||||
<main v-can="permissionCodes.recycleAccount.read" class="tui-page-content scroll column">
|
||||
<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.trim="keyword" type="search" borderless clearable placeholder="搜索客户姓名、拼音、编码">
|
||||
<template #suffix-icon>
|
||||
<t-button size="extra-small" theme="primary" variant="outline" :content="customerIds.length ? `已选 ${customerIds.length} 人` : '选择客户'" @click.stop="customerVisible = true" />
|
||||
</template>
|
||||
</t-input>
|
||||
<t-dropdown-menu ref="filterMenuRef" class="menus">
|
||||
<t-dropdown-item :label="selectedName" :options="[]" @open="openItemPicker" />
|
||||
</t-dropdown-menu>
|
||||
</div>
|
||||
<t-cell-group theme="card">
|
||||
<t-cell title="汇总">
|
||||
<template v-if="selectedId" #note>
|
||||
<t-button size="extra-small" variant="outline" content="清除" @click="clearItem" />
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="tags">
|
||||
<t-tag v-for="item in displayedTotals" :key="item.recycleItemId" theme="primary"
|
||||
variant="light"
|
||||
:content="accountText(item)" />
|
||||
<span v-if="!displayedTotals.length" v-text="loading ? '正在加载' : '暂无回收物'" />
|
||||
</div>
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<t-cell-group v-if="items.length" theme="card" class="fix-last-cell-line">
|
||||
<customer-cell v-for="row in items" :key="row.customer.id" :customer="row.customer" arrow hover
|
||||
@click="openCustomer(row.customer)">
|
||||
<template #description>
|
||||
<div class="tags">
|
||||
<t-tag v-for="account in row.accounts" :key="account.recycleItemId" theme="primary"
|
||||
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} 位客户` : '上拉加载更多'" />
|
||||
</t-pull-down-refresh>
|
||||
</main>
|
||||
<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" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import RecycleAPI from "@/api/RecycleAPI";
|
||||
import RecycleItemPickerPopup from "@/pages/recycle/components/RecycleItemPickerPopup.vue";
|
||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
import type { RecycleAccount, RecycleCustomerAccountPage, RecycleItem } from "@/types/Recycle";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getRecycleQuantityText } from "@/utils/recycle";
|
||||
|
||||
defineOptions({ name: "CustomerRecycleList" });
|
||||
const router = useRouter();
|
||||
const items = ref<RecycleCustomerAccountPage["list"]>([]);
|
||||
const totals = ref<RecycleAccount[]>([]);
|
||||
const selectedId = ref("");
|
||||
const selectedItem = ref<RecycleItem>();
|
||||
const filterVisible = ref(false);
|
||||
const customerIds = ref<string[]>([]);
|
||||
const customerVisible = ref(false);
|
||||
const filterMenuRef = ref<{ collapseMenu: () => void }>();
|
||||
const keyword = ref("");
|
||||
let searchTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
const loading = ref(false);
|
||||
const refreshing = ref(false);
|
||||
const noMore = ref(false);
|
||||
const total = ref(0);
|
||||
let version = 0;
|
||||
const selectedName = computed(() => selectedItem.value?.name || "全部回收物");
|
||||
const displayedTotals = computed(() => selectedId.value ? totals.value.filter(item => item.recycleItemId === selectedId.value) : totals.value);
|
||||
|
||||
function accountText(account: RecycleAccount): string {
|
||||
return `${account.recycleName || "未命名回收物"} ${getRecycleQuantityText(account.balance, account.recycleUnit)}`;
|
||||
}
|
||||
|
||||
async function fetchPage(reset: boolean): Promise<void> {
|
||||
if (!reset && (loading.value || noMore.value)) return;
|
||||
const token = reset ? ++version : version;
|
||||
const offset = reset ? 0 : items.value.length;
|
||||
if (reset) {
|
||||
items.value = [];
|
||||
noMore.value = false;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await RecycleAPI.accountCustomers(offset, 20, selectedId.value, keyword.value, customerIds.value);
|
||||
if (token !== version) return;
|
||||
items.value = reset ? result.list : [...items.value, ...result.list];
|
||||
totals.value = result.totals;
|
||||
total.value = result.total;
|
||||
noMore.value = result.list.length < 20 || !(items.value.length < total.value);
|
||||
} catch (error) {
|
||||
if (token === version) Message.error(getErrorMessage(error, "客户回收物加载失败"));
|
||||
} finally {
|
||||
if (token === version) {
|
||||
loading.value = false;
|
||||
refreshing.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function reload(): Promise<void> {
|
||||
await fetchPage(true);
|
||||
}
|
||||
|
||||
async function loadMore(): Promise<void> {
|
||||
await fetchPage(false);
|
||||
}
|
||||
|
||||
async function openItemPicker(): Promise<void> {
|
||||
filterVisible.value = true;
|
||||
await nextTick();
|
||||
filterMenuRef.value?.collapseMenu();
|
||||
}
|
||||
|
||||
async function updateItem(id: string): Promise<void> {
|
||||
if (selectedId.value === id) return;
|
||||
selectedId.value = id;
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
await reload();
|
||||
}
|
||||
|
||||
async function selectItem(item: RecycleItem): Promise<void> {
|
||||
selectedItem.value = item;
|
||||
await updateItem(item.id || "");
|
||||
}
|
||||
|
||||
async function clearItem(): Promise<void> {
|
||||
selectedItem.value = undefined;
|
||||
await updateItem("");
|
||||
}
|
||||
|
||||
watch(customerIds, async () => {
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
await reload();
|
||||
});
|
||||
|
||||
watch(keyword, () => {
|
||||
version++;
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout(() => {
|
||||
void reload();
|
||||
}, 300);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
});
|
||||
|
||||
async function openCustomer(customer: Customer): Promise<void> {
|
||||
if (customer.id) await router.push({ name: "RecycleAccount", query: { customerId: customer.id } });
|
||||
}
|
||||
|
||||
let wasDeactivated = false;
|
||||
onMounted(reload);
|
||||
onDeactivated(() => { wasDeactivated = true; });
|
||||
onActivated(async () => {
|
||||
if (!wasDeactivated) return;
|
||||
wasDeactivated = false;
|
||||
await reload();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.customer-recycle-list {
|
||||
.tags {
|
||||
gap: .375rem;
|
||||
display: flex;
|
||||
padding: .25rem 0;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -33,7 +33,7 @@
|
||||
<strong v-if="order.orderType === 'PACKAGE'" class="package-name" v-text="order.packageName || '未命名套餐'" />
|
||||
</div>
|
||||
</div>
|
||||
<span class="red text-bold keep-text" v-text="`¥${formatPackageAmount(order.saleAmount)}`" />
|
||||
<span v-if="order.orderType !== 'RECYCLE'" class="red text-bold keep-text" v-text="`¥${formatPackageAmount(order.saleAmount)}`" />
|
||||
</div>
|
||||
</template>
|
||||
<template #description>
|
||||
@@ -53,7 +53,18 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row payment">
|
||||
<div v-if="order.orderType === 'RECYCLE'" class="row payment">
|
||||
<span class="label">回收物</span>
|
||||
<div class="tags">
|
||||
<t-tag
|
||||
size="small"
|
||||
theme="primary"
|
||||
variant="light"
|
||||
:content="`${order.recycleItemName || '回收物'}:已核销 ${order.recycleVerifiedQuantity ?? 0} / 应回收 ${order.recycleRequiredQuantity ?? 0} ${order.recycleUnit || ''}`"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="row payment">
|
||||
<span class="label">收款</span>
|
||||
<div class="tags">
|
||||
<t-tag
|
||||
|
||||
@@ -36,10 +36,16 @@
|
||||
</template>
|
||||
<template #day="{ day }">
|
||||
<template v-if="selection">
|
||||
<span v-if="daily(day)?.inQuantity" class="quantity in"
|
||||
v-text="formatQuantity(daily(day)?.inQuantity)" />
|
||||
<span v-if="daily(day)?.outQuantity" class="quantity out"
|
||||
v-text="formatQuantity(daily(day)?.outQuantity)" />
|
||||
<span
|
||||
v-if="daily(day)?.inQuantity"
|
||||
class="quantity in"
|
||||
v-text="formatQuantity(daily(day)?.inQuantity)"
|
||||
/>
|
||||
<span
|
||||
v-if="daily(day)?.outQuantity"
|
||||
class="quantity out"
|
||||
v-text="formatQuantity(daily(day)?.outQuantity)"
|
||||
/>
|
||||
</template>
|
||||
<span class="movement-bar" :style="movementStyle(day)" />
|
||||
</template>
|
||||
@@ -51,82 +57,36 @@
|
||||
v-model:visible="selectorVisible"
|
||||
@select="selectProduct"
|
||||
/>
|
||||
<bottom-popup
|
||||
v-model="visible"
|
||||
:title="`${selectedDate} 库存流水`"
|
||||
left-button-text="关闭"
|
||||
@left-button-click="visible = false"
|
||||
>
|
||||
<div class="records">
|
||||
<template v-if="canReadRecords">
|
||||
<div class="directions">
|
||||
<t-segmented block :value="direction" :options="directionOptions" @change="changeDirection" />
|
||||
</div>
|
||||
<div class="record-list">
|
||||
<t-cell-group v-if="records.length" class="list empty-cell-title-margin" theme="card">
|
||||
<t-cell v-for="record in records" :key="record.id" class="item">
|
||||
<template #leftIcon>
|
||||
<t-image v-if="getCustomerPhotoURL(record.customer, 64)" :src="getCustomerPhotoURL(record.customer, 64)"
|
||||
:alt="getCustomerText(record)" fit="cover" class="avatar" />
|
||||
<div v-else-if="record.customer" class="avatar fallback" v-text="getCustomerText(record).slice(0, 1)" />
|
||||
<t-image v-else-if="record.operator" :src="getOperatorAvatar(record)" :alt="getOperatorText(record)" fit="cover" class="avatar" />
|
||||
<span v-else class="icon" :class="getDeltaClass(record.onHandDelta)"><t-icon name="history" size="1.25rem" /></span>
|
||||
</template>
|
||||
<template #title>
|
||||
<div class="record-title">
|
||||
<span v-if="record.customer" class="actor" v-text="getCustomerText(record)" />
|
||||
<span v-else-if="record.operator" class="actor" v-text="getOperatorText(record)" />
|
||||
<strong class="operation" :class="getOperationClass(record.operationType)" v-text="getStockOperationText(record.operationType)" />
|
||||
<strong class="product-name" v-text="record.productNameSnapshot || '未命名产品'" />
|
||||
<t-tag v-if="record.skuNameSnapshot && record.productNameSnapshot !== record.skuNameSnapshot"
|
||||
size="small" :content="record.skuNameSnapshot" />
|
||||
<span v-if="record.quantity !== undefined && record.quantity !== null && record.quantity !== ''"
|
||||
class="record-quantity" v-text="`${getProductQuantityText(record.quantity)} ${record.unitSnapshot || ''}`" />
|
||||
</div>
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="description">
|
||||
<time-label :timestamp="record.occurredAt" underline />
|
||||
<div><span class="delta" :class="getDeltaClass(record.onHandDelta)" v-text="getDeltaText(record.onHandDelta)" /></div>
|
||||
</div>
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<t-empty v-else-if="!recordsLoading" description="当天暂无流水" />
|
||||
<t-button v-if="!noMore" block variant="text" :loading="recordsLoading" @click="loadRecords">加载更多
|
||||
</t-button>
|
||||
</div>
|
||||
</template>
|
||||
<t-empty v-else description="暂无库存流水查看权限" />
|
||||
</div>
|
||||
</bottom-popup>
|
||||
<product-stock-calendar-records-popup
|
||||
ref="recordsPopup"
|
||||
v-model:unit-index="unitIndex"
|
||||
:store-id="storeId"
|
||||
:selection="selection"
|
||||
:summary="selectedSummary"
|
||||
:summary-loading="loading"
|
||||
@date-change="selectedDate = $event"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import { TimeLabel } from "timi-web";
|
||||
import { UserAPI, useUserStore } from "timi-web-api";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import GaoProductChartAPI from "@/api/GaoProductChartAPI";
|
||||
import GaoProductSkuChartAPI from "@/api/GaoProductSkuChartAPI";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
import StoreChartAPI from "@/api/StoreChartAPI";
|
||||
import MonthCalendar from "@/components/monthCalendar/MonthCalendar.vue";
|
||||
import ProductSelectPopup from "@/components/productSelector/ProductSelectPopup.vue";
|
||||
import ProductStockCalendarRecordsPopup from "@/pages/product/component/ProductStockCalendarRecordsPopup.vue";
|
||||
import { buildMonthCalendarDays, type MonthCalendarDay } from "@/components/monthCalendar/monthCalendar";
|
||||
import type { GaoProductStockMovementDailyStatView } from "@/types/GaoChart";
|
||||
import type { ProductSelection, StockRecord, StockRecordDirection } from "@/types/Product";
|
||||
import type { ProductSelection } from "@/types/Product";
|
||||
import type { ProductSkuSelectionValue } from "@/types/ProductSkuSelection";
|
||||
import { getProductQuantityText, getStockOperationText } from "@/utils/product";
|
||||
import { buildFallbackAvatar } from "@/utils/avatar";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||
|
||||
const props = defineProps<{ storeId: string }>();
|
||||
const userStore = useUserStore();
|
||||
const canReadRecords = computed(() => userStore.hasPermissions(permissionCodes.productStock.read));
|
||||
const canReadProducts = computed(() => userStore.hasPermissions(permissionCodes.product.read));
|
||||
const selectorVisible = ref(false);
|
||||
const selectedProductSku = ref<ProductSkuSelectionValue>();
|
||||
@@ -145,32 +105,6 @@ const unitIndex = ref(0);
|
||||
const units = computed(() => selection.value?.sku.unitList || []);
|
||||
const currentUnit = computed(() => units.value[unitIndex.value]);
|
||||
|
||||
function getCustomerText(record: StockRecord): string {
|
||||
return record.customer?.name || record.customer?.code || "未知客户";
|
||||
}
|
||||
|
||||
function getOperatorText(record: StockRecord): string {
|
||||
return record.operator?.nick || record.operator?.name || "未知操作人";
|
||||
}
|
||||
function getOperatorAvatar(record: StockRecord): string {
|
||||
return UserAPI.getAvatarURL(record.operator) || buildFallbackAvatar(getOperatorText(record), "#0f766e");
|
||||
}
|
||||
function getOperationClass(type?: string): string {
|
||||
return ({
|
||||
INITIAL_IN: "initial-in", MANUAL_IN: "manual-in", MANUAL_OUT: "manual-out", MANUAL_REVOKE: "manual-revoke",
|
||||
ORDER_RESERVE: "order-reserve", ORDER_RELEASE: "order-release", ORDER_OUT: "order-out", ORDER_REVOKE: "order-revoke",
|
||||
ORDER_RETURN_IN: "return-in", POINT_REDEMPTION_OUT: "manual-out", POINT_REDEMPTION_RETURN_IN: "return-in",
|
||||
STOCKTAKE_GAIN: "stocktake-gain", STOCKTAKE_LOSS: "stocktake-loss"
|
||||
} as Record<string, string>)[type || ""] || "unknown";
|
||||
}
|
||||
function getDeltaClass(value?: number | string): string {
|
||||
const amount = Number(value || 0);
|
||||
return 0 < amount ? "positive" : amount < 0 ? "negative" : "gray";
|
||||
}
|
||||
function getDeltaText(value?: number | string): string {
|
||||
const amount = Number(value || 0);
|
||||
return `${0 < amount ? "+" : amount < 0 ? "-" : ""}${getProductQuantityText(String(value || "0").replace(/^-/, ""))}`;
|
||||
}
|
||||
function nextUnit(): void {
|
||||
unitIndex.value = (unitIndex.value + 1) % units.value.length;
|
||||
}
|
||||
@@ -186,7 +120,7 @@ function movementStyle(day: MonthCalendarDay): Record<string, string> {
|
||||
const outgoing = Math.abs(Number(item?.outQuantity) || 0);
|
||||
if (!incoming && !outgoing) return { background: "var(--td-component-stroke)" };
|
||||
const percentage = incoming / (incoming + outgoing) * 100;
|
||||
return { background: `linear-gradient(90deg, var(--tui-green) ${percentage}%, var(--tui-red) ${percentage}%)` };
|
||||
return { background: `linear-gradient(90deg, var(--td-success-color-4) ${percentage}%, var(--td-error-color-4) ${percentage}%)` };
|
||||
}
|
||||
|
||||
function selectProduct(value: ProductSelection): void {
|
||||
@@ -246,72 +180,14 @@ watch([month, () => props.storeId, skuId], async () => {
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
const visible = ref(false);
|
||||
const recordsPopup = ref<InstanceType<typeof ProductStockCalendarRecordsPopup>>();
|
||||
const selectedDate = ref("");
|
||||
const selectedStart = ref(0);
|
||||
const direction = ref<StockRecordDirection>("IN");
|
||||
const directionOptions = [{ label: "入库", value: "IN" }, { label: "出库", value: "OUT" }];
|
||||
async function changeDirection(event: { value: string | number }): Promise<void> {
|
||||
if (event.value === "IN" || event.value === "OUT") await selectDirection(event.value);
|
||||
}
|
||||
const records = ref<StockRecord[]>([]);
|
||||
const recordsLoading = ref(false);
|
||||
const noMore = ref(false);
|
||||
let page = 0;
|
||||
let recordToken = 0;
|
||||
const selectedSummary = computed(() => stats.value.find(item => item.dateValue === Number(selectedDate.value.replaceAll("-", ""))));
|
||||
|
||||
async function openDay(day: MonthCalendarDay): Promise<void> {
|
||||
const [year, monthNumber, dateNumber] = day.dateText.split("-").map(Number);
|
||||
const date = new Date(year, monthNumber - 1, dateNumber);
|
||||
selectedStart.value = date.getTime();
|
||||
selectedDate.value = day.dateText;
|
||||
visible.value = true;
|
||||
if (canReadRecords.value) await selectDirection("IN");
|
||||
await recordsPopup.value?.openDay(day);
|
||||
}
|
||||
|
||||
async function selectDirection(value: StockRecordDirection): Promise<void> {
|
||||
direction.value = value;
|
||||
recordToken++;
|
||||
records.value = [];
|
||||
page = 0;
|
||||
noMore.value = false;
|
||||
recordsLoading.value = false;
|
||||
await loadRecords();
|
||||
}
|
||||
|
||||
async function loadRecords(): Promise<void> {
|
||||
if (recordsLoading.value || noMore.value) return;
|
||||
const token = ++recordToken;
|
||||
recordsLoading.value = true;
|
||||
try {
|
||||
const start = new Date(selectedStart.value);
|
||||
const endAt = new Date(start.getFullYear(), start.getMonth(), start.getDate() + 1).getTime() - 1;
|
||||
const result = await ProductAPI.recordList({
|
||||
storeId: props.storeId,
|
||||
productId: selection.value?.product.id || undefined,
|
||||
skuId: skuId.value || undefined,
|
||||
beginAt: selectedStart.value,
|
||||
endAt,
|
||||
direction: direction.value,
|
||||
index: page,
|
||||
size: 15
|
||||
});
|
||||
if (token !== recordToken) return;
|
||||
const list = result.list || [];
|
||||
records.value.push(...list);
|
||||
page++;
|
||||
noMore.value = list.length < 15 || !(records.value.length < (result.total || 0));
|
||||
} catch (error) {
|
||||
if (token === recordToken) Message.error(getErrorMessage(error, "库存流水加载失败"));
|
||||
} finally {
|
||||
if (token === recordToken) recordsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch([() => props.storeId, skuId], () => {
|
||||
visible.value = false;
|
||||
recordToken++;
|
||||
});
|
||||
watch(() => props.storeId, () => {
|
||||
selectorVisible.value = false;
|
||||
clearSelection();
|
||||
@@ -363,76 +239,4 @@ watch(() => props.storeId, () => {
|
||||
|
||||
}
|
||||
|
||||
.records {
|
||||
height: 60vh;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
|
||||
.directions {
|
||||
padding: .75rem;
|
||||
min-width: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.record-list {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 3.5rem;
|
||||
height: 3.5rem;
|
||||
}
|
||||
|
||||
.list { margin: 0; }
|
||||
.item { padding: .625rem; min-width: 0; }
|
||||
.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; }
|
||||
.record-title {
|
||||
gap: .25rem;
|
||||
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, .record-quantity { flex: 0 0 auto; }
|
||||
.operation {
|
||||
color: var(--operation-color, var(--td-text-color-secondary));
|
||||
&.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; }
|
||||
&.return-in { --operation-color: #15803d; }
|
||||
&.stocktake-gain { --operation-color: #0f766e; }
|
||||
&.stocktake-loss { --operation-color: #a16207; }
|
||||
}
|
||||
.product-name { overflow: hidden; flex: 0 1 auto; text-overflow: ellipsis; }
|
||||
.record-quantity { color: var(--td-text-color-secondary); }
|
||||
}
|
||||
.description { gap: .5rem; display: flex; font-size: .75rem; align-items: center; justify-content: space-between; }
|
||||
.delta { font-size: 1.25rem; }
|
||||
.positive { color: var(--td-success-color); }
|
||||
.negative { color: var(--td-error-color); }
|
||||
}
|
||||
:global(html.theme-dark) .records .operation {
|
||||
&.initial-in { --operation-color: #93c5fd; }
|
||||
&.manual-in, &.return-in { --operation-color: #86efac; }
|
||||
&.manual-out { --operation-color: #fdba74; }
|
||||
&.manual-revoke { --operation-color: #fda4af; }
|
||||
&.order-reserve { --operation-color: #c4b5fd; }
|
||||
&.order-release { --operation-color: #67e8f9; }
|
||||
&.order-out { --operation-color: #fca5a5; }
|
||||
&.order-revoke { --operation-color: #a5b4fc; }
|
||||
&.stocktake-gain { --operation-color: #5eead4; }
|
||||
&.stocktake-loss { --operation-color: #fcd34d; }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,437 @@
|
||||
<template>
|
||||
<bottom-popup
|
||||
v-model="visible"
|
||||
:title="`${selectedDate} 库存流水`"
|
||||
height="80vh"
|
||||
left-button-text="关闭"
|
||||
@left-button-click="visible = false"
|
||||
>
|
||||
<div class="records">
|
||||
<template v-if="canReadRecords">
|
||||
<div class="directions">
|
||||
<t-segmented :value="direction" :options="directionOptions" @change="changeDirection" />
|
||||
<div v-if="selection" class="summary">
|
||||
<span v-if="summaryLoading">汇总加载中</span>
|
||||
<span v-else :class="direction === 'IN' ? 'in' : 'out'"
|
||||
v-text="`合计 ${formatQuantity(direction === 'IN' ? summary?.inQuantity : summary?.outQuantity)} ${currentUnit?.name || ''}`" />
|
||||
<t-button v-if="1 < units.length" size="extra-small" variant="outline" :content="`单位:${currentUnit?.name}`" @click="nextUnit" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="record-list">
|
||||
<t-cell-group v-if="records.length" class="list empty-cell-title-margin" theme="card">
|
||||
<t-cell v-for="record in records" :key="record.id" class="item">
|
||||
<template #leftIcon>
|
||||
<t-image
|
||||
v-if="getCustomerPhotoURL(record.customer, 64)"
|
||||
:src="getCustomerPhotoURL(record.customer, 64)"
|
||||
:alt="getCustomerText(record)"
|
||||
fit="cover"
|
||||
class="avatar"
|
||||
/>
|
||||
<div
|
||||
v-else-if="record.customer"
|
||||
class="avatar fallback"
|
||||
v-text="getCustomerText(record).slice(0, 1)"
|
||||
/>
|
||||
<t-image
|
||||
v-else-if="record.operator"
|
||||
:src="getOperatorAvatar(record)"
|
||||
:alt="getOperatorText(record)"
|
||||
fit="cover"
|
||||
class="avatar"
|
||||
/>
|
||||
<span
|
||||
v-else
|
||||
class="icon"
|
||||
:class="getDeltaClass(record.onHandDelta)"
|
||||
>
|
||||
<t-icon name="history" size="1.25rem" />
|
||||
</span>
|
||||
</template>
|
||||
<template #title>
|
||||
<div class="record-title">
|
||||
<span v-if="record.customer" class="actor" v-text="getCustomerText(record)" />
|
||||
<span v-else-if="record.operator" class="actor"
|
||||
v-text="getOperatorText(record)" />
|
||||
<strong class="operation" :class="getOperationClass(record.operationType)"
|
||||
v-text="getStockOperationText(record.operationType)" />
|
||||
<strong class="product-name"
|
||||
v-text="record.productNameSnapshot || '未命名产品'" />
|
||||
<t-tag
|
||||
v-if="record.skuNameSnapshot && record.productNameSnapshot !== record.skuNameSnapshot"
|
||||
size="small" :content="record.skuNameSnapshot" />
|
||||
<span
|
||||
v-if="record.quantity !== undefined && record.quantity !== null && record.quantity !== ''"
|
||||
class="record-quantity"
|
||||
v-text="`${getProductQuantityText(record.quantity)} ${record.unitSnapshot || ''}`" />
|
||||
</div>
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="description">
|
||||
<time-label :timestamp="record.occurredAt" underline />
|
||||
<div><span class="delta" :class="getDeltaClass(record.onHandDelta)"
|
||||
v-text="getDeltaText(record.onHandDelta)" /></div>
|
||||
</div>
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<t-empty v-else-if="!recordsLoading" description="当天暂无流水" />
|
||||
<t-button v-if="!noMore" block variant="text" :loading="recordsLoading" @click="loadRecords">
|
||||
加载更多
|
||||
</t-button>
|
||||
</div>
|
||||
</template>
|
||||
<t-empty v-else description="暂无库存流水查看权限" />
|
||||
</div>
|
||||
</bottom-popup>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import { TimeLabel } from "timi-web";
|
||||
import { UserAPI, useUserStore } from "timi-web-api";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
import type { MonthCalendarDay } from "@/components/monthCalendar/monthCalendar";
|
||||
import type { GaoProductStockMovementDailyStatView } from "@/types/GaoChart";
|
||||
import type { ProductSelection, StockRecord, StockRecordDirection } from "@/types/Product";
|
||||
import { getProductQuantityText, getStockOperationText } from "@/utils/product";
|
||||
import { buildFallbackAvatar } from "@/utils/avatar";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||
|
||||
const props = defineProps<{ storeId: string; selection?: ProductSelection; summary?: GaoProductStockMovementDailyStatView; summaryLoading: boolean }>();
|
||||
const emit = defineEmits<{ "date-change": [date: string] }>();
|
||||
const unitIndex = defineModel<number>("unitIndex", { required: true });
|
||||
const userStore = useUserStore();
|
||||
const canReadRecords = computed(() => userStore.hasPermissions(permissionCodes.productStock.read));
|
||||
const skuId = computed(() => props.selection?.sku.id || "");
|
||||
const units = computed(() => props.selection?.sku.unitList || []);
|
||||
const currentUnit = computed(() => units.value[unitIndex.value]);
|
||||
|
||||
function nextUnit(): void {
|
||||
unitIndex.value = (unitIndex.value + 1) % units.value.length;
|
||||
}
|
||||
|
||||
function formatQuantity(value: number | string | undefined): string {
|
||||
const ratio = Number(currentUnit.value?.baseQuantityPerUnit) || 1;
|
||||
return String(Number((Number(value || 0) / ratio).toFixed(4)));
|
||||
}
|
||||
|
||||
function getCustomerText(record: StockRecord): string {
|
||||
return record.customer?.name || record.customer?.code || "未知客户";
|
||||
}
|
||||
|
||||
function getOperatorText(record: StockRecord): string {
|
||||
return record.operator?.nick || record.operator?.name || "未知操作人";
|
||||
}
|
||||
|
||||
function getOperatorAvatar(record: StockRecord): string {
|
||||
return UserAPI.getAvatarURL(record.operator) || buildFallbackAvatar(getOperatorText(record), "#0f766e");
|
||||
}
|
||||
|
||||
function getOperationClass(type?: string): string {
|
||||
return ({
|
||||
INITIAL_IN: "initial-in",
|
||||
MANUAL_IN: "manual-in",
|
||||
MANUAL_OUT: "manual-out",
|
||||
MANUAL_REVOKE: "manual-revoke",
|
||||
ORDER_RESERVE: "order-reserve",
|
||||
ORDER_RELEASE: "order-release",
|
||||
ORDER_OUT: "order-out",
|
||||
ORDER_REVOKE: "order-revoke",
|
||||
ORDER_RETURN_IN: "return-in",
|
||||
POINT_REDEMPTION_OUT: "manual-out",
|
||||
POINT_REDEMPTION_RETURN_IN: "return-in",
|
||||
STOCKTAKE_GAIN: "stocktake-gain",
|
||||
STOCKTAKE_LOSS: "stocktake-loss"
|
||||
} as Record<string, string>)[type || ""] || "unknown";
|
||||
}
|
||||
|
||||
function getDeltaClass(value?: number | string): string {
|
||||
const amount = Number(value || 0);
|
||||
return 0 < amount ? "positive" : amount < 0 ? "negative" : "gray";
|
||||
}
|
||||
|
||||
function getDeltaText(value?: number | string): string {
|
||||
const amount = Number(value || 0);
|
||||
const quantity = String(value || "0").replace(/^-/, "");
|
||||
const text = props.selection ? `${formatQuantity(quantity)} ${currentUnit.value?.name || ""}` : getProductQuantityText(quantity);
|
||||
return `${0 < amount ? "+" : amount < 0 ? "-" : ""}${text}`;
|
||||
}
|
||||
|
||||
const visible = ref(false);
|
||||
const selectedDate = ref("");
|
||||
const selectedStart = ref(0);
|
||||
const direction = ref<StockRecordDirection>("IN");
|
||||
const directionOptions = [{ label: "入库", value: "IN" }, { label: "出库", value: "OUT" }];
|
||||
|
||||
async function changeDirection(event: { value: string | number }): Promise<void> {
|
||||
if (event.value === "IN" || event.value === "OUT") await selectDirection(event.value);
|
||||
}
|
||||
|
||||
const records = ref<StockRecord[]>([]);
|
||||
const recordsLoading = ref(false);
|
||||
const noMore = ref(false);
|
||||
let page = 0;
|
||||
let recordToken = 0;
|
||||
|
||||
async function openDay(day: MonthCalendarDay): Promise<void> {
|
||||
const [year, monthNumber, dateNumber] = day.dateText.split("-").map(Number);
|
||||
const date = new Date(year, monthNumber - 1, dateNumber);
|
||||
selectedStart.value = date.getTime();
|
||||
selectedDate.value = day.dateText;
|
||||
emit("date-change", day.dateText);
|
||||
visible.value = true;
|
||||
if (canReadRecords.value) await selectDirection("IN");
|
||||
}
|
||||
|
||||
async function selectDirection(value: StockRecordDirection): Promise<void> {
|
||||
direction.value = value;
|
||||
recordToken++;
|
||||
records.value = [];
|
||||
page = 0;
|
||||
noMore.value = false;
|
||||
recordsLoading.value = false;
|
||||
await loadRecords();
|
||||
}
|
||||
|
||||
async function loadRecords(): Promise<void> {
|
||||
if (recordsLoading.value || noMore.value) return;
|
||||
const token = ++recordToken;
|
||||
recordsLoading.value = true;
|
||||
try {
|
||||
const start = new Date(selectedStart.value);
|
||||
const endAt = new Date(start.getFullYear(), start.getMonth(), start.getDate() + 1).getTime() - 1;
|
||||
const result = await ProductAPI.recordList({
|
||||
storeId: props.storeId,
|
||||
productId: props.selection?.product.id || undefined,
|
||||
skuId: skuId.value || undefined,
|
||||
beginAt: selectedStart.value,
|
||||
endAt,
|
||||
direction: direction.value,
|
||||
index: page,
|
||||
size: 15
|
||||
});
|
||||
if (token !== recordToken) return;
|
||||
const list = result.list || [];
|
||||
records.value.push(...list);
|
||||
page++;
|
||||
noMore.value = list.length < 15 || !(records.value.length < (result.total || 0));
|
||||
} catch (error) {
|
||||
if (token === recordToken) Message.error(getErrorMessage(error, "库存流水加载失败"));
|
||||
} finally {
|
||||
if (token === recordToken) recordsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch([() => props.storeId, skuId], () => {
|
||||
visible.value = false;
|
||||
recordToken++;
|
||||
});
|
||||
|
||||
defineExpose({ openDay });
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.records {
|
||||
height: 60vh;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
|
||||
.directions {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
padding: .75rem;
|
||||
min-width: 0;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.summary {
|
||||
gap: .75rem;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
font-size: .875rem;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
|
||||
.in { color: var(--td-success-color); }
|
||||
.out { color: var(--td-error-color); }
|
||||
}
|
||||
|
||||
.record-list {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 3.5rem;
|
||||
height: 3.5rem;
|
||||
}
|
||||
|
||||
.list {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.item {
|
||||
padding: .625rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.record-title {
|
||||
gap: .25rem;
|
||||
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, .record-quantity {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.operation {
|
||||
color: var(--operation-color, var(--td-text-color-secondary));
|
||||
|
||||
&.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;
|
||||
}
|
||||
|
||||
&.return-in {
|
||||
--operation-color: #15803d;
|
||||
}
|
||||
|
||||
&.stocktake-gain {
|
||||
--operation-color: #0f766e;
|
||||
}
|
||||
|
||||
&.stocktake-loss {
|
||||
--operation-color: #a16207;
|
||||
}
|
||||
}
|
||||
|
||||
.product-name {
|
||||
overflow: hidden;
|
||||
flex: 0 1 auto;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.record-quantity {
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
font-size: .75rem;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.delta {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.positive {
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
|
||||
.negative {
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
|
||||
:global(html.theme-dark) .records .operation {
|
||||
&.initial-in {
|
||||
--operation-color: #93c5fd;
|
||||
}
|
||||
|
||||
&.manual-in, &.return-in {
|
||||
--operation-color: #86efac;
|
||||
}
|
||||
|
||||
&.manual-out {
|
||||
--operation-color: #fdba74;
|
||||
}
|
||||
|
||||
&.manual-revoke {
|
||||
--operation-color: #fda4af;
|
||||
}
|
||||
|
||||
&.order-reserve {
|
||||
--operation-color: #c4b5fd;
|
||||
}
|
||||
|
||||
&.order-release {
|
||||
--operation-color: #67e8f9;
|
||||
}
|
||||
|
||||
&.order-out {
|
||||
--operation-color: #fca5a5;
|
||||
}
|
||||
|
||||
&.order-revoke {
|
||||
--operation-color: #a5b4fc;
|
||||
}
|
||||
|
||||
&.stocktake-gain {
|
||||
--operation-color: #5eead4;
|
||||
}
|
||||
|
||||
&.stocktake-loss {
|
||||
--operation-color: #fcd34d;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -54,6 +54,14 @@
|
||||
<t-tag :content="recycleUnitName || '单位'" />
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item
|
||||
v-if="customerId && recycleItemId"
|
||||
label="客户回收物数量"
|
||||
label-width="9rem"
|
||||
content-align="right"
|
||||
>
|
||||
<span :class="customerRecycleClass" v-text="customerRecycleText" />
|
||||
</t-form-item>
|
||||
<t-form-item v-if="selectedRule" label="兑换份数" required-mark content-align="right">
|
||||
<t-stepper v-model="multiple" size="large" :min="1" :max="9999" :step="1" integer theme="outline" />
|
||||
</t-form-item>
|
||||
@@ -149,7 +157,7 @@
|
||||
<bottom-popup
|
||||
v-model="ruleVisible"
|
||||
title="选择兑换模板"
|
||||
max-height="70vh"
|
||||
height="70vh"
|
||||
right-button-text=""
|
||||
@left-button-click="ruleVisible = false"
|
||||
>
|
||||
@@ -162,7 +170,13 @@
|
||||
@click="selectRule(item)"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-image v-if="getRulePhotoId(item)" class="avatar" :src="getAttachmentReadURL(getRulePhotoId(item), 96)" :alt="item.recycleName || '回收物'" fit="cover" />
|
||||
<t-image
|
||||
v-if="getRulePhotoId(item)"
|
||||
class="avatar"
|
||||
:src="getAttachmentReadURL(getRulePhotoId(item), 96)"
|
||||
:alt="item.recycleName || '回收物'"
|
||||
fit="cover"
|
||||
/>
|
||||
<div v-else class="avatar fallback" v-text="(item.recycleName || '回').slice(0, 1)" />
|
||||
</template>
|
||||
<template #title>
|
||||
@@ -224,8 +238,13 @@ import { Message } from "@/utils/message";
|
||||
import { comparePackageQuantity, normalizePackageQuantity, toPackageBaseQuantity } from "@/utils/package";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getProductPhotoURL, getProductQuantityStep, getProductSkuSnapshotText } from "@/utils/product";
|
||||
import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements, type ProductStockPreviewItem } from "@/utils/productStock";
|
||||
import { getRecycleQuantityText, multiplyRecycleQuantity } from "@/utils/recycle";
|
||||
import {
|
||||
buildProductStockPreview,
|
||||
getProductStockShortageMessage,
|
||||
mergeProductStockRequirements,
|
||||
type ProductStockPreviewItem
|
||||
} from "@/utils/productStock";
|
||||
import { getRecycleAvailable, getRecycleQuantityText, multiplyRecycleQuantity } from "@/utils/recycle";
|
||||
import { uploadPhotoList } from "@/utils/photo";
|
||||
|
||||
defineOptions({ name: "RecycleExchangeCreate" });
|
||||
@@ -367,6 +386,36 @@ const recycleItemList = ref<RecycleItem[]>([]);
|
||||
const recycleItemId = ref("");
|
||||
const selectedRecycleItem = ref<RecycleItem>();
|
||||
const recycleQuantityText = ref("");
|
||||
const customerRecycleText = ref("正在加载");
|
||||
const customerRecycleAvailable = ref<string>();
|
||||
const customerRecycleClass = computed(() => {
|
||||
const required = normalizePackageQuantity(recycleQuantityText.value || "0");
|
||||
if (customerRecycleAvailable.value === undefined || required === undefined) return "";
|
||||
return comparePackageQuantity(customerRecycleAvailable.value, required) < 0 ? "insufficient" : "sufficient";
|
||||
});
|
||||
|
||||
watch([customerId, recycleItemId], async ([customer, item], _previous, onCleanup) => {
|
||||
let active = true;
|
||||
onCleanup(() => { active = false; });
|
||||
customerRecycleAvailable.value = undefined;
|
||||
if (!customer || !item) return;
|
||||
if (!userStore.hasPermissions(permissionCodes.recycleAccount.read)) {
|
||||
customerRecycleText.value = "无权限查看";
|
||||
return;
|
||||
}
|
||||
customerRecycleText.value = "正在加载";
|
||||
try {
|
||||
const accounts = await RecycleAPI.accountList(customer);
|
||||
if (!active) return;
|
||||
const account = accounts.find(value => value.recycleItemId === item);
|
||||
customerRecycleAvailable.value = getRecycleAvailable(account).toFixed(3);
|
||||
customerRecycleText.value = `可用 ${getRecycleQuantityText(customerRecycleAvailable.value, recycleUnitName.value)}`;
|
||||
} catch (error) {
|
||||
if (!active) return;
|
||||
customerRecycleText.value = "加载失败";
|
||||
Message.error(getErrorMessage(error, "客户回收物数量加载失败"));
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
async function loadRecycleItems(): Promise<void> {
|
||||
itemLoading.value = true;
|
||||
@@ -776,6 +825,13 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.recycle-exchange-create {
|
||||
.sufficient {
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
|
||||
.insufficient {
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
|
||||
.form {
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
>
|
||||
<div class="filters glass">
|
||||
<t-input
|
||||
v-model.trim="keyword"
|
||||
v-model="keyword"
|
||||
class="keyword"
|
||||
type="search"
|
||||
borderless
|
||||
@@ -53,7 +53,14 @@
|
||||
@click="toEdit(item)"
|
||||
>
|
||||
<template #left-icon>
|
||||
<div class="avatar fallback" v-text="(getRecycleItemName(item) || '模').slice(0, 1)" />
|
||||
<t-image
|
||||
v-if="coverId(item)"
|
||||
class="avatar"
|
||||
:src="getAttachmentReadURL(coverId(item), 96)"
|
||||
:alt="getRecycleItemName(item)"
|
||||
fit="cover"
|
||||
/>
|
||||
<div v-else class="avatar fallback" v-text="(getRecycleItemName(item) || '模').slice(0, 1)" />
|
||||
</template>
|
||||
<template #title>
|
||||
<span class="clip-text" v-text="getRecycleItemName(item) || '未命名回收物'" />
|
||||
@@ -115,6 +122,7 @@ import RecycleRuleDetail from "@/pages/recycle/RecycleRuleDetail.vue";
|
||||
import RecycleRuleEdit from "@/pages/recycle/RecycleRuleEdit.vue";
|
||||
import type { NavbarAction } from "@/types/NavbarAction";
|
||||
import type { RecycleExchangeRule, RecycleRuleItem } from "@/types/Recycle";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
@@ -157,6 +165,10 @@ function getRecycleItemName(rule: RecycleExchangeRule): string {
|
||||
return rule.recycleName || "";
|
||||
}
|
||||
|
||||
function coverId(rule: RecycleExchangeRule): string {
|
||||
return rule.recycleItemAttachments?.find(attachment => attachment.id && attachment.mimeType?.startsWith("image/"))?.id || "";
|
||||
}
|
||||
|
||||
function getRuleItemList(rule: RecycleExchangeRule): RecycleRuleItem[] {
|
||||
return rule.itemList || [];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<bottom-popup
|
||||
v-model="visible"
|
||||
:title="props.title"
|
||||
height="60vh"
|
||||
height="70vh"
|
||||
right-button-text=""
|
||||
:z-index="12100"
|
||||
:overlay-props="{ zIndex: 12099 }"
|
||||
@@ -56,6 +56,7 @@ const props = withDefaults(defineProps<{
|
||||
title?: string;
|
||||
manage?: boolean;
|
||||
showStatus?: boolean;
|
||||
accountItems?: boolean;
|
||||
selectedId?: string;
|
||||
items?: RecycleItem[];
|
||||
loading?: boolean;
|
||||
@@ -65,6 +66,7 @@ const props = withDefaults(defineProps<{
|
||||
title: "选择回收物",
|
||||
manage: false,
|
||||
showStatus: false,
|
||||
accountItems: false,
|
||||
selectedId: "",
|
||||
loading: false,
|
||||
emptyText: "暂无回收物"
|
||||
@@ -86,6 +88,10 @@ async function load(): Promise<void> {
|
||||
if (internalLoading.value) return;
|
||||
internalLoading.value = true;
|
||||
try {
|
||||
if (props.accountItems) {
|
||||
loadedItems.value = await RecycleAPI.accountItems();
|
||||
return;
|
||||
}
|
||||
const result: RecycleItem[] = [];
|
||||
let offset = 0;
|
||||
let total = 0;
|
||||
|
||||
@@ -27,7 +27,20 @@
|
||||
<h1 class="no selectable" v-text="order.orderNo" />
|
||||
<div class="meta">
|
||||
<time-label class="time" :timestamp="order.purchasedAt" underline />
|
||||
<div class="amount red text-bold">
|
||||
<div v-if="order.orderType === 'RECYCLE'" class="amount red text-bold">
|
||||
<t-tag
|
||||
class="recycle"
|
||||
size="small"
|
||||
theme="primary"
|
||||
variant="light-outline"
|
||||
:content="order.recycleItemName || '未命名回收物'"
|
||||
/>
|
||||
<strong class="value">
|
||||
<span class="word-space" v-text="order.recycleRequiredQuantity ?? '-'" />
|
||||
<span v-text="order.recycleUnit || ''" />
|
||||
</strong>
|
||||
</div>
|
||||
<div v-else class="amount red text-bold">
|
||||
<span>¥</span>
|
||||
<strong class="value" v-text="formatPackageAmount(order.saleAmount)" />
|
||||
</div>
|
||||
@@ -120,7 +133,6 @@
|
||||
class="red"
|
||||
v-text="`¥${formatPackageAmount(item.lineAmount)}`"
|
||||
/>
|
||||
<t-tag v-else size="small" content="套餐权益" />
|
||||
<product-sku-tags
|
||||
:product-name="item.productNameSnapshot"
|
||||
:snapshot="item.skuSpecSnapshot"
|
||||
@@ -667,10 +679,17 @@ watch(() => [props.orderId, route.params.id], loadData);
|
||||
}
|
||||
|
||||
.amount {
|
||||
gap: .25rem;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
|
||||
.value {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.recycle {
|
||||
transform: translateY(-.25rem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+78
-57
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="tui-page-layout tui-navbar">
|
||||
<div class="tui-page-layout tui-navbar about">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
@@ -7,47 +7,65 @@
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
/>
|
||||
<main class="tui-page-content scroll column">
|
||||
<div class="about-page">
|
||||
<section class="brand" v-entrance-transition>
|
||||
<logo @click="handleLogoClick" />
|
||||
<h1 v-text="appName" />
|
||||
<p v-text="`版本 ${displayVersion}`" />
|
||||
<p v-text="appDescription" />
|
||||
</section>
|
||||
<t-cell-group v-if="agreementItemList.length" theme="card" v-entrance-transition>
|
||||
<t-cell
|
||||
v-for="item in agreementItemList"
|
||||
:key="item.id"
|
||||
:title="item.title"
|
||||
arrow
|
||||
hover
|
||||
@click="openAgreement(item)"
|
||||
<master-detail-page
|
||||
class="list"
|
||||
:split="isWide"
|
||||
:selected="!!selectedId"
|
||||
:direction="paneDirection"
|
||||
>
|
||||
<template #master>
|
||||
<div class="about-page tui-page-content column">
|
||||
<section class="brand" v-entrance-transition>
|
||||
<logo @click="handleLogoClick" />
|
||||
<h1 v-text="appName" />
|
||||
<p class="version" v-text="`版本 ${displayVersion}`" />
|
||||
<p class="description" v-text="appDescription" />
|
||||
</section>
|
||||
<t-cell-group
|
||||
v-if="agreementItemList.length"
|
||||
theme="card"
|
||||
v-entrance-transition
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-icon :name="item.icon" size="1.75rem" />
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<t-empty
|
||||
v-else
|
||||
:description="isLoading ? '正在加载协议配置' : '暂无可用协议'"
|
||||
<t-cell
|
||||
v-for="item in agreementItemList"
|
||||
:key="item.id"
|
||||
:title="item.title"
|
||||
arrow
|
||||
hover
|
||||
@click="openAgreement(item)"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-icon :name="item.icon" size="1.75rem" />
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<t-empty
|
||||
v-else
|
||||
:description="isLoading ? '正在加载协议配置' : '暂无可用协议'"
|
||||
/>
|
||||
<t-cell-group theme="card" v-entrance-transition>
|
||||
<t-cell title="版本更新" arrow hover @click="openDetail('update')">
|
||||
<template #leftIcon>
|
||||
<t-icon name="download" size="1.75rem" />
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<footer class="footer" v-entrance-transition>
|
||||
<p>技术支持:夜雨</p>
|
||||
<p>联系技术:imyeyu@qq.com</p>
|
||||
<p>短信服务支持:广州易保网络科技有限公司</p>
|
||||
<p>Copyright © 2026 imyeyu.com</p>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
<template #detail>
|
||||
<app-update v-if="selectedId === 'update'" />
|
||||
<agreement
|
||||
v-else-if="selectedId?.startsWith('agreement:')"
|
||||
:article-id="selectedId.slice(10)"
|
||||
/>
|
||||
<t-cell-group v-if="updateSupported" theme="card" v-entrance-transition>
|
||||
<t-cell title="版本更新" arrow hover @click="router.push({ name: 'AppUpdate' })">
|
||||
<template #leftIcon>
|
||||
<t-icon name="download" size="1.75rem" />
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<footer class="footer" v-entrance-transition>
|
||||
<p>技术支持:夜雨</p>
|
||||
<p>联系技术:imyeyu@qq.com</p>
|
||||
<p>短信服务支持:广州易保网络科技有限公司</p>
|
||||
<p>Copyright © 2026 imyeyu.com</p>
|
||||
</footer>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
</master-detail-page>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -55,6 +73,9 @@
|
||||
import { version } from "../../../package.json";
|
||||
import { useAppUpdate } from "@/composables/useAppUpdate";
|
||||
import { SettingAPI } from "timi-web-api";
|
||||
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
||||
import Agreement from "@/pages/setting/Agreement.vue";
|
||||
import AppUpdate from "@/pages/setting/AppUpdate.vue";
|
||||
import Logo from "@/pages/user/component/Logo.vue";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
@@ -71,9 +92,12 @@ defineOptions({
|
||||
});
|
||||
|
||||
const appName = "糕店客户管理";
|
||||
const appDescription = "面向门店的客户、登记、积分与经营管理工具";
|
||||
const router = useRouter();
|
||||
const { supported: updateSupported, currentVersion, loadCurrent } = useAppUpdate();
|
||||
const appDescription = "融合客户服务、门店经营与 AI 智能助手的一体化管理平台";
|
||||
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
|
||||
path: "/management/about",
|
||||
detail: id => id === "update" ? "/management/about/update" : `/management/about/agreement/${encodeURIComponent(id.slice(10))}`
|
||||
});
|
||||
const { currentVersion, loadCurrent } = useAppUpdate();
|
||||
const displayVersion = computed(() => currentVersion.value && currentVersion.value !== "builtin" ? currentVersion.value : version);
|
||||
|
||||
const agreementItemList = ref<AgreementItem[]>([]);
|
||||
@@ -81,13 +105,8 @@ const isLoading = ref(false);
|
||||
|
||||
const handleLogoClick = createVConsoleClickHandler(toggleVConsole);
|
||||
|
||||
async function openAgreement(item: AgreementItem): Promise<void> {
|
||||
await router.push({
|
||||
name: "Agreement",
|
||||
params: {
|
||||
id: item.id
|
||||
}
|
||||
});
|
||||
function openAgreement(item: AgreementItem): void {
|
||||
openDetail(`agreement:${item.id}`);
|
||||
}
|
||||
|
||||
function normalizeAgreementItem(value: unknown): AgreementItem | undefined {
|
||||
@@ -145,10 +164,6 @@ onMounted(async () => {
|
||||
|
||||
<style scoped lang="less">
|
||||
.about-page {
|
||||
gap: 1rem;
|
||||
display: flex;
|
||||
padding: 0 0 5rem;
|
||||
flex-direction: column;
|
||||
|
||||
.brand {
|
||||
padding: 1rem;
|
||||
@@ -159,17 +174,23 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: .875rem 0 .5rem;
|
||||
color: #0f172a;
|
||||
margin: .875rem 0 .5rem;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
color: #52607a;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.version {
|
||||
font-size: .875rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: .75rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,41 +1,40 @@
|
||||
<template>
|
||||
<div class="tui-page-layout tui-navbar">
|
||||
<div class="tui-page-layout tui-navbar agreement">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
:title="routeNavBarTitle"
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
@left-click="goBack"
|
||||
/>
|
||||
<main class="tui-page-content scroll column">
|
||||
<div class="agreement-page">
|
||||
<template v-if="article">
|
||||
<header class="header" v-entrance-transition>
|
||||
<h3 v-text="article.title || '协议'" />
|
||||
<markdown-view
|
||||
v-if="article.description"
|
||||
class="description"
|
||||
:content="article.description"
|
||||
/>
|
||||
</header>
|
||||
<article-view
|
||||
:article="article"
|
||||
empty-text="暂无协议正文"
|
||||
:resolve-attachment-url="resolveAttachmentUrl"
|
||||
<main class="tui-page-content scroll column bg-white">
|
||||
<template v-if="article">
|
||||
<header class="header" v-entrance-transition>
|
||||
<h3 v-text="article.title || '协议'" />
|
||||
<markdown-view
|
||||
v-if="article.description"
|
||||
class="description"
|
||||
:content="article.description"
|
||||
/>
|
||||
</template>
|
||||
<t-empty
|
||||
v-else
|
||||
:description="isLoading ? '正在加载协议' : '协议不存在'"
|
||||
</header>
|
||||
<article-view
|
||||
:article="article"
|
||||
empty-text="暂无协议正文"
|
||||
:resolve-attachment-url="resolveAttachmentUrl"
|
||||
v-entrance-transition
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<t-empty
|
||||
v-else
|
||||
:description="isLoading ? '正在加载协议' : '协议不存在'"
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type Article, ArticleAPI, AttachmentAPI } from "timi-web-api";
|
||||
import { ArticleView } from "timi-tdesign-mobile";
|
||||
import { ArticleView, usePane } from "timi-tdesign-mobile";
|
||||
import { MarkdownView } from "timi-web";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
@@ -45,6 +44,17 @@ defineOptions({
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const pane = usePane();
|
||||
const props = defineProps<{ articleId?: string }>();
|
||||
|
||||
function goBack(): void {
|
||||
if (pane) {
|
||||
pane.close();
|
||||
return;
|
||||
}
|
||||
router.back();
|
||||
}
|
||||
|
||||
const routeNavBarTitle = computed(() => {
|
||||
switch (route.name) {
|
||||
@@ -57,7 +67,7 @@ const routeNavBarTitle = computed(() => {
|
||||
case "OpenSourceAgreement":
|
||||
return "开源软件协议";
|
||||
default:
|
||||
return "";
|
||||
return "协议";
|
||||
}
|
||||
});
|
||||
const article = ref<Article>();
|
||||
@@ -72,7 +82,7 @@ async function loadArticle(): Promise<void> {
|
||||
const requestToken = loadToken + 1;
|
||||
loadToken = requestToken;
|
||||
article.value = undefined;
|
||||
const articleId = String(route.params.id || "").trim();
|
||||
const articleId = String(props.articleId || route.params.id || "").trim();
|
||||
if (!articleId) {
|
||||
return;
|
||||
}
|
||||
@@ -93,30 +103,26 @@ async function loadArticle(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => route.params.id, async () => {
|
||||
watch(() => props.articleId || route.params.id, async () => {
|
||||
await loadArticle();
|
||||
}, { immediate: true });
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.agreement-page {
|
||||
padding: 0 0 1rem 0;
|
||||
.agreement {
|
||||
|
||||
.header {
|
||||
padding: .5rem 1rem;
|
||||
padding: 0 1rem;
|
||||
|
||||
h3 {
|
||||
color: #0f172a;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.description {
|
||||
color: #52607a;
|
||||
font-size: .875rem;
|
||||
margin-top: .5rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,18 +130,4 @@ watch(() => route.params.id, async () => {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
:global(html.theme-dark) {
|
||||
.agreement-page {
|
||||
.header {
|
||||
h1 {
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
.description {
|
||||
color: #94a3b8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
+148
-14
@@ -1,11 +1,16 @@
|
||||
<template>
|
||||
<div class="tui-page-layout tui-navbar">
|
||||
<t-navbar fixed :z-index="20" title="版本更新" left-arrow @left-click="$router.back()" />
|
||||
<div class="tui-page-layout tui-navbar app-update">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
title="版本更新"
|
||||
left-arrow
|
||||
@left-click="goBack"
|
||||
/>
|
||||
<main class="tui-page-content scroll column">
|
||||
<center-tips v-if="!updateSupported" content="仅在 App 内可用" />
|
||||
<t-cell-group v-if="updateSupported" title="版本更新" theme="card" v-entrance-transition>
|
||||
<t-cell-group v-if="updateSupported" theme="card" v-entrance-transition>
|
||||
<t-cell title="外壳版本" :note="nativeVersion || '—'" />
|
||||
<t-cell title="系统版本" :note="currentVersion || '—'" />
|
||||
<t-cell title="系统版本" :note="displayVersion" />
|
||||
<t-cell v-if="latestVersionText" title="最新版本" :note="latestVersionText" />
|
||||
<t-cell title="自动更新">
|
||||
<template #right-icon>
|
||||
@@ -13,6 +18,9 @@
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<t-cell-group v-else theme="card" v-entrance-transition>
|
||||
<t-cell title="系统版本" :note="displayVersion" />
|
||||
</t-cell-group>
|
||||
<div v-if="updateSupported" class="update-panel" v-entrance-transition>
|
||||
<center-tips v-if="updateHint"><span v-text="updateHint" /></center-tips>
|
||||
<t-button
|
||||
@@ -36,9 +44,13 @@
|
||||
</t-button>
|
||||
<template v-else-if="updateStage === 'downloading'">
|
||||
<t-progress class="progress" stroke-width=".5rem" :percentage="percent" />
|
||||
<t-button class="cell-button" theme="primary" size="large" disabled>
|
||||
<span v-text="`下载中 ${percent}%`" />
|
||||
</t-button>
|
||||
<t-button
|
||||
class="cell-button"
|
||||
theme="primary"
|
||||
size="large"
|
||||
disabled
|
||||
content="正在下载.."
|
||||
/>
|
||||
</template>
|
||||
<t-button
|
||||
v-else-if="updateStage === 'apply'"
|
||||
@@ -50,18 +62,71 @@
|
||||
现在更新
|
||||
</t-button>
|
||||
</div>
|
||||
<section v-if="noteList.length" class="versions">
|
||||
<h2 class="title" v-text="noteTitle" />
|
||||
<timeline>
|
||||
<timeline-item
|
||||
class="version"
|
||||
v-for="item in noteList"
|
||||
:key="item.version"
|
||||
v-entrance-transition
|
||||
>
|
||||
<template #label>
|
||||
<div class="label">
|
||||
<t-tag
|
||||
size="small"
|
||||
theme="primary"
|
||||
variant="light-outline"
|
||||
:content="item.version"
|
||||
/>
|
||||
<time-label class="time" :timestamp="item.publishedAt" />
|
||||
</div>
|
||||
</template>
|
||||
<markdown-view class="content bg-white" :content="item.note" />
|
||||
</timeline-item>
|
||||
<timeline-item v-entrance-transition>
|
||||
<template #label>
|
||||
<div class="label">
|
||||
<t-tag
|
||||
size="small"
|
||||
theme="primary"
|
||||
variant="light-outline"
|
||||
content="..."
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</timeline-item>
|
||||
</timeline>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { setAutoUpdate, useAppUpdate } from "@/composables/useAppUpdate";
|
||||
import { version } from "../../../package.json";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
import { Timeline, TimelineItem, usePane } from "timi-tdesign-mobile";
|
||||
import { MarkdownView, TimeLabel } from "timi-web";
|
||||
import AppUpdateAPI from "@/api/AppUpdateAPI";
|
||||
import { APP_ID, setAutoUpdate, useAppUpdate } from "@/composables/useAppUpdate";
|
||||
import type { AppUpdateNote } from "@/types/AppUpdate";
|
||||
import { Message } from "@/utils/message";
|
||||
|
||||
defineOptions({
|
||||
name: "AppUpdate"
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const pane = usePane();
|
||||
|
||||
function goBack(): void {
|
||||
if (pane) {
|
||||
pane.close();
|
||||
return;
|
||||
}
|
||||
router.back();
|
||||
}
|
||||
|
||||
// ---------- 版本更新 ----------
|
||||
|
||||
const {
|
||||
@@ -83,6 +148,11 @@ const {
|
||||
restorePending
|
||||
} = useAppUpdate();
|
||||
|
||||
/** 系统版本:原生端优先取热更包版本,未热更过或 web 端回落到构建版本 */
|
||||
const displayVersion = computed<string>(
|
||||
() => (currentVersion.value && currentVersion.value !== "builtin" ? currentVersion.value : version)
|
||||
);
|
||||
|
||||
/** 有更新时展示目标版本号 */
|
||||
const latestVersionText = computed<string>(() => (hasUpdate() ? `v${latest.value?.version ?? ""}` : ""));
|
||||
|
||||
@@ -117,11 +187,43 @@ const updateHint = computed<string>(() => {
|
||||
return "";
|
||||
});
|
||||
|
||||
// ---------- 更新日志 ----------
|
||||
|
||||
/** web 端只展示最近几个版本 */
|
||||
const WEB_NOTE_LIMIT = 3;
|
||||
|
||||
const noteList = ref<AppUpdateNote[]>([]);
|
||||
|
||||
const noteTitle = computed<string>(() => (updateSupported ? "更新内容" : "最近更新"));
|
||||
|
||||
/** 查询当前版本到通道最新版本之间的变更说明 */
|
||||
async function loadNotes(): Promise<void> {
|
||||
try {
|
||||
const result = await AppUpdateAPI.notes({
|
||||
appId: APP_ID,
|
||||
// web 端没有热更包版本,从内置包开始算,后端会返回通道的完整历史
|
||||
versionName: updateSupported ? currentVersion.value || "builtin" : "builtin",
|
||||
platform: Capacitor.getPlatform(),
|
||||
channel: "stable"
|
||||
});
|
||||
const list = result?.notes ?? [];
|
||||
noteList.value = updateSupported ? list : list.slice(0, WEB_NOTE_LIMIT);
|
||||
} catch {
|
||||
// 日志不是关键路径,失败时安静降级,不弹错误
|
||||
noteList.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 生命周期 ----------
|
||||
|
||||
onMounted(async () => {
|
||||
await loadCurrent();
|
||||
await restorePending();
|
||||
await loadNotes();
|
||||
});
|
||||
|
||||
// ---------- 交互 ----------
|
||||
|
||||
function handleAutoUpdateChange(value: boolean | string | number): void {
|
||||
setAutoUpdate(value === true);
|
||||
}
|
||||
@@ -135,6 +237,8 @@ async function handleCheck(): Promise<void> {
|
||||
if (!hasUpdate()) {
|
||||
Message.info("已是最新版本");
|
||||
}
|
||||
// 检查后目标版本可能变化,重查一次日志
|
||||
await loadNotes();
|
||||
}
|
||||
|
||||
async function handleDownload(): Promise<void> {
|
||||
@@ -156,14 +260,44 @@ async function handleApply(): Promise<void> {
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.update-panel {
|
||||
gap: .75rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.app-update {
|
||||
|
||||
.progress {
|
||||
margin: 0 1rem;
|
||||
}
|
||||
|
||||
.versions {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
padding: .25rem 1rem 1rem;
|
||||
flex-direction: column;
|
||||
|
||||
.title {
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: .5rem .25rem 0;
|
||||
font-size: .8125rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.version {
|
||||
|
||||
.label {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.time {
|
||||
font-size: .875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: .5rem;
|
||||
font-size: .875rem;
|
||||
margin-top: .5rem;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
title="客户"
|
||||
>
|
||||
<template #right>
|
||||
<app-update-button />
|
||||
<navbar-notify-button />
|
||||
</template>
|
||||
</t-navbar>
|
||||
@@ -32,7 +31,6 @@
|
||||
<store-overview ref="storeOverviewRef" compact />
|
||||
</template>
|
||||
<template #right-actions>
|
||||
<app-update-button />
|
||||
<navbar-notify-button />
|
||||
</template>
|
||||
<template #right>
|
||||
@@ -55,7 +53,6 @@ import { useLayout } from "timi-tdesign-mobile";
|
||||
import PendingNoticeBar from "./component/PendingNoticeBar.vue";
|
||||
import CustomerEntryPanel from "./component/CustomerEntryPanel.vue";
|
||||
import NavbarNotifyButton from "./component/NavbarNotifyButton.vue";
|
||||
import AppUpdateButton from "./component/AppUpdateButton.vue";
|
||||
import StoreOverview from "./component/StoreOverview.vue";
|
||||
import TabSplitView from "./component/TabSplitView.vue";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
|
||||
@@ -149,6 +149,12 @@ const menuGroupList = computed<MenuGroup[]>(() => [
|
||||
title: "客户邀请关系",
|
||||
visible: userStore.hasPermissions(permissionCodes.customer.read)
|
||||
},
|
||||
{
|
||||
icon: "layers",
|
||||
path: "/management/customer-recycle-accounts",
|
||||
title: "客户回收物",
|
||||
visible: userStore.hasPermissions(permissionCodes.recycleAccount.read)
|
||||
},
|
||||
{
|
||||
icon: "chart-combo",
|
||||
path: "/management/customer-data-charts",
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<template>
|
||||
<t-button
|
||||
v-if="visible"
|
||||
aria-label="有新版本"
|
||||
@click="router.push('/management/settings')"
|
||||
theme="default"
|
||||
shape="square"
|
||||
variant="text"
|
||||
size="small"
|
||||
>
|
||||
<t-badge dot :offset="[-4, 4]">
|
||||
<t-icon name="download" size="1.25rem" />
|
||||
</t-badge>
|
||||
</t-button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useAppUpdate } from "@/composables/useAppUpdate";
|
||||
|
||||
defineOptions({
|
||||
name: "AppUpdateButton"
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const { supported, latest, autoUpdate, hasUpdate } = useAppUpdate();
|
||||
|
||||
// 只在有更新且未开启自动更新时出现,开启自动更新后由启动弹窗负责提醒
|
||||
const visible = computed(() => {
|
||||
void latest.value;
|
||||
return supported && hasUpdate() && !autoUpdate.value;
|
||||
});
|
||||
</script>
|
||||
@@ -1,13 +1,14 @@
|
||||
<template>
|
||||
<t-notice-bar
|
||||
v-if="noticeContent.length"
|
||||
v-if="noticeList.length"
|
||||
:key="noticeContent.join(',')"
|
||||
class="pending-notice"
|
||||
theme="warning"
|
||||
:visible="true"
|
||||
direction="vertical"
|
||||
:interval="4000"
|
||||
:content="1 < noticeContent.length ? noticeContent : noticeContent[0]"
|
||||
@change="currentIndex = $event"
|
||||
@change="handleChange"
|
||||
@click="openNotice"
|
||||
>
|
||||
<template #suffix-icon>
|
||||
@@ -17,17 +18,32 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useAppUpdate } from "@/composables/useAppUpdate";
|
||||
import { usePendingNoticeStore } from "@/store/pendingNoticeStore";
|
||||
|
||||
const pendingNoticeStore = usePendingNoticeStore();
|
||||
const router = useRouter();
|
||||
const currentIndex = ref(0);
|
||||
const noticeContent = computed(() => pendingNoticeStore.pendingNoticeList.map(notice => notice.content));
|
||||
const { supported, latest, autoUpdate, hasUpdate } = useAppUpdate();
|
||||
const noticeList = computed(() => {
|
||||
const notices = [...pendingNoticeStore.pendingNoticeList];
|
||||
if (supported && !autoUpdate.value && hasUpdate() && latest.value) {
|
||||
notices.push({ content: `有可用新版本 v${latest.value.version} 更新`, name: "AppUpdate", query: {} });
|
||||
}
|
||||
return notices;
|
||||
});
|
||||
const noticeContent = computed(() => noticeList.value.map(notice => notice.content));
|
||||
let currentIndex = 0;
|
||||
|
||||
watch(noticeContent, () => { currentIndex.value = 0; });
|
||||
watch(noticeContent, () => {
|
||||
currentIndex = 0;
|
||||
});
|
||||
|
||||
function handleChange(index: number): void {
|
||||
currentIndex = index;
|
||||
}
|
||||
|
||||
async function openNotice(): Promise<void> {
|
||||
const notice = pendingNoticeStore.pendingNoticeList[currentIndex.value];
|
||||
const notice = noticeList.value[currentIndex];
|
||||
if (notice) {
|
||||
await router.push({ name: notice.name, query: notice.query });
|
||||
}
|
||||
@@ -38,6 +54,10 @@ async function openNotice(): Promise<void> {
|
||||
.pending-notice {
|
||||
margin-top: -1rem;
|
||||
|
||||
:deep(.t-swiper__container) {
|
||||
transition-duration: .5s !important;
|
||||
}
|
||||
|
||||
:deep(.t-swiper-nav__dots) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
/>
|
||||
</div>
|
||||
</t-form>
|
||||
<user-agreement v-model="hasAgreed" />
|
||||
<t-button class="submit" theme="primary" size="medium" :loading="isSubmitting" :disabled="isExpired || isSubmitting || !hasAgreed" @click="register">注册并登录</t-button>
|
||||
<user-agreement ref="agreementRef" v-model="hasAgreed" @agree="resumeRegister" @reject="cancelRegister" />
|
||||
<t-button class="submit" theme="primary" size="medium" :loading="isSubmitting" :disabled="isExpired || isSubmitting" @click="register">注册并登录</t-button>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -78,6 +78,19 @@ const expireAt = ref(0);
|
||||
const invalidMessage = ref("邀请码无效或已过期,请联系邀请人重新生成。");
|
||||
const isSubmitting = ref(false);
|
||||
const hasAgreed = ref(false);
|
||||
const agreementRef = ref<InstanceType<typeof UserAgreement> | null>(null);
|
||||
let pendingRegister = false;
|
||||
|
||||
async function resumeRegister(): Promise<void> {
|
||||
if (!pendingRegister) return;
|
||||
pendingRegister = false;
|
||||
await nextTick();
|
||||
await register();
|
||||
}
|
||||
|
||||
function cancelRegister(): void {
|
||||
pendingRegister = false;
|
||||
}
|
||||
const captchaRef = ref<CaptchaExpose | null>(null);
|
||||
const formModel = reactive({
|
||||
phoneNo: "",
|
||||
@@ -196,11 +209,12 @@ async function sendSms(): Promise<void> {
|
||||
}
|
||||
|
||||
async function register(): Promise<void> {
|
||||
if (isSubmitting.value || !hasAgreed.value || isExpired.value || !validateForm()) {
|
||||
if (!hasAgreed.value) {
|
||||
Message.warning("请先阅读并同意用户协议");
|
||||
return;
|
||||
}
|
||||
if (!hasAgreed.value) {
|
||||
pendingRegister = true;
|
||||
await agreementRef.value?.open();
|
||||
return;
|
||||
}
|
||||
if (isSubmitting.value || isExpired.value || !validateForm()) {
|
||||
if (isExpired.value) {
|
||||
Message.warning("邀请码已失效,请联系邀请人重新生成");
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
:options="loginTypeOptions"
|
||||
v-entrance-transition
|
||||
/>
|
||||
<password-login v-if="loginType === 'password'" class="form card" :agreement-accepted="hasAgreed" />
|
||||
<sms-login v-else class="form card" :agreement-accepted="hasAgreed" />
|
||||
<user-agreement v-model="hasAgreed" />
|
||||
<password-login v-if="loginType === 'password'" class="form card" :agreement-accepted="hasAgreed" @request-agreement="requestAgreement" />
|
||||
<sms-login v-else class="form card" :agreement-accepted="hasAgreed" @request-agreement="requestAgreement" />
|
||||
<user-agreement ref="agreementRef" v-model="hasAgreed" @agree="resumeLogin" @reject="cancelLogin" />
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -33,6 +33,26 @@ type LoginType = "password" | "sms";
|
||||
|
||||
const loginType = ref<LoginType>("password");
|
||||
const hasAgreed = ref(false);
|
||||
const agreementRef = ref<InstanceType<typeof UserAgreement> | null>(null);
|
||||
let pendingLogin: (() => Promise<void>) | undefined;
|
||||
|
||||
async function requestAgreement(resume: () => Promise<void>): Promise<void> {
|
||||
pendingLogin = resume;
|
||||
await agreementRef.value?.open();
|
||||
}
|
||||
|
||||
async function resumeLogin(): Promise<void> {
|
||||
const resume = pendingLogin;
|
||||
pendingLogin = undefined;
|
||||
await nextTick();
|
||||
await resume?.();
|
||||
}
|
||||
|
||||
function cancelLogin(): void {
|
||||
pendingLogin = undefined;
|
||||
}
|
||||
|
||||
watch(loginType, cancelLogin);
|
||||
const loginTypeOptions = [
|
||||
{ value: "password" as LoginType, label: "密码登录" },
|
||||
{ value: "sms" as LoginType, label: "短信登录" }
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<captcha class="captcha" ref="captchaRef" :width="120" :height="40" :request="CommonAPI.captcha" />
|
||||
</div>
|
||||
<div class="exec">
|
||||
<t-button theme="primary" class="button" type="submit" :loading="isSubmitting" :disabled="isSubmitting || !props.agreementAccepted">登录</t-button>
|
||||
<t-button theme="primary" class="button" type="submit" :loading="isSubmitting" :disabled="isSubmitting">登录</t-button>
|
||||
</div>
|
||||
</t-form>
|
||||
</template>
|
||||
@@ -45,6 +45,8 @@ const props = withDefaults(defineProps<{
|
||||
agreementAccepted: false
|
||||
});
|
||||
|
||||
const emit = defineEmits<{ "request-agreement": [resume: () => Promise<void>] }>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
@@ -62,10 +64,6 @@ function getRedirectPath(): string {
|
||||
}
|
||||
|
||||
function validateForm(): boolean {
|
||||
if (!props.agreementAccepted) {
|
||||
Message.warning("请先阅读并同意用户协议");
|
||||
return false;
|
||||
}
|
||||
if (!formModel.user || !formModel.password || !formModel.captcha || !captchaRef.value?.captchaId) {
|
||||
Message.warning("请输入账号、密码和验证码");
|
||||
return false;
|
||||
@@ -74,6 +72,10 @@ function validateForm(): boolean {
|
||||
}
|
||||
|
||||
async function login(): Promise<void> {
|
||||
if (!props.agreementAccepted) {
|
||||
emit("request-agreement", login);
|
||||
return;
|
||||
}
|
||||
if (isSubmitting.value || !validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="exec">
|
||||
<t-button theme="primary" class="button" type="submit" :loading="isSubmitting" :disabled="isSubmitting || !props.agreementAccepted">登录</t-button>
|
||||
<t-button theme="primary" class="button" type="submit" :loading="isSubmitting" :disabled="isSubmitting">登录</t-button>
|
||||
</div>
|
||||
</t-form>
|
||||
</template>
|
||||
@@ -57,6 +57,8 @@ const props = withDefaults(defineProps<{
|
||||
agreementAccepted: false
|
||||
});
|
||||
|
||||
const emit = defineEmits<{ "request-agreement": [resume: () => Promise<void>] }>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
@@ -142,10 +144,6 @@ async function sendSms(): Promise<void> {
|
||||
}
|
||||
|
||||
function validateForm(): boolean {
|
||||
if (!props.agreementAccepted) {
|
||||
Message.warning("请先阅读并同意用户协议");
|
||||
return false;
|
||||
}
|
||||
if (!/^1\d{10}$/.test(formModel.mobilePhone)) {
|
||||
Message.warning("请输入正确的 11 位手机号");
|
||||
return false;
|
||||
@@ -158,6 +156,10 @@ function validateForm(): boolean {
|
||||
}
|
||||
|
||||
async function login(): Promise<void> {
|
||||
if (!props.agreementAccepted) {
|
||||
emit("request-agreement", login);
|
||||
return;
|
||||
}
|
||||
if (isSubmitting.value || !validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
:label="item.title"
|
||||
lazy
|
||||
>
|
||||
<div class="agreement-item">
|
||||
<div class="panel">
|
||||
<t-loading v-if="item.loading" class="loading" text="正在加载协议" />
|
||||
<article-view
|
||||
v-else-if="item.article"
|
||||
@@ -84,6 +84,8 @@ const props = withDefaults(defineProps<{
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": [value: boolean];
|
||||
agree: [];
|
||||
reject: [];
|
||||
}>();
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
@@ -133,6 +135,10 @@ async function handleCheckboxChange(checked: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
await open();
|
||||
}
|
||||
|
||||
async function open(): Promise<void> {
|
||||
emit("update:modelValue", false);
|
||||
dialogVisible.value = true;
|
||||
activeAgreementId.value = "";
|
||||
@@ -188,12 +194,16 @@ function resolveAttachmentUrl(attachmentId: string): string {
|
||||
return AttachmentAPI.getReadURL(attachmentId);
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
|
||||
function rejectAgreement(): void {
|
||||
emit("update:modelValue", false);
|
||||
emit("reject");
|
||||
}
|
||||
|
||||
function agreeAgreement(): void {
|
||||
emit("update:modelValue", true);
|
||||
emit("agree");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -219,22 +229,15 @@ function agreeAgreement(): void {
|
||||
|
||||
:global(.user-agreement-dialog.t-dialog .t-dialog__body) {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
text-align: unset;
|
||||
}
|
||||
|
||||
:global(.user-agreement-dialog.t-dialog .t-dialog__body-text) {
|
||||
width: 100%;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
:global(.user-agreement-dialog.t-dialog .t-dialog__footer) {
|
||||
--td-spacer-1: 0;
|
||||
--td-button-border-radius: 1rem;
|
||||
padding: 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.dialog-content {
|
||||
@@ -242,6 +245,7 @@ function agreeAgreement(): void {
|
||||
|
||||
gap: .5rem;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
flex: 1 1 auto;
|
||||
display: flex;
|
||||
@@ -251,12 +255,17 @@ function agreeAgreement(): void {
|
||||
.tabs {
|
||||
--td-tab-item-height: 2rem;
|
||||
|
||||
width: 100%;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
|
||||
:deep(.t-tabs__nav) {
|
||||
border-bottom: 1px solid var(--td-component-border);
|
||||
}
|
||||
|
||||
:deep(.t-tabs__content) {
|
||||
flex: 1 1 auto;
|
||||
@@ -269,10 +278,13 @@ function agreeAgreement(): void {
|
||||
padding: 0 .5rem;
|
||||
font-size: .75rem;
|
||||
}
|
||||
|
||||
:deep(.t-tabs__item--active) {
|
||||
font-weight: unset;
|
||||
}
|
||||
}
|
||||
|
||||
.agreement-item {
|
||||
padding-top: 1rem;
|
||||
.panel {
|
||||
|
||||
.loading {
|
||||
padding: 1.5rem 0;
|
||||
@@ -301,6 +313,31 @@ function agreeAgreement(): void {
|
||||
}
|
||||
}
|
||||
|
||||
@media (orientation: landscape) and (min-width: 48rem) {
|
||||
:global(.user-agreement-dialog.t-dialog) {
|
||||
--td-dialog-width: min(80vw, 48rem);
|
||||
}
|
||||
|
||||
.user-agreement-dialog {
|
||||
:global(.user-agreement-dialog.t-dialog .t-dialog__content) {
|
||||
height: min(76vh, 36rem);
|
||||
max-height: min(76vh, 36rem);
|
||||
}
|
||||
|
||||
.dialog-content {
|
||||
.tips {
|
||||
br {
|
||||
display: none;
|
||||
}
|
||||
|
||||
span + span::before {
|
||||
content: ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global(html.theme-dark) {
|
||||
.user-agreement {
|
||||
.checkbox {
|
||||
@@ -310,7 +347,7 @@ function agreeAgreement(): void {
|
||||
|
||||
.user-agreement-dialog {
|
||||
.dialog-content {
|
||||
.hint {
|
||||
.tips {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,12 @@ export default [
|
||||
},
|
||||
meta: meta(4)
|
||||
},
|
||||
{
|
||||
path: "/management/customer-recycle-accounts",
|
||||
name: "CustomerRecycleList",
|
||||
component: () => import("@/pages/customer/CustomerRecycleList.vue"),
|
||||
meta: meta()
|
||||
},
|
||||
{
|
||||
path: "/management/recycle-accounts",
|
||||
name: "RecycleAccount",
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 更新日志查询参数
|
||||
*
|
||||
* 内部用驼峰,下划线协议字段在 API 层转换,避免业务代码出现 snake_case
|
||||
*/
|
||||
export type AppUpdateNotesQuery = {
|
||||
/** 产品标识,与 capacitor.config.ts 的 appId 一致 */
|
||||
appId: string;
|
||||
/** 当前运行的 Web 包版本,内置包为 builtin */
|
||||
versionName?: string;
|
||||
/** 当前原生 versionCode */
|
||||
versionCode?: string;
|
||||
/** 平台 */
|
||||
platform?: string;
|
||||
/** 通道代码 */
|
||||
channel?: string;
|
||||
};
|
||||
|
||||
/** 单条版本变更说明 */
|
||||
export type AppUpdateNote = {
|
||||
/** 版本号 */
|
||||
version: string;
|
||||
/** 变更说明,markdown 原文 */
|
||||
note: string;
|
||||
/** 首次发布时间,回滚上线的版本可能为空 */
|
||||
publishedAt?: number;
|
||||
};
|
||||
|
||||
/** 更新日志响应 */
|
||||
export type AppUpdateNotesResult = {
|
||||
/** 通道当前版本号,为空表示没有可展示的版本 */
|
||||
version?: string;
|
||||
/** 变更说明,按版本号从新到旧 */
|
||||
notes: AppUpdateNote[];
|
||||
};
|
||||
@@ -105,7 +105,11 @@ export type QuickFulfillmentSourceOrderItem = {
|
||||
export type QuickFulfillmentSourceOrder = {
|
||||
id: string;
|
||||
orderNo?: string;
|
||||
orderType?: "PACKAGE" | "DIRECT_PRODUCT";
|
||||
orderType?: "PACKAGE" | "DIRECT_PRODUCT" | "RECYCLE";
|
||||
recycleItemName?: string | null;
|
||||
recycleUnit?: string | null;
|
||||
recycleRequiredQuantity?: number | string | null;
|
||||
recycleVerifiedQuantity?: number | string | null;
|
||||
paymentStatus?: GaoSalesPaymentStatus;
|
||||
packageName?: string;
|
||||
saleAmount?: number | null;
|
||||
|
||||
@@ -188,6 +188,13 @@ export type RecycleAccount = {
|
||||
updatedAt?: number;
|
||||
};
|
||||
|
||||
/** 客户回收物分页与按回收物分组的余额汇总。 */
|
||||
export type RecycleCustomerAccountPage = {
|
||||
list: { customer: Customer; accounts: RecycleAccount[] }[];
|
||||
total: number;
|
||||
totals: RecycleAccount[];
|
||||
};
|
||||
|
||||
/**
|
||||
* 额度流水。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user