Commit 4cd8b6b5 authored by liang's avatar liang

文件上传

parent 3dce4ce7
......@@ -19,8 +19,15 @@
>
<div class="flex">
<div>
<el-upload-self
v-if="item.type === 'upload'"
v-bind="item"
:upload-query="{ formId, patientId, prefix: item.prop }"
v-model="form[item.prop]"
:disabled="item.disabled"
></el-upload-self>
<!-- 表单改文本 -->
<template v-if="vwForm.detail">
<template v-else-if="vwForm.detail">
<form-item-text :item="item" :form="form"></form-item-text>
</template>
<template v-else>
......@@ -342,12 +349,6 @@
>
</el-date-picker>
</template>
<el-upload-self
v-if="item.type === 'upload'"
v-bind="item"
v-model="form[item.prop]"
:disabled="item.disabled"
></el-upload-self>
</div>
<span
class="important_field"
......@@ -385,6 +386,11 @@ export default {
vwForm: {
default: {},
},
formId: {},
getPatientId: {
type: Function,
default: () => {},
},
getDefectsSet: {
type: Function,
default: () => {},
......@@ -428,6 +434,9 @@ export default {
defectsSet() {
return this.getDefectsSet ? this.getDefectsSet() : []
},
patientId() {
return this.getPatientId ? this.getPatientId() : ""
},
},
methods: {
scrollToView() {
......
......@@ -54,7 +54,12 @@ export default {
type: Boolean,
default: false,
},
bucketName: { type: String }, //后端上传文件路径(参数)
uploadQuery: {
type: Object,
default: () => {
return {}
},
}, //后端上传文件路径(参数)
listType: String,
tip: String,
multiple: Boolean,
......@@ -72,7 +77,7 @@ export default {
type: Boolean,
default: false,
},
value: Array,//上传文件数组 绑定数组
value: Array, //上传文件数组 绑定数组
},
data() {
return {
......@@ -91,13 +96,8 @@ export default {
if (newValue === oldValue) return
this.fileList = newValue.map((_) => {
return {
name: _.fileName,
url:
this.httpPrefix +
"/disease-data/file/" +
_.bucketName +
"-" +
_.uuidName,
name: _.file_name,
url: `${this.httpPrefix}/disease-data/file/info/${_.bucket_name}/${_.prefix}-${_.uuid_name}`,
}
})
},
......@@ -113,8 +113,7 @@ export default {
action() {
return (
this.httpPrefix +
"/disease-data/file/upload?bucketName=" +
this.bucketName
`/disease-data/file/upload?formId=${this.uploadQuery.formId}&patientId=${this.uploadQuery.patientId}&prefix=${this.uploadQuery.prefix}`
)
},
// 预览list
......@@ -123,11 +122,7 @@ export default {
return this.value.map((_) => {
return (
_.url ||
this.httpPrefix +
"/disease-data/file/" +
_.bucketName +
"-" +
_.uuidName
`${this.httpPrefix}/disease-data/file/info/${_.bucket_name}/${_.prefix}-${_.uuid_name}`
)
})
},
......@@ -163,27 +158,43 @@ export default {
// 移除提醒
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.fileName || file.name}?`)
return this.$confirm(`确定移除 ${file.file_name || file.name}?`)
},
// 移除
handleRemove({ url }, fileList) {
const i = this.value.findIndex((_) => url.endsWith(_.uuidName))
if (i > -1) this.value.splice(i, 1)// 静态移除
const i = this.value.findIndex((_) => url.endsWith(_.uuid_name))
if (i > -1) this.value.splice(i, 1) // 静态移除
},
// 查看
handlePreview(file) {
const name = file.fileName || file.name
this.title = name
let responseUrl
if (file.response) {
const _ = file.response.data
responseUrl = `${this.httpPrefix}/disease-data/file/info/${_.bucket_name}/${_.prefix}-${_.uuid_name}`
}
try {
if (name.match(/\.(png|jpg|jpeg)/)) {
this.imgUrl = file.url
this.imgUrl = file.url || responseUrl
this.$refs.image.clickHandler()
} else {
const elink = document.createElement("a")
elink.download = name
elink.style.display = "none"
elink.href = file.url
elink.href = file.url || responseUrl
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
}
} catch {
const elink = document.createElement("a")
elink.download = name
elink.style.display = "none"
elink.href = file.url || responseUrl
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
......@@ -204,6 +215,5 @@ export default {
<style lang="scss" scoped>
.el-upload-self {
font-size: 14px;
margin-bottom: 15px;
}
</style>
......@@ -82,6 +82,14 @@ export default {
getAll: Boolean, // 获取页面所有数据
},
components: { CustomForm, TagsScrollBar },
provide() {
return {
formId: this.form.formId,
getPatientId: () => {
return this.patientId || this.patientStandbyId
},
}
},
data() {
return {
btnType: "",
......
......@@ -154,9 +154,9 @@ export default {
},
methods: {
handleView(row) {
this.handleAdd(row, true)
this.handleAdd(row, null, true)
},
handleAdd({ patient_id, hzxx_xm }, disabled = false) {
handleAdd({ patient_id, hzxx_xm }, index, disabled = false) {
this.disabled = disabled
this.isDetail = true
this.patientId = patient_id || null
......
......@@ -131,7 +131,7 @@ export default {
width: 80,
formatter: (row) => {
return this.$handle.formatDicList(
this.dictMap["gender"],
this.dictMap["d-sex"],
String(row.sex)
)
},
......@@ -249,7 +249,7 @@ export default {
spanCount: 12,
prop: "sex",
optsFormatter: () => {
return this.dictMap && this.dictMap["gender"]
return this.dictMap && this.dictMap["d-sex"]
},
},
{
......@@ -273,14 +273,12 @@ export default {
prop: "orgId",
opts: orgList,
func: this.orgChange,
rules: [{ required: true, message: "请选择机构" }],
},
{
type: "select",
label: "科室",
spanCount: 12,
prop: "deptId",
rules: [{ required: true, message: "请选择科室" }],
opts: [],
},
{
......@@ -478,7 +476,7 @@ export default {
? {
id,
name,
sex: String(sex),
sex: sex ? String(sex) : "",
idCard,
phone,
email,
......
......@@ -88,8 +88,8 @@ module.exports = {
},
proxy: {
"/api": {
// target: "http://192.168.31.140:11021/",
target: "https://ds.cixincloud.com/geca-api/",
target: "http://192.168.31.140:11021/",
// target: "https://ds.cixincloud.com/geca-api/",
changeOrigin: true,
pathRewrite: {
"^/api": "",
......
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