index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <!--题目管理-->
  2. <template>
  3. <div class="app-container qu">
  4. <el-form
  5. :model="queryParams"
  6. ref="queryForm"
  7. :inline="true"
  8. v-show="showSearch && pageType == 0"
  9. label-width="68px"
  10. >
  11. <el-form-item label="题目名称" prop="content" style="margin-left: 10px">
  12. <el-input
  13. v-model="queryParams.content"
  14. placeholder="请输入题目名称"
  15. clearable
  16. size="small"
  17. />
  18. </el-form-item>
  19. <el-form-item label="题目类型" prop="quType" style="margin-left: 10px">
  20. <el-select
  21. v-model="queryParams.quType"
  22. placeholder="请选择题目类型"
  23. clearable
  24. size="small">
  25. <el-option
  26. v-for="dict in quTypes"
  27. :key="dict.type"
  28. :label="dict.value"
  29. :value="dict.type">
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="题目分类" prop="cIds" style="margin-left: 10px">
  34. <el-select
  35. v-model="queryParams.cIds"
  36. placeholder="请选择题目分类"
  37. clearable
  38. size="small">
  39. <el-option
  40. v-for="dict in optionList"
  41. :key="dict.id"
  42. :label="dict.title"
  43. :value="dict.id">
  44. </el-option>
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="难度级别" prop="level" style="margin-left: 10px">
  48. <el-select
  49. v-model="queryParams.level"
  50. placeholder="请选择难度级别"
  51. clearable
  52. size="small"
  53. >
  54.            <el-option
  55. v-for="dict in levels"
  56. :key="dict.type"
  57. :label="dict.value"
  58. :value="dict.type"
  59. ></el-option>
  60.        
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item style="float: right;" v-hasPermi="['exam:qu:add']">
  64. <el-row :gutter="10" class="mb8" v-show="pageType == 0">
  65. <el-dropdown @command="addTopic">
  66. <p class="add-button-one-120"><i class="el-icon-plus"></i>新增题目</p>
  67. <el-dropdown-menu slot="dropdown">
  68. <el-dropdown-item
  69. style="border-bottom: 1px solid #e0e0e0; margin: 0 10px"
  70. command="1"
  71. >单选题</el-dropdown-item
  72. >
  73. <el-dropdown-item
  74. style="border-bottom: 1px solid #e0e0e0; margin: 0 10px"
  75. command="2"
  76. >多选题</el-dropdown-item
  77. >
  78. <el-dropdown-item style="margin: 0 10px" command="3"
  79. >判断题</el-dropdown-item
  80. >
  81. </el-dropdown-menu>
  82. </el-dropdown>
  83. </el-row>
  84. </el-form-item>
  85. <el-form-item>
  86. <p class="inquire-button-one" @click="handleQuery">查询</p>
  87. <p class="reset-button-one" @click="resetQuery">重置</p>
  88. </el-form-item>
  89. </el-form>
  90. <el-table border
  91. v-loading="loading"
  92. :data="quList"
  93. @selection-change="handleSelectionChange"
  94. v-show="pageType == 0"
  95. >
  96. <el-table-column label="题目名称" align="left" prop="content" show-overflow-tooltip/>
  97. <el-table-column label="题目类型" align="left" prop="quType" width="120">
  98. <template slot-scope="scope">
  99. <span
  100. v-for="(item, index) in quTypes"
  101. :key="index"
  102. v-if="scope.row.quType == item.type"
  103. >{{ item.value }}</span
  104. >
  105. </template>
  106. </el-table-column>
  107. <!-- <el-table-column label="归属题库" align="left" prop="poId">
  108. <template slot-scope="scope">
  109. <span v-for="(bigItem,index1) in scope.row.repoIds" :key="index1" style="margin-right:10px;" v-if="scope.row.repoIds[0]">
  110. <span v-for="(minItem,index2) in repoOption" :key="index2" v-if="bigItem==minItem.id">{{ minItem.title}}</span>
  111. </span>
  112. <span v-if="!scope.row.repoIds[0]">暂无归属</span>
  113. </template>
  114. </el-table-column>-->
  115. <el-table-column label="题目分类" align="left" prop="classifyNames" width="160"></el-table-column>
  116. <!--<el-table-column label="适用范围" align="left" prop="scopeType" width="160">-->
  117. <!--<template slot-scope="scope">-->
  118. <!--<span>{{ scope.row.scopeType==1?'安全准入考试':(scope.row.scopeType==2?'负面清单考试':(scope.row.scopeType==3?'黑名单考试':scope.row.scopeType==4?'模拟考试':"未知")) }}</span>-->
  119. <!--</template>-->
  120. <!--</el-table-column>-->
  121. <el-table-column label="难度级别" align="left" prop="level" width="120">
  122. <template slot-scope="scope">
  123. <span
  124. v-for="(item, index) in levels"
  125. :key="index"
  126. v-if="scope.row.level == item.type"
  127. >{{ item.value }}</span
  128. >
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="创建时间" align="left" prop="createTime" width="180"/>
  132. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="160" v-if="tableButtonType">
  133. <template slot-scope="scope">
  134. <div class="button-box">
  135. <p class="table-min-button"
  136. style="margin-right: 10px"
  137. @click="editTopic(scope.row)"
  138. v-hasPermiAnd="['exam:qu:query','exam:qu:edit']">编辑</p>
  139. <p class="table-min-button"
  140. @click="handleDelete(scope.row)"
  141. v-hasPermi="['exam:qu:remove']">删除</p>
  142. </div>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <pagination :page-sizes="[20, 30, 40, 50]"
  147. v-show="total > 0 && pageType == 0"
  148. :total="total"
  149. layout="total, prev, pager, next, sizes, jumper"
  150. :page.sync="queryParams.pageNum"
  151. :limit.sync="queryParams.pageSize"
  152. @pagination="getList"
  153. />
  154. <div v-if="pageType != 0">
  155. <add-topic :pageType="pageType" :quId="quId"></add-topic>
  156. </div>
  157. </div>
  158. </template>
  159. <script>
  160. import { listQu, getQu, delQu, addQu, updateQu } from "@/api/exam/qu";
  161. import addTopic from "./addTopic.vue";
  162. import { optionRepo } from "@/api/exam/repo";
  163. import { list_option } from "@/api/exam/el_classify";
  164. export default {
  165. components: {
  166. addTopic,
  167. },
  168. name: "Qu",
  169. data() {
  170. return {
  171. tableButtonType:this.hasPermiDom(['exam:qu:query','exam:qu:edit','exam:qu:remove']),
  172. // 遮罩层
  173. loading: true,
  174. // 选中数组
  175. ids: [],
  176. // 非单个禁用
  177. single: true,
  178. // 非多个禁用
  179. multiple: true,
  180. // 显示搜索条件
  181. showSearch: true,
  182. // 总条数
  183. total: 0,
  184. // 问题题目表格数据
  185. quList: [],
  186. // 弹出层标题
  187. title: "",
  188. // 是否显示弹出层
  189. open: false,
  190. // 查询参数
  191. queryParams: {
  192. pageNum: 1,
  193. pageSize:20,
  194. poId: null,
  195. quType: null,
  196. level: null,
  197. scopeType: null,
  198. content: null,
  199. analysis: null,
  200. userId: null,
  201. deptId: null,
  202. deptName: null,
  203. },
  204. scopeTypes: [
  205. {
  206. type: 1,
  207. value: "安全准入考试",
  208. },
  209. {
  210. type: 2,
  211. value: "负面清单考试",
  212. },
  213. {
  214. type: 3,
  215. value: "黑名单考试",
  216. },
  217. {
  218. type: 4,
  219. value: "模拟考试",
  220. },
  221. ],
  222. levels: [
  223. {
  224. type: 1,
  225. value: "中等",
  226. },
  227. {
  228. type: 2,
  229. value: "较难",
  230. },
  231. {
  232. type: 3,
  233. value: "难",
  234. },
  235. ],
  236. quTypes: [
  237. {
  238. type: 1,
  239. value: "单选题",
  240. },
  241. {
  242. type: 2,
  243. value: "多选题",
  244. },
  245. {
  246. type: 3,
  247. value: "判断题",
  248. },
  249. ],
  250. // 表单参数
  251. form: {},
  252. // 表单校验
  253. rules: {
  254. quType: [
  255. { required: true, message: "题目类型不能为空", trigger: "change" },
  256. ],
  257. level: [
  258. { required: true, message: "1普通,2较难不能为空", trigger: "blur" },
  259. ],
  260. content: [
  261. { required: true, message: "题目内容不能为空", trigger: "blur" },
  262. { required: true, message: "题目内容不能为空", validator: this.spaceJudgment, trigger: "blur" }
  263. ],
  264. createTime: [
  265. { required: true, message: "创建时间不能为空", trigger: "blur" },
  266. { required: true, message: "创建时间不能为空", validator: this.spaceJudgment, trigger: "blur" }
  267. ],
  268. updateTime: [
  269. { required: true, message: "更新时间不能为空", trigger: "blur" },
  270. { required: true, message: "更新时间不能为空", validator: this.spaceJudgment, trigger: "blur" }
  271. ],
  272. remark: [
  273. { required: true, message: "题目备注不能为空", trigger: "blur" },
  274. { required: true, message: "题目备注不能为空", validator: this.spaceJudgment, trigger: "blur" }
  275. ],
  276. analysis: [
  277. { required: true, message: "整题解析不能为空", trigger: "blur" },
  278. { required: true, message: "整题解析不能为空", validator: this.spaceJudgment, trigger: "blur" }
  279. ],
  280. },
  281. //页面状态 默认0单选1多选2判断3
  282. pageType: 0,
  283. repoOption: [],
  284. quId:"",
  285. //题目分类
  286. optionList:[],
  287. };
  288. },
  289. created() {
  290. this.getList();
  291. this.getRepoOption();
  292. this.getList_option();
  293. },
  294. methods: {
  295. //刷新数据/用于修改或编辑后
  296. refreshData(){
  297. this.resetQuery();
  298. this.pageType = 0;
  299. },
  300. getList_option(){
  301. list_option({}).then(response => {
  302. this.optionList = response.data;
  303. });
  304. },
  305. /** 查询题库列表 */
  306. getRepoOption() {
  307. optionRepo({}).then(response => {
  308. this.repoOption = response.data;
  309. });
  310. },
  311. //创建题目
  312. addTopic(type) {
  313. if (this.pageType != type) {
  314. this.quId = "";
  315. this.pageType = type;
  316. }
  317. },
  318. //编辑题目
  319. editTopic(item) {
  320. if (item.quType) {
  321. this.quId = item.id;
  322. this.pageType = item.quType;
  323. }
  324. },
  325. //关闭创建页面
  326. offAddTopic() {
  327. this.pageType = 0;
  328. },
  329. /** 查询问题题目列表 */
  330. getList() {
  331. this.loading = true;
  332. listQu(this.queryParams).then((response) => {
  333. this.quList = response.rows;
  334. this.total = response.total;
  335. this.loading = false;
  336. });
  337. },
  338. // 取消按钮
  339. cancel() {
  340. this.open = false;
  341. this.reset();
  342. },
  343. // 表单重置
  344. reset() {
  345. this.form = {
  346. id: null,
  347. quType: null,
  348. level: null,
  349. scopeType: null,
  350. content: null,
  351. createTime: null,
  352. updateTime: null,
  353. remark: null,
  354. analysis: null,
  355. userId: null,
  356. createBy: null,
  357. updateBy: null,
  358. deptId: null,
  359. deptName: null,
  360. };
  361. this.resetForm("form");
  362. },
  363. /** 搜索按钮操作 */
  364. handleQuery() {
  365. this.queryParams.pageNum = 1;
  366. this.getList();
  367. },
  368. /** 重置按钮操作 */
  369. resetQuery() {
  370. this.resetForm("queryForm");
  371. this.handleQuery();
  372. },
  373. // 多选框选中数据
  374. handleSelectionChange(selection) {
  375. this.ids = selection.map((item) => item.id);
  376. this.single = selection.length !== 1;
  377. this.multiple = !selection.length;
  378. },
  379. /** 新增按钮操作 */
  380. handleAdd() {
  381. this.reset();
  382. this.open = true;
  383. this.title = "添加问题题目";
  384. },
  385. /** 修改按钮操作 */
  386. handleUpdate(row) {
  387. this.reset();
  388. const id = row.id || this.ids;
  389. getQu(id).then((response) => {
  390. this.form = response.data;
  391. this.open = true;
  392. this.title = "修改问题题目";
  393. });
  394. },
  395. /** 提交按钮 */
  396. submitForm() {
  397. this.$refs["form"].validate((valid) => {
  398. if (valid) {
  399. if (this.form.id != null) {
  400. updateQu(this.form).then((response) => {
  401. this.msgSuccess("修改成功");
  402. this.open = false;
  403. this.getList();
  404. });
  405. } else {
  406. addQu(this.form).then((response) => {
  407. this.msgSuccess("新增成功");
  408. this.open = false;
  409. this.getList();
  410. });
  411. }
  412. }
  413. });
  414. },
  415. /** 删除按钮操作 */
  416. handleDelete(row) {
  417. const ids = row.id || this.ids;
  418. this.$confirm(
  419. '是否确认删除该题目?',
  420. "警告",
  421. {
  422. confirmButtonText: "确定",
  423. cancelButtonText: "取消",
  424. type: "warning",
  425. }
  426. )
  427. .then(function () {
  428. return delQu(ids);
  429. })
  430. .then(() => {
  431. this.getList();
  432. this.msgSuccess("删除成功");
  433. })
  434. .catch(() => {});
  435. },
  436. /** 导出按钮操作 */
  437. handleExport() {
  438. this.download(
  439. "exam/qu/export",
  440. {
  441. ...this.queryParams,
  442. },
  443. `exam_qu.xlsx`
  444. );
  445. },
  446. },
  447. };
  448. </script>
  449. <style scoped lang="scss">
  450. .qu {
  451. display: flex !important;
  452. flex-direction: column;
  453. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  454. padding: 20px !important;
  455. .el-row {
  456. margin-bottom: 20px;
  457. }
  458. .button-box {
  459. width: 190px;
  460. display: flex;
  461. }
  462. .form-box {
  463. display: flex;
  464. .null-p {
  465. flex: 1;
  466. }
  467. }
  468. }
  469. </style>