Commit 41492672 by lichengming

修改了开土制备上传图片

parent 3fff0d1f
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<Button>上传</Button> <Button>上传</Button>
</Upload> </Upload>
</label> </label>
<Button @click="batchUpload">批量上传</Button>
<!--一系列操作--> <!--一系列操作-->
<!--非表格--> <!--非表格-->
<!-- <Button v-if="viewStyle === 2 || viewStyle === 3" v-for="item in menusListA" :key="item.name" @click="_radioChange(item.value)"--> <!-- <Button v-if="viewStyle === 2 || viewStyle === 3" v-for="item in menusListA" :key="item.name" @click="_radioChange(item.value)"-->
...@@ -115,6 +116,7 @@ ...@@ -115,6 +116,7 @@
<!--/--> <!--/-->
</Col> </Col>
</Row> </Row>
<BatchPhotoManage ref="batchUpload" @on-result-change="_page"></BatchPhotoManage>
<!--上传loading--> <!--上传loading-->
<div v-show="isLoad"> <div v-show="isLoad">
<Spin fix> <Spin fix>
...@@ -202,11 +204,15 @@ export default { ...@@ -202,11 +204,15 @@ export default {
} }
}, },
methods: { methods: {
batchUpload() {
this.$refs.batchUpload._open(this.id)
},
_setUploadData(data, idsObj, idKey) { _setUploadData(data, idsObj, idKey) {
this.selectIds = [] this.selectIds = []
this.imgViewIndex = null this.imgViewIndex = null
this.isLoad = false this.isLoad = false
this.id = data.id this.id = data.id
console.log('委托id', this.id)
const pageKey = idKey const pageKey = idKey
console.log(pageKey) console.log(pageKey)
this.$set(this.formObj, pageKey, data.id) this.$set(this.formObj, pageKey, data.id)
......
<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/sample_photo/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>
...@@ -215,6 +215,7 @@ export default { ...@@ -215,6 +215,7 @@ export default {
edit: false, edit: false,
cityData: [], cityData: [],
selectData: [], selectData: [],
sampleItemList: [],
searchOpen: true, searchOpen: true,
testedCityData: [], testedCityData: [],
judgeType: [{ value: 1, name: '是' }, { value: 0, name: '否' }], judgeType: [{ value: 1, name: '是' }, { value: 0, name: '否' }],
...@@ -386,11 +387,11 @@ export default { ...@@ -386,11 +387,11 @@ export default {
}, },
_removeItem(itemInfo) { _removeItem(itemInfo) {
console.log('试验项目', itemInfo) console.log('试验项目', itemInfo)
this.itemList = itemInfo.experimentList this.sampleItemList = itemInfo.experimentList
if (this.edit) { if (itemInfo.sampleCode !== '') {
this.$refs.sampleItemEdit._open(itemInfo.id) this.$refs.sampleItemEdit._open(itemInfo.id)
} else { } else {
this.$refs.sampleItemRemove._open(this.itemList) this.$refs.sampleItemRemove._open(this.sampleItemList)
} }
}, },
_removeItemBack(data) { _removeItemBack(data) {
...@@ -415,8 +416,9 @@ export default { ...@@ -415,8 +416,9 @@ export default {
console.log('去掉id后的data', info) console.log('去掉id后的data', info)
for (let i = 0; i < this.indexList.length; i++) { for (let i = 0; i < this.indexList.length; i++) {
const index = this.indexList[i] const index = this.indexList[i]
if (this.getPage.records[index].experimentList !== undefined) { if (this.getPage.records[index].experiments !== undefined) {
const name = [] const name = []
if (this.getPage.records[index].experimentList) {
this.itemList = this.getPage.records[index].experimentList this.itemList = this.getPage.records[index].experimentList
name.push(this.getPage.records[index].experiments) name.push(this.getPage.records[index].experiments)
for (let i = 0; i < info.length; i++) { for (let i = 0; i < info.length; i++) {
...@@ -426,6 +428,13 @@ export default { ...@@ -426,6 +428,13 @@ export default {
} }
this.getPage.records[index].experiments = name.join('、') this.getPage.records[index].experiments = name.join('、')
this.getPage.records[index].experimentList = this.itemList this.getPage.records[index].experimentList = this.itemList
} else {
name.push(this.getPage.records[index].experiments)
for (let i = 0; i < info.length; i++) {
name.push(info[i].name)
}
this.getPage.records[index].experiments = name.join('、')
}
this.$set(this.getPage.records, index, this.getPage.records[index]) this.$set(this.getPage.records, index, this.getPage.records[index])
} else { } else {
const name = [] const name = []
...@@ -439,6 +448,12 @@ export default { ...@@ -439,6 +448,12 @@ export default {
this.$set(this.getPage.records, index, this.getPage.records[index]) this.$set(this.getPage.records, index, this.getPage.records[index])
} }
} }
if (this.edit) {
const sampleData = {}
sampleData.id = this.id
sampleData.sampleList = this.getPage.records
this._sampleEdit(sampleData)
}
console.log(this.getPage.records) console.log(this.getPage.records)
}, },
_selectPerson() { _selectPerson() {
...@@ -633,7 +648,8 @@ export default { ...@@ -633,7 +648,8 @@ export default {
samplePack: '', samplePack: '',
sampleDescribe: '', sampleDescribe: '',
siteNo: '', siteNo: '',
experiments: '' experiments: '',
experimentList: []
} }
this.getPage.records.unshift(data) this.getPage.records.unshift(data)
}, },
...@@ -958,6 +974,13 @@ export default { ...@@ -958,6 +974,13 @@ export default {
this._resultChange('编辑成功!') this._resultChange('编辑成功!')
} }
}, },
_sampleEdit: async function(data) {
this._hideLoading()
const result = await soilEntrust.editDTO(data)
if (result) {
this.$Message.success('编辑成功')
}
},
_visibleChange(data) { _visibleChange(data) {
this.$forceUpdate() this.$forceUpdate()
console.log('清空') console.log('清空')
......
...@@ -193,7 +193,7 @@ export default { ...@@ -193,7 +193,7 @@ export default {
}) })
}, },
_deleteOk: async function(id) { _deleteOk: async function(id) {
const result = await soilEntrust.deleteById(id) const result = await soilEntrust.experimentDeleteById(id)
if (result) { if (result) {
this.$Message.success('删除成功') this.$Message.success('删除成功')
this._page() this._page()
...@@ -213,7 +213,11 @@ export default { ...@@ -213,7 +213,11 @@ export default {
} }
}, },
_ok() { _ok() {
const data = this.itemList.records const expNames = []
for (let i = 0; i < this.getPage.records.length; i++) {
expNames.push(this.getPage.records[i].name)
}
const data = expNames
this._saveCatalogueItem(data) this._saveCatalogueItem(data)
}, },
_saveCatalogueItem(data) { _saveCatalogueItem(data) {
......
...@@ -210,7 +210,7 @@ export default { ...@@ -210,7 +210,7 @@ export default {
this._sampleManage(data.id) this._sampleManage(data.id)
break break
case '试样照片': case '试样照片':
this._uploadPhoto(data.id) this._uploadPhoto(data)
break break
case '附件': case '附件':
this._upload(data.id) this._upload(data.id)
...@@ -370,11 +370,11 @@ export default { ...@@ -370,11 +370,11 @@ export default {
// this.$refs.itemManageModal._openByEntrustId(data) // this.$refs.itemManageModal._openByEntrustId(data)
}, },
_uploadPhoto(id) { _uploadPhoto(data) {
// 上传照片文件 // 上传照片文件
this.currentComponent = 'PhotoManage' this.currentComponent = 'PhotoManage'
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.refModal._open(id, 'entrustId') this.$refs.refModal._open(data.id, 'entrustId')
}) })
// this.$refs.PhotoManage._open(id, 'entrustId') // this.$refs.PhotoManage._open(id, 'entrustId')
}, },
......
...@@ -18,6 +18,7 @@ import VXESettingCol from '../components/base/VXESettingCol' ...@@ -18,6 +18,7 @@ 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' import PhotoManage from '../components/file/photo-manage/PhotoManage'
import elementTableHeight from '../components/table/elementTableHeight' import elementTableHeight from '../components/table/elementTableHeight'
import BatchPhotoManage from '../components/import/BatchUploadFile'
Vue.use(VXETable) Vue.use(VXETable)
Vue.component('btn-list', btnList) Vue.component('btn-list', btnList)
...@@ -33,4 +34,5 @@ Vue.component('VXEIconList', VXEIconList) ...@@ -33,4 +34,5 @@ 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('PhotoManage', PhotoManage)
Vue.component('BatchPhotoManage', BatchPhotoManage)
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