index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <!-- 试题管理 -->
  2. <template>
  3. <div class="app-container questionBankManagement">
  4. <div class="page-container questionBankManagementPage" 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="shareStatus">
  9. <el-select v-model="queryParams.shareStatus" placeholder="是否共享" style="width: 180px">
  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="knowledgePointId">
  19. <el-cascader
  20. v-model="queryParams.knowledgePointId"
  21. :options="optionListB"
  22. :props="{
  23. emitPath:false,
  24. checkStrictly: true,
  25. value: 'id',
  26. label: 'knowledgePointName',
  27. children: 'children',
  28. }"
  29. style="width: 180px"
  30. :show-all-levels="false"
  31. filterable
  32. placeholder="知识点"
  33. ></el-cascader>
  34. </el-form-item>
  35. <el-form-item label="" prop="questionType">
  36. <el-select v-model="queryParams.questionType" placeholder="题型" style="width: 180px">
  37. <el-option
  38. v-for="dict in optionListC"
  39. :key="dict.value"
  40. :label="dict.label"
  41. :value="dict.value"
  42. />
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="" prop="difficulty">
  46. <el-select v-model="queryParams.difficulty" placeholder="难度" style="width: 180px">
  47. <el-option
  48. v-for="dict in optionListD"
  49. :key="dict.value"
  50. :label="dict.label"
  51. :value="dict.value"
  52. />
  53. </el-select>
  54. </el-form-item>
  55. <el-form-item label="" prop="disciplineTypeId">
  56. <el-select v-model="queryParams.disciplineTypeId" placeholder="试题分类" style="width: 200px">
  57. <el-option
  58. v-for="dict in disciplineOptionList"
  59. :key="dict.id"
  60. :label="dict.disciplineName"
  61. :value="dict.id"
  62. />
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item label="" prop="questionContent">
  66. <el-input
  67. maxLength="30"
  68. v-model="queryParams.questionContent"
  69. placeholder="搜索试题"
  70. style="width: 200px"
  71. />
  72. </el-form-item>
  73. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  74. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  75. <p class="page-submit-common-style-button"
  76. style="float: right;"
  77. v-hasPermiRouter="['exam:elQuestionBank:add']"
  78. @click="tableButton(1)"
  79. >添加试题</p>
  80. <el-form-item style="float: right;" v-hasPermiRouter="['exam:elQuestionBank:importData']">
  81. <import-component :importConfig="importConfig"></import-component>
  82. </el-form-item>
  83. </el-form>
  84. </div>
  85. <div class="page-content-box">
  86. <el-table class="table-box" border :data="dataList">
  87. <el-table-column label="题干" prop="questionContent" show-overflow-tooltip>
  88. <template slot-scope="scope">
  89. <span style="color:#0183fa;cursor: pointer;" @click="tableButton(2,scope.row)">{{ cleanRichText(scope.row.questionContent) }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="知识点" prop="knowledgePointNames" width="200" show-overflow-tooltip/>
  93. <el-table-column label="题型" prop="questionType" width="200" show-overflow-tooltip>
  94. <template slot-scope="scope">
  95. <span>{{ scope.row.questionType == 1?'单选题':(scope.row.questionType == 2?'多选题':(scope.row.questionType == 3?'判断题':'')) }}</span>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="难度" prop="content" width="200" show-overflow-tooltip>
  99. <template slot-scope="scope">
  100. <span>{{ scope.row.difficulty == 1?'简单':(scope.row.difficulty == 2?'一般':(scope.row.difficulty == 3?'较难':(scope.row.difficulty == 4?'极难':''))) }}</span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="是否共享" prop="content" width="200" show-overflow-tooltip>
  104. <template slot-scope="scope">
  105. <span style="padding:2px 10px;border:1px solid rgb(1, 131, 251);border-radius:4px;color: rgb(1, 131, 251);background-color:rgba(1, 131, 251,0.2)" v-if="scope.row.shareStatus == 1">共享</span>
  106. <span style="padding:2px 10px;border:1px solid rgb(245, 154, 35);border-radius:4px;color: rgb(245, 154, 35);background-color:rgba(245, 154, 35,0.2)" v-if="scope.row.shareStatus == 0">不共享</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="操作" width="200" show-overflow-tooltip v-if="tableButtonType">
  110. <template slot-scope="scope">
  111. <div class="table-button-box">
  112. <p class="table-button-null"></p>
  113. <p class="table-button-p"
  114. v-if="scope.row.canEditDelete"
  115. v-hasPermiRouter="['exam:elQuestionBank:edit']"
  116. @click="tableButton(3,scope.row)"
  117. >编辑</p>
  118. <p class="table-button-p"
  119. v-if="scope.row.canEditDelete"
  120. v-hasPermiRouter="['exam:elQuestionBank:del']"
  121. @click="tableButton(4,scope.row)"
  122. >删除</p>
  123. <p class="table-button-null"></p>
  124. </div>
  125. </template>
  126. </el-table-column>
  127. </el-table>
  128. <pagination :page-sizes="[20, 30, 40, 50]"
  129. v-show="total>0"
  130. :total="total"
  131. :page.sync="queryParams.page"
  132. :limit.sync="queryParams.pageSize"
  133. @pagination="getList"
  134. />
  135. </div>
  136. </div>
  137. <add-page :propsData="propsData" v-if="pageType === 2"></add-page>
  138. <el-drawer
  139. size="40%"
  140. custom-class="questionBankManagement-drawer"
  141. :append-to-body="true"
  142. :title="drawerTitle"
  143. ref="drawer"
  144. :visible.sync="drawer"
  145. direction="rtl"
  146. >
  147. <answerKey v-if="drawer" :answerKeyPropsData="answerKeyPropsData"></answerKey>
  148. </el-drawer>
  149. </div>
  150. </template>
  151. <script>
  152. //import { getDicts } from "@/api/commonality/noPermission";
  153. //import { systemUserSelect } from "@/api/commonality/permission";
  154. import { examElKnowledgePointTreeList,examElQuestionBankList,examElQuestionBankDel,examElDisciplineTypeList } from "@/api/safetyEducationExaminationNew/index";
  155. import importComponent from "@/components/importComponent/importComponent.vue";
  156. import answerKey from "@/views/safetyEducationExaminationNew/components/answerKey.vue";
  157. import addPage from "./addPage.vue";
  158. export default {
  159. name: 'index',
  160. components: {
  161. importComponent,
  162. addPage,
  163. answerKey,
  164. },
  165. data () {
  166. return {
  167. tableButtonType:this.hasPermiDom(['exam:elQuestionBank:edit','exam:elQuestionBank:del',]),
  168. //页面状态
  169. pageType:1,
  170. importConfig:{
  171. upLoadApi:'/exam/elQuestionBank/importData', //上传接口地址
  172. downloadApi:'/exam/elQuestionBank/importTemplate', //下载模板接口地址
  173. downloadCustomKey:null, //下载模板自定义参数KEY(非必填)
  174. downloadCustomValue:null, //下载模板自定义参数VALUE(非必填)
  175. loseApi:'/exam/elQuestionBank/exportErrorData', //失败报表接口地址
  176. loseCustomKey:null, //失败报表自定义参数KEY(非必填)
  177. loseCustomValue:null, //失败报表自定义参数VALUE(非必填)
  178. fileName:'导入模板-', //下载模板命名
  179. },
  180. //下拉列表数据
  181. optionListA:[{value:1,label:'共享'},{value:0,label:'不共享'}],
  182. optionListB:[],
  183. optionListC:[{value:1,label:'单选'},{value:2,label:'多选'},{value:3,label:'判断'}],
  184. optionListD:[{value:1,label:'简单'},{value:2,label:'一般'},{value:3,label:'较难'},{value:4,label:'极难'}],
  185. disciplineOptionList:[],
  186. //查询条件
  187. queryParams:{
  188. page:1,
  189. pageSize:20,
  190. shareStatus:null,
  191. knowledgePointId :null,
  192. disciplineTypeId: '',
  193. questionType :null,
  194. difficulty :null,
  195. questionContent :'',
  196. },
  197. //列表数据
  198. dataList:[],
  199. //数据数量
  200. total:0,
  201. //组件传参
  202. propsData:{},
  203. answerKeyPropsData:{},
  204. //弹窗相关
  205. drawerTitle: '',
  206. drawerType: '',
  207. drawer: false
  208. }
  209. },
  210. created () {
  211. },
  212. mounted () {
  213. this.examElKnowledgePointTreeList();
  214. this.examElDisciplineTypeList();
  215. this.getList();
  216. },
  217. methods: {
  218. //清洗富文本
  219. cleanRichText(htmlStr, maxLength = 50) {
  220. if (!htmlStr) return '';
  221. const tempDiv = document.createElement('div');
  222. tempDiv.innerHTML = htmlStr;
  223. let text = tempDiv.textContent || tempDiv.innerText || '';
  224. text = text.replace(/\s+/g, ' ').trim();
  225. if (maxLength && text.length > maxLength) {
  226. return text.substring(0, maxLength) + '...';
  227. }
  228. return text;
  229. },
  230. //查询按钮
  231. handleQuery(){
  232. this.$set(this.queryParams,'page',1);
  233. this.getList();
  234. },
  235. //重置按钮
  236. resetQuery(){
  237. this.$set(this,'queryParams',{
  238. page:1,
  239. pageSize:20,
  240. shareStatus:null,
  241. knowledgePointId :null,
  242. disciplineTypeId: '',
  243. questionType :null,
  244. difficulty :null,
  245. questionContent :'',
  246. });
  247. this.getList();
  248. },
  249. //获取数据列表
  250. getList(){
  251. let obj = JSON.parse(JSON.stringify(this.queryParams))
  252. examElQuestionBankList(obj).then(response => {
  253. this.$set(this,'dataList',response.data.records);
  254. this.$set(this,'total',response.data.total);
  255. });
  256. },
  257. //操作按钮
  258. tableButton(type,row){
  259. let self = this;
  260. if(type == 1){
  261. //新增
  262. this.$set(this,'pageType',2);
  263. this.$set(this,'propsData',{});
  264. }else if(type == 2){
  265. //预览
  266. this.$set(this, 'drawerTitle', '试题预览')
  267. this.$set(this, 'drawerType', 2)
  268. this.$set(this, 'drawer', true)
  269. this.$set(this,'answerKeyPropsData',{
  270. id:row.id,
  271. });
  272. }else if(type == 3){
  273. //编辑
  274. this.$set(this,'pageType',2);
  275. let obj = JSON.parse(JSON.stringify(row))
  276. this.$set(this,'propsData',obj);
  277. }else if(type == 4){
  278. //删除
  279. this.$confirm('是否确认删除?', "提示", {
  280. confirmButtonText: "确定",
  281. cancelButtonText: "取消",
  282. type: "warning"
  283. }).then(function() {
  284. }).then(() => {
  285. examElQuestionBankDel({ids:[row.id]}).then(response => {
  286. self.msgSuccess(response.message)
  287. self.getList();
  288. });
  289. }).catch(() => {});
  290. }else if(type == 6){
  291. //返回并刷新
  292. this.$set(this,'pageType',1);
  293. this.getList();
  294. }
  295. },
  296. examElKnowledgePointTreeList(){
  297. examElKnowledgePointTreeList({ dataScope:2 }).then(response => {
  298. const list = response.data || [];
  299. this.formatTreeData(list);
  300. this.$set(this, 'optionListB', list);
  301. });
  302. },
  303. //查询全部专业类别
  304. examElDisciplineTypeList(){
  305. examElDisciplineTypeList({}).then(response => {
  306. this.$set(this,'disciplineOptionList',response.data);
  307. });
  308. },
  309. },
  310. }
  311. </script>
  312. <style scoped lang="scss">
  313. .questionBankManagement{
  314. .questionBankManagementPage{
  315. }
  316. }
  317. </style>