init
This commit is contained in:
2025-06-27 17:42:38 +08:00
commit bd6402478b
5317 changed files with 785994 additions and 0 deletions
@@ -0,0 +1,466 @@
<template>
<div class="traceability">
<div class="header">
<div class="header-font">
<span>{{ type.title }}</span>
<span>{{ type.sub }}</span>
</div>
<img :src="headerIcon" />
</div>
<div class="container">
<div class="question-box" v-for="(quesItem, index) in questionList" :key="index">
<div class="question-header">
<div>{{ quesItem.name }}</div>
<div v-if="qustType === '1'" @click="handleLookRes(quesItem)">查看最新检查结果</div>
</div>
<template v-for="(qus, quIndex) in quesItem.question">
<div class="question-title" v-if="qus.isShow" :key="quIndex">
<div class="title">
<span class="tips">*</span>
<div>
<span>{{ quIndex + 1 }}</span>
<span>{{ qus.title }}</span>
</div>
</div>
<template v-if="qus.inputType === 'radio'">
<a-radio-group v-model:value="qus.answer" @change="(e) => changeRadio(index, e, qus.type)">
<a-radio class="radioStyle" v-for="(optionItem, indexItem) in qus.options" :key="indexItem" :value="optionItem.value">
{{ optionItem.name }}</a-radio
>
</a-radio-group>
</template>
<template v-if="qus.inputType === 'text'">
<div class="error-box">
<div class="error-item" v-for="(optionItem, optionIndex) in qus.options" :key="optionIndex">
<van-field class="field-input" v-model="optionItem.remark" :label="optionItem.sizeMsg" />
<van-field class="field-input" v-model="optionItem.position" :label="optionItem.positionMsg" />
<van-icon
v-if="optionIndex !== 0"
class="deleteIcon"
size="26"
name="clear"
color="#666666"
@click="deleteICon(index, optionIndex)"
/>
</div>
</div>
<div class="error-btn" @click="addInfo(index, qus.options, qus.type)">添加斑块信息</div>
</template>
<template v-if="qus.inputType === 'input'">
<van-field type="number" class="field-answer" v-model="qus.answer" />
</template>
</div>
</template>
</div>
</div>
<div class="bottom-btn">
<van-button class="btn" round type="primary" @click="handleSubmit">提交</van-button>
</div>
<van-overlay :show="popupShow">
<div class="dialog">
<img :src="resultIcon" />
<div class="content-overlay">
<div class="popup-title">{{ detailRes?.name }}</div>
<div v-if="detailRes?.conclusion !== ''" class="popup-con">{{ detailRes?.conclusion }}</div>
<div v-else class="no-date">暂无结果</div>
</div>
<van-icon class="closeIcon" name="close" color="#ffffff" size="36" @click="handleClose" />
</div>
</van-overlay>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import headerIcon from '/@/assets/images/traceability/headerImage.png';
import resultIcon from '/@/assets/images/traceability/resultIcon.png';
import { useTypeHeader } from '/@/views/23intervene/ImageTraceability/traceabilityHooks';
import { useRouter, useRoute } from 'vue-router';
import { showToast, showSuccessToast, showFailToast } from 'vant';
import {
getBehaviorSurveyApi,
getEnvironmentSurveyApi,
getSurveyApi,
submitBehaviorSurveyApi,
submitEnvironmentSurveyApi,
submitSurveyApi,
} from '/@/views/23intervene/ImageTraceability/tranceabilityApi';
import { destroyPage } from '/@/hooks/openPage';
import { useLoading } from '/@/utils/compUtils';
const questionList = ref([]);
const submitParams = ref({});
const popupShow = ref(false);
const router = useRouter();
const route = useRoute();
const detailRes = ref({});
const isEdit = ref(''); // 0 新增 1编辑
const qustType = route.query?.traceabType;
const type = useTypeHeader(qustType); // 1 影像溯源、2 行为溯源、 3环境溯源
const { loadingSpinner, loadingClose } = useLoading();
onMounted(() => {
useTypeApi(qustType).getApi();
});
function useTypeApi(type: number) {
const data = {
1: {
getApi: getSurvey,
subApi: subSurvey,
},
2: {
getApi: getBehavior,
subApi: subBehavior,
},
3: {
getApi: getEnvironment,
subApi: subEnvironment,
},
};
return data[type];
}
/**
*
* @param index
* @param val 0 不存在异常、否, 1 存在异常、是
* @param qustType 1 影像溯源、2 行为溯源、3环境溯源
*/
function changeRadio(index: number, val: number, field: string) {
let data = val.target.value;
let qusData = questionList.value;
submitParams.value[field] = data;
if (qustType === '1') {
qusData[index].question[1].isShow = data === 1;
if (data === 0) {
let optionsList = qusData[index].question[1].options;
if (optionsList.length > 1) {
optionsList.splice(1, optionsList.length - 1);
optionsList[0].size = '';
optionsList[0].position = '';
}
}
} else if (qustType === '2') {
let qusList = qusData[index].question;
if (qusList.length > 1) {
qusList.filter((v: any) => {
if (v.inputType === 'input') {
if (v.answer !== '') {
v.answer = '';
}
v.isShow = data === 1;
}
});
}
}
questionList.value = qusData;
}
function addInfo(index: number, data: Array) {
let dataParams = {
remark: '',
position: '',
sizeMsg: data[0].sizeMsg,
positionMsg: data[0].positionMsg,
};
questionList.value[index].question[1].options.push(dataParams);
}
function deleteICon(index: number, optionIndex: number) {
questionList.value[index].question[1].options.splice(optionIndex, 1);
}
function getParams() {
questionList.value.map((quItem: any) => {
quItem.question.map((item: any) => {
if (item.inputType === 'text' && item.isShow) {
submitParams.value[item.type] = item.options;
}
if (['radio', 'input'].includes(item.inputType) && item.isShow) {
submitParams.value[item.type] = item.answer;
}
});
});
return submitParams.value;
}
// 影像
async function getSurvey() {
const { code, result } = await getSurveyApi({});
getResult(code, result);
}
async function subSurvey() {
const { code, result, message } = await submitSurveyApi(getParams());
subResult(code, result, message);
}
// 行为
async function getBehavior() {
const { code, result } = await getBehaviorSurveyApi({});
getResult(code, result);
}
async function subBehavior() {
const { code, result, message } = await submitBehaviorSurveyApi(getParams());
subResult(code, result, message);
}
// 环境
async function getEnvironment() {
const { code, result } = await getEnvironmentSurveyApi({});
getResult(code, result);
}
async function subEnvironment() {
const { code, result, message } = await submitEnvironmentSurveyApi(getParams());
subResult(code, result, message);
}
function getResult(code: number, result: any) {
if (code === 200) {
isEdit.value = result.status;
questionList.value = result.questionList;
}
}
function subResult(code: number, result: any, message: string) {
if (code === 200) {
loadingClose();
showSuccessToast('提交成功');
try {
destroyPage();
} catch {
router.go(-1);
}
} else {
loadingClose();
showFailToast(message);
}
}
async function handleSubmit() {
let vis = true;
questionList.value.map((v: any) => {
v.question.map((qusItem: any) => {
if (qusItem.isShow && ['radio', 'input'].includes(qusItem.inputType)) {
if (qusItem.answer === '') {
vis = false;
showToast('请填写完问卷');
}
}
if (qusItem.isShow && qusItem.inputType === 'text') {
qusItem.options.map((e: any) => {
if (e.position === '' || e.remark === '') {
vis = false;
showToast('请填写异常信息');
}
});
}
});
});
if (vis) {
loadingSpinner();
useTypeApi(qustType).subApi();
}
}
async function handleLookRes(item: any) {
popupShow.value = true;
detailRes.value = item;
}
function handleClose() {
popupShow.value = false;
}
</script>
<style scoped lang="less">
.traceability {
width: 100%;
height: 100vh;
background-color: #f5f7fb;
position: relative;
.header {
z-index: 4;
width: 100%;
height: 140px;
position: relative;
img {
width: 100%;
height: 100%;
}
.header-font {
position: absolute;
left: 7%;
top: 22%;
display: flex;
flex-direction: column;
font-weight: bold;
font-style: italic;
span:nth-child(1) {
font-size: 30px;
color: #ffffff;
}
span:nth-child(2) {
margin-top: -12px;
color: rgba(255, 255, 255, 0.1);
font-size: 22px;
}
}
}
.container {
width: 100%;
height: calc(100vh - 180px);
overflow-y: auto;
position: absolute;
left: 0;
top: 125px;
z-index: 99;
.question-box {
margin-bottom: 18px;
border-radius: 16px;
background-color: #ffffff;
.question-header {
border-top-left-radius: 16px;
border-top-right-radius: 16px;
display: flex;
justify-content: space-between;
height: 43px;
padding: 20px;
background: linear-gradient(180deg, rgba(26, 104, 238, 0.2) 0%, rgba(48, 160, 226, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
> div:nth-child(1) {
font-size: 16px;
color: #333333;
font-weight: bold;
}
> div:nth-child(2) {
color: #1a68ee;
font-size: 14px;
}
}
.question-title {
padding: 20px;
.title {
color: #333b42;
font-weight: bold;
padding-bottom: 20px;
position: relative;
.tips {
color: #ed2a26;
font-size: 18px;
font-weight: bold;
position: absolute;
top: -2px;
left: -10px;
}
}
.radioStyle {
display: block;
height: 40px;
}
.error-item {
position: relative;
margin-top: 12px;
border-radius: 16px;
& > .field-input:nth-child(1) {
border-top-left-radius: 16px;
border-top-right-radius: 16px;
}
& > .field-input:nth-child(2) {
border-bottom-left-radius: 16px;
border-bottom-right-radius: 16px;
}
& > .deleteIcon {
position: absolute;
right: -10px;
top: -10px;
z-index: 9;
}
:deep(.van-field__control:-webkit-autofill) {
background-color: transparent;
padding-left: 10px;
transition: background-color 0s linear 3600s;
}
:deep(.van-field__control) {
padding-left: 10px;
}
:deep(.van-cell) {
background-color: #eff5ff;
line-height: 38px;
}
:deep(.van-field__label) {
font-weight: bold;
}
:deep(.van-cell__value) {
height: 38px;
background-color: #ffffff;
}
}
.error-btn {
text-align: center;
color: #1a68ee;
padding: 20px 0px;
}
.field-answer {
border-bottom: 1px solid #eaecf1;
}
}
}
}
.bottom-btn {
width: 100%;
position: absolute;
left: 0;
bottom: 0;
height: 50px;
background-color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
.btn {
width: 80%;
height: 40px;
line-height: 40px;
background-color: #1a68ee;
border-radius: 16px;
color: #ffffff;
text-align: center;
}
}
:deep(.ant-radio-group) {
width: 100%;
}
:deep(.van-overlay){
z-index: 99;
}
.dialog {
position: absolute;
top: 30%;
left: 11%;
width: 80%;
margin: 0 auto;
img {
position: absolute;
top: -35px;
left: 43%;
width: 15%;
}
.content-overlay {
background-color: #ffffff;
border-radius: 16px;
padding: 40px 20px 20px 20px;
.popup-title {
font-size: 18px;
font-weight: bold;
padding-bottom: 10px;
}
.popup-con {
font-size: 15px;
line-height: 25px;
max-height: 120px;
overflow-y: auto;
text-align: left;
}
.no-date {
text-align: center;
color: #999999;
height: 120px;
line-height: 120px;
}
}
.closeIcon {
position: relative;
left: 45%;
padding-top: 10%;
}
}
}
</style>
@@ -0,0 +1,18 @@
export function useTypeHeader(type: number) {
const data = {
1: {
title: '影像溯源',
sub: 'IMAGE TRACEABILITY',
},
2: {
title: '行为溯源',
sub: 'BEHAVIOR TRACEABILITY',
},
3: {
title: '环境溯源',
sub: 'ENVIRONMENTAL TRACEABILITY',
},
};
// @ts-ignore
return data[type];
}
@@ -0,0 +1,21 @@
import { get, post } from '/@/views/mobile/api/api';
const prefix: string = import.meta.env.VITE_GLOB_APP_PREFIX || '';
// 获取影像溯源
export const getSurveyApi = (params: any) => get(`${prefix}/cancer/api/getImageSurvey`, params);
// 提交影像溯源
export const submitSurveyApi = (params: any) => post(`${prefix}/cancer/api/postImageSurvey`, params);
// 获取行为溯源
export const getBehaviorSurveyApi = (params: any) => get(`${prefix}/cancer/api/getBehaviorSurvey`, params);
// 提交行为溯源
export const submitBehaviorSurveyApi = (params: any) => post(`${prefix}/cancer/api/postBehaviorSurvey`, params);
// 获取环境溯源
export const getEnvironmentSurveyApi = (params: any) => get(`${prefix}/cancer/api/getEnvironmentSurvey`, params);
// 提交环境溯源
export const submitEnvironmentSurveyApi = (params: any) => post(`${prefix}/cancer/api/postEnvironmentSurvey`, params);
@@ -0,0 +1,94 @@
<template>
<div class="vaccines-container">
<div v-for="(qus, qusIndex) in question" :key="qusIndex">
<template v-if="qus.isShow">
<div class="qus-title">
<span v-if="warnType === 0">{{ qus.indexNo }}</span>
<span>{{ qus.question }}</span>
</div>
<template v-if="qus.type === 0">
<van-radio-group v-model="qus.userAnswer" shape="dot" @change="(e) => handleRadios(qusIndex, e)">
<van-radio class="radioStyle" v-for="(opt, optIndex) in qus.optionList" :name="opt.optionCode" :key="optIndex">{{
opt.option
}}</van-radio>
</van-radio-group>
</template>
<template v-if="qus.type === 1">
<div class="time-box" @click="handleTimes(qus, qusIndex)">
<div class="time-answer" v-if="qus.userAnswer !== '' || qus.userAnswer !== null">{{ qus.userAnswer }}</div>
<div class="time-answer" v-else>{{ rangTime?.join('-') }}</div>
<div class="time-pla" v-if="qus.userAnswer === '' || (qus.userAnswer === null && rangTime)">请选择接种时间 </div>
<van-icon class="right-icon" color="#666666" name="arrow" />
</div>
<van-popup v-model:show="show" position="bottom">
<van-date-picker
v-model="rangTime"
title="选择日期"
:min-date="minDate"
:max-date="new Date()"
@cancel="show = false"
@confirm="onConfirmPicker"
/>
</van-popup>
</template>
</template>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, defineProps, defineEmits } from 'vue';
import { useRoute } from 'vue-router';
const props = defineProps({
qusIndex: Number,
question: Object,
});
const route = useRoute();
const warnType = parseInt(route.query.warnType); // 0 疫苗+其他题 、 1 更新疫苗、 2 更新其他题
const emit = defineEmits(['radios', 'picker']);
let show = ref(false);
let rangTime = ref([]);
let vanIndex = ref('');
let vanParmas = ref({});
let minDate = new Date(1990, 0, 1);
function handleRadios(index: number, value: string) {
emit('radios', props.qusIndex, index, value);
}
function onConfirmPicker(e: any) {
rangTime.value = e.selectedValues;
emit('picker', vanParmas.value.questionCode, vanIndex.value, rangTime.value);
show.value = false;
}
function handleTimes(vanData: any, val: number) {
vanIndex.value = val;
vanParmas.value = vanData;
show.value = true;
}
</script>
<style scoped lang="less">
.vaccines-container {
width: 100%;
.qus-title {
padding: 10px 0;
}
.radioStyle {
height: 30px;
}
.time-answer {
padding: 10px 0;
font-size: 15px;
color: #333333;
}
.right-icon {
padding-left: 6px;
}
.time-pla {
color: #666666;
}
.time-box {
display: flex;
align-items: center;
}
}
</style>
@@ -0,0 +1,318 @@
<template>
<div class="warning-container">
<div class="warn-con">
<div class="warn-header" v-if="warnType === 0">
<div class="header-font">
<span>免疫预警</span>
<span>IMMUNE WARNING</span>
</div>
<img :src="headerIcon" />
</div>
<div :class="warnType === 0 ? 'warn-box' : 'vancc-box'">
<div class="vancc-title" v-if="warnType === 1">
<div>疫苗信息</div>
<div>请填写疫苗接种信息评估您的细菌·病毒预警情况</div>
</div>
<div class="ques-item" v-for="(qus, qusIndex) in quesList" :key="qusIndex">
<div :class="warnType === 0 ? '' : 'vancc'" v-if="qus.hasChildren && [0, 1].includes(warnType)">
<div class="qus-title">{{ qus.question }}</div>
<Vaccines
v-if="qus.hasChildren"
:question="qus.childrenQuestions"
:qusIndex="qusIndex"
@radios="changeRadios"
@picker="handlePicker"
/>
</div>
<template v-if="qus.isShow && [0, 2].includes(warnType) && !qus.hasChildren">
<div class="qus-title">{{ qus.indexNo }}{{ qus.question }}</div>
<van-radio-group v-model="qus.userAnswer" shape="dot">
<van-radio class="radioStyle" v-for="(opt, optIndex) in qus.optionList" :name="opt.optionCode" :key="optIndex">{{
opt.option
}}</van-radio>
</van-radio-group>
</template>
</div>
</div>
</div>
<div class="bottom-btn">
<van-button class="btn" round type="primary" @click="handleSubmit">提交</van-button>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { getQuestionList, setQuestion } from '/@/views/23intervene/ImmuneWarning/warningApi.ts';
import Vaccines from '/@/views/23intervene/ImmuneWarning/Vaccines.vue';
import { useRouter, useRoute } from 'vue-router';
import headerIcon from '/@/assets/images/traceability/headerImage.png';
import { showSuccessToast, showFailToast } from 'vant';
import { destroyPage } from '/@/hooks/openPage';
import { useLoading } from '/@/utils/compUtils';
const route = useRoute();
const router = useRouter();
let quesList = ref([]);
const warnType = parseInt(route.query.warnType); // 0 疫苗+其他题 、 1 更新疫苗、 2 更新其他题
const { loadingSpinner, loadingClose } = useLoading();
const subParams = ref({
optionList: [],
submitType: '',
surveyCode: '',
});
interface quesItem {
hasChildren: Boolean;
childrenQuestions: Array;
questionCode: String;
optionList: Array;
isShow: Boolean;
meaning: String;
userAnswer: String;
type: Number;
}
onMounted(() => {
getList();
});
function setListIndex(data: any) {
let indexNo = 0;
const list = data.map((item: any) => {
if (item.hasChildren) {
indexNo = 0;
item.childrenQuestions.map((childrenItem: any) => {
if (childrenItem.isShow) {
indexNo++;
childrenItem['indexNo'] = indexNo;
}
});
} else {
if (item.isShow) {
indexNo++;
item['indexNo'] = indexNo;
}
}
return item;
});
return list;
}
function setShowQuestion(vanList: any) {
vanList.map((data: any) => {
if (data.hasChildren) {
const user_answer = data.childrenQuestions[0].userAnswer;
if (['10', '12', '11'].includes(data.questionCode)) {
data.childrenQuestions.map((item: any) => {
if (user_answer !== null || user_answer !== '') {
if (['10.1', '12.1'].includes(item.questionCode)) {
data.childrenQuestions[1].isShow = user_answer === 'A';
}
if (item.questionCode === '11.1') {
const showNo = [1, 2, 3];
showNo.map((itemNo: number) => {
data.childrenQuestions[itemNo].isShow = user_answer === 'A';
});
}
}
});
}
}
});
return vanList;
}
async function getList() {
const { code, result } = await getQuestionList({});
if (code === 200) {
let data_index = await setShowQuestion(result.questionList);
quesList.value = await setListIndex(data_index);
subParams.value.surveyCode = result.surveyCode;
}
}
/**
*
* @param qusIndex
* @param childIndex 子集下标
* @param value 单选题值
*/
function changeRadios(qusIndex: number, childIndex: number, value: string) {
let new_quesList: quesItem[] = quesList.value;
if (new_quesList[qusIndex].hasChildren) {
let childList = new_quesList[qusIndex].childrenQuestions;
if (['10.1', '12.1'].includes(childList[childIndex].questionCode)) {
if (value === 'B') {
childList[1].userAnswer = '';
}
childList[1].isShow = value === 'A';
}
if (childList[childIndex].questionCode === '11.1') {
const showNo = [1, 2, 3];
showNo.map((itemNo: number) => {
childList[itemNo].isShow = value === 'A';
if (value === 'B') {
childList[itemNo].userAnswer = '';
}
});
}
}
quesList.value = setListIndex(new_quesList);
}
/**
*
* @param questionCode 编号
* @param childIndex 子集下标
* @param value 时间
*/
function handlePicker(questionCode: string, childIndex: number, value: string) {
let new_quesList: quesItem[] = quesList.value;
new_quesList.map((item: any) => {
if (item.hasChildren && item.childrenQuestions !== null) {
const chiCode = item.childrenQuestions[childIndex];
if (chiCode && questionCode === chiCode.questionCode) {
item.childrenQuestions[childIndex].userAnswer = value.join('-');
}
}
});
quesList.value = setListIndex(new_quesList);
}
function getParams() {
let list: quesItem[] = [];
quesList.value.map((item: any) => {
if (item.hasChildren) {
item.childrenQuestions.map((childrenItem: any) => {
if ([0, 1].includes(warnType)) {
list.push(answerSame(childrenItem));
}
});
} else {
if ([0, 2].includes(warnType)) {
list.push(answerSame(item));
}
}
});
subParams.value.optionList = list;
subParams.value.submitType = warnType;
return subParams.value;
}
function answerSame(item: quesItem) {
let paramsItem = {
questionCode: item.questionCode,
userOptionCode: item.userAnswer,
};
if (item.isShow) {
if (item.type === 0) {
let meanFind = item.optionList.find((e: any) => e.optionCode === item.userAnswer);
paramsItem.meaning = meanFind.meaning;
} else {
delete paramsItem.meaning;
}
}
return paramsItem;
}
async function handleSubmit() {
loadingSpinner();
const { code, result, message } = await setQuestion(getParams());
if (code === 200) {
loadingClose();
showSuccessToast('提交成功');
try {
destroyPage();
} catch {
router.go(-1);
}
} else {
loadingClose();
showFailToast(message);
}
}
</script>
<style scoped lang="less">
.warning-container {
background-color: #f5f7fb;
.warn-con {
width: 100%;
.warn-header {
z-index: 4;
width: 100%;
height: 140px;
position: relative;
img {
width: 100%;
height: 100%;
}
.header-font {
position: absolute;
left: 7%;
top: 22%;
display: flex;
flex-direction: column;
font-weight: bold;
font-style: italic;
span:nth-child(1) {
font-size: 30px;
color: #ffffff;
}
span:nth-child(2) {
margin-top: -12px;
color: rgba(255, 255, 255, 0.1);
font-size: 22px;
}
}
}
.warn-box {
height: calc(100vh - 190px);
overflow-y: auto;
padding: 10px 20px;
}
.vancc-box {
background-color: #fff;
border-radius: 16px;
padding: 20px;
height: calc(100vh - 60px);
overflow-y: auto;
.vancc-title {
div:nth-child(1) {
font-weight: bold;
font-size: 16px;
}
div:nth-child(2) {
padding: 4px 0;
color: #999999;
}
}
}
.ques-item {
width: 100%;
.vancc {
padding: 10px 12px;
background-color: #f1f1f1;
border-radius: 16px;
margin-top: 10px;
}
.qus-title {
padding: 10px 0;
font-weight: bold;
}
.radioStyle {
height: 30px;
}
}
}
.bottom-btn {
width: 100%;
height: 50px;
background-color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
.btn {
width: 80%;
height: 40px;
line-height: 40px;
background-color: #1a68ee;
border-radius: 16px;
color: #ffffff;
text-align: center;
}
}
}
</style>
@@ -0,0 +1,7 @@
import { get, post } from '/@/views/mobile/api/api';
const prefix: string = import.meta.env.VITE_GLOB_APP_PREFIX || '';
export const getQuestionList = (params: any) => get(`${prefix}/cancer/immune/survey/info`, params);
export const setQuestion = (params: any) => post(`${prefix}/cancer/immune/survey/submit`, params);
@@ -0,0 +1,3 @@
export function changeRadio(){
}
@@ -0,0 +1,374 @@
<template>
<div class="home-perediction">
<div class="container" v-if="type === 1">
<van-collapse v-model="activeNames" ref="collapse">
<div class="con-box" v-for="(item, index) in tableData" :key="index">
<van-collapse-item>
<template #title>
<div class="header">
<span class="name">{{ item.name }}</span>
<span @click="checkStatus(item.vis, index)">
{{ item.vis ? '收起' : '展开' }}
</span>
</div>
</template>
<a-table
v-if="item.list.length > 0"
:columns="index === 1 ? columns1 : columns"
:data-source="item.list"
:pagination="false"
/>
<Nodata v-else />
</van-collapse-item>
</div>
</van-collapse>
<div class="cancer-box">
<div class="header">
<span class="name">癌症信号预判</span>
<span class="info" @click="goPeredic">修改问卷信息</span>
</div>
<div class="cancer-con" v-if="cancerList.length > 0">
<div
class="cance-width"
v-for="(canItem, canIndex) in cancerList"
:key="canIndex"
:style="{ padding: canIndex % 2 === 0 ? '0 10px 10px 0' : '0 0 10px 0' }"
>
<div :class="['cancer-item', canItem.classBg]">
<div class="icon"></div>
<div class="title">{{ canItem.name }}</div>
<div class="grade" v-if="canItem.grade !== null">{{ canItem.grade }}</div>
<div v-else class="tips">缺少必要指标无法计算</div>
</div>
</div>
<div class="cance-tips">
<span class="con">存在未体检的指标数据如需正常计算相关癌症风险请前往做相关检查 </span>
<span class="tipsLook" @click="handleTips">查看指标</span>
</div>
</div>
<Nodata v-else />
<div v-if="isAbnormal !== ''" class="bottom-btn" @click="handleWarn">干预提示</div>
</div>
</div>
<div class="no-date" v-else>
<img :src="home" />
<div class="tips">请先进行信号预判问卷填写</div>
<div class="bottom-btn" @click="goPeredic">去填写</div>
</div>
<dialog-overlay
:show="dialogCon.show"
:content="dialogCon.con"
:imgUrl="dialogCon.url"
:okText="dialogCon.okText"
:cancelBtn="dialogCon.canBtn"
@ok="handleOk"
>
<template #content>
<div class="overlay-container">
<template v-if="overlayType === '1'">
<div class="title">癌症风险计算所需体检指标</div>
<div class="overlay-con">
<div class="con-item" v-for="(item, index) in overlayList" :key="index"
><span>{{ index + 1 }}</span
><span>{{ item.name }}</span></div
>
</div>
</template>
<template v-if="overlayType === '2'">
<span v-if="isAbnormal === 0" style="color: #52c41a">您的癌症信号正常请继续保持!</span>
<span v-else style="color: #ed2a26">您的癌症信号异常请及时就诊</span>
<!-- {{ // isAbnormal === 0 ? '您的癌症信号正常请继续保持!' : '您的癌症信号异常请及时就诊!' }}-->
</template>
</div>
</template>
</dialog-overlay>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, nextTick } from 'vue';
import home from '/@/assets/images/traceability/homePrediction.png';
import signal from '/@/assets/images/traceability/no-signal.png';
import warnIcon from '/@/assets/images/questions/warn.png';
import dialogOverlay from '/@/views/23-physical-questions/components/dialogOverlay.vue';
import Nodata from '/@/views/23-physical-questions/components/noData.vue';
import { getHomeListApi } from '/@/views/23intervene/signalPrediction/predictionApi.ts';
import { columns, columns1 } from '/@/views/23intervene/signalPrediction/signalHooks.ts';
import { newPageParams, openPage } from '/@/hooks/openPage';
const type = ref(0);
const activeNames = ref(['1']);
const collapse = ref(null);
const tableData = ref([
{
name: '表象信号',
list: [],
vis: true,
},
{
name: '检验信号',
list: [],
vis: true,
},
{
name: '检查信号',
list: [],
vis: true,
},
]);
const overlayType = ref('');
const cancerList = ref([]);
const overlayList = ref([]);
const dialogCon = ref({
show: false,
url: warnIcon,
con: '',
canBtn: false,
okText: '我知道了',
});
const isAbnormal = ref(''); // 0 正常、 1 异常
onMounted(() => {
getList();
});
async function getList() {
const { code, result } = await getHomeListApi({});
if (code === 200) {
if (result.appearanceList !== null && result.checkList !== null) {
type.value = 1;
nextTick(() => {
collapse.value.toggleAll(true);
});
}
tableData.value[0].list = result.appearanceList !== null ? result.appearanceList : [];
tableData.value[1].list = result.inspectionList !== null ? result.inspectionList : [];
tableData.value[2].list = result.checkList !== null ? result.checkList : [];
isAbnormal.value = result.isAbnormal;
if (result.cancerList !== null) {
const barColor = {
1: 'lowBg',
2: 'centerBg',
3: 'highBg',
};
result.cancerList.map((v: any) => {
v['classBg'] = v.code !== null ? barColor[v.code] : '';
});
}
cancerList.value = result.cancerList !== null ? result.cancerList : [];
}
}
function handleWarn() {
dialogCon.value.show = true;
// dialogCon.value.con = isAbnormal.value === 0 ? '您的癌症信号正常请继续保持!' : '您的癌症信号异常请及时就诊!';
overlayType.value = '2';
}
function handleTips() {
dialogCon.value.show = true;
// dialogCon.value.con = '';
overlayType.value = '1';
let data = tableData.value[1].list;
overlayList.value = data.filter((v: any) => {
return v.result === null;
});
}
function goPeredic() {
openPage('/signal-prediction', newPageParams({}));
}
function checkStatus(status: Boolean, index: Number) {
tableData.value[index].vis = !status;
}
function handleOk() {
dialogCon.value.show = false;
}
</script>
<style scoped lang="less">
.home-perediction {
height: 100%;
background-color: #f5f7fb;
overflow-y: auto;
:deep(.ant-table-thead > tr > th) {
background: rgba(26, 104, 238, 0.2);
}
:deep(.ant-table-tbody > tr > td) {
border: 1px solid #f0f0f0;
}
.container {
.con-box {
background-color: #ffffff;
margin-top: 20px;
}
.header {
display: flex;
justify-content: space-between;
.name {
font-weight: bold;
font-size: 16px;
}
.info {
color: #1a68ee;
position: relative;
padding-left: 20px;
&::before {
content: '';
position: absolute;
left: 0;
top: 5px;
width: 12px;
height: 12px;
background: url('/@/assets/images/traceability/edit.png') no-repeat;
background-size: 100% 100%;
}
}
}
.min-height {
max-height: 0;
transition: max-height 0.5s ease-out;
overflow: hidden;
}
.max-height {
transition: max-height 0.5s ease-out;
max-height: 600px;
}
.cancer-box {
margin-top: 20px;
background-color: #ffffff;
padding: 20px;
.cancer-con {
width: 100%;
display: flex;
flex-wrap: wrap;
align-items: center;
padding-top: 20px;
margin-bottom: 20px;
.cance-width {
width: 50%;
.cancer-item {
width: 100%;
height: 110px;
border-radius: 10px;
background: url('/@/assets/images/traceability/defaultBg.png') no-repeat;
background-size: 100% 100%;
position: relative;
.title {
padding: 16px;
font-size: 16px;
color: #333333;
font-weight: bold;
}
.grade {
padding-left: 16px;
}
.tips {
padding: 0 16px;
color: #999999;
}
.icon {
position: absolute;
right: 16px;
top: 16px;
width: 22px;
height: 18px;
}
}
.lowBg {
background: url('/@/assets/images/traceability/lowBg.png') no-repeat;
background-size: 100% 100%;
.grade {
color: #52c41a;
}
}
.centerBg {
background: url('/@/assets/images/traceability/centerBg.png') no-repeat;
background-size: 100% 100%;
.grade {
color: #ff7421;
}
.icon {
background: url('/@/assets/images/traceability/centerIcon.png') no-repeat;
background-size: 100% 100%;
}
}
.highBg {
background: url('/@/assets/images/traceability/highBg.png') no-repeat;
background-size: 100% 100%;
.grade {
color: #ed2a26;
}
.icon {
background: url('/@/assets/images/traceability/highBgIcon.png') no-repeat;
background-size: 100% 100%;
}
}
}
.cance-tips {
padding: 20px 0;
.con {
color: #999999;
}
.tipsLook {
color: #1a68ee;
}
}
}
}
}
.no-date {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 55%;
img {
width: 46%;
}
.tips {
font-size: 16px;
padding: 10px 0 20px 0;
color: #666666;
}
}
.bottom-btn {
width: 28%;
height: 38px;
line-height: 38px;
background-color: #1a68ee;
color: #ffffff;
text-align: center;
border-radius: 30px;
margin: 0 auto;
}
.overlay-container {
.title {
color: #333333;
font-size: 18px;
font-weight: bold;
padding-bottom: 10px;
}
.overlay-con {
max-height: 200px;
overflow-y: auto;
.con-item {
padding: 8px 0;
display: flex;
align-items: center;
span:nth-child(1) {
display: inline-block;
width: 22px;
height: 22px;
line-height: 22px;
text-align: center;
border: 1px solid #bdbdbd;
border-radius: 50%;
font-size: 16px;
color: #b6b6b6;
}
span:nth-child(2) {
padding-left: 10px;
width: 90%;
display: inline-block;
text-decoration: underline 4px rgba(26, 104, 238, 0.4);
}
}
}
}
}
</style>
@@ -0,0 +1,277 @@
<template>
<div class="prediction-container">
<div class="prediction-header">
<div class="header-font">
<span>信号预判</span>
<span>SIGNAL PREDICTION</span>
</div>
<img :src="headerIcon" />
</div>
<div class="prediction-con">
<div class="con-title"></div>
<div class="container">
<div class="question-box" v-for="(quesItem, index) in questionList" :key="index">
<template v-for="(qus, quIndex) in quesItem.question">
<div class="question-title" v-if="qus.isShow" :key="quIndex">
<div class="title">
<span class="tips">*</span>
<div>
<span>{{ qus.index_type }}</span>
<span>{{ qus.title }}</span>
</div>
</div>
<template v-if="qus.inputType === 'radio'">
<a-radio-group v-model:value="qus.answer" @change="(e) => changeRadio(index, e, qus.type, qus.options)">
<a-radio
class="radioStyle"
v-for="(optionItem, indexItem) in qus.options"
:key="indexItem"
:value="optionItem.value"
>
{{ optionItem.name }}</a-radio
>
</a-radio-group>
</template>
<template v-if="qus.inputType === 'input'">
<div class="input-box">
<div class="field-answer">
<van-field type="number" v-model="qus.answer" @blur="changeInpput(qus.answer, index, quIndex)" />
</div>
<div class="input-unit">{{ qus.unit }}</div>
</div>
</template>
</div>
</template>
</div>
</div>
</div>
<div class="bottom-btn">
<van-button class="btn" round type="primary" @click="handleSubmit">提交</van-button>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import headerIcon from '/@/assets/images/traceability/headerImage.png';
import { getSignalApi, postSignalApi } from '/@/views/23intervene/signalPrediction/predictionApi.ts';
import { showFailToast, showSuccessToast, showToast, showLoadingToast } from 'vant';
import { destroyPage } from '/@/hooks/openPage';
import {useLoading} from '/@/utils/compUtils';
import { useRouter } from 'vue-router';
let questionList = ref({});
let submitParams = ref({});
const router = useRouter();
const { loadingSpinner, loadingClose } = useLoading();
getList();
async function getList() {
const { code, result } = await getSignalApi({});
if (code === 200) {
questionList.value = changeIndex(result.questionList);
}
}
/**
* 添加自定义问卷序号
*/
function changeIndex(data: Array) {
let indexInit = 0;
const list = data.map((v: any) => {
v.question.map((item: any) => {
if (item.isShow) {
indexInit++;
item['index_type'] = indexInit;
}
});
return v;
});
return list;
}
/**
* radio 跳题,给提交对象赋值
* @param index
* @param value radio 选中值
* @param field 提交时所需参数
* @param options 选中题的选项
*/
async function changeRadio(index: number, value: number, field: string, options: object) {
let datas = questionList.value;
let radioVal = value.target.value;
let optionItem = options.find((e: { value: any }) => e.value === 1);
if (optionItem.showCode !== '') {
let codeList = optionItem.showCode.split(',');
codeList.map((code: any) => {
datas.map((item: any) => {
if (code == item.questionCode) {
if (item.question[0].answer !== '') {
item.question[0].answer = '';
}
item.question[0].isShow = radioVal === 1;
}
});
});
}
submitParams.value[field] = radioVal;
questionList.value = changeIndex(datas);
}
// 限制input输入负数
function changeInpput(value: string, index: number, qusIndex: number) {
if (Number(value) < 0) {
showToast('不能输入负数');
questionList.value[index].question[qusIndex].answer = '';
}
}
function getParams() {
questionList.value.map((quItem: any) => {
quItem.question.map((item: any) => {
if (['radio', 'input'].includes(item.inputType) && item.isShow) {
submitParams.value[item.type] = item.answer;
}
});
});
return submitParams.value;
}
async function handleSubmit() {
let vis = true;
questionList.value.map((v: any) => {
v.question.map((qusItem: any) => {
if (qusItem.isShow && ['radio', 'input'].includes(qusItem.inputType)) {
if (qusItem.answer === '') {
vis = false;
showToast('请填写完问卷');
}
}
});
});
if (vis) {
loadingSpinner();
const { code, result, message } = await postSignalApi(getParams());
if (code === 200) {
loadingClose();
showSuccessToast('提交成功');
try {
destroyPage();
} catch {
router.go(-1);
}
} else {
loadingClose();
showFailToast(message);
}
}
}
</script>
<style scoped lang="less">
.prediction-container {
width: 100%;
height: 100vh;
background-color: #f5f7fb;
position: relative;
.prediction-header {
z-index: 4;
width: 100%;
height: 140px;
position: relative;
img {
width: 100%;
height: 100%;
}
.header-font {
position: absolute;
left: 7%;
top: 22%;
display: flex;
flex-direction: column;
font-weight: bold;
font-style: italic;
span:nth-child(1) {
font-size: 30px;
color: #ffffff;
}
span:nth-child(2) {
margin-top: -12px;
color: rgba(255, 255, 255, 0.1);
font-size: 22px;
}
}
}
.prediction-con {
width: 100%;
position: absolute;
left: 0;
top: 125px;
z-index: 99;
border-radius: 16px;
background-color: #ffffff;
.con-title {
width: 100%;
height: 34px;
background: linear-gradient(180deg, rgba(26, 104, 238, 0.2) 0%, rgba(48, 160, 226, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
}
.container {
width: 100%;
height: calc(100vh - 220px);
overflow-y: auto;
.question-box {
.question-title {
padding: 10px 20px;
.title {
color: #333b42;
font-weight: bold;
padding-bottom: 10px;
position: relative;
.tips {
color: #ed2a26;
font-size: 18px;
font-weight: bold;
position: absolute;
top: -2px;
left: -10px;
}
}
.radioStyle {
display: block;
height: 32px;
}
.input-box {
display: flex;
align-items: center;
.field-answer {
width: 40%;
}
:deep(.van-cell) {
border: 1px solid #e6e6ea;
border-radius: 4px;
}
.input-unit {
width: 20%;
padding-left: 10px;
color: #333333;
}
}
}
}
}
}
.bottom-btn {
width: 100%;
position: absolute;
left: 0;
bottom: 0;
height: 50px;
background-color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
.btn {
width: 80%;
height: 40px;
line-height: 40px;
background-color: #1a68ee;
border-radius: 16px;
color: #ffffff;
text-align: center;
}
}
}
</style>
@@ -0,0 +1,9 @@
import { get, post } from '/@/views/mobile/api/api';
const prefix: string = import.meta.env.VITE_GLOB_APP_PREFIX || '';
export const getHomeListApi = (params: any) => get(`${prefix}/cancer/signal/app/index`, params);
export const getSignalApi = (params: any) => get(`${prefix}/cancer/signal/app/getSurvey`, params);
export const postSignalApi = (params: any) => post(`${prefix}/cancer/signal/app/postSurvey`, params);
@@ -0,0 +1,70 @@
import { h } from 'vue';
function resColor(data: any) {
let color = '';
if (data.resultText !== null) {
color = data.isError === 1 ? 'red' : '';
}
return h('span', { style: { color } }, data.resultText !== null ? data.resultText : '-');
}
// @ts-ignore
export const columns = [
{
title: '信号名称',
dataIndex: 'name',
width: 110,
},
{
title: '结果',
dataIndex: 'result',
width: 60,
customRender: ({ record }) => {
return resColor(record);
},
},
{
title: '单位',
dataIndex: 'unit',
width: 60,
},
{
title: '更新时间',
dataIndex: 'updateTime',
width: 110,
customRender: ({ record }) => {
return record.updateTime !== null ? record.updateTime : '-';
},
},
];
export const columns1 = [
{
title: '指标名称',
dataIndex: 'name',
width: 80,
},
{
title: '结果',
dataIndex: 'result',
width: 70,
customRender: ({ record }) => {
return resColor(record);
},
},
{
title: '单位',
dataIndex: 'unit',
width: 50,
},
{
title: '参考范围',
dataIndex: 'referenceRange',
width: 80,
},
{
title: '更新时间',
dataIndex: 'updateTime',
width: 110,
customRender: ({ record }) => {
return record.updateTime !== null ? record.updateTime : '-';
},
},
];