fzq #31

Closed
fanzhiqin wants to merge 215 commits from fzq into test
3 changed files with 40 additions and 4 deletions
Showing only changes of commit a9265d6708 - Show all commits

View File

@ -1,6 +1,7 @@
<template> <template>
<div class="base-upload" style="border-radius: 8px; margin-top: 38px; padding: 0; max-height: 500px;"> <div class="base-upload" style="border-radius: 8px; margin-top: 38px; padding: 0; max-height: 500px;">
<el-upload class="yd-upload" :action="$http.adornUrl(url)" multiple name="files" :file-list="fileList" :on-remove="handleRemove" :before-remove="beforeRemove"> <el-upload class="yd-upload" action="#" :http-request="handleUpload" multiple :file-list="fileList" :on-remove="handleRemove" :before-remove="beforeRemove">
<!-- <el-upload class="yd-upload" :action="$http.adornUrl(url)" multiple name="files" :data="extraParams" :file-list="fileList" :on-remove="handleRemove" :before-remove="beforeRemove"> -->
<el-button size="small" type="primary">{{ buttonContent }}</el-button> <el-button size="small" type="primary">{{ buttonContent }}</el-button>
<div v-if="tip" slot="tip" class="el-upload__tip">{{ tip }}</div> <div v-if="tip" slot="tip" class="el-upload__tip">{{ tip }}</div>
</el-upload> </el-upload>
@ -16,6 +17,10 @@ export default {
tip: { tip: {
type: String, type: String,
default: null default: null
},
extraParams: {
type: Object,
default: () => ({})
} }
}, },
data() { data() {
@ -24,6 +29,30 @@ export default {
} }
}, },
methods: { methods: {
/** 自定义上传行为 */
handleUpload(file) {
const formData = new FormData()
let files = file.file
formData.append('files', files)
this.$http({
url: this.$http.adornUrl(this.url),
method: 'POST',
data: formData,
params: {
typeCode: this.extraParams.typeCode
}
}).then(({ data: res }) => {
if (res && res.code === 0) {
console.log(this.fileList)
this.fileList.splice(0)
res.data.forEach(item => {
this.fileList.push(item) // <==
})
// TODO: files[]
}
})
},
beforeRemove(file, filelist) { beforeRemove(file, filelist) {
return this.$confirm(`确定移除 ${file.name}?`) return this.$confirm(`确定移除 ${file.name}?`)
}, },

View File

@ -85,7 +85,8 @@ const addOrUpdateConfigs = {
label: '上传资料', label: '上传资料',
component: () => import('@/components/base-upload'), component: () => import('@/components/base-upload'),
props: { // props props: { // props
url: "/monitoring/attachment/uploadFileFormData?typeCode=EquipmentTypeFile", url: "/monitoring/attachment/uploadFileFormData",
extraParams: { typeCode: 123 },
buttonContent: '点击上传', buttonContent: '点击上传',
tip: '上传文件大小不要超过 2mb (2048kb)' tip: '上传文件大小不要超过 2mb (2048kb)'
} }

View File

@ -57,7 +57,7 @@ import AddOrUpdate from '@/components/base-dialog/addOrUpdate'
// import AddOrUpdate from './qualityInspectionRecord-add-or-update' // import AddOrUpdate from './qualityInspectionRecord-add-or-update'
import BaseTable from '@/components/base-table' import BaseTable from '@/components/base-table'
import TableOperateComponent from '@/components/base-table/components/operationComponent' import TableOperateComponent from '@/components/base-table/components/operationComponent'
import TableTextComponent from '@/components/base-table/components/detailComponent' // import TableTextComponent from '@/components/base-table/components/detailComponent'
const tableConfigs = [ const tableConfigs = [
{ prop: 'createTime', name: '添加时间' }, { prop: 'createTime', name: '添加时间' },
@ -78,7 +78,13 @@ const tableConfigs = [
{ prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] } { prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] }
] ]
const addOrUpdateConfigs = {} const addOrUpdateConfigs = {
type: 'dialog',
infoUrl: '/monitoring/qualityInspectionRecord',
fields: [
{name: '', label: '检测类型', type: 'select', options: []}
]
}
export default { export default {
data() { data() {