123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- <template>
- <div class="task-paper-manage">
- <div class="part-box part-box-filter">
- <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
- <template v-if="checkPrivilege('condition', 'condition')">
- <secp-select
- v-model="filter"
- defaultSelectExam
- @exam-default="toPage(1)"
- ></secp-select>
- <el-form-item label="入库时间:">
- <el-date-picker
- v-model="createTime"
- type="datetimerange"
- :picker-options="pickerOptions"
- range-separator="至"
- start-placeholder="入库开始时间"
- end-placeholder="入库结束时间"
- value-format="timestamp"
- align="right"
- unlink-panels
- >
- </el-date-picker>
- </el-form-item>
- </template>
- <el-form-item label-width="0px">
- <el-button
- v-if="checkPrivilege('button', 'select')"
- type="primary"
- @click="toPage(1)"
- >查询</el-button
- >
- </el-form-item>
- </el-form>
- <div class="box-justify">
- <div></div>
- <div>
- <el-button
- v-if="checkPrivilege('button', 'BatchDownload')"
- icon="el-icon-download"
- type="primary"
- :loading="loading"
- @click="toBatchExport"
- >
- 批量下载试卷题卡
- </el-button>
- <el-button
- v-if="checkPrivilege('button', 'BatchDownload')"
- type="primary"
- icon="el-icon-s-order"
- @click="toDataTask"
- >下载结果查询</el-button
- >
- </div>
- </div>
- </div>
- <div class="part-box part-box-pad">
- <el-table ref="TableList" :data="papers">
- <el-table-column
- type="index"
- label="序号"
- width="70"
- :index="indexMethod"
- ></el-table-column>
- <el-table-column
- prop="semesterName"
- label="学期"
- min-width="210"
- ></el-table-column>
- <el-table-column
- prop="examName"
- label="考试"
- min-width="160"
- ></el-table-column>
- <el-table-column
- prop="paperNumber"
- label="试卷编号"
- min-width="160"
- ></el-table-column>
- <el-table-column prop="courseName" label="课程(代码)" min-width="200">
- <template slot-scope="scope">
- {{ scope.row.courseName }}({{ scope.row.courseCode }})
- </template>
- </el-table-column>
- <el-table-column
- prop="paperType"
- label="卷型"
- width="80"
- ></el-table-column>
- <el-table-column
- prop="userName"
- label="命题老师"
- min-width="100"
- ></el-table-column>
- <el-table-column prop="createTime" label="入库时间" width="170">
- <span slot-scope="scope">{{
- scope.row.createTime | timestampFilter
- }}</span>
- </el-table-column>
- <el-table-column prop="exposedPaperType" label="已曝光" width="80">
- <span slot-scope="scope">{{
- scope.row.exposedPaperType | defaultFieldFilter
- }}</span>
- </el-table-column>
- <el-table-column prop="unexposedPaperType" label="未曝光" width="80">
- <span slot-scope="scope">{{
- scope.row.unexposedPaperType | defaultFieldFilter
- }}</span>
- </el-table-column>
- <el-table-column prop="enable" label="启用/禁用" width="90">
- <template slot-scope="scope">
- {{ scope.row.enable | enableFilter }}
- </template>
- </el-table-column>
- <el-table-column
- class-name="action-column"
- label="操作"
- width="140px"
- fixed="right"
- >
- <template slot-scope="scope">
- <el-button
- v-if="checkPrivilege('link', 'preview')"
- class="btn-primary"
- type="text"
- @click="toPreview(scope.row)"
- >预览</el-button
- >
- <el-button
- v-if="checkPrivilege('link', 'edit')"
- class="btn-primary"
- type="text"
- @click="toEdit(scope.row)"
- >编辑</el-button
- >
- <el-button
- v-if="checkPrivilege('link', 'enable')"
- :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
- type="text"
- @click="toEnable(scope.row)"
- >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
- >
- <el-button
- v-if="checkPrivilege('link', 'download')"
- class="btn-primary"
- type="text"
- :disabled="loading"
- @click="toDownload(scope.row)"
- >下载</el-button
- >
- <el-button
- v-if="checkPrivilege('link', 'publish')"
- class="btn-primary"
- type="text"
- @click="toPublishPrintTask(scope.row)"
- >发布印刷任务</el-button
- >
- <el-button
- v-if="checkPrivilege('link', 'cancel')"
- class="btn-danger"
- type="text"
- @click="toCancel(scope.row)"
- >作废</el-button
- >
- <el-button
- v-if="checkPrivilege('link', 'restart')"
- class="btn-danger"
- type="text"
- @click="toRestart(scope.row)"
- >打回</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <div class="part-page">
- <el-pagination
- v-if="papers.length"
- background
- layout="total, sizes, prev, pager, next, jumper"
- :pager-count="5"
- :current-page="current"
- :total="total"
- :page-size="size"
- @current-change="toPage"
- @size-change="pageSizeChange"
- >
- </el-pagination>
- </div>
- </div>
- <!-- ModifyTaskPaper -->
- <modify-task-paper
- v-if="checkPrivilege('link', 'edit') || checkPrivilege('link', 'preview')"
- :instance="curPaper"
- :edit-type="editType"
- ref="ModifyTaskPaper"
- @modified="getList"
- ></modify-task-paper>
- <!-- PublishPrintTask -->
- <publish-print-task
- v-if="checkPrivilege('link', 'publish')"
- :instance="curPaper"
- ref="PublishPrintTask"
- ></publish-print-task>
- <!-- data-task-dialog -->
- <data-task-dialog
- v-if="checkPrivilege('button', 'BatchDownload')"
- ref="DataTaskDialog"
- task-type="PAPER_AND_CARD_PDF_DOWNLOAD"
- ></data-task-dialog>
- </div>
- </template>
- <script>
- import {
- taskPaperListPage,
- ableTaskPaper,
- downloadPaper,
- paperAndCardBatchExport,
- cancelTaskPaper,
- restartTaskPaper,
- } from "../api";
- import pickerOptions from "@/constants/datePickerOptions";
- import { downloadByApi } from "@/plugins/download";
- import { CARD_SOURCE_TYPE } from "@/constants/enumerate";
- import ModifyTaskPaper from "../components/ModifyTaskPaper";
- import PublishPrintTask from "../components/PublishPrintTask";
- export default {
- name: "task-paper-manage",
- components: { ModifyTaskPaper, PublishPrintTask },
- data() {
- return {
- filter: {
- semesterId: "",
- examId: "",
- courseCode: "",
- paperNumber: "",
- cardRuleId: "",
- makeMethod: "",
- startTime: "",
- endTime: "",
- },
- current: 1,
- size: this.GLOBAL.pageSize,
- total: 0,
- papers: [],
- curPaper: {},
- loading: false,
- editType: "EDIT",
- CARD_SOURCE_TYPE,
- IS_QUESTION_TEACHER: this.$ls
- .get("user", { roleList: [] })
- .roleList.includes("QUESTION_TEACHER"),
- IS_EXAM_TEACHER: this.$ls
- .get("user", { roleList: [] })
- .roleList.includes("EXAM_TEACHER"),
- cancelRemark: "",
- // date-picker
- createTime: [],
- pickerOptions,
- };
- },
- mounted() {
- this.initData();
- },
- methods: {
- async initData() {
- const cachePageInfo = this.$ls.get("cachePageInfo");
- if (cachePageInfo) {
- this.filter = this.$objAssign(this.filter, cachePageInfo.filter);
- if (this.filter.startTime && this.filter.endTime)
- this.createTime = [this.filter.startTime, this.filter.endTime];
- this.current = cachePageInfo.page;
- await this.getList();
- this.$nextTick(() => {
- const curRow = this.papers.find(
- (item) => item.id === cachePageInfo.curRowId
- );
- if (!curRow) return;
- this.toEdit(curRow);
- });
- } else {
- // this.toPage(1);
- }
- this.$ls.remove("cachePageInfo");
- },
- async getList() {
- if (!this.checkPrivilege("list", "list")) return;
- const datas = {
- ...this.filter,
- pageNumber: this.current,
- pageSize: this.size,
- };
- if (this.createTime) {
- datas.startTime = this.createTime[0];
- datas.endTime = this.createTime[1];
- }
- const data = await taskPaperListPage(datas);
- this.papers = data.records;
- this.total = data.total;
- },
- toPage(page) {
- this.current = page;
- this.getList();
- },
- async toEnable(row) {
- const msgs = [
- ["命题任务禁用后,会触发试卷关联解除,您确定要禁用命题任务吗?"],
- [
- "命题任务启用后,触发试卷关联校验,若能匹配则自动关联试卷,您确定要启用命题任务吗?",
- ],
- ];
- const msg = row.enable ? msgs[0] : msgs[1];
- const msgHtml = msg
- .map((item) => `<p class="text-left">${item}</p>`)
- .join("");
- this.$confirm(msgHtml, "提示", {
- dangerouslyUseHTMLString: true,
- type: "warning",
- })
- .then(async () => {
- const enable = !row.enable;
- await ableTaskPaper({
- id: row.id,
- enable,
- });
- row.enable = enable;
- this.$message.success("操作成功!");
- })
- .catch(() => {});
- },
- async toCancel(row) {
- const res = await this.$prompt("确定要作废选中的命题任务吗", "提示", {
- type: "warning",
- showInput: true,
- inputPlaceholder: "请输入作废理由",
- inputValue: this.cancelRemark,
- inputValidator: (val) => {
- if (!val) return "请输入作废理由";
- if (val.length > 100) return "作废理由不得超过100个字符!";
- return true;
- },
- }).catch(() => {});
- if (!res || res.action !== "confirm") {
- return;
- }
- this.cancelRemark = res.value;
- const result = await cancelTaskPaper({
- id: row.id,
- cancelRemark: this.cancelRemark,
- }).catch(() => {});
- this.cancelRemark = "";
- if (!result) return;
- this.$message.success("操作成功!");
- this.getList();
- },
- async toRestart(row) {
- const res = await this.$confirm("确定要打回当前命题任务吗", "提示", {
- type: "warning",
- }).catch(() => {});
- if (res !== "confirm") return;
- const result = await restartTaskPaper({
- examTaskId: row.id,
- paperType: row.paperType,
- }).catch(() => {});
- if (!result) return;
- this.$message.success("操作成功!");
- this.getList();
- },
- toEdit(row) {
- this.curPaper = row;
- this.editType = "EDIT";
- this.$refs.ModifyTaskPaper.open();
- },
- toPreview(row) {
- this.curPaper = row;
- this.editType = "PREVIEW";
- this.$refs.ModifyTaskPaper.open();
- },
- toPublishPrintTask(row) {
- this.curPaper = row;
- this.$refs.PublishPrintTask.open();
- },
- async toDownload(row) {
- if (this.loading) return;
- this.loading = true;
- const res = await downloadByApi(() => {
- return downloadPaper(row.id);
- }, "").catch((e) => {
- this.$message.error(e || "下载失败,请重新尝试!");
- });
- this.loading = false;
- if (!res) return;
- this.$message.success("下载成功!");
- },
- async toBatchExport() {
- // 异步导出
- if (this.loading) return;
- this.loading = true;
- let datas = {
- ...this.filter,
- };
- if (this.createTime) {
- datas.startTime = this.createTime[0];
- datas.endTime = this.createTime[1];
- }
- const res = await paperAndCardBatchExport(datas).catch(() => {});
- this.loading = false;
- if (res) {
- this.$message.success("导出任务已提交!");
- } else {
- this.$message.error("导出任务提交失败,请重新尝试!");
- }
- },
- toDataTask() {
- this.$refs.DataTaskDialog.open();
- },
- },
- beforeRouteLeave(to, from, next) {
- if (to.name === "CardEdit") {
- this.$ls.set("cachePageInfo", {
- page: this.current,
- filter: this.filter,
- curRowId: this.curPaper.id,
- });
- } else {
- this.$ls.remove("cachePageInfo");
- }
- next();
- },
- };
- </script>
|