Commit 3300a2a3 authored by miaojiale's avatar miaojiale

1.修改上传组件的删除问题

2.修改上传组件
parent 98be2753
...@@ -154,7 +154,7 @@ export default { ...@@ -154,7 +154,7 @@ export default {
} }
return vwForm return vwForm
}, },
formId: "", // formId: "",
} }
}, },
data() { data() {
......
<template> <template>
<el-row class="el-upload-self"> <el-row class="el-upload-self">
<el-upload <el-upload
ref="upload"
:multiple="multiple" :multiple="multiple"
class="avatar-uploader" class="avatar-uploader"
ref="upload"
:action="action" :action="action"
:headers="headers" :headers="headers"
:list-type="listType" :list-type="listType"
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
:drag="drag" :drag="drag"
:disabled="disabled" :disabled="disabled"
> >
<!-- :http-request="handleUpload" -->
<template v-if="drag"> <template v-if="drag">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
...@@ -37,10 +38,10 @@ ...@@ -37,10 +38,10 @@
</el-upload> </el-upload>
<el-image <el-image
ref="image"
style="display: none" style="display: none"
:src="imgUrl" :src="imgUrl"
:preview-src-list="previewList" :preview-src-list="previewList"
ref="image"
> >
</el-image> </el-image>
</el-row> </el-row>
...@@ -50,7 +51,7 @@ ...@@ -50,7 +51,7 @@
import { getAccessToken } from "@/utils/accessToken" import { getAccessToken } from "@/utils/accessToken"
import { delFile } from "@/api/file" import { delFile } from "@/api/file"
export default { export default {
name: "el-upload-self", name: "ElUploadSelf",
props: { props: {
accept: { type: String, default: "image/*" }, accept: { type: String, default: "image/*" },
disabled: { disabled: {
...@@ -97,20 +98,6 @@ export default { ...@@ -97,20 +98,6 @@ export default {
fileList: [], fileList: [],
} }
}, },
watch: {
value: {
handler(newValue, oldValue) {
if (newValue === oldValue) return
this.fileList = newValue.map((_) => {
return {
name: _.file_name,
url: `https://ds.cixincloud.com/geca-api/disease-data/file/info/${_.bucketName}/${_.uuidName}`,
}
})
},
immediate: true,
},
},
computed: { computed: {
headers() { headers() {
return { return {
...@@ -118,7 +105,10 @@ export default { ...@@ -118,7 +105,10 @@ export default {
} }
}, },
action() { action() {
return this.httpPrefix + `/cloud-upms/file/upload` return (
this.httpPrefix +
`/disease-data/file/upload?formId=${this.uploadQuery.formId}&patientId=${this.uploadQuery.patientId}&prefix=${this.uploadQuery.prefix}`
)
}, },
// 预览list // 预览list
previewList() { previewList() {
...@@ -131,7 +121,35 @@ export default { ...@@ -131,7 +121,35 @@ export default {
}) })
}, },
}, },
watch: {
value: {
handler(newValue, oldValue) {
console.log(this.value)
if (newValue === oldValue) return
this.fileList = newValue.map((_) => {
return {
name: _.file_name,
url: `https://ds.cixincloud.com/geca-api/disease-data/file/info/${_.bucketName}/${_.uuidName}`,
}
})
},
immediate: true,
},
},
methods: { methods: {
// 自定义上传方法
// handleUpload(param) {
// let formData = new FormData()
// fd.append("file", param.file) //传文件
// fd.append("formld", this.formld) //传formld
// // ajax.axiosPost(
// // url, //接口地址
// // fd, //formdata对象参数
// // (res) => {
// // console.log(res)
// // }
// // )
// },
// 上传前回调 // 上传前回调
beforeUpload(file) { beforeUpload(file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -162,13 +180,19 @@ export default { ...@@ -162,13 +180,19 @@ export default {
// 移除提醒 // 移除提醒
beforeRemove(file, fileList) { beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.file_name || file.name}?`) // console.log(file, fileList)
return this.$confirm(
`确定移除 ${file.file_name || file.name || "该照片"}?`
)
}, },
// 移除 // 移除
handleRemove({ url }, fileList) { handleRemove({ url }, fileList) {
const i = this.value.findIndex((_) => url.endsWith(_.uuid_name)) let arr = url.split("/")
if (i > -1) this.value.splice(i, 1) // 静态移除 let uuidName = arr[arr.length - 1]
const i = this.value.findIndex((_) => uuidName == _.uuidName)
if (i > -1) this.value.splice(i, 1)
console.log("删了", this.value)
}, },
// 查看 // 查看
......
...@@ -157,7 +157,9 @@ export default { ...@@ -157,7 +157,9 @@ export default {
if (val == "index1") { if (val == "index1") {
// 第二步问卷调查 // 第二步问卷调查
this.$nextTick(() => { this.$nextTick(() => {
let { birthday } = JSON.parse(sessionStorage.getItem("index1Data")) let index1Data = sessionStorage.getItem("index1Data")
if (index1Data) {
let { birthday } = JSON.parse(index1Data)
let date = new Date(String(birthday).replace(/-/g, "/")) let date = new Date(String(birthday).replace(/-/g, "/"))
let d = new Date() let d = new Date()
let age = let age =
...@@ -172,6 +174,7 @@ export default { ...@@ -172,6 +174,7 @@ export default {
birthday, birthday,
age, age,
} }
}
}) })
} else { } else {
this.formInitial = false this.formInitial = false
......
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