From 6c6e0514283c7ff3016b845b600186b464e616c4 Mon Sep 17 00:00:00 2001 From: Your Name <123456> Date: 星期四, 25 八月 2022 16:44:56 +0800 Subject: [PATCH] 项目 --- src/views/doublePreventAction/hiddenDanger/hiddenDangerReform/report/components/reportDialog.vue | 104 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 93 insertions(+), 11 deletions(-) diff --git a/src/views/doublePreventAction/hiddenDanger/hiddenDangerReform/report/components/reportDialog.vue b/src/views/doublePreventAction/hiddenDanger/hiddenDangerReform/report/components/reportDialog.vue index fac85d8..c4d2bf2 100644 --- a/src/views/doublePreventAction/hiddenDanger/hiddenDangerReform/report/components/reportDialog.vue +++ b/src/views/doublePreventAction/hiddenDanger/hiddenDangerReform/report/components/reportDialog.vue @@ -114,6 +114,47 @@ <el-input class="analyseUnit_input" type="textarea" :rows="2" style="padding-bottom: 10px" v-model.trim="dataForm.rectifyDesc" placeholder="请输入整改措施"></el-input> </el-form-item> </el-col> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24"> + <el-form-item label="隐患上报图" prop="img"> + <el-upload + accept=".pdf,.jpg,.png" + :action="fileRoad" + class="upload-demo" + ref="upload" + :headers="header" + :data="uploadForm" + list-type="picture-card" + :file-list="fileList" + v-model="dataForm.paths" + :on-change="handleChangeFile" + :on-success="onFileSuccess" + :multiple="false" + :auto-upload="true"> + <i slot="default" class="el-icon-plus"></i> + <div slot="file" slot-scope="{file}"> + <img + class="el-upload-list__item-thumbnail" + :src="file.url" alt="" + > + <span class="el-upload-list__item-actions"> + <span + class="el-upload-list__item-preview" + @click="handleFile(file)" + > + <i class="el-icon-zoom-in"></i> + </span> + <span + v-if="!disabled" + class="el-upload-list__item-delete" + @click="handleRemove(file,file.$index)" + > + <i class="el-icon-delete"></i> + </span> + </span> + </div> + </el-upload> + </el-form-item> + </el-col> </el-row> @@ -132,15 +173,17 @@ import { hiddenDangerReport } from '@/api/hiddenDanger'; import {getToken} from "@/utils/auth"; import {modHiddenDangerReport} from "../../../../../../api/hiddenDanger"; + import Cookies from "_js-cookie@2.2.0@js-cookie"; export default { name: "reportDialog", data(){ return { + disabled:false, title:'', - baseUrl: process.env.BASE_API + 'hiddenDanger/report', - headers: { - 'Authorization': getToken() + fileRoad:process.env.BASE_API + '/task/web/upload', + uploadForm:{ }, + header:{Authorization:''}, submiting:false, departmentList: [], userList: [], @@ -206,7 +249,8 @@ liablePersonId: null, rectifyTime: null, cost: null, - rectifyDesc: null + rectifyDesc: null, + reportImage:[] }, dataFormRules:{ dangerDesc: [{ required: true, message: '请填写隐患情况描述', trigger: 'blur' }], @@ -278,19 +322,29 @@ liablePersonId: null, rectifyTime: null, cost: null, - rectifyDesc: null + rectifyDesc: null, + reportImages:[] } }else if(type === '修改'){ + console.log(value) for( let key in this.dataForm){ this.dataForm[key] = JSON.parse(JSON.stringify(value))[key] } this.dataForm.id = JSON.parse(JSON.stringify(value)).id + this.fileList = value.reportImages.map(item => { + return { + url : process.env.IMG_API + item + } + }) } }, trigger2Submit(){ this.$refs["dataForm"].validate(valid =>{ if(valid){ + this.dataForm.reportImages = this.fileList.map(item => { + return item.url.substring(process.env.IMG_API.length) + }) if(this.title === '新增'){ this.submiting = true hiddenDangerReport(this.dataForm).then(res=>{ @@ -307,7 +361,6 @@ type: 'warning' }); } - this.fileList = [] }).catch(err=>{ console.log(err) this.$message({ @@ -333,7 +386,6 @@ type: 'warning' }); } - this.fileList = [] }).catch(err=>{ console.log(err) this.$message({ @@ -352,7 +404,6 @@ }) } }) - }, changeUnit() { @@ -377,10 +428,41 @@ }, - handleChange(file, fileList) { - this.fileList = fileList + handleChangeFile(){ + this.header.Authorization = Cookies.get('token') }, - + onFileSuccess(response){ + if(response.code === '200'){ + this.fileList.push({url:process.env.IMG_API + response.result.path}) + this.$notify({ + type:'success', + duration:2000, + message:'上传成功', + title:'成功', + }) + }else{ + this.$message({ + message:res.data.message, + type:'warning' + }) + } + }, + handleFile(file){ + this.dialogImageUrl = file.url; + this.dialogVisible = true; + }, + showImg(file){ + window.open(file, '_blank') + }, + handleRemove(file,value){ + return this.$confirm(`确定移除 ${ file.uid }?`,'提示',{ + confirmButtonText:'确定', + cancelButtonText:'取消', + type:'warning', + }).then(()=> { + this.fileList.splice(value,1) + }) + }, } } -- Gitblit v1.9.2