feat: 事故信息管理菜单重构

hyx_2024-10-30_new
mengfanliang 2024-09-06 18:17:09 +08:00
parent 991ef9ea52
commit 2c930b42b2
6 changed files with 831 additions and 411 deletions

View File

@ -11,7 +11,7 @@ module.exports = {
assetsPublicPath: '/', assetsPublicPath: '/',
proxyTable: { proxyTable: {
'/api': { '/api': {
target: 'http://192.168.0.79:8091/', target: 'http://192.168.0.125:8091/',
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
'^/api': '' '^/api': ''

View File

@ -5,7 +5,7 @@
"author": "", "author": "",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 192.168.0.45", "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev", "start": "npm run dev",
"unit": "jest --config test/unit/jest.conf.js --coverage", "unit": "jest --config test/unit/jest.conf.js --coverage",
"e2e": "node test/e2e/runner.js", "e2e": "node test/e2e/runner.js",

View File

@ -0,0 +1,203 @@
<template>
<div class="app-container">
<el-form
ref="form"
:model="infoForm"
:rules="rules"
label-width="110px"
style="width: 800px"
>
<el-form-item :label-width="formLabelWidth" label="事故案号">
<el-input v-model="infoForm.incidentNumber" autocomplete="off" />
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故名称">
<el-input v-model="infoForm.incidentName" autocomplete="off" />
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故类型">
<el-select v-model="infoForm.hiddenPartList" placeholder="请选择">
<el-option
v-for="item in hiddenPartList"
:key="item.id"
:label="item.type"
:value="item.id"/>
</el-select>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故级别">
<el-select v-model="infoForm.incidentLevels" placeholder="请选择">
<el-option
v-for="item in incidentLevels"
:key="item.id"
:label="item.type"
:value="item.id"/>
</el-select>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故发生地点">
<el-input v-model="infoForm.location" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故发生时间">
<el-date-picker
v-model="infoForm.incidentDate"
type="date"
placeholder="选择日期"
style="width: 100%;"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd HH:mm:ss"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="直接经济损失">
<el-input v-model="infoForm.directLoss" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="受伤人数">
<el-input v-model="infoForm.injured" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="死亡人数">
<el-input v-model="infoForm.fatalities" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="重伤人数">
<el-input v-model="infoForm.seriouslyInjured" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故起因">
<el-input v-model="infoForm.cause" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故概述">
<el-input v-model="infoForm.summary" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故照片">
<!-- <el-upload
:limit="1"
:multiple="false"
action=""
list-type="picture-card"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload> -->
<el-upload
ref="upload"
:file-list="photos"
:multiple="false"
:limit="1"
:on-remove="handleRemovePicture"
:on-change="handleChangeIMG"
:on-preview="handlePictureCardPreview"
:before-upload="beforeHiddenUpload"
:auto-upload="false"
class="avatar-uploader"
action="#"
accept=".jpg,.jpeg,.png"
list-type="picture-card">
<i class="el-icon-plus" />
</el-upload>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="原因分析及责任认定">
<el-input v-model="infoForm.analysis" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="考核建议">
<el-input v-model="infoForm.suggestions" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="整改措施">
<el-input v-model="infoForm.measures" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="填表人">
<el-input v-model="infoForm.creator" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="报出日期">
<el-date-picker
v-model="infoForm.reportDate"
type="date"
placeholder="选择日期"
style="width: 100%;"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd HH:mm:ss"/>
</el-form-item>
</el-form>
<div class="ui-height" />
<div class="ui-foot">
<el-button
type="primary"
icon="el-icon-arrow-left"
plain
@click="goBack">返回</el-button>
<el-button type="primary" @click="confirm"> </el-button>
</div>
</div>
</template>
<script>
export default {
data() {
return {
infoForm: {
id: '', // ID
incidentNumber: '', //
incidentName: '', //
incidentType: null, //
companyName: '', //
incidentLevel: '', //
incidentNature: '', //
location: '', //
incidentDate: null, //
directLoss: '', //
injured: null, //
fatalities: null, //
seriouslyInjured: null, //
cause: '', //
summary: '', //
photos: [], //
analysis: '', //
suggestions: '', //
measures: '', //
creator: '', //
reportDate: null //
},
formLabelWidth: '140px',
hiddenPartList: [], //
incidentLevels: [], //
rules: {
incidentNumber: [{ required: true, message: '事故案号不能为空', trigger: 'blur' }],
incidentName: [{ required: true, message: '事故名称不能为空', trigger: 'blur' }],
HIDDENTYPE: [{ required: true, message: '事故类型不能为空', trigger: 'blur' }],
incidentType: [{ required: true, message: '隐患类型不能为空', trigger: 'blur' }],
incidentLevel: [{ required: true, message: '事故级别不能为空', trigger: 'blur' }],
incidentNature: [{ required: true, message: '事故性质不能为空', trigger: 'blur' }],
location: [{ required: true, message: '事故发生地点不能为空', trigger: 'blur' }],
incidentDate: [{ required: true, message: '事故发生时间不能为空', trigger: 'blur' }],
directLoss: [{ required: true, message: '直接经济损失(万元)不能为空', trigger: 'blur' }],
injured: [{ required: true, message: '受伤人数不能为空', trigger: 'blur' }],
seriouslyInjured: [{ required: true, message: '隐患类型不能为空', trigger: 'blur' }],
cause: [{ required: true, message: '事故起因不能为空', trigger: 'blur' }],
summary: [{ required: true, message: '事故概述不能为空', trigger: 'blur' }],
photos: [{ 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' }]
}
}
},
methods: {
handleRemovePicture() {},
handleChangeIMG() {},
handlePictureCardPreview() {},
beforeHiddenUpload() {},
/**
* 返回到列表页面
*/
goBack() {
this.$parent.activeName = 'List'
},
/**
* 表单确认按钮
*/
confirm() {}
}
}
</script>
<style scoped lang="scss"></style>

View File

@ -1,27 +1,29 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form ref="searchForm" :model="searchForm" label-width="100px"> <el-form ref="searchForm" :model="searchForm" label-width="90px">
<el-row :gutter="12"> <!-- 搜索查询 start -->
<el-row :gutter="24">
<el-col :span="4"> <el-col :span="4">
<el-form-item label="事故名称" prop="incidentName"> <el-form-item label="事故名称" prop="incidentName">
<el-input v-model="searchForm.incidentName" placeholder="请输入隐患描述" class="filter-item"/> <el-input v-model="searchForm.incidentName" placeholder="请输入事故名称" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="5">
<el-form-item label="发生时间" prop="incidentDates"> <el-form-item label="发生时间" prop="incidentDates">
<el-date-picker <el-date-picker
v-model="searchForm.incidentDates" v-model="searchForm.incidentDates"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss"
format="yyyy-MM-dd HH:mm:ss"
style="width: 100%" style="width: 100%"
type="daterange" type="daterange"
range-separator="" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期"/> end-placeholder="结束日期" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<el-form-item label="发生地点" prop="location"> <el-form-item label="发生地点" prop="location">
<el-input v-model="searchForm.location" placeholder="请输入关键字" class="filter-item"/> <el-input v-model="searchForm.location" placeholder="请输入发生地点" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
@ -38,31 +40,28 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="3">
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="getList"> <el-button v-waves type="primary" icon="el-icon-search" @click="searchList"></el-button>
查询 <el-button v-waves icon="el-icon-refresh" @click="handleReset"></el-button>
</el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-refresh" @click="reset">
重置
</el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-refresh" @click="changeDialog('添加')">
添加
</el-button>
<el-button v-waves class="filter-item" type="danger" icon="el-icon-delete" @click="deleteInBulk">
批量删除
</el-button>
<!-- <el-button v-waves class="filter-item" type="warning" icon="el-icon-star-off" @click="chongzhi">-->
<!-- 导出-->
<!-- </el-button>-->
<!-- <el-button v-waves class="filter-item" type="warning" icon="el-icon-star-off" @click="chongzhi">-->
<!-- 导出全部-->
<!-- </el-button>-->
<el-button v-waves class="filter-item" type="success" icon="el-icon-refresh" @click="getList">
刷新
</el-button>
</el-col> </el-col>
</el-row> </el-row>
<!-- 搜索查询 end -->
<!-- 顶部操作按钮 start -->
<el-row :gutter="24">
<el-col :span="24">
<el-button type="primary" icon="el-icon-circle-plus" @click="handleAddNew"></el-button>
<el-button icon="el-icon-top-right" @click="handleExport"></el-button>
<el-button icon="el-icon-s-promotion" @click="handleAllExport"></el-button>
<el-button icon="el-icon-refresh-left" @click="handleRefresh"></el-button>
<el-button type="danger" icon="el-icon-delete-solid" @click="handleBatchDel"></el-button>
</el-col>
</el-row>
<!-- 顶部操作按钮 end -->
</el-form> </el-form>
<!-- table 表格 start -->
<div style="margin-top: 16px;">
<el-table <el-table
v-loading="listLoading" v-loading="listLoading"
ref="multipleTable" ref="multipleTable"
@ -88,382 +87,129 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="page-btn-group">
<div/>
<pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList"/>
</div> </div>
<el-dialog :visible.sync="dialogFormVisible" :title="dialogTitle"> <!-- table 表格 end -->
<el-form :model="infoForm">
<el-form-item :label-width="formLabelWidth" label="事故案号"> <div class="pagination-group">
<el-input v-model="infoForm.incidentNumber" autocomplete="off"/> <pagination :total="listQuery.total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故名称">
<el-input v-model="infoForm.incidentName" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故类型">
<el-select v-model="infoForm.hiddenPartList" placeholder="请选择">
<el-option
v-for="item in hiddenPartList"
:key="item.id"
:label="item.type"
:value="item.id"/>
</el-select>
</el-form-item>
<!-- <el-form-item :label-width="formLabelWidth" label="所属公司">-->
<!-- <el-select v-model="form.region" placeholder="请选择">-->
<!-- <el-option label="区域一" value="shanghai"/>-->
<!-- <el-option label="区域二" value="beijing"/>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item :label-width="formLabelWidth" label="事故级别">
<el-select v-model="infoForm.incidentLevels" placeholder="请选择">
<el-option
v-for="item in incidentLevels"
:key="item.id"
:label="item.type"
:value="item.id"/>
</el-select>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故发生地点">
<el-input v-model="infoForm.location" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故发生时间">
<el-date-picker
v-model="infoForm.incidentDate"
type="date"
placeholder="选择日期"
style="width: 100%;"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd HH:mm:ss"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="直接经济损失">
<el-input v-model="infoForm.directLoss" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="受伤人数">
<el-input v-model="infoForm.injured" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="死亡人数">
<el-input v-model="infoForm.fatalities" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="重伤人数">
<el-input v-model="infoForm.seriouslyInjured" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故起因">
<el-input v-model="infoForm.cause" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故概述">
<el-input v-model="infoForm.summary" autocomplete="off"/>
</el-form-item>
<!-- TODO 图片
<el-form-item :label-width="formLabelWidth" label="事故照片">-->
<!-- <el-upload-->
<!-- action="https://jsonplaceholder.typicode.com/posts/"-->
<!-- list-type="picture-card"-->
<!-- !multiple-->
<!-- limit="1">-->
<!-- <el-button size="small" type="primary">点击上传</el-button>-->
<!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>-->
<!-- </el-upload>-->
<!-- </el-form-item>-->
<el-form-item :label-width="formLabelWidth" label="原因分析及责任认定">
<el-input v-model="infoForm.analysis" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="考核建议">
<el-input v-model="infoForm.suggestions" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="整改措施">
<el-input v-model="infoForm.measures" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="填表人">
<el-input v-model="infoForm.creator" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="报出日期">
<el-date-picker
v-model="infoForm.reportDate"
type="date"
placeholder="选择日期"
style="width: 100%;"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd HH:mm:ss"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button>
<el-button type="primary" @click="saveOrUpdate"> </el-button>
</div> </div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import Pagination from '@/components/Pagination' import Pagination from '@/components/Pagination'
import waves from '@/directive/waves' import waves from '@/directive/waves'
import { requestFN } from '@/utils/request'
import SelectTree from '@/components/SelectTree'
import formatDate from '@/utils/dateformat'
export default { export default {
components: { Pagination, SelectTree }, components: { Pagination },
directives: { waves }, directives: { waves },
data() { data() {
return { return {
listLoading: true, //
add: false,
del: false,
edit: false,
dialogFormVisible: false,
listQuery: {
page: 1,
limit: 20
},
total: 0,
varList: [],
hiddenPartList: [], //
incidentLevels: [], //
multipleSelection: [], //
formLabelWidth: '120px',
dialogTitle: '',
searchForm: { searchForm: {
/** 事故名称 */
incidentName: '', incidentName: '',
/** 发生时间 */
incidentDates: [], incidentDates: [],
/** 发生地点 */
location: '', location: '',
incidentLevel: '', /** 事故类型 */
incidentType: '' incidentType: '',
/** 事故等级 */
incidentLevel: ''
}, },
infoForm: { /** 列表加载态 */
id: '', // ID listLoading: false,
incidentNumber: '', // /** 源列表数据项 */
incidentName: '', // varList: [],
incidentType: null, // /** 事故类型 */
companyName: '', // incidentTypes: [
incidentLevel: '', // {
incidentNature: '', // id: '01',
location: '', // value: 'yiji',
incidentDate: null, // label: '一级事故'
directLoss: '', // },
injured: null, // {
fatalities: null, // id: '02',
seriouslyInjured: null, // value: 'erji',
cause: '', // label: '二级事故'
summary: '', // }
photos: '', // ],
analysis: '', // /** 事故等级 */
suggestions: '', // incidentLevels: [
measures: '', // {
creator: '', // id: '01',
reportDate: null // value: 'yiji',
label: '一级等级'
},
{
id: '02',
value: 'erji',
label: '二级等级'
}
],
//
listQuery: {
/** 当前页数 */
page: 1,
/** 分页数 */
limit: 20,
/** 总页数 */
total: 0
} }
} }
}, },
created() {
this.getDict()
this.getList()
},
methods: { methods: {
// /**
getList() { * 查询搜索
this.listLoading = true */
const url = '/accident/page?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page searchList() { },
requestFN(url, { ...this.searchForm }).then((data) => {
this.listLoading = false /**
this.varList = data.varList * 重置搜索条件
this.total = data.page.totalResult */
this.hasButton() handleReset() {},
}).catch((e) => {
this.listLoading = false /**
}) * 获取分页列表
*/
getList() {},
/**
* 表格行选择器处理
*/
handleSelectionChange() {},
/**
* 新增
*/
handleAddNew() {
this.$parent.activeName = 'AddOrEdit'
}, },
// /**
reset() { * 导出
this.searchForm = this.$options.data().searchForm */
this.getList() handleExport() {},
this.toggleSelection()
},
// /**
deleteInBulk() { * 全部导出
// */
const selectedRows = this.multipleSelection handleAllExport() {},
// /**
if (selectedRows.length === 0) { * 刷新
this.$message.warning('请选择要删除的行') */
return handleRefresh() {},
}
// /**
this.$confirm('确定要删除这些记录吗?', '提示', { * 批量删除
confirmButtonText: '确定', */
cancelButtonText: '取消', handleBatchDel() {}
type: 'warning'
}).then(() => {
// ID
const ids = selectedRows.map(row => row.id).join(',')
//
const url = '/accident/delete/' + '' + ids
requestFN(url).then((response) => {
//
this.$message.success('删除成功')
this.getList() //
// eslint-disable-next-line handle-callback-err
}).catch((error) => {
this.$message.error('删除失败')
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
this.getList()
},
//
deleteRow(id) {
if (id === null || id === '') {
this.$message.warning('请选择要删除的行')
return
}
//
this.$confirm('确定要删除这调记录吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
//
const url = '/accident/delete/' + '' + id
requestFN(url).then((response) => {
//
this.$message.success('删除成功')
this.getList() //
// eslint-disable-next-line handle-callback-err
}).catch((error) => {
this.$message.error('删除失败')
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
this.getList()
},
//
handleSelectionChange(val) {
this.multipleSelection.push(val)
},
//
toggleSelection(rows) {
if (rows) {
rows.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row)
})
} else {
this.$refs.multipleTable.clearSelection()
}
},
// TODO
hasButton() {
var keys = 'hidden:add,hidden:del,hidden:edit,toExcel'
requestFN(
'/head/hasButton',
{
keys: keys
}
).then((data) => {
this.add = data.hiddenfhadminadd
this.del = data.hiddenfhadmindel
this.edit = data.hiddenfhadminedit
}).catch((e) => {
this.listLoading = false
})
},
//
getDict() {
requestFN(
'dictionaries/listSelectTree?tm=' + new Date().getTime(),
{
DICTIONARIES_ID: '5e7cf8620ba54ad89719d0be62133c7a'
}
).then((data) => {
this.hiddenlevelList = JSON.parse(data.zTreeNodes)
console.info(this.hiddenlevelList)
}).catch((e) => {
this.listLoading = false
})
requestFN(
'/dictionaries/listSelectTree',
{
DICTIONARIES_ID: '3babc15144444bdc8d763d0af2bdfff6'
}
).then((data) => {
this.hiddenTypeList = JSON.parse(data.zTreeNodes)
})
requestFN(
'/dictionaries/listSelectTree',
{
DICTIONARIES_ID: '18c0a9aea6e54feab9f4ab3f46e0bc86'
}
).then((data) => {
this.hiddenType2List = JSON.parse(data.zTreeNodes)
})
//
requestFN(
'/hiddenRegion/listAll'
).then((data) => {
console.log(data)
this.hiddenPartList = JSON.parse(data.zTreeNodes)
}).catch((e) => {
this.listLoading = false
})
},
//
changeDialog(title, id) {
this.dialogFormVisible = true
this.dialogTitle = title
if (title === '修改') {
requestFN('/accident/' + id, {}).then((data) => {
this.infoForm = data.info
}).catch((e) => {
this.listLoading = false
})
}
},
//
saveOrUpdate() {
requestFN('/accident' + (this.dialogTitle === '修改' ? '/update' : '/save'), this.infoForm)
.then((response) => {
//
this.$message.success(this.dialogTitle + '成功')
this.getList() //
this.infoForm = this.$options.data().infoForm
// eslint-disable-next-line handle-callback-err
}).catch((error) => {
this.$message.error(this.dialogTitle + '失败')
})
},
goView(id) {
this.$parent.activeName = 'Detail'
this.$parent.hiddenId = id
},
formatDate(date, format) {
return formatDate(date, format)
}
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped></style>
</style>

View File

@ -0,0 +1,469 @@
<template>
<div class="app-container">
<el-form ref="searchForm" :model="searchForm" label-width="100px">
<el-row :gutter="12">
<el-col :span="4">
<el-form-item label="事故名称" prop="incidentName">
<el-input v-model="searchForm.incidentName" placeholder="请输入隐患描述" class="filter-item"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="发生时间" prop="incidentDates">
<el-date-picker
v-model="searchForm.incidentDates"
value-format="yyyy-MM-dd"
style="width: 100%"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="发生地点" prop="location">
<el-input v-model="searchForm.location" placeholder="请输入关键字" class="filter-item"/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="事故类型" prop="incidentType">
<el-select v-model="searchForm.incidentType" placeholder="请选择">
<el-option v-for="item in incidentTypes" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="事故等级" prop="incidentLevel">
<el-select v-model="searchForm.incidentLevel" placeholder="请选择">
<el-option v-for="item in incidentLevels" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="getList">
查询
</el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-refresh" @click="reset">
重置
</el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-refresh" @click="changeDialog('添加')">
添加
</el-button>
<el-button v-waves class="filter-item" type="danger" icon="el-icon-delete" @click="deleteInBulk">
批量删除
</el-button>
<!-- <el-button v-waves class="filter-item" type="warning" icon="el-icon-star-off" @click="chongzhi">-->
<!-- 导出-->
<!-- </el-button>-->
<!-- <el-button v-waves class="filter-item" type="warning" icon="el-icon-star-off" @click="chongzhi">-->
<!-- 导出全部-->
<!-- </el-button>-->
<el-button v-waves class="filter-item" type="success" icon="el-icon-refresh" @click="getList">
刷新
</el-button>
</el-col>
</el-row>
</el-form>
<el-table
v-loading="listLoading"
ref="multipleTable"
:data="varList"
border
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"/>
<el-table-column label="事故名称" prop="incidentName"/>
<el-table-column label="所属公司" prop="companyName"/>
<el-table-column label="发生时间" prop="incidentDate">
<template v-slot="{row}">
{{ formatDate(row.incidentDate, 'YYYY-MM-DD HH:mm:ss') }}
</template>
</el-table-column>
<el-table-column label="发生地点" prop="location"/>
<el-table-column label="操作" width="100">
<template v-slot="{row}">
<el-button v-show="edit" icon="el-icon-view" size="mini" @click="goView(row.id)"></el-button>
<el-button v-show="edit" icon="el-icon-view" size="mini" @click="changeDialog('修改',row.id)"></el-button>
<el-button v-show="del" icon="el-icon-view" size="mini" @click="deleteRow(row.id)"></el-button>
</template>
</el-table-column>
</el-table>
<div class="page-btn-group">
<div/>
<pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList"/>
</div>
<el-dialog :visible.sync="dialogFormVisible" :title="dialogTitle">
<el-form :model="infoForm">
<el-form-item :label-width="formLabelWidth" label="事故案号">
<el-input v-model="infoForm.incidentNumber" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故名称">
<el-input v-model="infoForm.incidentName" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故类型">
<el-select v-model="infoForm.hiddenPartList" placeholder="请选择">
<el-option
v-for="item in hiddenPartList"
:key="item.id"
:label="item.type"
:value="item.id"/>
</el-select>
</el-form-item>
<!-- <el-form-item :label-width="formLabelWidth" label="所属公司">-->
<!-- <el-select v-model="form.region" placeholder="请选择">-->
<!-- <el-option label="区域一" value="shanghai"/>-->
<!-- <el-option label="区域二" value="beijing"/>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item :label-width="formLabelWidth" label="事故级别">
<el-select v-model="infoForm.incidentLevels" placeholder="请选择">
<el-option
v-for="item in incidentLevels"
:key="item.id"
:label="item.type"
:value="item.id"/>
</el-select>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故发生地点">
<el-input v-model="infoForm.location" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故发生时间">
<el-date-picker
v-model="infoForm.incidentDate"
type="date"
placeholder="选择日期"
style="width: 100%;"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd HH:mm:ss"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="直接经济损失">
<el-input v-model="infoForm.directLoss" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="受伤人数">
<el-input v-model="infoForm.injured" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="死亡人数">
<el-input v-model="infoForm.fatalities" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="重伤人数">
<el-input v-model="infoForm.seriouslyInjured" type="number" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故起因">
<el-input v-model="infoForm.cause" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="事故概述">
<el-input v-model="infoForm.summary" autocomplete="off"/>
</el-form-item>
<!-- TODO 图片
<el-form-item :label-width="formLabelWidth" label="事故照片">-->
<!-- <el-upload-->
<!-- action="https://jsonplaceholder.typicode.com/posts/"-->
<!-- list-type="picture-card"-->
<!-- !multiple-->
<!-- limit="1">-->
<!-- <el-button size="small" type="primary">点击上传</el-button>-->
<!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>-->
<!-- </el-upload>-->
<!-- </el-form-item>-->
<el-form-item :label-width="formLabelWidth" label="原因分析及责任认定">
<el-input v-model="infoForm.analysis" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="考核建议">
<el-input v-model="infoForm.suggestions" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="整改措施">
<el-input v-model="infoForm.measures" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="填表人">
<el-input v-model="infoForm.creator" autocomplete="off"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="报出日期">
<el-date-picker
v-model="infoForm.reportDate"
type="date"
placeholder="选择日期"
style="width: 100%;"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd HH:mm:ss"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button>
<el-button type="primary" @click="saveOrUpdate"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import Pagination from '@/components/Pagination'
import waves from '@/directive/waves'
import { requestFN } from '@/utils/request'
import SelectTree from '@/components/SelectTree'
import formatDate from '@/utils/dateformat'
export default {
components: { Pagination, SelectTree },
directives: { waves },
data() {
return {
listLoading: true,
add: false,
del: false,
edit: false,
dialogFormVisible: false,
listQuery: {
page: 1,
limit: 20
},
total: 0,
varList: [],
hiddenPartList: [], //
incidentLevels: [], //
multipleSelection: [], //
formLabelWidth: '120px',
dialogTitle: '',
searchForm: {
incidentName: '',
incidentDates: [],
location: '',
incidentLevel: '',
incidentType: ''
},
infoForm: {
id: '', // ID
incidentNumber: '', //
incidentName: '', //
incidentType: null, //
companyName: '', //
incidentLevel: '', //
incidentNature: '', //
location: '', //
incidentDate: null, //
directLoss: '', //
injured: null, //
fatalities: null, //
seriouslyInjured: null, //
cause: '', //
summary: '', //
photos: '', //
analysis: '', //
suggestions: '', //
measures: '', //
creator: '', //
reportDate: null //
}
}
},
created() {
this.getDict()
this.getList()
},
methods: {
//
getList() {
this.listLoading = true
const url = '/accident/page?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page
requestFN(url, { ...this.searchForm }).then((data) => {
this.listLoading = false
this.varList = data.varList
this.total = data.page.totalResult
this.hasButton()
}).catch((e) => {
this.listLoading = false
})
},
//
reset() {
this.searchForm = this.$options.data().searchForm
this.getList()
this.toggleSelection()
},
//
deleteInBulk() {
//
const selectedRows = this.multipleSelection
//
if (selectedRows.length === 0) {
this.$message.warning('请选择要删除的行')
return
}
//
this.$confirm('确定要删除这些记录吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// ID
const ids = selectedRows.map(row => row.id).join(',')
//
const url = '/accident/delete/' + '' + ids
requestFN(url).then((response) => {
//
this.$message.success('删除成功')
this.getList() //
// eslint-disable-next-line handle-callback-err
}).catch((error) => {
this.$message.error('删除失败')
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
this.getList()
},
//
deleteRow(id) {
if (id === null || id === '') {
this.$message.warning('请选择要删除的行')
return
}
//
this.$confirm('确定要删除这调记录吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
//
const url = '/accident/delete/' + '' + id
requestFN(url).then((response) => {
//
this.$message.success('删除成功')
this.getList() //
// eslint-disable-next-line handle-callback-err
}).catch((error) => {
this.$message.error('删除失败')
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
this.getList()
},
//
handleSelectionChange(val) {
this.multipleSelection.push(val)
},
//
toggleSelection(rows) {
if (rows) {
rows.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row)
})
} else {
this.$refs.multipleTable.clearSelection()
}
},
// TODO
hasButton() {
var keys = 'hidden:add,hidden:del,hidden:edit,toExcel'
requestFN(
'/head/hasButton',
{
keys: keys
}
).then((data) => {
this.add = data.hiddenfhadminadd
this.del = data.hiddenfhadmindel
this.edit = data.hiddenfhadminedit
}).catch((e) => {
this.listLoading = false
})
},
//
getDict() {
requestFN(
'dictionaries/listSelectTree?tm=' + new Date().getTime(),
{
DICTIONARIES_ID: '5e7cf8620ba54ad89719d0be62133c7a'
}
).then((data) => {
this.hiddenlevelList = JSON.parse(data.zTreeNodes)
console.info(this.hiddenlevelList)
}).catch((e) => {
this.listLoading = false
})
requestFN(
'/dictionaries/listSelectTree',
{
DICTIONARIES_ID: '3babc15144444bdc8d763d0af2bdfff6'
}
).then((data) => {
this.hiddenTypeList = JSON.parse(data.zTreeNodes)
})
requestFN(
'/dictionaries/listSelectTree',
{
DICTIONARIES_ID: '18c0a9aea6e54feab9f4ab3f46e0bc86'
}
).then((data) => {
this.hiddenType2List = JSON.parse(data.zTreeNodes)
})
//
requestFN(
'/hiddenRegion/listAll'
).then((data) => {
console.log(data)
this.hiddenPartList = JSON.parse(data.zTreeNodes)
}).catch((e) => {
this.listLoading = false
})
},
//
changeDialog(title, id) {
this.dialogFormVisible = true
this.dialogTitle = title
if (title === '修改') {
requestFN('/accident/' + id, {}).then((data) => {
this.infoForm = data.info
}).catch((e) => {
this.listLoading = false
})
}
},
//
saveOrUpdate() {
requestFN('/accident' + (this.dialogTitle === '修改' ? '/update' : '/save'), this.infoForm)
.then((response) => {
//
this.$message.success(this.dialogTitle + '成功')
this.getList() //
this.infoForm = this.$options.data().infoForm
// eslint-disable-next-line handle-callback-err
}).catch((error) => {
this.$message.error(this.dialogTitle + '失败')
})
},
goView(id) {
this.$parent.activeName = 'Detail'
this.$parent.hiddenId = id
},
formatDate(date, format) {
return formatDate(date, format)
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -1,17 +1,19 @@
<template> <template>
<!-- <component :is="activeName" />-->
<div> <div>
<List v-show="activeName==='List'" ref="list"/> <List v-if="activeName === 'List'" ref="List" />
<Add v-if="activeName === 'AddOrEdit'" ref="AddOrEdit" />
<!-- <Detail v-if="activeName==='Detail'"/>--> <!-- <Detail v-if="activeName==='Detail'"/>-->
</div> </div>
</template> </template>
<script> <script>
import List from './components/list.vue' import List from './components/list.vue'
import Add from './components/addOrEdit.vue'
export default { export default {
components: { components: {
List: List List: List,
Add: Add
// Detail: Detail // Detail: Detail
}, },
data() { data() {
@ -23,7 +25,7 @@ export default {
watch: { watch: {
activeName(val) { activeName(val) {
if (val === 'List') { if (val === 'List') {
this.$refs.list.getList() this.$refs.List.getList()
} }
} }
} }