repo.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" 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>
  14. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  18. </el-form>
  19. <el-table v-loading="loading" :data="repoList" @selection-change="handleSelectionChange" :height="clientHeight"
  20. border>
  21. <el-table-column type="selection" width="55" align="center"/>
  22. <!-- <el-table-column label="题库编号" align="center" prop="code" :show-overflow-tooltip="true"/>-->
  23. <el-table-column label="题库名称" align="center" prop="title" :show-overflow-tooltip="true"/>
  24. <el-table-column
  25. label="单选题数量"
  26. prop="radioCount"
  27. align="center"
  28. />
  29. <el-table-column
  30. label="多选题数量"
  31. prop="multiCount"
  32. align="center"
  33. />
  34. <el-table-column
  35. label="判断题数量"
  36. prop="judgeCount"
  37. align="center"
  38. />
  39. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
  40. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  41. <template slot-scope="scope">
  42. <el-button
  43. size="mini"
  44. type="text"
  45. icon="el-icon-edit"
  46. @click="handleTrain(scope.row)"
  47. >开始练习
  48. </el-button>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <pagination
  53. v-show="total>0"
  54. :total="total"
  55. :page.sync="queryParams.pageNum"
  56. :limit.sync="queryParams.pageSize"
  57. @pagination="getList"
  58. />
  59. </div>
  60. </template>
  61. <script>
  62. import {listRepo, getRepo, delRepo, addRepo, updateRepo, exportRepo, importTemplate} from "@/api/training/elearn/repo";
  63. import {treeselect} from "@/api/system/dept";
  64. import {getToken} from "@/utils/auth";
  65. import Treeselect from "@riophae/vue-treeselect";
  66. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  67. export default {
  68. name: "Repo",
  69. components: {Treeselect},
  70. data() {
  71. return {
  72. // 遮罩层
  73. loading: true,
  74. // 选中数组
  75. ids: [],
  76. // 非单个禁用
  77. single: true,
  78. // 非多个禁用
  79. multiple: true,
  80. // 显示搜索条件
  81. showSearch: true,
  82. // 总条数
  83. total: 0,
  84. // 题库表格数据
  85. repoList: [],
  86. // 弹出层标题
  87. title: "",
  88. // 部门树选项
  89. deptOptions: undefined,
  90. clientHeight: 300,
  91. // 是否显示弹出层
  92. open: false,
  93. // 用户导入参数
  94. upload: {
  95. // 是否显示弹出层(用户导入)
  96. open: false,
  97. // 弹出层标题(用户导入)
  98. title: "",
  99. // 是否禁用上传
  100. isUploading: false,
  101. // 是否更新已经存在的用户数据
  102. updateSupport: 0,
  103. // 设置上传的请求头部
  104. headers: {Authorization: "Bearer " + getToken()},
  105. // 上传的地址
  106. url: process.env.VUE_APP_BASE_API + "/elearn/repo/importData"
  107. },
  108. // 查询参数
  109. queryParams: {
  110. pageNum: 1,
  111. pageSize: 20,
  112. code: null,
  113. title: null,
  114. createrCode: null,
  115. createdate: null,
  116. updaterCode: null,
  117. updatedate: null,
  118. deptId: null,
  119. remarks: null,
  120. isStudy: 1,
  121. },
  122. // 表单参数
  123. form: {},
  124. // 表单校验
  125. rules: {}
  126. };
  127. },
  128. watch: {
  129. // 根据名称筛选部门树
  130. deptName(val) {
  131. this.$refs.tree.filter(val);
  132. }
  133. },
  134. created() {
  135. //设置表格高度对应屏幕高度
  136. this.$nextTick(() => {
  137. this.clientHeight = document.body.clientHeight - 250
  138. })
  139. this.getList();
  140. this.getTreeselect();
  141. },
  142. methods: {
  143. /** 查询题库列表 */
  144. getList() {
  145. this.loading = true;
  146. listRepo(this.queryParams).then(response => {
  147. this.repoList = response.rows;
  148. this.total = response.total;
  149. this.loading = false;
  150. });
  151. },
  152. /** 查询部门下拉树结构 */
  153. getTreeselect() {
  154. treeselect().then(response => {
  155. this.deptOptions = response.data;
  156. });
  157. },
  158. // 取消按钮
  159. cancel() {
  160. this.open = false;
  161. this.reset();
  162. },
  163. // 表单重置
  164. reset() {
  165. this.form = {
  166. repoId: null,
  167. code: null,
  168. title: null,
  169. delFlag: null,
  170. createrCode: null,
  171. createdate: null,
  172. updaterCode: null,
  173. updatedate: null,
  174. deptId: null,
  175. remarks: null
  176. };
  177. this.resetForm("form");
  178. },
  179. /** 搜索按钮操作 */
  180. handleQuery() {
  181. this.queryParams.pageNum = 1;
  182. this.getList();
  183. },
  184. /** 重置按钮操作 */
  185. resetQuery() {
  186. this.resetForm("queryForm");
  187. this.handleQuery();
  188. },
  189. // 多选框选中数据
  190. handleSelectionChange(selection) {
  191. this.ids = selection.map(item => item.repoId)
  192. this.single = selection.length !== 1
  193. this.multiple = !selection.length
  194. },
  195. /** 新增按钮操作 */
  196. handleAdd() {
  197. this.reset();
  198. this.open = true;
  199. this.title = "添加题库";
  200. },
  201. /** 修改按钮操作 */
  202. handleTrain(row) {
  203. const repoId = row.repoId || this.ids
  204. this.$router.push({ name: 'RepoTraining', params: { repoId: repoId }})
  205. },
  206. /** 提交按钮 */
  207. submitForm() {
  208. this.$refs["form"].validate(valid => {
  209. if (valid) {
  210. if (this.form.repoId != null) {
  211. updateRepo(this.form).then(response => {
  212. this.msgSuccess("修改成功");
  213. this.open = false;
  214. this.getList();
  215. });
  216. } else {
  217. addRepo(this.form).then(response => {
  218. this.msgSuccess("新增成功");
  219. this.open = false;
  220. this.getList();
  221. });
  222. }
  223. }
  224. });
  225. },
  226. /** 删除按钮操作 */
  227. handleDelete(row) {
  228. const repoIds = row.repoId || this.ids;
  229. this.$confirm('是否确认删除?', "警告", {
  230. confirmButtonText: "确定",
  231. cancelButtonText: "取消",
  232. type: "warning"
  233. }).then(function () {
  234. return delRepo(repoIds);
  235. }).then(() => {
  236. this.getList();
  237. this.msgSuccess("删除成功");
  238. })
  239. },
  240. /** 导出按钮操作 */
  241. handleExport() {
  242. const queryParams = this.queryParams;
  243. this.$confirm('是否确认导出所有题库数据项?', "警告", {
  244. confirmButtonText: "确定",
  245. cancelButtonText: "取消",
  246. type: "warning"
  247. }).then(function () {
  248. return exportRepo(queryParams);
  249. }).then(response => {
  250. this.download(response.msg);
  251. })
  252. },
  253. /** 导入按钮操作 */
  254. handleImport() {
  255. this.upload.title = "用户导入";
  256. this.upload.open = true;
  257. },
  258. /** 下载模板操作 */
  259. importTemplate() {
  260. importTemplate().then(response => {
  261. this.download(response.msg);
  262. });
  263. },
  264. // 文件上传中处理
  265. handleFileUploadProgress(event, file, fileList) {
  266. this.upload.isUploading = true;
  267. },
  268. // 文件上传成功处理
  269. handleFileSuccess(response, file, fileList) {
  270. this.upload.open = false;
  271. this.upload.isUploading = false;
  272. this.$refs.upload.clearFiles();
  273. this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
  274. this.getList();
  275. },
  276. // 提交上传文件
  277. submitFileForm() {
  278. this.$refs.upload.submit();
  279. }
  280. }
  281. };
  282. </script>