70 lines
2.4 KiB
Vue
70 lines
2.4 KiB
Vue
<template>
|
|
<view class="page">
|
|
<fy-header title="工作汇报" back />
|
|
<view v-if="!can" class="deny">当前账号没有写汇报权限</view>
|
|
<view v-else>
|
|
<view class="card form">
|
|
<picker :range="kinds" @change="(e) => kind = kinds[e.detail.value]">
|
|
<view class="box">{{ kind }}</view>
|
|
</picker>
|
|
<view class="box tall"><textarea v-model="content" placeholder="今日工作内容 / 周报摘要" /></view>
|
|
<view class="btn-primary" @click="submit">提交汇报</view>
|
|
</view>
|
|
<view v-for="r in rows" :key="r.id" class="card item">
|
|
<text class="t">{{ r.title || r.kind || '汇报' }}</text>
|
|
<text class="s">{{ r.createdAt || r.date || '' }}</text>
|
|
<text class="c">{{ r.content || r.summary || '' }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import FyHeader from '../../components/fy-header.vue'
|
|
import { store } from '../../utils/store.js'
|
|
import { asList, toast } from '../../utils/format.js'
|
|
import { oaGet, oaPost } from '../../utils/api.js'
|
|
|
|
export default {
|
|
components: { FyHeader },
|
|
data() {
|
|
return { kinds: ['日报', '周报', '月报', '工时'], kind: '日报', content: '', rows: [] }
|
|
},
|
|
computed: {
|
|
can() { return store.can('personal', 'report') }
|
|
},
|
|
onShow() { if (this.can) this.load() },
|
|
methods: {
|
|
async load() {
|
|
try {
|
|
this.rows = asList(await oaGet('/reports?mine=1', store.token))
|
|
} catch (_) {
|
|
try { this.rows = asList(await oaGet('/project/hours?mine=1', store.token)) } catch (e) { this.rows = [] }
|
|
}
|
|
},
|
|
async submit() {
|
|
if (!this.content.trim()) return toast('请填写内容')
|
|
try {
|
|
await oaPost('/reports', { kind: this.kind, content: this.content, title: this.kind }, store.token)
|
|
toast('已提交', 'success')
|
|
this.content = ''
|
|
this.load()
|
|
} catch (e) {
|
|
toast(e.message || '提交失败')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.form { margin: 24rpx; padding: 24rpx; }
|
|
.box { background: #F3F6FB; border-radius: 12rpx; padding: 20rpx; margin-bottom: 16rpx; }
|
|
.box.tall { min-height: 160rpx; }
|
|
.item { margin: 0 24rpx 16rpx; padding: 24rpx; }
|
|
.t { display: block; font-weight: 600; }
|
|
.s { font-size: 22rpx; color: #6B7280; }
|
|
.c { display: block; font-size: 26rpx; margin-top: 8rpx; }
|
|
.deny { padding: 80rpx; text-align: center; color: #6B7280; }
|
|
</style>
|