From 826c65fc925c81404dd224316e770e3aab906432 Mon Sep 17 00:00:00 2001 From: liudianxin Date: Fri, 24 Apr 2020 19:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{updatefile.vue => cropper.vue} | 129 ++++++----- src/components/table-input.vue | 47 ++-- src/components/table-um.vue | 87 ++++++-- src/components/upload_file.vue | 211 ++++++++++++++++++ src/pages/table_example.vue | 57 ++++- src/pages/upload_example.vue | 71 ++++-- 6 files changed, 479 insertions(+), 123 deletions(-) rename src/components/{updatefile.vue => cropper.vue} (62%) create mode 100644 src/components/upload_file.vue diff --git a/src/components/updatefile.vue b/src/components/cropper.vue similarity index 62% rename from src/components/updatefile.vue rename to src/components/cropper.vue index 7bad01c..19e795a 100644 --- a/src/components/updatefile.vue +++ b/src/components/cropper.vue @@ -1,29 +1,27 @@ @@ -67,18 +61,17 @@ export default { options: { autoCrop: true, //默认生成截图框 fixedBox: true, //固定截图框大小 - canMoveBox: false, //截图框不能拖动 + canMoveBox: true, //截图框不能拖动 autoCropWidth: 200, //截图框宽度 autoCropHeight: 200, //截图框高度 centerBox: false //截图框被限制在图片里面 }, previews: {}, //实时预览图数据 attach: { - //后端附件表 id: "", userId: "", customaryUrl: "", //原图片路径 - laterUrl: "", //裁剪后图片路径 /static/logo.png + laterUrl: "", //裁剪后图片路径 attachType: "photo" //附件类型 }, fileName: "", //本机文件地址 @@ -94,10 +87,10 @@ export default { realTime(data) { this.previews = data; }, - //加载头像信息 + //加载图片信息 find() { this.userId = sessionStorage.getItem("userId"); - this.$axios.post("/api/attach/find", this.attach).then(res => { + this.$http.post("ssapi", this.attach).then(res => { console.log(res); }); }, @@ -108,7 +101,7 @@ export default { this.$message.error("图片类型必须是.gif,jpeg,jpg,png,bmp中的一种"); return false; } - console.log(e.target.result); + // console.log(e.target); //fileReader 接口,用于异步读取文件数据 var reader = new FileReader(); reader.readAsDataURL(file); //重要 以dataURL形式读取文件 @@ -122,6 +115,7 @@ export default { // reader.readAsDataURL(file) // 转化为blob }; + this.dialogVisible = true; }, //确认截图,上传 cut(type) { @@ -129,13 +123,17 @@ export default { this.$refs.cropper.getCropBlob(res => { //res是裁剪后图片的bolb对象 formData.append("file", res, this.userId); - this.$axios - .put("ssapi", formData, { + let url = "ssurl"; + this.$http + .post(url, formData, { contentType: false, processData: false, headers: { "Content-Type": "multipart/form-data" } }) - .then(res => {}); + .then(res => { + // 上传图片后服务器返回访问路径 + this.$emit("getNewUrl", res.data.visitUrl); + }); }); } } @@ -143,21 +141,52 @@ export default { + \ No newline at end of file diff --git a/src/components/table-input.vue b/src/components/table-input.vue index d898a33..42c1850 100644 --- a/src/components/table-input.vue +++ b/src/components/table-input.vue @@ -1,41 +1,46 @@ \ No newline at end of file diff --git a/src/components/upload_file.vue b/src/components/upload_file.vue new file mode 100644 index 0000000..6d4723d --- /dev/null +++ b/src/components/upload_file.vue @@ -0,0 +1,211 @@ + + + + + \ No newline at end of file diff --git a/src/pages/table_example.vue b/src/pages/table_example.vue index 852e542..822b90a 100644 --- a/src/pages/table_example.vue +++ b/src/pages/table_example.vue @@ -1,13 +1,16 @@ @@ -25,8 +52,8 @@ export default { data: () => ({ headers: [ { label: "服务url", prop: "date", type: "href", align: "left" }, - { label: "服务名称", prop: "name", type: "input", align: "center" }, - { label: "中文名", prop: "address", type: "input", align: "right" }, + { label: "服务名称", prop: "name", type: "href", align: "center" }, + { label: "中文名", prop: "address", type: "href", align: "right" }, { label: "操作", type: "Button", @@ -44,16 +71,21 @@ export default { ] } ], + headers1: [ + { label: "服务url", prop: "date", type: "input", align: "center" }, + { label: "服务名称", prop: "name", type: "input", align: "center" }, + { label: "中文名", prop: "address", type: "input", align: "center" }, + ], url: "", detailsUrl: "ss/", addRowBtn: true, confirmOptions: { - title: "提示", //提示 - message: "确认删除该条数据?", //"" - btnCancelText: "取消", //取消 - btnSubmitText: "确定" //确定 - }, - emptyText: "暂时没数据" + title: "提示", //提示 + message: "确认删除该条数据?", //"" + btnCancelText: "取消", //取消 + btnSubmitText: "确定" //确定 + }, + emptyText: "暂时没数据" }), components: { cesTable @@ -67,8 +99,9 @@ export default { \ No newline at end of file -- 2.26.0