Commit b922e068 authored by zhang's avatar zhang
parents a71efc04 21e2858a
...@@ -23,38 +23,55 @@ ...@@ -23,38 +23,55 @@
@input="input" @input="input"
> >
</el-input> </el-input>
<div <div
style="width: 20rem; display: inline-block; vertical-align: middle" style="width: 20rem; display: inline-block; vertical-align: middle"
> >
{{ i.object }} {{ i.object }}
</div> </div>
</div>
</div>
<el-upload <el-upload
class="upload-demo" class="upload-demo"
ref="fileUpload" ref="fileUpload"
:action="uploadImgUrl" :action="uploadImgUrl"
:on-preview="handlePreview" :on-preview="handlePreview"
v-model="model.file" v-model="i.file"
:on-remove="handleRemove" :on-remove="handleRemove"
accept=".pdf" accept=".pdf ,.doc ,.docx ,.xls, .xlsx"
:before-remove="beforeRemove" :before-remove="beforeRemove"
:show-file-list="false" :show-file-list="false"
:limit="1" :limit="1"
:on-success="handleSuccess" :on-success="
res => {
handleSuccess(res, i)
}
"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:headers="headers" :headers="headers"
> >、
<el-button size="small" :disabled="status" type="primary" <!-- <el-button
size="small"
v-if="i.path"
v-loading="loading"
:disabled="status"
type="primary"
>{{ i.file_name }}</el-button
> -->
<el-button
size="small"
v-loading="loading"
:disabled="status"
type="primary"
>上传文件</el-button >上传文件</el-button
> >
<div slot="tip" class="el-upload__tip"> <div slot="tip" class="el-upload__tip">
<div v-if="model.path"> <div v-if="i.path">
<el-link :href="model.path">{{ model.name }}</el-link> <el-link :href="i.path">{{ i.file_name }}</el-link>
</div> </div>
</div> </div>
</el-upload> </el-upload>
</div> </div>
</div>
</div>
</template> </template>
<script> <script>
export default { export default {
...@@ -83,11 +100,9 @@ export default { ...@@ -83,11 +100,9 @@ export default {
return { return {
model: { model: {
value: '', value: '',
list: [], list: []
file: '',
path: '',
name: ''
}, },
loading: false,
headers: { headers: {
Authorization: 'Bearer ' + this.$store.getters.token Authorization: 'Bearer ' + this.$store.getters.token
}, },
...@@ -172,6 +187,9 @@ export default { ...@@ -172,6 +187,9 @@ export default {
value: '', value: '',
check: false, check: false,
useCaseNo: i.useCaseNo, useCaseNo: i.useCaseNo,
path: '',
file: '',
file_name: '',
key: i.value, key: i.value,
id: i.id, id: i.id,
flag: i.flag flag: i.flag
...@@ -183,13 +201,18 @@ export default { ...@@ -183,13 +201,18 @@ export default {
}, },
handlePreview(file) { handlePreview(file) {
console.log(file) console.log(file)
this.loading = true
}, },
handleSuccess(res, file) { handleSuccess(res, item) {
console.log(res, item)
if (res.code === 200) { if (res.code === 200) {
this.model.path = process.env.VUE_APP_IMAGE_API + res.url this.loading = false
this.model.name = res.originalFilename // const item = this.model.list[k]
this.$refs.fileUpload.clearFiles() item.path = process.env.VUE_APP_IMAGE_API + res.url
item.file_name = res.originalFilename
this.$message.success('上传成功') this.$message.success('上传成功')
this.$forceUpdate()
} else { } else {
this.$message.error('error') this.$message.error('error')
} }
......
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