feat: 展示客户咨询状态时间线
This commit is contained in:
1 parent
d6c47ce143
commit
a8a37c179e
11 files changed
+98
-24
No files matched your search
+33
-22
@@ -282,24 +282,24 @@ export class PublicWorkspaceController {
|
||||
].includes(String(value.type))
|
||||
? (value.type as RuntimeInquiryField["type"])
|
||||
: "text";
|
||||
const options = Array.isArray(value.options)
|
||||
? value.options.flatMap((option) => {
|
||||
if (!option || typeof option !== "object") return [];
|
||||
const item = option as Record<string, unknown>;
|
||||
return typeof item.label === "string" && typeof item.value === "string"
|
||||
? [{ label: item.label, value: item.value }]
|
||||
: [];
|
||||
})
|
||||
: undefined;
|
||||
return [
|
||||
{
|
||||
key: value.key,
|
||||
label: value.label,
|
||||
type,
|
||||
required: value.required === true,
|
||||
...(options?.length ? { options } : {}),
|
||||
},
|
||||
];
|
||||
const options = Array.isArray(value.options)
|
||||
? value.options.flatMap((option) => {
|
||||
if (!option || typeof option !== "object") return [];
|
||||
const item = option as Record<string, unknown>;
|
||||
return typeof item.label === "string" && typeof item.value === "string"
|
||||
? [{ label: item.label, value: item.value }]
|
||||
: [];
|
||||
})
|
||||
: undefined;
|
||||
return [
|
||||
{
|
||||
key: value.key,
|
||||
label: value.label,
|
||||
type,
|
||||
required: value.required === true,
|
||||
...(options?.length ? { options } : {}),
|
||||
},
|
||||
];
|
||||
});
|
||||
const inquiryForm = inquiryForms[0] ?? null;
|
||||
const runtimeWorkspace: RuntimeWorkspace = {
|
||||
@@ -480,11 +480,14 @@ export class PublicInquiryFormController {
|
||||
@Controller("customer/inquiry-submissions")
|
||||
export class CustomerInquirySubmissionController {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
private present<T extends { customerSubject: string }>(
|
||||
submission: T,
|
||||
): Omit<T, "customerSubject"> {
|
||||
const { customerSubject: _customerSubject, ...publicSubmission } = submission;
|
||||
private present<T extends { customerSubject: string; adminNote?: string | null }>(submission: T) {
|
||||
const {
|
||||
customerSubject: _customerSubject,
|
||||
adminNote: _adminNote,
|
||||
...publicSubmission
|
||||
} = submission;
|
||||
void _customerSubject;
|
||||
void _adminNote;
|
||||
return publicSubmission;
|
||||
}
|
||||
private identity(request: FastifyRequest): ReturnType<typeof readIdentity> {
|
||||
@@ -509,6 +512,10 @@ export class CustomerInquirySubmissionController {
|
||||
include: {
|
||||
inquiryForm: { select: { name: true, purpose: true } },
|
||||
offering: { select: { id: true, name: true } },
|
||||
statusHistory: {
|
||||
select: { fromStatus: true, toStatus: true, createdAt: true },
|
||||
orderBy: { createdAt: "asc" },
|
||||
},
|
||||
},
|
||||
});
|
||||
return submissions.map((submission) => this.present(submission));
|
||||
@@ -522,6 +529,10 @@ export class CustomerInquirySubmissionController {
|
||||
include: {
|
||||
inquiryForm: { select: { name: true, purpose: true } },
|
||||
offering: { select: { id: true, name: true } },
|
||||
statusHistory: {
|
||||
select: { fromStatus: true, toStatus: true, createdAt: true },
|
||||
orderBy: { createdAt: "asc" },
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!submission) throw new NotFoundException("咨询记录不存在");
|
||||
|
||||
@@ -604,6 +604,15 @@ test("admin can create and version an inquiry form", async () => {
|
||||
assert.equal(updatedSubmission.statusCode, 200);
|
||||
assert.equal(JSON.parse(updatedSubmission.body).status, "reviewing");
|
||||
assert.equal(JSON.parse(updatedSubmission.body).adminNote, "已开始评估需求");
|
||||
const customerSubmissionAfterUpdate = await request(
|
||||
`/customer/inquiry-submissions/${savedSubmission.id}`,
|
||||
{ headers: { authorization: `Bearer ${customerToken}` } },
|
||||
);
|
||||
assert.equal(customerSubmissionAfterUpdate.statusCode, 200);
|
||||
const customerBody = JSON.parse(customerSubmissionAfterUpdate.body);
|
||||
assert.equal(customerBody.adminNote, undefined);
|
||||
assert.equal(customerBody.statusHistory[0].toStatus, "reviewing");
|
||||
assert.equal(customerBody.statusHistory[0].adminNote, undefined);
|
||||
const history = await prisma.inquirySubmissionStatusHistory.findMany({
|
||||
where: { submissionId: savedSubmission.id },
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="records"><view wx:if="{{!records.length}}" class="empty"><text class="empty-title">还没有咨询记录</text><text>预约一次私享沟通,让我们从你的空间开始。</text><button bindtap="create">开始咨询</button></view><view wx:else><view class="record" wx:for="{{records}}" wx:key="id"><view class="record-head"><text>{{item.type}}</text><text class="status">{{item.status}}</text></view><text class="project">{{item.project}} · {{item.offeringName}}</text><text class="meta">档案编号 {{item.id}} {{item.createdAt}}</text></view></view></view>
|
||||
<view class="records"><view wx:if="{{!records.length}}" class="empty"><text class="empty-title">还没有咨询记录</text><text>预约一次私享沟通,让我们从你的空间开始。</text><button bindtap="create">开始咨询</button></view><view wx:else><view class="record" wx:for="{{records}}" wx:key="id"><view class="record-head"><text>{{item.type}}</text><text class="status">{{item.status}}</text></view><text class="project">{{item.project}} · {{item.offeringName}}</text><text class="meta">档案编号 {{item.id}} {{item.createdAt}}</text><view wx:if="{{item.timeline.length}}" class="timeline"><view wx:for="{{item.timeline}}" wx:key="createdAt" class="timeline-item"><text class="timeline-dot">●</text><text>{{item.status}} · {{item.createdAt}}</text></view></view></view></view></view>
|
||||
@@ -1 +1 @@
|
||||
.records{margin-top:22rpx}.empty{text-align:center;padding:120rpx 20rpx;color:#99928a;font-size:26rpx;line-height:1.8}.empty-title{display:block;margin-bottom:16rpx;color:#252525;font:40rpx serif}.empty button{margin-top:34rpx;background:#8a6846;color:#fff;border-radius:0}.record{margin-top:18rpx;padding:28rpx;background:#fff;border:1rpx solid #e6ded5}.record-head{display:flex;justify-content:space-between;font:32rpx serif}.status{color:#8a6846;font:23rpx sans-serif}.project{display:block;margin-top:18rpx;color:#77736b;font-size:26rpx}.meta{display:block;margin-top:16rpx;color:#aaa39a;font-size:22rpx}
|
||||
.records{margin-top:22rpx}.empty{text-align:center;padding:120rpx 20rpx;color:#99928a;font-size:26rpx;line-height:1.8}.empty-title{display:block;margin-bottom:16rpx;color:#252525;font:40rpx serif}.empty button{margin-top:34rpx;background:#8a6846;color:#fff;border-radius:0}.record{margin-top:18rpx;padding:28rpx;background:#fff;border:1rpx solid #e6ded5}.record-head{display:flex;justify-content:space-between;font:32rpx serif}.status{color:#8a6846;font:23rpx sans-serif}.project{display:block;margin-top:18rpx;color:#77736b;font-size:26rpx}.meta{display:block;margin-top:16rpx;color:#aaa39a;font-size:22rpx}.timeline{margin-top:24rpx;padding-top:18rpx;border-top:1rpx solid #eee7df}.timeline-item{display:flex;gap:12rpx;margin-top:10rpx;color:#77736b;font-size:22rpx}.timeline-dot{color:#8a6846}
|
||||
@@ -22,6 +22,10 @@ Page({
|
||||
...item,
|
||||
type: item.inquiryForm?.name || "品牌咨询",
|
||||
status: statusLabels[item.status] || item.status,
|
||||
timeline: (item.statusHistory || []).map((entry) => ({
|
||||
status: statusLabels[entry.toStatus] || entry.toStatus,
|
||||
createdAt: new Date(entry.createdAt).toLocaleString("zh-CN"),
|
||||
})),
|
||||
project: "咨询记录",
|
||||
offeringName: item.offering?.name || "品牌合作",
|
||||
createdAt: new Date(item.createdAt).toLocaleDateString("zh-CN"),
|
||||
|
||||
Reference in new issue
Block a user