feat(work-results): support historical project outcomes

This commit is contained in:
2026-07-22 00:29:19 +08:00
parent 49189474c1
commit d7664e45a7
26 changed files with 479 additions and 49 deletions
@@ -3,12 +3,20 @@
<view class="page-head">
<button class="back" aria-label="返回" @click="goBack">‹</button>
<view class="head-copy">
<text class="title">今日工作成果</text>
<text class="title">工作成果</text>
<text class="subtitle">{{ result?.projectName || currentProject?.projectName || '请选择项目' }} · {{ workDate }}</text>
</view>
<button class="refresh" :disabled="loading" @click="load">{{ loading ? '整理中' : '重新整理' }}</button>
</view>
<WorkDateSelector
v-if="currentProject"
:model-value="workDate"
:max-date="today"
:disabled="loading"
@change="changeWorkDate"
/>
<view v-if="message" class="message">{{ message }}</view>
<view v-if="!currentProject && !loading" class="empty-card">
<text class="empty-title">请先在工作助手选择当前项目</text>
@@ -48,9 +56,9 @@
</view>
<view v-if="!result.total" class="empty-card">
<text class="empty-title">今天还没有已确认的工作记录</text>
<text class="empty-desc">在工作助手里按住说话或发照片,确认后会自动汇总到这里。</text>
<button class="primary" @click="goAssistant">去记录一件事</button>
<text class="empty-title">{{ emptyTitle }}</text>
<text class="empty-desc">{{ emptyDescription }}</text>
<button class="primary" @click="handleEmptyAction">{{ emptyActionLabel }}</button>
</view>
</template>
</view>
@@ -65,14 +73,23 @@ import { fetchMobileIdentity } from '@/services/position';
import { updateAssistantCaptureStatus } from '@/services/personal-assistant';
import { openProtectedSource } from '@/services/source-preview';
import { generateMyWorkResult } from '@/services/work-results';
import WorkDateSelector from '@/components/WorkDateSelector.vue';
const result = ref<WorkResult | null>(null);
const currentProject = ref<MobileProject | null>(getCurrentProject());
const loading = ref(false);
const message = ref('');
const workDate = new Date().toLocaleDateString('sv-SE', { timeZone: 'Asia/Shanghai' });
const currentDate = () => new Date().toLocaleDateString('sv-SE', { timeZone: 'Asia/Shanghai' });
const today = ref(currentDate());
const workDate = ref(today.value);
const isToday = computed(() => workDate.value === today.value);
const emptyTitle = computed(() => isToday.value ? '今天还没有已确认的工作记录' : '这一天没有已确认的工作记录');
const emptyDescription = computed(() => isToday.value
? '在工作助手里按住说话或发照片,确认后会自动汇总到这里。'
: '可以继续查看其他日期,或回到今天记录新的工作。');
const emptyActionLabel = computed(() => isToday.value ? '去记录一件事' : '回到今天');
const sectionLabels: Record<string, string> = {
completed: '今日已完成',
completed: '当日已完成',
inspection: '巡检发现',
services: '业主服务',
leads: '画像与服务线索',
@@ -94,14 +111,20 @@ const load = async () => {
result.value = null;
return;
}
result.value = await generateMyWorkResult(currentProject.value.projectCode, workDate);
result.value = await generateMyWorkResult(currentProject.value.projectCode, workDate.value);
} catch (error) {
message.value = error instanceof Error ? error.message : '今日工作成果读取失败';
message.value = error instanceof Error ? error.message : '工作成果读取失败';
} finally {
loading.value = false;
}
};
const changeWorkDate = (value: string) => {
workDate.value = value;
result.value = null;
void load();
};
const advance = async (item: WorkResultItem) => {
const next = item.businessStatus === 'IN_PROGRESS' ? 'COMPLETED' : 'IN_PROGRESS';
try {
@@ -120,9 +143,13 @@ const statusLabel = (value: string) => ({
const sourceLabel = (value: string) => ({ TEXT: '文字', VOICE: '语音', IMAGE: '照片', VIDEO: '视频' }[value] || '文字');
const displayTime = (value: string) => value?.replace('T', ' ').slice(11, 16) || '--:--';
const goAssistant = () => uni.switchTab({ url: '/pages/user/sop/index' });
const handleEmptyAction = () => isToday.value ? goAssistant() : changeWorkDate(today.value);
const goBack = () => uni.navigateBack({ fail: () => uni.switchTab({ url: '/pages/user/today/index' }) });
onShow(load);
onShow(() => {
today.value = currentDate();
load();
});
</script>
<style scoped>