83d217e5 by qingxiao

添加教育教学

1 parent cebc7e0e
...@@ -149,6 +149,30 @@ export const constantRouterMap = [{ ...@@ -149,6 +149,30 @@ export const constantRouterMap = [{
149 } 149 }
150 }] 150 }]
151 }, 151 },
152 {
153 path: '/live',
154 component: Layout,
155 children: [
156 {
157 path: 'index',
158 name: 'Live',
159 component: () => import('@/views/live/index'),
160 meta: { title: '直播课程', icon: 'form' }
161 }
162 ]
163 },
164 {
165 path: '/public',
166 component: Layout,
167 children: [
168 {
169 path: 'index',
170 name: 'public',
171 component: () => import('@/views/public/index'),
172 meta: { title: '公开课', icon: 'form' }
173 }
174 ]
175 },
152 176
153 177
154 // { 178 // {
......
1 <template>
2 <div>
3 <el-dialog
4 :title="title"
5 :visible.sync="dialogVisible"
6 :before-close="handleCloseDialog">
7 <el-form :model="liveForm" ref="liveForm" :rules="liveRules" label-width="130px">
8 <el-form-item label="时间:" prop="liveTime">
9 <el-date-picker
10 v-model="liveForm.liveTime"
11 type="datetime"
12 value-format="timestamp"
13 placeholder="选择日期时间">
14 </el-date-picker>
15 </el-form-item>
16 <el-form-item label="内容:" prop="liveContent">
17 <el-input type="textarea" v-model="liveForm.liveContent" maxlength="500" show-word-limit></el-input>
18 </el-form-item>
19 </el-form>
20 <span slot="footer" class="dialog-footer">
21 <el-button type="primary" @click="submitForm('liveForm')">提交</el-button>
22 <el-button @click="handleCloseDialog">取消</el-button>
23 </span>
24 </el-dialog>
25 </div>
26 </template>
27
28 <script>
29 import { request } from '@/api/fetch-api'
30
31
32 let urls = {
33 liveSaveUrl: '/tianbao_edu_api/admin/live/save',
34 }
35 export default {
36 props: ['dialogVisible', 'title', 'liveTemp'],
37 data() {
38 return {
39 title: '',
40 liveForm:{},
41 liveRules:{
42 liveTime: [
43 {required: true, message: '请选择时间', trigger: 'blur'}
44 ],
45 liveContent: [
46 {required: true, message: '请输入内容', trigger: 'blur'}
47 ],
48 }
49
50 }
51 },
52 methods: {
53 handleCloseDialog() {
54 this.$emit('closedialog', false)
55 },
56 init(){
57 if (JSON.parse(JSON.stringify(this.liveTemp)) == null) {
58 this.title='创建'
59 } else {
60 this.title="修改"
61 this.liveForm = JSON.parse(JSON.stringify(this.liveTemp))
62 }
63 },
64 submitForm(formName){
65 this.$refs[formName].validate((valid) => {
66 if (valid) {
67 request.post(urls.liveSaveUrl, this.liveForm).then(response => {
68 this.$emit('initLive')
69 this.$emit('closedialog', false)
70 this.$message.success("保存成功")
71 }).catch(() => {
72
73 })
74 } else {
75 console.log('error submit!!')
76 return false
77 }
78 })
79
80 }
81
82 },
83 created() {
84 this.init()
85 }
86 }
87 </script>
88
89 <style scoped>
90
91 </style>
1 <template>
2 <div class="app-container">
3 <el-header height>
4 <el-button type="primary" @click="createLive">创建</el-button>
5 </el-header>
6 <el-main>
7 <el-table
8 :data="liveList"
9 style="width: 100%"
10 stripe
11 highlight-current-row
12 v-loading="loading"
13 >
14 <el-table-column label="时间" prop="liveTime">
15 <template slot-scope="scope">
16 {{timestampToTime(scope.row.liveTime)}}
17 </template>
18 </el-table-column>
19 <el-table-column label="直播内容" prop="liveContent"></el-table-column>
20 <el-table-column label="操作">
21 <template slot-scope="scope">
22 <el-link type="primary" @click="editLive(scope.row)">编辑 &nbsp;</el-link>
23 <el-link type="primary" @click="deleteLive(scope.row.liveCode)">删除</el-link>
24 </template>
25 </el-table-column>
26 </el-table>
27 </el-main>
28 <el-footer height>
29 <div style="text-align:right;">
30 <el-pagination
31 @size-change="handleSizeChange"
32 @current-change="handleCurrentChange"
33 :current-page="queryForm.page"
34 :page-size="queryForm.size"
35 layout="total, prev, pager, next"
36 :total="total">
37 </el-pagination>
38 </div>
39 </el-footer>
40
41 <live-save-dialog
42 v-if="dialogVisible"
43 :dialog-visible="dialogVisible"
44 :live-temp="liveTemp"
45 @closedialog="closedialog"
46 @initLive="initLive">
47 </live-save-dialog>
48 </div>
49 </template>
50
51 <script>
52 import {request} from '@/api/fetch-api'
53 import liveSaveDialog from './components/liveSaveDialog'
54
55 let urls = {
56 liveListUrl: '/tianbao_edu_api/admin/live/list',
57 liveSaveUrl: '/tianbao_edu_api/admin/live/save',
58 liveDelUrl:'/tianbao_edu_api/admin/live/delete'
59 }
60 export default {
61 components: {liveSaveDialog},
62 data() {
63 return {
64 liveList: [],
65 total: 0,
66 loading: false,
67 queryForm: {
68 page: 1,
69 size: 10
70 },
71 dialogVisible:false,
72 liveTemp:{},
73 }
74 },
75 methods: {
76 initLive() {
77 this.loading = true
78 request.get(urls.liveListUrl, this.queryForm).then(data => {
79 this.loading = false
80 this.liveList = data.content.list
81 this.total = data.content.total
82 }).catch(() => {
83
84 })
85 },
86 editLive(row){
87 this.liveTemp=row
88 this.dialogVisible=true
89 },
90 createLive(){
91 this.liveTemp=null
92 this.dialogVisible=true
93 },
94 closedialog() {
95 this.dialogVisible = false
96 },
97 deleteLive(code){
98
99 this.$confirm('是否永远删除, 是否继续?', '提示', {
100 confirmButtonText: '确定',
101 cancelButtonText: '取消',
102 type: 'warning'
103 }).then(() => {
104 request.post(urls.liveDelUrl, {liveCode: code}).then(data => {
105 this.$message.success("删除成")
106 this.initLive()
107 }).catch(() => {
108
109 })
110 }).catch(() => {
111
112 })
113 },
114 timestampToTime(row) {
115 if (row === 0) {
116 return ''
117 }
118 var date = new Date(row)
119 var Y = date.getFullYear() + '-'
120 var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
121 var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
122 var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
123 var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
124 var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
125 return Y + M + D + h + m + s
126 },
127 /*分页*/
128 handleSizeChange(val) {
129 console.log(`每页 ${val} 条`)
130 this.queryForm.size = val
131 this.queryForm.page = 1
132 this.initLive()
133 },
134 handleCurrentChange(val) {
135 console.log(`当前页: ${val}`)
136 this.queryForm.page = val
137 this.initLive()
138 },
139 },
140 created() {
141 this.initLive()
142 }
143 }
144 </script>
145
146 <style scoped>
147
148 </style>
1 <template>
2 <div>
3 <el-dialog
4 :title="title2"
5 :visible.sync="dialogVisible"
6 :before-close="handleCloseDialog">
7 <el-form :model="publicForm" ref="publicForm" :rules="publicRules" label-width="130px">
8 <el-form-item label="标题:" prop="title">
9 <el-input v-model="publicForm.title" maxlength="50" show-word-limit></el-input>
10 </el-form-item>
11 <el-form-item label="开始日期:" prop="startDate">
12 <el-date-picker
13 v-model="publicForm.startDate"
14 type="date"
15 placeholder="选择日期(必填)"
16 format="yyyy年MM月dd日"
17 value-format="yyyy年MM月dd日"
18 :picker-options="pickerOptionsStart">
19 </el-date-picker>
20 <el-time-picker
21 v-model="publicForm.startTime"
22 format="HH:mm:ss"
23 value-format="HH:mm:ss"
24 placeholder="选择时间">
25 </el-time-picker>
26 </el-form-item>
27 <el-form-item label="结束时间:" prop="endDate">
28 <el-date-picker
29 v-model="publicForm.endDate"
30 type="date"
31 placeholder="选择日期(必填)"
32 format="yyyy年MM月dd日"
33 value-format="yyyy年MM月dd日"
34 :picker-options="pickerOptionsEnd"
35 >
36 </el-date-picker>
37 <el-time-picker
38 v-model="publicForm.endTime"
39 format="HH:mm:ss"
40 value-format="HH:mm:ss"
41 placeholder="选择时间">
42 </el-time-picker>
43 </el-form-item>
44 <el-form-item label="地点:" prop="city">
45 <el-row :gutter="5">
46 <el-col :span="7">
47 <el-select
48 v-model="publicForm.province"
49 filterable
50 placeholder="省"
51 @change="provinceSelectChangeHandler"
52 >
53 <el-option
54 v-for="(item,index) in provinceList"
55 :key="index"
56 :label="item.areaName"
57 :value="item.areaName"
58 ></el-option>
59 </el-select>
60 </el-col>
61 <el-col :span="7">
62 <el-select
63 v-model="publicForm.city"
64 filterable
65 placeholder="市"
66 >
67 <el-option
68 v-for="(item,index) in cityList"
69 :key="index"
70 :label="item.areaName"
71 :value="item.areaName"
72 ></el-option>
73 </el-select>
74 </el-col>
75 </el-row>
76 </el-form-item>
77 <el-form-item label="报名:" prop="enroll">
78 <el-input v-model="publicForm.enroll" maxlength="200"
79 show-word-limit></el-input>
80 </el-form-item>
81 <el-form-item label="内容:" prop="content">
82 <el-input v-model="publicForm.content" type="textarea" maxlength="500"
83 show-word-limit></el-input>
84 </el-form-item>
85 </el-form>
86 <span slot="footer" class="dialog-footer">
87 <el-button type="primary" @click="submitForm('publicForm')">提交</el-button>
88 <el-button @click="handleCloseDialog">取消</el-button>
89 </span>
90 </el-dialog>
91 </div>
92 </template>
93
94 <script>
95 import {request} from '@/api/fetch-api'
96
97
98 let urls = {
99 publicSaveUrl: '/tianbao_edu_api/admin/public/save',
100 areaUrl: 'https://api.k.wxpai.cn/bizproxy/kdapi/area',
101 }
102 export default {
103 props: ['dialogVisible', 'publicTemp'],
104 data() {
105 return {
106 title2: '',
107 publicForm: {},
108 publicRules: {
109 title: [{required: true, message: '请输入标题', trigger: 'blur'}],
110 startDate: [{required: true, message: '请选择开始时间', trigger: 'blur'}],
111 endDate: [{required: false, message: '请选择结束时间', trigger: 'blur'}],
112 enroll: [{required: true, message: '请填写报名', trigger: 'blur'}],
113 city: [{required: true, message: '请选择省市', trigger: 'blur'}],
114 content: [{required: true, message: '请输入内容', trigger: 'blur'}],
115 },
116 provinceList: [],
117 cityList: [],
118 pickerOptionsStart: {
119 disabledDate: time => {
120 let endDateVal = this.publicForm.endDate;
121 if (endDateVal) {
122 return time.getTime() >= new Date(endDateVal).getTime();
123 }
124 }
125 },
126 pickerOptionsEnd: {
127 disabledDate: time => {
128 let beginDateVal = this.publicForm.startDate;
129 if (beginDateVal) {
130 return (
131 time.getTime() < new Date(beginDateVal).getTime()-24*60*60*1000
132 );
133 }
134 },
135 },
136 }
137 },
138 methods: {
139 handleCloseDialog() {
140 this.$emit('closedialog', false)
141 },
142 init() {
143 if (JSON.parse(JSON.stringify(this.publicTemp)) == null) {
144 this.title2 = '创建'
145 } else {
146 this.title2 = "修改"
147 this.publicForm = JSON.parse(JSON.stringify(this.publicTemp))
148 }
149 },
150 submitForm(formName) {
151 this.$refs[formName].validate((valid) => {
152 if (valid) {
153 request.post(urls.publicSaveUrl, this.publicForm).then(response => {
154 this.$emit('initPublic')
155 this.$emit('closedialog', false)
156 this.$message.success("保存成功")
157 }).catch(() => {
158
159 })
160 } else {
161 console.log('error submit!!')
162 return false
163 }
164 })
165 },
166 getProvince() {
167 request.post(urls.areaUrl, {}).then(res => {
168 this.provinceList = res.content
169 })
170 },
171 provinceSelectChangeHandler(province) {
172 this.cityList = null
173 let areaId = this.findAreaId(
174 this.provinceList,
175 province
176 )
177 request.post(urls.areaUrl, {parentId: areaId}).then(res => {
178 this.cityList = res.content
179 })
180 },
181 findAreaId(areaList, name) {
182 let areaId = ''
183 areaList.forEach(element => {
184 if (element.areaName == name) {
185 areaId = element.areaId
186 }
187 })
188 return areaId
189 },
190 changeStart() {
191 this.pickerOptionsStart = Object.assign({}, this.pickerOptionsStart, {
192 // 可通过箭头函数的方式访问到this
193 disabledDate: (time) => {
194 var times = '';
195 times = this.publicForm.endDate < time.getTime() || time.getTime() < new Date(new Date().toLocaleDateString())
196 .getTime();
197 return times
198 }
199 })
200
201 },
202 //开始时间 控制结束时间
203 changeEnd() {
204 this.pickerOptionsEnd = Object.assign({}, this.pickerOptionsEnd, {
205 disabledDate: (time) => {
206 return time.getTime() > this.publicForm.startDate
207 }
208 })
209 },
210 },
211 created() {
212 this.init()
213 this.getProvince()
214 }
215 }
216 </script>
217
218 <style scoped>
219
220 </style>
1 <template>
2 <div class="app-container">
3 <el-header height>
4 <el-button type="primary" @click="createPublic">创建</el-button>
5 </el-header>
6 <el-main>
7 <el-table
8 :data="publicList"
9 style="width: 100%"
10 stripe
11 highlight-current-row
12 v-loading="loading"
13 >
14 <el-table-column label="活动标题" prop="title"></el-table-column>
15 <el-table-column label="地点" prop="province">
16 <template slot-scope="scope">
17 {{scope.row.province}}-{{scope.row.city}}
18 </template>
19 </el-table-column>
20 <el-table-column label="报名" prop="enroll"></el-table-column>
21 <el-table-column label="开始时间">
22 <template slot-scope="scope">
23 {{scope.row.startDate}} &nbsp; {{scope.row.startTime}}
24 </template>
25 </el-table-column>
26 <el-table-column label="结束时间">
27 <template slot-scope="scope">
28 {{scope.row.endDate}} &nbsp; {{scope.row.endTime}}
29 </template>
30 </el-table-column>
31 <el-table-column label="直播内容" prop="content"></el-table-column>
32 <el-table-column label="操作">
33 <template slot-scope="scope">
34 <el-link type="primary" @click="editPublic(scope.row)">编辑&nbsp;</el-link>
35 <el-link type="primary" @click="deletePublic(scope.row.publicCode)">删除</el-link>
36 </template>
37 </el-table-column>
38 </el-table>
39 </el-main>
40 <el-footer height>
41 <div style="text-align:right;">
42 <el-pagination
43 @size-change="handleSizeChange"
44 @current-change="handleCurrentChange"
45 :current-page="queryForm.page"
46 :page-size="queryForm.size"
47 layout="total, prev, pager, next"
48 :total="total">
49 </el-pagination>
50 </div>
51 </el-footer>
52
53 <public-save-dialog
54 v-if="dialogVisible"
55 :dialog-visible="dialogVisible"
56 :public-temp="publicTemp"
57 @closedialog="closedialog"
58 @initPublic="initPublic">
59 </public-save-dialog>
60 </div>
61 </template>
62
63 <script>
64 import {request} from '@/api/fetch-api'
65 import publicSaveDialog from './components/publicSaveDialog'
66
67 let urls = {
68 publicListUrl: '/tianbao_edu_api/admin/public/list',
69 publicSaveUrl: '/tianbao_edu_api/admin/public/save',
70 publicDelUrl: '/tianbao_edu_api/admin/public/delete'
71 }
72 export default {
73 components: {publicSaveDialog},
74 data() {
75 return {
76 publicList: [],
77 total: 0,
78 loading: false,
79 queryForm: {
80 page: 1,
81 size: 10
82 },
83 dialogVisible: false,
84 publicTemp: {},
85 }
86 },
87 methods: {
88 initPublic() {
89 this.loading = true
90 request.get(urls.publicListUrl, this.queryForm).then(data => {
91 this.loading = false
92 this.publicList = data.content.list
93 this.total = data.content.total
94 }).catch(() => {
95
96 })
97 },
98 editPublic(row) {
99 this.publicTemp = row
100 this.dialogVisible = true
101 },
102 createPublic() {
103 this.publicTemp = null
104 this.dialogVisible = true
105 },
106 closedialog() {
107 this.dialogVisible = false
108 },
109 deletePublic(code) {
110
111 this.$confirm('是否永远删除, 是否继续?', '提示', {
112 confirmButtonText: '确定',
113 cancelButtonText: '取消',
114 type: 'warning'
115 }).then(() => {
116 request.post(urls.publicDelUrl, {publicCode: code}).then(data => {
117 this.$message.success("删除成")
118 this.initPublic()
119 }).catch(() => {
120
121 })
122 }).catch(() => {
123
124 })
125 },
126 timestampToTime(row) {
127 if (row === 0) {
128 return ''
129 }
130 var date = new Date(row)
131 var Y = date.getFullYear() + '-'
132 var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
133 var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
134 var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
135 var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
136 var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
137 return Y + M + D + h + m + s
138 },
139 /*分页*/
140 handleSizeChange(val) {
141 console.log(`每页 ${val} 条`)
142 this.queryForm.size = val
143 this.queryForm.page = 1
144 this.initPublic()
145 },
146 handleCurrentChange(val) {
147 console.log(`当前页: ${val}`)
148 this.queryForm.page = val
149 this.initPublic()
150 },
151 },
152 created() {
153 this.initPublic()
154 }
155 }
156 </script>
157
158 <style scoped>
159
160 </style>