123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989 |
- <script setup lang="ts">
- import { format } from "date-fns";
- import CpmdHeader from '@/components/CpmdHeader.vue';
- import { onMounted, onUnmounted, ref } from 'vue'
- import { Check } from '@element-plus/icons-vue'
- import { number } from 'echarts';
- import { ElMessage } from 'element-plus';
- import { useRouter, useRoute } from 'vue-router';
- import { getCurrentTimeApi, getScaleApi, queryScaleDetailApi, saveScaleApi } from '@/api/plan';
- import { userInfoStore } from '@/stores'
- import CpdmTip from "@/components/CpdmTip.vue";
- const isLock = ref<boolean>(false)
- import { isHaveManage } from '@/utils/test'
- import { userPlanApi, userPlanDetailApi } from '@/api/home';
- import { id } from 'element-plus/es/locales.mjs';
- const userInfo = userInfoStore()
- const router = useRouter()
- const route = useRoute()
- const cpdmTip = ref<any>()
- const isCompleted = ref<boolean>(false)
- const planObj = ref<any>({})
- const flag = ref<string>('')
- const flagName = ref<string>('')
- const planId = ref<string>('')
- const planName = ref<string>('')
- const startTime = ref<string>('')
- const num = ref<string>('')
- const isComplate = ref<string>('')
- const planAllNum = ref<number>(0);
- const planIsComplateNum = ref<number>(0);
- const planNoComplateNum = ref<number>(0);
- const scaleList = ref<any>([
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ])
- const topicIndex = ref<number>(1)
- const listDepressed = ref<any>([])
- const listStress = ref<any>([])
- const listAnxiety = ref<any>([])
- const nextTopic = () => {
-
-
-
-
-
- if (scaleList.value[topicIndex.value - 1].isCheck == '') {
- ElMessage({
- message: '请选择当前题目',
- type: "warning",
- })
- return
- }
-
-
-
- if (scaleList.value[topicIndex.value - 1].flag == '20210617020516' && !listDepressed.value.includes(scaleList.value[topicIndex.value - 1].id)) {
- listDepressed.value.push(scaleList.value[topicIndex.value - 1].id)
-
-
-
- if (listDepressed.value.length == 20) {
- let list = []
- for (let i = 0; i < scaleList.value.length; i++) {
- if (scaleList.value[i].flag == '20210617020516') {
- list.push(scaleList.value[i])
- }
- }
- let listTm = JSON.parse(JSON.stringify(list))
- subScaleData(listTm, "20210617020516")
- }
- }
-
- if (scaleList.value[topicIndex.value - 1].flag == '20210913093250' && !listStress.value.includes(scaleList.value[topicIndex.value - 1].id)) {
- listStress.value.push(scaleList.value[topicIndex.value - 1].id)
-
-
- if (listStress.value.length == 30) {
- let list = []
- for (let i = 0; i < scaleList.value.length; i++) {
- if (scaleList.value[i].flag == '20210913093250') {
- list.push(scaleList.value[i])
- }
- }
- let listTm = JSON.parse(JSON.stringify(list))
- subScaleData(listTm, "20210913093250")
- }
- }
-
- if (scaleList.value[topicIndex.value - 1].flag == '20210617000853' && !listAnxiety.value.includes(scaleList.value[topicIndex.value - 1].id)) {
- listAnxiety.value.push(scaleList.value[topicIndex.value - 1].id)
-
- if (listAnxiety.value.length == 20) {
- let list = []
- for (let i = 0; i < scaleList.value.length; i++) {
- if (scaleList.value[i].flag == '20210617000853') {
- list.push(scaleList.value[i])
- }
- }
- let listTm = JSON.parse(JSON.stringify(list))
- subScaleData(listTm, "20210617000853")
- }
- }
-
-
- if (topicIndex.value == scaleList.value.length) {
-
-
- if (scaleList.value[topicIndex.value - 1].flag != '20210617020516' && scaleList.value[topicIndex.value - 1].flag != '20210913093250' && scaleList.value[topicIndex.value - 1].flag != '20210617000853') {
- let listTm = JSON.parse(JSON.stringify(scaleList.value))
- subScaleData(listTm, flag.value)
- }
-
- return
- }
- topicIndex.value++
- }
- const subScaleData = async (data: any, flag: string) => {
- if (isLock.value) {
- return
- }
- isLock.value = true
-
-
-
-
-
-
-
-
-
-
-
- let time = '' + startTime.value
- let params = {
- beginTime: time,
- orgName: userInfo.userInfo.orgName,
- orgNo: userInfo.userInfo.orgNo,
- planId: planId.value,
- planName: planName.value,
- taskFlag: flag,
- taskName: flagName.value,
- testRecord: JSON.stringify(productData(data)),
- type: '0',
- userName: userInfo.userInfo.userName,
- userNo: userInfo.userInfo.userNo,
- }
- const res = await saveScaleApi(params)
-
-
-
- getStartTime()
- isLock.value = false
-
-
- if (flag == '20210617020516' || flag == '20210913093250' || flag == '20210617000853') {
-
- if (topicIndex.value == scaleList.value.length) {
-
-
- ElMessage({
- message: '提交完成',
- type: "success",
- })
- router.push({ name: 'plan' })
- }
- }
- if (flag == '20210617140713') {
- queryNeedScale()
-
- } else if (flag != '20210617020516' && flag != '20210913093250' && flag != '20210617000853') {
-
- ElMessage({
- message: '提交完成',
- type: "success",
- })
- router.push({ name: 'plan' })
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- const sclIsCom = async () => {
- if (userInfo.token) {
- let userNo = ''
-
-
- userNo = userInfo.userInfo.userNo
-
- let res: any = await userPlanApi(userNo)
- for (let i = 0; i < res.data.length; i++) {
- if (res.data[i].id = planId.value) {
- planObj.value = res.data[i]
- }
- }
-
- planObj.value.list = [];
- let params = {
- planId: planObj.value.id,
- userNo: userInfo.userInfo.userNo
- }
-
- let temp: any = await userPlanDetailApi(params)
- planObj.value.list = temp.data
-
-
- for (let i = 0; i < planObj.value.list.length; i++) {
-
- if (planObj.value.list[i].flag == '20210617140713') {
- if (planObj.value.list[i].isCompleted == '1') {
- isComplate.value = '2';
- }
- if (planObj.value.list[i].isCompleted == '0') {
- isComplate.value = '0';
- }
- }
- }
- }
- }
- const queryNeedScale = async () => {
-
-
-
- if (userInfo.token) {
- let userNo = ''
-
-
- userNo = userInfo.userInfo.userNo
-
- let res: any = await userPlanApi(userNo)
-
- for (let i = 0; i < res.data.length; i++) {
- if (res.data[i].id = planId.value) {
- planObj.value = res.data[i]
- }
- }
-
- planObj.value.list = [];
- let params = {
- planId: planObj.value.id,
- userNo: userInfo.userInfo.userNo
- }
-
- let temp: any = await userPlanDetailApi(params)
- planObj.value.list = temp.data
-
-
- let list = []
- for (let i = 0; i < planObj.value.list.length; i++) {
-
- if (planObj.value.list[i].contentType == '0' && planObj.value.list[i].isAvailable == '1' && planObj.value.list[i].isDisplayed == '0') {
-
-
- list.push(planObj.value.list[i])
- }
- }
-
- planObj.value.list = list;
-
-
- let listNeedAll = []
- let listIsComplate = []
- let listNoComplate = []
- for (let i = 0; i < planObj.value.list.length; i++) {
-
-
-
- if (planObj.value.list[i].isCompleted == '1') {
- let res: any = await getScaleApi(planObj.value.list[i].flag)
- listIsComplate.push(...res.data)
- listNeedAll.push(...res.data)
- }
-
- if (planObj.value.list[i].isCompleted == '0') {
- let res: any = await getScaleApi(planObj.value.list[i].flag)
- listNoComplate.push(...res.data)
- listNeedAll.push(...res.data)
- }
-
-
- }
-
- planAllNum.value = listNeedAll.length;
-
- planIsComplateNum.value = listIsComplate.length;
-
- planNoComplateNum.value = listNoComplate.length;
-
- if (planAllNum.value == 0) {
-
- router.push({ name: 'plan' })
- } else {
-
-
- isComplate.value = '2'
- }
-
- topicIndex.value = 1
- scaleList.value = listNoComplate
- for (let i = 0; i < scaleList.value.length; i++) {
- scaleList.value[i].isCheck = ''
- }
- }
- }
- const productData = (data: any) => {
-
-
-
-
- let testRecord = []
- for (let i = 0; i < data.length; i++) {
- for (let k = 0; k < data[i].answerList.length; k++) {
- if (data[i].isCheck === data[i].answerList[k].name) {
-
- testRecord.push(data[i].answerList[k])
- }
- }
- }
- return testRecord
- }
- const lastTopic = () => {
- if (topicIndex.value == 1) {
- ElMessage({
- message: '已经是第一题了',
- type: "warning",
- })
- return
- }
- topicIndex.value--
- }
- const timeNum = ref<number>(0)
- const listTime = ref<any>([])
- const countTime = ref<number>(0)
- const radioFun = () => {
- overTimeFun()
- countTime.value += 1
-
- let currentTime = new Date().getTime();
-
- let difference = currentTime - timeNum.value;
- timeNum.value = currentTime;
- listTime.value.push(difference)
- if (countTime.value == 5) {
-
-
-
-
-
- if (listTime.value.length == 5) {
- let timeTotal = 0
- for (let i = 0; i < listTime.value.length; i++) {
- timeTotal += listTime.value[i]
- }
- if (timeTotal < 1000 * 5) {
-
- cpdmTip.value.open({ type: 1, message: '请认真答题' })
- countTime.value = 0;
- listTime.value = []
- } else {
-
- countTime.value = 0;
- listTime.value = []
- }
- }
- }
- nextTopic()
- }
- const overTime = ref()
- const overTimeFun = () => {
- clearTimeout(overTime.value)
- overTime.value = setTimeout(() => {
-
- cpdmTip.value.open({ type: 2, message: '离开太久了,请尽快做题!' })
- }, 1000 * 300)
-
- }
- onMounted(async () => {
- overTimeFun()
-
-
-
-
-
-
- timeNum.value = new Date().getTime()
- flag.value = route.params.flag as string;
- planId.value = route.params.planId as string
- planName.value = route.params.planName as string
- flagName.value = route.params.flagName as string
- isComplate.value = route.params.isComplate as string
-
-
- if (flag.value == '20210617140713') {
-
- await sclIsCom()
-
- if (isComplate.value == '0') {
- getScaleFun(flag.value)
- } else if (isComplate.value == '2') {
- queryNeedScale();
- }
- } else {
- getScaleFun(flag.value)
- }
- getStartTime()
-
-
- })
- const getStartTime = async () => {
- let res: any = await getCurrentTimeApi();
-
- startTime.value = res.data;
-
- }
- const getScaleFun = async (val: string) => {
- scaleList.value = []
- let res: any = await getScaleApi(val)
- scaleList.value = res.data
- for (let i = 0; i < scaleList.value.length; i++) {
- scaleList.value[i].isCheck = ''
- }
- }
- onUnmounted(() => {
- clearTimeout(overTime.value)
- })
- </script>
- <template>
- <div class="home_header_out">
- <div class=" home_header_inner">
- <CpmdHeader />
- <div class="report_top">
- <div class="report_jt">
- <span v-if="!(flag == '20210617140713' && isComplate == '2')">{{ flagName }}</span>
- <span v-if="flag == '20210617140713' && isComplate == '2'"> 心理健康测评基础量表(附加题)</span>
- <span v-show="!isCompleted" class="des">请根据您的表现回答下列问题,每道题请选择最符合您的情况的选项。</span>
- </div>
- <img v-show="!isCompleted" class="xlts_img" src="../assets/scale/scale.png" />
- </div>
- </div>
- <div class="kply">
- <div class="kply_inner" :style="{ border: isCompleted ? '8px solid #ffffff' : '8px solid #B2F2D2' }">
- <div style="padding :10px 100px">
- <el-progress v-if="!(flag == '20210617140713' && isComplate == '2')" :text-inside="true"
- :stroke-width="20" :percentage="(topicIndex / scaleList.length) * 100" color="#48D68E">
- <span style="color:#000000">{{ topicIndex }}/{{ scaleList.length }}</span>
- </el-progress>
- <el-progress v-if="flag == '20210617140713' && isComplate == '2'" :text-inside="true"
- :stroke-width="20" :percentage="((topicIndex + planIsComplateNum) / planAllNum) * 100"
- color="#48D68E">
- <span style="color:#000000">{{ topicIndex + planIsComplateNum }}/{{ planAllNum }}</span>
- </el-progress>
- <div v-if="scaleList.length > 0">
- <div class="scale_title" v-if="!(flag == '20210617140713' && isComplate == '2')">{{ topicIndex
- }}:{{ scaleList[topicIndex - 1].content }}</div>
- <div class="scale_title" v-if="flag == '20210617140713' && isComplate == '2'">{{ topicIndex +
- planIsComplateNum }}:{{ scaleList[topicIndex - 1].content }}</div>
- <el-radio-group v-model="scaleList[topicIndex - 1].isCheck" class="scale_radio_group">
- <el-radio-button
- v-for="item in scaleList[topicIndex - 1].checkItems.split(';').sort(() => { return Math.random() - 0.5 }) "
- @change="radioFun" :label="item" :value="item" />
- </el-radio-group>
- <div class="scale_button">
- <el-row>
- <el-col :span="12" class="scale_button_inner">
- <div v-show="topicIndex > 1" class="scale_button_self" @click="lastTopic">上一题
- </div>
- </el-col>
- <el-col :span="12" class="scale_button_inner">
- <div v-show="topicIndex < scaleList.length" class="scale_button_self"
- @click="nextTopic">下一题</div>
- <!-- <div v-show="topicIndex == scaleList.length" class="scale_button_self"
- @click="subScaleData">提交</div> -->
- </el-col>
- </el-row>
- </div>
- </div>
- </div>
- </div>
- </div>
- <CpdmTip ref="cpdmTip" />
- </div>
- </template>
- <style scoped>
- :deep(.dig_kg> .el-dialog__header) {
- padding-right: 0px !important;
- }
- </style>
- <style lang="scss" scoped>
- :deep(.el-progress-bar__outer) {
- background-color: #f3f3f3;
- border-radius: 100px;
- height: 6px;
- overflow: hidden;
- position: relative;
- vertical-align: middle;
- }
- :deep(.el-radio-group) {
- align-items: center;
- display: flex;
- flex-wrap: wrap;
- font-size: 0;
- flex-direction: column;
- }
- :deep(.el-radio-button) {
- display: inline-block;
- outline: none;
- position: relative;
- width: 80% !important;
- }
- :deep(.el-radio-button__inner) {
- width: 100%;
- border-radius: 40px !important;
- margin-top: 10px;
- border: 4px solid #B2F2D2;
- border-left: 4px solid #B2F2D2 !important;
- padding: 10px 10px;
- font-size: 14px;
- font-weight: 700;
- text-align: left;
- }
- :deep(.el-radio-button__inner:hover) {
- width: 100%;
- border-radius: 40px !important;
- margin-top: 10px;
- border: 4px solid #B2F2D2;
- border-left: 4px solid #B2F2D2 !important;
- padding: 10px 10px;
- font-size: 14px;
- font-weight: 700;
- text-align: left;
- color: #000000;
- background-color: #48D68E;
- color: #ffffff;
- }
- :deep().el-radio-button.is-active .el-radio-button__original-radio:not(:disabled)+.el-radio-button__inner {
- background-color: #48D68E !important;
- border-color: #B2F2D2 !important;
- box-shadow: 0 0 0 0 var(--el-radio-button-checked-border-color, var(--el-color-primary)) !important;
- color: var(--el-radio-button-checked-text-color, var(--el-color-white));
- }
- .home_header_out {
-
- padding-bottom: 60px;
- width: 100%;
- min-width: 1200px;
- background-image: url('../assets/home/bg_ty.png');
- background-repeat: no-repeat;
- background-size: contain;
- background-color: #B3F1DA; //估计是需要动态
-
- .home_header_inner {
- min-height: 1;
- left: 0;
- right: 0;
- margin: auto;
-
- width: 1200px;
- .report_top {
- width: 860px;
- margin-left: 170px;
- margin-top: 20px;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 0px;
- .xlts_img {
- margin-right: 60px;
- width: 40px;
- height: 30px;
-
- }
- .report_jt {
- display: flex;
- flex-direction: column;
- font-size: 20px;
- font-weight: 700;
- letter-spacing: 3px;
- .des {
- color: #888888;
-
- font-size: 15px;
- letter-spacing: 0px;
- margin-top: 10px;
- }
- }
- }
- }
- .kply {
- width: 100%;
- margin-top: 10px;
- margin-bottom: 9px;
-
-
- .kply_inner {
-
- min-height: 500px;
- left: 0;
- right: 0;
- margin: auto;
- width: 860px;
-
- background-color: #ffffff;
- border-radius: 40px;
- .scale_title {
- margin-top: 20px;
- font-size: 18px;
- letter-spacing: 2px;
- line-height: 20px;
- .scale_radio_group {
- display: flex;
- flex-direction: column;
- }
- }
- .scale_button {
- margin-top: 60px;
- margin-bottom: 20px;
- .scale_button_inner {
- text-align: center;
- display: flex;
- justify-content: center;
- .scale_button_self {
- border-radius: 12px;
- border: 3px solid #48D68E;
- color: #ffffff;
- background-color: #000000;
- margin-right: 20px;
- padding: 10px 40px;
- cursor: pointer;
- display: flex;
- align-items: center;
- font-size: 14px;
- }
- }
- }
- .finish_calss {
- display: flex;
- flex-direction: column;
- .finish_img {
- margin-top: 60px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .finish_font {
- margin-top: 40px;
- font-size: 30px;
- margin-bottom: 100px;
- }
- }
- }
- }
- }
- }
- .home_mid {
-
- width: 1200px;
- left: 0;
- right: 0;
- margin: auto;
- margin-top: 40px;
-
- .kepu_title {
- text-align: center;
- font-size: 50px;
- color: #111111;
- line-height: 95px;
-
-
-
-
- }
- .kepu_title_sub {
- margin-top: 30px;
- text-align: center;
- font-size: 28px;
- color: #48D68E;
- line-height: 26px;
- }
- .man1_group {
- margin-top: 60px;
- height: 100%;
- display: flex;
- .man1 {
- position: relative;
- width: 327px;
-
-
- .man1_img {
- position: absolute;
- bottom: 0;
-
-
- width: 100%;
- left: 100px
- }
- }
- .des {
- border: #48D68E solid 5px;
- border-radius: 40px;
- padding: 20px;
- letter-spacing: 6px;
- flex: 1;
- .des_inner {
- border: 1px dashed #48D68E;
- border-radius: 40px;
- padding-bottom: 40px;
- padding-top: 30px;
- padding-left: 100px;
- padding-right: 20px;
- letter-spacing: 6px;
- font-weight: normal;
- font-size: 24px;
- color: #333333;
- line-height: 40px;
- }
- }
- }
- .man2_group {
- margin-top: 60px;
- height: 100%;
- display: flex;
- .man2 {
- position: relative;
- width: 327px;
-
-
- .man2_img {
- position: absolute;
- bottom: 0;
-
-
- width: 100%;
- left: -100px
- }
- }
- .des2 {
- border: #48D68E solid 5px;
- border-radius: 40px;
- padding: 20px;
- letter-spacing: 6px;
- flex: 1;
- .des2_inner {
- border: 1px dashed #48D68E;
- border-radius: 40px;
- padding-bottom: 40px;
- padding-top: 30px;
- padding-left: 20px;
- padding-right: 100px;
- letter-spacing: 6px;
- font-weight: normal;
- font-size: 24px;
- color: #333333;
- line-height: 40px;
- }
- }
- }
- .get_more {
- text-align: center;
- img {
- width: 300px;
- margin-top: 60px;
- margin-bottom: 60px;
- }
- }
- }
|