Commit 4811da74 by zhangquan

细节优化

1 parent b2b4f04e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="activity-img-box"> <div class="activity-img-box">
<template v-if="imageUrlArr && imageUrlArr.length > 0"> <template v-if="imageUrlArr && imageUrlArr.length > 0">
<div v-for="(item, index) in imageUrlArr" :key="index"> <div v-for="(item, index) in imageUrlArr" :key="index">
<div v-if="picOptions.type == 'video'"> <!-- <div v-if="picOptions.type == 'video'">
<video <video
controls controls
class="pic-box" class="pic-box"
...@@ -12,6 +12,27 @@ ...@@ -12,6 +12,27 @@
<div class="pic-pane-close" @click="handleEnlarge(item, 'video')"> <div class="pic-pane-close" @click="handleEnlarge(item, 'video')">
<img :src="require('@/assets/view.png')" alt="" /> <img :src="require('@/assets/view.png')" alt="" />
</div> </div>
</div> -->
<div
class="pic-box"
:style="{ width: picOptions.width, height: picOptions.height }"
v-if="picOptions.type == 'video'"
>
<video id="video" width="100%" height="100%" preload loop muted>
<source :src="item" type="video/mp4" />
</video>
<div class="mask">
<div class="pic-pane-close" @click="handleEnlarge(item, 'video')">
<img :src="require('@/assets/view.png')" alt="" />
</div>
<div
class="pic-pane-close"
@click="close('video', index)"
v-if="picOptions.isClose"
>
<img :src="require('@/assets/icon-delete.png')" alt="" />
</div>
</div>
</div> </div>
<div <div
class="pic-box" class="pic-box"
...@@ -41,7 +62,10 @@ ...@@ -41,7 +62,10 @@
(imageUrlArr && imageUrlArr.length == 0 && limit == 1) (imageUrlArr && imageUrlArr.length == 0 && limit == 1)
" "
> >
<div class="upload-img"> <div
class="upload-img"
:style="{ width: picOptions.width, height: picOptions.height }"
>
<i class="el-icon-plus avatar-uploader-desc-icon"></i> <i class="el-icon-plus avatar-uploader-desc-icon"></i>
<div class="avatar-uploader-desc-word"> <div class="avatar-uploader-desc-word">
上传{{ picOptions.type == "video" ? "视频" : "图片" }} 上传{{ picOptions.type == "video" ? "视频" : "图片" }}
...@@ -50,6 +74,7 @@ ...@@ -50,6 +74,7 @@
type="file" type="file"
ref="uploadImg" ref="uploadImg"
class="upload-img" class="upload-img"
:style="{ width: picOptions.width, height: picOptions.height }"
style="opacity: 0" style="opacity: 0"
:accept="picOptions.type == 'video' ? '.mp4' : '.jpg, .jpeg, .png,'" :accept="picOptions.type == 'video' ? '.mp4' : '.jpg, .jpeg, .png,'"
@change="(e) => handleImgChange(e)" @change="(e) => handleImgChange(e)"
...@@ -103,14 +128,14 @@ export default { ...@@ -103,14 +128,14 @@ export default {
methods: { methods: {
// 上传图片 // 上传图片
handleImgChange(e) { handleImgChange(e) {
this.$notify({
title: "提示",
message: `${
this.picOptions.type == "video" ? "视频" : "图片"
}上传中,请稍后`
})
var file = e.srcElement.files[0] var file = e.srcElement.files[0]
var reader = new FileReader() var reader = new FileReader()
if (this.picOptions.type == "video" && file.type?.indexOf("mp4") == -1) {
return this.$message.error(`上传文件不是mp4的格式!`)
}
if (this.picOptions.type != "video" && !/jpg|jpeg|png/i.test(file.type)) {
return this.$message.error(`上传图片不是jpg、jpeg或png的格式!`)
}
// 默认1MB // 默认1MB
const limitSize = this.picOptions.limitSize || 10 const limitSize = this.picOptions.limitSize || 10
const isLt = file.size / 1024 / 1024 < limitSize const isLt = file.size / 1024 / 1024 < limitSize
...@@ -130,6 +155,12 @@ export default { ...@@ -130,6 +155,12 @@ export default {
) )
return return
} }
this.$notify({
title: "提示",
message: `${
this.picOptions.type == "video" ? "视频" : "图片"
}上传中,请稍后`
})
this.$emit("beforeUpload") this.$emit("beforeUpload")
reader.readAsDataURL(file) reader.readAsDataURL(file)
reader.onload = (e) => { reader.onload = (e) => {
...@@ -158,10 +189,10 @@ export default { ...@@ -158,10 +189,10 @@ export default {
index: this.index index: this.index
}) })
} }
e.target.value = ""
}) })
.finally((end) => { .finally((end) => {
this.$refs.uploadImg.value = "" this.$refs.uploadImg && (this.$refs.uploadImg.value = "")
e.target.value = ""
this.$emit("afterUpload", end) this.$emit("afterUpload", end)
}) })
} }
...@@ -174,23 +205,13 @@ export default { ...@@ -174,23 +205,13 @@ export default {
}, },
// 删除图片/视频 // 删除图片/视频
close(type, index) { close(type, index) {
switch (type) { this.imageUrlArr.splice(index, 1)
case "radio": this.$emit("change", {
this.videoUrl = "" arr: this.imageUrlArr,
this.videoImage = "" key: this.picOptions.key,
break id: 1,
case "img": index: this.index
this.imageUrlArr.splice(index, 1) })
this.$emit("change", {
arr: this.imageUrlArr,
key: this.picOptions.key,
id: 1,
index: this.index
})
break
default:
this.videoUrl = ""
}
} }
} }
} }
...@@ -202,8 +223,6 @@ export default { ...@@ -202,8 +223,6 @@ export default {
max-width: 600px; max-width: 600px;
.pic-box { .pic-box {
position: relative; position: relative;
width: 104px;
height: 104px;
border-radius: 4px; border-radius: 4px;
margin-right: 8px; margin-right: 8px;
margin-bottom: 5px; margin-bottom: 5px;
...@@ -229,8 +248,8 @@ export default { ...@@ -229,8 +248,8 @@ export default {
opacity: 0; opacity: 0;
top: 0; top: 0;
right: 0; right: 0;
width: 104px; left: 0;
height: 104px; bottom: 0;
z-index: 999; z-index: 999;
.pic-pane-close { .pic-pane-close {
width: 16px; width: 16px;
...@@ -252,8 +271,6 @@ export default { ...@@ -252,8 +271,6 @@ export default {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 104px;
height: 104px;
background: rgba(0, 0, 0, 0.04); background: rgba(0, 0, 0, 0.04);
border: 1px dashed rgba(0, 0, 0, 0.15); border: 1px dashed rgba(0, 0, 0, 0.15);
border-radius: 4px; border-radius: 4px;
...@@ -262,8 +279,6 @@ export default { ...@@ -262,8 +279,6 @@ export default {
position: absolute; position: absolute;
// top: 0; // top: 0;
// left: 0; // left: 0;
width: 104px;
height: 104px;
} }
} }
.avatar-uploader-desc-word { .avatar-uploader-desc-word {
......
...@@ -95,12 +95,11 @@ export default { ...@@ -95,12 +95,11 @@ export default {
methods: { methods: {
// 上传图片 // 上传图片
handleImgChange(e) { handleImgChange(e) {
this.$notify({
title: "提示",
message: `pdf上传中,请稍后`
})
var file = e.srcElement.files[0] var file = e.srcElement.files[0]
var reader = new FileReader() var reader = new FileReader()
if (file.type?.indexOf("pdf") == -1) {
return this.$message.error(`上传文件不是pdf的格式!`)
}
// 默认1MB // 默认1MB
const limitSize = this.picOptions.limitSize || 10 const limitSize = this.picOptions.limitSize || 10
const isLt = file.size / 1024 / 1024 < limitSize const isLt = file.size / 1024 / 1024 < limitSize
...@@ -112,6 +111,10 @@ export default { ...@@ -112,6 +111,10 @@ export default {
this.$message.error(`最多上传${this.limit}个pdf文件`) this.$message.error(`最多上传${this.limit}个pdf文件`)
return return
} }
this.$notify({
title: "提示",
message: `pdf上传中,请稍后`
})
this.$emit("beforeUpload") this.$emit("beforeUpload")
const idx = this.imageUrlArr.length const idx = this.imageUrlArr.length
this.$set(this.imageUrlArr, idx, { imageName: file.name, image: "" }) this.$set(this.imageUrlArr, idx, { imageName: file.name, image: "" })
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
</el-form-item> </el-form-item>
<el-form-item label-width="120px" label="封面:" prop="cover"> <el-form-item label-width="120px" label="封面:" prop="cover">
<glsx-preview <glsx-preview
:picOptions="coverOptions"
:imageUrlArr="formData.cover" :imageUrlArr="formData.cover"
limit="1" limit="1"
></glsx-preview> ></glsx-preview>
...@@ -67,7 +68,7 @@ ...@@ -67,7 +68,7 @@
limit="10" limit="10"
></glsx-preview> ></glsx-preview>
<p class="photo-top-tips"> <p class="photo-top-tips">
支持 .jpg .png,单个文件不超过10M,最多上传10个文件 支持 .jpg .jpeg .png,单个文件不超过10M,最多上传10个文件
</p> </p>
</div> </div>
<div v-if="formData.type == 1"> <div v-if="formData.type == 1">
...@@ -190,7 +191,12 @@ ...@@ -190,7 +191,12 @@
<el-button type="primary" class="width_100" @click="confirmAdd(1)" <el-button type="primary" class="width_100" @click="confirmAdd(1)"
>保存并使用</el-button >保存并使用</el-button
> >
<el-button type="primary" plain class="width_100" @click="commitFn(0)" <el-button
type="primary"
plain
class="width_100"
@click="commitFn(0)"
v-if="!routeInfo.status"
>存草稿</el-button >存草稿</el-button
> >
<el-button class="width_100 cancel-btn" @click="handleCancel" <el-button class="width_100 cancel-btn" @click="handleCancel"
...@@ -242,16 +248,22 @@ export default { ...@@ -242,16 +248,22 @@ export default {
merchantVisible: false, merchantVisible: false,
brandVisible: false, brandVisible: false,
tableData: [], tableData: [],
coverOptions: {
width: "88px",
height: "88px",
isClose: true,
limitSize: 1
},
picOptions: { picOptions: {
width: "104px", width: "88px",
height: "104px", height: "88px",
isClose: true, isClose: true,
limitSize: 10, limitSize: 10,
type: "img" type: "img"
}, },
videoOptions: { videoOptions: {
width: "104px", width: "88px",
height: "104px", height: "88px",
isClose: true, isClose: true,
limitSize: 200, limitSize: 200,
type: "video" type: "video"
...@@ -264,10 +276,12 @@ export default { ...@@ -264,10 +276,12 @@ export default {
}, },
formData: { formData: {
title: "", title: "",
type: 0, type: 1,
cover: [], cover: [],
subtitle: "", subtitle: "",
imageList: [], imageList: [
"http://qcimg01.glsx.com.cn:7060/group1/M00/06/80/wKgD3mX0-0qAchRTAIh_w-FpA1U588.mp4"
],
scene: "", scene: "",
showChannel: 0, showChannel: 0,
showMerchant: 0 showMerchant: 0
...@@ -348,12 +362,14 @@ export default { ...@@ -348,12 +362,14 @@ export default {
prop: "label" prop: "label"
} }
] ]
} },
routeInfo: {}
} }
}, },
mounted() { mounted() {
const { id } = this.$route.params const { id } = this.$route.params
this.routeInfo = this.$route.params
if (id) this.getDetail() if (id) this.getDetail()
}, },
...@@ -377,22 +393,13 @@ export default { ...@@ -377,22 +393,13 @@ export default {
this.formData[key] = res[key] this.formData[key] = res[key]
} }
} }
console.log(res) this.tableData = res?.assignInfos || []
} }
}) })
}, },
clearTableFn() { clearTableFn() {
this.tableData = [] this.tableData = []
}, },
handleImgChange() {},
handleImgLook(src) {
this.lookImgVisible = true
this.dialogObj = {
url: src,
uploadType: "photo"
}
},
handleImgDelete() {},
getParams(type) { getParams(type) {
const params = deepClone(this.formData) const params = deepClone(this.formData)
params.cover = params.cover[0] params.cover = params.cover[0]
...@@ -419,12 +426,20 @@ export default { ...@@ -419,12 +426,20 @@ export default {
return params return params
}, },
confirmAdd(type) { confirmAdd(type) {
this.$refs.ruleForm.validate((valid) => { this.$confirm("删除后内容不可恢复", "提示", {
this.$refs.channelForm.validate((cvalid) => { confirmButtonText: "确定",
if (valid && cvalid) { cancelButtonText: "取消",
this.commitFn(type) type: "warning"
} }).then((end) => {
}) if (end == "confirm") {
this.$refs.ruleForm.validate((valid) => {
this.$refs.channelForm.validate((cvalid) => {
if (valid && cvalid) {
this.commitFn(type)
}
})
})
}
}) })
}, },
commitFn(type) { commitFn(type) {
...@@ -442,7 +457,8 @@ export default { ...@@ -442,7 +457,8 @@ export default {
}) })
}, },
openMerchantDialog() { openMerchantDialog() {
if (!this.formData.scene) return this.$message.error("请先选择业务场景") if (!this.formData.scene && this.formData.scene !== 0)
return this.$message.error("请先选择业务场景")
if (this.formData.showMerchant == 1) { if (this.formData.showMerchant == 1) {
this.brandVisible = true this.brandVisible = true
} else { } else {
......
...@@ -335,6 +335,7 @@ export default { ...@@ -335,6 +335,7 @@ export default {
} }
if (row?.id) { if (row?.id) {
params.id = row.id params.id = row.id
params.status = row.status
} }
this.$router.push({ this.$router.push({
name: "contentAdd", name: "contentAdd",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!