增加了手机操作端

This commit is contained in:
wushumin
2026-05-15 14:01:36 +08:00
parent 9aac78b8da
commit dd56e0861b
107 changed files with 23547 additions and 346 deletions

View File

@@ -0,0 +1,224 @@
<script setup lang="ts">
import { computed, reactive, ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { adminApi } from "../../api/admin";
import {
availableWorkRoles,
getAdminInfo,
getSelectedWorkRole,
hasAnyWorkPermission,
isLoggedIn,
navigateAfterLogin,
roleText,
setAdminInfo,
setAdminToken,
setSelectedWorkRole,
type WorkRole,
} from "../../utils/auth";
import { showErrorToast, showInfoToast, withLoading } from "../../utils/feedback";
const submitting = ref(false);
const redirect = ref("");
const choosingRole = ref(false);
const roleOptions = ref<WorkRole[]>([]);
const form = reactive({
mobile: "",
password: "",
});
const canSubmit = computed(() => form.mobile.trim() !== "" && form.password.trim() !== "");
const roleOptionText = (role: WorkRole) => (role === "warehouse" ? "仓管作业" : "鉴定师作业");
const roleOptionDesc = (role: WorkRole) =>
role === "warehouse" ? "扫码入库、出库,并查看订单中心。" : "处理鉴定工单,上传图片和视频证据。";
function finishLoginWithRole(role: WorkRole) {
if (!setSelectedWorkRole(role, getAdminInfo())) {
showInfoToast("当前账号无此角色权限");
return;
}
showInfoToast(`已选择${roleText(role)}`);
navigateAfterLogin(redirect.value || "/pages/scan/index");
}
async function handleSubmit() {
if (submitting.value) return;
if (!canSubmit.value) {
showInfoToast("请输入手机号和密码");
return;
}
submitting.value = true;
try {
const result = await withLoading("正在登录", () => adminApi.login(form.mobile.trim(), form.password.trim()));
if (!hasAnyWorkPermission(result.admin_info)) {
throw new Error("当前账号没有作业端权限");
}
const roles = availableWorkRoles(result.admin_info);
setAdminToken(result.token);
setAdminInfo(result.admin_info);
if (roles.length > 1) {
roleOptions.value = roles;
choosingRole.value = true;
showInfoToast("请选择本次登录角色");
return;
}
if (roles[0]) {
setSelectedWorkRole(roles[0], result.admin_info);
}
showInfoToast("登录成功");
navigateAfterLogin(redirect.value || "/pages/scan/index");
} catch (error) {
showErrorToast(error, "登录失败");
} finally {
submitting.value = false;
}
}
onLoad((options) => {
redirect.value = String(options?.redirect || "");
const info = getAdminInfo();
if (isLoggedIn() && hasAnyWorkPermission(info)) {
const roles = availableWorkRoles(info);
const selectedRole = getSelectedWorkRole();
if (roles.length > 1 && !selectedRole) {
roleOptions.value = roles;
choosingRole.value = true;
return;
}
if (roles.length === 1 && roles[0]) {
setSelectedWorkRole(roles[0], info);
}
navigateAfterLogin(redirect.value || "/pages/scan/index");
}
});
</script>
<template>
<view class="login-page">
<view class="login-card">
<view class="brand-row">
<image class="brand-logo" src="/static/logo.png" mode="aspectFit" />
<view>
<view class="brand-name">安心验作业端</view>
<view class="brand-desc">仓管与鉴定师移动作业</view>
</view>
</view>
<view class="form-stack">
<template v-if="!choosingRole">
<input v-model="form.mobile" class="field" type="number" placeholder="管理员手机号" />
<input v-model="form.password" class="field" type="password" placeholder="登录密码" @confirm="handleSubmit" />
</template>
<template v-else>
<view class="role-title">选择本次登录角色</view>
<view
v-for="item in roleOptions"
:key="item"
class="role-option"
@click="finishLoginWithRole(item)"
>
<view>
<view class="role-name">{{ roleOptionText(item) }}</view>
<view class="role-desc">{{ roleOptionDesc(item) }}</view>
</view>
<text class="role-arrow">进入</text>
</view>
</template>
</view>
<button v-if="!choosingRole" class="btn btn--primary login-submit" :disabled="submitting" @click="handleSubmit">
{{ submitting ? "登录中" : "登录" }}
</button>
</view>
</view>
</template>
<style scoped lang="scss">
.login-page {
min-height: 100vh;
padding: 96rpx 32rpx 40rpx;
background: var(--work-bg);
}
.login-card {
padding: 42rpx 32rpx 34rpx;
border: 1px solid var(--work-border);
border-radius: 20rpx;
background: #ffffff;
box-shadow: var(--work-shadow);
}
.brand-row {
display: flex;
align-items: center;
gap: 20rpx;
}
.brand-logo {
width: 88rpx;
height: 88rpx;
border-radius: 16rpx;
background: var(--work-card-muted);
}
.brand-name {
color: var(--work-text);
font-size: 38rpx;
font-weight: 800;
line-height: 1.2;
}
.brand-desc {
margin-top: 8rpx;
color: var(--work-text-soft);
font-size: 26rpx;
}
.form-stack {
display: grid;
gap: 18rpx;
margin-top: 48rpx;
}
.login-submit {
margin-top: 28rpx;
}
.role-title {
color: var(--work-text);
font-size: 30rpx;
font-weight: 800;
}
.role-option {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18rpx;
min-height: 132rpx;
padding: 22rpx;
border: 1px solid var(--work-border);
border-radius: var(--work-radius-sm);
background: var(--work-card-muted);
}
.role-name {
color: var(--work-text);
font-size: 30rpx;
font-weight: 800;
}
.role-desc {
margin-top: 8rpx;
color: var(--work-text-soft);
font-size: 24rpx;
line-height: 1.45;
}
.role-arrow {
flex: 0 0 auto;
color: var(--work-accent-deep);
font-size: 24rpx;
font-weight: 800;
}
</style>

View File

@@ -0,0 +1,195 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { adminApi } from "../../api/admin";
import {
APPRAISAL_PERMISSION,
REPORT_PERMISSION,
WAREHOUSE_PERMISSION,
availableWorkRoles,
getAdminInfo,
hasPermission,
logoutAndRedirect,
resolveWorkRole,
roleText,
setAdminInfo,
setSelectedWorkRole,
type AdminSessionInfo,
type WorkRole,
} from "../../utils/auth";
import { showErrorToast, showInfoToast, withLoading } from "../../utils/feedback";
const adminInfo = ref<AdminSessionInfo | null>(getAdminInfo());
const currentRole = ref<WorkRole>(resolveWorkRole(adminInfo.value));
const currentRoleText = computed(() => roleText(currentRole.value));
const workRoles = computed(() => availableWorkRoles(adminInfo.value));
const canSwitchRole = computed(() => workRoles.value.length > 1);
const permissionTags = computed(() => {
const tags = [];
if (hasPermission(WAREHOUSE_PERMISSION, adminInfo.value)) tags.push("仓管作业");
if (hasPermission(APPRAISAL_PERMISSION, adminInfo.value)) tags.push("鉴定工单");
if (hasPermission(REPORT_PERMISSION, adminInfo.value)) tags.push("报告查看");
return tags;
});
const roleOptionText = (role: WorkRole) => (role === "warehouse" ? "仓管作业" : "鉴定师作业");
async function refreshMe() {
try {
const data = await adminApi.getAuthMe();
adminInfo.value = data.admin_info;
setAdminInfo(data.admin_info);
currentRole.value = resolveWorkRole(data.admin_info);
} catch (error) {
showErrorToast(error, "账号信息加载失败");
}
}
function switchRole(role: WorkRole) {
if (role === currentRole.value) return;
if (!setSelectedWorkRole(role, adminInfo.value)) {
showInfoToast("当前账号无此角色权限");
return;
}
currentRole.value = role;
showInfoToast(`已切换为${roleText(role)}`);
}
async function handleLogout() {
try {
await withLoading("正在退出", () => adminApi.logout());
} catch {
// Token may already be invalid; local logout still needs to complete.
}
logoutAndRedirect();
}
function copyMobile() {
const mobile = adminInfo.value?.mobile || "";
if (!mobile) return;
uni.setClipboardData({
data: mobile,
success: () => showInfoToast("手机号已复制"),
});
}
onShow(() => {
adminInfo.value = getAdminInfo();
currentRole.value = resolveWorkRole(adminInfo.value);
});
</script>
<template>
<view class="page">
<view class="hero">
<view class="eyebrow">当前角色{{ currentRoleText }}</view>
<view class="title">我的</view>
<view class="subtitle">查看当前作业账号权限和登录状态</view>
</view>
<view class="card profile-card">
<view class="avatar">{{ (adminInfo?.name || "作").slice(0, 1) }}</view>
<view class="profile-main">
<view class="profile-name">{{ adminInfo?.name || "未登录" }}</view>
<view class="profile-meta" @click="copyMobile">{{ adminInfo?.mobile || "-" }}</view>
</view>
</view>
<view v-if="canSwitchRole" class="card">
<view class="card-title">作业角色</view>
<view class="role-switch segmented">
<view
v-for="item in workRoles"
:key="item"
:class="['segment', currentRole === item ? 'segment--active' : '']"
@click="switchRole(item)"
>
{{ roleOptionText(item) }}
</view>
</view>
</view>
<view class="card">
<view class="card-title">权限</view>
<view class="permission-list">
<text v-for="item in permissionTags" :key="item" class="tag">{{ item }}</text>
<text v-if="!permissionTags.length" class="tag tag--warning">暂无作业权限</text>
</view>
<view class="role-list">
<view v-for="item in adminInfo?.role_names || []" :key="item" class="role-row">{{ item }}</view>
</view>
</view>
<view class="card action-card">
<button class="btn" @click="refreshMe">刷新账号信息</button>
<button class="btn btn--danger" @click="handleLogout">退出登录</button>
</view>
</view>
</template>
<style scoped lang="scss">
.profile-card {
display: flex;
align-items: center;
gap: 22rpx;
}
.avatar {
width: 96rpx;
height: 96rpx;
border-radius: 20rpx;
background: var(--work-accent);
color: #ffffff;
font-size: 40rpx;
font-weight: 800;
line-height: 96rpx;
text-align: center;
}
.profile-main {
min-width: 0;
}
.profile-name {
color: var(--work-text);
font-size: 34rpx;
font-weight: 800;
}
.profile-meta {
margin-top: 8rpx;
color: var(--work-text-soft);
font-size: 26rpx;
}
.permission-list {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
margin-top: 20rpx;
}
.role-list {
display: grid;
gap: 12rpx;
margin-top: 20rpx;
}
.role-switch {
grid-template-columns: repeat(2, 1fr);
margin-top: 20rpx;
}
.role-row {
padding: 18rpx 20rpx;
border-radius: var(--work-radius-sm);
background: var(--work-card-muted);
color: var(--work-text-soft);
font-size: 26rpx;
}
.action-card {
display: grid;
gap: 16rpx;
}
</style>

View File

@@ -0,0 +1,215 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { adminApi, type AdminOrderDetail } from "../../api/admin";
import { showErrorToast } from "../../utils/feedback";
const loading = ref(false);
const pageReady = ref(false);
const loadError = ref("");
const detail = ref<AdminOrderDetail | null>(null);
const orderId = ref(0);
const pageTitle = computed(() => detail.value?.order_info.order_no || "订单详情");
const timeline = computed(() => detail.value?.timeline || []);
async function fetchDetail() {
if (!orderId.value) return;
loading.value = true;
if (!pageReady.value) loadError.value = "";
try {
detail.value = await adminApi.getOrderDetail(orderId.value);
pageReady.value = true;
} catch (error) {
if (!pageReady.value) {
loadError.value = "订单详情加载失败,请稍后重试。";
}
showErrorToast(error, "订单详情加载失败");
} finally {
loading.value = false;
}
}
function openReportDetail() {
const reportId = Number(detail.value?.report_summary?.id || 0);
if (!reportId) return;
uni.navigateTo({ url: `/pages/report/detail?id=${reportId}` });
}
function formatMoney(value?: number) {
const amount = Number(value || 0);
return `¥${amount.toFixed(2)}`;
}
function displayAddress(address?: { consignee?: string; mobile?: string; full_address?: string } | null) {
if (!address) return "-";
return [address.consignee, address.mobile, address.full_address].filter(Boolean).join(" / ");
}
onLoad((options) => {
orderId.value = Number(options?.id || 0);
if (!orderId.value) {
loadError.value = "缺少订单编号,无法查看详情。";
}
});
onShow(() => {
if (orderId.value) {
void fetchDetail();
}
});
</script>
<template>
<view class="page">
<view v-if="!pageReady && loading" class="empty">正在加载订单详情</view>
<view v-else-if="!pageReady && loadError" class="empty">{{ loadError }}</view>
<template v-else-if="detail">
<view class="hero">
<view class="eyebrow">订单详情</view>
<view class="title">{{ pageTitle }}</view>
<view class="subtitle">{{ detail.order_info.appraisal_no }}</view>
</view>
<view class="card">
<view class="row">
<view>
<view class="card-title">{{ detail.product_info.product_name || "待完善物品信息" }}</view>
<view class="card-desc">{{ detail.product_info.category_name || "-" }} / {{ detail.product_info.brand_name || "-" }}</view>
</view>
<text class="tag">{{ detail.order_info.display_status }}</text>
</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">服务类型</view>
<view class="meta-value">{{ detail.order_info.service_provider_text }}</view>
</view>
<view class="meta-item">
<view class="meta-label">订单金额</view>
<view class="meta-value">{{ formatMoney(detail.order_info.pay_amount) }}</view>
</view>
<view class="meta-item">
<view class="meta-label">创建时间</view>
<view class="meta-value">{{ detail.order_info.created_at || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">预计完成</view>
<view class="meta-value">{{ detail.order_info.estimated_finish_time || "-" }}</view>
</view>
</view>
</view>
<view class="card">
<view class="card-title">物品信息</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">商品名称</view>
<view class="meta-value">{{ detail.product_info.product_name || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">品类 / 品牌</view>
<view class="meta-value">{{ detail.product_info.category_name || "-" }} / {{ detail.product_info.brand_name || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">颜色 / 规格</view>
<view class="meta-value">{{ detail.product_info.color || "-" }} / {{ detail.product_info.size_spec || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">序列号</view>
<view class="meta-value">{{ detail.product_info.serial_no || "-" }}</view>
</view>
</view>
</view>
<view class="card">
<view class="card-title">物流与寄回</view>
<view class="stack" style="margin-top: 18rpx">
<view class="meta-item">
<view class="meta-label">寄送到中心</view>
<view class="meta-value">{{ detail.logistics_info ? `${detail.logistics_info.express_company || "-"} / ${detail.logistics_info.tracking_no || "-"}` : "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">寄回地址</view>
<view class="meta-value">{{ displayAddress(detail.return_address) }}</view>
</view>
<view class="meta-item">
<view class="meta-label">回寄运单</view>
<view class="meta-value">{{ detail.return_logistics ? `${detail.return_logistics.express_company || "-"} / ${detail.return_logistics.tracking_no || "-"}` : "-" }}</view>
</view>
</view>
</view>
<view v-if="detail.report_summary" class="card">
<view class="row">
<view>
<view class="card-title">报告摘要</view>
<view class="card-desc">{{ detail.report_summary.report_status_text || detail.report_summary.report_status }}</view>
</view>
<button class="btn btn--ghost" @click="openReportDetail">查看报告</button>
</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">报告编号</view>
<view class="meta-value">{{ detail.report_summary.report_no }}</view>
</view>
<view class="meta-item">
<view class="meta-label">报告标题</view>
<view class="meta-value">{{ detail.report_summary.report_title }}</view>
</view>
<view class="meta-item">
<view class="meta-label">发布时间</view>
<view class="meta-value">{{ detail.report_summary.publish_time || "-" }}</view>
</view>
</view>
</view>
<view class="card">
<view class="card-title">流转时间线</view>
<view class="timeline">
<view v-for="item in timeline" :key="`${item.node_text}-${item.occurred_at}`" class="timeline-item">
<view class="timeline-item__head">
<view class="timeline-item__title">{{ item.node_text }}</view>
<view class="timeline-item__time">{{ item.occurred_at }}</view>
</view>
<view class="timeline-item__desc">{{ item.node_desc }}</view>
</view>
</view>
</view>
</template>
</view>
</template>
<style scoped lang="scss">
.timeline {
display: grid;
gap: 16rpx;
margin-top: 18rpx;
}
.timeline-item {
padding: 18rpx;
border-radius: var(--work-radius-sm);
background: var(--work-card-muted);
}
.timeline-item__head {
display: flex;
justify-content: space-between;
gap: 16rpx;
}
.timeline-item__title {
color: var(--work-text);
font-size: 28rpx;
font-weight: 700;
}
.timeline-item__time,
.timeline-item__desc {
color: var(--work-text-soft);
font-size: 24rpx;
line-height: 1.5;
}
</style>

View File

@@ -0,0 +1,241 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { adminApi, type AdminReportDetail } from "../../api/admin";
import { showErrorToast } from "../../utils/feedback";
const loading = ref(false);
const pageReady = ref(false);
const loadError = ref("");
const detail = ref<AdminReportDetail | null>(null);
const reportId = ref(0);
const isZhongjian = computed(() => detail.value?.report_header.service_provider === "zhongjian");
function previewImage(urls: string[], current: string) {
if (!urls.length) return;
uni.previewImage({ urls, current });
}
function openAsset(item: { file_url: string; file_type?: string; thumbnail_url?: string }) {
if (item.file_type === "image") {
const urls = [
...(detail.value?.evidence_attachments || []).map((asset) => asset.file_url),
...(detail.value?.zhongjian_report_files || []).map((asset) => asset.file_url),
];
previewImage(urls, item.file_url);
return;
}
if (item.file_type === "video") {
const previewMedia = (uni as any).previewMedia;
if (typeof previewMedia === "function") {
previewMedia({
sources: [{ url: item.file_url, type: "video", poster: item.thumbnail_url || "" }],
current: 0,
});
return;
}
}
if (item.file_type === "pdf") {
uni.downloadFile({
url: item.file_url,
success: (response) => {
if (response.statusCode !== 200 || !response.tempFilePath) {
uni.showToast({ title: "附件打开失败", icon: "none" });
return;
}
uni.openDocument({
filePath: response.tempFilePath,
fileType: "pdf",
showMenu: true,
});
},
fail: () => uni.showToast({ title: "附件打开失败", icon: "none" }),
});
return;
}
uni.showToast({ title: "当前附件暂不支持打开", icon: "none" });
}
async function fetchDetail() {
if (!reportId.value) return;
loading.value = true;
if (!pageReady.value) {
loadError.value = "";
}
try {
detail.value = await adminApi.getReportDetail(reportId.value);
pageReady.value = true;
} catch (error) {
if (!pageReady.value) {
loadError.value = "报告详情加载失败,请稍后重试。";
}
showErrorToast(error, "报告详情加载失败");
} finally {
loading.value = false;
}
}
onLoad((options) => {
reportId.value = Number(options?.id || 0);
if (!reportId.value) {
loadError.value = "缺少报告编号,无法查看详情。";
}
});
onShow(() => {
if (reportId.value) {
void fetchDetail();
}
});
</script>
<template>
<view class="page">
<view v-if="!pageReady && loading" class="empty">正在加载报告详情</view>
<view v-else-if="!pageReady && loadError" class="empty">{{ loadError }}</view>
<template v-else-if="detail">
<view class="hero">
<view class="eyebrow">报告详情</view>
<view class="title">{{ detail.report_header.report_title }}</view>
<view class="subtitle">{{ detail.report_header.report_no }}</view>
</view>
<view class="card">
<view class="row">
<view>
<view class="card-title">{{ detail.report_header.report_status_text }}</view>
<view class="card-desc">{{ detail.report_header.institution_name }}</view>
</view>
<text class="tag">{{ detail.report_header.service_provider_text }}</text>
</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">发布时间</view>
<view class="meta-value">{{ detail.report_header.publish_time || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">录入人</view>
<view class="meta-value">{{ detail.report_header.report_entry_admin_name || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">中检报告号</view>
<view class="meta-value">{{ detail.report_header.zhongjian_report_no || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">验真次数</view>
<view class="meta-value">{{ detail.verify_info.verify_count }}</view>
</view>
</view>
</view>
<view class="card">
<view class="card-title">商品信息</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">商品名称</view>
<view class="meta-value">{{ detail.product_info.product_name || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">品类 / 品牌</view>
<view class="meta-value">{{ detail.product_info.category_name || "-" }} / {{ detail.product_info.brand_name || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">颜色 / 规格</view>
<view class="meta-value">{{ detail.product_info.color || "-" }} / {{ detail.product_info.size_spec || "-" }}</view>
</view>
</view>
</view>
<view class="card">
<view class="card-title">鉴定结果</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">结论</view>
<view class="meta-value">{{ detail.result_info.result_text || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">结论说明</view>
<view class="meta-value">{{ detail.result_info.result_desc || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">评级</view>
<view class="meta-value">{{ detail.valuation_info.condition_grade || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">估值区间</view>
<view class="meta-value">¥{{ detail.valuation_info.valuation_min || 0 }} - ¥{{ detail.valuation_info.valuation_max || 0 }}</view>
</view>
</view>
</view>
<view class="card">
<view class="card-title">附件</view>
<view v-if="detail.evidence_attachments.length" class="list" style="margin-top: 18rpx">
<view
v-for="item in detail.evidence_attachments"
:key="item.file_id"
class="list-card"
@click="openAsset(item)"
>
<view class="row">
<view class="list-title">{{ item.name || item.file_id }}</view>
<text class="tag">{{ item.file_type || "附件" }}</text>
</view>
</view>
</view>
<view v-else class="empty" style="padding: 24rpx 0">暂无证据附件</view>
</view>
<view v-if="detail.zhongjian_report_files.length" class="card">
<view class="card-title">中检报告文件</view>
<view class="list" style="margin-top: 18rpx">
<view
v-for="item in detail.zhongjian_report_files"
:key="item.file_id"
class="list-card"
@click="openAsset(item)"
>
<view class="row">
<view class="list-title">{{ item.name || item.file_id }}</view>
<text class="tag">{{ item.file_type || "附件" }}</text>
</view>
</view>
</view>
</view>
<view class="card">
<view class="card-title">验真信息</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">验真状态</view>
<view class="meta-value">{{ isZhongjian ? "中检报告" : detail.verify_info.verify_status || "valid" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">验真页</view>
<view class="meta-value">{{ detail.verify_info.verify_url || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">验真二维码</view>
<view class="meta-value">{{ detail.verify_info.verify_qrcode_url || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">报告页</view>
<view class="meta-value">{{ detail.verify_info.report_page_url || "-" }}</view>
</view>
</view>
</view>
</template>
</view>
</template>
<style scoped lang="scss">
.list {
display: grid;
gap: 14rpx;
}
</style>

View File

@@ -0,0 +1,372 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { adminApi, type AdminWarehouseWorkbenchContext } from "../../api/admin";
import {
getAdminInfo,
resolveWorkRole,
roleText,
type WorkRole,
} from "../../utils/auth";
import { showErrorToast, showInfoToast, withLoading } from "../../utils/feedback";
type WarehouseMode = "inbound" | "outbound" | "lookup";
const role = ref<WorkRole>(resolveWorkRole());
const mode = ref<WarehouseMode>("inbound");
const scanValue = ref("");
const internalTagNo = ref("");
const materialQr = ref("");
const expressCompany = ref("");
const returnTrackingNo = ref("");
const context = ref<AdminWarehouseWorkbenchContext | null>(null);
const loading = ref(false);
const actionLoading = ref(false);
const isWarehouse = computed(() => role.value === "warehouse");
const roleLabel = computed(() => roleText(role.value));
const pageDesc = computed(() =>
isWarehouse.value ? "扫描快递单号或内部流转挂牌,完成入库、出库和查单。" : "扫描内部流转挂牌,进入鉴定工单处理。",
);
const primaryPlaceholder = computed(() => {
if (!isWarehouse.value) return "扫描内部流转码";
return mode.value === "inbound" ? "扫描寄入运单号" : "扫描内部流转挂牌";
});
const canReceiveInbound = computed(() =>
mode.value === "inbound" &&
Boolean(context.value) &&
context.value?.order_info.order_status === "pending_shipping" &&
context.value?.logistics_info?.tracking_status !== "received" &&
context.value?.transfer_flow?.current_stage !== "warehouse_received",
);
const canReturnShip = computed(() => Boolean(context.value?.transfer_flow?.return_confirmed_at));
function refreshRole() {
role.value = resolveWorkRole(getAdminInfo());
}
function chooseMode(next: WarehouseMode) {
mode.value = next;
scanValue.value = "";
internalTagNo.value = "";
materialQr.value = "";
expressCompany.value = "";
returnTrackingNo.value = "";
context.value = null;
}
function applyScanResult(value: string) {
if (!value) return;
scanValue.value = value.trim();
void handlePrimaryAction();
}
function openScanner() {
uni.scanCode({
scanType: ["barCode", "qrCode"],
success: (result) => applyScanResult(String(result.result || "")),
fail: () => showInfoToast("当前环境暂不支持扫码,可手动输入"),
});
}
async function handlePrimaryAction() {
if (!scanValue.value.trim()) {
showInfoToast(primaryPlaceholder.value);
return;
}
if (!isWarehouse.value) {
await scanAppraisalTask();
return;
}
if (mode.value === "inbound") {
await lookupInbound();
return;
}
if (mode.value === "outbound") {
await lookupOutbound();
return;
}
await lookupAnyOrder();
}
async function lookupInbound() {
loading.value = true;
try {
context.value = await adminApi.lookupWarehouseInbound(scanValue.value.trim());
showInfoToast("已匹配订单");
} catch (error) {
context.value = null;
showErrorToast(error, "入库查询失败");
} finally {
loading.value = false;
}
}
async function receiveInbound() {
if (!scanValue.value.trim() || !internalTagNo.value.trim()) {
showInfoToast("请填写寄入运单号和内部流转挂牌");
return;
}
actionLoading.value = true;
try {
context.value = await withLoading("正在入库", () =>
adminApi.receiveWarehouseInbound({
tracking_no: scanValue.value.trim(),
internal_tag_no: internalTagNo.value.trim(),
}),
);
showInfoToast("入库完成");
internalTagNo.value = "";
} catch (error) {
showErrorToast(error, "入库失败");
} finally {
actionLoading.value = false;
}
}
async function lookupOutbound() {
loading.value = true;
try {
try {
context.value = await adminApi.lookupZhongjianWarehouseTransfer(scanValue.value.trim());
showInfoToast("已识别中检流转");
return;
} catch (zhongjianError) {
context.value = await adminApi.lookupWarehouseReturn(scanValue.value.trim());
showInfoToast("已打开寄回流程");
}
} catch (error) {
context.value = null;
showErrorToast(error, "出库查询失败");
} finally {
loading.value = false;
}
}
async function submitOutboundAction() {
if (!context.value) {
await lookupOutbound();
return;
}
actionLoading.value = true;
try {
if (context.value.next_action === "outbound") {
context.value = await adminApi.zhongjianWarehouseOutbound(scanValue.value.trim());
showInfoToast("送检出库完成");
return;
}
if (context.value.next_action === "inbound") {
context.value = await adminApi.zhongjianWarehouseInbound(scanValue.value.trim());
showInfoToast("送检入库完成");
return;
}
if (context.value.order_info.service_provider === "zhongjian") {
context.value = await adminApi.confirmWarehouseReturnZhongjian(scanValue.value.trim());
showInfoToast("中检报告已确认");
return;
}
if (!canReturnShip.value) {
if (!materialQr.value.trim()) {
showInfoToast("请扫描验真吊牌");
return;
}
context.value = await adminApi.verifyWarehouseReturnMaterialTag({
internal_tag_no: scanValue.value.trim(),
qr_input: materialQr.value.trim(),
});
showInfoToast("验真吊牌已确认");
return;
}
if (!expressCompany.value.trim() || !returnTrackingNo.value.trim()) {
showInfoToast("请填写回寄快递和运单号");
return;
}
context.value = await adminApi.shipWarehouseReturn({
internal_tag_no: scanValue.value.trim(),
express_company: expressCompany.value.trim(),
tracking_no: returnTrackingNo.value.trim(),
});
showInfoToast("回寄运单已登记");
} catch (error) {
showErrorToast(error, "出库操作失败");
} finally {
actionLoading.value = false;
}
}
async function lookupAnyOrder() {
loading.value = true;
try {
try {
context.value = await adminApi.lookupWarehouseInbound(scanValue.value.trim());
return;
} catch {
context.value = await adminApi.lookupWarehouseReturn(scanValue.value.trim());
}
} catch (error) {
context.value = null;
showErrorToast(error, "查单失败");
} finally {
loading.value = false;
}
}
async function scanAppraisalTask() {
loading.value = true;
try {
const data = await adminApi.scanAppraisalTransferTag(scanValue.value.trim());
showInfoToast("工单已打开");
uni.navigateTo({ url: `/pages/task/detail?id=${data.task_id}` });
} catch (error) {
showErrorToast(error, "内部流转码识别失败");
} finally {
loading.value = false;
}
}
function scanInternalTagInput() {
uni.scanCode({
scanType: ["barCode", "qrCode"],
success: (result) => {
internalTagNo.value = String(result.result || "").trim();
},
fail: () => showInfoToast("当前环境暂不支持扫码,可手动输入"),
});
}
function scanMaterialQr() {
uni.scanCode({
scanType: ["barCode", "qrCode"],
success: (result) => {
materialQr.value = String(result.result || "").trim();
},
fail: () => showInfoToast("当前环境暂不支持扫码,可手动输入"),
});
}
onShow(refreshRole);
</script>
<template>
<view class="page">
<view class="hero">
<view class="eyebrow">{{ roleLabel }}作业</view>
<view class="title">扫码</view>
<view class="subtitle">{{ pageDesc }}</view>
</view>
<view v-if="isWarehouse" class="card">
<view class="segmented">
<view :class="['segment', mode === 'inbound' ? 'segment--active' : '']" @click="chooseMode('inbound')">入库</view>
<view :class="['segment', mode === 'outbound' ? 'segment--active' : '']" @click="chooseMode('outbound')">出库</view>
<view :class="['segment', mode === 'lookup' ? 'segment--active' : '']" @click="chooseMode('lookup')">查单</view>
</view>
</view>
<view class="card">
<view class="card-title">{{ primaryPlaceholder }}</view>
<view class="scan-control">
<input v-model="scanValue" class="field scan-input" :placeholder="primaryPlaceholder" @confirm="handlePrimaryAction" />
<button class="btn scan-button" @click="openScanner">扫码</button>
</view>
<button class="btn btn--primary main-action" :disabled="loading" @click="handlePrimaryAction">
{{ loading ? "处理中" : isWarehouse ? "识别" : "打开工单" }}
</button>
</view>
<view v-if="canReceiveInbound" class="card">
<view class="card-title">入库绑定</view>
<view class="scan-control">
<input v-model="internalTagNo" class="field scan-input" placeholder="内部流转挂牌" />
<button class="btn scan-button" @click="scanInternalTagInput">扫码</button>
</view>
<button class="btn btn--primary main-action" :disabled="actionLoading" @click="receiveInbound">
{{ actionLoading ? "入库中" : "确认入库" }}
</button>
</view>
<view v-if="mode === 'outbound' && context" class="card">
<view class="card-title">出库动作</view>
<view class="card-desc">
{{ context.next_action_text || (context.order_info.service_provider === 'zhongjian' ? '确认中检报告后回寄' : '确认验真吊牌后回寄') }}
</view>
<view v-if="context.order_info.service_provider !== 'zhongjian' && !canReturnShip && !context.next_action" class="scan-control">
<input v-model="materialQr" class="field scan-input" placeholder="验真吊牌二维码" />
<button class="btn scan-button" @click="scanMaterialQr">扫码</button>
</view>
<view v-if="canReturnShip && !context.next_action" class="ship-fields">
<input v-model="expressCompany" class="field" placeholder="回寄快递公司" />
<input v-model="returnTrackingNo" class="field" placeholder="回寄运单号" />
</view>
<button class="btn btn--primary main-action" :disabled="actionLoading" @click="submitOutboundAction">
{{ actionLoading ? "提交中" : "确认操作" }}
</button>
</view>
<view v-if="context" class="card">
<view class="row">
<view>
<view class="card-title">{{ context.product_info.product_name || "待完善物品信息" }}</view>
<view class="card-desc">{{ context.order_info.order_no }} / {{ context.order_info.appraisal_no }}</view>
</view>
<text class="tag">{{ context.order_info.display_status }}</text>
</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">服务</view>
<view class="meta-value">{{ context.order_info.service_provider_text }}</view>
</view>
<view class="meta-item">
<view class="meta-label">内部挂牌</view>
<view class="meta-value">{{ context.transfer_flow?.internal_tag_no || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">流转阶段</view>
<view class="meta-value">{{ context.transfer_flow?.current_stage_text || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">当前位置</view>
<view class="meta-value">{{ context.transfer_flow?.current_location_text || "-" }}</view>
</view>
</view>
<view v-if="context.return_address" class="return-box">
<view class="meta-label">寄回地址</view>
<view class="meta-value">{{ context.return_address.consignee }} / {{ context.return_address.mobile }} / {{ context.return_address.full_address }}</view>
</view>
</view>
</view>
</template>
<style scoped lang="scss">
.scan-control {
display: flex;
gap: 14rpx;
margin-top: 22rpx;
}
.scan-input {
flex: 1;
min-width: 0;
}
.scan-button {
width: 132rpx;
}
.main-action {
margin-top: 18rpx;
}
.ship-fields {
display: grid;
gap: 14rpx;
margin-top: 20rpx;
}
.return-box {
margin-top: 20rpx;
padding: 18rpx;
border-radius: var(--work-radius-sm);
background: var(--work-warning-soft);
}
</style>

View File

@@ -0,0 +1,705 @@
<script setup lang="ts">
import { computed, reactive, ref } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { adminApi, type AdminAppraisalTaskDetail, type AdminFileAsset } from "../../api/admin";
import { showErrorToast, showInfoToast, withLoading } from "../../utils/feedback";
const loading = ref(false);
const submitting = ref(false);
const supplementSubmitting = ref(false);
const uploading = ref(false);
const pageReady = ref(false);
const loadError = ref("");
const detail = ref<AdminAppraisalTaskDetail | null>(null);
const taskId = ref(0);
const activeSection = ref<"result" | "supplement" | "zhongjian">("result");
const resultText = ref("");
const resultDesc = ref("");
const conditionGrade = ref("");
const conditionDesc = ref("");
const valuationMin = ref("");
const valuationMax = ref("");
const valuationDesc = ref("");
const externalRemark = ref("");
const internalRemark = ref("");
const zhongjianReportNo = ref("");
const zhongjianFiles = ref<AdminFileAsset[]>([]);
const evidenceFiles = ref<AdminFileAsset[]>([]);
const supplementForm = reactive({
reason: "",
deadline: "",
items: [{ item_name: "", guide_text: "", is_required: true }],
});
const isZhongjian = computed(() => detail.value?.task_info.service_provider === "zhongjian");
const resultSummary = computed(() => detail.value?.result_info.result_text || "暂未填写");
const reportSummary = computed(() => detail.value?.report_summary?.report_no || "");
type AppraisalTemplate = NonNullable<AdminAppraisalTaskDetail["appraisal_template"]>;
function hasConditionFields(template?: AppraisalTemplate | null) {
return (template?.condition_options?.length || 0) > 0;
}
function hasValuationFields(template?: AppraisalTemplate | null) {
return Boolean((template?.valuation_hint || "").trim());
}
const showConditionFields = computed(() => hasConditionFields(detail.value?.appraisal_template));
const showValuationFields = computed(() => hasValuationFields(detail.value?.appraisal_template));
function formatMoneyInput(value: string | number) {
const num = Number(value || 0);
return Number.isFinite(num) ? num : 0;
}
function hydrate(detailData: AdminAppraisalTaskDetail) {
detail.value = detailData;
activeSection.value = detailData.task_info.service_provider === "zhongjian"
? "zhongjian"
: (detailData.supplement_task ? "supplement" : "result");
resultText.value = detailData.result_info.result_text || "";
resultDesc.value = detailData.result_info.result_desc || "";
if (hasConditionFields(detailData.appraisal_template)) {
conditionGrade.value = detailData.result_info.condition_grade || "";
conditionDesc.value = detailData.result_info.condition_desc || "";
} else {
conditionGrade.value = "";
conditionDesc.value = "";
}
if (hasValuationFields(detailData.appraisal_template)) {
valuationMin.value = detailData.result_info.valuation_min ? String(detailData.result_info.valuation_min) : "";
valuationMax.value = detailData.result_info.valuation_max ? String(detailData.result_info.valuation_max) : "";
valuationDesc.value = detailData.result_info.valuation_desc || "";
} else {
valuationMin.value = "";
valuationMax.value = "";
valuationDesc.value = "";
}
externalRemark.value = detailData.result_info.external_remark || "";
internalRemark.value = detailData.result_info.internal_remark || "";
zhongjianReportNo.value = detailData.zhongjian_report?.report_no || "";
zhongjianFiles.value = [...(detailData.zhongjian_report?.files || [])];
evidenceFiles.value = [...(detailData.result_info.attachments || [])];
if (detailData.supplement_task) {
supplementForm.reason = detailData.supplement_task.reason || "";
supplementForm.deadline = detailData.supplement_task.deadline || "";
supplementForm.items.splice(
0,
supplementForm.items.length,
...(detailData.supplement_task.items.length
? detailData.supplement_task.items.map((item) => ({
item_name: item.item_name,
guide_text: item.guide_text,
is_required: item.is_required,
}))
: [{ item_name: "", guide_text: "", is_required: true }]),
);
} else {
supplementForm.reason = "";
supplementForm.deadline = "";
supplementForm.items.splice(0, supplementForm.items.length, {
item_name: "",
guide_text: "",
is_required: true,
});
}
}
async function fetchDetail() {
if (!taskId.value) return;
loading.value = true;
if (!pageReady.value) {
loadError.value = "";
}
try {
const data = await adminApi.getAppraisalTaskDetail(taskId.value);
hydrate(data);
pageReady.value = true;
} catch (error) {
if (!pageReady.value) {
loadError.value = "工单详情加载失败,请稍后重试。";
}
showErrorToast(error, "工单详情加载失败");
} finally {
loading.value = false;
}
}
function addSupplementItem() {
supplementForm.items.push({ item_name: "", guide_text: "", is_required: true });
}
function removeSupplementItem(index: number) {
if (supplementForm.items.length === 1) {
supplementForm.items[0].item_name = "";
supplementForm.items[0].guide_text = "";
supplementForm.items[0].is_required = true;
return;
}
supplementForm.items.splice(index, 1);
}
async function removeEvidenceFile(fileUrl: string) {
try {
await adminApi.deleteAppraisalEvidenceFile(fileUrl);
evidenceFiles.value = evidenceFiles.value.filter((item) => item.file_url !== fileUrl);
showInfoToast("附件已删除");
} catch (error) {
showErrorToast(error, "附件删除失败");
}
}
async function removeZhongjianFile(fileUrl: string) {
try {
await adminApi.deleteAppraisalEvidenceFile(fileUrl);
zhongjianFiles.value = zhongjianFiles.value.filter((item) => item.file_url !== fileUrl);
showInfoToast("文件已删除");
} catch (error) {
showErrorToast(error, "文件删除失败");
}
}
function updateTemplatePoint(index: number, key: "point_value" | "point_remark", value: string) {
const template = detail.value?.appraisal_template;
if (!template) return;
const current = template.key_points[index];
if (!current) return;
current[key] = value;
}
function updateTemplatePointFromInput(
index: number,
key: "point_value" | "point_remark",
event: Event,
) {
const target = event.target as HTMLInputElement | HTMLTextAreaElement | null;
updateTemplatePoint(index, key, target?.value || "");
}
function templateKeyPointsPayload() {
return detail.value?.appraisal_template?.key_points?.map((item) => ({
point_code: item.point_code,
point_name: item.point_name,
point_value: item.point_value || "",
point_remark: item.point_remark || "",
})) || [];
}
function returnToWorkOrders(message: string) {
showInfoToast(message);
setTimeout(() => {
uni.switchTab({ url: "/pages/work-order/index" });
}, 700);
}
async function chooseEvidenceImage() {
try {
const result = await uni.chooseImage({
count: 9,
sizeType: ["compressed"],
sourceType: ["album", "camera"],
});
if (!result.tempFilePaths?.length) return;
uploading.value = true;
for (const filePath of result.tempFilePaths) {
const asset = await adminApi.uploadAppraisalEvidenceFile(filePath);
evidenceFiles.value.push(asset);
}
showInfoToast("图片上传成功");
} catch (error) {
showErrorToast(error, "图片上传失败");
} finally {
uploading.value = false;
}
}
async function chooseEvidenceVideo() {
try {
const result = await uni.chooseVideo({
sourceType: ["album", "camera"],
});
const filePath = result.tempFilePath;
if (!filePath) return;
uploading.value = true;
const asset = await adminApi.uploadAppraisalEvidenceFile(filePath);
evidenceFiles.value.push(asset);
showInfoToast("视频上传成功");
} catch (error) {
showErrorToast(error, "视频上传失败");
} finally {
uploading.value = false;
}
}
async function chooseZhongjianImage() {
try {
const result = await uni.chooseImage({
count: 9,
sizeType: ["compressed"],
sourceType: ["album", "camera"],
});
if (!result.tempFilePaths?.length) return;
uploading.value = true;
for (const filePath of result.tempFilePaths) {
const asset = await adminApi.uploadAppraisalEvidenceFile(filePath);
zhongjianFiles.value.push(asset);
}
showInfoToast("图片上传成功");
} catch (error) {
showErrorToast(error, "图片上传失败");
} finally {
uploading.value = false;
}
}
async function chooseZhongjianVideo() {
try {
const result = await uni.chooseVideo({
sourceType: ["album", "camera"],
});
const filePath = result.tempFilePath;
if (!filePath) return;
uploading.value = true;
const asset = await adminApi.uploadAppraisalEvidenceFile(filePath);
zhongjianFiles.value.push(asset);
showInfoToast("视频上传成功");
} catch (error) {
showErrorToast(error, "视频上传失败");
} finally {
uploading.value = false;
}
}
async function submitResult(action: "save" | "submit") {
if (!detail.value) return;
if (isZhongjian.value) {
showInfoToast("中检订单请切换到中检报告区");
activeSection.value = "zhongjian";
return;
}
if (action === "submit" && !resultText.value.trim()) {
showInfoToast("请先填写鉴定结论");
return;
}
submitting.value = true;
try {
const conditionPayload = showConditionFields.value
? {
condition_grade: conditionGrade.value.trim(),
condition_desc: conditionDesc.value.trim(),
}
: {
condition_grade: "",
condition_desc: "",
};
const valuationPayload = showValuationFields.value
? {
valuation_min: formatMoneyInput(valuationMin.value),
valuation_max: formatMoneyInput(valuationMax.value),
valuation_desc: valuationDesc.value.trim(),
}
: {
valuation_min: 0,
valuation_max: 0,
valuation_desc: "",
};
await withLoading(action === "submit" ? "正在提交鉴定" : "正在保存鉴定", () =>
adminApi.saveAppraisalTaskResult({
id: detail.value!.task_info.id,
action,
product_info: {
category_id: detail.value!.product_info.category_id,
product_name: detail.value!.product_info.product_name,
category_name: detail.value!.product_info.category_name,
brand_name: detail.value!.product_info.brand_name,
color: detail.value!.product_info.color,
size_spec: detail.value!.product_info.size_spec,
serial_no: detail.value!.product_info.serial_no,
},
result_text: resultText.value.trim(),
result_desc: resultDesc.value.trim(),
...conditionPayload,
...valuationPayload,
external_remark: externalRemark.value.trim(),
internal_remark: internalRemark.value.trim(),
attachments: evidenceFiles.value,
key_points: templateKeyPointsPayload(),
}),
);
if (action === "submit") {
returnToWorkOrders("鉴定已提交,正在返回工单");
return;
}
showInfoToast("鉴定已保存");
await fetchDetail();
} catch (error) {
showErrorToast(error, action === "submit" ? "鉴定提交失败" : "鉴定保存失败");
} finally {
submitting.value = false;
}
}
async function submitSupplement() {
if (!detail.value) return;
const items = supplementForm.items.filter((item) => item.item_name.trim());
if (!supplementForm.reason.trim()) {
showInfoToast("请先填写补资料原因");
return;
}
if (!items.length) {
showInfoToast("请至少填写一项补资料要求");
return;
}
supplementSubmitting.value = true;
try {
await adminApi.requestAppraisalTaskSupplement({
id: detail.value.task_info.id,
reason: supplementForm.reason.trim(),
deadline: supplementForm.deadline.trim(),
items: items.map((item) => ({
item_name: item.item_name.trim(),
guide_text: item.guide_text.trim(),
is_required: item.is_required,
})),
});
showInfoToast("已发起补资料要求");
await fetchDetail();
} catch (error) {
showErrorToast(error, "发起补资料失败");
} finally {
supplementSubmitting.value = false;
}
}
async function submitZhongjianReport() {
if (!detail.value) return;
if (!zhongjianReportNo.value.trim()) {
showInfoToast("请填写中检报告编号");
return;
}
if (!zhongjianFiles.value.length) {
showInfoToast("请至少上传 1 个中检报告文件");
return;
}
submitting.value = true;
try {
await adminApi.saveZhongjianAppraisalReport({
id: detail.value.task_info.id,
zhongjian_report_no: zhongjianReportNo.value.trim(),
report_files: zhongjianFiles.value,
});
returnToWorkOrders("中检报告已提交,正在返回工单");
} catch (error) {
showErrorToast(error, "中检报告录入失败");
} finally {
submitting.value = false;
}
}
function openReportDetail() {
const reportId = Number(detail.value?.report_summary?.id || 0);
if (!reportId) return;
uni.navigateTo({ url: `/pages/report/detail?id=${reportId}` });
}
onLoad((options) => {
taskId.value = Number(options?.id || 0);
if (!taskId.value) {
loadError.value = "缺少工单编号,无法查看详情。";
}
});
onShow(() => {
if (taskId.value) {
void fetchDetail();
}
});
</script>
<template>
<view class="page">
<view v-if="!pageReady && loading" class="empty">正在加载工单详情</view>
<view v-else-if="!pageReady && loadError" class="empty">{{ loadError }}</view>
<template v-else-if="detail">
<view class="hero">
<view class="eyebrow">鉴定工单</view>
<view class="title">{{ detail.product_info.product_name || "待完善物品信息" }}</view>
<view class="subtitle">{{ detail.task_info.order_no }} / {{ detail.task_info.appraisal_no }}</view>
</view>
<view class="card">
<view class="row">
<view>
<view class="card-title">{{ detail.task_info.task_stage_text }} · {{ detail.task_info.status_text }}</view>
<view class="card-desc">{{ detail.task_info.service_provider_text }} / {{ detail.task_info.assignee_name }}</view>
</view>
<text class="tag">{{ resultSummary }}</text>
</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">SLA 截止</view>
<view class="meta-value">{{ detail.task_info.sla_deadline || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">开始时间</view>
<view class="meta-value">{{ detail.task_info.started_at || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">提交时间</view>
<view class="meta-value">{{ detail.task_info.submitted_at || "-" }}</view>
</view>
<view class="meta-item">
<view class="meta-label">报告摘要</view>
<view class="meta-value">{{ reportSummary || "-" }}</view>
</view>
</view>
</view>
<view class="card">
<view class="segmented">
<view :class="['segment', activeSection === 'result' ? 'segment--active' : '']" @click="activeSection = 'result'">鉴定结论</view>
<view :class="['segment', activeSection === 'supplement' ? 'segment--active' : '']" @click="activeSection = 'supplement'">补资料</view>
<view :class="['segment', activeSection === 'zhongjian' ? 'segment--active' : '']" @click="activeSection = 'zhongjian'">中检报告</view>
</view>
</view>
<view v-if="activeSection === 'result' && !isZhongjian" class="card">
<view class="card-title">鉴定结论</view>
<view class="stack" style="margin-top: 18rpx">
<input v-model="resultText" class="field" placeholder="结论,例如:正品 / 存疑" />
<textarea v-model="resultDesc" class="textarea" placeholder="结论说明" />
<template v-if="showConditionFields">
<input v-model="conditionGrade" class="field" placeholder="成色评级" />
<textarea v-model="conditionDesc" class="textarea" placeholder="成色说明" />
</template>
<template v-if="showValuationFields">
<view class="meta-grid">
<input v-model="valuationMin" class="field" placeholder="最低估值" />
<input v-model="valuationMax" class="field" placeholder="最高估值" />
</view>
<textarea v-model="valuationDesc" class="textarea" placeholder="估值说明" />
</template>
<textarea v-model="externalRemark" class="textarea" placeholder="对外备注" />
<textarea v-model="internalRemark" class="textarea" placeholder="内部备注" />
</view>
<view v-if="detail.appraisal_template?.key_points?.length" class="stack" style="margin-top: 20rpx">
<view class="card-desc">模板项</view>
<view v-for="(item, index) in detail.appraisal_template.key_points" :key="item.point_code" class="stack">
<view class="meta-item">
<view class="meta-label">{{ item.point_name }}</view>
<view class="meta-value">{{ item.point_type }}{{ item.is_required ? " · 必填" : "" }}</view>
</view>
<input
:value="item.point_value"
class="field"
:placeholder="`${item.point_name} 值`"
@input="updateTemplatePointFromInput(index, 'point_value', $event)"
/>
<textarea
:value="item.point_remark"
class="textarea"
:placeholder="`${item.point_name} 说明`"
@input="updateTemplatePointFromInput(index, 'point_remark', $event)"
/>
</view>
</view>
<view class="card-desc evidence-title">证据附件</view>
<view v-if="evidenceFiles.length" class="list" style="margin-top: 14rpx">
<view v-for="item in evidenceFiles" :key="item.file_url" class="list-card">
<view class="row">
<view class="list-title">{{ item.name || item.file_id }}</view>
<text class="tag tag--danger" @click="removeEvidenceFile(item.file_url)">删除</text>
</view>
</view>
</view>
<view class="upload-actions">
<button class="action-button action-button--secondary" :disabled="uploading" @click="chooseEvidenceImage">
<text class="action-symbol">+</text>
<text>{{ uploading ? "上传中" : "添加图片" }}</text>
</button>
<button class="action-button action-button--secondary" :disabled="uploading" @click="chooseEvidenceVideo">
<text class="action-symbol">+</text>
<text>{{ uploading ? "上传中" : "添加视频" }}</text>
</button>
</view>
<view class="form-actions">
<button class="form-action form-action--secondary" :disabled="submitting" @click="submitResult('save')">保存</button>
<button class="form-action form-action--primary" :disabled="submitting" @click="submitResult('submit')">提交</button>
</view>
</view>
<view v-else-if="activeSection === 'supplement'" class="card">
<view class="card-title">补资料</view>
<view class="stack" style="margin-top: 18rpx">
<textarea v-model="supplementForm.reason" class="textarea" placeholder="补资料原因" />
<input v-model="supplementForm.deadline" class="field" placeholder="截止时间(可选)" />
<view v-for="(item, index) in supplementForm.items" :key="index" class="stack">
<input v-model="item.item_name" class="field" placeholder="补资料项名称" />
<textarea v-model="item.guide_text" class="textarea" placeholder="补资料说明" />
<view class="row">
<text class="tag" :class="item.is_required ? 'tag--warning' : ''" @click="item.is_required = !item.is_required">
{{ item.is_required ? "必传" : "选传" }}
</text>
<text class="tag tag--danger" @click="removeSupplementItem(index)">删除</text>
</view>
</view>
<view class="form-actions">
<button class="form-action form-action--secondary" @click="addSupplementItem">添加一项</button>
<button class="form-action form-action--primary" :disabled="supplementSubmitting" @click="submitSupplement">发起补资料</button>
</view>
</view>
</view>
<view v-else class="card">
<view class="card-title">中检报告</view>
<view class="stack" style="margin-top: 18rpx">
<input v-model="zhongjianReportNo" class="field" placeholder="中检报告编号" />
<view v-if="zhongjianFiles.length" class="list">
<view v-for="item in zhongjianFiles" :key="item.file_url" class="list-card">
<view class="row">
<view class="list-title">{{ item.name || item.file_id }}</view>
<text class="tag tag--danger" @click="removeZhongjianFile(item.file_url)">删除</text>
</view>
</view>
</view>
<view class="upload-actions">
<button class="action-button action-button--secondary" :disabled="uploading" @click="chooseZhongjianImage">
<text class="action-symbol">+</text>
<text>{{ uploading ? "上传中" : "添加图片" }}</text>
</button>
<button class="action-button action-button--secondary" :disabled="uploading" @click="chooseZhongjianVideo">
<text class="action-symbol">+</text>
<text>{{ uploading ? "上传中" : "添加视频" }}</text>
</button>
</view>
<view class="form-actions" :class="detail.report_summary?.id ? '' : 'form-actions--single'">
<button class="form-action form-action--primary" :disabled="submitting" @click="submitZhongjianReport">提交并发布</button>
<button v-if="detail.report_summary?.id" class="form-action form-action--secondary" @click="openReportDetail">查看报告</button>
</view>
</view>
</view>
<view class="card">
<view class="card-title">任务信息</view>
<view class="meta-grid">
<view class="meta-item">
<view class="meta-label">订单号</view>
<view class="meta-value">{{ detail.task_info.order_no }}</view>
</view>
<view class="meta-item">
<view class="meta-label">鉴定单号</view>
<view class="meta-value">{{ detail.task_info.appraisal_no }}</view>
</view>
<view class="meta-item">
<view class="meta-label">服务类型</view>
<view class="meta-value">{{ detail.task_info.service_provider_text }}</view>
</view>
<view class="meta-item">
<view class="meta-label">处理人</view>
<view class="meta-value">{{ detail.task_info.assignee_name }}</view>
</view>
</view>
</view>
</template>
</view>
</template>
<style scoped lang="scss">
.list {
display: grid;
gap: 14rpx;
}
.evidence-title {
margin-top: 24rpx;
color: var(--work-text);
font-weight: 800;
}
.upload-actions {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16rpx;
margin-top: 16rpx;
}
.action-button,
.form-action {
display: flex;
align-items: center;
justify-content: center;
min-width: 0;
min-height: 88rpx;
padding: 0 22rpx;
border: 1px solid transparent;
border-radius: var(--work-radius-sm);
font-size: 28rpx;
font-weight: 800;
line-height: 1;
}
.action-button::after,
.form-action::after {
border: 0;
}
.action-button[disabled],
.form-action[disabled] {
opacity: 0.56;
}
.action-button--secondary {
justify-content: flex-start;
gap: 12rpx;
border-color: var(--work-border);
background: var(--work-card-muted);
color: var(--work-text);
}
.action-symbol {
width: 36rpx;
height: 36rpx;
border-radius: 50%;
background: #ffffff;
color: var(--work-accent-deep);
font-size: 30rpx;
font-weight: 800;
line-height: 34rpx;
text-align: center;
}
.form-actions {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
gap: 16rpx;
margin-top: 24rpx;
}
.form-actions--single {
grid-template-columns: 1fr;
}
.form-action--secondary {
border-color: var(--work-border);
background: #ffffff;
color: var(--work-text);
}
.form-action--primary {
border-color: var(--work-accent);
background: var(--work-accent);
color: #ffffff;
}
</style>

View File

@@ -0,0 +1,225 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { onReachBottom, onShow } from "@dcloudio/uni-app";
import { adminApi, type AdminAppraisalTaskListItem, type AdminOrderListItem } from "../../api/admin";
import { getAdminInfo, resolveWorkRole, type WorkRole } from "../../utils/auth";
import { showErrorToast } from "../../utils/feedback";
const role = ref<WorkRole>(resolveWorkRole());
const keyword = ref("");
const status = ref("");
const loading = ref(false);
const loadingMore = ref(false);
const page = ref(1);
const pageSize = 20;
const total = ref(0);
const orders = ref<AdminOrderListItem[]>([]);
const tasks = ref<AdminAppraisalTaskListItem[]>([]);
const isWarehouse = computed(() => role.value === "warehouse");
const title = computed(() => (isWarehouse.value ? "订单中心" : "鉴定工单"));
const desc = computed(() => (isWarehouse.value ? "仅展示在途、已入仓、待寄回订单。" : "处理我的鉴定待办和历史任务。"));
const listCount = computed(() => (isWarehouse.value ? orders.value.length : tasks.value.length));
const hasMore = computed(() => total.value > listCount.value);
const statusOptions = computed(() =>
isWarehouse.value
? [
{ label: "全部", value: "warehouse_active" },
{ label: "在途", value: "warehouse_in_transit" },
{ label: "已入仓", value: "warehouse_received" },
{ label: "待寄回", value: "warehouse_pending_return" },
]
: [
{ label: "全部", value: "" },
{ label: "待处理", value: "pending" },
{ label: "处理中", value: "processing" },
{ label: "已完成", value: "completed" },
],
);
function refreshRole() {
role.value = resolveWorkRole(getAdminInfo());
}
function normalizeStatusForRole() {
const values = statusOptions.value.map((item) => item.value);
if (!values.includes(status.value)) {
status.value = statusOptions.value[0]?.value || "";
}
}
function chooseStatus(value: string) {
status.value = value;
void fetchList(true);
}
async function fetchList(reset = false) {
if (loading.value || loadingMore.value) return;
if (reset) {
page.value = 1;
total.value = 0;
orders.value = [];
tasks.value = [];
}
const isFirstPage = page.value === 1;
if (isFirstPage) {
loading.value = true;
} else {
loadingMore.value = true;
}
try {
if (isWarehouse.value) {
const data = await adminApi.getOrders({
keyword: keyword.value.trim(),
status: status.value || "warehouse_active",
page: page.value,
page_size: pageSize,
});
orders.value = reset || isFirstPage ? data.list : orders.value.concat(data.list);
total.value = data.total || orders.value.length;
} else {
const data = await adminApi.getAppraisalTasks({
keyword: keyword.value.trim(),
status: status.value,
scope: "my",
page: page.value,
page_size: pageSize,
});
tasks.value = reset || isFirstPage ? data.list : tasks.value.concat(data.list);
total.value = data.total || tasks.value.length;
}
} catch (error) {
showErrorToast(error, "工单加载失败");
} finally {
loading.value = false;
loadingMore.value = false;
}
}
function handleSearch() {
void fetchList(true);
}
function loadMore() {
if (!hasMore.value || loading.value || loadingMore.value) return;
page.value += 1;
void fetchList(false);
}
function openOrder(item: AdminOrderListItem) {
uni.navigateTo({ url: `/pages/order/detail?id=${item.id}` });
}
function openTask(item: AdminAppraisalTaskListItem) {
uni.navigateTo({ url: `/pages/task/detail?id=${item.id}` });
}
onShow(() => {
refreshRole();
normalizeStatusForRole();
void fetchList(true);
});
onReachBottom(loadMore);
</script>
<template>
<view class="page">
<view class="hero">
<view class="eyebrow">工单</view>
<view class="title">{{ title }}</view>
<view class="subtitle">{{ desc }}</view>
</view>
<view class="card">
<input v-model="keyword" class="field" :placeholder="isWarehouse ? '搜索订单号 / 鉴定单号 / 商品名称' : '搜索订单号 / 外部订单号 / 商品名称'" @confirm="handleSearch" />
<scroll-view class="status-scroll" scroll-x>
<view class="status-row">
<view
v-for="item in statusOptions"
:key="item.value"
:class="['status-chip', status === item.value ? 'status-chip--active' : '']"
@click="chooseStatus(item.value)"
>
{{ item.label }}
</view>
</view>
</scroll-view>
</view>
<view v-if="loading" class="empty">正在加载</view>
<view v-else-if="isWarehouse" class="list">
<view v-if="!orders.length" class="empty">暂无订单</view>
<view v-for="item in orders" :key="item.id" class="list-card" @click="openOrder(item)">
<view class="row">
<view class="list-title">{{ item.product_name }}</view>
<text class="tag">{{ item.warehouse_bucket_text || item.display_status }}</text>
</view>
<view class="list-subtitle">{{ item.order_no }} / {{ item.appraisal_no }}</view>
<view class="list-footer">
<text class="tag">{{ item.service_provider_text }}</text>
<text class="list-subtitle">{{ item.created_at }}</text>
</view>
</view>
</view>
<view v-else class="list">
<view v-if="!tasks.length" class="empty">暂无鉴定工单</view>
<view v-for="item in tasks" :key="item.id" class="list-card" @click="openTask(item)">
<view class="row">
<view class="list-title">{{ item.product_name }}</view>
<text :class="['tag', item.status === 'completed' ? 'tag--success' : item.status === 'returned' ? 'tag--warning' : '']">{{ item.status_text }}</text>
</view>
<view class="list-subtitle">{{ item.order_no }} / {{ item.external_order_no || item.appraisal_no }}</view>
<view class="list-footer">
<text class="tag">{{ item.service_provider_text }}</text>
<text class="list-subtitle">{{ item.assignee_name }}</text>
</view>
</view>
</view>
<view v-if="loadingMore" class="empty">继续加载</view>
<view v-else-if="hasMore" class="load-more" @click="loadMore">加载更多</view>
</view>
</template>
<style scoped lang="scss">
.status-scroll {
width: 100%;
margin-top: 18rpx;
white-space: nowrap;
}
.status-row {
display: inline-flex;
gap: 12rpx;
padding-bottom: 2rpx;
}
.status-chip {
min-height: 62rpx;
padding: 0 22rpx;
border-radius: var(--work-radius-pill);
background: var(--work-card-muted);
color: var(--work-text-soft);
font-size: 26rpx;
font-weight: 700;
line-height: 62rpx;
}
.status-chip--active {
background: var(--work-accent);
color: #ffffff;
}
.load-more {
margin-top: 22rpx;
padding: 22rpx;
color: var(--work-text-soft);
font-size: 26rpx;
text-align: center;
}
</style>