|
|
@@ -0,0 +1,464 @@
|
|
|
+<template>
|
|
|
+ <view class="credit-page">
|
|
|
+ <!-- 加载骨架 -->
|
|
|
+ <LoadingSkeleton v-if="loading" :rows="4" />
|
|
|
+
|
|
|
+ <!-- 错误态 -->
|
|
|
+ <ErrorState v-else-if="error" message="学时账户加载失败" @retry="loadAll" />
|
|
|
+
|
|
|
+ <!-- 空态 -->
|
|
|
+ <EmptyState
|
|
|
+ v-else-if="isEmpty"
|
|
|
+ icon="⏳"
|
|
|
+ title="暂无学时"
|
|
|
+ desc="完成培训签到后学时将自动入账,T+3 后正式生效"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 正常态 -->
|
|
|
+ <view v-else>
|
|
|
+ <!-- 顶部大数字 -->
|
|
|
+ <view class="hero-card">
|
|
|
+ <text class="hero-label">{{ year }}年已学</text>
|
|
|
+ <view class="hero-num-row">
|
|
|
+ <text class="hero-num">{{ totalText }}</text>
|
|
|
+ <text class="hero-unit">/ 90.0 学时</text>
|
|
|
+ </view>
|
|
|
+ <text class="hero-gap" :class="gapClass">{{ gapText }}</text>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 理论/实践分列 -->
|
|
|
+ <view class="split-card">
|
|
|
+ <view class="split-row">
|
|
|
+ <view class="split-head">
|
|
|
+ <text class="split-name">理论学时</text>
|
|
|
+ <text class="split-num">已 {{ theoryText }} / 40.0 h</text>
|
|
|
+ </view>
|
|
|
+ <ProgressBar :percent="theoryPercent" :color="blueColor" />
|
|
|
+ </view>
|
|
|
+ <view class="split-row">
|
|
|
+ <view class="split-head">
|
|
|
+ <text class="split-name">实践学时</text>
|
|
|
+ <text class="split-num">已 {{ practiceText }} / 20.0 h</text>
|
|
|
+ </view>
|
|
|
+ <ProgressBar :percent="practicePercent" :color="greenColor" />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 双 Tab -->
|
|
|
+ <view class="tab-card">
|
|
|
+ <view class="tab-head">
|
|
|
+ <view class="tab-item" :class="effectiveTabClass" @click="switchTab('effective')">
|
|
|
+ 生效中({{ effectiveList.length }})
|
|
|
+ </view>
|
|
|
+ <view class="tab-item" :class="pendingTabClass" @click="switchTab('pending')">
|
|
|
+ 待生效({{ pendingList.length }})
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 明细列表 -->
|
|
|
+ <view v-if="activeList.length === 0" class="list-empty">
|
|
|
+ <text class="list-empty-text">暂无{{ activeTab === 'effective' ? '生效' : '待生效' }}明细</text>
|
|
|
+ </view>
|
|
|
+ <view v-else>
|
|
|
+ <view v-for="(item, idx) in activeList" :key="item.id || idx" class="credit-item">
|
|
|
+ <view class="item-top">
|
|
|
+ <text class="item-name">{{ item.sourceText }}</text>
|
|
|
+ <text class="item-hours">+{{ item.hoursText }}h</text>
|
|
|
+ </view>
|
|
|
+ <view class="item-mid">
|
|
|
+ <StatusTag :status="item.status" type="credit" />
|
|
|
+ <text v-if="item.effectiveText" class="item-time">{{ item.effectiveText }}</text>
|
|
|
+ <text v-else-if="item.status === 'pending'" class="item-time">待 T+3 生效</text>
|
|
|
+ </view>
|
|
|
+ <view v-if="item.canObject && activeTab === 'pending'" class="item-bottom">
|
|
|
+ <text class="object-btn" @click="openObject(item)">提异议</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 提异议弹窗 -->
|
|
|
+ <view v-if="objectModal" class="modal-mask">
|
|
|
+ <view class="modal-card">
|
|
|
+ <text class="modal-title">学时异议</text>
|
|
|
+ <text class="modal-desc">异议提交后由机构复核,请说明原因</text>
|
|
|
+ <textarea
|
|
|
+ class="modal-textarea"
|
|
|
+ v-model="objectReason"
|
|
|
+ placeholder="请输入异议原因(必填)"
|
|
|
+ maxlength="200"
|
|
|
+ ></textarea>
|
|
|
+ <view class="modal-btns">
|
|
|
+ <view class="modal-btn modal-btn-cancel" @click="closeObject">取消</view>
|
|
|
+ <view class="modal-btn modal-btn-ok" @click="submitObject">提交</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getCreditMine, getCreditPending, creditObject } from '@/api/credit.js'
|
|
|
+import { creditHours, formatDateTime } from '@/utils/format.js'
|
|
|
+import StatusTag from '@/components/status-tag.vue'
|
|
|
+import EmptyState from '@/components/empty-state.vue'
|
|
|
+import ErrorState from '@/components/error-state.vue'
|
|
|
+import LoadingSkeleton from '@/components/loading-skeleton.vue'
|
|
|
+import ProgressBar from '@/components/progress-bar.vue'
|
|
|
+
|
|
|
+// 目标阈值(分钟):理论 2400=40h / 实践 1200=20h / 总 5400=90h(合同红线:一律分钟)
|
|
|
+var TARGET_THEORY = 2400
|
|
|
+var TARGET_PRACTICE = 1200
|
|
|
+var TARGET_TOTAL = 5400
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: { StatusTag, EmptyState, ErrorState, LoadingSkeleton, ProgressBar },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: true,
|
|
|
+ error: false,
|
|
|
+ year: 0,
|
|
|
+ total: 0,
|
|
|
+ theory: 0,
|
|
|
+ practice: 0,
|
|
|
+ gap: 0,
|
|
|
+ detail: [],
|
|
|
+ pendingRows: [],
|
|
|
+ activeTab: 'effective',
|
|
|
+ objectModal: false,
|
|
|
+ objectReason: '',
|
|
|
+ objectTarget: null,
|
|
|
+ submittingObject: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isEmpty() {
|
|
|
+ if (this.loading || this.error) return false
|
|
|
+ return this.total === 0 && this.theory === 0 && this.practice === 0 && (this.detail.length === 0 || !this.hasAnyDetail())
|
|
|
+ },
|
|
|
+ totalText() {
|
|
|
+ return creditHours(this.total)
|
|
|
+ },
|
|
|
+ theoryText() {
|
|
|
+ return creditHours(this.theory)
|
|
|
+ },
|
|
|
+ practiceText() {
|
|
|
+ return creditHours(this.practice)
|
|
|
+ },
|
|
|
+ gapText() {
|
|
|
+ if (this.gap > 0) return '还差 ' + creditHours(this.gap) + ' 学时满足年度目标'
|
|
|
+ return '已达成年度目标 🎉'
|
|
|
+ },
|
|
|
+ gapClass() {
|
|
|
+ return this.gap > 0 ? 'gap-warn' : 'gap-ok'
|
|
|
+ },
|
|
|
+ theoryPercent() {
|
|
|
+ return this.percentOf(this.theory, TARGET_THEORY)
|
|
|
+ },
|
|
|
+ practicePercent() {
|
|
|
+ return this.percentOf(this.practice, TARGET_PRACTICE)
|
|
|
+ },
|
|
|
+ blueColor() {
|
|
|
+ return '#2E6FA8'
|
|
|
+ },
|
|
|
+ greenColor() {
|
|
|
+ return '#0E8A4F'
|
|
|
+ },
|
|
|
+ // 生效侧(effective/objected/rejected)视图模型
|
|
|
+ effectiveList() {
|
|
|
+ return this.buildList('effective')
|
|
|
+ },
|
|
|
+ // 待生效侧(pending)视图模型
|
|
|
+ pendingList() {
|
|
|
+ var arr = []
|
|
|
+ var self = this
|
|
|
+ var source = this.pendingRows.length > 0 ? this.pendingRows : this.filterDetail('pending')
|
|
|
+ for (var i = 0; i < source.length; i++) {
|
|
|
+ arr.push(this.toItem(source[i]))
|
|
|
+ }
|
|
|
+ return arr
|
|
|
+ },
|
|
|
+ activeList() {
|
|
|
+ return this.activeTab === 'effective' ? this.effectiveList : this.pendingList
|
|
|
+ },
|
|
|
+ effectiveTabClass() {
|
|
|
+ return this.activeTab === 'effective' ? 'tab-active' : 'tab-normal'
|
|
|
+ },
|
|
|
+ pendingTabClass() {
|
|
|
+ return this.activeTab === 'pending' ? 'tab-active' : 'tab-normal'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ this.loadAll()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ loadAll() {
|
|
|
+ var self = this
|
|
|
+ self.loading = true
|
|
|
+ self.error = false
|
|
|
+ getCreditMine().then(function(res) {
|
|
|
+ var data = (res && res.data) ? res.data : {}
|
|
|
+ self.year = data.year || new Date().getFullYear()
|
|
|
+ self.total = data.total || 0
|
|
|
+ self.theory = data.theory || 0
|
|
|
+ self.practice = data.practice || 0
|
|
|
+ self.gap = data.gap || 0
|
|
|
+ self.detail = data.detail || []
|
|
|
+ // 待生效明细为分页接口,先加载第一页(不足时兜底用 mine.detail 过滤)
|
|
|
+ return getCreditPending(1, 50).then(function(resp) {
|
|
|
+ var pdata = (resp && resp.data) ? resp.data : {}
|
|
|
+ self.pendingRows = Array.isArray(pdata.list) ? pdata.list : []
|
|
|
+ return null
|
|
|
+ })
|
|
|
+ }).catch(function() {
|
|
|
+ self.error = true
|
|
|
+ }).finally(function() {
|
|
|
+ self.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ hasAnyDetail() {
|
|
|
+ var arr = this.detail || []
|
|
|
+ return arr.length > 0
|
|
|
+ },
|
|
|
+ filterDetail(status) {
|
|
|
+ var arr = []
|
|
|
+ var raw = this.detail || []
|
|
|
+ for (var i = 0; i < raw.length; i++) {
|
|
|
+ if (raw[i].status === status) arr.push(raw[i])
|
|
|
+ }
|
|
|
+ return arr
|
|
|
+ },
|
|
|
+ buildList(tab) {
|
|
|
+ var arr = []
|
|
|
+ var raw = this.detail || []
|
|
|
+ for (var i = 0; i < raw.length; i++) {
|
|
|
+ var s = raw[i].status || ''
|
|
|
+ var hit = tab === 'effective'
|
|
|
+ ? (s === 'effective' || s === 'objected' || s === 'rejected')
|
|
|
+ : (s === 'pending')
|
|
|
+ if (hit) arr.push(this.toItem(raw[i]))
|
|
|
+ }
|
|
|
+ return arr
|
|
|
+ },
|
|
|
+ toItem(raw) {
|
|
|
+ var item = raw || {}
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ sourceText: this.sourceText(item.sourceType),
|
|
|
+ hoursText: creditHours(item.hours || item.theory || 0),
|
|
|
+ status: item.status || 'pending',
|
|
|
+ effectiveText: item.effectiveAt ? formatDateTime(item.effectiveAt).slice(0, 16) : '',
|
|
|
+ canObject: this.canObject(item)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sourceText(type) {
|
|
|
+ var map = {
|
|
|
+ training: '培训',
|
|
|
+ attendance: '现场签到',
|
|
|
+ internship: '实习',
|
|
|
+ community: '社区服务',
|
|
|
+ family_service: '家庭服务',
|
|
|
+ exam: '考核',
|
|
|
+ other: '其他'
|
|
|
+ }
|
|
|
+ return map[type] || type || '学时'
|
|
|
+ },
|
|
|
+ canObject(item) {
|
|
|
+ var s = item.status || ''
|
|
|
+ return s === 'pending' || s === 'effective'
|
|
|
+ },
|
|
|
+ percentOf(part, totalTarget) {
|
|
|
+ if (!totalTarget || totalTarget <= 0) return 0
|
|
|
+ var p = (part / totalTarget) * 100
|
|
|
+ if (p < 0) return 0
|
|
|
+ if (p > 100) return 100
|
|
|
+ return Math.round(p)
|
|
|
+ },
|
|
|
+ switchTab(tab) {
|
|
|
+ this.activeTab = tab
|
|
|
+ },
|
|
|
+ openObject(item) {
|
|
|
+ this.objectTarget = item
|
|
|
+ this.objectReason = ''
|
|
|
+ this.objectModal = true
|
|
|
+ },
|
|
|
+ closeObject() {
|
|
|
+ this.objectModal = false
|
|
|
+ this.objectTarget = null
|
|
|
+ this.objectReason = ''
|
|
|
+ },
|
|
|
+ submitObject() {
|
|
|
+ var self = this
|
|
|
+ var reason = (this.objectReason || '').trim()
|
|
|
+ if (!this.objectTarget) return
|
|
|
+ if (!reason) {
|
|
|
+ uni.showToast({ title: '请输入异议原因', icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (self.submittingObject) return
|
|
|
+ self.submittingObject = true
|
|
|
+ creditObject(this.objectTarget.id, reason).then(function() {
|
|
|
+ self.submittingObject = false
|
|
|
+ self.closeObject()
|
|
|
+ uni.showToast({ title: '异议已提交,待机构复核', icon: 'none' })
|
|
|
+ self.loadAll()
|
|
|
+ }).catch(function(err) {
|
|
|
+ self.submittingObject = false
|
|
|
+ uni.showToast({ title: (err && err.message) || '提交失败', icon: 'none' })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.credit-page {
|
|
|
+ min-height: 100vh;
|
|
|
+ background: #F4F8FC;
|
|
|
+ padding: 20rpx 24rpx 48rpx;
|
|
|
+}
|
|
|
+/* 顶部大数字 */
|
|
|
+.hero-card {
|
|
|
+ background: linear-gradient(135deg, #12395F, #2E6FA8);
|
|
|
+ border-radius: 20rpx;
|
|
|
+ padding: 36rpx 32rpx;
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+.hero-label { font-size: 26rpx; color: rgba(255, 255, 255, 0.85); margin-bottom: 12rpx; }
|
|
|
+.hero-num-row { display: flex; align-items: baseline; margin-bottom: 14rpx; }
|
|
|
+.hero-num { font-size: 88rpx; font-weight: 700; color: #FFFFFF; line-height: 1.1; }
|
|
|
+.hero-unit { font-size: 28rpx; color: rgba(255, 255, 255, 0.85); margin-left: 10rpx; }
|
|
|
+.hero-gap { font-size: 26rpx; padding: 6rpx 24rpx; border-radius: 24rpx; }
|
|
|
+.gap-warn { background: rgba(255, 255, 255, 0.2); color: #FFE0B2; }
|
|
|
+.gap-ok { background: rgba(34, 197, 94, 0.3); color: #B8F5CE; }
|
|
|
+/* 分列 */
|
|
|
+.split-card {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #E3EEF7;
|
|
|
+ border-radius: 20rpx;
|
|
|
+ padding: 28rpx 26rpx;
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+}
|
|
|
+.split-row { margin-bottom: 28rpx; }
|
|
|
+.split-row:last-child { margin-bottom: 0; }
|
|
|
+.split-head {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 16rpx;
|
|
|
+}
|
|
|
+.split-name { font-size: 28rpx; font-weight: 600; color: #12395F; }
|
|
|
+.split-num { font-size: 24rpx; color: #7A97B5; }
|
|
|
+/* 双 Tab */
|
|
|
+.tab-card {
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #E3EEF7;
|
|
|
+ border-radius: 20rpx;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+.tab-head {
|
|
|
+ display: flex;
|
|
|
+ border-bottom: 1rpx solid #F0F5FA;
|
|
|
+}
|
|
|
+.tab-item {
|
|
|
+ flex: 1;
|
|
|
+ text-align: center;
|
|
|
+ height: 88rpx;
|
|
|
+ line-height: 88rpx;
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #7A97B5;
|
|
|
+}
|
|
|
+.tab-active {
|
|
|
+ color: #2E6FA8;
|
|
|
+ font-weight: 700;
|
|
|
+}
|
|
|
+.tab-normal { color: #7A97B5; }
|
|
|
+/* 明细 */
|
|
|
+.credit-item {
|
|
|
+ padding: 26rpx 26rpx 22rpx;
|
|
|
+ border-bottom: 1rpx solid #F0F5FA;
|
|
|
+}
|
|
|
+.item-top {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 12rpx;
|
|
|
+}
|
|
|
+.item-name { font-size: 28rpx; font-weight: 600; color: #1E3A5F; }
|
|
|
+.item-hours { font-size: 34rpx; font-weight: 700; color: #0E8A4F; }
|
|
|
+.item-mid {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+.item-time { font-size: 24rpx; color: #9DB3C9; }
|
|
|
+.item-bottom {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ margin-top: 12rpx;
|
|
|
+}
|
|
|
+.object-btn {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #2E6FA8;
|
|
|
+ border: 1rpx solid #BFDCF1;
|
|
|
+ border-radius: 28rpx;
|
|
|
+ padding: 8rpx 28rpx;
|
|
|
+}
|
|
|
+.object-btn:active { background: #EAF3FB; }
|
|
|
+.list-empty { padding: 56rpx 0; }
|
|
|
+.list-empty-text { display: block; text-align: center; font-size: 26rpx; color: #9DB3C9; }
|
|
|
+/* 弹窗 */
|
|
|
+.modal-mask {
|
|
|
+ position: fixed;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ background: rgba(18, 57, 95, 0.55);
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ z-index: 999;
|
|
|
+}
|
|
|
+.modal-card {
|
|
|
+ width: 80%;
|
|
|
+ background: #FFFFFF;
|
|
|
+ border-radius: 20rpx;
|
|
|
+ padding: 40rpx 32rpx 32rpx;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+}
|
|
|
+.modal-title { font-size: 34rpx; font-weight: 700; color: #12395F; margin-bottom: 12rpx; }
|
|
|
+.modal-desc { font-size: 24rpx; color: #7A97B5; margin-bottom: 24rpx; }
|
|
|
+.modal-textarea {
|
|
|
+ width: 100%;
|
|
|
+ height: 180rpx;
|
|
|
+ background: #F8FAFC;
|
|
|
+ border: 1rpx solid #E3EEF7;
|
|
|
+ border-radius: 12rpx;
|
|
|
+ padding: 20rpx;
|
|
|
+ font-size: 26rpx;
|
|
|
+ color: #12395F;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+.modal-btns { display: flex; margin-top: 28rpx; }
|
|
|
+.modal-btn {
|
|
|
+ flex: 1;
|
|
|
+ height: 80rpx;
|
|
|
+ line-height: 80rpx;
|
|
|
+ text-align: center;
|
|
|
+ border-radius: 40rpx;
|
|
|
+ font-size: 30rpx;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+.modal-btn-cancel {
|
|
|
+ background: #F0F5FA;
|
|
|
+ color: #5B7A99;
|
|
|
+ margin-right: 20rpx;
|
|
|
+}
|
|
|
+.modal-btn-ok { background: #2E6FA8; color: #FFFFFF; }
|
|
|
+</style>
|