ihzero 2024-04-24 01:10:43 +08:00
parent 38a733648a
commit be43c6ad67
3 changed files with 453 additions and 44 deletions

316
src/pages copy.json 100644
View File

@ -0,0 +1,316 @@
{
"pages": [
{
"path": "pages/login/index",
"style": {
"navigationBarTitleText": "登录"
}
},
{
"path": "pages/home/index",
"style": {
"navigationBarTitleText": "首页"
}
},
{
"path": "pages/revert/index",
"style": {
"navigationBarTitleText": "上报"
}
},
{
"path": "pages/statement/index",
"style": {
"navigationBarTitleText": "报表"
}
},
{
"path": "pages/mine/index",
"style": {
"navigationBarTitleText": "我的"
}
}
],
"subPackages": [
{
"root": "pages/data",
"pages": [
{
"path": "brokerage/index",
"style": {
"navigationBarTitleText": "提成数据"
}
},
{
"path": "performance/index",
"style": {
"navigationBarTitleText": "业绩数据"
}
},
{
"path": "upload/index",
"style": {
"navigationBarTitleText": "上传数据"
}
}
]
},
{
"root": "pages/user",
"pages": [
{
"path": "index",
"style": {
"navigationBarTitleText": "员工管理"
}
},
{
"path": "update",
"style": {
"navigationBarTitleText": "修改信息"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "员工详情"
}
}
]
},
{
"root": "pages/setting",
"pages": [
{
"path": "index",
"style": {
"navigationBarTitleText": "设置"
}
},
{
"path": "password",
"style": {
"navigationBarTitleText": "修改密码"
}
},
{
"path": "complain",
"style": {
"navigationBarTitleText": "举报投诉"
}
},
{
"path": "suggestion",
"style": {
"navigationBarTitleText": "意见箱"
}
}
]
},
{
"root": "pages/task",
"pages": [
{
"path": "index",
"style": {
"navigationBarTitleText": "任务列表"
}
},
{
"path": "submit",
"style": {
"navigationBarTitleText": "任务提交"
}
},
{
"path": "task_hygienes_submit",
"style": {
"navigationBarTitleText": "清洁任务提交"
}
},
{
"path": "task_ledgers_submit",
"style": {
"navigationBarTitleText": "数据上报"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "任务详情"
}
}
]
},
{
"root": "pages/expense-account",
"pages": [
{
"path": "index",
"style": {
"navigationBarTitleText": "报销管理"
}
},
{
"path": "submit",
"style": {
"navigationBarTitleText": "报销提交"
}
}
]
},
{
"root": "pages/work",
"pages": [
{
"path": "list",
"style": {
"navigationBarTitleText": "升职申请"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "升职申请"
}
},
{
"path": "create",
"style": {
"navigationBarTitleText": "升职申请"
}
}
]
},
{
"root": "pages/make-card",
"pages": [
{
"path": "list",
"style": {
"navigationBarTitleText": "补卡申请"
}
},
{
"path": "create",
"style": {
"navigationBarTitleText": "补卡申请"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "补卡审核"
}
}
]
},
{
"root": "pages/ask-leave",
"pages": [
{
"path": "list",
"style": {
"navigationBarTitleText": "请假申请"
}
},
{
"path": "create",
"style": {
"navigationBarTitleText": "请假申请"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "请假详情"
}
}
]
},
{
"root": "pages/train-books",
"pages": [
{
"path": "index",
"style": {
"navigationBarTitleText": "培训课件"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "培训课件"
}
}
]
},
{
"root": "pages/examination",
"pages": [
{
"path": "index",
"style": {
"navigationBarTitleText": "培训考试"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "培训考试"
}
}
]
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#FFFFFF",
"navigationStyle": "custom",
"backgroundColorTop": "#FFFFFF",
"app-plus": {
"bounce": "none",
"scrollIndicator": "none"
}
},
"tabBar": {
"color": "#333",
"selectedColor": "#ff3c2a",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/home/index",
"selectedIconPath": "static/images/home.png",
"iconPath": "static/images/home.png",
"text": "首页"
},
{
"pagePath": "pages/revert/index",
"selectedIconPath": "static/images/home.png",
"iconPath": "static/images/home.png",
"text": "上报"
},
{
"pagePath": "pages/statement/index",
"selectedIconPath": "static/images/home.png",
"iconPath": "static/images/home.png",
"text": "报表"
},
{
"pagePath": "pages/mine/index",
"selectedIconPath": "static/images/home.png",
"iconPath": "static/images/home.png",
"text": "我的"
}
]
},
"easycom": {
"autoscan": true,
"custom": {
"^uv-(.*)": "@climblee/uv-ui/components/uv-$1/uv-$1.vue"
}
}
}

View File

@ -1,81 +1,168 @@
<template>
<view>
<CuNavbar title="培训考试"></CuNavbar>
<CuNavbar title="培训考试">
<template v-if="!readonly" #right>
<view class="text-white" @click="submit"></view>
</template>
</CuNavbar>
<uv-sticky bgColor="#fff">
<view class="flex items-center justify-between h-90rpx px-base">
<view>{{ index }}/{{ total }}</view>
<view>
<view v-if="index > 0" @click="prev"></view>
<view v-if="index < total" @click="next"></view>
<view v-if="index >= total" @click="submit"></view>
<view class="w-140rpx">
<view class="btn" :disabled="index == 0" @click="prev"></view>
</view>
<view>{{ index + 1 }}/{{ total }}</view>
<view class="w-140rpx text-right">
<view class="btn" :disabled="index == total - 1" @click="next">
下一题</view
>
</view>
</view>
</uv-sticky>
<view class="content">
<template v-for="(item, key) in list" :key="key">
<view v-show="key == index" class="item">
<view class="title">({{ item.cate_name }}){{ item.title }}</view>
<view class="options">
<u-checkbox-group v-if="item.cate == 1">
<u-checkbox
v-for="(option, optionKey) in item.options"
:key="optionKey"
:label="option.text"
:name="optionKey"
/>
</u-checkbox-group>
<u-radio-group v-if="item.cate == 2">
<u-radio
v-for="(option, optionKey) in item.options"
:key="optionKey"
:label="option.text"
:name="optionKey"
/>
</u-radio-group>
<view class="p-base">
<view class="card-shadow bg-white rounded-19rpx p-base min-h-30vh">
<template v-for="(item, key) in list" :key="key">
<view v-show="key == index" class="item">
<view class="title text-30rpx"
>({{ item.cate_name }}){{ item.title }}
<text v-if="readonly" class="text-primary"
>(得分{{ item.user_score }})</text
>
</view>
<view
class="pt-base"
:class="[readonly ? 'pointer-events-none' : '']"
>
<template v-if="item.cate == 2">
<uv-checkbox-group
activeColor="#ee2c37"
v-model="item.answer"
placement="column"
>
<uv-checkbox
:customStyle="{ margin: '8px' }"
v-for="(op, i) in item.options"
:key="i"
:label="op.text"
:name="op.text"
>
</uv-checkbox>
</uv-checkbox-group>
</template>
<template v-if="item.cate == 1">
<uv-radio-group
activeColor="#ee2c37"
v-model="item.answer"
placement="column"
>
<uv-radio
:customStyle="{ margin: '8px' }"
v-for="(op, i) in item.options"
:key="i"
:label="op.text"
:name="op.text"
>
</uv-radio>
</uv-radio-group>
</template>
</view>
</view>
</view>
</template>
</template>
</view>
</view>
<uv-modal
ref="modalRef"
title="提示"
:content="`是否确认提交?`"
@confirm="onSubmit"
></uv-modal>
</view>
</template>
<script setup>
import CuNavbar from '@/components/cu-navbar/index'
import { http } from '@/utils/request'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { computed, ref } from 'vue'
const modalRef = ref(null)
const info = ref({})
const id = ref(0)
//
const list = ref([])
// const list = ref([])
//
const total = ref(0)
// const total = ref(0)
//
const index = ref(0)
//
const readonly = ref(true)
onLoad((options) => {
http.get(`/train/examinations/${options.id}`).then((res) => {
if (res.finished_at) {
readonly = false
// const readonly = ref(true)
const loading = ref(false)
const list = computed(() => {
const content = info.value?.content ?? []
content.forEach((item) => {
if (item.score == 1) {
item.answer = item.user_answer[0] ?? ''
} else {
item.answer = item.user_answer ?? []
}
})
return info.value.content || []
})
const total = computed(() => list.value.length)
const readonly = computed(() => (info.value.finished_at ? true : false))
const answer = computed(() => {
const arr = list.value.reduce((a, b) => {
const c = [].concat(b.answer ?? [])
a.push(c)
return a
}, [])
return arr || []
})
onLoad((options) => {
id.value = options.id
http.get(`/train/examinations/${options.id}`).then((resData) => {
const res = resData
info.value = res
list.value = res.content
total.value = res.content.length
})
})
const next = () => {
if (index < total) {
if (index.value < total.value - 1) {
index.value++
}
}
const prev = () => {
if (index > 0) {
if (index.value > 0) {
index.value--
}
}
const submit = () => {
http.post(`/train/examinations/${info.id}/answer`).then((res) => {})
modalRef.value.open()
}
const onSubmit = async () => {
if (loading.value) return
loading.value = true
try {
await http.post(`/train/examinations/${id.value}/answer`, {
answers: answer.value,
})
uni.$emit('examination:onRefresh')
uni.navigateBack()
} catch (error) {
} finally {
loading.value = false
}
}
</script>
<style scoped lang="scss">
.btn {
@apply text-28rpx;
}
.btn[disabled='true'] {
color: #999;
@apply pointer-events-none;
}
</style>

View File

@ -38,6 +38,12 @@ import useMescrollComp from '@/uni_modules/mescroll-uni/hooks/useMescrollComp.js
import { timeFormat } from '@climblee/uv-ui/libs/function/index'
const { mescrollItem } = useMescrollComp(onPageScroll, onReachBottom)
onLoad(() => {
uni.$on('examination:onRefresh', () => {
mescrollItem.value?.refresh()
})
})
const detail = (item) => {
uni.navigateTo({
url: `/pages/examination/detail?id=${item.id}`,