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 7bad01cadc536502197ecc3b870ca31565518d42..19e795a787f683bfcdba967c71fd70577de4e85a 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 d898a33a7e7e08cb7fe8f25cbe73c2ccaf7ab769..42c185022ce815ae1f084b4e7e55e06baddc38cd 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 0000000000000000000000000000000000000000..6d4723df53231a8cac371a6e74d9b2f3a945df26 --- /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 852e54218fd8afcb153c22110ae8bbb2f523802c..822b90a9ca0f33a161366ba3931f298822e1cd3f 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