分类问题允许关联多个问题

uat_us
caiyiling 2024-10-29 09:40:40 +08:00
parent 7360be1726
commit fb4fc347f3
8 changed files with 211 additions and 108 deletions

View File

@ -487,27 +487,52 @@ export default {
},
setFormTableItemData(obj) {
this.$set(this.QuestionsForm, obj.key, obj.val)
if (this.classArr.length > 0) {
let qs = this.classArr.find(i=>i.triggerId === obj.key)
if (!qs) return
let answer = null
let list = JSON.parse(qs.classifyAlgorithms)
if (qs.classifyType === 0) {
let o = list.find(v => {
return (
parseFloat(obj.val) >= parseFloat(v.gt) &&
parseFloat(obj.val) < parseFloat(v.lt)
)
})
answer = o ? o.label : null
} else if (qs.classifyType === 1) {
let o = list.find(v => {
return v.val.includes(obj.val)
})
answer = o ? o.label : null
this.classArr.map(i=>{
if (i.triggerId === obj.key) {
let answer = null
let list = JSON.parse(i.classifyAlgorithms)
if (i.classifyType === 0) {
let o = list.find(v => {
return (
parseFloat(obj.val) >= parseFloat(v.gt) &&
parseFloat(obj.val) < parseFloat(v.lt)
)
})
answer = o ? o.label : null
} else if (indexedDB.classifyType === 1) {
let o = list.find(v => {
return v.val.includes(obj.val)
})
answer = o ? o.label : null
}
if (answer !== null) {
this.$set(this.QuestionsForm, i.classId, answer)
}
}
this.$set(this.QuestionsForm, qs.classId, answer)
}
})
// if (this.classArr.length > 0) {
// let qs = this.classArr.find(i=>i.triggerId === obj.key)
// if (!qs) return
// let answer = null
// let list = JSON.parse(qs.classifyAlgorithms)
// if (qs.classifyType === 0) {
// let o = list.find(v => {
// return (
// parseFloat(obj.val) >= parseFloat(v.gt) &&
// parseFloat(obj.val) < parseFloat(v.lt)
// )
// })
// answer = o ? o.label : null
// } else if (qs.classifyType === 1) {
// let o = list.find(v => {
// return v.val.includes(obj.val)
// })
// answer = o ? o.label : null
// }
// if (answer !== null) {
// this.$set(this.QuestionsForm, qs.classId, answer)
// }
// }
},
resetTableFormItemData(obj) {
this.$set(this.QuestionsForm, obj.key, null)
@ -581,7 +606,7 @@ export default {
var index = this.AnswersList.findIndex(v => v.RowId === this.QuestionsForm.RowId)
this.AnswersList.splice(index, 1, this.QuestionsForm)
}
this.$emit('setFormItemData', {key: this.question.Id, val: this.AnswersList})
this.$emit('setFormItemData', {key: this.question.Id, val: this.AnswersList, question: this.question})
this.formItemNumberChange(this.question.Id, true)
this.addOrEdit.visible = false
})
@ -703,7 +728,7 @@ export default {
if (find) {
var num = this.logic(v)
if (num !== false) {
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
this.$emit('setFormItemData', { key: v.QuestionId, val: num, question: v })
}
}
})
@ -716,7 +741,7 @@ export default {
if (find) {
var num = this.logic(v)
if (num !== false) {
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
this.$emit('setFormItemData', { key: v.QuestionId, val: num, question: v })
}
}
})
@ -784,7 +809,7 @@ export default {
})
},
formNumberItemChange(v) {
this.$emit('setFormItemData', { key: v.QuestionId, val: num })
this.$emit('setFormItemData', { key: v.QuestionId, val: num, question: v })
},
formItemChange(v, question) {
if (question.Childrens.length > 0) {
@ -799,10 +824,10 @@ export default {
// if (typeof val === 'boolean') {
// // val = String(val)
// }
this.$emit('setFormItemData', { key: qs.Id, val: val })
this.$emit('setFormItemData', { key: qs.Id, val: val, question: qs })
})
} else {
this.$emit('setFormItemData', { key: question.Id, val: v })
this.$emit('setFormItemData', { key: question.Id, val: v, question: question })
}
},
resetChild(obj) {
@ -836,7 +861,7 @@ export default {
this.fileList.push({ name: `${this.$t('trials:emailManageCfg:title:fileName')}${this.fileList.length + 1}`, url: this.$getObjectName(res.url) })
console.log('fileList', this.fileList)
this.urls.push(this.$getObjectName(res.url))
this.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '' })
this.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '', question: this.question })
loading.close()
// uploadReadingAnswerImage(this.$route.query.trialId, this.visitTaskId, formData).then(res => {
// if (res.IsSuccess) {
@ -891,7 +916,7 @@ export default {
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.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '', question: this.question })
}
}
}

View File

@ -290,7 +290,7 @@ export default {
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('|') : '' })
this.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '', question: this.question })
loading.close()
},
handleBeforeUpload(file) {
@ -330,7 +330,7 @@ export default {
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.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '', question: this.question })
}
}
}

View File

@ -359,10 +359,10 @@ export default {
// if (typeof val === 'boolean') {
// // val = String(val)
// }
this.$emit('setFormItemData', { key: qs.Id, val: val })
this.$emit('setFormItemData', { key: qs.Id, val: val, question: qs })
})
} else {
this.$emit('setFormItemData', { key: question.Id, val: v })
this.$emit('setFormItemData', { key: question.Id, val: v, question: question })
}
},
limitInput(value, q) {
@ -515,7 +515,7 @@ export default {
console.log(res)
this.fileList.push({ name: param.file.name, path: this.$getObjectName(res.url), 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('|') : '' })
this.$emit('setFormItemData', { key:this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '', question: this.question })
loading.close()
},
handleBeforeUpload(file) {
@ -555,7 +555,7 @@ export default {
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.$emit('setFormItemData', { key:this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '', question: this.question })
}
}
}

View File

@ -230,28 +230,52 @@ export default {
},
setFormItemData(obj) {
this.$set(this.questionForm, obj.key, JSON.parse(JSON.stringify(obj.val)))
if (this.classArr.length > 0) {
let qs = this.classArr.find(i=>i.triggerId === obj.key)
if (!qs) return
let answer = null
let list = JSON.parse(qs.classifyAlgorithms)
if (qs.classifyType === 0) {
let o = list.find(v => {
return (
parseFloat(obj.val) >= parseFloat(v.gt) &&
parseFloat(obj.val) < parseFloat(v.lt)
)
})
answer = o ? o.label : null
} else if (qs.classifyType === 1) {
let o = list.find(v => {
return v.val.includes(obj.val)
})
answer = o ? o.label.trim() : null
this.classArr.map(i=>{
if (i.triggerId === obj.key) {
let answer = null
let list = JSON.parse(i.classifyAlgorithms)
if (i.classifyType === 0) {
let o = list.find(v => {
return (
parseFloat(obj.val) >= parseFloat(v.gt) &&
parseFloat(obj.val) < parseFloat(v.lt)
)
})
answer = o ? o.label : null
} else if (i.classifyType === 1) {
let o = list.find(v => {
return v.val.includes(obj.val)
})
answer = o ? o.label.trim() : null
}
if (answer !== null) {
this.$set(this.questionForm, i.classId, answer)
}
}
console.log(this.questionForm, qs.classId, answer)
this.$set(this.questionForm, qs.classId, answer)
}
})
// if (this.classArr.length > 0) {
// let qs = this.classArr.find(i=>i.triggerId === obj.key)
// if (!qs) return
// let answer = null
// let list = JSON.parse(qs.classifyAlgorithms)
// if (qs.classifyType === 0) {
// let o = list.find(v => {
// return (
// parseFloat(obj.val) >= parseFloat(v.gt) &&
// parseFloat(obj.val) < parseFloat(v.lt)
// )
// })
// answer = o ? o.label : null
// } else if (qs.classifyType === 1) {
// let o = list.find(v => {
// return v.val.includes(obj.val)
// })
// answer = o ? o.label.trim() : null
// }
// if (answer !== null) {
// this.$set(this.questionForm, qs.classId, answer)
// }
// }
}
}
}

View File

@ -112,8 +112,8 @@
<el-option
v-for="val in scope.row.TypeValue.split('|')"
:key="val"
:label="val"
:value="val"
:label="val.trim()"
:value="val.trim()"
/>
</template>
</el-select>
@ -130,8 +130,8 @@
<el-option
v-for="val in scope.row.TypeValue.split('|')"
:key="val"
:label="val"
:value="val"
:label="val.trim()"
:value="val.trim()"
/>
</template>
</el-select>

View File

@ -506,7 +506,8 @@ export default {
this.$emit("setFormItemData", {
key: this.question.Id,
val: this.QuestionsForm,
type: 'table'
type: 'table',
question: this.question
});
this.question.TableQuestions.Answers.push(this.QuestionsForm)
this.formItemNumberChange(this.question.Id, true);
@ -624,7 +625,7 @@ export default {
if (find) {
var num = this.logic(v);
if (num !== false) {
this.$emit("setFormItemData", { key: v.QuestionId, val: num });
this.$emit("setFormItemData", { key: v.QuestionId, val: num, question: v });
}
}
});
@ -637,7 +638,7 @@ export default {
if (find) {
var num = this.logic(v);
if (num !== false) {
this.$emit("setFormItemData", { key: v.QuestionId, val: num });
this.$emit("setFormItemData", { key: v.QuestionId, val: num, question: v });
}
}
});
@ -723,7 +724,7 @@ export default {
});
},
formNumberItemChange(v) {
this.$emit("setFormItemData", { key: v.QuestionId, val: num });
this.$emit("setFormItemData", { key: v.QuestionId, val: num, question: v });
},
formItemChange(v, question) {
if (question.Childrens.length > 0) {
@ -743,10 +744,10 @@ export default {
// if (typeof val === 'boolean') {
// // val = String(val)
// }
this.$emit("setFormItemData", { key: qs.Id, val: val });
this.$emit("setFormItemData", { key: qs.Id, val: val, question: qs });
});
} else {
this.$emit("setFormItemData", { key: question.Id, val: v })
this.$emit("setFormItemData", { key: question.Id, val: v, question: question })
}
},
resetChild(obj) {
@ -766,27 +767,52 @@ export default {
setTblFormItemData(obj) {
console.log('setTblFormItemData', this.classArr)
this.$set(this.QuestionsForm, obj.key, obj.val)
if (this.classArr.length > 0) {
let qs = this.classArr.find(i=>i.triggerId === obj.key)
if (!qs) return
let answer = null
let list = JSON.parse(qs.classifyAlgorithms)
if (qs.classifyType === 0) {
let o = list.find(v => {
return (
parseFloat(obj.val) >= parseFloat(v.gt) &&
parseFloat(obj.val) < parseFloat(v.lt)
)
})
answer = o ? o.label : null
} else if (qs.classifyType === 1) {
let o = list.find(v => {
return v.val.includes(obj.val)
})
answer = o ? o.label : null
this.classArr.map(i=>{
if (i.triggerId === obj.key) {
let answer = null
let list = JSON.parse(i.classifyAlgorithms)
if (i.classifyType === 0) {
let o = list.find(v => {
return (
parseFloat(obj.val) >= parseFloat(v.gt) &&
parseFloat(obj.val) < parseFloat(v.lt)
)
})
answer = o ? o.label : null
} else if (i.classifyType === 1) {
let o = list.find(v => {
return v.val.includes(obj.val)
})
answer = o ? o.label : null
}
if (answer !== null) {
this.$set(this.QuestionsForm, i.classId, answer)
}
}
this.$set(this.QuestionsForm, qs.classId, answer)
}
})
// if (this.classArr.length > 0) {
// let qs = this.classArr.find(i=>i.triggerId === obj.key)
// if (!qs) return
// let answer = null
// let list = JSON.parse(qs.classifyAlgorithms)
// if (qs.classifyType === 0) {
// let o = list.find(v => {
// return (
// parseFloat(obj.val) >= parseFloat(v.gt) &&
// parseFloat(obj.val) < parseFloat(v.lt)
// )
// })
// answer = o ? o.label : null
// } else if (qs.classifyType === 1) {
// let o = list.find(v => {
// return v.val.includes(obj.val)
// })
// answer = o ? o.label : null
// }
// if (answer !== null) {
// this.$set(this.QuestionsForm, qs.classId, answer)
// }
// }
},
resetTblFormItemData(obj) {
this.$set(this.QuestionsForm, obj.key, null)
@ -813,6 +839,7 @@ export default {
this.$emit("setFormItemData", {
key: this.question.Id,
val: this.urls.length > 0 ? this.urls.join("|") : "",
question: this.question
});
loading.close();
} else {
@ -836,6 +863,7 @@ export default {
this.$emit("setFormItemData", {
key: this.question.Id,
val: this.urls.length > 0 ? this.urls.join("|") : "",
question: this.question
});
loading.close();
}
@ -897,6 +925,7 @@ export default {
this.$emit("setFormItemData", {
key: this.question.Id,
val: this.urls.length > 0 ? this.urls.join("|") : "",
question: this.question
});
},
},

View File

@ -328,10 +328,10 @@ export default {
// if (typeof val === 'boolean') {
// // val = String(val)
// }
this.$emit('setFormItemData', { key: qs.Id, val: val })
this.$emit('setFormItemData', { key: qs.Id, val: val, question: qs })
})
} else {
this.$emit('setFormItemData', { key: question.Id, val: v })
this.$emit('setFormItemData', { key: question.Id, val: v, question: question })
}
},
formItemNumberChange(v, question) {
@ -383,7 +383,7 @@ export default {
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.$emit('setFormItemData', { key: this.question.Id, val: this.urls.length > 0 ? this.urls.join('|') : '', question: this.question })
}
}
}

View File

@ -185,27 +185,52 @@ export default {
this.$set(this.questionForm, obj.key, arr)
} else {
this.$set(this.questionForm, obj.key, JSON.parse(JSON.stringify(obj.val)))
if (this.classArr.length > 0) {
let qs = this.classArr.find(i=>i.triggerId === obj.key)
if (!qs) return
let answer = null
let list = JSON.parse(qs.classifyAlgorithms)
if (qs.classifyType === 0) {
let o = list.find(v => {
return (
parseFloat(obj.val) >= parseFloat(v.gt) &&
parseFloat(obj.val) < parseFloat(v.lt)
)
})
answer = o ? o.label : null
} else if (qs.classifyType === 1) {
let o = list.find(v => {
return v.val.includes(obj.val)
})
answer = o ? o.label : null
this.classArr.map(i=>{
if (i.triggerId === obj.key) {
let answer = null
let list = JSON.parse(i.classifyAlgorithms)
if (i.classifyType === 0) {
let o = list.find(v => {
return (
parseFloat(obj.val) >= parseFloat(v.gt) &&
parseFloat(obj.val) < parseFloat(v.lt)
)
})
answer = o ? o.label : null
} else if (i.classifyType === 1) {
let o = list.find(v => {
return v.val.includes(obj.val)
})
answer = o ? o.label : null
}
if (answer !== null) {
this.$set(this.questionForm, i.classId, answer)
}
}
this.$set(this.questionForm, qs.classId, answer)
}
})
// if (this.classArr.length > 0) {
// let qs = this.classArr.find(i=>i.triggerId === obj.key)
// if (!qs) return
// let answer = null
// let list = JSON.parse(qs.classifyAlgorithms)
// if (qs.classifyType === 0) {
// let o = list.find(v => {
// return (
// parseFloat(obj.val) >= parseFloat(v.gt) &&
// parseFloat(obj.val) < parseFloat(v.lt)
// )
// })
// answer = o ? o.label : null
// } else if (qs.classifyType === 1) {
// let o = list.find(v => {
// return v.val.includes(obj.val)
// })
// answer = o ? o.label : null
// }
// if (answer !== null) {
// this.$set(this.questionForm, qs.classId, answer)
// }
// }
}
}
}