|
@@ -1,4 +1,4 @@
|
|
|
-// import { Get } from "../../../../lib/request/method";
|
|
|
|
|
|
|
+
|
|
|
import {
|
|
import {
|
|
|
getQuestionnaireMethod,
|
|
getQuestionnaireMethod,
|
|
|
submitQuestionnaireMethod,
|
|
submitQuestionnaireMethod,
|
|
@@ -21,14 +21,11 @@ export interface Questionnaire {
|
|
|
}
|
|
}
|
|
|
Page({
|
|
Page({
|
|
|
onLoad(options: { id?: string }) {
|
|
onLoad(options: { id?: string }) {
|
|
|
- console.log(options, "options");
|
|
|
|
|
// 如果没有传递 id,使用默认 id 1,或者可以根据实际情况调整
|
|
// 如果没有传递 id,使用默认 id 1,或者可以根据实际情况调整
|
|
|
const questionnaireId = options.id ? Number(options.id) : 1;
|
|
const questionnaireId = options.id ? Number(options.id) : 1;
|
|
|
this.setData({
|
|
this.setData({
|
|
|
"followDetail.id": questionnaireId,
|
|
"followDetail.id": questionnaireId,
|
|
|
});
|
|
});
|
|
|
- console.log(this.data.followDetail.id, "this.data.followDetail.id");
|
|
|
|
|
- console.log(questionnaireId, "questionnaireId");
|
|
|
|
|
if (questionnaireId) {
|
|
if (questionnaireId) {
|
|
|
this.getQuestionnaire(questionnaireId);
|
|
this.getQuestionnaire(questionnaireId);
|
|
|
} else {
|
|
} else {
|
|
@@ -120,7 +117,6 @@ Page({
|
|
|
// });
|
|
// });
|
|
|
// 实际接口调用
|
|
// 实际接口调用
|
|
|
let list = await getQuestionnaireMethod(id);
|
|
let list = await getQuestionnaireMethod(id);
|
|
|
- console.log(list, "list");
|
|
|
|
|
const questionnaireData = list?.data as Questionnaire;
|
|
const questionnaireData = list?.data as Questionnaire;
|
|
|
// 确保 id 字段存在,如果后端没有返回 id,使用传入的 id
|
|
// 确保 id 字段存在,如果后端没有返回 id,使用传入的 id
|
|
|
const finalData = questionnaireData
|
|
const finalData = questionnaireData
|
|
@@ -131,12 +127,10 @@ Page({
|
|
|
followDetail: finalData,
|
|
followDetail: finalData,
|
|
|
showEmpty: JSON.stringify(list?.data) === "{}" ? true : false,
|
|
showEmpty: JSON.stringify(list?.data) === "{}" ? true : false,
|
|
|
});
|
|
});
|
|
|
- console.log(this.data.followDetail, "this.data.followDetail");
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 选择分数(radio-group change 事件)
|
|
// 选择分数(radio-group change 事件)
|
|
|
onScoreChange(e: WechatMiniprogram.CustomEvent) {
|
|
onScoreChange(e: WechatMiniprogram.CustomEvent) {
|
|
|
- console.log(e, "改变分数");
|
|
|
|
|
const { groupIndex, itemIndex } = e.currentTarget.dataset;
|
|
const { groupIndex, itemIndex } = e.currentTarget.dataset;
|
|
|
const score = e.detail.value;
|
|
const score = e.detail.value;
|
|
|
const groups = [...this.data.followDetail.groups];
|
|
const groups = [...this.data.followDetail.groups];
|
|
@@ -160,7 +154,6 @@ Page({
|
|
|
const groups = this.data.followDetail?.groups || [];
|
|
const groups = this.data.followDetail?.groups || [];
|
|
|
// let allAnswered = true;
|
|
// let allAnswered = true;
|
|
|
// let unansweredQuestions: string[] = [];
|
|
// let unansweredQuestions: string[] = [];
|
|
|
- console.log(groups, "groups");
|
|
|
|
|
// for (const group of groups) {
|
|
// for (const group of groups) {
|
|
|
// for (const item of group.items) {
|
|
// for (const item of group.items) {
|
|
|
// if (!item.selectedScore) {
|
|
// if (!item.selectedScore) {
|
|
@@ -178,7 +171,6 @@ Page({
|
|
|
// });
|
|
// });
|
|
|
// return;
|
|
// return;
|
|
|
// }
|
|
// }
|
|
|
- console.log(this.data.followDetail.id, "提交=====");
|
|
|
|
|
// 准备提交数据
|
|
// 准备提交数据
|
|
|
const submitData = {
|
|
const submitData = {
|
|
|
groups: groups.map((group) => ({
|
|
groups: groups.map((group) => ({
|
|
@@ -193,7 +185,6 @@ Page({
|
|
|
suggestion: this.data.suggestion,
|
|
suggestion: this.data.suggestion,
|
|
|
name: this.data.followDetail.name,
|
|
name: this.data.followDetail.name,
|
|
|
};
|
|
};
|
|
|
- console.log(submitData, "提交的数据==submitData");
|
|
|
|
|
this.setData({
|
|
this.setData({
|
|
|
saving: true,
|
|
saving: true,
|
|
|
});
|
|
});
|