Commit 6b0fcb52 authored by Xiaxuxia's avatar Xiaxuxia

新增影像图库

parent cf0c03e4
import fetch from 'utils/fetch'; import fetch from 'utils/fetch';
//获取影像图库列表
export function page(query) { export function page(query) {
return fetch({ return fetch({
url: '/api/website/imageImgStorage/getList', url: '/api/website/imageImgStorage/getList',
...@@ -7,7 +7,7 @@ export function page(query) { ...@@ -7,7 +7,7 @@ export function page(query) {
params: query params: query
}); });
} }
//新增或修改影像图库
export function update(query) { export function update(query) {
return fetch({ return fetch({
url: '/api/website/imageImgStorage/addUpdate', url: '/api/website/imageImgStorage/addUpdate',
...@@ -15,3 +15,19 @@ export function update(query) { ...@@ -15,3 +15,19 @@ export function update(query) {
data: query data: query
}); });
} }
//获取所有相似图像
export function getAll(query) {
return fetch({
url: '/api/website/imageInfoRelation/getAll',
method: 'get',
params: query
});
}
///api/website/imageImgStorage/getDetail/{id}
export function getDetail(query) {
return fetch({
url: `/api/website/imageImgStorage/getDetail/${query}`,
method: 'get'
});
}
<template> <template>
<div class="upload-container"> <div class="upload-container">
<el-upload <el-upload
v-show="!imageUrl" v-show="!value"
ref="upload" :ref="refName"
drag drag
v-loading="uploading" v-loading="uploading"
action="#" action="#"
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__text">只能上传1个文件</div> <div class="el-upload__text">只能上传1个文件</div>
</el-upload> </el-upload>
<div class="image-preview" v-show="imageUrl"> <div class="image-preview" v-show="value">
<div class="image-preview-wrapper"> <div class="image-preview-wrapper">
<img :src="imageUrl" /> <img :src="value" />
<div class="image-preview-action"> <div class="image-preview-action">
<i @click="rmImage" class="el-icon-delete"></i> <i @click="rmImage" class="el-icon-delete"></i>
</div> </div>
...@@ -29,12 +29,16 @@ ...@@ -29,12 +29,16 @@
// 预览效果见专题 // 预览效果见专题
import { uploadFile } from "@/api/website/newsCategory/index"; import { uploadFile } from "@/api/website/newsCategory/index";
export default { export default {
name: "singleImageUpload2", name: "singleImageX",
props: { props: {
refName: {
type: String,
default: 'upload'
},
//图片地址 //图片地址
value: { value: {
type: String, type: String,
default: "", default: () => "",
}, },
}, },
data() { data() {
...@@ -42,26 +46,29 @@ export default { ...@@ -42,26 +46,29 @@ export default {
uploading: false uploading: false
}; };
}, },
computed: {
imageUrl() {
return (!!this.value) ? this.value : ""
}
},
methods: { methods: {
//删除图片 //删除图片
rmImage() { rmImage() {
this.$refs.upload.clearFiles() this.$refs[this.refName].clearFiles()
this.emitFunc(""); this.emitFunc("", null);
}, },
//上传请求 //上传请求
onUploadRequest(data) { onUploadRequest(data) {
this.uploading = true; this.uploading = true;
let fileObj = data.file; let fileObj = data.file;
console.log(data)
//获取图片详情信息
let imgInfo = {};
let temp = URL.createObjectURL(fileObj) let temp = URL.createObjectURL(fileObj)
let img = new Image(); let img = new Image();
img.src = temp; img.src = temp;
console.log(img.width, img.height) img.onload = function () {
imgInfo.width = img.width;
imgInfo.height = img.height;
}
imgInfo.size = fileObj.size;
imgInfo.type = fileObj.type;
// FormData 对象 // FormData 对象
let form = new FormData(); let form = new FormData();
...@@ -72,16 +79,16 @@ export default { ...@@ -72,16 +79,16 @@ export default {
this.uploading = false; this.uploading = false;
if (res.status == 200) { if (res.status == 200) {
this.emitFunc(res.data) this.emitFunc(res.data, imgInfo)
} else { } else {
this.emitFunc(""); this.emitFunc("", null);
this.$message.error(res.message) this.$message.error(res.message)
} }
}) })
}, },
//组件通信 //组件通信
emitFunc(val) { emitFunc(val, info = null) {
this.$emit('input', val) this.$emit('input', val, info)
} }
}, },
}; };
......
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
if (!!val) { if (!!val) {
this.$bus.$emit('satelliteIntroduction-edit-renderData', val) this.$bus.$emit('imageLibrary-edit-renderData', val)
} }
}) })
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
<el-table-column align="center" type="index" label="序号" width="65"></el-table-column> <el-table-column align="center" type="index" label="序号" width="65"></el-table-column>
<el-table-column align="center" label="产品名称" prop="name"></el-table-column> <el-table-column align="center" label="产品名称" prop="name"></el-table-column>
<el-table-column align="center" label="产品类型" prop="type"></el-table-column> <el-table-column align="center" label="产品类型" prop="type"></el-table-column>
<el-table-column align="center" label="尺寸" prop="imageInfoRelationList.ileWidth"></el-table-column> <el-table-column align="center" label="尺寸" prop="imageInfoRelationList[0].fileWidth"></el-table-column>
<el-table-column align="center" label="价格" prop="name"></el-table-column> <el-table-column align="center" label="价格" prop="imageInfoRelationList[0].price"></el-table-column>
<el-table-column align="center" label="状态"> <el-table-column align="center" label="状态">
<template slot-scope="scope"> <template slot-scope="scope">
{{ getStatus(scope.row.status) }} {{ getStatus(scope.row.status) }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment