index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <!-- 课件管理 -->
  2. <template>
  3. <div class="app-container coursewareManagement" :class="pageType != 1?'no-app-container':''">
  4. <div class="page-container coursewareManagementPage" 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. <div class="table-top-button-box">
  9. <div>
  10. <p :class="queryParams.shareStatus == ''?'check-table-button':''" @click="tableTypeButton('')">全部</p>
  11. <p :class="queryParams.shareStatus == '1'?'check-table-button':''" @click="tableTypeButton('1')">共享</p>
  12. <p :class="queryParams.shareStatus == '0'?'check-table-button':''" @click="tableTypeButton('0')">不共享</p>
  13. </div>
  14. </div>
  15. <el-form-item label="" prop="materialType">
  16. <el-select v-model="queryParams.materialType" placeholder="课件类型" style="width: 200px">
  17. <el-option
  18. v-for="dict in optionListA"
  19. :key="dict.value"
  20. :label="dict.label"
  21. :value="dict.value"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="" prop="knowledgePointId">
  26. <el-cascader
  27. style="width: 180px"
  28. v-model="queryParams.knowledgePointId"
  29. :options="optionListB"
  30. :props="{
  31. emitPath:false,
  32. checkStrictly: true,
  33. value: 'id',
  34. label: 'knowledgePointName',
  35. children: 'children',
  36. }"
  37. :show-all-levels="false"
  38. filterable
  39. placeholder="请选择知识点"
  40. ></el-cascader>
  41. </el-form-item>
  42. <el-form-item label="" prop="deptId">
  43. <el-select v-model="queryParams.deptId" placeholder="来源" style="width: 200px">
  44. <el-option
  45. v-for="dict in optionListC"
  46. :key="dict.deptId"
  47. :label="dict.deptName"
  48. :value="dict.deptId"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="" prop="searchValue">
  53. <el-input
  54. maxLength="30"
  55. v-model="queryParams.searchValue"
  56. placeholder="搜索名称"
  57. style="width: 200px"
  58. />
  59. </el-form-item>
  60. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  61. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  62. <p class="page-submit-common-style-button"
  63. style="float: right;"
  64. @click="tableButton(1)"
  65. v-hasPermiRouter="['exam:courseware:add']"
  66. >添加课件</p>
  67. </el-form>
  68. </div>
  69. <div class="page-content-box">
  70. <el-table class="table-box" v-loading="loading" border :data="dataList">
  71. <el-table-column label="课件名称" prop="coursewareName" show-overflow-tooltip>
  72. <template slot-scope="scope">
  73. <span @click="tableButton(2,scope.row)" style="color:#0183fa;cursor: pointer">{{scope.row.coursewareName}}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="知识点" prop="knowledgePointName" width="120" show-overflow-tooltip/>
  77. <!--<el-table-column label="专业类别" prop="content" width="100" show-overflow-tooltip/>-->
  78. <el-table-column label="是否共享" prop="shareStatus" width="100" show-overflow-tooltip>
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.shareStatus == 1" 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)">共享</span>
  81. <span v-if="scope.row.shareStatus == 0" 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)">不共享</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="课件类型" prop="materialType" width="100" show-overflow-tooltip>
  85. <template slot-scope="scope">
  86. {{scope.row.materialType == 1?'视频':(scope.row.materialType == 3?'文档':(scope.row.materialType == 4?'文章':''))}}
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="文件大小" prop="attachmentSize" width="100" show-overflow-tooltip>
  90. <template slot-scope="scope">
  91. {{scope.row.attachmentSize?scope.row.attachmentSize+'Mb':'-'}}
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="要求时长" prop="minLearningDuration" width="100" show-overflow-tooltip>
  95. <template slot-scope="scope">
  96. {{scope.row.minLearningDuration}}分钟
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="可得学时" prop="creditHours" width="100" show-overflow-tooltip/>
  100. <el-table-column label="可得积分" prop="points" width="100" show-overflow-tooltip/>
  101. <el-table-column label="来源" prop="deptName" width="100" show-overflow-tooltip/>
  102. <el-table-column label="创建人" prop="createName" width="100" show-overflow-tooltip/>
  103. <el-table-column label="创建时间" prop="createTime" width="160" show-overflow-tooltip>
  104. <template slot-scope="scope">
  105. <span>{{ parseTime(scope.row.createTime,"{y}-{m}-{d} {h}:{i}") }}</span>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="操作" width="200" show-overflow-tooltip v-if="tableButtonType">
  109. <template slot-scope="scope">
  110. <div class="table-button-box">
  111. <p class="table-button-null"></p>
  112. <p class="table-button-p"
  113. @click="tableButton(3,scope.row)"
  114. v-hasPermiRouter="['exam:courseware:edit']"
  115. >编辑</p>
  116. <p class="table-button-p"
  117. @click="tableButton(4,scope.row)"
  118. v-hasPermiRouter="['exam:courseware:del']"
  119. >删除</p>
  120. <p class="table-button-null"></p>
  121. </div>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <pagination :page-sizes="[20, 30, 40, 50]"
  126. v-show="total>0"
  127. :total="total"
  128. :page.sync="queryParams.page"
  129. :limit.sync="queryParams.pageSize"
  130. @pagination="getList"
  131. />
  132. </div>
  133. </div>
  134. <add-page :propsData="propsData" v-if="pageType === 2"></add-page>
  135. <fullScreenFileLook ref="fullScreenFileLook"></fullScreenFileLook>
  136. </div>
  137. </template>
  138. <script>
  139. import fullScreenFileLook from "@/components/fullScreenFileLook/fullScreenFileLook.vue";
  140. import {
  141. examElCoursewarePage,examElCoursewareDel,examElKnowledgePointTreeList,
  142. systemDeptCurrentDept,examElCoursewareDetail
  143. } from "@/api/safetyEducationExaminationNew/index";
  144. import addPage from "./addPage.vue";
  145. export default {
  146. name: 'index',
  147. components: {
  148. addPage,
  149. fullScreenFileLook
  150. },
  151. data () {
  152. return {
  153. tableButtonType:this.hasPermiDom(['exam:courseware:edit','exam:courseware:del',]),
  154. //页面状态
  155. pageType:1,
  156. //页面遮罩
  157. loading:false,
  158. //下拉列表数据
  159. optionListA:[{value:1,label:'视频'},{value:3,label:'文档'},{value:4,label:'文章'}],
  160. optionListB:[],
  161. optionListC:[],
  162. queryParams:{
  163. page:1,
  164. pageSize:20,
  165. searchValue:'',
  166. shareStatus:'',
  167. materialType:null,
  168. knowledgePointId :null,
  169. deptId :null,
  170. },
  171. //列表数据
  172. dataList:[],
  173. //数据数量
  174. total:0,
  175. //组件传参
  176. propsData:{},
  177. }
  178. },
  179. created () {
  180. },
  181. mounted () {
  182. this.systemDeptCurrentDept();
  183. this.examElKnowledgePointTreeList();
  184. this.getList();
  185. },
  186. methods: {
  187. //切换按钮
  188. tableTypeButton(val){
  189. if(this.queryParams.shareStatus != val){
  190. this.$set(this.queryParams,'shareStatus',val);
  191. this.handleQuery();
  192. }
  193. },
  194. //查询按钮
  195. handleQuery(){
  196. this.$set(this.queryParams,'page',1);
  197. this.getList();
  198. },
  199. //重置按钮
  200. resetQuery(){
  201. this.$set(this,'queryParams',{
  202. page:1,
  203. pageSize:20,
  204. searchValue:'',
  205. shareStatus:'',
  206. materialType:null,
  207. knowledgePointId :null,
  208. deptId :null,
  209. });
  210. this.getList();
  211. },
  212. //获取数据列表
  213. getList(){
  214. this.$set(this,'loading',true);
  215. let obj = JSON.parse(JSON.stringify(this.queryParams))
  216. examElCoursewarePage(obj).then(response => {
  217. this.$set(this,'loading',false);
  218. this.$set(this,'dataList',response.data.records);
  219. this.$set(this,'total',response.data.total);
  220. });
  221. },
  222. //操作按钮
  223. tableButton(type,row){
  224. let self = this;
  225. if(type == 1){
  226. //新增
  227. this.$set(this,'pageType',2);
  228. this.$set(this,'propsData',{});
  229. }else if(type == 2){
  230. //预览
  231. let name=row.coursewareName;
  232. let url='';
  233. let type='';
  234. if(row.materialType == 1){
  235. //视频
  236. type = 'video'
  237. url = row.attachmentPath;
  238. this.$refs['fullScreenFileLook'].initialize(name,url,type);
  239. }else if(row.materialType == 3){
  240. //文档
  241. if(row.attachmentType == '.docx'){
  242. type = 'docx'
  243. }else if(row.attachmentType == '.xlsx'){
  244. type = 'excel'
  245. }else if(row.attachmentType == '.pdf'){
  246. type = 'pdf'
  247. }
  248. url = row.attachmentPath;
  249. this.$refs['fullScreenFileLook'].initialize(name,url,type);
  250. }else if(row.materialType == 4){
  251. //富文本
  252. examElCoursewareDetail({id:row.id}).then(response => {
  253. type = 'text'
  254. url = response.data.articleContent;
  255. this.$refs['fullScreenFileLook'].initialize(name,url,type);
  256. });
  257. }
  258. }else if(type == 3){
  259. //编辑
  260. this.$set(this,'pageType',2);
  261. let obj = JSON.parse(JSON.stringify(row))
  262. this.$set(this,'propsData',obj);
  263. }else if(type == 4){
  264. //删除
  265. this.$confirm('是否确认删除?', "警告", {
  266. confirmButtonText: "确定",
  267. cancelButtonText: "取消",
  268. type: "warning"
  269. }).then(function() {
  270. }).then(() => {
  271. examElCoursewareDel({id:row.id}).then(response => {
  272. self.msgSuccess(response.message)
  273. self.getList();
  274. });
  275. }).catch(() => {});
  276. }else if(type == 6){
  277. //返回并刷新
  278. this.$set(this,'pageType',1);
  279. this.getList();
  280. }
  281. },
  282. //知识点
  283. examElKnowledgePointTreeList(){
  284. examElKnowledgePointTreeList({}).then(response => {
  285. const list = response.data || [];
  286. this.formatTreeData(list);
  287. this.$set(this, 'optionListB', list);
  288. });
  289. },
  290. //学院列表
  291. systemDeptCurrentDept(){
  292. systemDeptCurrentDept({}).then(response => {
  293. this.$set(this,'optionListC',response.data);
  294. });
  295. },
  296. formatTreeData(data) {
  297. data.forEach(item => {
  298. // 如果 children 存在,且是数组,且长度为 0(即 children: [])
  299. if (Array.isArray(item.children) && item.children.length === 0) {
  300. // 将 children 设为 undefined(或直接 delete item.children;)
  301. item.children = undefined;
  302. } else if (item.children && item.children.length > 0) {
  303. // 如果还有下一级,继续递归处理
  304. this.formatTreeData(item.children);
  305. }
  306. });
  307. },
  308. },
  309. }
  310. </script>
  311. <style scoped lang="scss">
  312. .no-app-container{
  313. border-radius:0 !important;
  314. margin:0 !important;
  315. box-shadow: none !important;
  316. }
  317. .coursewareManagement{
  318. .coursewareManagementPage{
  319. .table-top-button-box{
  320. display: inline-block;
  321. vertical-align: top;
  322. margin-right:10px;
  323. div{
  324. display: flex;
  325. p{
  326. border:1px solid #DCDFE6;
  327. width:80px;
  328. text-align: center;
  329. height:40px;
  330. line-height:40px;
  331. cursor: pointer;
  332. font-size:14px;
  333. }
  334. p:nth-child(1){
  335. border-top-left-radius:4px;
  336. border-bottom-left-radius:4px;
  337. }
  338. p:nth-child(2){
  339. border-left:none;
  340. border-right:none;
  341. }
  342. p:nth-child(3){
  343. border-top-right-radius:4px;
  344. border-bottom-right-radius:4px;
  345. }
  346. .check-table-button{
  347. border:1px solid #0183fa;
  348. background-color: #0183fa;
  349. color:#fff;
  350. }
  351. }
  352. }
  353. }
  354. }
  355. </style>