|
|
|
@ -10,7 +10,7 @@ |
|
|
|
<el-form-item label="积分" prop="points"> |
|
|
|
<el-input-number v-model="dataForm.points" :min="0" :max="1000000000" label="积分" style="width: 200px"></el-input-number> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="显示图片" prop="headPic"> |
|
|
|
<el-form-item label="显示图片" prop="headPic" v-loading="loading"> |
|
|
|
<el-upload |
|
|
|
class="avatar-uploader" |
|
|
|
:action="uploadUrl" |
|
|
|
@ -19,26 +19,8 @@ |
|
|
|
:before-upload="beforeAvatarUpload"> |
|
|
|
<img v-if="dataForm.headPic" :src="dataForm.headPic" class="avatar"> |
|
|
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i> |
|
|
|
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> |
|
|
|
</el-upload> |
|
|
|
<el-upload |
|
|
|
ref="upload" |
|
|
|
:action="uploadUrl" |
|
|
|
:class="{hide:hideUpload}" |
|
|
|
list-type="picture-card" |
|
|
|
:file-list="dataForm.images" |
|
|
|
:limit=1 |
|
|
|
:on-preview="handlePictureCardPreview" |
|
|
|
:on-remove="handleRemove" |
|
|
|
:on-success="handleAvatarSuccess" |
|
|
|
:on-error="handelError" |
|
|
|
:before-upload="beforeAvatarUpload" |
|
|
|
style="width:480px"> |
|
|
|
<i class="el-icon-plus"></i> |
|
|
|
</el-upload> |
|
|
|
<el-dialog :visible.sync="dialogVisible"> |
|
|
|
<img width="100%" :src="dialogImageUrl" alt=""> |
|
|
|
</el-dialog> |
|
|
|
<div><font color="gray">1张图</font></div> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="兑换开始时间" prop="startTime"> |
|
|
|
<el-date-picker |
|
|
|
@ -97,7 +79,6 @@ export default { |
|
|
|
content: '', |
|
|
|
points: '', |
|
|
|
headPic: '', |
|
|
|
images: [], |
|
|
|
startTime: '', |
|
|
|
endTime: '', |
|
|
|
state: '', |
|
|
|
@ -117,10 +98,7 @@ export default { |
|
|
|
options: [], |
|
|
|
isAble: false, |
|
|
|
uploadUrl: '', |
|
|
|
loading: false, |
|
|
|
dialogImageUrl: '', |
|
|
|
dialogVisible: false, |
|
|
|
hideUpload: false |
|
|
|
loading: false |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
@ -136,7 +114,7 @@ export default { |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
headPic: [ |
|
|
|
{ required: false, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
], |
|
|
|
startTime: [ |
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
|
|
@ -161,7 +139,8 @@ export default { |
|
|
|
}, |
|
|
|
created: function () { |
|
|
|
this.getOptions() |
|
|
|
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/uploadImg?token=${Cookies.get('token')}` |
|
|
|
// this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/uploadImg?token=${Cookies.get('token')}` |
|
|
|
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|
|
|
// this.uploadUrl = `http://219.146.91.110:10000/epdc-api/oss/file/uploadImg?token=${Cookies.get('token')}` |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
@ -200,64 +179,13 @@ export default { |
|
|
|
this.dataForm.deptId = this.dataForm.allDeptIds.substring(this.dataForm.allDeptIds.lastIndexOf(',')).replace(',', '') |
|
|
|
this.dataForm.deptName = this.dataForm.allDeptNames.substring(this.dataForm.allDeptNames.lastIndexOf('-')).replace('-', '') |
|
|
|
}, |
|
|
|
beforeAvatarUpload (file) { |
|
|
|
if (this.dataForm.images.length === 1) { |
|
|
|
this.$message.error('最多上传1张图片!') |
|
|
|
return false |
|
|
|
} |
|
|
|
this.loading = true |
|
|
|
this.isAble = true |
|
|
|
const isJPG = file.type === 'image/jpeg' |
|
|
|
const isPNG = file.type === 'image/png' |
|
|
|
// const isLt1M = file.size / 1024 / 1024 < 1 |
|
|
|
// 判断是否符合格式要求 |
|
|
|
if (!isJPG && !isPNG) { |
|
|
|
this.$message.error('上传文件必须是jpg、png格式!') |
|
|
|
this.loading = false |
|
|
|
this.isAble = false |
|
|
|
return false |
|
|
|
} |
|
|
|
}, |
|
|
|
// 上传图片 |
|
|
|
handleAvatarSuccess (res, file) { |
|
|
|
this.loading = false |
|
|
|
this.isAble = false |
|
|
|
if (res === null || res.data === null || res.data.imgUrl === null) { |
|
|
|
this.$message.error('文件上传失败!') |
|
|
|
this.handleErrorRemove(file) |
|
|
|
return false |
|
|
|
} |
|
|
|
this.dataForm.images.push({ url: res.data.imgUrl, thumbnail: res.data.thumbnail, fileType: 1 }) |
|
|
|
this.hideUpload = this.dataForm.images.length >= 1 |
|
|
|
// 头像控件使用 to do |
|
|
|
this.dataForm.headPic = res.data.imgUrl |
|
|
|
}, |
|
|
|
handleErrorRemove (file) { |
|
|
|
// 实现缩略图模板时删除文件 |
|
|
|
let fileList = this.$refs.upload.uploadFiles |
|
|
|
for (var i = 0; i < fileList.length; i++) { |
|
|
|
let item = fileList[i] |
|
|
|
if (item.url === file.url) { |
|
|
|
fileList.splice(i, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
handelError () { |
|
|
|
this.loading = false |
|
|
|
this.isAble = false |
|
|
|
this.$message.error('上传文件失败!') |
|
|
|
}, |
|
|
|
handleRemove (file, fileList) { |
|
|
|
for (var i = 0; i < this.dataForm.images.length; i++) { |
|
|
|
let item = this.dataForm.images[i] |
|
|
|
if (item.url === file.url) { |
|
|
|
this.dataForm.images.splice(i, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
this.hideUpload = this.dataForm.images.length >= 1 |
|
|
|
this.dataForm.headPic = res.data.url |
|
|
|
}, |
|
|
|
handlePictureCardPreview (file) { |
|
|
|
this.dialogImageUrl = file.url |
|
|
|
this.dialogVisible = true |
|
|
|
beforeAvatarUpload (file) { |
|
|
|
this.loading = true |
|
|
|
}, |
|
|
|
// 获取信息 |
|
|
|
getInfo () { |
|
|
|
@ -277,6 +205,20 @@ export default { |
|
|
|
if (!valid) { |
|
|
|
return false |
|
|
|
} |
|
|
|
// 校验兑换开始时间、结束时间 |
|
|
|
let startTime = new Date(this.dataForm.startTime) |
|
|
|
let endTime = new Date(this.dataForm.endTime) |
|
|
|
if (startTime.getTime() > endTime.getTime()) { |
|
|
|
this.$message({ |
|
|
|
message: '兑换开始时间大于结束时间、请修改后提交!', |
|
|
|
type: 'error', |
|
|
|
duration: 2000, |
|
|
|
onClose: () => { |
|
|
|
return false |
|
|
|
} |
|
|
|
}) |
|
|
|
return false |
|
|
|
} |
|
|
|
this.$http[!this.dataForm.id ? 'post' : 'put']('/points/acitveproductinfo/', this.dataForm).then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
@ -297,7 +239,27 @@ export default { |
|
|
|
} |
|
|
|
</script> |
|
|
|
<style> |
|
|
|
.hide .el-upload--picture-card { |
|
|
|
display: none; |
|
|
|
.avatar-uploader .el-upload { |
|
|
|
border: 1px dashed #d9d9d9; |
|
|
|
border-radius: 6px; |
|
|
|
cursor: pointer; |
|
|
|
position: relative; |
|
|
|
overflow: hidden; |
|
|
|
} |
|
|
|
.avatar-uploader .el-upload:hover { |
|
|
|
border-color: #409eff; |
|
|
|
} |
|
|
|
.avatar-uploader-icon { |
|
|
|
font-size: 28px; |
|
|
|
color: #8c939d; |
|
|
|
width: 178px; |
|
|
|
height: 178px; |
|
|
|
line-height: 178px; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
.avatar { |
|
|
|
width: 178px; |
|
|
|
height: 178px; |
|
|
|
display: block; |
|
|
|
} |
|
|
|
</style> |
|
|
|
|