Lufaneng 11 months ago
parent c452b83a66
commit fd4a737396

@ -1,46 +1,61 @@
<script setup> <script setup>
import { import {
onLaunch, onLaunch,
onShow, onShow,
onHide, onHide,
onError, onError,
onPageNotFound, onPageNotFound,
} from "@dcloudio/uni-app"; } from "@dcloudio/uni-app";
import { checkForUpdate } from "@/utils"; import {
checkForUpdate
onLaunch(() => { } from "@/utils";
console.log("App Launch");
// #ifdef MP-WEIXIN onLaunch(() => {
checkForUpdate(); console.log("App Launch");
// #endif // #ifdef MP-WEIXIN
}); checkForUpdate();
// #endif
onShow(() => {
console.log("App Show"); // #ifdef H5
}); if (navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1) {
//
onHide(() => { const style = document.createElement('style')
console.log("App Hide"); style.textContent = `
}); uni-page-head {
display:none !important;
onError((error) => { }
console.error("App Error", error); `
}); document.head.appendChild(style)
}
onPageNotFound((res) => { // #endif
console.error("PageNotFound", res); });
uni.redirectTo({
url: "/pages/404/404", onShow(() => {
}); console.log("App Show");
}); });
</script>
onHide(() => {
<style lang="scss"> console.log("App Hide");
/* 每个页面公共css */ });
page {
height: 100%; onError((error) => {
} console.error("App Error", error);
});
/* uv-ui基础样式 */
@import "@/uni_modules/uv-ui-tools/index.scss"; onPageNotFound((res) => {
</style> console.error("PageNotFound", res);
uni.redirectTo({
url: "/pages/404/404",
});
});
</script>
<style lang="scss">
/* 每个页面公共css */
page {
height: 100%;
}
/* uv-ui基础样式 */
@import "@/uni_modules/uv-ui-tools/index.scss";
</style>

@ -1,280 +1,347 @@
<template> <template>
<view class="container"> <view class="container">
<!-- 生成记录列表 --> <!-- 生成记录列表 -->
<view class="record-list"> <view class="record-list">
<uv-swipe-action> <uv-swipe-action>
<uv-swipe-action-item @click="delItem(record)" :options="options" v-for="record in list" :key="record.id"> <uv-swipe-action-item
<view class="record-item"> @click="delItem(record)"
<!-- 记录信息 --> :options="options"
<view class="record-info"> v-for="record in list"
<view class="record-title">{{ record.file_name }}</view> :key="record.id"
<view class="record-time">生成时间: {{ record.CreatedAt ? dayjs(record.CreatedAt).format('YYYY-MM-DD') : '' }}</view> >
</view> <view class="record-item">
<!-- 记录信息 -->
<view class="record-info">
<view class="record-title">{{ record.file_name }}</view>
<view class="record-time">
生成时间:
{{
record.CreatedAt
? dayjs(record.CreatedAt).format("YYYY-MM-DD")
: ""
}}
</view>
</view>
<!-- 状态标签 --> <!-- 状态标签 -->
<view class="status-tag" :class="{completed:record.status == 4,failed:record.status == 5}"> <view
<span v-if="record.status == 4"></span> class="status-tag"
<span v-else-if="record.status == 5">生成失败</span> :class="{
<span v-else></span> completed: record.status == 4,
</view> failed: record.status == 5,
}"
>
<span v-if="record.status == 4"></span>
<span v-else-if="record.status == 5">生成失败</span>
<span v-else></span>
</view>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view class="record-actions"> <view class="record-actions">
<uv-button v-if="record.status === 4" type="primary" size="small" <uv-button
@click="downloadRecord(record)"> v-if="record.status === 4"
<uv-icon name="download" size="14" color="white" style="margin-right: 4px"></uv-icon> type="primary"
下载 size="small"
</uv-button> @click="downloadRecord(record)"
<uv-button v-else type="info" size="small" disabled> >
<uv-icon name="download" size="14" color="#aaa" style="margin-right: 4px"></uv-icon> <uv-icon
下载 name="download"
</uv-button> size="14"
color="white"
style="margin-right: 4px"
></uv-icon>
下载
</uv-button>
<uv-button v-else type="info" size="small" disabled>
<uv-icon
name="download"
size="14"
color="#aaa"
style="margin-right: 4px"
></uv-icon>
下载
</uv-button>
</view>
</view>
</uv-swipe-action-item>
</uv-swipe-action>
</view>
</view> <!-- 空状态 -->
</view> <view v-if="list.length === 0" class="empty-state">
</uv-swipe-action-item> <uv-icon name="file-text" size="60" color="#ccc"></uv-icon>
</uv-swipe-action> <text class="empty-text">暂无生成记录</text>
</view> </view>
<!-- 空状态 --> <!-- 加载更多 -->
<view v-if="list.length === 0" class="empty-state"> <uv-load-more :status="loadingStatus" @loadmore="loadmore" />
<uv-icon name="file-text" size="60" color="#ccc"></uv-icon> </view>
<text class="empty-text">暂无生成记录</text>
</view>
<!-- 加载更多 -->
<uv-load-more :status="loadingStatus" @loadmore="loadmore" />
</view>
</template> </template>
<script setup> <script setup>
import { import { ref, onMounted } from "vue";
ref, import RPC from "@/utils/request";
onMounted import dayjs from "dayjs";
} from "vue"; import { onShow, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
import RPC from "@/utils/request";
import dayjs from 'dayjs' const options = ref([
import { {
onShow,onPullDownRefresh,onReachBottom text: "删除",
} from "@dcloudio/uni-app"; style: {
backgroundColor: "#f56c6c",
},
},
]);
const delItem = (item) => {
console.log(item);
deleteRecord(item);
};
//
const loading = ref(false);
const loadingStatus = ref("loadmore");
const page = ref(1);
const list = ref([]);
const count = ref(0);
//
const downloadRecord = (record) => {
uni.showLoading({
title: "准备下载...",
});
// #ifdef H5
// H5使
const link = document.createElement("a");
link.href = record.result_url;
link.download = record.file_name || "download";
link.target = "_blank";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
uni.hideLoading();
uni.showToast({
title: "开始下载",
icon: "success",
});
// #endif
const options = ref([{ // #ifndef H5
text: '删除', // App使uni.downloadFile
style: { uni.downloadFile({
backgroundColor: '#f56c6c' url: record.result_url,
} success: (res) => {
}]) console.log(res);
const delItem = item => { if (res.statusCode === 200) {
console.log(item) uni.saveFile({
deleteRecord(item) tempFilePath: res.tempFilePath,
} success: () => {
// uni.hideLoading();
const loading = ref(false); uni.showToast({
const loadingStatus = ref('loadmore') title: "下载成功",
const page = ref(1) icon: "success",
const list = ref([]) });
const count = ref(0) },
fail: () => {
// uni.hideLoading();
const downloadRecord = (record) => { uni.showToast({
title: "保存失败",
icon: "none",
});
},
});
} else {
uni.hideLoading();
uni.showToast({
title: "下载失败",
icon: "none",
});
}
},
fail: () => {
uni.hideLoading();
uni.showToast({
title: "下载失败",
icon: "none",
});
},
});
// #endif
};
uni.showLoading({ //
title: "准备下载...", const deleteRecord = (record) => {
}); uni.showModal({
uni.downloadFile({ title: "确认删除",
url: record.result_url, content: "确定要删除这条生成记录吗?删除后无法恢复。",
// url:'https://ksdt-1255846884.cos.ap-shanghai.myqcloud.com/lift-result/2025/09/24/d6180add4cd94875a1854a4febce8966.pdf', success: (res) => {
success: (res) => { if (res.confirm) {
console.log(res) //
if (res.statusCode === 200) { const index = records.value.findIndex((item) => item.id === record.id);
uni.saveFile({ if (index !== -1) {
tempFilePath: res.tempFilePath, records.value.splice(index, 1);
success: () => { }
uni.showToast({
title: '下载成功',
icon: 'success'
})
}
})
}
},
fail: () => {
uni.showToast({
title: '下载失败',
icon: 'none'
})
}
})
};
// uni.showToast({
const deleteRecord = (record) => { title: "删除成功",
uni.showModal({ icon: "success",
title: "确认删除", });
content: "确定要删除这条生成记录吗?删除后无法恢复。",
success: (res) => {
if (res.confirm) {
//
const index = records.value.findIndex((item) => item.id === record.id);
if (index !== -1) {
records.value.splice(index, 1);
}
uni.showToast({ // API
title: "删除成功", // try {
icon: "success", // await RPC.post('/api/generate-record/delete', { id: record.id })
}); // } catch (error) {
// console.error(':', error)
// }
}
},
});
};
// API //
// try { const loadRecords = async () => {
// await RPC.post('/api/generate-record/delete', { id: record.id }) loadingStatus.value === "loading";
// } catch (error) { RPC.post("/planned_list", { page: page.value, page_size: 20 })
// console.error(':', error) .then((res) => {
// } list.value = [...list.value, ...res.list];
} count.value = res.total;
}, if (list.value.length >= count.value) {
}); loadingStatus.value = "nomore";
}; } else {
loadingStatus.value = "loadmore";
}
})
.catch(() => {
loadingStatus.value = "loadmore";
});
};
// //
const loadRecords = async () => { onPullDownRefresh(() => {
loadingStatus.value === 'loading' list.value = [];
RPC.post('/planned_list',{page:page.value,page_size:20}).then(res => { page.value = 1;
list.value = [...list.value, ...res.list] loadingStatus.value === "loading";
count.value = res.total RPC.post("/planned_list", { page: page.value, page_size: 20 })
if (list.value.length >= count.value) { .then((res) => {
loadingStatus.value = 'nomore' list.value = [...list.value, ...res.list];
} else { count.value = res.total;
loadingStatus.value = 'loadmore' if (list.value.length >= count.value) {
} loadingStatus.value = "nomore";
}).catch(() => { } else {
loadingStatus.value = 'loadmore' loadingStatus.value = "loadmore";
}) }
}; })
.catch(() => {
loadingStatus.value = "loadmore";
})
.finally(() => {
uni.stopPullDownRefresh();
});
});
// onReachBottom(() => {
onPullDownRefresh(() => { loadmore();
list.value = [] });
page.value = 1
loadingStatus.value === 'loading'
RPC.post('/planned_list',{page:page.value,page_size:20}).then(res => {
list.value = [...list.value, ...res.list]
count.value = res.total
if (list.value.length >= count.value) {
loadingStatus.value = 'nomore'
} else {
loadingStatus.value = 'loadmore'
}
}).catch(() => {
loadingStatus.value = 'loadmore'
}).finally(() => {
uni.stopPullDownRefresh()
})
})
onReachBottom(() => {
loadmore()
})
const loadmore = () => {
if (list.value.length >= count.value || loadingStatus.value === 'loading') return
console.log('上拉加载:')
loadingStatus.value = 'loading';
page.value = ++page.value;
loadRecords()
}
const loadmore = () => {
if (list.value.length >= count.value || loadingStatus.value === "loading")
return;
console.log("上拉加载:");
loadingStatus.value = "loading";
page.value = ++page.value;
loadRecords();
};
onShow(() => { onShow(() => {
// //
list.value = [] list.value = [];
page.value = 1 page.value = 1;
loadRecords(); loadRecords();
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
font-size: 14px; font-size: 14px;
min-height: 100vh; min-height: 100vh;
background-color: #f8f8f8; background-color: #f8f8f8;
padding: 16px; padding: 16px;
} }
.record-list { .record-list {
.record-item { .record-item {
background: white; background: white;
border-radius: 12px; border-radius: 12px;
padding: 16px; padding: 16px;
margin-bottom: 12px; margin-bottom: 12px;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 12px; gap: 12px;
.record-info { .record-info {
flex: 1; flex: 1;
.record-title { .record-title {
font-size: 16px; font-size: 16px;
color: #333; color: #333;
font-weight: 500; font-weight: 500;
margin-bottom: 6px; margin-bottom: 6px;
} }
.record-time { .record-time {
font-size: 13px; font-size: 13px;
color: #999; color: #999;
} }
} }
.status-tag { .status-tag {
padding: 4px 8px; padding: 4px 8px;
border-radius: 4px; border-radius: 4px;
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 500;
background: #fff7e6; background: #fff7e6;
color: #fa8c16; color: #fa8c16;
&.completed { &.completed {
background: #e8f5e8; background: #e8f5e8;
color: #52c41a; color: #52c41a;
} }
&.failed { &.failed {
background: #fff1f0; background: #fff1f0;
color: #ff4d4f; color: #ff4d4f;
} }
&.processing { &.processing {
background: #fff7e6; background: #fff7e6;
color: #fa8c16; color: #fa8c16;
} }
} }
.record-actions { .record-actions {
display: flex; display: flex;
align-items: center; align-items: center;
flex-shrink: 0; flex-shrink: 0;
} }
} }
} }
.empty-state { .empty-state {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 80px 20px; padding: 80px 20px;
.empty-text { .empty-text {
color: #999; color: #999;
font-size: 14px; font-size: 14px;
margin-top: 16px; margin-top: 16px;
} }
} }
.load-more { .load-more {
padding: 20px; padding: 20px;
text-align: center; text-align: center;
} }
</style> </style>
Loading…
Cancel
Save