|
|
@@ -0,0 +1,236 @@
|
|
|
+<template>
|
|
|
+ <view class="daily-container">
|
|
|
+ <!-- 顶部操作栏 -->
|
|
|
+ <view class="header-actions">
|
|
|
+ <button class="add-btn" type="primary" @click="createDaily">
|
|
|
+ <uni-icons type="plus" size="16"></uni-icons>
|
|
|
+ 写日报
|
|
|
+ </button>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 日报列表 -->
|
|
|
+ <view class="daily-list">
|
|
|
+ <uni-card v-for="item in dailyList" :key="item.dailyId" :title="item.dailyTitle"
|
|
|
+ :extra="formatDate(item.createTime)" @click="viewDaily(item)">
|
|
|
+
|
|
|
+ <view class="daily-content">
|
|
|
+ <view class="daily-summary">
|
|
|
+ <text class="summary-text">{{ item.dailySummary }}</text>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="daily-meta">
|
|
|
+ <view class="meta-item">
|
|
|
+ <uni-icons type="calendar" size="14" color="#666"></uni-icons>
|
|
|
+ <text class="meta-text">{{ item.reportDate }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="meta-item">
|
|
|
+ <uni-icons type="person" size="14" color="#666"></uni-icons>
|
|
|
+ <text class="meta-text">{{ item.createBy }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <view class="card-actions">
|
|
|
+ <button size="mini" type="default" @click.stop="editDaily(item)">
|
|
|
+ 编辑
|
|
|
+ </button>
|
|
|
+ <button size="mini" type="warn" @click.stop="deleteDaily(item)">
|
|
|
+ 删除
|
|
|
+ </button>
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+ </uni-card>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 空状态 -->
|
|
|
+ <view v-if="dailyList.length === 0" class="empty-state">
|
|
|
+ <uni-icons type="info" size="48" color="#ccc"></uni-icons>
|
|
|
+ <text class="empty-text">暂无日报记录</text>
|
|
|
+ <button class="empty-btn" type="primary" @click="createDaily">立即写日报</button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { ref, reactive, onMounted } from 'vue'
|
|
|
+import { listDaily, delDaily } from '@/api/oa/daily'
|
|
|
+
|
|
|
+// 日报列表数据
|
|
|
+const dailyList = ref([])
|
|
|
+const queryParams = reactive({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ projectId: null
|
|
|
+})
|
|
|
+
|
|
|
+// 获取日报列表
|
|
|
+async function getDailyList() {
|
|
|
+ try {
|
|
|
+ const res = await listDaily(queryParams)
|
|
|
+ if (res && res.rows) {
|
|
|
+ dailyList.value = res.rows
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取日报列表失败:', error)
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取日报列表失败',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 格式化日期
|
|
|
+function formatDate(dateString) {
|
|
|
+ if (!dateString) return ''
|
|
|
+ const date = new Date(dateString)
|
|
|
+ return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
|
|
+}
|
|
|
+
|
|
|
+// 创建日报
|
|
|
+function createDaily() {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/work/daily/edit'
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 查看日报
|
|
|
+function viewDaily(item) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/work/daily/detail?dailyId=${item.dailyId}`
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 编辑日报
|
|
|
+function editDaily(item) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/work/daily/edit?dailyId=${item.dailyId}`
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 删除日报
|
|
|
+function deleteDaily(item) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '确认删除',
|
|
|
+ content: '确定要删除这篇日报吗?',
|
|
|
+ success: async (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ try {
|
|
|
+ await delDaily(item.dailyId)
|
|
|
+ uni.showToast({
|
|
|
+ title: '删除成功',
|
|
|
+ icon: 'success'
|
|
|
+ })
|
|
|
+ getDailyList() // 重新加载列表
|
|
|
+ } catch (error) {
|
|
|
+ console.error('删除日报失败:', error)
|
|
|
+ uni.showToast({
|
|
|
+ title: '删除失败',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 页面加载时获取数据
|
|
|
+onMounted(() => {
|
|
|
+ getDailyList()
|
|
|
+})
|
|
|
+
|
|
|
+// 下拉刷新
|
|
|
+onPullDownRefresh(() => {
|
|
|
+ getDailyList().finally(() => {
|
|
|
+ uni.stopPullDownRefresh()
|
|
|
+ })
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.daily-container {
|
|
|
+ padding: 20rpx;
|
|
|
+ background-color: #f5f5f5;
|
|
|
+ min-height: 100vh;
|
|
|
+}
|
|
|
+
|
|
|
+.header-actions {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.add-btn {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 8rpx;
|
|
|
+ padding: 16rpx 24rpx;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ font-size: 28rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.daily-list {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.daily-content {
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.daily-summary {
|
|
|
+ margin-bottom: 16rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.summary-text {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #333;
|
|
|
+ line-height: 1.6;
|
|
|
+ display: -webkit-box;
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
+ -webkit-line-clamp: 3;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+
|
|
|
+.daily-meta {
|
|
|
+ display: flex;
|
|
|
+ gap: 24rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.meta-item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 8rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.meta-text {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #666;
|
|
|
+}
|
|
|
+
|
|
|
+.card-actions {
|
|
|
+ display: flex;
|
|
|
+ gap: 16rpx;
|
|
|
+ justify-content: flex-end;
|
|
|
+}
|
|
|
+
|
|
|
+.empty-state {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ padding: 120rpx 40rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.empty-text {
|
|
|
+ margin: 20rpx 0 40rpx;
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #999;
|
|
|
+}
|
|
|
+
|
|
|
+.empty-btn {
|
|
|
+ padding: 20rpx 40rpx;
|
|
|
+ border-radius: 8rpx;
|
|
|
+}
|
|
|
+</style>
|