|
@@ -72,7 +72,7 @@
|
|
|
<div class="qn-box-header">
|
|
|
<span>{{ $t('survey.surveyResult') }}</span>
|
|
|
<div class="qn-box-header-tools" v-show="!isEmptyData">
|
|
|
- <div class="qn-box-header-tools-tool" style="margin-right: 25px" v-show="currentQn.progress !== 'finish' && editable">
|
|
|
+ <div class="qn-box-header-tools-tool" style="margin-right: 10px" v-show="currentQn.progress !== 'finish' && editable">
|
|
|
<Icon type="md-list-box" color="#dcdcdc" />
|
|
|
<Dropdown @on-click="onAddItem">
|
|
|
<Button>
|
|
@@ -83,6 +83,7 @@
|
|
|
<DropdownItem name="single">{{ $t('survey.single') }}</DropdownItem>
|
|
|
<DropdownItem name="multiple">{{ $t('survey.multiple') }}</DropdownItem>
|
|
|
<DropdownItem name="judge">{{ $t('survey.judge') }}</DropdownItem>
|
|
|
+ <DropdownItem name="subjective">{{ $t('survey.subjective') }}</DropdownItem>
|
|
|
</DropdownMenu>
|
|
|
</Dropdown>
|
|
|
</div>
|
|
@@ -94,11 +95,11 @@
|
|
|
<Icon type="md-create" color="#209460" />
|
|
|
<span>{{ $t('survey.edit') }}</span>
|
|
|
</div>
|
|
|
-
|
|
|
- <div class="qn-box-header-tools-tool" v-show="editable" style="margin-right: 20px">
|
|
|
+
|
|
|
+ <div class="qn-box-header-tools-tool" v-show="editable" style="margin-right: 10px">
|
|
|
<Button class="btn-save" icon="md-folder" :loading="isBtnLoading" @click="onSaveQn">{{ $t('survey.save') }}</Button>
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
<div class="qn-box-header-tools-tool" @click="onCancelEditQn" v-show="editable">
|
|
|
<Icon type="md-create" color="#209460" />
|
|
|
<span>{{ $t('survey.cancelEdit') }}</span>
|
|
@@ -119,6 +120,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+ import blobTool from "@/utils/blobTool.js";
|
|
|
import BaseQuestionnaire from "@/components/questionnaire/BaseQuestionnaire.vue";
|
|
|
import BaseQnForm from "@/components/questionnaire/BaseQnForm.vue";
|
|
|
export default {
|
|
@@ -153,7 +155,9 @@
|
|
|
// 校本课纲与个人课纲切换
|
|
|
handleTabClick(index) {
|
|
|
this.tabIndex = index;
|
|
|
- this.getQnList(index === 0 ? "school" : "private");
|
|
|
+ setTimeout(() => {
|
|
|
+ this.getQnList(index === 0 ? "school" : "private");
|
|
|
+ }, 500)
|
|
|
},
|
|
|
|
|
|
/** 新增问卷 */
|
|
@@ -164,13 +168,14 @@
|
|
|
} else {
|
|
|
let defaultQn = {
|
|
|
name: this.$t('survey.defaultName'),
|
|
|
- targetClassIds: [],
|
|
|
+ classes: [],
|
|
|
endTime: "",
|
|
|
startTime: "",
|
|
|
description: "",
|
|
|
rangeTime: [],
|
|
|
isReset: [],
|
|
|
progress: "pending",
|
|
|
+ questionUrl: [],
|
|
|
other: [],
|
|
|
};
|
|
|
|
|
@@ -183,42 +188,7 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- /** 删除当前问卷 */
|
|
|
- onDeleteQn() {
|
|
|
- this.$Modal.confirm({
|
|
|
- title: this.$t('survey.deletesurvey'),
|
|
|
- content: this.$t('survey.deleteConfirmTip'),
|
|
|
- onOk: () => {
|
|
|
- this.isLoading = true;
|
|
|
|
|
|
- if (this.currentQn.id) {
|
|
|
- this.$api.questionnaire
|
|
|
- .DeleteSurvey({
|
|
|
- id: this.currentQn.id,
|
|
|
- code: this.currentQn.code,
|
|
|
- scope: this.getCurScope,
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (!res.error) {
|
|
|
- this.isLoading = false;
|
|
|
- this.$Message.success(this.$t('survey.deleteSuc'));
|
|
|
- this.handleTabClick(
|
|
|
- this.$route.name === "manageQuestionnaire" ? 0 : 1
|
|
|
- );
|
|
|
- } else {
|
|
|
- this.isLoading = false;
|
|
|
- this.$Message.error(this.$t('survey.deleteFail'));
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.qnList.splice(this.qnList.indexOf(this.currentQn), 1);
|
|
|
- this.isLoading = false;
|
|
|
- this.$Message.success(this.$t('survey.deleteSuc'));
|
|
|
- if (this.qnList.length) this.onQnClick(this.qnList[0], 0);
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
|
|
|
/** 获取问卷列表 */
|
|
|
getQnList(type) {
|
|
@@ -227,7 +197,7 @@
|
|
|
code: this.getCurCode,
|
|
|
scope: this.getCurScope,
|
|
|
};
|
|
|
- this.$api.questionnaire.FindSurveysSummary(params).then(async (res) => {
|
|
|
+ this.$api.questionnaire.FindSurveys(params).then(async (res) => {
|
|
|
if (!res.error && res.surveys) {
|
|
|
let list = res.surveys.reverse();
|
|
|
this.qnList = list;
|
|
@@ -241,21 +211,23 @@
|
|
|
} else {
|
|
|
this.$Message.error(this.$t('survey.getDataFailTip'));
|
|
|
}
|
|
|
+ }).catch(err => {
|
|
|
+ this.isLoadList = false
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/** 获取问卷列表 */
|
|
|
- async getQnDetails(qnId) {
|
|
|
+ async getQnDetails(qnItem) {
|
|
|
+ console.log(qnItem)
|
|
|
return new Promise(async (r, j) => {
|
|
|
this.$api.questionnaire
|
|
|
- .FindSurveys({
|
|
|
- id: qnId,
|
|
|
- code: this.getCurCode,
|
|
|
- scope: this.getCurScope,
|
|
|
+ .FindSurveysSummary({
|
|
|
+ id: qnItem.id,
|
|
|
+ code: qnItem.code,
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
- if (!res.error && res.surveys) {
|
|
|
- r(res.surveys[0]);
|
|
|
+ if (!res.error && res.survey) {
|
|
|
+ r(res.survey);
|
|
|
} else {
|
|
|
this.$Message.error(this.$t('survey.getDataFailTip'));
|
|
|
}
|
|
@@ -282,11 +254,11 @@
|
|
|
}
|
|
|
// 如果当前点击活动是已结束 则获取问卷的作答数据
|
|
|
this.currentRecord =
|
|
|
- item.status === 300 && item.id ? await this.getQnRecord(item.id) : null;
|
|
|
+ item.progress === 'finish' && item.id ? await this.getQnRecord(item.id) : null;
|
|
|
this.currentQn = item.id ?
|
|
|
- await this.getQnDetails(item.id) :
|
|
|
+ await this.getQnDetails(item) :
|
|
|
this.currentQn;
|
|
|
- this.currentQn.status = item.status;
|
|
|
+ this.currentQn.progress = item.progress;
|
|
|
console.log("获取问卷数据");
|
|
|
console.log(this.currentQn);
|
|
|
this.currentRecord && this.makeItemResult(this.currentRecord);
|
|
@@ -295,37 +267,99 @@
|
|
|
this.editable = false;
|
|
|
},
|
|
|
|
|
|
+ /* 获取问卷所有试题的选项内容 */
|
|
|
+ getSurveyAns(items) {
|
|
|
+ let result = []
|
|
|
+ items.forEach(item => {
|
|
|
+ result.push(item.option.map(i => i.code))
|
|
|
+ })
|
|
|
+ return result
|
|
|
+ },
|
|
|
+
|
|
|
/* 保存问卷操作 */
|
|
|
async onSaveQn() {
|
|
|
- console.log(this.$refs.qnForm.qnFormEdit);
|
|
|
+ this.isBtnLoading = true;
|
|
|
let isQnFormEdit = this.$refs.qnForm.qnFormEdit; // 判断当前表单是否为编辑状态
|
|
|
- let qnBaseInfo = isQnFormEdit ?
|
|
|
- await this.$refs.qnForm.handleSubmit("qnForm") :
|
|
|
- this.currentQn;
|
|
|
+ let qnBaseInfo = isQnFormEdit ? await this.$refs.qnForm.handleSubmit("qnForm") : this.currentQn;
|
|
|
let qnItems = this.$refs.qnPaper.items || [];
|
|
|
- // 获取到基础信息 以及 题目数据 拼接保存
|
|
|
- qnBaseInfo.questions = qnItems;
|
|
|
- this.isBtnLoading = true;
|
|
|
- this.saveorUpdataQn({
|
|
|
- survey: qnBaseInfo,
|
|
|
- reset: false,
|
|
|
- })
|
|
|
+ // 将问卷试题内容保存到blob 用blobUrl来替换quesitons字段
|
|
|
+ qnBaseInfo.ans = this.getSurveyAns(qnItems)
|
|
|
+ qnBaseInfo.questionUrl = await this.doUploadBlob(qnBaseInfo, qnItems);
|
|
|
+ // 开始保存问卷
|
|
|
+ this.saveorUpdataQn(qnBaseInfo)
|
|
|
.then((res) => {
|
|
|
this.$Message.success(this.$t('survey.doSuc'));
|
|
|
- this.$refs.qnForm.qnFormEdit = false;
|
|
|
this.editable = false;
|
|
|
- this.isLoading = false;
|
|
|
- this.isBtnLoading = false;
|
|
|
this.onAddSuccess();
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
this.$Message.error(`操作失败,错误信息为${error}`);
|
|
|
+ }).finally(data => {
|
|
|
this.$refs.qnForm.qnFormEdit = false;
|
|
|
this.isLoading = false;
|
|
|
this.isBtnLoading = false;
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ async doUploadBlob(qnBaseInfo, items) {
|
|
|
+ console.log('上传参数', qnBaseInfo)
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
+ let promiseArr = []
|
|
|
+ // 获取初始化Blob需要的数据
|
|
|
+ let sasData = qnBaseInfo.scope === 'private' ? await this.$tools.getPrivateSas() : await this.$tools.getSchoolSas();
|
|
|
+ //初始化Blob
|
|
|
+ let containerClient = new blobTool(
|
|
|
+ sasData.url,
|
|
|
+ sasData.name,
|
|
|
+ sasData.sas,
|
|
|
+ qnBaseInfo.scope
|
|
|
+ );
|
|
|
+
|
|
|
+ // 上传index.json
|
|
|
+ promiseArr.push(new Promise(async (r, j) => {
|
|
|
+ // let itemJsonFile = await this.$evTools.createBlobItem(exerciseItem);
|
|
|
+ let file = new File([JSON.stringify(qnBaseInfo)], "index.json");
|
|
|
+ try {
|
|
|
+ // 等待上传blob的返回结果
|
|
|
+ let blobFile = await containerClient.upload(file, 'survey/' + qnBaseInfo.id);
|
|
|
+ if (blobFile.blob) {
|
|
|
+ console.log('上传Blob成功', blobFile)
|
|
|
+ r(blobFile.blob)
|
|
|
+ } else {
|
|
|
+ this.$Message.error(this.$t('evaluation.newExercise.uploadErrorTip'));
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ this.$Message.error(e.spaceError);
|
|
|
+ }
|
|
|
+ }))
|
|
|
+
|
|
|
+
|
|
|
+ for (let item of items) {
|
|
|
+ let curId = item.id || this.$tools.guid()
|
|
|
+ promiseArr.push(new Promise(async (r, j) => {
|
|
|
+ // let itemJsonFile = await this.$evTools.createBlobItem(exerciseItem);
|
|
|
+ let file = new File([JSON.stringify(item)], curId + ".json");
|
|
|
+ try {
|
|
|
+ // 等待上传blob的返回结果
|
|
|
+ let blobFile = await containerClient.upload(file, 'survey/' + qnBaseInfo.id);
|
|
|
+ if (blobFile.blob) {
|
|
|
+ console.log('上传Blob成功', blobFile)
|
|
|
+ r(blobFile.blob)
|
|
|
+ } else {
|
|
|
+ this.$Message.error(this.$t('evaluation.newExercise.uploadErrorTip'));
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ this.$Message.error(e.spaceError);
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ Promise.all(promiseArr).then(result => {
|
|
|
+ console.log(result)
|
|
|
+ resolve(result.slice(1))
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
onShowAllAnalysis() {
|
|
|
this.$refs.qnPaper.onShowAllAnalysis();
|
|
|
},
|
|
@@ -454,6 +488,71 @@
|
|
|
this.handleTabClick(this.$route.name === "manageQuestionnaire" ? 0 : 1);
|
|
|
},
|
|
|
|
|
|
+ /** 删除当前问卷 */
|
|
|
+ onDeleteQn() {
|
|
|
+ this.$Modal.confirm({
|
|
|
+ title: this.$t('survey.deletesurvey'),
|
|
|
+ content: this.$t('survey.deleteConfirmTip'),
|
|
|
+ onOk: () => {
|
|
|
+ this.isLoading = true;
|
|
|
+ if (this.currentQn.id) {
|
|
|
+ this.$api.questionnaire
|
|
|
+ .DeleteSurvey({
|
|
|
+ id: this.currentQn.id,
|
|
|
+ code: this.currentQn.code,
|
|
|
+ scope: this.getCurScope,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (!res.error) {
|
|
|
+ // 获取初始化Blob需要的数据
|
|
|
+ this.deleteBlobPrefix(this.currentQn).then(status => {
|
|
|
+ if (status === 200) {
|
|
|
+ this.isLoading = false;
|
|
|
+ this.$Message.success(this.$t('survey.deleteSuc'));
|
|
|
+ this.handleTabClick(
|
|
|
+ this.$route.name === "manageQuestionnaire" ? 0 : 1
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ console.log(err)
|
|
|
+ this.isLoading = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.isLoading = false;
|
|
|
+ this.$Message.error(this.$t('survey.deleteFail'));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.qnList.splice(this.qnList.indexOf(this.currentQn), 1);
|
|
|
+ this.isLoading = false;
|
|
|
+ this.$Message.success(this.$t('survey.deleteSuc'));
|
|
|
+ if (this.qnList.length) this.onQnClick(this.qnList[0], 0);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 删除blob指定试题目录下所有 */
|
|
|
+ deleteBlobPrefix(item) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$api.blob.deletePrefix({
|
|
|
+ "cntr": item.scope === 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
|
|
|
+ "prefix": "survey/" + item.id
|
|
|
+ }).then(
|
|
|
+ (res) => {
|
|
|
+ if (!res.error) {
|
|
|
+ resolve(200)
|
|
|
+ } else {
|
|
|
+ resolve(500)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ reject(err)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 滚动条返回顶部
|
|
|
* @param refName
|