|
|
@@ -72,51 +72,79 @@
|
|
|
</el-row>
|
|
|
|
|
|
<el-row>
|
|
|
- <el-form-item label="藏品图片">
|
|
|
- <el-upload
|
|
|
- class="avatar-uploader"
|
|
|
- ref="upload"
|
|
|
- accept=".jpg,.png"
|
|
|
- :headers="headerObj"
|
|
|
- :action="uploadUrl"
|
|
|
- :on-error="handleError"
|
|
|
- :show-file-list="false"
|
|
|
- :on-success="handleIconSuccess"
|
|
|
- :before-upload="beforeIconUpload"
|
|
|
- :on-change="handleChange"
|
|
|
- :on-remove="handleRemove"
|
|
|
- >
|
|
|
- <img
|
|
|
- v-if="ruleForm.thumb"
|
|
|
- :src="OSSURL + ruleForm.thumb"
|
|
|
- class="avatar"
|
|
|
- />
|
|
|
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
- <!-- 单纯用来刷新视图的变化的 -->
|
|
|
- <el-input v-show="false" v-model="refresh"></el-input>
|
|
|
- </el-upload>
|
|
|
- <div>
|
|
|
- <p style="color: #999">格式要求:</p>
|
|
|
- <p style="color: #999; line-height: 1">1、支持png,jpeg的图片格式</p>
|
|
|
- <p style="color: #999">2、最大可支持10M</p>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
+ <div class="myRow">
|
|
|
+ <!-- 单纯用来刷新视图的变化的 -->
|
|
|
+ <el-input v-show="false" v-model="refresh"></el-input>
|
|
|
+
|
|
|
+ <!-- 裁剪的图片 -->
|
|
|
+ <el-form-item label="封面图片">
|
|
|
+ <Cropper
|
|
|
+ :width="250"
|
|
|
+ :height="250"
|
|
|
+ :fixed-number="[1, 1]"
|
|
|
+ :uploadUrl="uploadUrl"
|
|
|
+ :img="ruleForm.thumb"
|
|
|
+ @clearImg="ruleForm.thumb = ''"
|
|
|
+ @subUploadSucceed="getShopImages"
|
|
|
+ >
|
|
|
+ </Cropper>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="藏品图片">
|
|
|
+ <el-upload
|
|
|
+ class="avatar-uploader"
|
|
|
+ ref="upload"
|
|
|
+ accept=".jpg,.png"
|
|
|
+ :headers="headerObj"
|
|
|
+ :action="uploadUrl"
|
|
|
+ :on-error="handleError"
|
|
|
+ :show-file-list="false"
|
|
|
+ :on-success="handleIconSuccess"
|
|
|
+ :before-upload="beforeIconUpload"
|
|
|
+ :on-change="handleChange"
|
|
|
+ :on-remove="handleRemove"
|
|
|
+ >
|
|
|
+ <img
|
|
|
+ v-if="ruleForm.filePath"
|
|
|
+ :src="OSSURL + ruleForm.filePath"
|
|
|
+ class="avatar"
|
|
|
+ />
|
|
|
+ <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <div>
|
|
|
+ <p style="color: #999">格式要求:</p>
|
|
|
+ <p style="color: #999; line-height: 1">
|
|
|
+ 1、支持png,jpeg的图片格式
|
|
|
+ <br />
|
|
|
+ <br />
|
|
|
+ 2、最大可支持10M
|
|
|
+ <br />
|
|
|
+ <br />
|
|
|
+ 3、封面图片建议上传250 * 250尺寸的图片
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-form-item label="藏品介绍" prop="description">
|
|
|
<!-- <vue-editor class="quill-editor" v-model="ruleForm.description" /> -->
|
|
|
- <!-- 图片上传 -->
|
|
|
- <el-upload
|
|
|
- class="upload-demo"
|
|
|
- action="http://8.135.106.227:8001/manage/goods/upload"
|
|
|
- multiple
|
|
|
- :headers="headerObj"
|
|
|
- :before-upload="beforethumbUploadImg"
|
|
|
- :on-success="upload_thumb_successImg"
|
|
|
+ <!-- 图片上传 -->
|
|
|
+ <el-upload
|
|
|
+ class="upload-demo"
|
|
|
+ action="http://8.135.106.227:8001/manage/goods/upload"
|
|
|
+ multiple
|
|
|
+ :headers="headerObj"
|
|
|
+ :before-upload="beforethumbUploadImg"
|
|
|
+ :on-success="upload_thumb_successImg"
|
|
|
+ >
|
|
|
+ <el-button size="small" type="primary">图片上传</el-button>
|
|
|
+ <span class="fwbtit"
|
|
|
+ >支持png、jpg、gif和jpeg的图片格式;最大支持5M</span
|
|
|
>
|
|
|
- <el-button size="small" type="primary">图片上传</el-button>
|
|
|
- <span class="fwbtit">支持png、jpg、gif和jpeg的图片格式;最大支持5M</span>
|
|
|
- </el-upload>
|
|
|
+ </el-upload>
|
|
|
<div id="div1" style="z-index: 1"></div>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
@@ -134,12 +162,15 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import Cropper from "@/components/cropper";
|
|
|
import E from "wangeditor";
|
|
|
import * as common from "@/util/commonfn.js";
|
|
|
// import { VueEditor } from "vue2-editor";
|
|
|
export default {
|
|
|
+ name: "CPXX",
|
|
|
components: {
|
|
|
// VueEditor,
|
|
|
+ Cropper,
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -149,11 +180,15 @@ export default {
|
|
|
token: window.localStorage.getItem("token"),
|
|
|
},
|
|
|
ruleForm: {
|
|
|
+ thumb: "",
|
|
|
goodsTypeId: "",
|
|
|
display: 0,
|
|
|
},
|
|
|
rules: {
|
|
|
- name: [{ required: true, message: "请输入藏品名称", trigger: "blur" },{ max: 32, message: '不能超过32个字', trigger: 'blur' }],
|
|
|
+ name: [
|
|
|
+ { required: true, message: "请输入藏品名称", trigger: "blur" },
|
|
|
+ { max: 32, message: "不能超过32个字", trigger: "blur" },
|
|
|
+ ],
|
|
|
goodsTypeId: [
|
|
|
{ required: true, message: "请选择藏品分类", trigger: "blur" },
|
|
|
],
|
|
|
@@ -194,37 +229,44 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 图片裁剪功能
|
|
|
+ getShopImages(img) {
|
|
|
+ this.ruleForm = { ...this.ruleForm, thumb: img.ossPath };
|
|
|
+ // this.ruleForm.thumb = img.ossPath;
|
|
|
+ // 刷新下页面
|
|
|
+ this.refresh = "刷新了";
|
|
|
+ },
|
|
|
// 上传图片
|
|
|
- beforethumbUploadImg (file) {
|
|
|
+ beforethumbUploadImg(file) {
|
|
|
// console.log(998, file)
|
|
|
// 限制图片大小和格式
|
|
|
- const sizeOk = file.size / 1024 / 1024 < 5
|
|
|
+ const sizeOk = file.size / 1024 / 1024 < 5;
|
|
|
const typeOk =
|
|
|
- file.type === 'image/png' ||
|
|
|
- file.type === 'image/jpeg' ||
|
|
|
- file.type === 'image/gif'
|
|
|
+ file.type === "image/png" ||
|
|
|
+ file.type === "image/jpeg" ||
|
|
|
+ file.type === "image/gif";
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
if (!typeOk) {
|
|
|
- this.$message.error('照片格式有误!')
|
|
|
- reject(file)
|
|
|
+ this.$message.error("照片格式有误!");
|
|
|
+ reject(file);
|
|
|
} else if (!sizeOk) {
|
|
|
- this.$message.error('照片大小超过5M!')
|
|
|
- reject(file)
|
|
|
+ this.$message.error("照片大小超过5M!");
|
|
|
+ reject(file);
|
|
|
} else if (file.name.length > 32) {
|
|
|
- this.$message.error('照片名字不能超过32个字!')
|
|
|
- reject(file)
|
|
|
+ this.$message.error("照片名字不能超过32个字!");
|
|
|
+ reject(file);
|
|
|
} else {
|
|
|
- resolve(file)
|
|
|
+ resolve(file);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
- upload_thumb_successImg (data) {
|
|
|
- this.$message.success('上传成功')
|
|
|
- console.log('图片上传成功', data)
|
|
|
+ upload_thumb_successImg(data) {
|
|
|
+ this.$message.success("上传成功");
|
|
|
+ console.log("图片上传成功", data);
|
|
|
this.editor.txt.append(
|
|
|
`<img src="${data.data.ossUrl}" style="max-width:100%" /><p>  </p>`
|
|
|
- );
|
|
|
+ );
|
|
|
},
|
|
|
quxiao(reload) {
|
|
|
this.$layer.close(this.layerid);
|
|
|
@@ -236,7 +278,7 @@ export default {
|
|
|
submitForm(formName) {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- if (!this["ruleForm"].thumb) {
|
|
|
+ if (!this["ruleForm"].thumb || !this["ruleForm"].filePath) {
|
|
|
common.tip("warning", "请上传图片");
|
|
|
return;
|
|
|
}
|
|
|
@@ -248,15 +290,8 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
async save() {
|
|
|
- let {
|
|
|
- name,
|
|
|
- id,
|
|
|
- goodsTypeId,
|
|
|
- modelUrl,
|
|
|
- thumb,
|
|
|
- type,
|
|
|
- goodsAgeId,
|
|
|
- } = this.ruleForm;
|
|
|
+ let { name, id, goodsTypeId, modelUrl, thumb, type, goodsAgeId,filePath } =
|
|
|
+ this.ruleForm;
|
|
|
let data = {
|
|
|
name,
|
|
|
id,
|
|
|
@@ -265,8 +300,9 @@ export default {
|
|
|
thumb,
|
|
|
type,
|
|
|
goodsAgeId,
|
|
|
+ filePath
|
|
|
};
|
|
|
- data.description=this.editor.txt.html()
|
|
|
+ data.description = this.editor.txt.html();
|
|
|
let result = await this.$http({
|
|
|
method: "post",
|
|
|
data,
|
|
|
@@ -282,31 +318,30 @@ export default {
|
|
|
handleError() {},
|
|
|
handleIconSuccess(res) {
|
|
|
let { data } = res;
|
|
|
- this.ruleForm.thumb = data.ossPath;
|
|
|
+ this.ruleForm = { ...this.ruleForm, filePath: data.ossPath };
|
|
|
+ // this.ruleForm.thumb = data.ossPath;
|
|
|
// 刷新下页面
|
|
|
this.refresh = "刷新了";
|
|
|
},
|
|
|
beforeIconUpload(file) {
|
|
|
// console.log('上传文件前校验', file)
|
|
|
// 限制图片大小和格式
|
|
|
- const sizeOk = file.size / 1024 / 1024 < 10
|
|
|
- const typeOk =
|
|
|
- file.type === 'image/png' ||
|
|
|
- file.type === 'image/jpeg'
|
|
|
+ const sizeOk = file.size / 1024 / 1024 < 10;
|
|
|
+ const typeOk = file.type === "image/png" || file.type === "image/jpeg";
|
|
|
return new Promise((resolve, reject) => {
|
|
|
if (!typeOk) {
|
|
|
- this.$message.error('照片格式有误!')
|
|
|
- reject(file)
|
|
|
+ this.$message.error("照片格式有误!");
|
|
|
+ reject(file);
|
|
|
} else if (!sizeOk) {
|
|
|
- this.$message.error('照片大小超过10M!')
|
|
|
- reject(file)
|
|
|
- }else if(file.name.length>32){
|
|
|
- this.$message.error('照片名字不能超过32个字!')
|
|
|
- reject(file)
|
|
|
+ this.$message.error("照片大小超过10M!");
|
|
|
+ reject(file);
|
|
|
+ } else if (file.name.length > 32) {
|
|
|
+ this.$message.error("照片名字不能超过32个字!");
|
|
|
+ reject(file);
|
|
|
} else {
|
|
|
- resolve(file)
|
|
|
+ resolve(file);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
handleChange(file) {
|
|
|
this.fileList = this.fileList.length === 0 ? this.fileList : [];
|
|
|
@@ -364,7 +399,7 @@ export default {
|
|
|
this.editor.config.uploadImgShowBase64 = true; //图片地址
|
|
|
this.editor.config.showLinkVideo = false;
|
|
|
this.editor.create();
|
|
|
- this.editor.txt.html(this.iframeData.description)
|
|
|
+ this.editor.txt.html(this.iframeData.description);
|
|
|
}, 100);
|
|
|
});
|
|
|
this.ruleForm = this.iframeData;
|
|
|
@@ -381,6 +416,12 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
+.myRow {
|
|
|
+ display: flex;
|
|
|
+ /deep/.el-form-item {
|
|
|
+ margin-right: 30px;
|
|
|
+ }
|
|
|
+}
|
|
|
/deep/.el-upload-list__item-name {
|
|
|
display: none !important;
|
|
|
}
|
|
|
@@ -391,7 +432,9 @@ export default {
|
|
|
.Root {
|
|
|
padding: 50px;
|
|
|
}
|
|
|
-
|
|
|
+/deep/.avatar-uploader {
|
|
|
+ max-height: 300px;
|
|
|
+}
|
|
|
.avatar-uploader .el-upload {
|
|
|
border: 1px dashed #d9d9d9;
|
|
|
border-radius: 6px;
|
|
|
@@ -400,12 +443,13 @@ export default {
|
|
|
overflow: hidden;
|
|
|
img {
|
|
|
max-width: 300px;
|
|
|
+ max-height: 300px;
|
|
|
}
|
|
|
}
|
|
|
.avatar-uploader .el-upload:hover {
|
|
|
border-color: #409eff;
|
|
|
}
|
|
|
-.avatar-uploader-icon {
|
|
|
+/deep/.avatar-uploader-icon {
|
|
|
font-size: 28px;
|
|
|
color: #8c939d;
|
|
|
width: 178px;
|