Commit 7099ca8d by lichengming

修改了附件上传

parent 3d9a9288
...@@ -63,5 +63,10 @@ export default { ...@@ -63,5 +63,10 @@ export default {
http.post('soil/v1/sample_backup/page_backup', data).then(res => res), http.post('soil/v1/sample_backup/page_backup', data).then(res => res),
// 试验项目列表 // 试验项目列表
experimentPage: data => experimentPage: data =>
http.post('soil/v1/experiment/page', data).then(res => res) http.post('soil/v1/experiment/page', data).then(res => res),
// 开土制备试验照片预览
photoView: data =>
http
.get('soil/v1/sample_photo/view?objectKey=' + data.objectKey)
.then(res => res)
} }
<template>
<div>
<Modal v-model="showModal" :width="900" v-drag class="modal-footer-none zIndex-1100">
<p slot="header">{{modalTitle}}</p>
<div>
<FileManageCont ref="fileCont" :flag="flag"></FileManageCont>
</div>
</Modal>
</div>
</template>
<script>
import FileManageCont from './PhotoManageCont'
export default {
components: {
FileManageCont
},
props: {
// 只能删除自己的标识
flag: null
},
data() {
return {
showModal: false,
modalTitle: '试样照片'
}
},
methods: {
_open(id, key) {
this.showModal = true
this.$refs.fileCont._open(id, key)
}
}
}
</script>
<template>
<div>
<!--内容-->
<Row>
<!--查询-->
<Col span="24" style="margin-bottom: -10px">
<Form :label-width="70" inline onsubmit="return false">
<label class="label-sign"></label>
<Form-item label="文件名称:">
<Input v-model="fileName" @on-enter="_search" placeholder="请输入文件名称"
style="width:200px" clearable/>
</Form-item>
<Form-item class="search-btn">
<Button @click="_search" type="primary">搜索</Button>
</Form-item>
</Form>
</Col>
<!--列表-->
<Col span="24">
<FilesList ref="fileModal" :fileName="fileName" @on-result-change="_fileData"></FilesList>
</Col>
</Row>
<!--删除提示框-->
<ModalConfirm ref="confirmModal" :content="modalContent" :btnModalList="btnModalList"
@on-result-change="_modalResult"></ModalConfirm>
</div>
</template>
<script>
import ModalConfirm from '../../base/ModalConfirm'
import { meterEntrust } from '../../../api'
import FilesList from './PhotoList'
export default {
components: {
FilesList,
ModalConfirm
},
props: {
// 只能删除自己的标识
flag: null
},
data() {
return {
fileName: '',
selectIds: [],
getPage: {},
// ids
contractId: '',
sampleId: '',
subcontractorId: '',
originalRecordId: '',
curveId: '',
// 用于区分是哪种附件(合同、委托、样品)
idKey: '',
// 弹框的内容
modalContent: '',
btnModalList: [
{ type: '', name: '取消' },
{ type: 'primary', name: '确定' }
],
//
deleteId: [],
urlData: {}
}
},
methods: {
/**
* msg:表示是哪种附件(委托,样品,分包商)
* pageUrl:page 请求地址
* deleteUrl:删除请求地址
* uploadFileUrl:上传地址
* downloadFileUrl:下载地址
* uri:预览请求地址
* viewUri:预览图片地址
* downloadBatch:批量打包下载
*/
_open(id, key) {
this.fileName = ''
this.showModal = true
this.contractId = ''
this.sampleId = ''
this.subcontractorId = ''
this.originalRecordId = ''
this.curveId = ''
this.entrustId = ''
this.idKey = key
switch (key) {
// 委托
case 'contractId':
this.contractId = id
this.urlData = {
msg: 'FoodContractAttachment',
pageUrl: '/meter/v1/entrust_attachment/page',
deleteUrl: '/meter/v1/entrust_attachment/?ids=',
uploadFileUrl: '/meter/v1/entrust_attachment/upload/',
downloadFileUrl: '/meter/v1/entrust_attachment/download/',
downloadBatch: '/food/v1/contract_attachment/download_batch',
uri: 'FoodContractAttachment/getByContractId',
viewUri: '/meter/v1/entrust_attachment/preview/'
}
break
case 'entrustId':
this.entrustId = id
this.urlData = {
msg: 'FoodContractAttachment',
pageUrl: '/soil/v1/sample_photo/page',
deleteUrl: '/meter/v1/entrust_attachment/?ids=',
uploadFileUrl: '/soil/v1/sample_photo/upload/',
downloadFileUrl: '/soil/v1/sample_photo/download/',
downloadBatch: '/food/v1/contract_attachment/download_batch',
uri: 'FoodContractAttachment/getByContractId',
viewUri: 'soil/v1/sample_photo/view'
}
break
case 'sampleId':
// 样品
this.sampleId = id
this.urlData = {
msg: 'FoodSampleAttachment',
pageUrl: 'FoodSampleAttachment/page',
deleteUrl: 'FoodSampleAttachment/deleteByIds',
uploadFileUrl: '/food/v1/sample_attachment/upload/',
downloadFileUrl: '/food/v1/sample_attachment/download/',
downloadBatch: '/food/v1/sample_attachment/download_batch',
uri: 'FoodSampleAttachment/getBySampleId',
viewUri: '/food/v1/sample_attachment/view'
}
break
case 'subcontractorId':
// 分包商
this.subcontractorId = id
this.urlData = {
msg: 'FoodSubContractAttachment',
pageUrl: '/meter/v1/contract_attachment/page',
deleteUrl: '/meter/v1/contract_attachment/?ids=',
uploadFileUrl: '/meter/v1/contract_attachment/upload/',
downloadFileUrl: '/meter/v1/contract_attachment/download/',
downloadBatch: '/food/v1/subcontractor_attachment/download_batch',
uri: 'FoodSubContractAttachment/getBySubcontractorId',
viewUri: '/food/v1/subcontractor_attachment/view'
}
break
case 'originalRecordId':
// 原始记录
this.originalRecordId = id
this.urlData = {
msg: 'FoodOriginalRecordAttachment',
pageUrl: 'FoodOriginalRecordAttachment/page',
deleteUrl: 'FoodOriginalRecordAttachment/deleteByIds',
uploadFileUrl: '/food/v1/original_attachment/',
downloadFileUrl: '/food/v1/original_attachment/download/',
downloadBatch: '/food/v1/original_attachment/download_batch',
uri: 'FoodOriginalRecordAttachment/getByOriginalRecordId',
viewUri: '/food/v1/original_attachment/preview'
}
break
case 'curveId':
// 采样记录
this.curveId = id
this.urlData = {
msg: 'ElnCurveAttachment',
pageUrl: 'ElnCurveAttachment/page',
deleteUrl: 'ElnCurveAttachment/deleteByIds',
uploadFileUrl: '/print/v1/curve_attachment/',
downloadFileUrl: '/print/v1/curve_attachment/download/',
downloadBatch: '/print/v1/curve_attachment/download_batch',
uri: 'ElnCurveAttachment/getById',
viewUri: '/print/v1/curve_attachment/view'
}
break
}
const idsObj = {
contractId: this.contractId,
sampleId: this.sampleId,
subcontractorId: this.subcontractorId,
originalRecordId: this.originalRecordId,
curveId: this.curveId,
entrustId: this.entrustId
}
this.$refs.fileModal._setUploadData(
Object.assign({ id: id }, this.urlData),
idsObj,
this.idKey
)
},
_deleteById(ids) {
this.deleteId = ids
this.modalContent = '确定要删除这 ' + ids.length + ' 个附件?'
this.$refs.confirmModal._openModal()
},
_delPage: async function(data) {
console.log(data)
const result = await meterEntrust.attachmentDelete(
this.urlData.deleteUrl,
data.id
)
if (result) {
this.$Message.success('删除成功!')
this.$refs.fileModal._page()
}
this.$refs.confirmModal._closeModal()
this.deleteId = []
},
// 删除提示框返回
_modalResult(msg) {
if (msg === '确定') {
// 删除一条记录
if (this.flag === undefined) {
// 只能删除自己上传的
this._delPage({ id: this.deleteId, flag: 1 })
} else {
// 可以删除全部
this._delPage({ id: this.deleteId })
}
}
},
_fileData(msg, data) {
switch (msg) {
case 'delete':
this._deleteById(data)
break
}
},
// 搜索
_search() {
this.$refs.fileModal._page()
}
}
}
</script>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</Row> </Row>
</div> </div>
</div> </div>
<FileManage ref="FileManage"></FileManage> <PhotoManage ref="FileManage"></PhotoManage>
<Operation ref="operationModal"></Operation> <Operation ref="operationModal"></Operation>
<SamplePreparationEdit ref="editModal" @on-result-change="_formSearch"></SamplePreparationEdit> <SamplePreparationEdit ref="editModal" @on-result-change="_formSearch"></SamplePreparationEdit>
<SoilSampleManage ref="sampleManageModal" @on-result-change="_page"></SoilSampleManage> <SoilSampleManage ref="sampleManageModal" @on-result-change="_page"></SoilSampleManage>
......
...@@ -14,6 +14,7 @@ import VXEIconList from '../components/base/VXEIconList' ...@@ -14,6 +14,7 @@ import VXEIconList from '../components/base/VXEIconList'
import FileManage from '../components/file/file-manage/FileManage' import FileManage from '../components/file/file-manage/FileManage'
import VXESettingCol from '../components/base/VXESettingCol' import VXESettingCol from '../components/base/VXESettingCol'
import ElTableNoPage from '../components/table/ElTableNoPage' import ElTableNoPage from '../components/table/ElTableNoPage'
import PhotoManage from '../components/file/photo-manage/PhotoManage'
Vue.use(VXETable) Vue.use(VXETable)
Vue.component('btn-list', btnList) Vue.component('btn-list', btnList)
...@@ -25,4 +26,5 @@ Vue.component('PTVXETableData', PTVXETableData) ...@@ -25,4 +26,5 @@ Vue.component('PTVXETableData', PTVXETableData)
Vue.component('VXEIconList', VXEIconList) Vue.component('VXEIconList', VXEIconList)
Vue.component('VXESettingCol', VXESettingCol) Vue.component('VXESettingCol', VXESettingCol)
Vue.component('FileManage', FileManage) Vue.component('FileManage', FileManage)
Vue.component('PhotoManage', PhotoManage)
Vue.component('ElTableNoPage', ElTableNoPage) Vue.component('ElTableNoPage', ElTableNoPage)
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