|
|
@@ -68,20 +68,26 @@
|
|
|
<el-input v-model="form.description" type="textarea" autosize style="padding-right: 1px;" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="分区">
|
|
|
- <el-select v-model="category" placeholder="请选择分区">
|
|
|
- <el-option label="新闻" value="shanghai" />
|
|
|
- <el-option label="教育" value="beijing" />
|
|
|
+ <el-select v-model="form.categoryPid" placeholder="请选择分区" @change="getCategory">
|
|
|
+ <el-option
|
|
|
+ v-for="item in pCategoryList" :key="item.value"
|
|
|
+ :label="item.label" :value="item.value">
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
|
- <el-select v-model="childCategory" placeholder="请选择子分区">
|
|
|
- <el-option label="历史" value="shanghai" />
|
|
|
- <el-option label="计算机" value="beijing" />
|
|
|
+ <el-select v-model="form.categoryId" placeholder="请选择子分区">
|
|
|
+ <el-option
|
|
|
+ v-for="item in categoryList" :key="item.value"
|
|
|
+ :label="item.label" :value="item.value">
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="标签">
|
|
|
- <el-input v-model="tagsStr" style="width: 70%; padding-right: 2px" placeholder="多个标签使用英文逗号分隔" />
|
|
|
+ <el-select v-model="form.tags" style="padding-right: 1px" placeholder="输入标签,用回车添加" @change="getRecommendTags" clearable multiple filterable allow-create default-first-option>
|
|
|
+ <el-option v-for="item in rcmdTags" :key="item.value" :label="item.label" :value="item.label"></el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="可见范围">
|
|
|
- <el-select v-model="form.scope" placeholder="选择可见范围">
|
|
|
+ <el-select v-model="form.scope" placeholder="选择稿件的可见范围">
|
|
|
<el-option label="所有人可见" value="1" />
|
|
|
<el-option label="验证码可见" value="2" />
|
|
|
<el-option label="VIP 可见" value="3" />
|
|
|
@@ -89,12 +95,12 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="定时发布">
|
|
|
- <el-col :span="11">
|
|
|
- <el-date-picker v-model="form.date" type="date" placeholder="选择日期" style="width: 100%;" />
|
|
|
- </el-col>
|
|
|
- <el-col :span="11">
|
|
|
- <el-time-picker v-model="form.time" placeholder="选择时间" style="width: 100%;" />
|
|
|
- </el-col>
|
|
|
+ <el-date-picker
|
|
|
+ v-model="form.scheduledPubDate"
|
|
|
+ type="datetime"
|
|
|
+ placeholder="选择发布的时间"
|
|
|
+ @change="getScheduledPubDate">
|
|
|
+ </el-date-picker>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
@@ -146,21 +152,24 @@ export default {
|
|
|
Contains: function(key) { return this.Get(key) !== null },
|
|
|
Remove: function(key) { delete this[key] }
|
|
|
},
|
|
|
- category: [],
|
|
|
- childCategory: [],
|
|
|
- // 提交给后端的数据
|
|
|
- tagsStr: null,
|
|
|
+ pCategoryList: [],
|
|
|
+ categoryList: [],
|
|
|
+ rcmdTags: [
|
|
|
+ /*{ label: "知识点1" }*/
|
|
|
+ ],
|
|
|
form: {
|
|
|
videoFileId: null,
|
|
|
coverUrl: null,
|
|
|
title: null,
|
|
|
description: null,
|
|
|
- categoryId: 0,
|
|
|
+ categoryPid: null,
|
|
|
+ categoryId: null,
|
|
|
tags: [],
|
|
|
scope: null,
|
|
|
width: 0,
|
|
|
height: 0,
|
|
|
- duration: 0
|
|
|
+ duration: 0,
|
|
|
+ scheduledPubDate: null
|
|
|
},
|
|
|
}
|
|
|
},
|
|
|
@@ -172,7 +181,20 @@ export default {
|
|
|
this.options.chunkSize = resData.maxSize
|
|
|
this.options.headers.Authorization = "Bearer " + resData.token
|
|
|
} else {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: '获取视频上传服务器地址失败, 暂时无法上传视频',
|
|
|
+ type: 'error',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
}
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: error.message,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
getServerInfo(5).then(res => {
|
|
|
@@ -181,7 +203,20 @@ export default {
|
|
|
this.imgOssUrl = resData.ossUrl
|
|
|
this.imgHeaders.Authorization = "Bearer " + resData.token
|
|
|
} else {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: '获取图片上传服务器地址失败, 暂时无法上传视频',
|
|
|
+ type: 'error',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
}
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: error.message,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
})
|
|
|
this.getVideoCategory()
|
|
|
},
|
|
|
@@ -192,14 +227,12 @@ export default {
|
|
|
onFileAdded(file) {
|
|
|
if (file.file.size > 1024*1024*1024*5) {
|
|
|
file.cancel()
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
+ this.$notify({
|
|
|
title: '提示',
|
|
|
message: '视频文件应小于 5GiB',
|
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
|
- }
|
|
|
- )
|
|
|
+ })
|
|
|
return
|
|
|
}
|
|
|
this.setTitle(file.file.name)
|
|
|
@@ -218,17 +251,25 @@ export default {
|
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
|
})
|
|
|
+ } else {
|
|
|
+ console.log(chunk)
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: '视频文件上传失败',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
onFileError(rootFile, file, response, chunk) {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
+ const res = JSON.parse(response)
|
|
|
+ console.log(res.msg)
|
|
|
+ this.$notify({
|
|
|
title: '提示',
|
|
|
- message: '文件上传错误',
|
|
|
+ message: '视频文件上传错误',
|
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
|
- }
|
|
|
- )
|
|
|
+ })
|
|
|
},
|
|
|
/***********************************************************************/
|
|
|
beforeAvatarUpload(file) {
|
|
|
@@ -319,17 +360,14 @@ export default {
|
|
|
const resData = json.data
|
|
|
this.form.coverUrl = resData.url
|
|
|
} else {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
- title: '提示',
|
|
|
- message: '视频封面上传失败,请重试!' + json.msg,
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- }
|
|
|
- )
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: '视频封面上传失败,请重试!' + json.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
- .catch(e => {
|
|
|
+ }).catch(e => {
|
|
|
return null
|
|
|
})
|
|
|
}
|
|
|
@@ -347,60 +385,51 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
getVideoCategory() {
|
|
|
- videoCategory()
|
|
|
- .then(res => {
|
|
|
+ videoCategory().then(res => {
|
|
|
if (res.code === 0) {
|
|
|
- for (let i = 0; i < res.data.length; i++) {
|
|
|
- const name = res.data[i].name
|
|
|
- //this.category.push(name)
|
|
|
- this.categoryMap.Set(name, res.data[i])
|
|
|
+ const resData = res.data
|
|
|
+ for (let i = 0; i < resData.length; i++) {
|
|
|
+ const name = resData[i].name
|
|
|
+ const id = resData[i].id
|
|
|
+ this.pCategoryList.push({label: name, value: id})
|
|
|
+ this.categoryMap.Set(id, resData[i].children)
|
|
|
}
|
|
|
} else {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
- title: '提示',
|
|
|
- message: res.msg,
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- }).catch(error => {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
+ this.$notify({
|
|
|
title: '提示',
|
|
|
- message: error.message,
|
|
|
- type: 'error',
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
duration: 3000
|
|
|
- }
|
|
|
- )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: error.message,
|
|
|
+ type: 'error',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
- getCategory(name) {
|
|
|
+ getCategory(id) {
|
|
|
// 重置子分区,清除前一次选择分区时留下的缓存
|
|
|
- this.childCategory = []
|
|
|
- this.currentCategory = this.categoryMap.Get(name)
|
|
|
- this.form.categoryId = this.currentCategory.id
|
|
|
-
|
|
|
- const c = this.currentCategory.children
|
|
|
- if (c) {
|
|
|
- for (let i = 0; i < c.length; i++) {
|
|
|
- this.childCategory.push(c[i].name)
|
|
|
- }
|
|
|
+ this.categoryList = []
|
|
|
+ for (const item of this.categoryMap.Get(id)) {
|
|
|
+ this.categoryList.push({label: item.name, value: item.id})
|
|
|
}
|
|
|
},
|
|
|
- getChildCategory(name) {
|
|
|
- const c = this.currentCategory.children
|
|
|
- for (let i = 0; i < c.length; i++) {
|
|
|
- if (c[i].name === name) {
|
|
|
- this.form.categoryId = c[i].id
|
|
|
- }
|
|
|
+ // 根据输入的标签获取相似的标签
|
|
|
+ getRecommendTags(tags) {
|
|
|
+ for (const tag of tags) {
|
|
|
+ // console.log(tag)
|
|
|
}
|
|
|
},
|
|
|
+ getScheduledPubDate() {
|
|
|
+ console.log(this.form.scheduledPubDate)
|
|
|
+ },
|
|
|
onSubmit() {
|
|
|
if (!this.form.videoFileId) {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
+ this.$notify({
|
|
|
title: '提示',
|
|
|
message: '你还没有上传视频',
|
|
|
type: 'warning',
|
|
|
@@ -411,8 +440,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
if (!this.form.coverUrl) {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
+ this.$notify({
|
|
|
title: '提示',
|
|
|
message: '你还没有上传视频封面',
|
|
|
type: 'warning',
|
|
|
@@ -423,8 +451,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
if (this.form.title === '' || this.form.categoryId === -1) {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
+ this.$notify({
|
|
|
title: '提示',
|
|
|
message: '分区和稿件标题不能为空',
|
|
|
type: 'warning',
|
|
|
@@ -434,11 +461,10 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (this.form.scope === null) {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
+ if (this.form.tags.length === 0 || this.form.tags.length > 10) {
|
|
|
+ this.$notify({
|
|
|
title: '提示',
|
|
|
- message: '稿件可见范围不能为空',
|
|
|
+ message: '标签最少 1 个, 最多 10 个',
|
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
|
}
|
|
|
@@ -446,12 +472,10 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- this.form.tags = this.tagsStr.split(",")
|
|
|
- if (this.form.tags.length === 0 || this.form.tags.length > 10) {
|
|
|
- this.$notify(
|
|
|
- {
|
|
|
+ if (this.form.scope === null) {
|
|
|
+ this.$notify({
|
|
|
title: '提示',
|
|
|
- message: '标签最少 1 个, 最多 10 个',
|
|
|
+ message: '稿件可见范围不能为空',
|
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
|
}
|
|
|
@@ -459,6 +483,18 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if (this.form.scheduledPubDate !== null) {
|
|
|
+ console.log(this.form.scheduledPubDate)
|
|
|
+ if (false) {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: '定时发布的时间必须在当前时间之后',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
submitVideo(this.form).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
this.$notify({
|