|
@@ -41,7 +41,7 @@ class QuestionnaireService extends CrudService {
|
|
|
|
|
|
// 根据id更新问卷信息
|
|
|
async update({ id }, data) {
|
|
|
- const { name, num, type, question } = data;
|
|
|
+ const { name, num, type, question, status } = data;
|
|
|
const questionnaire = await this.questionnairemodel.findById(id);
|
|
|
if (name) {
|
|
|
questionnaire.name = name;
|
|
@@ -52,6 +52,9 @@ class QuestionnaireService extends CrudService {
|
|
|
if (type) {
|
|
|
questionnaire.type = type;
|
|
|
}
|
|
|
+ if (status) {
|
|
|
+ questionnaire.status = status;
|
|
|
+ }
|
|
|
if (question) {
|
|
|
const quedata = [];
|
|
|
for (const elm of question) {
|
|
@@ -70,10 +73,7 @@ class QuestionnaireService extends CrudService {
|
|
|
// 查询
|
|
|
async query({ skip, limit, ...num }) {
|
|
|
const total = await this.questionnairemodel.count(num);
|
|
|
- const data = await this.questionnairemodel
|
|
|
- .find(num)
|
|
|
- .skip(Number(skip))
|
|
|
- .limit(Number(limit));
|
|
|
+ const data = await this.questionnairemodel.find(num).skip(Number(skip)).limit(Number(limit));
|
|
|
const result = { total, data };
|
|
|
return result;
|
|
|
}
|
|
@@ -87,9 +87,7 @@ class QuestionnaireService extends CrudService {
|
|
|
// 建立任务
|
|
|
async toExport(body) {
|
|
|
const { range, questionnaireid } = body;
|
|
|
- const questionnaire = await this.questionnairemodel.findById(
|
|
|
- questionnaireid
|
|
|
- );
|
|
|
+ const questionnaire = await this.questionnairemodel.findById(questionnaireid);
|
|
|
if (!questionnaire) {
|
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到问卷信息');
|
|
|
}
|
|
@@ -166,12 +164,7 @@ class QuestionnaireService extends CrudService {
|
|
|
}
|
|
|
for (const t of termid) {
|
|
|
queryObject.termid = t;
|
|
|
- let data = await this.toGetData(
|
|
|
- queryObject,
|
|
|
- questionnaireid,
|
|
|
- direction,
|
|
|
- modelList
|
|
|
- );
|
|
|
+ let data = await this.toGetData(queryObject, questionnaireid, direction, modelList);
|
|
|
if (!data) continue;
|
|
|
if (count !== 0 && direction === 'horizontal') data.shift();
|
|
|
if (count !== 0 && direction === 'vertical') {
|
|
@@ -180,10 +173,7 @@ class QuestionnaireService extends CrudService {
|
|
|
return i;
|
|
|
});
|
|
|
}
|
|
|
- const {
|
|
|
- downloadPath,
|
|
|
- fn: newFileName,
|
|
|
- } = await this.ctx.service.util.toAsyncExcel(data, fn, dp, direction);
|
|
|
+ const { downloadPath, fn: newFileName } = await this.ctx.service.util.toAsyncExcel(data, fn, dp, direction);
|
|
|
dp = downloadPath;
|
|
|
fn = newFileName;
|
|
|
count++;
|
|
@@ -236,15 +226,11 @@ class QuestionnaireService extends CrudService {
|
|
|
}
|
|
|
res.push(mid);
|
|
|
}
|
|
|
-
|
|
|
} else if (direction === 'vertical') {
|
|
|
data = this.verticaSetData(studentList, questAnswerList, modelList);
|
|
|
res = data.map(i => Object.values(i));
|
|
|
} else {
|
|
|
- throw new BusinessError(
|
|
|
- ErrorCode.DATA_NOT_EXIST,
|
|
|
- '未找到excel的表头排列方式'
|
|
|
- );
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到excel的表头排列方式');
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
@@ -322,10 +308,7 @@ class QuestionnaireService extends CrudService {
|
|
|
}
|
|
|
const { termnum } = trainPlan;
|
|
|
if (!termnum) {
|
|
|
- throw new BusinessError(
|
|
|
- ErrorCode.DATA_NOT_EXIST,
|
|
|
- '未找到年度计划的期信息'
|
|
|
- );
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到年度计划的期信息');
|
|
|
}
|
|
|
const obj = {};
|
|
|
if (termid) {
|