index.vue 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div class="subPage">
  3. <div class="system-table-search">
  4. <div class="flex-h">
  5. <div class="flex-item flex-h">
  6. <el-button size="mini" type="success" @click="addCourse">新增课程</el-button>
  7. </div>
  8. <ul>
  9. <li>
  10. <!-- <span>选择案场:</span> -->
  11. <el-select v-model="postData.caseid" placeholder="请选择案场">
  12. <el-option
  13. key=""
  14. label=""
  15. value=""
  16. >
  17. </el-option>
  18. <el-option
  19. v-for="item in cases"
  20. :key="item.CaseId"
  21. :label="item.CaseName"
  22. :value="item.CaseId">
  23. </el-option>
  24. </el-select>
  25. </li>
  26. <li>
  27. <el-select v-model="postData.typeid" placeholder="课程分类">
  28. <el-option
  29. key=""
  30. label=""
  31. value=""
  32. >
  33. </el-option>
  34. <el-option
  35. v-for="item in location"
  36. :key="item.LocationId"
  37. :label="item.LocationName"
  38. :value="item.LocationId">
  39. </el-option>
  40. </el-select>
  41. </li>
  42. <li>
  43. <el-input
  44. placeholder="请输入课程名称"
  45. v-model="postData.name"
  46. >
  47. </el-input>
  48. </li>
  49. </ul>
  50. <el-button
  51. size="mini"
  52. type="primary" @click="search">搜索</el-button>
  53. </div>
  54. <div class="moreFilter"></div>
  55. </div>
  56. <div class="system-table-box">
  57. <el-table
  58. :data="courses.list"
  59. stripe
  60. style="width: 100%">
  61. <el-table-column
  62. prop="CourseName"
  63. label="发布状态"
  64. width="150">
  65. <template slot-scope="scope">
  66. <label>{{scope.row.Status===1?'已发布':'未发布'}}</label>
  67. </template>
  68. </el-table-column>
  69. <el-table-column
  70. prop="CourseName"
  71. label="课程名称"
  72. width="150">
  73. </el-table-column>
  74. <el-table-column
  75. prop="Price"
  76. label="课程价格"
  77. width="150">
  78. </el-table-column>
  79. <el-table-column
  80. label="课程类别"
  81. width="150">
  82. <template slot-scope="scope">
  83. <label>{{getLocationName(scope.row.LocationId)}}</label>
  84. </template>
  85. </el-table-column>
  86. <el-table-column
  87. label="所在案场"
  88. width="150">
  89. <template slot-scope="scope">
  90. <label>{{getCaseName(scope.row.CaseId)}}</label>
  91. </template>
  92. </el-table-column>
  93. <el-table-column
  94. prop="BeginDate"
  95. label="课程开始时间"
  96. width="150">
  97. <template slot-scope="scope">
  98. <label>{{FormatDate(scope.row.BeginDate)}}</label>
  99. </template>
  100. </el-table-column>
  101. <el-table-column
  102. prop="EndDate"
  103. label="课程结束时间"
  104. width="150">
  105. <template slot-scope="scope">
  106. <label>{{FormatDate(scope.row.EndDate)}}</label>
  107. </template>
  108. </el-table-column>
  109. <el-table-column
  110. fixed="right"
  111. label="操作"
  112. width="600">
  113. <template slot-scope="scope">
  114. <el-button
  115. size="mini"
  116. type="success">添加课程详情</el-button>
  117. <el-button
  118. size="mini"
  119. type="warning"
  120. v-if="scope.row.Status===0"
  121. >排课</el-button>
  122. <el-button
  123. size="mini"
  124. type="primary"
  125. @click="handleCopy(scope.row)"
  126. >复制课程</el-button>
  127. <el-button
  128. size="mini"
  129. type="warning"
  130. @click="handlePublic(scope.row)"
  131. v-if="scope.row.Status===0"
  132. >发布</el-button>
  133. <el-button
  134. size="mini"
  135. type="danger"
  136. @click="handleUnPublic(scope.row)"
  137. v-if="scope.row.Status===1"
  138. >取消发布</el-button>
  139. <el-button
  140. size="mini"
  141. type="warning"
  142. v-if="scope.row.Status===0"
  143. @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  144. <el-button
  145. size="mini"
  146. type="danger"
  147. v-if="scope.row.Status===0"
  148. @click="handleDelete(scope.$index, scope.row)">删除</el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. </div>
  153. <el-pagination
  154. @current-change="handleCurrentChange"
  155. :current-page.sync="courses.page"
  156. :page-size="courses.pagesize"
  157. layout="prev, pager, next, jumper"
  158. :total="courses.pagenum">
  159. </el-pagination>
  160. </div>
  161. </template>
  162. <script>
  163. import { createNamespacedHelpers, mapState } from 'vuex'
  164. const { mapState: mapCourseState, mapActions: mapCourseActions } = createNamespacedHelpers('course')
  165. const { mapState: mapLocationState, mapActions: mapLocationActions } = createNamespacedHelpers('cms')
  166. export default {
  167. name: '',
  168. data () {
  169. return {
  170. total: 0,
  171. postData: { // 表格搜索条件
  172. caseid: '', // 案场id
  173. page: 1, // 当前页码
  174. pagesize: 10, // 请求数据量
  175. typeid: '', // 课程类型
  176. name: '', // 课程名称
  177. },
  178. courseTypeList: [],
  179. }
  180. },
  181. mounted () {
  182. this.updateLocationInfo({ pagesize: 100 })
  183. this.$nextTick(function () {
  184. this.getList()
  185. })
  186. },
  187. computed: {
  188. ...mapState({
  189. cases: x => x.app.cases.list,
  190. defaultCaseId: x => x.app.cases.default
  191. }),
  192. ...mapCourseState({
  193. courses: x => x.courseList,
  194. }),
  195. ...mapLocationState({
  196. location: x => x.location
  197. }),
  198. CaseId: {
  199. get () {
  200. return this.postData.caseid || this.defaultCaseId
  201. },
  202. set (val) {
  203. this.postData.caseid = val
  204. }
  205. }
  206. },
  207. methods: {
  208. ...mapCourseActions([
  209. 'GetCourseList',
  210. 'Public',
  211. 'UnPublic',
  212. 'DelCourse',
  213. 'SetNull',
  214. 'GetCourseByID'
  215. ]),
  216. ...mapLocationActions([
  217. 'updateLocationInfo',
  218. ]),
  219. getLocationName (id) {
  220. return (this.location.filter(x => x.LocationId === id)[0] || {}).LocationName
  221. },
  222. getCaseName (id) {
  223. return (this.cases.filter(x => x.CaseId === id)[0] || {}).CaseName
  224. },
  225. FormatDate (date) {
  226. return this.toolClass.dateFormat(date, 'yyyy-mm-dd')
  227. },
  228. search () { // 搜索
  229. this.postData.page = 1
  230. this.currentList = []
  231. this.getList()
  232. },
  233. getList () { // 获取列表
  234. this.GetCourseList(this.postData)
  235. },
  236. handleCurrentChange (val) { // 跳转到分页
  237. this.getList()
  238. },
  239. handleEdit (index, row) { // 编辑
  240. this.$router.push({ name: 'addCourse', query: { id: row.CourseId } })
  241. },
  242. handleDelete (index, row) { // 删除
  243. this.$confirm('确认删除此课程?', '提示', {
  244. confirmButtonText: '确定',
  245. cancelButtonText: '取消',
  246. type: 'warning'
  247. })
  248. .then(() => {
  249. this.DelCourse({id: row.CourseId, callback: this.delCallBack})
  250. })
  251. .catch(() => {
  252. this.$message({
  253. type: 'info',
  254. message: '已取消删除'
  255. })
  256. })
  257. },
  258. actionCallBack () {
  259. this.$message({
  260. type: 'success',
  261. message: '操作成功!'
  262. })
  263. this.getList()
  264. },
  265. delCallBack () {
  266. this.$message({
  267. type: 'success',
  268. message: '删除成功!'
  269. })
  270. this.getList()
  271. },
  272. addCourse () {
  273. this.SetNull()
  274. this.$router.push({ name: 'addCourse' })
  275. },
  276. handlePublic (row) {
  277. this.$confirm('确认发布此课程?', '提示', {
  278. confirmButtonText: '确定',
  279. cancelButtonText: '取消',
  280. type: 'warning'
  281. })
  282. .then(() => {
  283. this.Public({ id: row.CourseId, callback: this.actionCallBack })
  284. })
  285. },
  286. handleUnPublic (row) {
  287. this.$confirm('确认取消发布此课程?', '提示', {
  288. confirmButtonText: '确定',
  289. cancelButtonText: '取消',
  290. type: 'warning'
  291. })
  292. .then(() => {
  293. this.UnPublic({ id: row.CourseId, callback: this.actionCallBack })
  294. })
  295. },
  296. handleCopy (row) {
  297. this.GetCourseByID({ id: row.CourseId })
  298. this.$router.push({ name: 'addCourse' })
  299. }
  300. }
  301. }
  302. </script>
  303. <!-- Add "scoped" attribute to limit CSS to this component only -->
  304. <style lang="scss" scoped>
  305. @import "page.scss";
  306. </style>