index.vue 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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="addSchedule">新增排课</el-button> -->
  7. </div>
  8. <ul v-if="courseid===''">
  9. <li>
  10. <el-select v-model="CaseId" placeholder="请选择案场">
  11. <el-option
  12. v-for="item in cases"
  13. :key="item.CaseId"
  14. :label="item.CaseName"
  15. :value="item.CaseId">
  16. </el-option>
  17. </el-select>
  18. </li>
  19. </ul>
  20. </div>
  21. <div class="moreFilter"></div>
  22. <full-calendar :events="fcEvents" @changeMonth="changeMonth" locale="en" @eventClick="eventClick" @dayClick="dayClick"></full-calendar>
  23. </div>
  24. <el-dialog
  25. title="课时信息"
  26. :visible.sync="centerDialogVisible"
  27. width="500px"
  28. center>
  29. <div>
  30. <ul class="courseDetailForm">
  31. <li class="flex-h">
  32. <span>案场名称:</span>
  33. <span>{{currentCourseItem.CaseName}}</span>
  34. </li>
  35. <li class="flex-h">
  36. <span>案场地址:</span>
  37. <span>{{currentCourseItem.CaseAddress}}</span>
  38. </li>
  39. <li class="flex-h">
  40. <span>课程名称:</span>
  41. <span>{{currentCourseItem.CourseName}}</span>
  42. </li>
  43. <li class="flex-h">
  44. <span>课时名称:</span>
  45. <div class="flex-item">
  46. <div>
  47. <el-input
  48. v-if="currentCourseItem.CourseStatus===0"
  49. placeholder="请输入课时名称"
  50. v-model="currentCourseItem.DetailName"
  51. clearable>
  52. </el-input>
  53. <span v-else>{{currentCourseItem.DetailName}}</span>
  54. </div>
  55. </div>
  56. </li>
  57. <li class="flex-h">
  58. <span>课时简介:</span>
  59. <div class="flex-item">
  60. <div>
  61. <el-input
  62. v-if="currentCourseItem.CourseStatus===0"
  63. type="textarea"
  64. placeholder="请输入课时简介"
  65. v-model="currentCourseItem.DetailDesc"
  66. clearable>
  67. </el-input>
  68. <span v-else>{{currentCourseItem.DetailDesc}}</span>
  69. </div>
  70. </div>
  71. </li>
  72. <li class="flex-h">
  73. <span>开始时间:</span>
  74. <!-- <div class="flex-item" v-if="currentCourseItem.CourseStatus===0">
  75. <div>
  76. <el-date-picker
  77. v-if="currentCourseItem.CourseStatus===0"
  78. v-model="currentCourseItem.BeginDate"
  79. type="datetime"
  80. placeholder="选择开始日期"
  81. >
  82. </el-date-picker>
  83. <span v-else>{{this.toolClass.dateFormat(currentCourseItem.BeginDate, 'yyyy-MM-dd hh:mm')}}</span>
  84. </div>
  85. </div> -->
  86. <span>{{this.toolClass.dateFormat(currentCourseItem.BeginDate, 'yyyy-MM-dd hh:mm:ss')}}</span>
  87. </li>
  88. <li class="flex-h">
  89. <span>结束时间:</span>
  90. <!-- <div class="flex-item" v-if="currentCourseItem.CourseStatus===0">
  91. <div>
  92. <el-date-picker
  93. v-if="currentCourseItem.CourseStatus===0"
  94. v-model="currentCourseItem.EndDate"
  95. type="datetime"
  96. placeholder="选择结束日期">
  97. </el-date-picker>
  98. <span v-else>{{this.toolClass.dateFormat(currentCourseItem.EndDate, 'yyyy-MM-dd hh:mm')}}</span>
  99. </div>
  100. </div> -->
  101. <span>{{this.toolClass.dateFormat(currentCourseItem.EndDate, 'yyyy-MM-dd hh:mm:ss')}}</span>
  102. </li>
  103. </ul>
  104. </div>
  105. <span slot="footer" class="dialog-footer" v-if="currentCourseItem.CourseStatus===0">
  106. <el-button type="danger" @click="handlDelDetail">删除该课时</el-button>
  107. <el-button type="primary" @click="handlUpdateDetail">确 定</el-button>
  108. </span>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import { createNamespacedHelpers, mapState } from 'vuex'
  114. import fullCalendar from 'vue-fullcalendar'
  115. const { mapState: mapScheduleState, mapActions: mapScheduleActions } = createNamespacedHelpers('schedule')
  116. export default {
  117. name: '',
  118. data () {
  119. return {
  120. caseid: '',
  121. seldate: '',
  122. courseid: '',
  123. currentCourseItem: {},
  124. centerDialogVisible: false,
  125. }
  126. },
  127. computed: {
  128. ...mapState({
  129. cases: x => x.app.cases.list,
  130. defaultCaseId: x => x.app.cases.default
  131. }),
  132. ...mapScheduleState({
  133. details: x => x.detailList
  134. }),
  135. CaseId: {
  136. get () {
  137. return this.caseid || this.defaultCaseId
  138. },
  139. set (val) {
  140. this.caseid = val
  141. this.getList()
  142. }
  143. },
  144. fcEvents () {
  145. return this.details.map(x => {
  146. return {
  147. title: x.DetailName,
  148. start: x.BeginDate,
  149. end: x.EndDate,
  150. id: x.DetailId,
  151. detail: x,
  152. }
  153. })
  154. },
  155. CurrentMonth: {
  156. get () {
  157. const now = new Date()
  158. return this.seldate || this.getFullDate(now)
  159. },
  160. set (val) {
  161. this.seldate = val
  162. }
  163. },
  164. },
  165. components: {
  166. fullCalendar,
  167. },
  168. methods: {
  169. ...mapScheduleActions([
  170. 'GetDetailList',
  171. 'UpdateDetail',
  172. 'DelDetail',
  173. 'SetListNull',
  174. ]),
  175. dayClick (day, jsEvent) { // 点击某天进入排课
  176. this.$router.push({ name: 'editSchedule', query: {caseid: this.CaseId, courseid: this.courseid, date: this.toolClass.dateFormat(day, 'yyyy-MM-dd')} })
  177. },
  178. eventClick (event, jsEvent, pos) { // 点击日历
  179. this.currentCourseItem = {...event.detail}
  180. this.centerDialogVisible = true
  181. },
  182. changeMonth (start, end, current) {
  183. this.CurrentMonth = this.toolClass.dateFormat(current, 'yyyy-MM')
  184. this.getList()
  185. },
  186. search () { // 搜索
  187. this.getList()
  188. },
  189. getList () {
  190. if (this.CaseId !== '' || this.courseid !== '') {
  191. this.GetDetailList({
  192. caseid: this.CaseId,
  193. date: this.CurrentMonth,
  194. courseid: this.courseid,
  195. })
  196. } else {
  197. this.SetListNull()
  198. }
  199. },
  200. handlUpdateDetail () {
  201. this.UpdateDetail({...this.currentCourseItem,
  202. // BeginDate: this.toolClass.dateFormat(this.currentCourseItem.BeginDate, 'yyyy-MM-dd hh:mm:ss'),
  203. // EndDate: this.toolClass.dateFormat(this.currentCourseItem.EndDate, 'yyyy-MM-dd hh:mm:ss'),
  204. callback: this.AfterAction})
  205. },
  206. AfterAction () {
  207. this.$message({
  208. type: 'success',
  209. message: '操作成功!'
  210. })
  211. this.search()
  212. this.centerDialogVisible = false
  213. },
  214. handlDelDetail () {
  215. this.$confirm('确认删除此课时?', '提示', {
  216. confirmButtonText: '确定',
  217. cancelButtonText: '取消',
  218. type: 'warning'
  219. })
  220. .then(() => {
  221. this.DelDetail({id: this.currentCourseItem.DetailId, callback: this.AfterAction})
  222. })
  223. }
  224. },
  225. mounted () {
  226. this.$nextTick(function () {
  227. const { id } = this.$route.query
  228. if (id && id !== '') {
  229. this.courseid = id
  230. }
  231. this.getList()
  232. })
  233. }
  234. }
  235. </script>
  236. <!-- Add "scoped" attribute to limit CSS to this component only -->
  237. <style lang="scss" scoped>
  238. @import "page.scss";
  239. </style>