自动计算平均值问题
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
05cd1c4075
commit
29be0d6035
|
@ -8,24 +8,22 @@
|
|||
</div> -->
|
||||
<div
|
||||
v-if="!!question.GroupName && question.Type === 'group'"
|
||||
style="font-weight: bold;font-size: 16px;margin: 5px 0px;"
|
||||
style="font-weight: bold; font-size: 16px; margin: 5px 0px"
|
||||
>
|
||||
{{ language==='en'?question.GroupEnName:question.GroupName }}
|
||||
{{ language === "en" ? question.GroupEnName : question.GroupName }}
|
||||
</div>
|
||||
<div
|
||||
v-if="question.Type === 'table'"
|
||||
style="font-weight: bold;font-size: 14px;margin: 5px 0px;"
|
||||
style="font-weight: bold; font-size: 14px; margin: 5px 0px"
|
||||
>
|
||||
<div style="display: flex;justify-content: space-between;">
|
||||
<div style="display: flex; justify-content: space-between">
|
||||
<span>{{ question.QuestionName }}</span>
|
||||
<!-- 添加 -->
|
||||
<el-button type="primary" @click="openAddTableCol(question)">
|
||||
{{ $t('trials:readingUnit:qsList:title:add') }}
|
||||
{{ $t("trials:readingUnit:qsList:title:add") }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
:data="questionForm[question.Id]"
|
||||
>
|
||||
<el-table :data="questionForm[question.Id]">
|
||||
<el-table-column
|
||||
v-for="item of question.TableQuestions.Questions"
|
||||
:key="item.Id"
|
||||
|
@ -38,14 +36,37 @@
|
|||
</div>
|
||||
<template v-else>
|
||||
<el-form-item
|
||||
v-if="(question.ShowQuestion===1 && !!~question.ParentTriggerValueList.indexOf(questionForm[question.ParentId].toString())) || question.ShowQuestion===0"
|
||||
v-if="
|
||||
(question.ShowQuestion === 1 &&
|
||||
!!~question.ParentTriggerValueList.indexOf(
|
||||
questionForm[question.ParentId].toString()
|
||||
)) ||
|
||||
question.ShowQuestion === 0
|
||||
"
|
||||
:label="`${question.QuestionName}`"
|
||||
:prop="question.Id"
|
||||
:rules="[
|
||||
{ required: (question.IsRequired === 0 || (question.IsRequired ===1 && question.RelevanceId && (!!~question.RelevanceValueList.indexOf(questionForm[question.RelevanceId].toString())))) && question.Type!=='group' && question.Type!=='summary',
|
||||
message: this.$t('common:ruleMessage:specify'), trigger: ['blur', 'change']},
|
||||
{
|
||||
required:
|
||||
(question.IsRequired === 0 ||
|
||||
(question.IsRequired === 1 &&
|
||||
question.RelevanceId &&
|
||||
!!~question.RelevanceValueList.indexOf(
|
||||
questionForm[question.RelevanceId].toString()
|
||||
))) &&
|
||||
question.Type !== 'group' &&
|
||||
question.Type !== 'summary',
|
||||
message: this.$t('common:ruleMessage:specify'),
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
]"
|
||||
:class="[
|
||||
question.Type === 'group'
|
||||
? 'mb'
|
||||
: question.Type === 'upload'
|
||||
? 'uploadWrapper'
|
||||
: '',
|
||||
]"
|
||||
:class="[question.Type==='group'?'mb':question.Type==='upload'?'uploadWrapper':'']"
|
||||
>
|
||||
<!-- 输入框 -->
|
||||
<el-input
|
||||
|
@ -65,8 +86,16 @@
|
|||
v-if="question.Type === 'select'"
|
||||
v-model="questionForm[question.Id]"
|
||||
clearable
|
||||
:disabled="(question.TableQuestionType === 2 || question.QuestionGenre === 2) && !!question.DictionaryCode"
|
||||
@change="((val)=>{formItemChange(val, question)})"
|
||||
:disabled="
|
||||
(question.TableQuestionType === 2 ||
|
||||
question.QuestionGenre === 2) &&
|
||||
!!question.DictionaryCode
|
||||
"
|
||||
@change="
|
||||
(val) => {
|
||||
formItemChange(val, question);
|
||||
}
|
||||
"
|
||||
>
|
||||
<template v-if="question.TableQuestionType === 1">
|
||||
<el-option
|
||||
|
@ -76,7 +105,11 @@
|
|||
:value="item[question.DataTableColumn]"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="question.TableQuestionType === 3 || question.QuestionGenre === 3">
|
||||
<template
|
||||
v-else-if="
|
||||
question.TableQuestionType === 3 || question.QuestionGenre === 3
|
||||
"
|
||||
>
|
||||
<el-option
|
||||
v-for="item of $d[question.DictionaryCode]"
|
||||
:key="item.id"
|
||||
|
@ -84,7 +117,13 @@
|
|||
:label="item.label"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="(question.TableQuestionType === 2 || question.QuestionGenre === 2) && question.DictionaryCode">
|
||||
<template
|
||||
v-else-if="
|
||||
(question.TableQuestionType === 2 ||
|
||||
question.QuestionGenre === 2) &&
|
||||
question.DictionaryCode
|
||||
"
|
||||
>
|
||||
<el-option
|
||||
v-for="item of $d[question.DictionaryCode]"
|
||||
:key="item.id"
|
||||
|
@ -100,13 +139,16 @@
|
|||
:value="val"
|
||||
/>
|
||||
</template>
|
||||
|
||||
</el-select>
|
||||
<!-- 单选 -->
|
||||
<el-radio-group
|
||||
v-if="question.Type === 'radio'"
|
||||
v-model="questionForm[question.Id]"
|
||||
@change="((val)=>{formItemChange(val, question)})"
|
||||
@change="
|
||||
(val) => {
|
||||
formItemChange(val, question);
|
||||
}
|
||||
"
|
||||
>
|
||||
<template v-if="question.DictionaryCode">
|
||||
<el-radio
|
||||
|
@ -177,7 +219,11 @@
|
|||
v-if="question.Type === 'number' && question.DataSource !== 1"
|
||||
v-model="questionForm[question.Id]"
|
||||
type="number"
|
||||
@change="((val)=>{formItemNumberChange(val, question)})"
|
||||
@change="
|
||||
(val) => {
|
||||
formItemNumberChange(val, question);
|
||||
}
|
||||
"
|
||||
/>
|
||||
<el-input
|
||||
v-if="question.Type === 'number' && question.DataSource === 1"
|
||||
|
@ -205,7 +251,7 @@
|
|||
:src="OSSclientConfig.basePath + file.url"
|
||||
crossOrigin="Anonymous"
|
||||
alt=""
|
||||
>
|
||||
/>
|
||||
<span class="el-upload-list__item-actions">
|
||||
<span
|
||||
class="el-upload-list__item-preview"
|
||||
|
@ -233,15 +279,22 @@
|
|||
<el-image :src="imageUrl" crossOrigin="Anonymous" width="100%">
|
||||
<!-- 加载中 -->
|
||||
<div slot="placeholder" class="image-slot">
|
||||
{{ $t('trials:readingUnit:qsList:message:loading') }}<span class="dot">...</span>
|
||||
{{ $t("trials:readingUnit:qsList:message:loading")
|
||||
}}<span class="dot">...</span>
|
||||
</div>
|
||||
</el-image>
|
||||
</el-dialog>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template v-if="question.Childrens && question.Childrens.length>0 && question.Type !== 'table'">
|
||||
<template
|
||||
v-if="
|
||||
question.Childrens &&
|
||||
question.Childrens.length > 0 &&
|
||||
question.Type !== 'table'
|
||||
"
|
||||
>
|
||||
<QuestionFormItem
|
||||
v-for="(item) in question.Childrens"
|
||||
v-for="item in question.Childrens"
|
||||
:key="item.Id"
|
||||
:question="item"
|
||||
:reading-task-state="readingTaskState"
|
||||
|
@ -264,13 +317,9 @@
|
|||
width="400px"
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="tableQsForm"
|
||||
v-loading="loading"
|
||||
size="small"
|
||||
>
|
||||
<el-form ref="tableQsForm" v-loading="loading" size="small">
|
||||
<QuestionTableFormItem
|
||||
v-for="(item) in QuestionsList"
|
||||
v-for="item in QuestionsList"
|
||||
:key="item.Id"
|
||||
:question="item"
|
||||
:reading-task-state="readingTaskState"
|
||||
|
@ -282,7 +331,10 @@
|
|||
@setFormItemData="setFormItemData"
|
||||
@resetFormItemData="resetFormItemData"
|
||||
/>
|
||||
<div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
|
||||
<div
|
||||
class="base-dialog-footer"
|
||||
style="text-align: right; margin-top: 10px"
|
||||
>
|
||||
<el-form-item>
|
||||
<!-- 取消 -->
|
||||
<el-button
|
||||
|
@ -290,11 +342,11 @@
|
|||
type="primary"
|
||||
@click="addOrEdit.visible = false"
|
||||
>
|
||||
{{ $t('common:button:cancel') }}
|
||||
{{ $t("common:button:cancel") }}
|
||||
</el-button>
|
||||
<!-- 保存 -->
|
||||
<el-button size="small" type="primary" @click="save">
|
||||
{{ $t('common:button:save') }}
|
||||
{{ $t("common:button:save") }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
@ -303,66 +355,73 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { uploadReadingAnswerImage, getTrialOrganList, getCustomTableQuestionPreview, getQuestionCalculateRelation } from '@/api/trials'
|
||||
import QuestionTableFormItem from './QuestionTableFormItem'
|
||||
import { mapGetters } from 'vuex'
|
||||
import {
|
||||
uploadReadingAnswerImage,
|
||||
getTrialOrganList,
|
||||
getCustomTableQuestionPreview,
|
||||
getQuestionCalculateRelation,
|
||||
} from "@/api/trials";
|
||||
import QuestionTableFormItem from "./QuestionTableFormItem";
|
||||
import { mapGetters } from "vuex";
|
||||
export default {
|
||||
name: 'QuestionFormItem',
|
||||
name: "QuestionFormItem",
|
||||
components: { QuestionTableFormItem },
|
||||
props: {
|
||||
questionForm: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
},
|
||||
isSystemCriterion: {
|
||||
type: Boolean,
|
||||
default() { return false }
|
||||
default() {
|
||||
return false;
|
||||
},
|
||||
},
|
||||
question: {
|
||||
type: Object,
|
||||
default() {
|
||||
return []
|
||||
}
|
||||
return [];
|
||||
},
|
||||
},
|
||||
criterionId: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
readingTaskState: {
|
||||
type: Number,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
visitTaskId: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: "",
|
||||
},
|
||||
calculationList: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
}
|
||||
}
|
||||
return [];
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters(['language'])
|
||||
...mapGetters(["language"]),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
addOrEdit: { visible: false, title: '' },
|
||||
addOrEdit: { visible: false, title: "" },
|
||||
fileList: [],
|
||||
accept: '.png,.jpg,.jpeg',
|
||||
accept: ".png,.jpg,.jpeg",
|
||||
imgVisible: false,
|
||||
imageUrl: '',
|
||||
imageUrl: "",
|
||||
urls: [],
|
||||
organList: [],
|
||||
QuestionsList: [],
|
||||
QuestionsForm: {},
|
||||
AnswersList: [],
|
||||
loading: false
|
||||
}
|
||||
loading: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
questionForm: {
|
||||
|
@ -370,50 +429,56 @@ export default {
|
|||
immediate: true,
|
||||
handler(v, oldv) {
|
||||
try {
|
||||
if (!v || !v[this.question.Id] || !oldv || !oldv[this.question.Id]) return
|
||||
if (!v || !v[this.question.Id] || !oldv || !oldv[this.question.Id])
|
||||
return;
|
||||
} catch (e) {
|
||||
console.log(e, v)
|
||||
}
|
||||
this.formItemNumberChange(this.question.Id, false)
|
||||
}
|
||||
console.log(e, v);
|
||||
}
|
||||
this.formItemNumberChange(this.question.Id, false);
|
||||
},
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
if (this.question.Type === 'class') {
|
||||
this.ClassifyAlgorithmsList = JSON.parse(this.question.ClassifyAlgorithms)
|
||||
if (this.question.Type === "class") {
|
||||
this.ClassifyAlgorithmsList = JSON.parse(
|
||||
this.question.ClassifyAlgorithms
|
||||
);
|
||||
}
|
||||
setInterval(() => {
|
||||
if (this.question.Type === 'class') {
|
||||
let o = this.ClassifyAlgorithmsList.find(v => {
|
||||
return this.questionForm[this.question.ClassifyQuestionId] >= v.gt && this.questionForm[this.question.ClassifyQuestionId] < v.lt
|
||||
})
|
||||
if (this.question.Type === "class") {
|
||||
let o = this.ClassifyAlgorithmsList.find((v) => {
|
||||
return (
|
||||
this.questionForm[this.question.ClassifyQuestionId] >= v.gt &&
|
||||
this.questionForm[this.question.ClassifyQuestionId] < v.lt
|
||||
);
|
||||
});
|
||||
if (this.questionForm[this.question.ClassifyQuestionId]) {
|
||||
this.questionForm[this.question.Id] = o ? o.label : null
|
||||
this.questionForm[this.question.Id] = o ? o.label : null;
|
||||
} else {
|
||||
this.questionForm[this.question.Id] = null
|
||||
this.questionForm[this.question.Id] = null;
|
||||
}
|
||||
}
|
||||
}, 300)
|
||||
if (this.question.Type === 'upload') {
|
||||
}, 300);
|
||||
if (this.question.Type === "upload") {
|
||||
if (this.questionForm[this.question.Id]) {
|
||||
this.urls = this.questionForm[this.question.Id].split('|')
|
||||
this.fileList = []
|
||||
this.urls.map(url => {
|
||||
this.fileList.push({ name: '', url: `${url}` })
|
||||
})
|
||||
this.urls = this.questionForm[this.question.Id].split("|");
|
||||
this.fileList = [];
|
||||
this.urls.map((url) => {
|
||||
this.fileList.push({ name: "", url: `${url}` });
|
||||
});
|
||||
}
|
||||
}
|
||||
if (this.question.Type === 'table') {
|
||||
if (this.question.Type === "table") {
|
||||
// this.getQuestionCalculateRelation()
|
||||
if (this.questionForm[this.question.Id]) {
|
||||
this.QuestionsForm = {}
|
||||
this.question.TableQuestions.Questions.forEach(v => {
|
||||
if (v.Type === 'number') {
|
||||
this.$set(this.QuestionsForm, v.Id, 0)
|
||||
this.QuestionsForm = {};
|
||||
this.question.TableQuestions.Questions.forEach((v) => {
|
||||
if (v.Type === "number") {
|
||||
this.$set(this.QuestionsForm, v.Id, 0);
|
||||
} else {
|
||||
this.$set(this.QuestionsForm, v.Id, '')
|
||||
this.$set(this.QuestionsForm, v.Id, "");
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -421,21 +486,24 @@ export default {
|
|||
getQuestionCalculateRelation() {
|
||||
getQuestionCalculateRelation({
|
||||
TrialReadingCriterionId: this.criterionId,
|
||||
ReadingQuestionId: this.question.Id
|
||||
}).then(res => {
|
||||
this.calculationList = res.Result
|
||||
})
|
||||
ReadingQuestionId: this.question.Id,
|
||||
}).then((res) => {
|
||||
this.calculationList = res.Result;
|
||||
});
|
||||
},
|
||||
save() {
|
||||
this.AnswersList.push(this.QuestionsForm)
|
||||
this.$emit('setFormItemData', { key: this.question.Id, val: this.AnswersList })
|
||||
this.formItemNumberChange(this.question.Id, true)
|
||||
this.addOrEdit.visible = false
|
||||
this.AnswersList.push(this.QuestionsForm);
|
||||
this.$emit("setFormItemData", {
|
||||
key: this.question.Id,
|
||||
val: this.AnswersList,
|
||||
});
|
||||
this.formItemNumberChange(this.question.Id, true);
|
||||
this.addOrEdit.visible = false;
|
||||
},
|
||||
logic(rules, num = 0) {
|
||||
try {
|
||||
if (rules.CalculateQuestionList.length === 0) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
rules.CalculateQuestionList.forEach((o, i) => {
|
||||
if (i === 0) {
|
||||
|
@ -444,228 +512,261 @@ export default {
|
|||
case 5:
|
||||
this.questionForm[o.QuestionId].forEach((q, qi) => {
|
||||
if (qi === 0) {
|
||||
num = parseFloat(q[o.TableQuestionId])
|
||||
num = parseFloat(q[o.TableQuestionId]);
|
||||
} else {
|
||||
num *= parseFloat(q[o.TableQuestionId])
|
||||
num *= parseFloat(q[o.TableQuestionId]);
|
||||
}
|
||||
})
|
||||
break
|
||||
});
|
||||
break;
|
||||
case 6:
|
||||
this.questionForm[o.QuestionId].forEach((q, qi) => {
|
||||
if (qi === 0) {
|
||||
num = parseFloat(q[o.TableQuestionId])
|
||||
num = parseFloat(q[o.TableQuestionId]);
|
||||
} else {
|
||||
num += parseFloat(q[o.TableQuestionId])
|
||||
num += parseFloat(q[o.TableQuestionId]);
|
||||
}
|
||||
})
|
||||
break
|
||||
});
|
||||
break;
|
||||
case 7:
|
||||
this.questionForm[o.QuestionId].forEach((q, qi) => {
|
||||
if (qi === 0) {
|
||||
num = parseFloat(q[o.TableQuestionId])
|
||||
num = parseFloat(q[o.TableQuestionId]);
|
||||
} else {
|
||||
num += parseFloat(q[o.TableQuestionId])
|
||||
num += parseFloat(q[o.TableQuestionId]);
|
||||
}
|
||||
})
|
||||
num = this.questionForm[o.QuestionId].length === 0 ? 0 : num / this.questionForm[o.QuestionId].length
|
||||
break
|
||||
});
|
||||
num =
|
||||
this.questionForm[o.QuestionId].length === 0
|
||||
? 0
|
||||
: num / this.questionForm[o.QuestionId].length;
|
||||
break;
|
||||
case 8:
|
||||
var arr = []
|
||||
this.questionForm[o.QuestionId].forEach(q => {
|
||||
arr.push(q[o.TableQuestionId])
|
||||
})
|
||||
num = arr.length === 0 ? 0 : Math.max(...arr)
|
||||
break
|
||||
var arr = [];
|
||||
this.questionForm[o.QuestionId].forEach((q) => {
|
||||
arr.push(q[o.TableQuestionId]);
|
||||
});
|
||||
num = arr.length === 0 ? 0 : Math.max(...arr);
|
||||
break;
|
||||
case 9:
|
||||
var arr = []
|
||||
this.questionForm[o.QuestionId].forEach(q => {
|
||||
arr.push(q[o.TableQuestionId])
|
||||
})
|
||||
num = arr.length === 0 ? 0 : Math.min(...arr)
|
||||
console.log('min', this.questionForm[o.QuestionId], arr, num)
|
||||
break
|
||||
var arr = [];
|
||||
this.questionForm[o.QuestionId].forEach((q) => {
|
||||
arr.push(q[o.TableQuestionId]);
|
||||
});
|
||||
num = arr.length === 0 ? 0 : Math.min(...arr);
|
||||
console.log("min", this.questionForm[o.QuestionId], arr, num);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
num = parseFloat(this.questionForm[o.TableQuestionId])
|
||||
num = parseFloat(this.questionForm[o.TableQuestionId]);
|
||||
}
|
||||
} else {
|
||||
switch (rules.CustomCalculateMark) {
|
||||
case 1:
|
||||
num += parseFloat(this.questionForm[o.TableQuestionId])
|
||||
break
|
||||
num += parseFloat(this.questionForm[o.TableQuestionId]);
|
||||
break;
|
||||
case 2:
|
||||
num -= parseFloat(this.questionForm[o.TableQuestionId])
|
||||
break
|
||||
num -= parseFloat(this.questionForm[o.TableQuestionId]);
|
||||
break;
|
||||
case 3:
|
||||
num *= parseFloat(this.questionForm[o.TableQuestionId])
|
||||
break
|
||||
num *= parseFloat(this.questionForm[o.TableQuestionId]);
|
||||
break;
|
||||
case 4:
|
||||
num /= parseFloat(this.questionForm[o.TableQuestionId])
|
||||
break
|
||||
num /= parseFloat(this.questionForm[o.TableQuestionId]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.log(e);
|
||||
}
|
||||
return num
|
||||
return num;
|
||||
},
|
||||
formItemNumberChange(questionId, isTable) {
|
||||
if (isTable) {
|
||||
this.calculationList.forEach((v, i) => {
|
||||
var find = v.CalculateQuestionList.filter(o => {
|
||||
return o.QuestionId === questionId
|
||||
})
|
||||
var find = v.CalculateQuestionList.filter((o) => {
|
||||
return o.QuestionId === questionId;
|
||||
});
|
||||
// find的自动计算值number
|
||||
console.log('find', find)
|
||||
console.log("find", find);
|
||||
if (find) {
|
||||
var num = this.logic(v)
|
||||
var num = this.logic(v);
|
||||
if (num !== false) {
|
||||
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
|
||||
this.$emit("setFormItemData", { key: v.QuestionId, val: num });
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
this.calculationList.forEach(v => {
|
||||
var find = v.CalculateQuestionList.filter(o => {
|
||||
return o.TableQuestionId === questionId
|
||||
})
|
||||
this.calculationList.forEach((v) => {
|
||||
var find = v.CalculateQuestionList.filter((o) => {
|
||||
return o.TableQuestionId === questionId;
|
||||
});
|
||||
// find的自动计算值number
|
||||
if (find) {
|
||||
var num = this.logic(v)
|
||||
var num = this.logic(v);
|
||||
if (num !== false) {
|
||||
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
|
||||
this.$emit("setFormItemData", { key: v.QuestionId, val: num });
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
// this.$emit('formItemNumberChange')
|
||||
},
|
||||
formItemTableNumberChange() {
|
||||
this.question.TableQuestions.Questions.forEach(v => {
|
||||
if (v.Type === 'number' && v.DataSource === 1) {
|
||||
var CalculateQuestions = JSON.parse(v.CalculateQuestions)
|
||||
var num,arr=[]
|
||||
console.log(this.question.TableQuestions.Questions);
|
||||
this.question.TableQuestions.Questions.forEach((v) => {
|
||||
if (v.Type === "number" && v.DataSource === 1) {
|
||||
var CalculateQuestions = JSON.parse(v.CalculateQuestions);
|
||||
var num,
|
||||
arr = [];
|
||||
CalculateQuestions.forEach((o, i) => {
|
||||
if (i === 0) {
|
||||
num = parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||
num = parseFloat(this.QuestionsForm[o.TableQuestionId]);
|
||||
arr = [num];
|
||||
} else {
|
||||
switch (v.CustomCalculateMark) {
|
||||
case 1:
|
||||
num += parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||
break
|
||||
num += parseFloat(this.QuestionsForm[o.TableQuestionId]);
|
||||
break;
|
||||
case 2:
|
||||
num -= parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||
break
|
||||
num -= parseFloat(this.QuestionsForm[o.TableQuestionId]);
|
||||
break;
|
||||
case 3:
|
||||
num *= parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||
break
|
||||
num *= parseFloat(this.QuestionsForm[o.TableQuestionId]);
|
||||
break;
|
||||
case 4:
|
||||
num /= parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||
break
|
||||
num /= parseFloat(this.QuestionsForm[o.TableQuestionId]);
|
||||
break;
|
||||
case 7:
|
||||
arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId]))
|
||||
num += parseFloat(this.QuestionsForm[o.TableQuestionId])
|
||||
num = arr.length === 0 ? 0 : num / arr.length
|
||||
break
|
||||
arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId]));
|
||||
num =
|
||||
arr.length === 0
|
||||
? 0
|
||||
: arr.reduce((acc, curr) => {
|
||||
return acc + (typeof curr === "number" ? curr : 0);
|
||||
}, 0) / arr.length;
|
||||
break;
|
||||
case 8:
|
||||
arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId]))
|
||||
num = arr.length === 0 ? 0 : Math.max(...arr)
|
||||
break
|
||||
arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId]));
|
||||
num = arr.length === 0 ? 0 : Math.max(...arr);
|
||||
break;
|
||||
case 9:
|
||||
arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId]))
|
||||
num = arr.length === 0 ? 0 : Math.min(...arr)
|
||||
arr.push(parseFloat(this.QuestionsForm[o.TableQuestionId]));
|
||||
num = arr.length === 0 ? 0 : Math.min(...arr);
|
||||
// console.log('min', this.questionForm[o.QuestionId], arr, num)
|
||||
break
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
this.$set(this.QuestionsForm, v.Id, num.toString())
|
||||
});
|
||||
this.$set(this.QuestionsForm, v.Id, num.toString());
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
openAddTableCol(row) {
|
||||
this.addOrEdit.visible = true
|
||||
this.addOrEdit.title = row.QuestionName + this.$t('trials:readingUnit:qsList:title:tableQs')// '表格问题'
|
||||
this.QuestionsList = row.TableQuestions.Questions
|
||||
this.AnswersList = row.TableQuestions.Answers
|
||||
this.QuestionsForm = {}
|
||||
this.addOrEdit.visible = true;
|
||||
this.addOrEdit.title =
|
||||
row.QuestionName + this.$t("trials:readingUnit:qsList:title:tableQs"); // '表格问题'
|
||||
this.QuestionsList = row.TableQuestions.Questions;
|
||||
this.AnswersList = row.TableQuestions.Answers;
|
||||
this.QuestionsForm = {};
|
||||
},
|
||||
getOrganInfoList() {
|
||||
var param = {
|
||||
trialId: this.$route.query.trialId,
|
||||
lesionType: this.question.LesionType,
|
||||
// systemCriterionId: this.criterionId,
|
||||
isEnable: true
|
||||
}
|
||||
getTrialOrganList(param).then(res => {
|
||||
this.organList = res.Result
|
||||
})
|
||||
isEnable: true,
|
||||
};
|
||||
getTrialOrganList(param).then((res) => {
|
||||
this.organList = res.Result;
|
||||
});
|
||||
},
|
||||
formNumberItemChange(v) {
|
||||
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
|
||||
this.$emit("setFormItemData", { key: v.QuestionId, val: num });
|
||||
},
|
||||
formItemChange(v, question) {
|
||||
if (question.Childrens.length > 0) {
|
||||
this.resetChild(question.Childrens)
|
||||
this.resetChild(question.Childrens);
|
||||
}
|
||||
if (question.TableQuestionType === 1 && question.RelationQuestions.length > 0) {
|
||||
var index = this.organList.findIndex(item => item[question.DataTableColumn] === v)
|
||||
if (index < 0) return
|
||||
var selected = this.organList[index]
|
||||
this.question.RelationQuestions.map(qs => {
|
||||
var val = selected[qs.DataTableColumn]
|
||||
if (
|
||||
question.TableQuestionType === 1 &&
|
||||
question.RelationQuestions.length > 0
|
||||
) {
|
||||
var index = this.organList.findIndex(
|
||||
(item) => item[question.DataTableColumn] === v
|
||||
);
|
||||
if (index < 0) return;
|
||||
var selected = this.organList[index];
|
||||
this.question.RelationQuestions.map((qs) => {
|
||||
var val = selected[qs.DataTableColumn];
|
||||
// if (typeof val === 'boolean') {
|
||||
// // val = String(val)
|
||||
// }
|
||||
this.$emit('setFormItemData', { key: qs.Id, val: val })
|
||||
})
|
||||
this.$emit("setFormItemData", { key: qs.Id, val: val });
|
||||
});
|
||||
}
|
||||
},
|
||||
resetChild(obj) {
|
||||
obj.forEach(i => {
|
||||
this.$emit('resetFormItemData', i.Id)
|
||||
obj.forEach((i) => {
|
||||
this.$emit("resetFormItemData", i.Id);
|
||||
if (i.Childrens && i.Childrens.length > 0) {
|
||||
this.resetChild(i.Childrens)
|
||||
this.resetChild(i.Childrens);
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
resetFormItemData(v) {
|
||||
this.$emit('resetFormItemData', v)
|
||||
this.$emit("resetFormItemData", v);
|
||||
},
|
||||
setFormItemData(obj) {
|
||||
this.$emit('setFormItemData', obj)
|
||||
this.$emit("setFormItemData", obj);
|
||||
},
|
||||
async uploadScreenshot(param) {
|
||||
if (!this.visitTaskId) {
|
||||
const loading = this.$loading({
|
||||
target: document.querySelector('.ecrf-wrapper'),
|
||||
target: document.querySelector(".ecrf-wrapper"),
|
||||
fullscreen: false,
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading'
|
||||
})
|
||||
var file = await this.fileToBlob(param.file)
|
||||
const res = await this.OSSclient.put(`/${this.trialId}/ReadAttachment/preview/${param.file.name}`, file)
|
||||
this.fileList.push({ name: param.file.name, url: this.$getObjectName(res.url) })
|
||||
this.urls.push(this.$getObjectName(res.url))
|
||||
this.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '' })
|
||||
loading.close()
|
||||
text: "Loading",
|
||||
spinner: "el-icon-loading",
|
||||
});
|
||||
var file = await this.fileToBlob(param.file);
|
||||
const res = await this.OSSclient.put(
|
||||
`/${this.trialId}/ReadAttachment/preview/${param.file.name}`,
|
||||
file
|
||||
);
|
||||
this.fileList.push({
|
||||
name: param.file.name,
|
||||
url: this.$getObjectName(res.url),
|
||||
});
|
||||
this.urls.push(this.$getObjectName(res.url));
|
||||
this.$emit("setFormItemData", {
|
||||
key: this.question.Id,
|
||||
val: this.urls.length > 0 ? this.urls.join("|") : "",
|
||||
});
|
||||
loading.close();
|
||||
} else {
|
||||
const loading = this.$loading({
|
||||
target: document.querySelector('.ecrf-wrapper'),
|
||||
target: document.querySelector(".ecrf-wrapper"),
|
||||
fullscreen: false,
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading'
|
||||
})
|
||||
var file = await this.fileToBlob(param.file)
|
||||
const res = await this.OSSclient.put(`/${this.trialId}/ReadAttachment/${this.subjectId}/${this.visitTaskId}/${param.file.name}`, file)
|
||||
this.fileList.push({ name: param.file.name, url: this.$getObjectName(res.url) })
|
||||
this.urls.push(this.$getObjectName(res.url))
|
||||
this.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '' })
|
||||
loading.close()
|
||||
text: "Loading",
|
||||
spinner: "el-icon-loading",
|
||||
});
|
||||
var file = await this.fileToBlob(param.file);
|
||||
const res = await this.OSSclient.put(
|
||||
`/${this.trialId}/ReadAttachment/${this.subjectId}/${this.visitTaskId}/${param.file.name}`,
|
||||
file
|
||||
);
|
||||
this.fileList.push({
|
||||
name: param.file.name,
|
||||
url: this.$getObjectName(res.url),
|
||||
});
|
||||
this.urls.push(this.$getObjectName(res.url));
|
||||
this.$emit("setFormItemData", {
|
||||
key: this.question.Id,
|
||||
val: this.urls.length > 0 ? this.urls.join("|") : "",
|
||||
});
|
||||
loading.close();
|
||||
}
|
||||
// uploadReadingAnswerImage(this.$route.query.trialId, this.visitTaskId, formData).then(res => {
|
||||
// if (res.IsSuccess) {
|
||||
|
@ -682,20 +783,25 @@ export default {
|
|||
// 检测文件类型是否符合要求
|
||||
if (this.checkFileSuffix(file.name)) {
|
||||
// this.fileList = []
|
||||
return true
|
||||
return true;
|
||||
} else {
|
||||
var msg = this.$t('trials:readingUnit:qsList:message:imageFormat').replace('xxx', this.accept)
|
||||
this.$alert(msg)
|
||||
return false
|
||||
var msg = this.$t(
|
||||
"trials:readingUnit:qsList:message:imageFormat"
|
||||
).replace("xxx", this.accept);
|
||||
this.$alert(msg);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
checkFileSuffix(fileName) {
|
||||
var index = fileName.lastIndexOf('.')
|
||||
var suffix = fileName.substring(index + 1, fileName.length)
|
||||
if (this.accept.toLocaleLowerCase().search(suffix.toLocaleLowerCase()) === -1) {
|
||||
return false
|
||||
var index = fileName.lastIndexOf(".");
|
||||
var suffix = fileName.substring(index + 1, fileName.length);
|
||||
if (
|
||||
this.accept.toLocaleLowerCase().search(suffix.toLocaleLowerCase()) ===
|
||||
-1
|
||||
) {
|
||||
return false;
|
||||
} else {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
},
|
||||
autoCalculation() {
|
||||
|
@ -703,18 +809,27 @@ export default {
|
|||
},
|
||||
// 预览图片
|
||||
handlePictureCardPreview(file) {
|
||||
this.imageUrl = this.OSSclientConfig.basePath + file.url
|
||||
this.imgVisible = true
|
||||
this.imageUrl = this.OSSclientConfig.basePath + file.url;
|
||||
this.imgVisible = true;
|
||||
},
|
||||
// 删除图片
|
||||
handleRemove(file, fileList) {
|
||||
this.imageUrl = ''
|
||||
this.fileList.splice(this.fileList.findIndex(f => f.url === file.url), 1)
|
||||
this.urls.splice(this.fileList.findIndex(f => f === file.url), 1)
|
||||
this.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '' })
|
||||
}
|
||||
}
|
||||
}
|
||||
this.imageUrl = "";
|
||||
this.fileList.splice(
|
||||
this.fileList.findIndex((f) => f.url === file.url),
|
||||
1
|
||||
);
|
||||
this.urls.splice(
|
||||
this.fileList.findIndex((f) => f === file.url),
|
||||
1
|
||||
);
|
||||
this.$emit("setFormItemData", {
|
||||
key: this.question.Id,
|
||||
val: this.urls.length > 0 ? this.urls.join("|") : "",
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.my_dialog {
|
||||
|
|
Loading…
Reference in New Issue