index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <!--题库管理-->
  2. <template>
  3. <div class="app-container repo">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" class="form-box">
  5. <el-col :span="1.5" style="margin-right:20px;">
  6. <p class="add-button-one-120"
  7. @click="handleAdd"
  8. v-hasPermi="['exam:repo:add']"
  9. ><i class="el-icon-plus"></i>新增题库</p>
  10. </el-col>
  11. <el-form-item label="题库名称" prop="title">
  12. <el-input
  13. v-model="queryParams.title"
  14. placeholder="请输入题库名称"
  15. clearable
  16. size="small"
  17. />
  18. </el-form-item>
  19. <el-form-item label="学科类别" prop="code">
  20. <el-select v-model="queryParams.code" placeholder="请选择学科类别" clearable size="small">
  21. <el-option
  22. v-for="dict in subClassOptions"
  23. :key="dict.dictValue"
  24. :label="dict.dictLabel"
  25. :value="dict.dictValue">
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="开始时间" prop="inTime" style="margin-left:10px;">
  30. <el-date-picker clearable size="small"
  31. v-model="queryParams.inTime"
  32. type="date"
  33. value-format="yyyy-MM-dd"
  34. placeholder="请选择开始时间">
  35. </el-date-picker>
  36. </el-form-item>
  37. <el-form-item label="结束时间" prop="outTime">
  38. <el-date-picker clearable size="small"
  39. v-model="queryParams.outTime"
  40. type="date"
  41. value-format="yyyy-MM-dd"
  42. placeholder="请选择结束时间">
  43. </el-date-picker>
  44. </el-form-item>
  45. <el-form-item>
  46. <p class="inquire-button-one" @click="handleQuery">查询</p>
  47. <p class="reset-button-one" @click="resetQuery">重置</p>
  48. </el-form-item>
  49. </el-form>
  50. <el-table v-loading="loading" :data="repoList" @selection-change="handleSelectionChange">
  51. <el-table-column label="题库名称" align="left" prop="title" />
  52. <el-table-column label="学科类别" align="left" prop="code" >
  53. <template slot-scope="scope">
  54. <span v-for="(item,index) in subClassOptions" :key="index" v-if="scope.row.code==item.dictValue">{{item.dictLabel}}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="单选题数量" align="left" prop="radioCount" />
  58. <el-table-column label="多选题数量" align="left" prop="multiCount" />
  59. <el-table-column label="判断题数量" align="left" prop="judgeCount" />
  60. <el-table-column label="创建时间" align="left" prop="createTime" />
  61. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="240">
  62. <template slot-scope="scope">
  63. <div class="button-box">
  64. <p class="table-min-button"
  65. style="margin-right:10px;"
  66. @click="handleUpdate(scope.row)"
  67. v-hasPermi="['exam:repo:edit']"
  68. ><i class="el-icon-edit"></i>编辑</p>
  69. <p class="table-min-button"
  70. @click="handleDelete(scope.row)"
  71. v-hasPermi="['exam:repo:remove']"
  72. ><i class="el-icon-delete"></i>删除</p>
  73. </div>
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. <pagination :page-sizes="[20, 30, 40, 50]"
  78. v-show="total>0"
  79. :total="total"
  80. layout="total, prev, pager, next, sizes, jumper"
  81. :page.sync="queryParams.pageNum"
  82. :limit.sync="queryParams.pageSize"
  83. @pagination="getList"
  84. />
  85. <!-- 添加或修改题库对话框 -->
  86. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  87. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  88. <el-form-item label="题库名称" prop="title">
  89. <el-input v-model="form.title" placeholder="请输入题库名称" />
  90. </el-form-item>
  91. <el-form-item label="学科类别" prop="code">
  92. <el-select v-model="form.code" placeholder="请选择">
  93. <el-option
  94. v-for="dict in subClassOptions"
  95. :key="dict.dictValue"
  96. :label="dict.dictLabel"
  97. :value="dict.dictValue"
  98. ></el-option>
  99. </el-select>
  100. </el-form-item>
  101. </el-form>
  102. <div slot="footer" class="dialog-footer">
  103. <el-button @click="cancel">取 消</el-button>
  104. <el-button type="primary" @click="submitForm">确 定</el-button>
  105. </div>
  106. </el-dialog>
  107. </div>
  108. </template>
  109. <script>
  110. import { listRepo, getRepo, delRepo, addRepo, updateRepo } from "@/api/exam/repo";
  111. export default {
  112. name: "Repo",
  113. data() {
  114. return {
  115. // 遮罩层
  116. loading: true,
  117. // 选中数组
  118. ids: [],
  119. // 非单个禁用
  120. single: true,
  121. // 非多个禁用
  122. multiple: true,
  123. // 显示搜索条件
  124. showSearch: true,
  125. // 总条数
  126. total: 0,
  127. // 题库表格数据
  128. repoList: [],
  129. // 学科类别字典
  130. subClassOptions: [],
  131. // 弹出层标题
  132. title: "",
  133. // 是否显示弹出层
  134. open: false,
  135. // 查询参数
  136. queryParams: {
  137. pageNum: 1,
  138. pageSize:20,
  139. code: null,
  140. title: null,
  141. radioCount: null,
  142. multiCount: null,
  143. judgeCount: null,
  144. userId: null,
  145. deptId: null,
  146. deptName: null
  147. },
  148. // 表单参数
  149. form: {},
  150. // 表单校验
  151. rules: {
  152. code: [
  153. { required: true, message: "题库类别不能为空", trigger: "blur" }
  154. ],
  155. title: [
  156. { required: true, message: "题库名称不能为空", trigger: "blur" },
  157. { required: true, message: "题库名称不能为空", validator: this.spaceJudgment, trigger: "blur" }
  158. ],
  159. radioCount: [
  160. { required: true, message: "单选数量不能为空", trigger: "blur" }
  161. ],
  162. multiCount: [
  163. { required: true, message: "多选数量不能为空", trigger: "blur" }
  164. ],
  165. judgeCount: [
  166. { required: true, message: "判断数量不能为空", trigger: "blur" }
  167. ],
  168. // remark: [
  169. // { required: true, message: "题库备注不能为空", trigger: "blur" }
  170. // ],
  171. }
  172. };
  173. },
  174. created() {
  175. this.getList(),
  176. this.getDicts("subject_class").then(response => {
  177. this.subClassOptions = response.data;
  178. });
  179. },
  180. methods: {
  181. /** 查询题库列表 */
  182. getList() {
  183. this.loading = true;
  184. listRepo(this.queryParams).then(response => {
  185. this.repoList = response.rows;
  186. this.total = response.total;
  187. this.loading = false;
  188. });
  189. },
  190. // 取消按钮
  191. cancel() {
  192. this.open = false;
  193. this.reset();
  194. },
  195. // 表单重置
  196. reset() {
  197. this.form = {
  198. id: null,
  199. code: null,
  200. title: null,
  201. radioCount: null,
  202. multiCount: null,
  203. judgeCount: null,
  204. remark: null,
  205. createTime: null,
  206. updateTime: null,
  207. userId: null,
  208. createBy: null,
  209. updateBy: null,
  210. deptId: null,
  211. deptName: null
  212. };
  213. this.resetForm("form");
  214. },
  215. /** 搜索按钮操作 */
  216. handleQuery() {
  217. this.queryParams.pageNum = 1;
  218. this.getList();
  219. },
  220. /** 重置按钮操作 */
  221. resetQuery() {
  222. this.resetForm("queryForm");
  223. this.handleQuery();
  224. },
  225. // 多选框选中数据
  226. handleSelectionChange(selection) {
  227. this.ids = selection.map(item => item.id)
  228. this.single = selection.length!==1
  229. this.multiple = !selection.length
  230. },
  231. /** 新增按钮操作 */
  232. handleAdd() {
  233. this.reset();
  234. this.open = true;
  235. this.title = "添加题库";
  236. },
  237. /** 修改按钮操作 */
  238. handleUpdate(row) {
  239. this.reset();
  240. const id = row.id || this.ids
  241. getRepo(id).then(response => {
  242. this.form = response.data;
  243. this.form.code = this.form.code + ""
  244. this.open = true;
  245. this.title = "修改题库";
  246. });
  247. },
  248. /** 提交按钮 */
  249. submitForm() {
  250. this.$refs["form"].validate(valid => {
  251. if (valid) {
  252. if (this.form.id != null) {
  253. updateRepo(this.form).then(response => {
  254. this.msgSuccess("修改成功");
  255. this.open = false;
  256. this.getList();
  257. });
  258. } else {
  259. addRepo(this.form).then(response => {
  260. this.msgSuccess("新增成功");
  261. this.open = false;
  262. this.getList();
  263. });
  264. }
  265. }
  266. });
  267. },
  268. /** 删除按钮操作 */
  269. handleDelete(row) {
  270. const ids = row.id || this.ids;
  271. this.$confirm('是否确认删除题库?', "警告", {
  272. confirmButtonText: "确定",
  273. cancelButtonText: "取消",
  274. type: "warning"
  275. }).then(function() {
  276. return delRepo(ids);
  277. }).then(() => {
  278. this.getList();
  279. this.msgSuccess("删除成功");
  280. }).catch(() => {});
  281. },
  282. /** 导出按钮操作 */
  283. handleExport() {
  284. this.download('exam/repo/export', {
  285. ...this.queryParams
  286. }, `exam_repo.xlsx`)
  287. }
  288. }
  289. };
  290. </script>
  291. <style scoped lang="scss">
  292. .repo{
  293. display: flex!important;
  294. flex-direction: column;
  295. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  296. padding:20px!important;
  297. .button-box{
  298. width:190px;
  299. display: flex;
  300. }
  301. .form-box{
  302. }
  303. }
  304. </style>