巡检任务图片上传逻辑修改

master
jinna 11 months ago
parent 726469d4ea
commit 82e7a4048b
  1. 36
      src/views/businessManagement/inspection/task.vue
  2. 10
      src/views/device/deviceSystem.vue

@ -183,7 +183,7 @@
</span> </span>
</el-dialog> </el-dialog>
<el-dialog class="inspectionDialog" :title="dialogTitle" :visible.sync="dialogInspection" :append-to-body="true" <el-dialog class="inspectionDialog" :title="dialogTitle" :visible.sync="dialogInspection" :append-to-body="true"
width="70%" :close-on-click-modal="false"> width="70%" :close-on-click-modal="false" custom-class="task_dialog">
<div style="height: 500px; overflow: auto"> <div style="height: 500px; overflow: auto">
<el-form ref="inspectionForm" :model="inspectionForm" :rules="inspectionRules" label-width="120px" <el-form ref="inspectionForm" :model="inspectionForm" :rules="inspectionRules" label-width="120px"
label-position="left"> label-position="left">
@ -276,10 +276,10 @@
</el-table-column> </el-table-column>
<el-table-column prop="imgs" align="center" label="现场照片"> <el-table-column prop="imgs" align="center" label="现场照片">
<template slot-scope="scope"> <template slot-scope="scope">
<el-upload list-type="picture-card" v-show="dialogTitle != '巡检确认'" :disabled="dialogTitle == '巡检确认'||scope.row.picUrl != ''" <el-upload list-type="picture-card" v-show="dialogTitle != '巡检确认'" :disabled="dialogTitle == '巡检确认'" :class="scope.row.picUrl != '' ? 'exceed' : ''"
class="upload-demo" action="/api/blade-resource/oss/endpoint/put-file" class="upload-demo" action="/api/blade-resource/oss/endpoint/put-file"
:on-success="handleSuccess(scope.row)" :on-remove="handleRemove(scope.row)" :headers="headers" :on-success="handleSuccess(scope.row)" :on-remove="handleRemove(scope.row)" :headers="headers"
:limit="1" :on-exceed="handleExceed" :file-list="scope.row.fileList" :before-upload="beforeAvatarUpload(index,scope.row.fileList)"> :limit="1" :file-list="scope.row.fileList" :before-upload="beforeAvatarUpload(index,scope.row.fileList)">
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
</el-upload> </el-upload>
<img @click="clickImg(scope.row.picUrl)" style="width: 200px;height: 200px;cursor: pointer;" <img @click="clickImg(scope.row.picUrl)" style="width: 200px;height: 200px;cursor: pointer;"
@ -765,6 +765,7 @@ export default {
clickFloor(val) { clickFloor(val) {
console.log('val----------->', val) console.log('val----------->', val)
this.inspectionForm.tableData = this.inspectionTable this.inspectionForm.tableData = this.inspectionTable
console.log('inspectionTable===================>',this.inspectionTable)
this.deviceName = '' this.deviceName = ''
// this.activeFloor = val.value // this.activeFloor = val.value
this.activeFloorName = val this.activeFloorName = val
@ -773,6 +774,7 @@ export default {
this.activeRoom = this.roomArr[0] this.activeRoom = this.roomArr[0]
let firstRoom = firstFloor.details.find(item => item.deptName == this.activeRoom) let firstRoom = firstFloor.details.find(item => item.deptName == this.activeRoom)
this.tableData = firstRoom.details this.tableData = firstRoom.details
this.$forceUpdate()
}, },
clickRoom(val) { clickRoom(val) {
this.activeRoom = val this.activeRoom = val
@ -1270,7 +1272,6 @@ export default {
// //
handleSuccess(val) { handleSuccess(val) {
return (response, file, fileList) => { return (response, file, fileList) => {
console.log('val==========>', val)
// this.inspectionForm.tableData[index].picUrl = response.data.link // this.inspectionForm.tableData[index].picUrl = response.data.link
val.picUrl = response.data.link val.picUrl = response.data.link
val.fileList = [ val.fileList = [
@ -1279,17 +1280,34 @@ export default {
name: response.data.originalName name: response.data.originalName
} }
] ]
this.inspectionTable.map(item =>{
if(item.id == val.id){
item.fileList = [
{
url: response.data.link,
name: response.data.originalName
}
]
item.picUrl = response.data.link
}
})
} }
}, },
getRowKeys(row) { getRowKeys(row) {
return row.id return row.id
}, },
// //
handleRemove(index) { handleRemove(val) {
return (file, fileList) => { return (file, fileList) => {
// this.inspectionForm.tableData[index].picUrl = '' // this.inspectionForm.tableData[index].picUrl = ''
val.picUrl = '' val.picUrl = ''
val.fileList = [] val.fileList = []
this.inspectionTable.map(item =>{
if(item.id == val.id){
item.fileList = []
item.picUrl = ''
}
})
} }
}, },
beforeAvatarUpload(index,list){ beforeAvatarUpload(index,list){
@ -1414,4 +1432,12 @@ export default {
} }
} }
} }
.task_dialog{
.exceed{
.el-upload{
display: none;
}
}
}
</style> </style>

@ -156,7 +156,7 @@
<!-- :limit="3" --> <!-- :limit="3" -->
<el-upload class="upload-demo" action="/api/blade-resource/oss/endpoint/put-file" <el-upload class="upload-demo" action="/api/blade-resource/oss/endpoint/put-file"
:on-success="handleSuccess" :on-remove="handleRemove" multiple :disabled="viewType == 'view'" :on-success="handleSuccess" :on-remove="handleRemove" multiple :disabled="viewType == 'view'"
accept=".jpeg,.jpg,.png,.pdf" :on-exceed="handleExceed" :file-list="imgList"> accept=".jpeg,.jpg,.png,.pdf" :on-exceed="handleExceed" :file-list="imgList" :headers="headers">
<el-button size="small" type="primary">点击上传</el-button> <el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">支持上传jpegjpgpdf文件且不超过10M</div> <div slot="tip" class="el-upload__tip">支持上传jpegjpgpdf文件且不超过10M</div>
</el-upload> </el-upload>
@ -318,6 +318,8 @@
</template> </template>
<script> <script>
import website from '@/config/website';
import { getToken, removeToken, removeRefreshToken } from '@/util/auth';
import printJS from 'print-js' import printJS from 'print-js'
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import requestSub from '../components/requestSub.vue' import requestSub from '../components/requestSub.vue'
@ -345,6 +347,7 @@ export default {
tableData: [], tableData: [],
searchForm: {}, searchForm: {},
selectionList: [], selectionList: [],
headers:{},
option: { option: {
height: "auto", height: "auto",
calcHeight: 30, calcHeight: 30,
@ -603,6 +606,11 @@ export default {
this.repairPersonList = res.data.data this.repairPersonList = res.data.data
}) })
this.headers = {
"Authorization": `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`,
'Blade-Auth': 'bearer ' + getToken(),
'Blade-Requested-With': 'BladeHttpRequest'
}
this.onLoad() this.onLoad()
}, },
methods: { methods: {

Loading…
Cancel
Save