“体系文件”中上传的文件目前只能是pdf,其他格式的上传不了,建议能将word、excel及照片的格式上传。

“事件起因”建议去掉,与“原因分析及责任认定”中部分重合。“报出日期”的时间填写意义不大,建议去除。

事故事件中照片只能上传一张,多了就不让上传了,应该能上传多张,限制一下数量即可。附件也是只能上传pdf,其他格式上传不了,应能上传其他格式的文件。
pet
Shan Ao 2025-02-17 09:37:56 +08:00
parent 1ac52ed70d
commit 4e8847f93f
2 changed files with 97 additions and 107 deletions

View File

@ -1,7 +1,7 @@
<template>
<div class="app-container">
<el-form
ref="form"
ref="infoForm"
:model="infoForm"
:rules="rules"
label-width="180px"
@ -18,11 +18,6 @@
<el-option v-for="item in incidentTypes" :key="item.id" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
<!-- <el-form-item :label-width="formLabelWidth" label="事件级别" prop="incidentLevel">-->
<!-- <el-select v-model="infoForm.incidentLevel" :disabled="isDisabled" placeholder="请选择">-->
<!-- <el-option v-for="item in incidentLevels" :key="item.id" :label="item.name" :value="item.id"/>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item :label-width="formLabelWidth" label="事件发生地点" prop="location">
<el-input v-model="infoForm.location" :disabled="isDisabled" autocomplete="off"/>
</el-form-item>
@ -49,9 +44,6 @@
<el-form-item :label-width="formLabelWidth" label="重伤人数" prop="seriouslyInjured">
<el-input v-model="infoForm.seriouslyInjured" :disabled="isDisabled" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事件起因" prop="cause">
<el-input v-model="infoForm.cause" :disabled="isDisabled" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事件概述" prop="summary">
<el-input v-model="infoForm.summary" :disabled="isDisabled" autocomplete="off"/>
</el-form-item>
@ -67,17 +59,6 @@
<el-form-item :label-width="formLabelWidth" label="填表人" prop="creator">
<el-input v-model="infoForm.creator" :disabled="isDisabled" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="报出日期" prop="reportDate">
<el-date-picker
v-model="infoForm.reportDate"
:disabled="isDisabled"
type="datetime"
placeholder="请选择报出日期"
style="width: 100%;"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故照片" prop="fileList">
<el-upload
ref="upload"
@ -98,7 +79,7 @@
<i class="el-icon-plus"/>
</el-upload>
</el-form-item>
<el-form-item v-if="!isDisabled" :label-width="formLabelWidth" label="附件" prop="fileAddressList">
<el-form-item :label-width="formLabelWidth" label="附件" prop="fileAddressList">
<el-upload
ref="upload"
:disabled="isDisabled"
@ -108,6 +89,7 @@
:limit="limitNum"
:on-remove="handleRemoveAnnex"
:before-upload="beforeEventUpload"
:on-preview="handleDownloadAnnex"
:on-error="handleError"
:on-exceed="handleExceed"
name="file"
@ -116,14 +98,6 @@
<el-button :disabled="isDisabled" size="small" type="primary">点击上传</el-button>
</el-upload>
</el-form-item>
<el-form-item v-if="isDisabled" :label-width="formLabelWidth" label="附件" prop="fileAddressList">
<a
v-if="infoForm.fileAddressList != null && infoForm.fileAddressList.length !== 0"
:href="infoForm.fileAddressList[0].url"
style="display: flex;flex-wrap: wrap;gap: 10px;"
>{{ infoForm.fileAddressList[0].name }}</a>
</el-form-item>
</el-form>
<el-dialog :visible.sync="dialogImgVisible">
@ -168,15 +142,13 @@ export default {
injured: null, //
fatalities: null, //
seriouslyInjured: null, //
cause: '', //
summary: '', //
fileList: [], //
fileAddressList: [], //
analysis: '', //
suggestions: '', //
measures: '', //
creator: '', //
reportDate: null //
creator: '' //
},
formLabelWidth: '140px',
/** 事件类型 */
@ -185,7 +157,7 @@ export default {
incidentLevels: [],
tableName: '',
/** 图片上传限制个数 */
limitNum: 1,
limitNum: 6,
/** 预览弹窗 */
dialogImgVisible: false,
rules: {
@ -195,14 +167,12 @@ export default {
incidentNature: [{ required: true, message: '事件性质不能为空', trigger: 'blur' }],
location: [{ required: true, message: '事件发生地点不能为空', trigger: 'blur' }],
incidentDate: [{ required: true, message: '事件发生时间不能为空', trigger: 'blur' }],
cause: [{ required: true, message: '事件起因不能为空', trigger: 'blur' }],
summary: [{ required: true, message: '事件概述不能为空', trigger: 'blur' }],
fileList: [{ required: true, message: '事件照片不能为空', trigger: 'blur' }],
analysis: [{ required: true, message: '原因分析及责任认定不能为空', trigger: 'blur' }],
suggestions: [{ required: true, message: '考核建议不能为空', trigger: 'blur' }],
measures: [{ required: true, message: '整改措施不能为空', trigger: 'blur' }],
creator: [{ required: true, message: '填表人不能为空', trigger: 'blur' }],
reportDate: [{ required: true, message: '报出日期不能为空', trigger: 'blur' }]
creator: [{ required: true, message: '填表人不能为空', trigger: 'blur' }]
}
}
},
@ -220,32 +190,36 @@ export default {
if (id == null || id === '') {
this.infoForm = this.$options.data().infoForm
} else {
// ID,
requestFN('/accident/' + id, {}).then((data) => {
const fileList = []
if (data.info.photos != null && data.info.photos !== '') {
JSON.parse(data.info.photos).map((item) => {
fileList.push({
name: 'photo',
url: config.fileUrl + item,
remotePathName: item
})
})
}
const fileAddressList = []
if (data.info.attachmentAddress != null && data.info.attachmentAddress !== '') {
const names = data.info.attachmentNames == null ? [] : JSON.parse(data.info.attachmentNames)
const address = data.info.attachmentAddress == null ? [] : JSON.parse(data.info.attachmentAddress)
for (let i = 0; i < address.length; i++) {
fileAddressList.push({
name: names[i] || '附件',
url: config.fileUrl + address[i],
remotePathName: address[i]
})
}
}
this.infoForm = {
...data.info,
fileList: [
{
name: 'photo',
url: config.fileUrl + data.info.photos,
remotePathName: data.info.photos
}
],
fileAddressList: [
{
name: '附件',
url: config.fileUrl + data.info.attachmentAddress,
remotePathName: data.info.attachmentAddress
}
]
}
const fileAddress = this.infoForm.fileAddressList[0].remotePathName
if (fileAddress == null || fileAddress === '') {
this.infoForm.fileAddressList = []
fileList: fileList,
fileAddressList: fileAddressList
}
this.infoForm.incidentDate = new Date(data.info.incidentDate)
this.infoForm.reportDate = new Date(data.info.reportDate)
}).catch((e) => {
})
}
},
@ -254,13 +228,13 @@ export default {
/**
* 文件列表移除文件时的钩子
*/
handleRemovePicture(file) {
handleRemovePicture(file, fileList) {
if (file.remotePathName) {
requestFN(`/accident/delete/photos`, {
path: file.remotePathName
}).then((res) => {
if (res.result === 'success') {
this.infoForm.fileList = []
this.infoForm.fileList = fileList
this.$message({
message: '文件删除成功',
type: 'info',
@ -274,13 +248,13 @@ export default {
/**
* 文件列表移除文件时的钩子
*/
handleRemoveAnnex(file) {
handleRemoveAnnex(file, fileList) {
if (file.remotePathName) {
requestFN(`/accident/delete/photos`, {
path: file.remotePathName
}).then((res) => {
if (res.result === 'success') {
this.infoForm.fileAddressList = []
this.infoForm.fileAddressList = fileList
this.$message({
message: '文件删除成功',
type: 'info',
@ -299,6 +273,17 @@ export default {
this.dialogImageUrl = file.url
},
/**
* 点击文件列表中已上传的文件时的钩子
*/
handleDownloadAnnex(file) {
var a = document.createElement('a')
var event = new MouseEvent('click')
a.download = file.name
a.href = file.url
a.dispatchEvent(event)
},
/**
* 文件上传失败时的钩子处理
*/
@ -339,14 +324,11 @@ export default {
formData.append('file', file)
upload('/accident/import/photos', formData).then((data) => {
if (data.result === 'success') {
this.infoForm = {
...this.infoForm,
fileList: [{
name: file.name,
url: config.fileUrl + data.path,
remotePathName: data.path
}]
}
this.infoForm.fileList.push({
name: file.name,
url: config.fileUrl + data.path,
remotePathName: data.path
})
}
})
return false
@ -368,14 +350,11 @@ export default {
formData.append('file', file)
upload('/accident/import/photos', formData).then((data) => {
if (data.result === 'success') {
this.infoForm = {
...this.infoForm,
fileAddressList: [{
name: file.name,
url: config.fileUrl + data.path,
remotePathName: data.path
}]
}
this.infoForm.fileAddressList.push({
name: file.name,
url: config.fileUrl + data.path,
remotePathName: data.path
})
}
})
return false
@ -425,29 +404,28 @@ export default {
* 表单确认按钮
*/
confirm() {
this.$refs.form.validate(valid => {
this.$refs.infoForm.validate(valid => {
if (!valid) {
return false
}
this.infoForm.incidentDate = formatDate(this.infoForm.incidentDate, 'YYYY-MM-DD HH:mm:ss')
this.infoForm.reportDate = formatDate(this.infoForm.reportDate, 'YYYY-MM-DD HH:mm:ss')
const address = this.infoForm.fileAddressList[0]
console.log(address)
const params = {
...this.infoForm,
photos: this.infoForm.fileList[0].remotePathName,
attachmentAddress: address == null ? '' : address.remotePathName,
photos: this.infoForm.fileList.map(item => item.remotePathName),
attachmentAddress: this.infoForm.fileAddressList.map(item => item.remotePathName),
attachmentNames: this.infoForm.fileAddressList.map(item => item.name),
type: 1
}
delete params.fileList
delete params.fileAddressList
requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), params)
.then((response) => {
.then(() => {
//
this.$message.success(this.tableName + '成功')
this.infoForm = this.$options.data().infoForm
this.$parent.activeName = 'List'
// eslint-disable-next-line handle-callback-err
}).catch((error) => {
}).catch(() => {
this.$message.error(this.tableName + '失败')
})
})

View File

@ -24,6 +24,7 @@
<a v-show="row.extension_name == '.txt'" style="color: #1e9fff" @click="goViewTxt(row.FILEPATH)">[]</a>
<a v-show="row.extension_name == '.pdf'" style="color: #1e9fff" @click="goViewPdf(row.FILEPATH)">[]</a>
<a v-show="row.extension_name == '.mp4'" style="color: #1e9fff" @click="goViewVideo(row.FILEPATH)">[]</a>
<a v-show="row.extension_name == '.jpg' || row.extension_name == '.jpeg' || row.extension_name == '.png'" style="color: #1e9fff" @click="goViewImg(row.FILEPATH)">[]</a>
<a v-show="row.extension_name == '.doc' || row.extension_name == '.xls' || row.extension_name == '.ppt' || row.extension_name == '.docx' || row.extension_name == '.xlsx' || row.extension_name == '.pptx'" style="color: #1e9fff" @click="goOffice(row.FILEPATH)">[]</a>
</template>
@ -82,12 +83,12 @@
<el-input v-model="form.NAME" placeholder="这里输入名称..." />
</el-form-item>
<el-form-item label="附件">
<span v-if="form.FFILE">{{ form.FFILE.name }}</span>
<el-upload
:before-upload="beforeFileUpload"
:on-change="handleChangePDF"
:auto-upload="false"
accept=".pdf"
:limit="1"
accept=".pdf, .doc, .xls, .jpg, .png, .jpeg"
class="avatar-uploader"
action="#">
<el-button type="primary">上传</el-button>
@ -115,7 +116,7 @@
:on-change="handleChangePDF2"
:before-upload = "beforeFileUpload2"
:auto-upload="false"
accept=".pdf"
accept=".pdf, .doc, .xls, .jpg, .png, .jpeg"
class="upload-demo"
action="#">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
@ -162,7 +163,16 @@
class="video-player vjs-custom-skin"/>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogViewImg" title="图片" width="600px">
<el-image
:src="imgUrl"
:preview-src-list="[imgUrl]"
style="width: 100px; height: 100px">
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline"/>
</div>
</el-image>
</el-dialog>
</div>
</template>
@ -180,11 +190,14 @@ export default {
directives: { waves },
data() {
return {
config: config,
txtPre: '',
imgUrl: '',
dialogFormUpload: false,
dialogForm: false,
listLoading: true,
treeLoading: false,
dialogViewImg: false,
dialogBatchUpload: false,
add: false,
del: false,
@ -259,7 +272,10 @@ export default {
this.urlToBlob()
},
methods: {
goViewImg(filePath) {
this.imgUrl = this.config.fileUrl + filePath
this.dialogViewImg = true
},
urlToBlob() {},
//
prePage() {
@ -321,20 +337,18 @@ export default {
console.log(file)
},
handleChangePDF(file, fileList) {
const types = ['application/pdf']
const isImage = types.includes(file.raw.type)
if (!isImage) {
this.$message.error('上传文件只能是 PDF 格式!')
const types = ['pdf', 'doc', 'xls', 'jpg', 'png', 'jpeg']
if (!types.includes(file.name.substring(file.name.lastIndexOf('.') + 1))) {
this.$message.error('上传文件只支持【' + types + '】格式!')
fileList.pop()
} else {
this.form.FFILE = file.raw
}
},
handleChangePDF2(file, fileList) {
const types = ['application/pdf']
const isImage = types.includes(file.raw.type)
if (!isImage) {
this.$message.error('上传文件只能是 PDF 格式!')
const types = ['pdf', 'doc', 'xls', 'jpg', 'png', 'jpeg']
if (!types.includes(file.name.substring(file.name.lastIndexOf('.') + 1))) {
this.$message.error('上传文件只支持【' + types + '】格式!')
fileList.pop()
}
},
@ -355,23 +369,21 @@ export default {
// return false
// },
beforeFileUpload2(file) {
var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
const extension = testmsg === 'pdf'
if (!extension) {
this.$confirm(`上传文件只能是pdf格式!`)
} else {
const types = ['pdf', 'doc', 'xls', 'jpg', 'png', 'jpeg']
if (types.includes(file.name.substring(file.name.lastIndexOf('.') + 1))) {
this.fileList.push(file)
} else {
this.$confirm('上传文件只支持【' + types + '】格式!')
}
this.$forceUpdate()
return false
},
beforeFileUpload(file) {
var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
const extension = testmsg === 'pdf'
if (!extension) {
this.$confirm(`上传文件只能是pdf格式!`)
} else {
const types = ['pdf', 'doc', 'xls', 'jpg', 'png', 'jpeg']
if (types.includes(file.name.substring(file.name.lastIndexOf('.') + 1))) {
this.form.FFILE = file
} else {
this.$confirm('上传文件只支持【' + types + '】格式!')
}
this.$forceUpdate()
return false