123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- <template>
- <div class="subPage">
- <form class="mainForm">
- <ul>
- <li class="flex-h">
- <span>课程主图:<em>*</em></span>
- <div class="flex-item">
- <div>
- <el-upload
- class="avatar-uploader"
- action='string'
- :http-request="toolClass.upload"
- :show-file-list="false"
- :on-success="handleAvatarSuccess">
- <img v-if="detail.CourseImg" :src="detail.CourseImg" class="avatar">
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>课程名称:<em>*</em></span>
- <div class="flex-item">
- <div style="width: 50%;">
- <el-input
- placeholder="请输入课程名称"
- v-model="detail.CourseName"
- clearable
- >
- </el-input>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>课程类型:<em>*</em></span>
- <div class="flex-item">
- <div style="width: 50%;">
- <el-select v-model="detail.LocationId" placeholder="请选择">
- <el-option
- v-for="item in location"
- :key="item.LocationId"
- :label="item.LocationName"
- :value="item.LocationId">
- </el-option>
- </el-select>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>课程价格:<em>*</em></span>
- <div class="flex-item">
- <div style="width: 200px;">
- <el-input
- placeholder="请输入课程价格"
- v-model="detail.Price"
- clearable
- >
- </el-input>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>案场:<em>*</em></span>
- <div class="flex-item">
- <div style="width: 50%;">
- <el-select v-model="CaseId" placeholder="请选择">
- <el-option
- v-for="item in cases"
- :key="item.CaseId"
- :label="item.CaseName"
- :value="item.CaseId">
- </el-option>
- </el-select>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>开课人数:<em>*</em></span>
- <div class="flex-item">
- <div style="width: 200px;">
- <el-input
- placeholder="请输入开课人数"
- v-model="detail.MaxNum"
- clearable
- >
- </el-input>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>最小开课人数:<em>*</em></span>
- <div class="flex-item">
- <div style="width: 200px;">
- <el-input
- placeholder="请输入开课人数"
- v-model="detail.MinNum"
- clearable
- >
- </el-input>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>课时数:<em>*</em></span>
- <div class="flex-item">
- <div style="width: 200px;">
- <el-input
- placeholder="请输入课时数"
- v-model="detail.CourseNum"
- clearable
- >
- </el-input>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>课程时间:<em>*</em></span>
- <div class="flex-item">
- <div>
- <el-date-picker
- value-format="yyyy-MM-dd 00:00:00"
- v-model="detail.BeginDate"
- type="date"
- placeholder="选择起始日期">
- </el-date-picker>
- <span style="line-height:40px;">至</span>
- <el-date-picker
- value-format="yyyy-MM-dd 23:59:59"
- v-model="detail.EndDate"
- type="date"
- placeholder="选择截止日期">
- </el-date-picker>
-
-
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>课程计划备注:</span>
- <div class="flex-item">
- <div style="width: 50%;">
- <el-input
- type="textarea"
- autosize
- placeholder="请输入备注"
- v-model="detail.Remark"
- clearable
- >
- </el-input>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>课程标签:</span>
- <div class="flex-item">
- <div style="width: 50%;">
- <el-select
- style="width:100%"
- v-model="tags"
- multiple
- filterable
- allow-create
- default-first-option
- placeholder="请选择课程标签">
- <el-option
- v-for="item in tagList.list"
- :key="item.TagId"
- :label="item.TagName"
- :value="item.TagId"
- :value-key="item.TagId"
- >
- </el-option>
- </el-select>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>课程简介:</span>
- <div class="flex-item">
- <div style="width: 50%;">
- <el-input
- type="textarea"
- autosize
- placeholder="请输入课程简介"
- v-model="detail.CourseDesc"
- clearable
- >
- </el-input>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>是否精选课程:<em>*</em></span>
- <div class="flex-item">
- <div>
- <el-radio v-model="detail.IsSelect" :label="1">是</el-radio>
- <el-radio v-model="detail.IsSelect" :label="0">否</el-radio>
- </div>
- </div>
- </li>
- <li style="text-align:center">
- <el-button type="primary" size="mini" @click="submit">保存</el-button>
- <el-button type="danger" size="mini" @click="cancel">取消</el-button>
- </li>
- </ul>
- </form>
- </div>
- </template>
-
- <script>
- import { createNamespacedHelpers, mapState } from 'vuex'
-
- const { mapState: mapCourseState, mapActions: mapCourseActions } = createNamespacedHelpers('course')
- const { mapState: mapLocationState, mapActions: mapLocationActions } = createNamespacedHelpers('cms')
- const { mapState: mapTagState, mapActions: mapTagActions } = createNamespacedHelpers('coursetag')
-
- export default {
- name: '',
- data () {
- return {
- pickerOptions: {
- shortcuts: [{
- text: '最近一周',
- onClick (picker) {
- const end = new Date()
- const start = new Date()
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
- picker.$emit('pick', [start, end])
- }
- }, {
- text: '最近一个月',
- onClick (picker) {
- const end = new Date()
- const start = new Date()
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
- picker.$emit('pick', [start, end])
- }
- }, {
- text: '最近三个月',
- onClick (picker) {
- const end = new Date()
- const start = new Date()
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
- picker.$emit('pick', [start, end])
- }
- }]
- },
- }
- },
- computed: {
- ...mapLocationState({
- location: x => x.location
- }),
- ...mapCourseState({
- detail: x => x.courseInfo
- }),
- ...mapState({
- cases: x => x.app.cases.list,
- caseid: x => x.app.cases.default,
- orgid: x => x.app.user.OrgId,
- }),
- ...mapTagState({
- tagList: x => x.tagList
- }),
- CaseId: {
- get () {
- return this.detail.CaseId || this.caseid
- },
- set (val) {
- this.UpdateInfo({ ...this.detail, CaseId: val })
- }
- },
- courseDate: {
- get () {
- return this.detail.BeginDate && this.detail.EndDate ? [this.detail.BeginDate, this.detail.EndDate] : []
- },
- set (val) {
- this.UpdateInfo({ ...this.detail, BeginDate: val[0], EndDate: val[1] })
- },
- },
- tags: {
- get () {
- return (this.detail.CourseTags || []).map(x => x.TagId)
- },
- set (val) {
- let v = val.map(x => {
- return {
- TagId: x,
- }
- })
- this.UpdateInfo({ ...this.detail, CourseTags: v })
- }
- },
- },
- components: {},
- methods: {
- ...mapCourseActions([
- 'GetCourseByID',
- 'AddCourse',
- 'UpdateCourse',
- 'UpdateInfo',
- ]),
- ...mapLocationActions([
- 'updateLocationInfo',
- ]),
- ...mapTagActions([
- 'GetCourseTagList',
- ]),
- handleAvatarSuccess (res, file) {
- this.UpdateInfo({ ...this.detail, CourseImg: res.result.url })
- },
- upLoad (item) {
- this.toolClass.upload(item).then((res) => { this.handleAvatarSuccess(res, item.file) })
- },
- checkFn (arr) {
- for (var n = 0; n < arr.length; n++) {
- if ((arr[n].type === 'isNull' && arr[n].target === '') || (arr[n].type === 'Array' && arr[n].target.length)) {
- this.$message({
- message: arr[n].errorMsg,
- type: 'error'
- })
- return false
- }
- }
- return true
- },
- submit () {
- var checkOff = this.checkFn([{
- target: (this.detail.CourseImg || ''),
- errorMsg: '课程主图不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.CourseName || ''),
- errorMsg: '课程名称不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.LocationId || ''),
- errorMsg: '课程类型不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.Price || ''),
- errorMsg: '课程价格不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.MaxNum || ''),
- errorMsg: '开课人数不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.MinNum || ''),
- errorMsg: '最小开课人数不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.CourseNum || ''),
- errorMsg: '课时数不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.BeginDate || ''),
- errorMsg: '起始日期不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.EndDate || ''),
- errorMsg: '截止日期不能为空',
- type: 'isNull'
- }, {
- target: (this.detail.IsSelect || ''),
- errorMsg: '是否精选课程不能为空',
- type: 'isNull'
- }])
- if (!checkOff) {
- return false
- }
- const { id } = this.$route.query
- if (!id || id === '') {
- this.UpdateInfo({ ...this.detail, CourseId: '' })
- }
- const _that = this
- this.detail.tagids = this.tags.map(x => {
- let tagfilter = (_that.tagList.list || []).filter(tag => tag.TagId === x)
- if (tagfilter.length > 0) {
- return tagfilter[0].TagName + ':' + tagfilter[0].TagId
- } else {
- return x
- }
- }).join(',')
- if ((this.detail.CourseId || '') === '') {
- this.detail.OrgId = this.orgid
- if (!this.detail.CaseId || this.detail.CaseId === '') {
- this.detail.CaseId = this.caseid
- }
- this.AddCourse({ ...this.detail, callback: _that.afterSave })
- } else {
- this.UpdateCourse({ ...this.detail, callback: _that.afterSave })
- }
- },
- afterSave () {
- this.$message({
- type: 'success',
- message: '操作成功'
- })
- this.$router.push({ name: 'courseList' })
- },
- cancel () {
- this.$router.push({ name: 'courseList' })
- }
- },
- mounted () {
- this.updateLocationInfo(false)
- this.GetCourseTagList({ pagesize: 100 })
- const { id } = this.$route.query
- if (id && id !== '') {
- this.GetCourseByID({ id: id })
- } else {
-
- }
- }
- }
- </script>
-
-
- <style lang="scss" scoped>
- </style>
|