|
@@ -113,19 +113,53 @@
|
|
<i>{{ attachment.filename }}</i>
|
|
<i>{{ attachment.filename }}</i>
|
|
</el-button>
|
|
</el-button>
|
|
</td>
|
|
</td>
|
|
- <td :rowspan="paperAttachments.length" v-if="index === 0">
|
|
|
|
- <el-button
|
|
|
|
- v-if="CAN_EDIT_CARD"
|
|
|
|
- type="text"
|
|
|
|
- class="btn-primary"
|
|
|
|
- @click="toCreateOrViewCard"
|
|
|
|
- >{{ cardTodoName }}</el-button
|
|
|
|
- >
|
|
|
|
|
|
+ <td>
|
|
|
|
+ <template v-if="CAN_EDIT_CARD">
|
|
|
|
+ <el-select
|
|
|
|
+ class="mr-2"
|
|
|
|
+ v-model="attachment.cardId"
|
|
|
|
+ placeholder="请选择"
|
|
|
|
+ style="width: 200px"
|
|
|
|
+ filterable
|
|
|
|
+ @change="cardChange(attachment)"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in cards"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ :value="item.id"
|
|
|
|
+ :label="item.title"
|
|
|
|
+ >
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ <el-button
|
|
|
|
+ class="btn-primary"
|
|
|
|
+ type="text"
|
|
|
|
+ :disabled="!attachment.cardId"
|
|
|
|
+ @click="toViewCard(attachment)"
|
|
|
|
+ >预览</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button
|
|
|
|
+ class="btn-primary"
|
|
|
|
+ type="text"
|
|
|
|
+ :disabled="
|
|
|
|
+ !attachment.cardId || attachment.cardType === 'GENERIC'
|
|
|
|
+ "
|
|
|
|
+ @click="toEditCard(attachment)"
|
|
|
|
+ >编辑</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button
|
|
|
|
+ class="btn-primary"
|
|
|
|
+ type="text"
|
|
|
|
+ :disabled="!canCreateCard"
|
|
|
|
+ @click="toCreateCard(attachment)"
|
|
|
|
+ >新建</el-button
|
|
|
|
+ >
|
|
|
|
+ </template>
|
|
<el-button
|
|
<el-button
|
|
v-else
|
|
v-else
|
|
type="text"
|
|
type="text"
|
|
class="btn-primary"
|
|
class="btn-primary"
|
|
- @click="toViewCard"
|
|
|
|
|
|
+ @click="toViewCard(attachment)"
|
|
>
|
|
>
|
|
查看题卡
|
|
查看题卡
|
|
</el-button>
|
|
</el-button>
|
|
@@ -180,20 +214,13 @@
|
|
@confirm="uploadConfirm"
|
|
@confirm="uploadConfirm"
|
|
ref="UploadPaperDialog"
|
|
ref="UploadPaperDialog"
|
|
></upload-paper-dialog>
|
|
></upload-paper-dialog>
|
|
- <!-- card-option-dialog -->
|
|
|
|
- <card-option-dialog
|
|
|
|
- ref="CardOptionDialog"
|
|
|
|
- :data="curTaskApply"
|
|
|
|
- @confirm="cardConfirm"
|
|
|
|
- ></card-option-dialog>
|
|
|
|
<!-- ModifyCard -->
|
|
<!-- ModifyCard -->
|
|
- <modify-card ref="ModifyCard"></modify-card>
|
|
|
|
|
|
+ <modify-card ref="ModifyCard" @modified="cardModified"></modify-card>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import UploadPaperDialog from "./UploadPaperDialog";
|
|
import UploadPaperDialog from "./UploadPaperDialog";
|
|
-import CardOptionDialog from "./CardOptionDialog";
|
|
|
|
import ModifyCard from "../../card/components/ModifyCard";
|
|
import ModifyCard from "../../card/components/ModifyCard";
|
|
import { taskApplyDetail, taskPaperApplyEdit } from "../api";
|
|
import { taskApplyDetail, taskPaperApplyEdit } from "../api";
|
|
import { attachmentPreview } from "../../login/api";
|
|
import { attachmentPreview } from "../../login/api";
|
|
@@ -220,7 +247,7 @@ const initTaskApply = {
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "modify-task-paper",
|
|
name: "modify-task-paper",
|
|
- components: { UploadPaperDialog, CardOptionDialog, ModifyCard },
|
|
|
|
|
|
+ components: { UploadPaperDialog, ModifyCard },
|
|
props: {
|
|
props: {
|
|
instance: {
|
|
instance: {
|
|
type: Object,
|
|
type: Object,
|
|
@@ -251,22 +278,18 @@ export default {
|
|
CAN_EDIT_CARD() {
|
|
CAN_EDIT_CARD() {
|
|
return this.editType === "EDIT" && !this.instance.exposedPaperType;
|
|
return this.editType === "EDIT" && !this.instance.exposedPaperType;
|
|
},
|
|
},
|
|
- cardTodoName() {
|
|
|
|
- let name = "查看题卡";
|
|
|
|
- if (this.CAN_EDIT_CARD) {
|
|
|
|
- if (this.curTaskApply.makeMethod === "SELECT") {
|
|
|
|
- name = "选择题卡";
|
|
|
|
- } else {
|
|
|
|
- name = "编辑题卡";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return name;
|
|
|
|
- },
|
|
|
|
maxFetchCount() {
|
|
maxFetchCount() {
|
|
return this.paperAttachments.length < 1
|
|
return this.paperAttachments.length < 1
|
|
? 1
|
|
? 1
|
|
: this.paperAttachments.length;
|
|
: this.paperAttachments.length;
|
|
},
|
|
},
|
|
|
|
+ canCreateCard() {
|
|
|
|
+ return (
|
|
|
|
+ this.curTaskApply.courseCode &&
|
|
|
|
+ this.curTaskApply.examId &&
|
|
|
|
+ this.curTaskApply.cardRuleId !== COMMON_CARD_RULE_ID
|
|
|
|
+ );
|
|
|
|
+ },
|
|
exposedMode() {
|
|
exposedMode() {
|
|
return !!this.curTaskApply.exposedPaperType;
|
|
return !!this.curTaskApply.exposedPaperType;
|
|
}
|
|
}
|
|
@@ -291,6 +314,14 @@ export default {
|
|
const examRule = await examRuleDetail();
|
|
const examRule = await examRuleDetail();
|
|
this.includePaper = examRule && examRule.includePaper;
|
|
this.includePaper = examRule && examRule.includePaper;
|
|
},
|
|
},
|
|
|
|
+ async getCardList() {
|
|
|
|
+ if (!this.curTaskApply.courseCode || !this.curTaskApply.examId) return;
|
|
|
|
+ const data = await cardForSelectList({
|
|
|
|
+ courseCode: this.curTaskApply.courseCode,
|
|
|
|
+ examId: this.curTaskApply.examId
|
|
|
|
+ });
|
|
|
|
+ this.cards = data || [];
|
|
|
|
+ },
|
|
async visibleChange() {
|
|
async visibleChange() {
|
|
const data = await taskApplyDetail(this.instance.id);
|
|
const data = await taskApplyDetail(this.instance.id);
|
|
this.curTaskApply = this.$objAssign(initTaskApply, data || {});
|
|
this.curTaskApply = this.$objAssign(initTaskApply, data || {});
|
|
@@ -312,6 +343,12 @@ export default {
|
|
: true;
|
|
: true;
|
|
paper.isExposed = exposedPaperTypes.includes(paper.name);
|
|
paper.isExposed = exposedPaperTypes.includes(paper.name);
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ if (this.CAN_EDIT_CARD) {
|
|
|
|
+ this.getCardList();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
},
|
|
},
|
|
cancel() {
|
|
cancel() {
|
|
this.modalIsShow = false;
|
|
this.modalIsShow = false;
|
|
@@ -370,18 +407,19 @@ export default {
|
|
const data = await attachmentPreview(attachment.attachmentId);
|
|
const data = await attachmentPreview(attachment.attachmentId);
|
|
window.open(data.url);
|
|
window.open(data.url);
|
|
},
|
|
},
|
|
- toViewCard() {
|
|
|
|
|
|
+ toViewCard(attachment) {
|
|
window.open(
|
|
window.open(
|
|
this.getRouterPath({
|
|
this.getRouterPath({
|
|
name: "CardPreview",
|
|
name: "CardPreview",
|
|
params: {
|
|
params: {
|
|
- cardId: this.curTaskApply.cardId,
|
|
|
|
|
|
+ cardId: attachment.cardId,
|
|
viewType: "view"
|
|
viewType: "view"
|
|
}
|
|
}
|
|
})
|
|
})
|
|
);
|
|
);
|
|
},
|
|
},
|
|
- toEditCard() {
|
|
|
|
|
|
+ toEditCard(attachment) {
|
|
|
|
+ this.curAttachment = { ...attachment };
|
|
this.$ls.set("prepareTcPCard", {
|
|
this.$ls.set("prepareTcPCard", {
|
|
cardId: this.curTaskApply.cardId,
|
|
cardId: this.curTaskApply.cardId,
|
|
examTaskId: this.curTaskApply.examTaskId,
|
|
examTaskId: this.curTaskApply.examTaskId,
|
|
@@ -395,25 +433,44 @@ export default {
|
|
});
|
|
});
|
|
this.$refs.ModifyCard.open();
|
|
this.$refs.ModifyCard.open();
|
|
},
|
|
},
|
|
- async toCreateOrViewCard() {
|
|
|
|
- this.task = this.getTaskData();
|
|
|
|
- if (this.CAN_EDIT_CARD) {
|
|
|
|
- if (this.curTaskApply.makeMethod === "SELECT") {
|
|
|
|
- this.$refs.CardOptionDialog.open();
|
|
|
|
- } else {
|
|
|
|
- this.toEditCard();
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- this.toViewCard();
|
|
|
|
|
|
+ async cardModified(cardId) {
|
|
|
|
+ if (!cardId) return;
|
|
|
|
+ let card = this.cards.find(item => item.id === cardId);
|
|
|
|
+ if (!card) {
|
|
|
|
+ await this.getCardList();
|
|
|
|
+ card = this.cards.find(item => item.id === cardId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const aind = this.paperAttachments.findIndex(
|
|
|
|
+ item => item.name === this.curAttachment.name
|
|
|
|
+ );
|
|
|
|
+ if (aind !== -1) {
|
|
|
|
+ this.paperAttachments[aind].cardId = card && card.id;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- cardConfirm(data) {
|
|
|
|
- this.curTaskApply = this.$objAssign(this.curTaskApply, data);
|
|
|
|
|
|
+ toCreateCard(attachment) {
|
|
|
|
+ if (!this.curTaskApply.cardRuleId) {
|
|
|
|
+ this.$message.error("题卡规则缺失!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.curAttachment = { ...attachment };
|
|
|
|
+ this.$ls.set("prepareTcPCard", {
|
|
|
|
+ courseCode: this.curTaskApply.courseCode,
|
|
|
|
+ courseName: this.curTaskApply.courseName,
|
|
|
|
+ schoolName: this.$ls.get("schoolName"),
|
|
|
|
+ makeMethod: "SELF",
|
|
|
|
+ cardRuleId: this.curTaskApply.cardRuleId,
|
|
|
|
+ type: "CUSTOM",
|
|
|
|
+ createMethod: "STANDARD"
|
|
|
|
+ });
|
|
|
|
+ this.$refs.ModifyCard.open();
|
|
},
|
|
},
|
|
- getTaskData() {
|
|
|
|
- let data = { ...this.curTaskApply };
|
|
|
|
-
|
|
|
|
- return data;
|
|
|
|
|
|
+ cardChange(attachment) {
|
|
|
|
+ const card = this.cards.find(item => item.id === attachment.cardId);
|
|
|
|
+ if (card) {
|
|
|
|
+ attachment.cardType = card.type;
|
|
|
|
+ attachment.cardTitle = card.title;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
checkDataValid() {
|
|
checkDataValid() {
|
|
const attachmentValid = !this.paperAttachments.some(
|
|
const attachmentValid = !this.paperAttachments.some(
|
|
@@ -425,18 +482,12 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!this.curTaskApply.cardId) {
|
|
|
|
- this.$message.error("请选择题卡创建方式!");
|
|
|
|
|
|
+ const cardValid = !this.paperAttachments.some(item => !item.cardId);
|
|
|
|
+ if (!cardValid) {
|
|
|
|
+ this.$message.error("有试卷类型未选择题卡!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (
|
|
|
|
- this.curTaskApply.makeMethod !== "SELECT" &&
|
|
|
|
- this.curTaskApply.status !== "SUBMIT"
|
|
|
|
- ) {
|
|
|
|
- this.$message.error("请先提交题卡!");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
return true;
|
|
return true;
|
|
},
|
|
},
|
|
async submit() {
|
|
async submit() {
|
|
@@ -448,11 +499,8 @@ export default {
|
|
.then(async () => {
|
|
.then(async () => {
|
|
const datas = {
|
|
const datas = {
|
|
examTaskId: this.curTaskApply.examTaskId,
|
|
examTaskId: this.curTaskApply.examTaskId,
|
|
- cardId: this.curTaskApply.cardId,
|
|
|
|
paperType: this.paperAttachments.map(item => item.name).join(","),
|
|
paperType: this.paperAttachments.map(item => item.name).join(","),
|
|
- paperAttachmentIds: JSON.stringify(this.paperAttachments, (k, v) =>
|
|
|
|
- k === "editable" || k === "url" ? undefined : v
|
|
|
|
- )
|
|
|
|
|
|
+ paperAttachmentIds: JSON.stringify(this.paperAttachments)
|
|
};
|
|
};
|
|
const data = await taskPaperApplyEdit(datas).catch(() => {});
|
|
const data = await taskPaperApplyEdit(datas).catch(() => {});
|
|
if (!data) return;
|
|
if (!data) return;
|