index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="问题" prop="title">
  5. <el-input
  6. v-model="queryParams.title"
  7. placeholder="请输入问题标题"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <!-- <el-form-item label="排序" prop="sort">-->
  14. <!-- <el-input-->
  15. <!-- v-model="queryParams.sort"-->
  16. <!-- placeholder="请输入排序"-->
  17. <!-- clearable-->
  18. <!-- size="small"-->
  19. <!-- @keyup.enter.native="handleQuery"-->
  20. <!-- />-->
  21. <!-- </el-form-item>-->
  22. <el-form-item label="类别" prop="type">
  23. <el-select v-model="queryParams.type" placeholder="请选择类别" clearable size="small">
  24. <el-option
  25. v-for="dict in typeOptions"
  26. :key="dict.dictValue"
  27. :label="dict.dictLabel"
  28. :value="dict.dictValue"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="题目类别" prop="questionType">
  33. <el-select v-model="queryParams.questionType" ref="typeSelect" placeholder="请选择类别" @change="changeCateType" clearable size="small">
  34. <el-option
  35. v-for="item in questionRootTypeOptions"
  36. :key="item.dictValue"
  37. :label="item.dictLabel"
  38. :value="item.dictValue"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="题目子类别" prop="questionSubType" label-width="100px">
  43. <el-select v-model="queryParams.questionSubType" ref="typeSelect" placeholder="请选择子类别" clearable size="small">
  44. <el-option
  45. v-for="item in questionSubTypeOptions"
  46. :key="item.dictValue"
  47. :label="item.dictLabel"
  48. :value="item.dictValue"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. <!-- <el-form-item label="状态" prop="status">-->
  53. <!-- <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">-->
  54. <!-- <el-option-->
  55. <!-- v-for="dict in statusOptions"-->
  56. <!-- :key="dict.dictValue"-->
  57. <!-- :label="dict.dictLabel"-->
  58. <!-- :value="dict.dictValue"-->
  59. <!-- />-->
  60. <!-- </el-select>-->
  61. <!-- </el-form-item>-->
  62. <el-form-item>
  63. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  64. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  65. </el-form-item>
  66. </el-form>
  67. <el-row :gutter="10" class="mb8">
  68. <el-col :span="1.5">
  69. <el-button
  70. type="primary"
  71. plain
  72. icon="el-icon-plus"
  73. size="mini"
  74. @click="handleAdd"
  75. v-hasPermi="['course:courseQuestionBank:add']"
  76. >新增</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. type="success"
  81. plain
  82. icon="el-icon-edit"
  83. size="mini"
  84. :disabled="single"
  85. @click="handleUpdate"
  86. v-hasPermi="['course:courseQuestionBank:edit']"
  87. >修改</el-button>
  88. </el-col>
  89. <el-col :span="1.5">
  90. <el-button
  91. type="danger"
  92. plain
  93. icon="el-icon-delete"
  94. size="mini"
  95. :disabled="multiple"
  96. @click="handleDelete"
  97. v-hasPermi="['course:courseQuestionBank:remove']"
  98. >删除</el-button>
  99. </el-col>
  100. <el-col :span="1.5">
  101. <el-button
  102. type="warning"
  103. plain
  104. icon="el-icon-download"
  105. size="mini"
  106. :loading="exportLoading"
  107. @click="handleExport"
  108. v-hasPermi="['course:courseQuestionBank:export']"
  109. >导出</el-button>
  110. </el-col>
  111. <el-col :span="1.5">
  112. <el-button
  113. plain
  114. type="info"
  115. icon="el-icon-upload2"
  116. size="mini"
  117. @click="handleImport"
  118. v-hasPermi="['course:courseQuestionBank:import']"
  119. >导入</el-button>
  120. </el-col>
  121. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  122. </el-row>
  123. <el-table border v-loading="loading" :data="courseQuestionBankList" @selection-change="handleSelectionChange">
  124. <el-table-column type="selection" width="55" align="center" />
  125. <el-table-column label="标题" align="center" prop="title" show-overflow-tooltip width="300" />
  126. <el-table-column label="类别" align="center" prop="type">
  127. <template slot-scope="scope">
  128. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="题目类别" align="center" prop="questionType">
  132. <template slot-scope="scope">
  133. <el-tag v-if="scope.row.questionType">{{ getCategoryName(scope.row.questionType) }}</el-tag>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="题目子类别" align="center" prop="questionType">
  137. <template slot-scope="scope">
  138. <el-tag v-if="scope.row.questionSubType">{{ getCategoryName(scope.row.questionSubType) }}</el-tag>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="状态" align="center" prop="status">
  142. <template slot-scope="scope">
  143. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="排序" align="center" prop="sort" />
  147. <el-table-column label="答案" align="center" prop="answer" />
  148. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  149. <template slot-scope="scope">
  150. <el-button
  151. size="mini"
  152. type="text"
  153. icon="el-icon-edit"
  154. @click="handleUpdate(scope.row)"
  155. v-hasPermi="['course:courseQuestionBank:edit']"
  156. >修改</el-button>
  157. <el-button
  158. size="mini"
  159. type="text"
  160. icon="el-icon-delete"
  161. @click="handleDelete(scope.row)"
  162. v-hasPermi="['course:courseQuestionBank:remove']"
  163. >删除</el-button>
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. <pagination
  168. v-show="total>0"
  169. :total="total"
  170. :page.sync="queryParams.pageNum"
  171. :limit.sync="queryParams.pageSize"
  172. @pagination="getList"
  173. />
  174. <!-- 添加或修改题库对话框 -->
  175. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
  176. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  177. <el-form-item label="标题" prop="title">
  178. <el-input v-model="form.title" placeholder="请输入问题" />
  179. </el-form-item>
  180. <el-form-item label="排序" prop="sort">
  181. <el-input-number v-model="form.sort" :min="0" label="请输入排序"></el-input-number>
  182. </el-form-item>
  183. <el-form-item label="类别 " prop="type">
  184. <el-select v-model="form.type" placeholder="请选择类别" @change="changeType">
  185. <el-option
  186. v-for="dict in typeOptions"
  187. :key="dict.dictValue"
  188. :label="dict.dictLabel"
  189. :value="parseInt(dict.dictValue)"
  190. ></el-option>
  191. </el-select>
  192. </el-form-item>
  193. <el-form-item label="题目类别 " prop="questionType">
  194. <el-select v-model="form.questionType" clearable placeholder="请选择题目类别" @change="changeCateType">
  195. <el-option
  196. v-for="item in questionRootTypeOptions"
  197. :key="item.dictValue"
  198. :label="item.dictLabel"
  199. :value="item.dictValue"
  200. />
  201. </el-select>
  202. <el-select v-model="form.questionSubType" clearable placeholder="请选择题目子类别" >
  203. <el-option
  204. v-for="item in questionSubTypeOptions"
  205. :key="item.dictValue"
  206. :label="item.dictLabel"
  207. :value="item.dictValue"
  208. />
  209. </el-select>
  210. </el-form-item>
  211. <el-form-item label="状态">
  212. <el-radio-group v-model="form.status">
  213. <el-radio
  214. v-for="dict in statusOptions"
  215. :key="dict.dictValue"
  216. :label="parseInt(dict.dictValue)"
  217. >{{dict.dictLabel}}</el-radio>
  218. </el-radio-group>
  219. </el-form-item>
  220. <!-- 提示用户选择类别 -->
  221. <el-alert v-if="!form.type" title="选择题目类别后添加选项" type="warning" show-icon></el-alert>
  222. <el-form-item label="选项" v-if="form.type">
  223. <el-button @click="addRow" size="mini" type="primary">新增选项</el-button>
  224. <el-table border :data="question" :cell-style="{ textAlign: 'center' }" :header-cell-style="{textAlign: 'center'}" >
  225. <el-table-column label="序号" width="65px" >
  226. <template slot-scope="scope">
  227. {{ '选项'+getOptionLabel(scope.$index)+':' }}
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="选项" prop="name" >
  231. <template slot-scope="scope">
  232. <el-input v-model="scope.row.name" :placeholder="getOptionLabel(scope.$index) + ':' + '请输入标题'" ></el-input>
  233. </template>
  234. </el-table-column>
  235. <el-table-column label="是否为答案" prop="isWrite" >
  236. <template slot-scope="scope">
  237. <el-tooltip
  238. v-if="!scope.row.name"
  239. content="请先填写选项标题内容"
  240. placement="top"
  241. effect="dark"
  242. >
  243. <el-switch
  244. v-model="scope.row.isAnswer"
  245. :active-value="1"
  246. :inactive-value="0"
  247. @change="handleAnswerChange(scope.row,scope.$index)"
  248. :disabled="Boolean(!scope.row.name || (form.type === 1 && scope.row.isAnswer && selectedAnswer !== scope.row))"
  249. ></el-switch>
  250. </el-tooltip>
  251. <el-switch
  252. v-else
  253. v-model="scope.row.isAnswer"
  254. :active-value="1"
  255. :inactive-value="0"
  256. @change="handleAnswerChange(scope.row,scope.$index)"
  257. :disabled="Boolean(form.type === 1 && scope.row.isAnswer && selectedAnswer !== scope.row)"
  258. ></el-switch>
  259. </template>
  260. </el-table-column>
  261. <el-table-column label="操作">
  262. <template slot-scope="scope">
  263. <el-button @click="deleteRow(scope.$index)" size="mini" type="text" v-if="question.length>1">删除</el-button>
  264. </template>
  265. </el-table-column>
  266. </el-table>
  267. </el-form-item>
  268. <el-form-item label="答案:" prop="answer">
  269. <template slot-scope="scope">
  270. <span style="background-color: #faedc9; font-size: 20px;">
  271. {{ form.answer }}
  272. </span>
  273. </template>
  274. </el-form-item>
  275. </el-form>
  276. <div slot="footer" class="dialog-footer">
  277. <el-button type="primary" @click="submitForm">确 定</el-button>
  278. <el-button @click="cancel">取 消</el-button>
  279. </div>
  280. </el-dialog>
  281. <!-- 导入 -->
  282. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  283. <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  284. <i class="el-icon-upload"></i>
  285. <div class="el-upload__text">
  286. 将文件拖到此处,或
  287. <em>点击上传</em>
  288. </div>
  289. <div class="el-upload__tip" slot="tip">
  290. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  291. </div>
  292. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  293. </el-upload>
  294. <div slot="footer" class="dialog-footer">
  295. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  296. <el-button @click="upload.open = false">取 消</el-button>
  297. </div>
  298. </el-dialog>
  299. <el-dialog title="导入结果" :close-on-press-escape="false" :close-on-click-modal="false" :visible.sync="importMsgOpen" width="500px" append-to-body>
  300. <div class="import-msg" v-html="importMsg">
  301. </div>
  302. </el-dialog>
  303. </div>
  304. </template>
  305. <script>
  306. import { listCourseQuestionBank, getCourseQuestionBank, delCourseQuestionBank, addCourseQuestionBank, updateCourseQuestionBank, exportCourseQuestionBank, importTemplate } from "@/api/course/courseQuestionBank";
  307. import { getToken } from "@/utils/auth";
  308. import {
  309. listUserCourseCategory,
  310. getCatePidList,
  311. getCateListByPid
  312. } from '@/api/course/userCourseCategory'
  313. export default {
  314. name: "CourseQuestionBank",
  315. computed: {
  316. alphabet() {
  317. return 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  318. },
  319. },
  320. watch: {
  321. },
  322. mounted() {
  323. },
  324. data() {
  325. return {
  326. //单选
  327. selectedAnswer:null,
  328. //多选
  329. selectedAnswers: [],
  330. typeOptions: [],
  331. statusOptions: [],
  332. question:[
  333. { name: "", isAnswer: 0, indexId:0},
  334. { name: "", isAnswer: 0, indexId:1},
  335. { name: "", isAnswer: 0, indexId:2},
  336. { name: "", isAnswer: 0, indexId:3},
  337. ],
  338. // 遮罩层
  339. loading: true,
  340. // 导出遮罩层
  341. exportLoading: false,
  342. // 选中数组
  343. ids: [],
  344. // 非单个禁用
  345. single: true,
  346. // 非多个禁用
  347. multiple: true,
  348. // 显示搜索条件
  349. showSearch: true,
  350. // 总条数
  351. total: 0,
  352. // 题库表格数据
  353. courseQuestionBankList: [],
  354. questionTypeOptions: [],
  355. questionRootTypeOptions: [],
  356. questionSubTypeOptions: [],
  357. // 弹出层标题
  358. title: "",
  359. // 是否显示弹出层
  360. open: false,
  361. // 查询参数
  362. queryParams: {
  363. pageNum: 1,
  364. pageSize: 10,
  365. title: null,
  366. sort: null,
  367. type: null,
  368. status: null,
  369. question: null,
  370. questionType:null,
  371. questionSubType: null,
  372. answer: null,
  373. },
  374. // 表单参数
  375. form: {},
  376. // 表单校验
  377. rules: {
  378. title: [{ required: true, message: "不能为空", trigger: "blur" }],
  379. sort: [{ required: true, message: "不能为空", trigger: "blur" }],
  380. type: [{ required: true, message: "不能为空", trigger: "blur" }],
  381. status: [{ required: true, message: "不能为空", trigger: "blur" }],
  382. question: [{ required: true, message: "不能为空", trigger: "blur" }],
  383. answer: [{ required: true, message: "不能为空", trigger: "blur" }],
  384. },
  385. // 导入
  386. importMsgOpen:false,
  387. importMsg: '',
  388. upload: {
  389. // 是否显示弹出层(文件导入)
  390. open: false,
  391. // 弹出层标题(文件导入)
  392. title: "",
  393. // 是否禁用上传
  394. isUploading: false,
  395. // 设置上传的请求头部
  396. headers: { Authorization: "Bearer " + getToken() },
  397. // 上传的地址
  398. url: process.env.VUE_APP_BASE_API + "/course/courseQuestionBank/importData",
  399. }
  400. };
  401. },
  402. created() {
  403. this.getList();
  404. this.getDicts("sys_course_temp_type").then(response => {
  405. this.typeOptions = response.data;
  406. });
  407. this.getDicts("sys_company_status").then(response => {
  408. this.statusOptions = response.data;
  409. });
  410. this.getCategoryTree()
  411. },
  412. methods: {
  413. getOptionLabel(index) {
  414. return this.alphabet[index];
  415. },
  416. // 分类树
  417. getCategoryTree() {
  418. listUserCourseCategory().then(response => {
  419. this.questionTypeOptions = response.data
  420. });
  421. getCatePidList().then(response => {
  422. this.questionRootTypeOptions = response.data
  423. });
  424. },
  425. changeCateType(val) {
  426. if (!val) {
  427. return
  428. }
  429. getCateListByPid(val).then(response => {
  430. this.questionSubTypeOptions = response.data
  431. })
  432. },
  433. getCategoryName(id) {
  434. return this.questionTypeOptions.find(item => item.cateId === id)?.cateName || '';
  435. },
  436. //题目类型发生变化
  437. changeType(){
  438. this.selectedAnswers = [];
  439. this.selectedAnswer = null;
  440. this.question.forEach(item => {
  441. item.isAnswer = 0; // 清除所有选项的选中状态
  442. });
  443. // 重置答案的显示值
  444. this.form.answer = null;
  445. },
  446. //选择答案
  447. handleAnswerChange(row, index) {
  448. if (this.form.type === 1) {
  449. // 单选模式:记录选中的答案并取消其他选项
  450. this.selectedAnswer = row;
  451. this.question.forEach((item) => {
  452. if (item !== row) {
  453. item.isAnswer = 0;
  454. }
  455. });
  456. // 保存单选的答案
  457. // this.form.answer = this.getOptionLabel(index);
  458. this.form.answer = row.name;
  459. } else if (this.form.type === 2) {
  460. // 多选模式:将所有被选中的答案存储到 selectedAnswers 数组 先检查当前选项是否已经在选中答案列表中
  461. if (row.isAnswer === 1) {
  462. // 如果选中,将该答案加入到选中数组
  463. this.selectedAnswers.push(row);
  464. } else {
  465. // 如果取消选中,从选中数组中移除
  466. this.selectedAnswers = this.selectedAnswers.filter(item => item.indexId !== row.indexId);
  467. }
  468. // 对 selectedAnswers 进行排序 (假设按 row.indexId 排序)
  469. this.selectedAnswers.sort((a, b) => a.indexId - b.indexId);
  470. // 更新 form.answer,保存所有选中的答案
  471. this.form.answer = this.selectedAnswers.map(item => item.name);
  472. }
  473. },
  474. addRow() {
  475. this.question.push({ name: '', isAnswer: 0,indexId: this.question.length});},
  476. deleteRow(index) {
  477. if (this.form.type === 1 && this.question[index] === this.selectedAnswer) {
  478. this.selectedAnswer = null;
  479. }
  480. this.question.splice(index, 1);
  481. },
  482. /** 查询题库列表 */
  483. getList() {
  484. this.loading = true;
  485. listCourseQuestionBank(this.queryParams).then(response => {
  486. this.courseQuestionBankList = response.rows;
  487. this.total = response.total;
  488. this.loading = false;
  489. });
  490. },
  491. // 取消按钮
  492. cancel() {
  493. this.open = false;
  494. this.reset();
  495. this.changeCateType(this.queryParams.questionType)
  496. },
  497. // 表单重置
  498. reset() {
  499. this.form = {
  500. id: null,
  501. title: null,
  502. sort: null,
  503. type: 1,
  504. status: 1,
  505. question: null,
  506. createTime: null,
  507. answer: null,
  508. createBy: null
  509. };
  510. this.resetForm("form");
  511. },
  512. /** 搜索按钮操作 */
  513. handleQuery() {
  514. this.queryParams.pageNum = 1;
  515. this.getList();
  516. },
  517. /** 重置按钮操作 */
  518. resetQuery() {
  519. this.resetForm("queryForm");
  520. this.handleQuery();
  521. },
  522. // 多选框选中数据
  523. handleSelectionChange(selection) {
  524. this.ids = selection.map(item => item.id)
  525. this.single = selection.length!==1
  526. this.multiple = !selection.length
  527. },
  528. /** 新增按钮操作 */
  529. handleAdd() {
  530. this.reset();
  531. this.questionSubTypeOptions = []
  532. this.open = true;
  533. this.title = "添加题库";
  534. },
  535. /** 修改按钮操作 */
  536. handleUpdate(row) {
  537. this.reset();
  538. const id = row.id || this.ids
  539. getCourseQuestionBank(id).then(response => {
  540. this.form = response.data;
  541. this.changeCateType(this.form.questionType)
  542. //初始化多选的选择结果,单选的选择的时候,就取消其他的了 selectedAnswers
  543. if (this.form.type===2) {
  544. this.form.answer=JSON.parse(this.form.answer)
  545. this.selectedAnswers = JSON.parse(this.form.question).filter(item => item.isAnswer === 1);
  546. }
  547. this.question=JSON.parse(this.form.question)
  548. this.open = true;
  549. this.title = "修改题库";
  550. });
  551. },
  552. /** 提交按钮 */
  553. submitForm() {
  554. this.$refs["form"].validate(valid => {
  555. if (valid) {
  556. if (this.question.some(q => q.name === "")) {
  557. this.$message.error("不能存在空选项")
  558. return
  559. }
  560. this.form.question=JSON.stringify(this.question)
  561. if (this.form.type===2){
  562. this.form.answer=JSON.stringify(this.form.answer)
  563. // this.form.answer = this.form.answer.join(',');
  564. }
  565. if (this.form.id != null) {
  566. updateCourseQuestionBank(this.form).then(response => {
  567. this.msgSuccess("修改成功");
  568. this.open = false;
  569. this.getList();
  570. });
  571. } else {
  572. addCourseQuestionBank(this.form).then(response => {
  573. this.msgSuccess("新增成功");
  574. this.open = false;
  575. this.getList();
  576. });
  577. }
  578. }
  579. });
  580. },
  581. /** 删除按钮操作 */
  582. handleDelete(row) {
  583. const ids = row.id || this.ids;
  584. this.$confirm('是否确认删除题库编号为"' + ids + '"的数据项?', "警告", {
  585. confirmButtonText: "确定",
  586. cancelButtonText: "取消",
  587. type: "warning"
  588. }).then(function() {
  589. return delCourseQuestionBank(ids);
  590. }).then(() => {
  591. this.getList();
  592. this.msgSuccess("删除成功");
  593. }).catch(() => {});
  594. },
  595. /** 导出按钮操作 */
  596. handleExport() {
  597. const queryParams = this.queryParams;
  598. this.$confirm('是否确认导出所有题库数据项?', "警告", {
  599. confirmButtonText: "确定",
  600. cancelButtonText: "取消",
  601. type: "warning"
  602. }).then(() => {
  603. this.exportLoading = true;
  604. return exportCourseQuestionBank(queryParams);
  605. }).then(response => {
  606. this.download(response.msg);
  607. this.exportLoading = false;
  608. }).catch(() => {});
  609. },
  610. // 下载模板
  611. importTemplate() {
  612. importTemplate().then((response) => {
  613. this.download(response.msg);
  614. });
  615. },
  616. // 导入
  617. handleImport() {
  618. this.upload.title = "导入题目";
  619. this.upload.open = true;
  620. },
  621. submitFileForm() {
  622. this.$refs.upload.submit();
  623. },
  624. // 文件上传中处理
  625. handleFileUploadProgress(event, file, fileList) {
  626. this.upload.isUploading = true;
  627. },
  628. // 文件上传成功处理
  629. handleFileSuccess(response, file, fileList) {
  630. this.upload.open = false;
  631. this.upload.isUploading = false;
  632. this.$refs.upload.clearFiles();
  633. this.importMsgOpen=true;
  634. this.importMsg = response.msg
  635. this.getList();
  636. },
  637. }
  638. };
  639. </script>