index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <!-- 刷题练习 -->
  2. <template>
  3. <div class="app-container practiceSolvingProblems">
  4. <div class="page-container practiceSolvingProblemsPage" v-if="pageType === 1">
  5. <div class="page-form-title-box">
  6. <el-form :model="queryParams" class="form-box" ref="queryForm"
  7. :inline="true" style="width:100%;">
  8. <el-form-item label="" prop="queryParamsData1">
  9. <el-select v-model="queryParams.queryParamsData1" multiple placeholder="学年" style="width: 200px">
  10. <el-option
  11. v-for="dict in optionListA"
  12. :key="dict.value"
  13. :label="dict.label"
  14. :value="dict.value"
  15. />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="" prop="queryParamsData2">
  19. <el-select v-model="queryParams.queryParamsData2" placeholder="学院单位" style="width: 200px">
  20. <el-option
  21. v-for="dict in optionListB"
  22. :key="dict.deptId"
  23. :label="dict.deptName"
  24. :value="dict.deptId"
  25. />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="" prop="queryParamsData3">
  29. <el-cascader
  30. v-model="queryParams.queryParamsData3"
  31. :options="optionListC"
  32. :props="{
  33. emitPath:false,
  34. checkStrictly: true,
  35. value: 'id',
  36. label: 'knowledgePointName',
  37. children: 'children',
  38. }"
  39. style="width: 180px"
  40. :show-all-levels="false"
  41. filterable
  42. placeholder="知识点"
  43. ></el-cascader>
  44. </el-form-item>
  45. <el-form-item label="" prop="state">
  46. <el-date-picker
  47. :clearable="false"
  48. v-model="dateRange"
  49. size="small"
  50. style="width: 240px"
  51. value-format="yyyy-MM-dd"
  52. type="daterange"
  53. range-separator="-"
  54. start-placeholder="开始日期"
  55. end-placeholder="结束日期"
  56. ></el-date-picker>
  57. </el-form-item>
  58. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  59. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  60. </el-form>
  61. </div>
  62. <div class="page-content-box">
  63. <el-table class="table-box" v-loading="loading" border :data="dataList">
  64. <el-table-column label="知识点" prop="name" show-overflow-tooltip/>
  65. <el-table-column label="试题总数" prop="content" width="200" show-overflow-tooltip/>
  66. <el-table-column label="练习人数" prop="content" width="200" show-overflow-tooltip/>
  67. <el-table-column label="答题总数" prop="content" width="200" show-overflow-tooltip/>
  68. <el-table-column label="答对题数" prop="content" width="200" show-overflow-tooltip/>
  69. <el-table-column label="整体正确率%" prop="content" width="200" show-overflow-tooltip/>
  70. <el-table-column label="操作" width="200" show-overflow-tooltip v-if="tableButtonType">
  71. <template slot-scope="scope">
  72. <div class="table-button-box">
  73. <p class="table-button-null"></p>
  74. <p class="table-button-p"
  75. @click="tableButton(2,scope.row)"
  76. v-hasPermiRouter="['demo:demo:detail']"
  77. >练习统计</p>
  78. <p class="table-button-null"></p>
  79. </div>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <pagination :page-sizes="[20, 30, 40, 50]"
  84. v-show="total>0"
  85. :total="total"
  86. :page.sync="queryParams.page"
  87. :limit.sync="queryParams.pageSize"
  88. @pagination="getList"
  89. />
  90. </div>
  91. </div>
  92. <!--<add-page :propsData="propsData" v-if="pageType === 2"></add-page>-->
  93. </div>
  94. </template>
  95. <script>
  96. //import { getDicts } from "@/api/commonality/noPermission";
  97. //import { systemUserSelect } from "@/api/commonality/permission";
  98. //import { getInfo } from "@/api/basicsModules/index";
  99. //import addPage from "./addPage.vue";
  100. import { examElKnowledgePointTreeList,systemDeptCurrentDept, } from "@/api/safetyEducationExaminationNew/index";
  101. export default {
  102. name: 'index',
  103. //components: {
  104. // addPage
  105. //},
  106. data () {
  107. return {
  108. tableButtonType:this.hasPermiDom(['demo:demo:detail','demo:demo:edit','demo:demo:del',]),
  109. //页面状态
  110. pageType:1,
  111. //页面遮罩
  112. loading:false,
  113. //下拉列表数据
  114. optionListA:[],
  115. optionListB:[],
  116. optionListC:[],
  117. //查询条件
  118. queryParams:{
  119. page:1,
  120. pageSize:20,
  121. queryParamsData1:"",
  122. queryParamsData2 :null,
  123. },
  124. //时间数据
  125. dateRange:[],
  126. //列表数据
  127. dataList:[],
  128. //数据数量
  129. total:0,
  130. //组件传参
  131. propsData:{},
  132. }
  133. },
  134. created () {
  135. },
  136. mounted () {
  137. this.systemDeptCurrentDept();
  138. this.examElKnowledgePointTreeList();
  139. //this.getList();
  140. },
  141. methods: {
  142. //查询按钮
  143. handleQuery(){
  144. this.$set(this.queryParams,'page',1);
  145. this.getList();
  146. },
  147. //重置按钮
  148. resetQuery(){
  149. this.$set(this,'dateRange',[])
  150. this.$set(this,'queryParams',{
  151. page:1,
  152. pageSize:20,
  153. queryParamsData1:"",
  154. queryParamsData2 :null,
  155. });
  156. this.getList();
  157. },
  158. //获取数据列表
  159. getList(){
  160. this.$set(this,'loading',true);
  161. let obj = JSON.parse(JSON.stringify(this.queryParams))
  162. if(this.dateRange[0]){
  163. obj.startTime = this.dateRange[0]+'T00:00:00'
  164. obj.endTime = this.dateRange[1]+'T23:59:59'
  165. }else{
  166. obj.startTime = "";
  167. obj.endTime = "";
  168. }
  169. getListFunction(obj).then(response => {
  170. this.$set(this,'loading',false);
  171. this.$set(this,'dataList',response.data.records);
  172. this.$set(this,'total',response.data.total);
  173. });
  174. },
  175. //操作按钮
  176. tableButton(type,row){
  177. let self = this;
  178. if(type == 1){
  179. //新增
  180. this.$set(this,'pageType',2);
  181. this.$set(this,'propsData',{});
  182. }else if(type == 2){
  183. //详情
  184. this.$set(this,'pageType',2);
  185. let obj = JSON.parse(JSON.stringify(row))
  186. obj.showType = true;
  187. this.$set(this,'propsData',obj);
  188. }else if(type == 3){
  189. //编辑
  190. this.$set(this,'pageType',2);
  191. let obj = JSON.parse(JSON.stringify(row))
  192. obj.showType = false;
  193. this.$set(this,'propsData',obj);
  194. }else if(type == 4){
  195. //删除
  196. this.$confirm('是否确认删除?', "警告", {
  197. confirmButtonText: "确定",
  198. cancelButtonText: "取消",
  199. type: "warning"
  200. }).then(function() {
  201. }).then(() => {
  202. deleteFunction({id:row.id}).then(response => {
  203. self.msgSuccess(response.message)
  204. self.getList();
  205. });
  206. }).catch(() => {});
  207. }else if(type == 5){
  208. //启用&停用
  209. let text = row.state ? "停用" : "启用";
  210. this.$confirm('是否确认' + text + '?', "警告", {
  211. confirmButtonText: "确定",
  212. cancelButtonText: "取消",
  213. type: "warning"
  214. }).then(function() {
  215. }).then(() => {
  216. stateFunction({id:row.id,state:!row.state,}).then(response => {
  217. self.msgSuccess(response.message)
  218. self.getList();
  219. });
  220. }).catch(() => {});
  221. }else if(type == 6){
  222. //返回并刷新
  223. this.$set(this,'pageType',1);
  224. this.getList();
  225. }
  226. },
  227. //学院列表
  228. systemDeptCurrentDept(){
  229. systemDeptCurrentDept({}).then(response => {
  230. this.$set(this,'optionListB',response.data);
  231. });
  232. },
  233. examElKnowledgePointTreeList(){
  234. examElKnowledgePointTreeList({}).then(response => {
  235. const list = response.data || [];
  236. this.formatTreeData(list);
  237. this.$set(this, 'optionListC', list);
  238. });
  239. },
  240. formatTreeData(data) {
  241. data.forEach(item => {
  242. // 如果 children 存在,且是数组,且长度为 0(即 children: [])
  243. if (Array.isArray(item.children) && item.children.length === 0) {
  244. // 将 children 设为 undefined(或直接 delete item.children;)
  245. item.children = undefined;
  246. } else if (item.children && item.children.length > 0) {
  247. // 如果还有下一级,继续递归处理
  248. this.formatTreeData(item.children);
  249. }
  250. });
  251. },
  252. },
  253. }
  254. </script>
  255. <style scoped lang="scss">
  256. .practiceSolvingProblems{
  257. .practiceSolvingProblemsPage{
  258. }
  259. }
  260. </style>