kongyeqing
kongyeqing 2023-06-09 18:03:30 +08:00
commit 8976191796
12 changed files with 410 additions and 164 deletions

View File

@ -7,7 +7,7 @@ VUE_APP_GATEWAY_URL="/dev-api"
# 服务地址 # 服务地址
VUE_APP_BASE_API_URL="http://192.168.2.3:8081/" VUE_APP_BASE_API_URL="http://192.168.2.3:8081/"
# 服务前-- 请严格遵守格式 不允许换行 # 服务前-- 请严格遵守格式 不允许换行
VUE_APP_SERVICE_PREFIX= '{"system":"/system","prevention":"/prevention-yx"}' VUE_APP_SERVICE_PREFIX= '{"system":"/system","file":"/file-zy","prevention":"/prevention-yx"}'
# 是否显示全部菜单 # 是否显示全部菜单
VUE_APP_ALL_MENU = false VUE_APP_ALL_MENU = false
# 微前端地址 # 微前端地址

View File

@ -4,29 +4,30 @@
<span>{{modelMap[viewModel]}}</span> <span>{{modelMap[viewModel]}}</span>
<div class="actions"> <div class="actions">
<div class="btn" @click="drawScreenFull"></div> <div class="btn" @click="drawScreenFull"></div>
<i class="btn el-icon-close" @click="visible=false"></i> <i class="btn el-icon-close" @click="closePop()"></i>
</div> </div>
</div> </div>
<div class="content-box"> <div class="content-box">
<div class="update-box"> <div class="update-box">
<div class="form-box"> <div class="form-box">
<FormComponent v-if="viewModel!=='list'" labelWidth="56px" :fullBtn="true" :btnPosition="'center'" @change="change" :data.sync="updateParams" @actionCallback="callback" :options="options" :actions="actions"></FormComponent> <FormComponent v-if="viewModel!=='list'" labelWidth="56px" :isReadonly="isReadonly" :fullBtn="true" :btnPosition="'center'" @change="change" :data.sync="updateParams" @actionCallback="callback" :options="options" :actions="actions"></FormComponent>
<FormComponent v-else labelWidth="56px" @change="change" :data.sync="listParams" :options="listForm" ></FormComponent> <FormComponent v-else labelWidth="56px" @change="change" :data.sync="listParams" :options="listForm" ></FormComponent>
</div> </div>
<div class="tree-box" v-if="viewModel==='list'"> <div class="tree-box" v-if="viewModel==='list'">
<el-tree :data="treeData" :expand-on-click-node="false" default-expand-all highlight-current <el-tree :data="treeData" :props="{children:'children',label:'name'}" :expand-on-click-node="false" default-expand-all highlight-current
:filter-node-method="filterNode" :filter-node-method="filterNode"
ref="tree" @node-click="handleNodeClick"> ref="tree" @node-click="handleNodeClick">
<span class="custom-tree-node" slot-scope="{ node, data }"> <span class="custom-tree-node" slot-scope="{ node, data }">
<span class="text-block">{{ node.label }}</span> <span class="text-block">{{ node.label }}</span>
<span> <span>
<el-button <el-button
v-if="!data.geoJson || data.geoJson==='[]'"
type="text" type="text"
size="mini" size="mini"
@click="() => drawNode(data)"> @click="() => drawNode(data)">
绘制 绘制
</el-button> </el-button>
<!-- <el-tag v-else size="mini" type="success">已绘制</el-tag> --> <el-tag v-else size="mini" type="success">已绘制</el-tag>
</span> </span>
</span> </span>
</el-tree> </el-tree>
@ -46,6 +47,8 @@ import screenfull from "screenfull"
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'; import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
import MapboxDraw from '@mapbox/mapbox-gl-draw'; import MapboxDraw from '@mapbox/mapbox-gl-draw';
import * as turf from '@turf/turf' import * as turf from '@turf/turf'
import UnitService from '@/service/unit.service';
import AreaService from '@/service/area.service';
@Component({ @Component({
components:{ components:{
MapComponent, MapComponent,
@ -54,42 +57,10 @@ import * as turf from '@turf/turf'
}) })
export default class DrawComponent extends Vue { export default class DrawComponent extends Vue {
public treeData = [{ public unitService = new UnitService()
label: '一级 1', public areaService = new AreaService()
value: '123',
children: [{ public treeData = [] as any;
label: '二级 1-1',
children: [{
label: '三级 1-1-1'
}]
}]
}, {
label: '一级 2',
children: [{
label: '二级 2-1',
children: [{
label: '三级 2-1-1'
}]
}, {
label: '二级 2-2',
children: [{
label: '三级 2-2-1'
}]
}]
}, {
label: '一级 3',
children: [{
label: '二级 3-1',
children: [{
label: '三级 3-1-1'
}]
}, {
label: '二级 3-2',
children: [{
label: '三级 3-2-1'
}]
}]
}];
public modelMap = { public modelMap = {
list:"批量绘制", list:"批量绘制",
@ -132,6 +103,8 @@ export default class DrawComponent extends Vue {
}) })
@PropSync("model") @PropSync("model")
public viewModel:string; public viewModel:string;
@Prop()
public isReadonly:boolean;
@PropSync("show",{ @PropSync("show",{
required:true, required:true,
default:true default:true
@ -160,23 +133,28 @@ export default class DrawComponent extends Vue {
onModelChanges(newVal){ onModelChanges(newVal){
if(newVal==="list"){ if(newVal==="list"){
this.fromList = true; this.fromList = true;
this.positions = this.getAllFeatures(this.treeData); this.setTreeData();
if(this.positions.length){
this.addAllPolygon();
}
} }
this.buildUpdate() this.buildUpdate()
} }
@Watch("visible",{immediate:true,deep:true})
onVisibleChanges(newVal){
// console.log("close")
// if(!newVal){
// }
}
@Emit("onClose")
onClose(data){
//Emit false
}
created(){ created(){
// this.positions = [] as any; // this.positions = [] as any;
} }
public flyToCenter(zoom){ public flyToCenter(zoom,timer?){
if(!this.map ){ if(!this.map ){
setTimeout(()=>{
this.flyToCenter(zoom)
})
return return
} }
const center = turf.centerOfMass(turf.featureCollection(this.positions)); const center = turf.centerOfMass(turf.featureCollection(this.positions));
@ -184,12 +162,24 @@ export default class DrawComponent extends Vue {
this.addAllPolygon(); this.addAllPolygon();
} }
public setTreeData(){
this.unitService.getUnitTree().then(res=>{
this.treeData = res.data;
this.positions = this.getAllFeatures(this.treeData);
if(this.positions.length && this.map){
this.addAllPolygon();
}
})
}
public getMap(map){ public getMap(map){
this.map = map; this.map = map;
if(this.viewModel!=="list"){
this.map.on('draw.create', this.drawCallback); this.map.on('draw.create', this.drawCallback);
this.map.on('draw.delete', this.drawCallback); this.map.on('draw.delete', this.drawCallback);
this.map.on('draw.update', this.drawCallback); this.map.on('draw.update', this.drawCallback);
if(this.positions.length){
this.addAllPolygon();
this.flyToCenter(this.fromList?14:16)
} }
} }
@ -260,10 +250,12 @@ export default class DrawComponent extends Vue {
if(!this.map){ if(!this.map){
return return
} }
if(this.map.getSource("allDataSource")){
this.map.removeLayer("allDataLayer") this.map.removeLayer("allDataLayer")
this.map.removeLayer("textLayer") this.map.removeLayer("textLayer")
this.map.removeSource("allDataSource") this.map.removeSource("allDataSource")
} }
}
public drawCallback(e){ public drawCallback(e){
if(e.type ==="draw.create"){ if(e.type ==="draw.create"){
@ -273,6 +265,7 @@ export default class DrawComponent extends Vue {
}else{ }else{
this.positions.splice(this.positions.findIndex((item:any)=>item.id===e.features[0].id),1) this.positions.splice(this.positions.findIndex((item:any)=>item.id===e.features[0].id),1)
} }
console.log(this.positions)
} }
public drawScreenFull(){ public drawScreenFull(){
@ -284,7 +277,7 @@ export default class DrawComponent extends Vue {
// //
public filterNode(value, data) { public filterNode(value, data) {
if (!value) return true; if (!value) return true;
return data.label.indexOf(value) !== -1; return data.name.indexOf(value) !== -1;
} }
public change(data,meta){ public change(data,meta){
@ -294,10 +287,16 @@ export default class DrawComponent extends Vue {
} }
public handleNodeClick(node){ public handleNodeClick(node){
this.positions = JSON.parse(node.geoJson); const geoJson = JSON.parse(node.geoJson);
if(!geoJson.length){
return
}
const center = turf.centerOfMass(turf.featureCollection(geoJson));
this.map.flyTo({center: center.geometry.coordinates, zoom: 18});
} }
public drawNode(data){ public drawNode(data){
this.params =Object.assign({bottomHeight:0,topHeight:0,geoJson:"[]"},data) as any;
if(data.area_id){ if(data.area_id){
this.viewModel = "unit" this.viewModel = "unit"
}else{ }else{
@ -343,12 +342,15 @@ export default class DrawComponent extends Vue {
feature.properties = this.updateParams feature.properties = this.updateParams
}) })
this.updateParams.geoJson = JSON.stringify(this.positions); this.updateParams.geoJson = JSON.stringify(this.positions);
this.params = this.updateParams;
if(this.fromList){ if(this.fromList){
const service = this.viewModel==='unit'?this.unitService:this.areaService;
service.addOrUpdate(this.updateParams,false).then(res=>{
this.viewModel = "list"; this.viewModel = "list";
this.destoryDraw(); this.destoryDraw();
})
this.onClose(false)
}else{ }else{
this.params = this.updateParams;
this.visible = false; this.visible = false;
} }
} }
@ -359,10 +361,13 @@ export default class DrawComponent extends Vue {
if(action.value==="draw"){ if(action.value==="draw"){
this.drawCallBack(); this.drawCallBack();
}else if(action.value==="save"){ }else if(action.value==="save"){
this.doSave()
}else { }else {
if(this.fromList){ if(this.fromList){
this.viewModel = "list"; this.viewModel = "list";
if(this.hasInitDraw){
this.draw.deleteAll() this.draw.deleteAll()
}
}else{ }else{
this.visible = false; this.visible = false;
} }
@ -423,10 +428,19 @@ export default class DrawComponent extends Vue {
mounted(){ mounted(){
} }
public closePop(){
this.removeMap();
this.updateParams = {} as any;
this.onClose(false)
this.visible = false;
}
public removeMap(){ public removeMap(){
this.map.off('draw.create', this.drawCallback); this.map.off('draw.create', this.drawCallback);
this.map.off('draw.delete', this.drawCallback); this.map.off('draw.delete', this.drawCallback);
this.map.off('draw.update', this.drawCallback); this.map.off('draw.update', this.drawCallback);
this.removeLayer();
this.map.remove(); this.map.remove();
this.map = null; this.map = null;
} }
@ -445,6 +459,9 @@ export default class DrawComponent extends Vue {
.el-tree-node__content{ .el-tree-node__content{
height: auto; height: auto;
} }
.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content .el-button--text{
color: #FFF;
}
} }
.draw-box{ .draw-box{

View File

@ -12,10 +12,20 @@ export default class AreaService extends BaseService<any>{
} }
// 批量删除 // 批量删除
public deleteByIds(params):Promise<AxiosResponse<ActionResult<any>>>{ public deleteByIds(params):Promise<AxiosResponse<ActionResult<any>>>{
const url = this.prefix.prevention+'/user/list'; const url = this.prefix.prevention+'/risk/area';
return this.deleteBatch(url,params,{},true) return this.deleteBatch(url,params,{},true)
} }
public getAreaNumber():Promise<AxiosResponse<ActionResult<any>>>{
const url = this.prefix.prevention+'/risk/area/number';
return this.get(url,null)
}
public getQrCode(params){
const url = this.prefix.file+'/qrCode/createQrCode';
return this.post(url,params)
}
// 新增或更新 // 新增或更新
public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise<AxiosResponse<ActionResult<any>>>{ public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise<AxiosResponse<ActionResult<any>>>{
const url = this.prefix.prevention+'/risk/area'; const url = this.prefix.prevention+'/risk/area';

View File

@ -10,11 +10,23 @@ export default class UnitService extends BaseService<any>{
return this.get(url,params,true) return this.get(url,params,true)
} }
public deleteByIds(params):Promise<AxiosResponse<ActionResult<any>>>{ public deleteByIds(params):Promise<AxiosResponse<ActionResult<any>>>{
const url = this.prefix.system+'/user/list'; const url = this.prefix.prevention+'/risk/unit';
return this.deleteBatch(url,params,{},true) return this.deleteBatch(url,params,{},true)
} }
public getUnitNumber(params):Promise<AxiosResponse<ActionResult<any>>>{
const url = this.prefix.prevention+'/risk/unit/number';
return this.get(url,params)
}
public getUnitTree():Promise<AxiosResponse<ActionResult<any>>>{
const url = this.prefix.prevention+'/risk/unit/tree';
return this.get(url,null)
}
// 新增或更新 // 新增或更新
public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise<AxiosResponse<ActionResult<any>>>{ public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise<AxiosResponse<ActionResult<any>>>{
const url = this.prefix.prevention+'/risk/unit'; const url = this.prefix.prevention+'/risk/unit';

View File

@ -9,12 +9,31 @@ export default new Vuex.Store({
deptTreeList:[], deptTreeList:[],
userList:[], userList:[],
common_yes_no:[], common_yes_no:[],
yesNoMap:{ prevention_dangrous_level:[],
0:"否", prevention_risk_level:[],
1:"是"
}
}, },
getters: { getters: {
common_yes_no_map:(state)=>{
const map = {};
state.common_yes_no.forEach((item:any)=>{
map[item.value] = item.name
})
return map
},
prevention_dangrous_level_map:(state)=>{
const map = {};
state.prevention_dangrous_level.forEach((item:any)=>{
map[item.value] = item.name
})
return map
},
prevention_risk_level_map:(state)=>{
const map = {};
state.prevention_risk_level.forEach((item:any)=>{
map[item.value] = item.name
})
return map
}
}, },
mutations: { mutations: {
@ -29,6 +48,12 @@ export default new Vuex.Store({
}, },
set_common_yes_no(state,data){ set_common_yes_no(state,data){
state.common_yes_no = data; state.common_yes_no = data;
},
set_prevention_dangrous_level(state,data){
state.prevention_dangrous_level = data;
},
set_prevention_risk_level(state,data){
state.prevention_risk_level = data;
} }
}, },
actions: { actions: {

View File

@ -13,7 +13,9 @@ export default class BlankComponent extends Vue {
this.systemService.getDeptTree(), this.systemService.getDeptTree(),
this.systemService.getDeptList(), this.systemService.getDeptList(),
this.systemService.getUserList({pageSize:0}), this.systemService.getUserList({pageSize:0}),
this.systemService.getDictData("common_yes_no") this.systemService.getDictData("common_yes_no"),
this.systemService.getDictData("prevention_dangrous_level"),
this.systemService.getDictData("prevention_risk_level")
]).then(((results:any)=>{ ]).then(((results:any)=>{
this.$store.commit("setDeptTreeList",results[0].data); this.$store.commit("setDeptTreeList",results[0].data);
@ -36,6 +38,18 @@ export default class BlankComponent extends Vue {
value:isNaN(+item.dictValue)?item.dictValue:+item.dictValue value:isNaN(+item.dictValue)?item.dictValue:+item.dictValue
} }
})) }))
this.$store.commit("set_prevention_dangrous_level",results[4].data.map(item=>{
return {
name:item.dictLabel,
value:isNaN(+item.dictValue)?item.dictValue:+item.dictValue
}
}))
this.$store.commit("set_prevention_risk_level",results[5].data.map(item=>{
return {
name:item.dictLabel,
value:isNaN(+item.dictValue)?item.dictValue:+item.dictValue
}
}))
})) }))
} }
} }

View File

@ -51,7 +51,10 @@
&.active { &.active {
&::before { &::before {
position: absolute; position: absolute;
inset: 0; left: 0;
top: 0;
right: 0;
bottom: 0;
content: ""; content: "";
background: #68C23A; background: #68C23A;
z-index: 1; z-index: 1;

View File

@ -29,6 +29,20 @@ export default class AreaManagerComponent extends BaseRecordComponent<any> {
majorHazardFlag:null majorHazardFlag:null
} as any; } as any;
public filters = [{
text:"未绘制",
value:0
},{
text:"已绘制",
value:1
}]
public showQrCode = false;
public qrUrl = "";
// //
public formActions = [{ public formActions = [{
@ -105,6 +119,7 @@ export default class AreaManagerComponent extends BaseRecordComponent<any> {
name:"区域编号", name:"区域编号",
key:"number", key:"number",
type:"text", type:"text",
disable:true,
showError:false, showError:false,
width:"calc(50% - 20px)", width:"calc(50% - 20px)",
require:true require:true
@ -137,6 +152,7 @@ export default class AreaManagerComponent extends BaseRecordComponent<any> {
},{ },{
name:"属于重大危险源", name:"属于重大危险源",
key:"majorHazardFlag", key:"majorHazardFlag",
format:"majorHazardFlagName",
type:"radio", type:"radio",
width:"calc(50% - 20px)", width:"calc(50% - 20px)",
require:true, require:true,
@ -186,6 +202,14 @@ export default class AreaManagerComponent extends BaseRecordComponent<any> {
size:"small", size:"small",
icon:"el-icon-edit-outline", icon:"el-icon-edit-outline",
type:"primary" type:"primary"
},{
name:"查看绘制",
value:"readDraw",
hide:!this.isReadonly,
height:"36px",
size:"small",
icon:"el-icon-edit-outline",
type:"primary"
}] }]
}]; }];
@ -219,14 +243,40 @@ export default class AreaManagerComponent extends BaseRecordComponent<any> {
}] }]
} }
public getQrCode(row){
this.tableService.getQrCode({
url:"/",
id:row.id,
system:"prevention",
type:0,
data:"",
params:{
"区域名称" : row.name,
"区域编号" : row.number,
"责任人" : row.chargeUserName,
"责任部门" : row.chargeDeptName,
"重大危险源名称" : row.majorHazardName
}
}).then((res:any)=>{
this.showQrCode = true;
this.qrUrl = res.data.url;
})
}
public buildTable(){ public buildTable(){
this.tableColumn.push({name:'区域名称',key:"name"}); this.tableColumn.push({name:'区域名称',key:"name"});
this.tableColumn.push({name:'责任部门',key:"chargeDeptName"}); this.tableColumn.push({name:'责任部门',key:"chargeDeptName"});
this.tableColumn.push({name:'责任人',key:"chargeUserName"}); this.tableColumn.push({name:'责任人',key:"chargeUserName"});
this.tableColumn.push({name:'是否属于重大危险源',key:"majorHazardFlag",render:(data)=>{ this.tableColumn.push({name:'是否属于重大危险源',key:"majorHazardFlag",render:(data)=>{
return this.$store.state.yesNoMap[data.majorHazardFlag] return this.$store.getters.common_yes_no_map[data.majorHazardFlag]
}}); }});
this.tableColumn.push({name:'绘制情况',render:(data)=>{ this.tableColumn.push({name:'绘制情况',filters:this.filters,filterMethod:(data,row)=>{
if(data){
return row.geoJson && row.geoJson!=="[]"
}else{
return !row.geoJson || row.geoJson === "[]"
}
}, render:(data)=>{
if(data.geoJson==='[]' || !data.geoJson){ if(data.geoJson==='[]' || !data.geoJson){
return "<span class='noDraw'>未绘制</span>" return "<span class='noDraw'>未绘制</span>"
}else{ }else{
@ -235,50 +285,75 @@ export default class AreaManagerComponent extends BaseRecordComponent<any> {
}}); }});
} }
public callback(data,item?){ public doDraw(){
//
if(item && item.key === "majorHazardFlag"){
this.updateOptions[5].hide = !data;
this.updateOptions[6].hide = !data;
}
//
if(data.value==="search"){
this.getTableData()
//
}else if(data.value === "reset"){
this.reset()
//
}else if(data.value === "reverse"){
this.toggleAll()
//
}else if(data.value === "selectAll"){
this.selectAll()
}else if(data.value === "add"){
this.showUpdateModel()
}else if(data.value === "delete"){
this.deleteData(this.selectData.map((item:any)=>item.id))
}else if(data.value === "draw"){
if(!this.updateParams.name){ if(!this.updateParams.name){
this.$message.error("请先输入区域名称"); this.$message.error("请先输入区域名称");
return return
} }
this.drawModel = "area"; this.drawModel = "area";
this.showDraw = true; this.showDraw = true;
}else if(data.value === "drawList"){ }
this.drawModel = "list";
this.showDraw = true; public getCreateNumber(){
}else if(data.value === "submit"){ this.tableService.getAreaNumber().then((res)=>{
this.updateParams = {bottomHeight:0,topHeight:0,geoJson:"[]",number:res.data} as any;
this.buildFormOptions();
this.showUpdate = true
})
}
public doSave(goOn?){
this.tableService.addOrUpdate(this.updateParams,this.currentId===-1).then((res)=>{ this.tableService.addOrUpdate(this.updateParams,this.currentId===-1).then((res)=>{
this.$message.success(this.currentId===-1?"新增成功!":"修改成功!"); this.$message.success(this.currentId===-1?"新增成功!":"修改成功!");
if(goOn){
this.getCreateNumber();
}else{
this.handleClose(); this.handleClose();
}
this.getTableData(); this.getTableData();
}) })
}else if(data.value === "saveAndContinue"){ }
this.tableService.addOrUpdate(this.updateParams,this.currentId===-1).then((res)=>{
this.$message.success("新增成功!"); public callback(data,item?){
this.updateParams = {bottomHeight:0,topHeight:0,geoJson:"[]"} as any //
}) if(item && item.key === "chargeDeptId"){
}else if(data.value === "cancel"){ this.updateParams.chargeDeptName = this.$store.state.deptList.find(item=>item.value === data)?.name;
}
//
if(item && item.key === "chargeUserId"){
this.updateParams.chargeUserName = this.$store.state.userList.find(item=>item.value === data)?.name;
}
//
if(item && item.key === "majorHazardFlag"){
this.updateOptions[5].hide = !data;
this.updateOptions[6].hide = !data;
}
//
if(data && data.value==="search"){
this.getTableData()
//
}else if(data && data.value === "reset"){
this.reset()
//
}else if(data && data.value === "reverse"){
this.toggleAll()
//
}else if(data && data.value === "selectAll"){
this.selectAll()
}else if(data && data.value === "add"){
this.showUpdateModel()
}else if(data && data.value === "delete"){
this.deleteData(this.selectData.map((item:any)=>item.id))
}else if(data && (data.value === "draw" || data.value==="readDraw")){
this.doDraw()
}else if(data && data.value === "drawList"){
this.drawModel = "list";
this.showDraw = true;
}else if(data && data.value === "submit"){
this.doSave()
}else if(data && data.value === "saveAndContinue"){
this.doSave(true)
}else if(data && data.value === "cancel"){
this.updateParams = {} as any; this.updateParams = {} as any;
this.handleClose(); this.handleClose();
} }
@ -299,15 +374,16 @@ export default class AreaManagerComponent extends BaseRecordComponent<any> {
public showUpdateModel(data?,isRead?){ public showUpdateModel(data?,isRead?){
if(!data){ if(!data){
this.currentId = -1; this.currentId = -1;
this.updateParams = {bottomHeight:0,topHeight:0,geoJson:"[]"} as any this.getCreateNumber();
}else{ }else{
this.currentId = data.id; this.currentId = data.id;
this.updateParams = Object.assign({bottomHeight:0,topHeight:0,geoJson:"[]"},data); this.updateParams = Object.assign({bottomHeight:0,topHeight:0,geoJson:"[]",majorHazardFlagName:this.$store.getters.common_yes_no_map[data.majorHazardFlag]},data);
this.isReadonly = !!isRead;
this.buildFormOptions(); this.buildFormOptions();
this.isReadonly = !!isRead
}
this.showUpdate = true this.showUpdate = true
} }
}
public handleClose(){ public handleClose(){
this.showUpdate = false; this.showUpdate = false;

View File

@ -14,18 +14,18 @@
<el-table-column type="selection" label="全选"> <el-table-column type="selection" label="全选">
</el-table-column> </el-table-column>
<template v-for="item in tableColumn"> <template v-for="item in tableColumn">
<el-table-column v-if="item.render" :label="item.name" :width="item.width" :key="item.key"> <el-table-column v-if="item.render" :label="item.name" :filters="item.filters" :filter-method="item.filterMethod" :width="item.width" :key="item.key">
<div slot-scope="scope" v-html="item.render(scope.row)"></div> <div slot-scope="scope" v-html="item.render(scope.row)"></div>
</el-table-column> </el-table-column>
<el-table-column v-else :prop="item.key" :label="item.name" :width="item.width" :key="item.key"> <el-table-column v-else :prop="item.key" :filters="item.filters" :label="item.name" :filter-method="item.filterMethod" :width="item.width" :key="item.key">
</el-table-column> </el-table-column>
</template> </template>
<el-table-column label="操作" width="200"> <el-table-column label="操作" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="showUpdateModel(scope.row,true)">查看</el-button> <el-button type="text" @click="showUpdateModel(scope.row,true)">查看</el-button>
<el-button type="text" @click="showUpdateModel(scope.row)">修改</el-button> <el-button type="text" @click="showUpdateModel(scope.row)">修改</el-button>
<el-button type="text" @click="deleteData([scope.row])">删除</el-button> <el-button type="text" @click="deleteData([scope.row.id])">删除</el-button>
<el-button type="text">二维码</el-button> <el-button type="text" @click="getQrCode(scope.row)">二维码</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -35,7 +35,7 @@
</div> </div>
<div class="model-box" v-if="showDraw"> <div class="model-box" v-if="showDraw">
<div class="mask"></div> <div class="mask"></div>
<DrawComponent :model.sync="drawModel" :data.sync="updateParams" :show.sync="showDraw"></DrawComponent> <DrawComponent :model.sync="drawModel" :isReadonly="isReadonly" :data.sync="updateParams" :show.sync="showDraw" @onClose="getTableData"></DrawComponent>
</div> </div>
<el-dialog :close-on-click-modal="false" :title="isReadonly?'详情':currentId===-1?'新增':'编辑'" :visible.sync="showUpdate" width="952px" <el-dialog :close-on-click-modal="false" :title="isReadonly?'详情':currentId===-1?'新增':'编辑'" :visible.sync="showUpdate" width="952px"
@ -43,5 +43,12 @@
<FormComponent :options="updateOptions" :isReadonly="isReadonly" labelWidth="110px" labelAlign="right" :data.sync="updateParams" <FormComponent :options="updateOptions" :isReadonly="isReadonly" labelWidth="110px" labelAlign="right" :data.sync="updateParams"
@actionCallback="callback" :actions="updateActions" :full-btn="true" @change="callback" @actionCallback="callback" :actions="updateActions" :full-btn="true" @change="callback"
btn-position="center"></FormComponent> btn-position="center"></FormComponent>
</el-dialog>
<el-dialog :close-on-click-modal="false" :title="'查看二维码'" :visible.sync="showQrCode" >
<img :src="qrUrl" style="width: 100%;" alt="">
</el-dialog> </el-dialog>
</div> </div>

View File

@ -6,22 +6,30 @@
</div> </div>
<div class="table-box flex-1"> <div class="table-box flex-1">
<TableComponent :tableData="tableData" :tableColumn="tableColumn" @tabCallback="callback($event)" <TableComponent :tableData="tableData" :tableColumn="tableColumn" @tabCallback="callback($event)"
@actionCallback="callback($event)" @pageNumberChange="callback($event)" @pageSizeChange="callback($event)" @actionCallback="callback($event)" @pageNumberChange="callback($event)"
:footerActions="footerActions" :actions="tableActions"> @pageSizeChange="callback($event)" :actions="tableActions">
<el-table ref="multipleTable" :data="tableData.datas" height="100%" border row-key="checked" <el-table ref="multipleTable" :data="tableData.datas" height="100%" border row-key="checked"
@selection-change="handleSelectionChange" style="width: 100%"> style="width: 100%">
<el-table-column label="序号" width="60">
<template slot-scope="scope">
{{scope.$index+1}}
</template>
</el-table-column>
<template v-for="item in tableColumn"> <template v-for="item in tableColumn">
<el-table-column v-if="item.render" :label="item.name" :width="item.width" :key="item.key"> <el-table-column v-if="item.render" :label="item.name" :width="item.width" :key="item.key">
<div slot-scope="scope" style="pointer-events: none;" @click="addVal($event,scope.row)" v-html="item.render(scope.row)"></div> <div slot-scope="scope" style="pointer-events: none;" @click="addVal($event,scope.row)"
v-html="item.render(scope.row)"></div>
</el-table-column> </el-table-column>
<el-table-column v-else :prop="item.key" :label="item.name" :width="item.width" :key="item.key"> <el-table-column v-else :prop="item.key" :label="item.name" :width="item.width" :key="item.key">
</el-table-column> </el-table-column>
</template> </template>
<el-table-column label="操作" width="100"> <el-table-column label="操作" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" v-if="scope.row.analFlag && !scope.row.edit" @click="scope.row.edit = true">修改</el-button> <el-button type="text" v-if="scope.row.analFlag && !scope.row.edit"
<el-button type="text" v-if="!scope.row.analFlag || scope.row.edit" @click="saveVal(scope.row)">保存</el-button> @click="scope.row.edit = true">修改</el-button>
<el-button type="text" v-if="!scope.row.analFlag || scope.row.edit"
@click="saveVal(scope.row)">保存</el-button>
<el-button type="text" v-if="scope.row.edit" @click="scope.row.edit = false">取消</el-button> <el-button type="text" v-if="scope.row.edit" @click="scope.row.edit = false">取消</el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -39,21 +47,26 @@
<el-table-column prop="name" label="项目"></el-table-column> <el-table-column prop="name" label="项目"></el-table-column>
<el-table-column label="取值标准"> <el-table-column label="取值标准">
<el-table-column prop="noInvolved" label="是否涉及"> <el-table-column prop="noInvolved" label="是否涉及">
<div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===0}" @click="selectRow(scope.row,0)"> <div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===0}"
@click="selectRow(scope.row,0)">
<span>不涉及</span> <span>不涉及</span>
</div> </div>
</el-table-column> </el-table-column>
<el-table-column prop="type1" label="1"> <el-table-column prop="type1" label="1">
<div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===1}" @click="selectRow(scope.row,1)"><span>{{scope.row.type1}}</span></div> <div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===1}"
@click="selectRow(scope.row,1)"><span>{{scope.row.type1}}</span></div>
</el-table-column> </el-table-column>
<el-table-column prop="type2" label="2"> <el-table-column prop="type2" label="2">
<div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===2}" @click="selectRow(scope.row,2)"><span>{{scope.row.type2}}</span></div> <div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===2}"
@click="selectRow(scope.row,2)"><span>{{scope.row.type2}}</span></div>
</el-table-column> </el-table-column>
<el-table-column prop="type3" label="3"> <el-table-column prop="type3" label="3">
<div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===3}" @click="selectRow(scope.row,3)"><span>{{scope.row.type3}}</span></div> <div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===3}"
@click="selectRow(scope.row,3)"><span>{{scope.row.type3}}</span></div>
</el-table-column> </el-table-column>
<el-table-column prop="type4" label="4"> <el-table-column prop="type4" label="4">
<div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===4}" @click="selectRow(scope.row,4)"><span>{{scope.row.type4}}</span></div> <div slot-scope="scope" class="cursor td-content" :class="{active:scope.row.value===4}"
@click="selectRow(scope.row,4)"><span>{{scope.row.type4}}</span></div>
</el-table-column> </el-table-column>
</el-table-column> </el-table-column>
<el-table-column prop="value" :label="popTitle==='L值取值'?'Ln':'Sn'"> <el-table-column prop="value" :label="popTitle==='L值取值'?'Ln':'Sn'">
@ -64,6 +77,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="result" :label="popTitle==='L值取值'?'L':'S'"></el-table-column> <el-table-column prop="result" :label="popTitle==='L值取值'?'L':'S'"></el-table-column>
</el-table> </el-table>
<ButtonListComponent :actions="popBtns" @callback="popCallback" btn-position="center" :full-btn="true"></ButtonListComponent> <ButtonListComponent :actions="popBtns" @callback="popCallback" btn-position="center" :full-btn="true">
</ButtonListComponent>
</el-dialog> </el-dialog>
</div> </div>

View File

@ -44,7 +44,7 @@ export default class AreaAnalComponent extends BaseRecordComponent<any> {
}]; }];
public formOptions:FormOption<BtnOption>[] = [{ public formOptions:FormOption<BtnOption>[] = [{
name:"区域名称", name:"区域名称",
key:"areaId", key:"name",
type:"text", type:"text",
}]; }];
@ -72,8 +72,7 @@ export default class AreaAnalComponent extends BaseRecordComponent<any> {
} }
public buildTable(){ public buildTable(){
this.tableColumn.push({name:'序号',key:"areaName"}); this.tableColumn.push({name:'区域名称',key:"name"});
this.tableColumn.push({name:'区域名称',key:"areaName"});
this.tableColumn.push({name:'区域内发生事故的可能性/L',width:"195",render:(data)=>{ this.tableColumn.push({name:'区域内发生事故的可能性/L',width:"195",render:(data)=>{
if(!data.analFlag|| data.edit){ if(!data.analFlag|| data.edit){
return "<span class='link l-value'>"+(data.analLikelihoodValue || "选取L值")+"</span>" return "<span class='link l-value'>"+(data.analLikelihoodValue || "选取L值")+"</span>"
@ -91,7 +90,7 @@ export default class AreaAnalComponent extends BaseRecordComponent<any> {
}}); }});
this.tableColumn.push({name:'区域固有风险',render:(data)=>{ this.tableColumn.push({name:'区域固有风险',render:(data)=>{
return "<span class='color_"+data.analRiskLevel+"'>"+data.analRiskLevel+"</span>" return "<span class='color_"+data.analRiskLevel+"'>"+(this.$store.getters.prevention_risk_level_map[data.analRiskLevel] || '')+"</span>"
}}); }});
this.tableColumn.push({name:'评估完成情况',key:"status",render:(data)=>{ this.tableColumn.push({name:'评估完成情况',key:"status",render:(data)=>{
if(data.edit){ if(data.edit){
@ -162,10 +161,13 @@ export default class AreaAnalComponent extends BaseRecordComponent<any> {
this.$message.error("请选取S值"); this.$message.error("请选取S值");
return return
} }
row.edit = false;
// -1 // -1
row.analRiskLevel=riskLevel[row.analLikelihoodValue - 1][row.analSeverityValue - 1] row.analRiskLevel=riskLevel[row.analLikelihoodValue - 1][row.analSeverityValue - 1];
row.analFlag = 1; row.analFlag = 1;
this.tableService.addOrUpdate(row,false,true).then((res)=>{
this.$message.success("保存成功")
row.edit = false;
})
} }

View File

@ -25,6 +25,18 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
public params = {} as any; public params = {} as any;
public filters = [{
text:"未绘制",
value:0
},{
text:"已绘制",
value:1
}]
public showQrCode = false;
public qrUrl = "";
public isReadonly = false; public isReadonly = false;
public formActions = [{ public formActions = [{
@ -105,6 +117,7 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
name:"单元编号", name:"单元编号",
key:"number", key:"number",
type:"text", type:"text",
disable:true,
width:"calc(50% - 20px)", width:"calc(50% - 20px)",
require:true require:true
},{ },{
@ -126,6 +139,7 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
},{ },{
name:"责任人", name:"责任人",
key:"chargeUserId", key:"chargeUserId",
format:"chargeUserName",
type:"select", type:"select",
width:"calc(50% - 20px)", width:"calc(50% - 20px)",
require:true, require:true,
@ -142,6 +156,14 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
size:"small", size:"small",
icon:"el-icon-edit-outline", icon:"el-icon-edit-outline",
type:"primary" type:"primary"
},{
name:"查看绘制",
value:"readDraw",
hide:!this.isReadonly,
height:"36px",
size:"small",
icon:"el-icon-edit-outline",
type:"primary"
}] }]
}]; }];
@ -170,11 +192,38 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
}] }]
} }
public getQrCode(row){
this.areaService.getQrCode({
url:"/",
id:row.id,
system:"prevention",
type:0,
data:"",
params:{
"区域编号" : row.areaNo,
"单元名称" : row.name,
"单元编号" : row.number,
"责任人" : row.chargeUserName,
"责任部门" : row.chargeDeptName,
}
}).then((res:any)=>{
this.showQrCode = true;
this.qrUrl = res.data.url;
})
}
public buildTable(){ public buildTable(){
this.tableColumn.push({name:'风险分析单元',key:"name"}); this.tableColumn.push({name:'风险分析单元',key:"name"});
this.tableColumn.push({name:'责任部门',key:"chargeDeptName"}); this.tableColumn.push({name:'责任部门',key:"chargeDeptName"});
this.tableColumn.push({name:'责任人',key:"chargeUserName"}); this.tableColumn.push({name:'责任人',key:"chargeUserName"});
this.tableColumn.push({name:'绘制情况',render:(data)=>{ this.tableColumn.push({name:'绘制情况',filters:this.filters,filterMethod:(data,row)=>{
if(data){
return row.geoJson && row.geoJson!=="[]"
}else{
return !row.geoJson || row.geoJson === "[]"
}
},render:(data)=>{
if(data.geoJson==='[]' || !data.geoJson){ if(data.geoJson==='[]' || !data.geoJson){
return "<span class='noDraw'>未绘制</span>" return "<span class='noDraw'>未绘制</span>"
}else{ }else{
@ -196,6 +245,34 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
}) })
} }
public doDraw(){
console.log("openDraw")
if(!this.updateParams.name){
this.$message.error("请先输入单元名称");
return
}
this.drawModel = "unit";
this.showDraw = true;
}
public getCreateNumber(params){
this.tableService.getUnitNumber(params).then((res)=>{
this.updateParams.number = res.data;
})
}
public doSave(goOn?){
this.tableService.addOrUpdate(this.updateParams,this.currentId===-1).then((res)=>{
this.$message.success(this.currentId===-1?"新增成功!":"修改成功!");
if(goOn){
this.updateParams = {bottomHeight:0,topHeight:0,geoJson:"[]",number:null} as any;
}else{
this.handleClose();
}
this.getTableData();
})
}
public callback(data,item?){ public callback(data,item?){
// //
if(item && item.key === "chargeDeptId"){ if(item && item.key === "chargeDeptId"){
@ -207,48 +284,35 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
} }
// //
if(item && item.key === "areaId"){ if(item && item.key === "areaId"){
console.log(item)
this.updateParams.areaNo = this.areaNoMap[data]; this.updateParams.areaNo = this.areaNoMap[data];
console.log(this.updateParams) this.getCreateNumber({areaNo:this.updateParams.areaNo})
} }
// //
if(data.value==="search"){ if(data && data.value==="search"){
this.getTableData() this.getTableData()
// //
}else if(data.value === "reset"){ }else if(data && data.value === "reset"){
this.reset() this.reset()
// //
}else if(data.value === "reverse"){ }else if(data && data.value === "reverse"){
this.toggleAll() this.toggleAll()
// //
}else if(data.value === "selectAll"){ }else if(data && data.value === "selectAll"){
this.selectAll() this.selectAll()
}else if(data.value === "add"){ }else if(data && data.value === "add"){
this.showUpdateModel() this.showUpdateModel()
}else if(data.value === "delete"){ }else if(data.value === "delete"){
this.deleteData(this.selectData.map((item:any)=>item.id)) this.deleteData(this.selectData.map((item:any)=>item.id))
}else if(data.value === "draw"){ }else if(data && (data.value === "draw" || data.value==="readDraw")){
if(!this.updateParams.name){ this.doDraw()
this.$message.error("请先输入单元名称"); }else if(data && data.value === "drawList"){
return
}
this.drawModel = "unit";
this.showDraw = true;
}else if(data.value === "drawList"){
this.drawModel = "list"; this.drawModel = "list";
this.showDraw = true; this.showDraw = true;
}else if(data.value === "submit"){ }else if(data && data.value === "submit"){
this.tableService.addOrUpdate(this.updateParams,this.currentId===-1).then((res)=>{ this.doSave()
this.$message.success(this.currentId===-1?"新增成功!":"修改成功!"); }else if(data && data.value === "saveAndContinue"){
this.handleClose(); this.doSave(true)
this.getTableData(); }else if(data && data.value === "cancel"){
})
}else if(data.value === "saveAndContinue"){
this.tableService.addOrUpdate(this.updateParams,this.currentId===-1).then((res)=>{
this.$message.success("新增成功!");
this.updateParams = {bottomHeight:0,topHeight:0,geoJson:"[]"} as any
})
}else if(data.value === "cancel"){
this.updateParams = {} as any; this.updateParams = {} as any;
this.handleClose(); this.handleClose();
} }
@ -269,10 +333,11 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
public showUpdateModel(data?,isRead?){ public showUpdateModel(data?,isRead?){
if(!data){ if(!data){
this.currentId = -1; this.currentId = -1;
this.updateParams = {bottomHeight:0,topHeight:0,geoJson:"[]"} as any this.updateParams = {bottomHeight:0,topHeight:0,geoJson:"[]",number:null} as any;
this.showUpdate = true
}else{ }else{
this.currentId = data.id; this.currentId = data.id;
this.updateParams = Object.assign({bottomHeight:0,topHeight:0,geoJson:"[]"},data); this.updateParams = Object.assign({bottomHeight:0,topHeight:0,geoJson:"[]",number:null},data);
this.isReadonly = !!isRead; this.isReadonly = !!isRead;
this.buildFormOptions(); this.buildFormOptions();
} }
@ -280,6 +345,7 @@ export default class UnitManagerComponent extends BaseRecordComponent<any> {
} }
public handleClose(){ public handleClose(){
this.updateParams = {} as any;
this.showUpdate = false; this.showUpdate = false;
this.currentId = -1; this.currentId = -1;
this.isReadonly = false; this.isReadonly = false;