main
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");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onHide(() => {
|
||||||
|
console.log("App Hide");
|
||||||
|
});
|
||||||
|
|
||||||
|
onError((error) => {
|
||||||
|
console.error("App Error", error);
|
||||||
|
});
|
||||||
|
|
||||||
|
onPageNotFound((res) => {
|
||||||
|
console.error("PageNotFound", res);
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/404/404",
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
/* 每个页面公共css */
|
/* 每个页面公共css */
|
||||||
page {
|
page {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* uv-ui基础样式 */
|
/* uv-ui基础样式 */
|
||||||
@import "@/uni_modules/uv-ui-tools/index.scss";
|
@import "@/uni_modules/uv-ui-tools/index.scss";
|
||||||
</style>
|
</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 options = ref([{
|
// 下载记录
|
||||||
text: '删除',
|
const downloadRecord = (record) => {
|
||||||
style: {
|
uni.showLoading({
|
||||||
backgroundColor: '#f56c6c'
|
title: "准备下载...",
|
||||||
}
|
});
|
||||||
}])
|
|
||||||
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)
|
|
||||||
|
|
||||||
// 下载记录
|
// #ifdef H5
|
||||||
const downloadRecord = (record) => {
|
// 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.showLoading({
|
uni.hideLoading();
|
||||||
title: "准备下载...",
|
uni.showToast({
|
||||||
});
|
title: "开始下载",
|
||||||
uni.downloadFile({
|
icon: "success",
|
||||||
url: record.result_url,
|
});
|
||||||
// url:'https://ksdt-1255846884.cos.ap-shanghai.myqcloud.com/lift-result/2025/09/24/d6180add4cd94875a1854a4febce8966.pdf',
|
// #endif
|
||||||
success: (res) => {
|
|
||||||
console.log(res)
|
|
||||||
if (res.statusCode === 200) {
|
|
||||||
uni.saveFile({
|
|
||||||
tempFilePath: res.tempFilePath,
|
|
||||||
success: () => {
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载成功',
|
|
||||||
icon: 'success'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: () => {
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载失败',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除记录
|
// #ifndef H5
|
||||||
const deleteRecord = (record) => {
|
// 小程序和App端使用uni.downloadFile
|
||||||
uni.showModal({
|
uni.downloadFile({
|
||||||
title: "确认删除",
|
url: record.result_url,
|
||||||
content: "确定要删除这条生成记录吗?删除后无法恢复。",
|
success: (res) => {
|
||||||
success: (res) => {
|
console.log(res);
|
||||||
if (res.confirm) {
|
if (res.statusCode === 200) {
|
||||||
// 从列表中移除记录
|
uni.saveFile({
|
||||||
const index = records.value.findIndex((item) => item.id === record.id);
|
tempFilePath: res.tempFilePath,
|
||||||
if (index !== -1) {
|
success: () => {
|
||||||
records.value.splice(index, 1);
|
uni.hideLoading();
|
||||||
}
|
uni.showToast({
|
||||||
|
title: "下载成功",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: "保存失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: "下载失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: "下载失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
};
|
||||||
|
|
||||||
uni.showToast({
|
// 删除记录
|
||||||
title: "删除成功",
|
const deleteRecord = (record) => {
|
||||||
icon: "success",
|
uni.showModal({
|
||||||
});
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
// 实际项目中调用删除API
|
uni.showToast({
|
||||||
// try {
|
title: "删除成功",
|
||||||
// await RPC.post('/api/generate-record/delete', { id: record.id })
|
icon: "success",
|
||||||
// } catch (error) {
|
});
|
||||||
// console.error('删除失败:', error)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 加载生成记录
|
// 实际项目中调用删除API
|
||||||
const loadRecords = async () => {
|
// try {
|
||||||
loadingStatus.value === 'loading'
|
// await RPC.post('/api/generate-record/delete', { id: record.id })
|
||||||
RPC.post('/planned_list',{page:page.value,page_size:20}).then(res => {
|
// } catch (error) {
|
||||||
list.value = [...list.value, ...res.list]
|
// console.error('删除失败:', error)
|
||||||
count.value = res.total
|
// }
|
||||||
if (list.value.length >= count.value) {
|
}
|
||||||
loadingStatus.value = 'nomore'
|
},
|
||||||
} else {
|
});
|
||||||
loadingStatus.value = 'loadmore'
|
};
|
||||||
}
|
|
||||||
}).catch(() => {
|
|
||||||
loadingStatus.value = 'loadmore'
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
// 刷新数据
|
// 加载生成记录
|
||||||
onPullDownRefresh(() => {
|
const loadRecords = async () => {
|
||||||
list.value = []
|
loadingStatus.value === "loading";
|
||||||
page.value = 1
|
RPC.post("/planned_list", { page: page.value, page_size: 20 })
|
||||||
loadingStatus.value === 'loading'
|
.then((res) => {
|
||||||
RPC.post('/planned_list',{page:page.value,page_size:20}).then(res => {
|
list.value = [...list.value, ...res.list];
|
||||||
list.value = [...list.value, ...res.list]
|
count.value = res.total;
|
||||||
count.value = res.total
|
if (list.value.length >= count.value) {
|
||||||
if (list.value.length >= count.value) {
|
loadingStatus.value = "nomore";
|
||||||
loadingStatus.value = 'nomore'
|
} else {
|
||||||
} else {
|
loadingStatus.value = "loadmore";
|
||||||
loadingStatus.value = 'loadmore'
|
}
|
||||||
}
|
})
|
||||||
}).catch(() => {
|
.catch(() => {
|
||||||
loadingStatus.value = 'loadmore'
|
loadingStatus.value = "loadmore";
|
||||||
}).finally(() => {
|
});
|
||||||
uni.stopPullDownRefresh()
|
};
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
onReachBottom(() => {
|
// 刷新数据
|
||||||
loadmore()
|
onPullDownRefresh(() => {
|
||||||
})
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const loadmore = () => {
|
onReachBottom(() => {
|
||||||
if (list.value.length >= count.value || loadingStatus.value === 'loading') return
|
loadmore();
|
||||||
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…
Reference in new issue