edit.vue 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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
  7. size="mini"
  8. type="primary" @click="goLast">继续排课</el-button>
  9. </div>
  10. <ul>
  11. <li>
  12. <el-input
  13. placeholder="请输入课程名称"
  14. v-model="postData.name"
  15. >
  16. </el-input>
  17. </li>
  18. </ul>
  19. <el-button
  20. size="mini"
  21. type="primary" @click="search">搜索</el-button>
  22. </div>
  23. <div class="moreFilter"></div>
  24. </div>
  25. <div class="system-table-box">
  26. <el-table
  27. :data="schedules.list"
  28. stripe
  29. style="width: 100%">
  30. <el-table-column
  31. prop="CourseName"
  32. label="课程名称">
  33. </el-table-column>
  34. <el-table-column
  35. prop="Price"
  36. label="课程价格">
  37. </el-table-column>
  38. <el-table-column
  39. prop="CourseNum"
  40. label="课时数">
  41. </el-table-column>
  42. <el-table-column
  43. prop="ScheduleNum"
  44. label="已排课时数">
  45. </el-table-column>
  46. <el-table-column
  47. label="课程类别"
  48. width="150">
  49. <template slot-scope="scope">
  50. <label>{{getLocationName(scope.row.LocationId)}}</label>
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. label="所在案场"
  55. width="150">
  56. <template slot-scope="scope">
  57. <label>{{getCaseName(scope.row.CaseId)}}</label>
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. label="操作">
  62. <template slot-scope="scope">
  63. <el-button
  64. size="mini"
  65. type="success"
  66. @click="setCourseDate(scope.row)">设置课程时间</el-button>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. </div>
  71. <el-pagination
  72. @current-change="handleCurrentChange"
  73. :current-page.sync="postData.page"
  74. :page-size="postData.pagesize"
  75. layout="prev, pager, next, jumper"
  76. :total="schedules.pagenum">
  77. </el-pagination>
  78. <el-dialog
  79. title="设置课时时间"
  80. :visible.sync="centerDialogVisible"
  81. width="500px"
  82. center>
  83. <div>
  84. <ul class="courseDetailForm">
  85. <li class="flex-h">
  86. <span>开始时间:</span>
  87. <div class="flex-item">
  88. <div>
  89. <el-time-picker
  90. v-model="currentCourseItem.BeginDate"
  91. value-format="HH:mm:ss"
  92. placeholder="选择开始日期">
  93. </el-time-picker>
  94. </div>
  95. </div>
  96. </li>
  97. <li class="flex-h">
  98. <span>结束时间:</span>
  99. <div class="flex-item">
  100. <div>
  101. <el-time-picker
  102. v-model="currentCourseItem.EndDate"
  103. value-format="HH:mm:ss"
  104. placeholder="选择结束日期">
  105. </el-time-picker>
  106. </div>
  107. </div>
  108. </li>
  109. <li class="flex-h">
  110. <span>课时名称:</span>
  111. <div class="flex-item">
  112. <div>
  113. <el-input
  114. placeholder="请输入课时名称"
  115. v-model="currentCourseItem.DetailName"
  116. clearable>
  117. </el-input>
  118. </div>
  119. </div>
  120. </li>
  121. <li class="flex-h">
  122. <span>课时描述:</span>
  123. <div class="flex-item">
  124. <div>
  125. <el-input
  126. type="textarea"
  127. placeholder="请输入课时描述"
  128. v-model="currentCourseItem.DetailDesc"
  129. clearable>
  130. </el-input>
  131. </div>
  132. </div>
  133. </li>
  134. </ul>
  135. </div>
  136. <span slot="footer" class="dialog-footer">
  137. <el-button type="primary" @click="handleDetailSave">确 定</el-button>
  138. <el-button type="danger" @click="centerDialogVisible = false">取 消</el-button>
  139. </span>
  140. </el-dialog>
  141. </div>
  142. </template>
  143. <script>
  144. import { createNamespacedHelpers, mapState } from 'vuex'
  145. const { mapState: mapScheduleState, mapActions: mapScheduleActions } = createNamespacedHelpers('schedule')
  146. const { mapState: mapLocationState, mapActions: mapLocationActions } = createNamespacedHelpers('cms')
  147. export default {
  148. name: '',
  149. data () {
  150. return {
  151. currentCourseItem: { // 当前设置课程时间
  152. BeginDate: null,
  153. EndDate: null,
  154. DetailName: null,
  155. DetailDesc: null,
  156. CourseId: '',
  157. },
  158. centerDialogVisible: false,
  159. postData: { // 表格搜索条件
  160. caseid: '', // 案场id
  161. page: 1, // 当前页码
  162. pagesize: 10, // 请求数据量
  163. name: '', // 课程名称
  164. date: '',
  165. courseid: '',
  166. },
  167. }
  168. },
  169. mounted () {
  170. const { date, caseid, courseid } = this.$route.query
  171. if (!date || date === '') {
  172. this.$message({
  173. type: 'error',
  174. message: '请先选择排课时间'
  175. })
  176. this.$router.push({ name: 'scheduleManager', query: { courseid: courseid } })
  177. }
  178. if ((!courseid && courseid === '') && (!caseid || caseid === '')) {
  179. this.$message({
  180. type: 'error',
  181. message: '请先选择排课案场'
  182. })
  183. this.$router.push({ name: 'scheduleManager' })
  184. }
  185. this.postData.date = date
  186. this.postData.caseid = caseid
  187. this.postData.courseid = courseid
  188. this.updateLocationInfo()
  189. this.$nextTick(function () {
  190. this.getList()
  191. })
  192. },
  193. computed: {
  194. ...mapScheduleState({
  195. schedules: x => x.scheduleList
  196. }),
  197. ...mapState({
  198. cases: x => x.app.cases.list,
  199. orgid: x => x.app.user.OrgId,
  200. }),
  201. ...mapLocationState({
  202. location: x => x.location
  203. }),
  204. },
  205. methods: {
  206. ...mapScheduleActions([
  207. 'GetScheduleList',
  208. 'AddDetail'
  209. ]),
  210. ...mapLocationActions([
  211. 'updateLocationInfo',
  212. ]),
  213. getLocationName (id) {
  214. return (this.location.filter(x => x.LocationId === id)[0] || {}).LocationName
  215. },
  216. getCaseName (id) {
  217. return (this.cases.filter(x => x.CaseId === id)[0] || {}).CaseName
  218. },
  219. setCourseDate (row) { // 设置课程时间
  220. this.currentCourseItem.CourseId = row.CourseId
  221. this.currentCourseItem.BeginDate = null
  222. this.currentCourseItem.EndDate = null
  223. this.currentCourseItem.DetailName = null
  224. this.currentCourseItem.DetailDesc = null
  225. this.centerDialogVisible = true
  226. },
  227. search () { // 搜索
  228. this.postData.page = 1
  229. this.getList()
  230. },
  231. getList () { // 获取列表
  232. this.GetScheduleList({...this.postData})
  233. },
  234. handleCurrentChange (val) { // 跳转到分页
  235. this.getList()
  236. },
  237. handleDetailSave () {
  238. const item = {...this.currentCourseItem,
  239. OrgId: this.orgid,
  240. CaseId: this.postData.caseid,
  241. BeginDate: this.postData.date + 'T' + this.currentCourseItem.BeginDate,
  242. EndDate: this.postData.date + 'T' + this.currentCourseItem.EndDate,
  243. callback: this.afterSave
  244. }
  245. this.AddDetail(item)
  246. },
  247. afterSave () {
  248. this.$message({
  249. type: 'success',
  250. message: '操作成功!'
  251. })
  252. this.search()
  253. this.centerDialogVisible = false
  254. },
  255. goLast () {
  256. const { courseid } = this.$route.query
  257. this.$router.push({name: 'scheduleManager', query: {id: courseid}})
  258. }
  259. }
  260. }
  261. </script>
  262. <!-- Add "scoped" attribute to limit CSS to this component only -->
  263. <style lang="scss" scoped>
  264. @import "page.scss";
  265. </style>