|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="tab1Add">
|
|
|
<div class="insideTop">
|
|
|
- 文物典藏管理 > 新增文物典藏
|
|
|
+ 文物典藏管理 > {{ruleForm.id?'编辑':'新增'}}文物典藏
|
|
|
<div class="add">
|
|
|
<el-button type="primary" @click="goBack">返 回</el-button>
|
|
|
</div>
|
|
|
@@ -28,26 +28,38 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="精品类型:">
|
|
|
<i class="biaoshi biaoshi2"></i>
|
|
|
- <el-radio v-model="conLeftId" label="1" :disabled='conLeftId!=="1"'>实物模型</el-radio>
|
|
|
- <el-radio v-model="conLeftId" label="2" disabled>专题图库</el-radio>
|
|
|
- <el-radio v-model="conLeftId" label="3" :disabled='conLeftId!=="3"'>视频档案</el-radio>
|
|
|
+ <el-radio
|
|
|
+ v-model="conLeftId"
|
|
|
+ label="model"
|
|
|
+ :disabled="conLeftId !== 'model'"
|
|
|
+ >实物模型</el-radio
|
|
|
+ >
|
|
|
+ <el-radio v-model="conLeftId" label="img" disabled>专题图库</el-radio>
|
|
|
+ <el-radio
|
|
|
+ v-model="conLeftId"
|
|
|
+ label="video"
|
|
|
+ :disabled="conLeftId !== 'video'"
|
|
|
+ >视频档案</el-radio
|
|
|
+ >
|
|
|
</el-form-item>
|
|
|
<!-- 图片和附件 -->
|
|
|
- <el-form-item :label="conLeftId==='1'?'模型封面图片:':'封面图片:'">
|
|
|
- <i class="biaoshi" :class="{biaoshi1:conLeftId==='1'}"></i>
|
|
|
+ <el-form-item
|
|
|
+ :label="conLeftId === 'model' ? '模型封面图片:' : '封面图片:'"
|
|
|
+ >
|
|
|
+ <i class="biaoshi" :class="{ biaoshi1: conLeftId === 'model' }"></i>
|
|
|
<el-upload
|
|
|
class="avatar-uploader"
|
|
|
- :action="baseURL + '/cms/security/video/upload/img'"
|
|
|
+ :action="baseURL + '/cms/goods/upload'"
|
|
|
:headers="{
|
|
|
token,
|
|
|
}"
|
|
|
- :show-file-list="false"
|
|
|
+ :show-file-list="true"
|
|
|
:before-upload="beforethumbUpload"
|
|
|
:on-success="upload_thumb_success"
|
|
|
>
|
|
|
<div v-if="ruleForm.thumb" class="imgdiv">
|
|
|
<img
|
|
|
- style="width: 100%; height: 100%"
|
|
|
+ style="max-width: 200px; max-height: 200px;display: block;"
|
|
|
:src="baseURL + ruleForm.thumb"
|
|
|
/>
|
|
|
<i
|
|
|
@@ -61,16 +73,22 @@
|
|
|
<p class="upHint">
|
|
|
1、支持png、jpg、gif和jpeg的图片格式;最大支持20M。
|
|
|
</p>
|
|
|
- <p class="upHint">2、用于{{conLeftId==='1'?'实物模型':'视频档案'}}列表中进行展示。</p>
|
|
|
+ <p class="upHint">
|
|
|
+ 2、用于{{
|
|
|
+ conLeftId === "model" ? "实物模型" : "视频档案"
|
|
|
+ }}列表中进行展示。
|
|
|
+ </p>
|
|
|
</el-form-item>
|
|
|
<!-- 上传附件 -->
|
|
|
- <el-form-item :label="conLeftId==='1'?'模型文件:':'视频文件:'">
|
|
|
+ <el-form-item
|
|
|
+ :label="conLeftId === 'model' ? '模型文件:' : '视频文件:'"
|
|
|
+ >
|
|
|
<i class="biaoshi"></i>
|
|
|
<el-upload
|
|
|
multiple
|
|
|
class="upload-demo"
|
|
|
:file-list="fileList"
|
|
|
- :action="baseURL + '/cms/security/video/upload/video'"
|
|
|
+ :action="baseURL + '/cms/goods/video/upload'"
|
|
|
:headers="{ token }"
|
|
|
:before-upload="beforeFujian"
|
|
|
:on-success="successFujian"
|
|
|
@@ -81,28 +99,32 @@
|
|
|
:show-file-list="true"
|
|
|
>
|
|
|
<el-button size="small" type="primary">点击上传</el-button>
|
|
|
- <div class="el-upload__tip" slot="tip" v-if="conLeftId==='1'">
|
|
|
- <p class="upHint">格式要求:</p>
|
|
|
- <p class="upHint">1、仅支持.4dge格式的模型文件。</p>
|
|
|
- <p class="upHint">2、最大支持500M。</p>
|
|
|
- </div>
|
|
|
- <div class="el-upload__tip" slot="tip" v-else>
|
|
|
- <p class="upHint">格式要求:</p>
|
|
|
- <p class="upHint">1、支持视频格式文件(例如:AVI、mov、rmvb、rm、FLV、mp4、3GP)。</p>
|
|
|
- <p class="upHint">2、最大支持2G的视频文件。</p>
|
|
|
- </div>
|
|
|
</el-upload>
|
|
|
+ <div class="el-upload__tip" v-if="conLeftId === 'model'">
|
|
|
+ <p class="upHint">格式要求:</p>
|
|
|
+ <p class="upHint">1、仅支持.4dge格式的模型文件。</p>
|
|
|
+ <p class="upHint">2、最大支持500M。</p>
|
|
|
+ </div>
|
|
|
+ <div class="el-upload__tip" v-else>
|
|
|
+ <p class="upHint">格式要求:</p>
|
|
|
+ <p class="upHint">
|
|
|
+ 1、支持视频格式文件(例如:AVI、mov、rmvb、rm、FLV、mp4、3GP)。
|
|
|
+ </p>
|
|
|
+ <p class="upHint">2、最大支持2G的视频文件。</p>
|
|
|
+ </div>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<!-- 底部按钮 -->
|
|
|
<div class="con_btn">
|
|
|
- <el-button type="primary">保 存</el-button>
|
|
|
+ <el-button type="primary" @click="saveGood">保 存</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { goodsSave, goodsDetail } from '@/apis/tab1'
|
|
|
+import axios from '@/utils/request'
|
|
|
export default {
|
|
|
name: 'tab1Add',
|
|
|
components: {},
|
|
|
@@ -114,11 +136,11 @@ export default {
|
|
|
baseURL: '',
|
|
|
token: '',
|
|
|
ruleForm: {
|
|
|
- id: '',
|
|
|
- name: '',
|
|
|
- thumb: '',
|
|
|
- video: '',
|
|
|
- fileName: ''
|
|
|
+ name: '', // 标题
|
|
|
+ type: '', // 类型, model:模型, img:图片, video:视频
|
|
|
+ thumb: '', // 封面图
|
|
|
+ fileName: '', // 文件名称
|
|
|
+ filePath: '' // 文件地址
|
|
|
},
|
|
|
rules: {
|
|
|
name: [{ required: true, message: '不能为空', trigger: 'blur' }]
|
|
|
@@ -127,6 +149,21 @@ export default {
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
+ // 点击保存
|
|
|
+ async saveGood () {
|
|
|
+ if (this.ruleForm.name.trim() === '') { return this.$message.warning('标题不能为空') }
|
|
|
+ if (this.ruleForm.thumb === '') { return this.$message.warning('图片不能为空') }
|
|
|
+ if (this.ruleForm.filePath === '') { return this.$message.warning('文件不能为空') }
|
|
|
+ const obj = { ...this.ruleForm, type: this.conLeftId }
|
|
|
+ const res = await goodsSave(obj)
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('操作成功')
|
|
|
+ this.$router.push({
|
|
|
+ path: '/layout/tab1',
|
|
|
+ query: { conLeftId: this.conLeftId }
|
|
|
+ })
|
|
|
+ } else this.$message.warning(res.msg)
|
|
|
+ },
|
|
|
// 点击返回
|
|
|
goBack () {
|
|
|
this.$confirm('点击返回后,编辑的信息将无法保存,是否继续?', '提示', {
|
|
|
@@ -148,7 +185,7 @@ export default {
|
|
|
beforethumbUpload (file) {
|
|
|
// console.log(998, file)
|
|
|
// 限制图片大小和格式
|
|
|
- const sizeOk = file.size / 1024 / 1024 < 5
|
|
|
+ const sizeOk = file.size / 1024 / 1024 < 20
|
|
|
const typeOk =
|
|
|
file.type === 'image/png' ||
|
|
|
file.type === 'image/jpeg' ||
|
|
|
@@ -159,52 +196,71 @@ export default {
|
|
|
this.$message.error('照片格式有误!')
|
|
|
reject(file)
|
|
|
} else if (!sizeOk) {
|
|
|
- this.$message.error('照片大小超过5M!')
|
|
|
+ this.$message.error('照片大小超过20M!')
|
|
|
reject(file)
|
|
|
} else if (file.name.length > 32) {
|
|
|
this.$message.error('照片名字不能超过32个字!')
|
|
|
reject(file)
|
|
|
} else {
|
|
|
- this.$message.success('上传成功')
|
|
|
resolve(file)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
upload_thumb_success (data) {
|
|
|
- // console.log('图片上传成功', data.data.urlPath)
|
|
|
- this.ruleForm.thumb = data.data.urlPath
|
|
|
+ this.$message.success('上传成功')
|
|
|
+ // console.log('图片上传成功', data.data.filePath)
|
|
|
+ this.ruleForm.thumb = data.data.filePath
|
|
|
},
|
|
|
// 上传附件
|
|
|
beforeFujian (file) {
|
|
|
console.log('附件上传前', file)
|
|
|
- const sizeOk = file.size / 1024 / 1024 < 1024
|
|
|
- const typeOk =
|
|
|
- file.type === 'video/mp4' ||
|
|
|
- file.type === 'video/avi' ||
|
|
|
- file.type === 'video/quicktime' ||
|
|
|
- file.type === 'video/rm' ||
|
|
|
- (file.type === '' &&
|
|
|
- (file.name.includes('.flv') || file.name.includes('.rmvb'))) ||
|
|
|
- file.type === 'video/3gpp'
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- if (file.name.length > 32) {
|
|
|
- this.$message.error('视频名字不能超过32个字')
|
|
|
- reject(file)
|
|
|
- } else if (!sizeOk) {
|
|
|
- this.$message.error('视频大小超过1GB!')
|
|
|
- reject(file)
|
|
|
- } else if (!typeOk) {
|
|
|
- this.$message.error('视频格式有误!')
|
|
|
- reject(file)
|
|
|
- } else {
|
|
|
- resolve(file)
|
|
|
- }
|
|
|
- })
|
|
|
+ if (this.conLeftId === 'model') {
|
|
|
+ const sizeOk = file.size / 1024 / 1024 < 500
|
|
|
+ const typeOk = file.type === '' && file.name.includes('.4dage')
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ if (file.name.length > 32) {
|
|
|
+ this.$message.error('文件名字不能超过32个字')
|
|
|
+ reject(file)
|
|
|
+ } else if (!sizeOk) {
|
|
|
+ this.$message.error('模型大小超过500M!')
|
|
|
+ reject(file)
|
|
|
+ } else if (!typeOk) {
|
|
|
+ this.$message.error('模型格式有误!')
|
|
|
+ reject(file)
|
|
|
+ } else {
|
|
|
+ resolve(file)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (this.conLeftId === 'video') {
|
|
|
+ const sizeOk = file.size / 1024 / 1024 < 2048
|
|
|
+ const typeOk =
|
|
|
+ file.type === 'video/mp4' ||
|
|
|
+ file.type === 'video/avi' ||
|
|
|
+ file.type === 'video/quicktime' ||
|
|
|
+ file.type === 'video/rm' ||
|
|
|
+ (file.type === '' &&
|
|
|
+ (file.name.includes('.flv') || file.name.includes('.rmvb'))) ||
|
|
|
+ file.type === 'video/3gpp'
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ if (file.name.length > 32) {
|
|
|
+ this.$message.error('视频名字不能超过32个字')
|
|
|
+ reject(file)
|
|
|
+ } else if (!sizeOk) {
|
|
|
+ this.$message.error('视频大小超过2GB!')
|
|
|
+ reject(file)
|
|
|
+ } else if (!typeOk) {
|
|
|
+ this.$message.error('视频格式有误!')
|
|
|
+ reject(file)
|
|
|
+ } else {
|
|
|
+ resolve(file)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
successFujian (file) {
|
|
|
console.log('上传附件成功', file)
|
|
|
if (file.code === 0) {
|
|
|
- this.ruleForm.video = file.data.urlPath
|
|
|
+ this.ruleForm.filePath = file.data.urlPath
|
|
|
this.ruleForm.fileName = file.data.fileName
|
|
|
this.$message.success('上传成功')
|
|
|
} else if (file.code === -1) {
|
|
|
@@ -217,17 +273,29 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
handleRemove (file, fileList) {
|
|
|
- this.ruleForm.video = ''
|
|
|
+ this.ruleForm.filePath = ''
|
|
|
this.ruleForm.fileName = ''
|
|
|
},
|
|
|
handleExceed (files, fileList) {
|
|
|
- this.$message.warning('只能上传一个视频,请删除原视频后操作')
|
|
|
+ this.$message.warning('只能上传一个文件,请删除原文件后操作')
|
|
|
}
|
|
|
},
|
|
|
// 生命周期 - 创建完成(可以访问当前this实例)
|
|
|
- created () {
|
|
|
+ async created () {
|
|
|
+ // 获取服务器前缀地址
|
|
|
+ this.baseURL = axios.defaults.baseURL
|
|
|
+ // 获取用户token
|
|
|
+ this.token = localStorage.getItem('CQLJXU_token')
|
|
|
// 拿到路由跳转传过来的数据
|
|
|
this.conLeftId = this.$route.query.conLeftId
|
|
|
+ // 通过父亲传过来的id获取详情
|
|
|
+ if (this.$route.query.id) {
|
|
|
+ const res = await goodsDetail(Number(this.$route.query.id))
|
|
|
+ this.ruleForm = res.data.entity
|
|
|
+ // 附件回显
|
|
|
+ this.fileList = [{ name: res.data.entity.fileName }]
|
|
|
+ // console.log(998, res)
|
|
|
+ }
|
|
|
},
|
|
|
// 生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
mounted () {},
|
|
|
@@ -244,6 +312,7 @@ export default {
|
|
|
.tab1Add {
|
|
|
height: 100%;
|
|
|
.conten {
|
|
|
+ overflow-y: auto;
|
|
|
position: relative;
|
|
|
/deep/.el-icon-plus {
|
|
|
border: 1px dashed #ccc;
|
|
|
@@ -285,6 +354,16 @@ export default {
|
|
|
transform: translateX(-50%);
|
|
|
bottom: 15px;
|
|
|
}
|
|
|
+ .imgdiv {
|
|
|
+ max-width: 200px;
|
|
|
+ max-height: 200px;
|
|
|
+ &>img{
|
|
|
+ border: 10px solid #ccc;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .el-icon-circle-close {
|
|
|
+ font-size: 24px;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|