xinli/xinlidsj/pages/chart/drillUsers.vue
2026-02-24 16:49:05 +08:00

195 lines
7.1 KiB
Vue

<template>
<view class="page" :class="{ big: isH5 }">
<view v-if="errorMsg" class="error">{{ errorMsg }}</view>
<view class="meta">{{ subtitle }}</view>
<view v-if="loading" class="state">
<uni-icons type="spinner-cycle" size="28" color="#94A3B8"></uni-icons>
<view class="state-text">加载中...</view>
</view>
<view v-else class="list">
<view v-if="rows.length === 0" class="state">
<uni-icons type="person" size="34" color="#CBD5E1"></uni-icons>
<view class="state-text">暂无数据</view>
</view>
<view v-else>
<view class="item" v-for="u in rows" :key="u.userId" @click="openProfile(u)">
<view class="row">
<view class="badge">{{ u.warningLevel || '-' }}</view>
<view class="item-title">{{ u.userName || ('用户#' + u.userId) }}</view>
</view>
<view class="item-desc">监区:{{ u.deptName || '-' }}</view>
<view class="item-actions">
<button class="btn ghost small" @click.stop="openLatestReport(u)">查看最新报告</button>
</view>
</view>
<view v-if="hasMore" class="load-more">上拉加载更多…</view>
<view v-else class="load-more">没有更多了</view>
</view>
</view>
</view>
</template>
<script>
import { drillUsers } from '../../api/psychology/chart'
import UniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
export default {
components: {
UniIcons
},
data() {
return {
isH5: false,
loading: false,
errorMsg: '',
rows: [],
total: 0,
query: {
pageNum: 1,
pageSize: 10,
startDate: '',
endDate: '',
deptId: '',
prisonArea: '',
warningLevel: '',
factorId: '',
factorName: '',
scaleId: '',
remainingMonthsMax: '',
crimeName: ''
}
}
},
computed: {
hasMore() {
return this.rows.length < (this.total || 0)
},
subtitle() {
const parts = []
parts.push((this.query.startDate || '-') + ' ~ ' + (this.query.endDate || '-'))
if (this.query.warningLevel) parts.push('风险=' + this.query.warningLevel)
if (this.query.prisonArea) parts.push('监区=' + this.query.prisonArea)
else if (this.query.deptId) parts.push('deptId=' + this.query.deptId)
if (this.query.factorId) parts.push('factorId=' + this.query.factorId)
if (this.query.factorName) parts.push('因子=' + this.query.factorName)
if (this.query.remainingMonthsMax) parts.push('剩余≤' + this.query.remainingMonthsMax + '月')
if (this.query.crimeName) parts.push('罪名=' + this.query.crimeName)
return parts.join(' · ')
}
},
onLoad(q) {
try {
const info = uni.getSystemInfoSync()
const p = info ? (info.uniPlatform || info.platform) : ''
this.isH5 = p === 'web' || p === 'h5'
} catch (e) {
this.isH5 = false
}
this.query.startDate = q.startDate || ''
this.query.endDate = q.endDate || ''
this.query.deptId = q.deptId || ''
this.query.prisonArea = q.prisonArea || q.prison_area || ''
this.query.warningLevel = q.warningLevel || ''
this.query.factorId = q.factorId || ''
this.query.factorName = q.factorName || ''
this.query.scaleId = q.scaleId || ''
this.query.remainingMonthsMax = q.remainingMonthsMax || ''
this.query.crimeName = q.crimeName || ''
this.refresh()
},
onReachBottom() {
if (this.loading || !this.hasMore) return
this.query.pageNum += 1
this.fetchList(true)
},
methods: {
refresh() {
this.query.pageNum = 1
this.rows = []
this.total = 0
return this.fetchList(false)
},
fetchList(append) {
this.loading = true
this.errorMsg = ''
const params = { ...this.query }
Object.keys(params).forEach((k) => {
if (params[k] === '' || params[k] == null) delete params[k]
})
return drillUsers(params)
.then((res) => {
this.loading = false
const data = res && res.data ? res.data : null
if (!data || data.code !== 200) {
this.errorMsg = (data && data.msg) ? data.msg : '加载失败'
return
}
this.total = data.total || 0
const list = data.rows || []
this.rows = append ? this.rows.concat(list) : list
})
.catch((e) => {
this.loading = false
this.errorMsg = e && e.message ? e.message : '网络错误'
})
},
openProfile(u) {
if (!u || !u.userId) return
uni.navigateTo({ url: `/pages/profile/index?userId=${encodeURIComponent(u.userId)}` })
},
openLatestReport(u) {
if (!u) return
const reportId = u.latestReportId || u.reportId
if (!reportId) {
uni.showToast({ title: '暂无可用报告', icon: 'none' })
return
}
const sourceType = u.sourceType || 'assessment'
uni.navigateTo({
url: `/pages/report/detail?reportId=${encodeURIComponent(reportId)}&sourceType=${encodeURIComponent(sourceType)}`
})
}
}
}
</script>
<style>
.page { min-height: 100vh; padding: 24rpx 24rpx 120rpx; box-sizing: border-box; background: #F4F6FB; }
.page.big {
padding: 14rpx 14rpx 120rpx;
background-image:
radial-gradient(1100rpx 520rpx at 50% 14%, rgba(43, 107, 255, 0.30) 0%, rgba(6, 16, 40, 0.0) 65%),
linear-gradient(180deg, rgba(5, 11, 24, 0.90) 0%, rgba(8, 20, 45, 0.85) 42%, rgba(6, 16, 40, 0.92) 100%),
url('/static/bg.png');
background-size: auto, auto, cover;
background-position: center, center, center;
background-repeat: no-repeat, no-repeat, no-repeat;
}
.meta { margin: 10rpx 0 14rpx; padding: 18rpx; border-radius: 18rpx; background: rgba(15,23,42,0.03); border: 1px solid rgba(15,23,42,0.06); font-size: 22rpx; color: #64748B; line-height: 34rpx; }
.list { margin-top: 8rpx; }
.item { background: rgba(255, 255, 255, 0.95); border-radius: 18rpx; padding: 18rpx; border: 1px solid rgba(15,23,42,0.06); margin-bottom: 14rpx; }
.row { display: flex; align-items: center; }
.badge { font-size: 22rpx; padding: 6rpx 14rpx; border-radius: 999rpx; margin-right: 14rpx; color: #fff; background: #1677ff; }
.item-title { font-size: 28rpx; font-weight: 700; color: #111827; flex: 1; }
.item-desc { margin-top: 10rpx; font-size: 24rpx; color: #64748B; }
.state { height: 360rpx; border-radius: 20rpx; background: rgba(255, 255, 255, 0.85); border: 1px solid rgba(15, 23, 42, 0.06); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12rpx; }
.state-text { font-size: 24rpx; color: #94A3B8; font-weight: 700; }
.load-more { text-align: center; color: #94A3B8; font-size: 22rpx; padding: 20rpx 0 6rpx; }
.error { margin-top: 14rpx; font-size: 24rpx; color: #ff4d4f; line-height: 36rpx; }
.page.big .meta,
.page.big .item,
.page.big .state {
border: 1px solid rgba(116, 216, 255, 0.22);
background: linear-gradient(180deg, rgba(10, 18, 38, 0.75) 0%, rgba(5, 10, 22, 0.55) 100%);
box-shadow: 0 12rpx 24rpx rgba(0, 0, 0, 0.35);
}
.page.big .meta,
.page.big .item-desc,
.page.big .state-text,
.page.big .load-more { color: rgba(201, 242, 255, 0.65); }
.page.big .item-title { color: rgba(235, 248, 255, 0.92); }
.page.big .badge { background: linear-gradient(90deg, rgba(116, 216, 255, 0.95) 0%, rgba(43, 107, 255, 0.90) 100%); color: #0b1226; }
.page.big .btn.ghost { background: rgba(7, 13, 28, 0.35); border-color: rgba(116, 216, 255, 0.18); color: rgba(201, 242, 255, 0.86); }
</style>