Commit 2629549b by lichengming

修改了附件上传,输入搜索

parent 11926d54
......@@ -45,6 +45,8 @@ export default {
getVOById: data => http.get('soil/v1/entrust/vo/' + data).then(res => res),
deleteById: data =>
http.delete('soil/v1/entrust/?ids=' + data).then(res => res),
standardAnnexDelete: data =>
http.delete('soil/v1/standard_annex/?ids=' + data).then(res => res),
experimentDeleteById: data =>
http.delete('soil/v1/experiment/?ids=' + data).then(res => res),
// 保存
......
<template>
<div>
<Modal v-model="showEditModal" :mask-closable="false" width="600">
<p slot="header">{{modalTitle}}</p>
<div>
<Upload
:action="action"
:show-upload-list="false"
:before-upload="_beupload"
multiple
>
<Button type="dashed" icon="ios-cloud-upload-outline">上传文件(小于50MB)</Button>
</Upload>
<div>
<Card :dis-hover="true" style="width: 100%;height: 400px;overflow: auto;">
<p slot="title">已上传文件列表</p>
<div v-for="(item,index) in fileList" :key="index" class="file-upload-list">
<div>
<div class="file-upload-list-cover">
<Icon @click.native.stop="_handleRemove(item)" type="md-trash" style="color: white;font-size: 20px;"></Icon>
</div>
</div>
{{item.fileName }}
</div>
</Card>
</div>
</div>
<div slot="footer" class="btn-width">
<Button @click="showEditModal = false">取消</Button>
<Button @click="_mutipleUpload" :loading="isLoading" type="primary">{{btnName}}</Button>
</div>
</Modal>
</div>
</template>
<script>
/**
* 上传文件,在文件夹下
*/
import axios from 'axios'
import global from '../../../api/config'
import loading from '../../../api/loading'
export default {
data() {
return {
id: '',
ID: '',
action: '',
modalTitle: '',
showEditModal: false,
name: '',
isLoading: false,
btnName: '上传',
fileList: []
}
},
methods: {
_open(obj) {
this.fileList = []
this.showEditModal = true
this.ID = obj
this.modalTitle = '上传文件'
},
_beupload(file) {
// 单个文件上传超过50M时,取消上传
const isLt50M = file.size / 1024 / 1024 < 50
const fileName = file.name.split('.')[0]
if (!isLt50M) {
this.$Message.warning({
content: '文件 ' + fileName + ' 大小超多50M,请重新上传!',
duration: 3
})
this.isLoading = false
} else {
// 动态循环给文件命名
const temObj = {
file: file,
fileName: fileName
}
this.fileList.push(temObj)
}
return false
},
_mutipleUpload() {
if (this.fileList.length > 0 && this.btnName === '上传') {
this.isLoading = true
this.btnName = '上传中...'
// 创建formula对象
const formData = new FormData()
formData.append('entrustId', this.ID)
// 多个文件
for (let i = 0; i < this.fileList.length; i++) {
formData.append('file' + i, this.fileList[i].file)
}
const config = {
headers: {
'Content-Type': 'multipart/form-data'
}
}
const instanceFile = axios.create()
instanceFile.defaults.withCredentials = true
// 发起请求
instanceFile
.post(
global.baseURL + '/soil/v1/entrust_annex/upload_bath/' + this.ID,
formData,
{
headers: config
}
)
.then(res => {
if (res.data.code === '1') {
this.$Message.success('上传成功!')
this.showEditModal = false
this.$emit('on-result-change')
} else if (res.data.code === '0') {
loading.toast.show(res.data.code, res.data.msg)
this.$Message.error('操作失败')
}
this._resetLoading()
})
.catch(err => {
console.log(err)
this._resetLoading()
})
} else {
this.$Message.warning('请至少上传一个文件')
this._resetLoading()
}
},
_resetLoading() {
this.isLoading = false
this.btnName = '上传'
},
// 删除对应的上传的文件
_handleRemove(data) {
const index = this.fileList.findIndex(item => item === data)
this.fileList.splice(index, 1)
}
}
}
</script>
<style>
.file-upload-list {
display: inline-block;
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
border: 1px solid transparent;
border-radius: 4px;
overflow: hidden;
background: #fff;
position: relative;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
margin-right: 4px;
}
.file-upload-list:hover .file-upload-list-cover {
display: block;
}
.file-upload-list-cover {
display: none;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.6);
}
</style>
......@@ -22,7 +22,7 @@ export default {
data() {
return {
showModal: false,
modalTitle: '附件'
modalTitle: '附件管理'
}
},
methods: {
......
......@@ -104,8 +104,8 @@ export default {
msg: 'FoodContractAttachment',
pageUrl: 'soil/v1/entrust_annex/page',
deleteUrl: '/soil/v1/entrust_annex/?ids=',
uploadFileUrl: '/soil/v1/standard_annex/upload/',
downloadFileUrl: '/soil/v1/standard_annex/download/',
uploadFileUrl: '/soil/v1/entrust_annex/upload/',
downloadFileUrl: '/soil/v1/entrust_annex/download/',
downloadBatch: '/food/v1/contract_attachment/download_batch',
uri: 'FoodContractAttachment/getByContractId',
viewUri: '/soil/v1/standard_annex/preview/'
......
......@@ -22,6 +22,7 @@
<Button>上传</Button>
</Upload>
</label>
<Button @click="_batchUpload">批量上传</Button>
<!--一系列操作-->
<!--非表格-->
<!-- <Button v-if="viewStyle === 2 || viewStyle === 3" v-for="item in menusListA" :key="item.name" @click="_radioChange(item.value)"-->
......@@ -115,6 +116,7 @@
<!--/-->
</Col>
</Row>
<BatchUpload ref="batchUpload" @on-result-change="_page"></BatchUpload>
<!--上传loading-->
<div v-show="isLoad">
<Spin fix>
......@@ -134,11 +136,12 @@
// import VueGallerySlideshow from 'vue-gallery-slideshow'
import global from '../../../api/config'
import { meterEntrust } from '../../../api'
import BatchUpload from './BatchUpload'
/**
* 公共组件modal 弹框(支持上传,下载,预览,删除附件等操作)
*/
export default {
// components: { VueGallerySlideshow },
components: { BatchUpload },
props: {
fileName: null
},
......@@ -202,6 +205,9 @@ export default {
}
},
methods: {
_batchUpload() {
this.$refs.batchUpload._open(this.id)
},
_setUploadData(data, idsObj, idKey) {
this.selectIds = []
this.imgViewIndex = null
......@@ -411,6 +417,7 @@ export default {
} else {
this.isLoad = true
this.$Message.error(response.msg)
this.isLoad = false
}
}
}
......
......@@ -423,6 +423,7 @@ export default {
} else {
this.isLoad = true
this.$Message.error(response.msg)
this.isLoad = false
}
}
}
......
......@@ -310,7 +310,7 @@ export default {
},
_deleteOk: async function(ids) {
const result = await soilEntrust.deleteById(ids)
const result = await soilEntrust.standardAnnexDelete(ids)
if (result) {
this._resultChange('删除成功! ')
}
......
......@@ -340,13 +340,16 @@ export default {
} else if (this.customerData.indexOf(data) !== -1) {
this._getQueryList(data)
} else {
this._cusNameQuery(data)
}
},
_customerMatch(data) {
this._getQueryList(data)
},
_cusNameQuery(query) {
console.log('query', query)
this.formObj.client = query
this._getQueryList(query)
},
_btnClick(msg) {
......@@ -782,7 +785,12 @@ export default {
},
_getQueryList: async function(data) {
const result = await meterEntrust.pageQueryList(data)
const queryList = []
if (result) {
for (let i = 0; i < result.length; i++) {
queryList.push(result[i].cname)
}
this.customerData = queryList
console.log('委托商', result)
}
},
......
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