熊飞 2024-02-04 18:00:34 +08:00
parent 8a10d5287d
commit ddd7e4638c
4 changed files with 172 additions and 25 deletions

View File

@ -288,7 +288,7 @@
:visit-task-id="visitTaskId"
:criterion-id="criterionId"
:type="addOrEdit.type"
:CalculationList="CalculationList"
:CalculationList="CalculationTabelList"
@formItemTableNumberChange="formItemTableNumberChange"
@setFormItemData="setFormItemData"
@resetFormItemData="resetFormItemData"
@ -368,7 +368,8 @@ export default {
loading: false,
RowIndex: 0,
RowId: null,
digitPlaces: 0
digitPlaces: 0,
CalculationTabelList: []
}
},
watch: {
@ -411,7 +412,7 @@ export default {
}
}
if (this.question.Type === 'table') {
// this.getQuestionCalculateRelation()
this.getQuestionCalculateRelation()
if (this.questionForm[this.question.Id]) {
this.QuestionsForm = {}
this.question.TableQuestions.Questions.forEach(v => {
@ -511,10 +512,9 @@ export default {
},
getQuestionCalculateRelation() {
getQuestionCalculateRelation({
TrialReadingCriterionId: this.criterionId,
ReadingQuestionId: this.question.Id
}).then(res => {
this.CalculationList = res.Result
this.CalculationTabelList = res.Result
})
},
save() {

View File

@ -211,6 +211,12 @@ export default {
type: String,
required: true
},
CalculationList: {
type: Array,
default() {
return []
}
},
readingTaskState: {
type: Number,
required: true
@ -248,15 +254,28 @@ export default {
digitPlaces: 0
}
},
// watch: {
// questionForm: {
// deep: true,
// immediate: true,
// handler(v) {
//
// }
// }
// },
watch: {
questionForm: {
deep: true,
immediate: true,
handler(v) {
handler(v, oldv) {
try {
if (!v[this.question.Id] || !oldv[this.question.Id]) return
} catch (e) {
}
this.formItemNumberChange(this.question.Id, false)
}
},
},
mounted() {
this.digitPlaces = localStorage.getItem('digitPlaces') ? parseInt(localStorage.getItem('digitPlaces')) : 0
if (this.question.Type === 'upload') {
@ -323,8 +342,91 @@ export default {
} else {
}
},
logic(rules, num = 0) {
try {
if (rules.CalculateQuestionList.length === 0) {
return false
}
var count = 0
var maxList = [], minList = []
rules.CalculateQuestionList.forEach((o, i) => {
if (rules.CustomCalculateMark > 4) {
if (i !== 0) {
switch (rules.CustomCalculateMark) {
case 7:
count += parseFloat(this.questionForm[o.TableQuestionId])
if (i === rules.CalculateQuestionList.length - 1) {
num = count / rules.CalculateQuestionList.length
}
break;
case 8:
maxList.push(this.questionForm[o.TableQuestionId])
if (i === rules.CalculateQuestionList.length - 1) {
num = Math.max(...maxList)
}
break;
case 9:
minList.push(this.questionForm[o.TableQuestionId])
if (i === rules.CalculateQuestionList.length - 1) {
num = Math.min(...minList)
}
break;
}
} else {
maxList.push(this.questionForm[o.TableQuestionId])
minList.push(this.questionForm[o.TableQuestionId])
count = parseFloat(this.questionForm[o.TableQuestionId])
num = parseFloat(this.questionForm[o.TableQuestionId])
}
} else {
switch (rules.CustomCalculateMark) {
case 1:
num += parseFloat(this.questionForm[o.TableQuestionId])
break;
case 2:
num -= parseFloat(this.questionForm[o.TableQuestionId])
break;
case 3:
num *= parseFloat(this.questionForm[o.TableQuestionId])
break;
case 4:
if (parseFloat(this.questionForm[o.TableQuestionId]) === 0) {
num = 0
} else {
num /= parseFloat(this.questionForm[o.TableQuestionId])
}
break;
}
}
})
} catch (e) {
console.log(e)
}
var digitPlaces = parseInt(localStorage.getItem('digitPlaces'))
if (rules.ValueType === 2) {
num = num * 100
}
return num.toFixed(digitPlaces)
},
formItemNumberChange(v, question) {
this.$emit('formItemTableNumberChange', v, question)
console.log(this.CalculationList)
this.CalculationList.forEach((v, i) => {
console.log('v', v)
var find = v.CalculateQuestionList.filter(o => {
return o.QuestionId === question.Id
})
console.log('find', find)
// findnumber
if (find) {
var num = this.logic(v)
console.log(num)
if (num !== false) {
this.$set(this.questionForm, v.QuestionId, num)
// this.$emit('setFormItemData', { key: v.QuestionId, val: num })
}
}
})
// this.$emit('formItemTableNumberChange', v, question)
},
resetChild(obj) {
obj.forEach(i => {

View File

@ -447,8 +447,8 @@
</el-select>
</el-form-item>
<el-form-item
v-if="(form.QuestionGenre === 0 || form.QuestionGenre === null) && (form.Type === 'select' || form.Type === 'radio') && isFromSystem"
:label="$t('trials:qcCfg:table:typeValue')"
v-if="(form.Type === 'select' || form.Type === 'radio') && isFromSystem"
:label="$t('trials:readingUnit:qsList:title:defaultValue')"
>
<el-select v-model="form.DefaultValue" clearable>
<el-option
@ -459,6 +459,15 @@
/>
</el-select>
</el-form-item>
<el-form-item
v-if="(form.Type === 'number') && !isFromSystem"
:label="$t('trials:readingUnit:qsList:title:defaultValue')"
>
<el-input
:disabled="form.DataSource === 1"
v-model="form.DefaultValue"
/>
</el-form-item>
<!-- 分组 -->
<el-form-item
v-if="form.Type !== 'group'"

View File

@ -69,6 +69,21 @@
v-model="form.IsCopy"
/>
</el-form-item>
<!-- 问题数据来源 -->
<el-form-item v-if="form.Type === 'number'" :label="$t('trials:readingUnit:qsList:title:dataSource')"
prop="DataSource">
<el-radio-group
v-model="form.DataSource"
>
<el-radio
v-for="item of $d.DataSource"
:key="`DataSource${item.value}`"
:label="item.value"
>
{{ item.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="form.Type === 'number'"
:label="$t('trials:readingUnit:qsList:title:valueType')"
@ -135,14 +150,26 @@
style="line-height: 40px;"
@change="(v) => CustomCalculateMarkChange(v)"
>
<div>
<el-radio
v-for="item of $d.CustomCalculateMark"
v-if="item.value <= 4"
v-show="item.value <= 4"
:key="`CustomCalculateMark${item.value}`"
:label="item.value"
>
{{ item.label }}
</el-radio>
</div>
<div>
<el-radio
v-for="item of $d.CustomCalculateMark"
v-show="item.value > 6"
:key="`CustomCalculateMark${item.value}`"
:label="item.value"
>
{{ item.label }}
</el-radio>
</div>
</el-radio-group>
</el-form-item>
<el-table
@ -174,16 +201,12 @@
min-width="180"
>
<template slot-scope="scope">
<el-select v-if="!scope.row.IsTable" v-model="scope.row.TableQuestionId" clearable>
<el-select v-model="scope.row.TableQuestionId" clearable>
<el-option v-for="item of Questions" :key="item.QuestionId" :label="item.QuestionName" :value="item.QuestionId" />
</el-select>
<el-select v-if="scope.row.IsTable" v-model="scope.row.TableQuestionId" clearable>
<el-option v-for="item of !scope.row.QuestionId ? [] : tableQuestions.find(v => v.QuestionId === scope.row.QuestionId).TableQuestions" :key="item.QuestionId" :label="item.QuestionName" :value="item.QuestionId" />
</el-select>
</template>
</el-table-column>
<el-table-column
v-if="form.CustomCalculateMark <= 4"
:label="$t('common:action:action')"
prop="TableQuestionId"
show-overflow-tooltip
@ -620,7 +643,20 @@ export default {
}
}
}
// for (const k in this.form) {
// if (k === 'CalculateQuestions' && this.data[k] !== undefined) {
// console.log(this.data[k])
// this.form[k] = JSON.parse(this.data[k])
// console.log('CalculateQuestions', this.form[k])
// } else if (k === 'ClassifyAlgorithms' && this.data[k] !== undefined && this.data[k] !== '') {
// this.ClassifyAlgorithmsList = JSON.parse(this.data[k])
// console.log(11111, this.form)
// } else {
// if (this.data.hasOwnProperty(k)) {
// this.form[k] = this.data[k]
// }
// }
// }
if (this.form.ParentId) {
var index = this.parentOptions.findIndex(item => {
return item.QuestionId === this.form.ParentId