|
@@ -48,14 +48,14 @@
|
|
|
<v-col cols="5">
|
|
<v-col cols="5">
|
|
|
<v-select
|
|
<v-select
|
|
|
:items="category"
|
|
:items="category"
|
|
|
- label="主分区"
|
|
|
|
|
|
|
+ label="分区"
|
|
|
@change="getCategory"
|
|
@change="getCategory"
|
|
|
/>
|
|
/>
|
|
|
</v-col>
|
|
</v-col>
|
|
|
<v-col cols="5">
|
|
<v-col cols="5">
|
|
|
<v-select
|
|
<v-select
|
|
|
:items="childCategory"
|
|
:items="childCategory"
|
|
|
- label="分区"
|
|
|
|
|
|
|
+ label="子分区"
|
|
|
@change="getChildCategory"
|
|
@change="getChildCategory"
|
|
|
/>
|
|
/>
|
|
|
</v-col>
|
|
</v-col>
|
|
@@ -132,8 +132,9 @@ export default {
|
|
|
rules: [
|
|
rules: [
|
|
|
value => !value || value.size < 2000000 || 'Avatar size should be less than 2 MB!'
|
|
value => !value || value.size < 2000000 || 'Avatar size should be less than 2 MB!'
|
|
|
],
|
|
],
|
|
|
|
|
+ // 提交给后端的数据
|
|
|
videoInfo: {
|
|
videoInfo: {
|
|
|
- videoInfoId: '',
|
|
|
|
|
|
|
+ infoId: '',
|
|
|
title: '',
|
|
title: '',
|
|
|
desc: '',
|
|
desc: '',
|
|
|
coverUrl: '',
|
|
coverUrl: '',
|
|
@@ -145,7 +146,7 @@ export default {
|
|
|
categoryMap: {
|
|
categoryMap: {
|
|
|
Set: function(key, value) { this[key] = value },
|
|
Set: function(key, value) { this[key] = value },
|
|
|
Get: function(key) { return this[key] },
|
|
Get: function(key) { return this[key] },
|
|
|
- Contains: function(key) { return this.Get(key) != null },
|
|
|
|
|
|
|
+ Contains: function(key) { return this.Get(key) !== null },
|
|
|
Remove: function(key) { delete this[key] }
|
|
Remove: function(key) { delete this[key] }
|
|
|
},
|
|
},
|
|
|
category: [],
|
|
category: [],
|
|
@@ -166,7 +167,7 @@ export default {
|
|
|
this.showMessage = true
|
|
this.showMessage = true
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (this.videoInfo.title === '' || this.coverUrl === '' || this.videoInfo.tags.length === 0 || this.videoInfo.category === -1) {
|
|
|
|
|
|
|
+ if (this.videoInfo.title === '' || this.coverUrl === '' || this.videoInfo.tags.length === 0 || this.videoInfo.categoryId === -1) {
|
|
|
this.message = '标题,封面,标签,分区不能为空'
|
|
this.message = '标题,封面,标签,分区不能为空'
|
|
|
this.showMessage = true
|
|
this.showMessage = true
|
|
|
return
|
|
return
|
|
@@ -206,7 +207,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
videoUploadSuccess(value) {
|
|
videoUploadSuccess(value) {
|
|
|
if (value.code === 0) {
|
|
if (value.code === 0) {
|
|
|
- this.videoInfo.videoInfoId = value.data[0].videoInfoId
|
|
|
|
|
|
|
+ this.videoInfo.infoId = value.data[0].infoId
|
|
|
this.setTitle(value.data[0].filename)
|
|
this.setTitle(value.data[0].filename)
|
|
|
this.videoInfo.duration = value.data[0].duration
|
|
this.videoInfo.duration = value.data[0].duration
|
|
|
this.videoInfo.coverUrl = value.data[0].coverUrl
|
|
this.videoInfo.coverUrl = value.data[0].coverUrl
|
|
@@ -215,7 +216,12 @@ export default {
|
|
|
this.message = '视频上传成功'
|
|
this.message = '视频上传成功'
|
|
|
this.showMessage = true
|
|
this.showMessage = true
|
|
|
} else {
|
|
} else {
|
|
|
- this.message = '上传出现异常,请重试!' + value.message
|
|
|
|
|
|
|
+ // TODO 返回错误原因,网络错误或是服务端错误
|
|
|
|
|
+ if (value.message != null) {
|
|
|
|
|
+ this.message = '上传文件出现异常,请重新上传!' + value.message
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.message = '上传文件出现异常,请重新上传!'
|
|
|
|
|
+ }
|
|
|
this.showMessage = true
|
|
this.showMessage = true
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -268,7 +274,6 @@ export default {
|
|
|
.then(json => {
|
|
.then(json => {
|
|
|
for (let i = 0; i < json.data.length; i++) {
|
|
for (let i = 0; i < json.data.length; i++) {
|
|
|
const name = json.data[i].name
|
|
const name = json.data[i].name
|
|
|
-
|
|
|
|
|
this.category.push(name)
|
|
this.category.push(name)
|
|
|
this.categoryMap.Set(name, json.data[i])
|
|
this.categoryMap.Set(name, json.data[i])
|
|
|
}
|
|
}
|
|
@@ -277,23 +282,24 @@ export default {
|
|
|
return null
|
|
return null
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- getCategory(value) {
|
|
|
|
|
|
|
+ getCategory(name) {
|
|
|
|
|
+ // 重置子分区,清除前一次选择分区时留下的缓存
|
|
|
this.childCategory = []
|
|
this.childCategory = []
|
|
|
- this.nowCategory = this.categoryMap.Get(value)
|
|
|
|
|
- this.videoInfo.category = this.nowCategory.id
|
|
|
|
|
|
|
+ this.currentCategory = this.categoryMap.Get(name)
|
|
|
|
|
+ this.videoInfo.categoryId = this.currentCategory.id
|
|
|
|
|
|
|
|
- const c = this.nowCategory.children
|
|
|
|
|
|
|
+ const c = this.currentCategory.children
|
|
|
if (c) {
|
|
if (c) {
|
|
|
for (let i = 0; i < c.length; i++) {
|
|
for (let i = 0; i < c.length; i++) {
|
|
|
this.childCategory.push(c[i].name)
|
|
this.childCategory.push(c[i].name)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- getChildCategory(value) {
|
|
|
|
|
- const c = this.nowCategory.children
|
|
|
|
|
|
|
+ getChildCategory(name) {
|
|
|
|
|
+ const c = this.currentCategory.children
|
|
|
for (let i = 0; i < c.length; i++) {
|
|
for (let i = 0; i < c.length; i++) {
|
|
|
- if (c[i].name === value) {
|
|
|
|
|
- this.videoInfo.category = c[i].id
|
|
|
|
|
|
|
+ if (c[i].name === name) {
|
|
|
|
|
+ this.videoInfo.categoryId = c[i].id
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|