LiveCourse.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div class="manage-root recorded-manage">
  3. <Header />
  4. <div class="manage-root-contain">
  5. <nav-menu class="manage-root-contain-left" :activeMenuIndex="activeMenuIndex"></nav-menu>
  6. <div class="manage-root-contain-right personnel-manage-right">
  7. <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
  8. <div class="personal-inner">
  9. <div class="common-title-box">
  10. <h3>直播课</h3>
  11. <div class="btn-box">
  12. <el-button type="primary" size="small" @click="handleEdit()">创建课程</el-button>
  13. </div>
  14. </div>
  15. <div class="search-box">
  16. <div class="search-item">
  17. <label>搜索</label>
  18. <el-input
  19. placeholder="输入搜索内容"
  20. v-model="searchInput" maxlength="200">
  21. <i slot="suffix" class="el-input__icon el-icon-search" @click="getList(1)" style="cursor: pointer;"></i>
  22. </el-input>
  23. </div>
  24. <div class="search-item">
  25. <label>状态</label>
  26. <el-select v-model="searchStatus" @change="getList(1)" placeholder="请选择">
  27. <el-option
  28. v-for="item in $checkStatusList"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value">
  32. </el-option>
  33. </el-select>
  34. </div>
  35. </div>
  36. <el-table
  37. class="search-table"
  38. :data="tableData"
  39. style="width: 100%"
  40. @sort-change="handleSort"
  41. :default-sort = dataSort
  42. :max-height="tableHeight"
  43. v-loading="tableLoading">
  44. <el-table-column
  45. type="index"
  46. label="#"
  47. sortable
  48. width="64"
  49. :index="(pageNumber-1)*pageSize+1">
  50. </el-table-column>
  51. <el-table-column
  52. prop="name"
  53. label="名称"
  54. sortable="custom"
  55. min-width="128">
  56. </el-table-column>
  57. <el-table-column
  58. prop="teacher_name_desc"
  59. label="教师"
  60. width="150"
  61. sortable="custom">
  62. </el-table-column>
  63. <el-table-column
  64. prop="price_discount"
  65. label="价格"
  66. width="154"
  67. sortable="custom">
  68. <template slot-scope="scope">
  69. <span class="currectPrice">¥{{scope.row.price_discount | cutMoneyFiter}}</span>
  70. <span class="oldPrice" v-if="scope.row.price!==scope.row.price_discount">(¥{{scope.row.price | cutMoneyFiter}})</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. prop="status"
  75. label="状态"
  76. width="104" >
  77. <template slot-scope="scope">
  78. <div class="status-box">
  79. <span :style="{background:$checkStatusColorList[scope.row.status].bg}"></span>
  80. <b :style="{color:$checkStatusColorList[scope.row.status].color}">{{$checkStatusColorList[scope.row.status].text}}</b>
  81. </div>
  82. </template>
  83. </el-table-column>
  84. <el-table-column
  85. prop="creator_name"
  86. label="创建人"
  87. width="100"
  88. sortable="custom">
  89. </el-table-column>
  90. <el-table-column
  91. prop="create_time"
  92. label="创建时间"
  93. sortable="custom"
  94. width="160">
  95. <template slot-scope="scope">
  96. {{scope.row.create_time?scope.row.create_time.substring(0,16):'-'}}
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. fixed="right"
  101. label="操作"
  102. width="150">
  103. <template slot-scope="scope">
  104. <el-button
  105. @click.native.prevent="handleEdit(scope.row)"
  106. type="text"
  107. size="small"
  108. class="primary-btn">
  109. 编辑
  110. </el-button>
  111. <el-button
  112. @click.native.prevent="handleCheck(scope.row, scope.$index)"
  113. type="text"
  114. size="small"
  115. class="primary-btn"
  116. v-if="scope.row.status===0||scope.row.status===3">
  117. 审核
  118. </el-button>
  119. <el-button
  120. @click.native.prevent="handleUp(scope.row, scope.$index)"
  121. type="text"
  122. size="small"
  123. class="primary-btn"
  124. v-if="scope.row.status===1">
  125. 上架
  126. </el-button>
  127. <el-button
  128. @click.native.prevent="handleUp(scope.row, scope.$index)"
  129. type="text"
  130. size="small"
  131. class="red-btn"
  132. v-else-if="scope.row.status===2">
  133. 下架
  134. </el-button>
  135. <el-button
  136. @click.native.prevent="handleDelete(scope.row, scope.$index)"
  137. type="text"
  138. size="small"
  139. class="red-btn">
  140. 删除
  141. </el-button>
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. <el-pagination
  146. background
  147. @size-change="handleSizeChange"
  148. @current-change="handleCurrentChange"
  149. :current-page="pageNumber"
  150. :page-sizes="[10, 20, 30, 40]"
  151. :page-size="pageSize"
  152. layout="total, prev, pager, next, sizes, jumper"
  153. :total="total_count">
  154. </el-pagination>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. </template>
  160. <script>
  161. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  162. //例如:import 《组件名称》from ‘《组件路径》';
  163. import Header from "../../../components/Header.vue";
  164. import NavMenu from "../../../components/NavMenu.vue"
  165. import Breadcrumb from '../../../components/Breadcrumb.vue';
  166. import { cutMoneyFiter } from '@/utils/defined';
  167. import { getLogin } from "@/api/ajax";
  168. import { mapState } from 'vuex';
  169. export default {
  170. //import引入的组件需要注入到对象中才能使用
  171. components: { Header, NavMenu, Breadcrumb },
  172. props: {},
  173. filters:{
  174. cutMoneyFiter
  175. },
  176. data() {
  177. //这里存放数据
  178. return {
  179. activeMenuIndex: "live_course",
  180. breadcrumbList:[
  181. {
  182. icon:'file-list-line',
  183. url:'',
  184. text:''
  185. },
  186. {
  187. icon:'',
  188. url:'',
  189. notLink: true,
  190. text:'内容管理'
  191. },
  192. {
  193. icon:'',
  194. url:'',
  195. notLink: true,
  196. text:'课程管理'
  197. },
  198. {
  199. icon:'',
  200. url:'',
  201. text:'直播课'
  202. }
  203. ],
  204. searchInput:'',
  205. searchStatus: -1,
  206. tableData:[],
  207. pageSize: window.localStorage.getItem('pageSize')?Number(window.localStorage.getItem('pageSize')):10,
  208. pageNumber: window.localStorage.getItem('pageNumber')?Number(window.localStorage.getItem('pageNumber')):1,
  209. tableHeight: "", // 表格高度
  210. total_count: 0,
  211. dataSort: {},
  212. tableLoading: false
  213. }
  214. },
  215. //计算属性 类似于data概念
  216. computed: {
  217. ...mapState(['$checkStatusList', '$checkStatusColorList']),
  218. },
  219. //监控data中数据变化
  220. watch: {},
  221. //方法集合
  222. methods: {
  223. handleSort(value){
  224. let dataSort = {
  225. prop: value.prop,
  226. order: value.order
  227. }
  228. this.dataSort = dataSort
  229. this.getList()
  230. },
  231. // 查询列表
  232. getList(page){
  233. this.tableLoading = true
  234. if(page){
  235. this.pageNumber = page
  236. }
  237. let MethodName = "/CourseServer/Manager/PageQuery/PageQueryZBCourseList";
  238. let order_column_list = []
  239. if(this.dataSort != {}){
  240. if(this.dataSort.order=='descending'){
  241. order_column_list = [this.dataSort.prop + ':desc']
  242. }else if(this.dataSort.order=='ascending'){
  243. // 升序不传值
  244. order_column_list = [this.dataSort.prop]
  245. }else{
  246. order_column_list = ['create_time:desc']
  247. }
  248. }else{
  249. order_column_list = ['create_time:desc']
  250. }
  251. let data = {
  252. search_content: this.searchInput.trim(),
  253. status: this.searchStatus,
  254. page_capacity:this.pageSize,
  255. cur_page:this.pageNumber,
  256. order_column_list: order_column_list
  257. }
  258. getLogin(MethodName, data)
  259. .then((res) => {
  260. this.tableLoading = false
  261. if(res.status===1){
  262. this.tableData = res.zb_course_list
  263. this.total_count = res.total_count
  264. }
  265. })
  266. .catch(() => {
  267. this.tableLoading = false
  268. });
  269. },
  270. // 创建机构或者编辑信息
  271. handleEdit(row){
  272. // 根据登录用户判断当前用户是不是超管 在table里加上disabled
  273. // 点击时记录页码和每页条数
  274. window.localStorage.setItem('pageSize',this.pageSize)
  275. window.localStorage.setItem('pageNumber',this.pageNumber)
  276. this.$router.push({
  277. path: "/createLive",
  278. query: {
  279. id: row?row.id:''
  280. },
  281. });
  282. },
  283. // 停用 启用
  284. handleUp(row, index) {
  285. let Mname = "/CourseServer/Manager/ZBCourseManager/ShelveZBCourse";
  286. let updataData = JSON.parse(JSON.stringify(row));
  287. let data = {
  288. id: row.id
  289. };
  290. if (row.status === 1) {
  291. // 下架状态
  292. data.is_pass = "true";
  293. updataData.status = 2;
  294. } else if (row.status === 2) {
  295. data.is_pass = "false";
  296. updataData.status = 1;
  297. }
  298. getLogin(Mname, data).then(res => {
  299. this.$message.success("操作成功");
  300. this.$set(this.tableData, index, updataData);
  301. });
  302. },
  303. // 删除
  304. handleDelete(row){
  305. this.$confirm('确定删除吗?', '提示', {
  306. confirmButtonText: '确定',
  307. cancelButtonText: '取消',
  308. type: 'warning'
  309. }).then(() => {
  310. let Mname = "/CourseServer/Manager/ZBCourseManager/DeleteZBCourse";
  311. let data = {
  312. id: row.id,
  313. is_force_delete: "true"
  314. };
  315. getLogin(Mname, data).then(res => {
  316. this.$message({
  317. type: 'success',
  318. message: '删除成功!'
  319. });
  320. this.getList()
  321. });
  322. }).catch(() => {
  323. });
  324. },
  325. // 审核
  326. handleCheck(row, index){
  327. let Mname = "/CourseServer/Manager/ZBCourseManager/AuditZBCourse";
  328. let updataData = JSON.parse(JSON.stringify(row));
  329. let data = {
  330. id: row.id
  331. };
  332. this.$confirm('审核', '', {
  333. confirmButtonText: '审核通过',
  334. cancelButtonText: '驳回',
  335. showClose: false,
  336. type: 'warning'
  337. }).then(() => {
  338. data.is_pass = "true";
  339. updataData.status = 1;
  340. getLogin(Mname, data).then(res => {
  341. this.$message.success("已审核通过");
  342. this.$set(this.tableData, index, updataData);
  343. });
  344. }).catch(() => {
  345. data.is_pass = "false";
  346. updataData.status = 3;
  347. getLogin(Mname, data).then(res => {
  348. this.$message.success("已驳回");
  349. this.$set(this.tableData, index, updataData);
  350. });
  351. });
  352. },
  353. handleSizeChange(val) {
  354. this.pageSize = val
  355. this.pageNumber = 1
  356. this.getList()
  357. },
  358. handleCurrentChange(val) {
  359. this.pageNumber = val
  360. this.getList()
  361. },
  362. //计算table高度(动态设置table高度)
  363. getTableHeight() {
  364. let tableH = 370; //距离页面下方的高度
  365. let tableHeightDetil = window.innerHeight - tableH;
  366. if (tableHeightDetil <= 300) {
  367. this.tableHeight = 300;
  368. } else {
  369. this.tableHeight = window.innerHeight - tableH;
  370. }
  371. },
  372. },
  373. //生命周期 - 创建完成(可以访问当前this实例)
  374. created() {
  375. this.getTableHeight();
  376. this.getList()
  377. },
  378. //生命周期 - 挂载完成(可以访问DOM元素)
  379. mounted() {
  380. let _this = this
  381. let input = document.querySelector('input');
  382. input.addEventListener('keyup', function(event) {
  383. // 判断是否按下回车键
  384. if (event.keyCode === 13) {
  385. // 回车键被按下,执行你想要的操作
  386. _this.getList(1)
  387. }
  388. });
  389. },
  390. //生命周期-创建之前
  391. beforeCreated() { },
  392. //生命周期-挂载之前
  393. beforeMount() { },
  394. //生命周期-更新之前
  395. beforUpdate() { },
  396. //生命周期-更新之后
  397. updated() { },
  398. //生命周期-销毁之前
  399. beforeDestory() { },
  400. //生命周期-销毁完成
  401. destoryed() { },
  402. //如果页面有keep-alive缓存功能,这个函数会触发
  403. activated() { }
  404. }
  405. </script>
  406. <style lang="scss" scoped>
  407. /* @import url(); 引入css类 */
  408. .teacher-list{
  409. margin: 0;
  410. overflow:hidden;
  411. text-overflow:ellipsis;
  412. white-space: nowrap;
  413. }
  414. .currectPrice{
  415. color: #D85555;
  416. font-weight: 500;
  417. margin-right: 4px;
  418. }
  419. .oldPrice{
  420. color: #A7A7A7;
  421. font-weight: 500;
  422. }
  423. </style>