From 12d1d4aad2185e9dffbffa252f27c846aabbf93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=BB=B6=E7=A6=8F?= <> Date: Thu, 15 Jun 2023 18:24:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/rule.service.ts | 33 ++ src/service/table.service.ts | 37 ++ src/service/unit.service.ts | 5 + src/service/work.service.ts | 4 +- src/store/index.ts | 11 + src/views/blank.component.vue | 9 +- .../hiddenDanger/rules/rules.component.html | 97 +++- .../hiddenDanger/rules/rules.component.vue | 223 ++++---- .../rules/rulesManager.component.vue | 488 +++++++++++++----- src/views/risk/area/area.component.vue | 10 +- src/views/risk/areaUnit.component.html | 52 +- .../areaAnal/areaAnal.component.html | 8 +- .../areaAnal/areaAnal.component.vue | 7 +- .../risk/assessment/work/work.component.html | 12 +- .../risk/assessment/work/work.component.vue | 35 +- src/views/risk/unit/unit.component.vue | 12 +- 16 files changed, 747 insertions(+), 296 deletions(-) create mode 100644 src/service/rule.service.ts create mode 100644 src/service/table.service.ts diff --git a/src/service/rule.service.ts b/src/service/rule.service.ts new file mode 100644 index 0000000..3918da0 --- /dev/null +++ b/src/service/rule.service.ts @@ -0,0 +1,33 @@ +import BaseService from "hbt-common/service/base.service" +import type { AxiosResponse } from 'axios' +import { ActionResult } from "hbt-common/models/actionResult"; +export default class RuleService extends BaseService{ + constructor(){ + super() + } + // 查询列表 + public selectByPage(params: any):Promise>>{ + const url = this.prefix.prevention+'/danger/standard/list'; + return this.get(url,params,true) + } + // 批量删除 + public deleteByIds(params):Promise>>{ + const url = this.prefix.prevention+'/danger/standard'; + return this.deleteBatch(url,params,{},true) + } + + public getNumber():Promise>>{ + const url = this.prefix.prevention+'/danger/standard/number'; + return this.get(url,null) + } + + // 新增或更新 + public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise>>{ + const url = this.prefix.prevention+'/danger/standard'; + if(add){ + return this.post(url,params,{},showLoading) + }else{ + return this.put(url,params,{},showLoading) + } + } +} \ No newline at end of file diff --git a/src/service/table.service.ts b/src/service/table.service.ts new file mode 100644 index 0000000..46e55ee --- /dev/null +++ b/src/service/table.service.ts @@ -0,0 +1,37 @@ +import BaseService from "hbt-common/service/base.service" +import type { AxiosResponse } from 'axios' +import { ActionResult } from "hbt-common/models/actionResult"; +export default class TableService extends BaseService{ + constructor(){ + super() + } + // 查询列表 + public selectByPage(params: any):Promise>>{ + const url = this.prefix.prevention+'/danger/table/list'; + return this.get(url,params,true) + } + // 批量删除 + public deleteByIds(params):Promise>>{ + const url = this.prefix.prevention+'/danger/table'; + return this.deleteBatch(url,params,{},true) + } + public selectById(id:any,showLoading?:boolean):Promise>>{ + const url = this.prefix.prevention+'/danger/table/'+id; + return this.get(url,null,showLoading) + } + + public getNumber():Promise>>{ + const url = this.prefix.prevention+'/danger/table/number'; + return this.get(url,null) + } + + // 新增或更新 + public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise>>{ + const url = this.prefix.prevention+'/danger/table'; + if(add){ + return this.post(url,params,{},showLoading) + }else{ + return this.put(url,params,{},showLoading) + } + } +} \ No newline at end of file diff --git a/src/service/unit.service.ts b/src/service/unit.service.ts index a0b647d..83884b6 100644 --- a/src/service/unit.service.ts +++ b/src/service/unit.service.ts @@ -9,6 +9,11 @@ export default class UnitService extends BaseService{ const url = this.prefix.prevention+'/risk/unit/list'; return this.get(url,params,showLoading) } + + public getListByIds(params: any,showLoading?):Promise>>{ + const url = this.prefix.prevention+'/risk/unit/list/byareas'; + return this.get(url,params,showLoading) + } public deleteByIds(params):Promise>>{ const url = this.prefix.prevention+'/risk/unit'; return this.deleteBatch(url,params,{},true) diff --git a/src/service/work.service.ts b/src/service/work.service.ts index afcf571..85f5dba 100644 --- a/src/service/work.service.ts +++ b/src/service/work.service.ts @@ -17,10 +17,12 @@ export default class WorkService extends BaseService{ // 新增或更新 public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise>>{ - const url = this.prefix.prevention+'/job/inventory'; + if(add){ + const url = this.prefix.prevention+'/job/inventory/add'; return this.post(url,params,{},showLoading) }else{ + const url = this.prefix.prevention+'/job/inventory/update'; return this.put(url,params,{},showLoading) } } diff --git a/src/store/index.ts b/src/store/index.ts index 88d7d48..d60e406 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -13,6 +13,7 @@ export default new Vuex.Store({ prevention_dangrous_level:[], prevention_risk_level:[], prevention_safe_reason:[], + prevention_dangrous_type:[], }, getters: { dept_map:(state)=>{ @@ -63,6 +64,13 @@ export default new Vuex.Store({ map[item.value] = item.name }) return map + }, + prevention_dangrous_type_map:(state)=>{ + const map = {}; + state.prevention_dangrous_type.forEach((item:any)=>{ + map[item.value] = item.name + }) + return map } }, mutations: { @@ -91,6 +99,9 @@ export default new Vuex.Store({ }, set_prevention_safe_reason(state,data){ state.prevention_safe_reason = data; + }, + set_prevention_dangrous_type(state,data){ + state.prevention_dangrous_type = data; } }, actions: { diff --git a/src/views/blank.component.vue b/src/views/blank.component.vue index c062bfb..e748eaa 100644 --- a/src/views/blank.component.vue +++ b/src/views/blank.component.vue @@ -21,7 +21,8 @@ export default class BlankComponent extends Vue { this.systemService.getDictData("common_yes_no"), this.systemService.getDictData("prevention_dangrous_level"), this.systemService.getDictData("prevention_risk_level"), - this.systemService.getDictData("prevention_safe_reason") + this.systemService.getDictData("prevention_safe_reason"), + this.systemService.getDictData("prevention_dangrous_type") ]).then(((results:any)=>{ this.$store.commit("setDeptTreeList",results[0].data); this.$store.commit("setUserList",results[2].data.datas.map((item)=>{ @@ -64,6 +65,12 @@ export default class BlankComponent extends Vue { value:isNaN(+item.dictValue)?item.dictValue:+item.dictValue } })) + this.$store.commit("set_prevention_dangrous_type",results[8].data.map(item=>{ + return { + name:item.dictLabel, + value:isNaN(+item.dictValue)?item.dictValue:+item.dictValue + } + })) diff --git a/src/views/hiddenDanger/rules/rules.component.html b/src/views/hiddenDanger/rules/rules.component.html index 4bb4032..cc5394e 100644 --- a/src/views/hiddenDanger/rules/rules.component.html +++ b/src/views/hiddenDanger/rules/rules.component.html @@ -2,29 +2,34 @@
- - + + + @@ -32,15 +37,73 @@
-
-
- -
- - + +
检查项目
+ + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
+ 取消 + 确定 +
+
\ No newline at end of file diff --git a/src/views/hiddenDanger/rules/rules.component.vue b/src/views/hiddenDanger/rules/rules.component.vue index dc1af46..1e7c390 100644 --- a/src/views/hiddenDanger/rules/rules.component.vue +++ b/src/views/hiddenDanger/rules/rules.component.vue @@ -5,10 +5,11 @@ import template from "./rules.component.html" import BaseRecordComponent from "hbt-common/components/common/baseRecord.component.vue" import FormComponent from "hbt-common/components/common/form.component.vue" import TableComponent from "hbt-common/components/common/table.component.vue" -import AreaService from "@/service/area.service" import FormOption from "hbt-common/models/formOptions" import BtnOption from "hbt-common/models/btnOptions" import DrawComponent from '@/components/draw.component.vue'; +import RuleService from '@/service/rule.service'; +import { number } from 'echarts'; @Component({ template, components:{ @@ -18,10 +19,14 @@ import DrawComponent from '@/components/draw.component.vue'; }, }) export default class RulesComponent extends BaseRecordComponent { - public tableService = new AreaService(); + public tableService = new RuleService(); public params = {} as any; + public isReadonly = false; + + public isManager = false; + public formActions = [{ name:"查询", value:"search", @@ -54,93 +59,14 @@ export default class RulesComponent extends BaseRecordComponent { }]; public formOptions:FormOption[] = [{ name:"检查项目", - key:"areaId", + key:"name", type:"text", }]; public showUpdate = false; public currentId = -1; public updateParams = {} as any; - public updateOptions:FormOption[] = [{ - name:"区域编号", - key:"no", - type:"text", - width:"calc(50% - 20px)", - require:true - },{ - name:"区域名称", - key:"areaName", - type:"text", - width:"calc(50% - 20px)", - require:true - },{ - name:"责任部门", - key:"deptId", - type:"select", - width:"calc(50% - 20px)", - require:true, - datas:[{ - name:"部门1", - value:0 - },{ - name:"部门2", - value:1 - }] - },{ - name:"责任人", - key:"person", - type:"select", - width:"calc(50% - 20px)", - require:true, - datas:[{ - name:"人员1", - value:0 - },{ - name:"人员2", - value:1 - }] - },{ - name:"属于重大危险源", - key:"isDangrous", - type:"radio", - width:"calc(50% - 20px)", - require:true, - datas:[{ - name:"是", - value:0 - },{ - name:"否", - value:1 - }] - },{ - name:"重大危险源名称", - key:"dangrousName", - type:"text", - width:"calc(50% - 20px)", - require:true, - },{ - name:"重大危险源等级", - key:"level", - type:"select", - width:"calc(50% - 20px)", - require:true, - datas:[{ - name:"一级", - value:0 - },{ - name:"二级", - value:1 - }] - },{ - type:"btn", - name:"区域绘制", - width:"calc(50% - 20px)", - btn:[{ - name:"开始绘制", - value:"draw", - type:"primary" - }] - }]; + public updateOptions:FormOption[] = []; public showDraw = false; @@ -168,58 +94,141 @@ export default class RulesComponent extends BaseRecordComponent { } - public buildTable(){ - this.tableColumn.push({name:'序号',key:"areaName"}); - this.tableColumn.push({name:'检查项目',key:"areaName"}); - this.tableColumn.push({name:'检查内容',key:"deptName"}); - this.tableColumn.push({name:'检查依据',key:"person"}); - this.tableColumn.push({name:'分类',key:"isDangrous"}); + public getTableCallback(){ + this.updateOptions = [{ + name:"检查标准编号", + key:"number", + type:"text", + width:"calc(50% - 20px)", + require:true, + showError:false, + disable:true, + },{ + name:"检查项目", + key:"name", + type:"text", + width:"calc(50% - 20px)", + require:true, + showError:false, + },{ + name:"检查内容", + key:"content", + type:"textarea", + width:"100%", + require:true, + showError:false, + },{ + name:"检查依据", + key:"reason", + type:"textarea", + width:"100%", + require:true, + showError:false, + },{ + name:"类型", + key:"type", + format:"typeName", + type:"select", + width:"100%", + require:true, + datas:this.$store.state.prevention_dangrous_type + }] } - public callback(data){ + public buildTable(){ + this.tableColumn.push({name:'检查项目',key:"name"}); + this.tableColumn.push({name:'检查内容',key:"content",showTip:true}); + this.tableColumn.push({name:'检查依据',key:"reason",showTip:true}); + this.tableColumn.push({name:'分类',key:"type",render:(data)=>{ + return this.$store.getters.prevention_dangrous_type_map[data.type] + }}); + + } + + public change(data,item){ + // + } + + public callback(data,type?){ + if(type){ + this.params[type] = data; + this.getTableData(); + return + } // 查询 - if(data.value==="search"){ + if(data && data.value==="search"){ this.getTableData() // 重置 - }else if(data.value === "reset"){ + }else if(data && data.value === "reset"){ this.reset() // 反选 - }else if(data.value === "reverse"){ + }else if(data && data.value === "reverse"){ this.toggleAll() // 全选 - }else if(data.value === "selectAll"){ + }else if(data && data.value === "selectAll"){ this.selectAll() - }else if(data.value === "add"){ - this.showUpdateModel(-1) - }else if(data.value === "delete"){ - this.deleteData(this.selectData.map((item:any)=>item.id)) - }else if(data.value === "draw"){ - this.drawModel = "area"; - this.showDraw = true; - }else if(data.value === "drawList"){ - this.drawModel = "list"; - this.showDraw = true; + }else if(data && data.value === "add"){ + this.showUpdateModel() + }else if(data && data.value === "delete"){ + this.deleteData(this.selectData.map((item:any)=>item.id)); + this.clearSelect() + }else if(data && data.value.indexOf("save")>=0){ + this.doSave(data.value!=="save") + }else{ + this.handleClose(); } } // 重置数据 public reset(){ this.params = { + name:"", pageNum:1, pageSize:20, } as any; } + public doSave(goOn?){ + this.tableService.addOrUpdate(this.updateParams,this.currentId===-1).then((res=>{ + this.$message.success(this.currentId===-1?"新增成功!":"编辑成功"); + this.showUpdate = !!goOn; + this.updateParams = {number:null} as any; + if(goOn){ + this.tableService.getNumber().then(res=>{ + this.updateParams.number = res.data + }) + } + this.getTableData(); + + })) + } - public showUpdateModel(id){ - if(id!==-1){ + + public showUpdateModel(row?,isRead?){ + + this.updateParams = Object.assign({number:null}) + this.isReadonly = !!isRead; + if(!row){ + this.currentId = -1; + this.tableService.getNumber().then(res=>{ + this.updateParams.number = res.data + }) + }else{ + this.updateParams = Object.assign({number:null,typeName:this.$store.getters.prevention_dangrous_type_map[row.type]},row) + this.currentId = row.id; } - this.currentId = id; + this.clearSelect(); this.showUpdate = true } + public clearSelect(){ + (this.$refs.multipleTable as any).clearSelection(); + this.selectData = []; + } + public handleClose(){ this.showUpdate = false; + this.clearSelect(); } diff --git a/src/views/hiddenDanger/rules/rulesManager.component.vue b/src/views/hiddenDanger/rules/rulesManager.component.vue index d1d0c55..6d2cb48 100644 --- a/src/views/hiddenDanger/rules/rulesManager.component.vue +++ b/src/views/hiddenDanger/rules/rulesManager.component.vue @@ -5,10 +5,13 @@ import template from "./rules.component.html" import BaseRecordComponent from "hbt-common/components/common/baseRecord.component.vue" import FormComponent from "hbt-common/components/common/form.component.vue" import TableComponent from "hbt-common/components/common/table.component.vue" -import AreaService from "@/service/area.service" import FormOption from "hbt-common/models/formOptions" import BtnOption from "hbt-common/models/btnOptions" import DrawComponent from '@/components/draw.component.vue'; +import TableService from '@/service/table.service'; +import UnitService from '@/service/unit.service'; +import AreaService from '@/service/area.service'; +import RuleService from '@/service/rule.service'; @Component({ template, components:{ @@ -18,10 +21,22 @@ import DrawComponent from '@/components/draw.component.vue'; }, }) export default class RulesManagerComponent extends BaseRecordComponent { - public tableService = new AreaService(); + public tableService = new TableService(); + public unitService = new UnitService() + public areaService = new AreaService() + + public ruleService = new RuleService() public params = {} as any; + public isReadonly = false; + + public subIsReadonly = false; + public isManager = true; + + public areaList = []; + public unitList = []; + public formActions = [{ name:"查询", value:"search", @@ -44,6 +59,24 @@ export default class RulesManagerComponent extends BaseRecordComponent { icon:"el-icon-delete", type:"danger" }]; + public updateTableActions = [{ + name:"添加", + value:"subAdd", + plain:true, + icon:"el-icon-plus", + type:"success" + },{ + name:"批量删除", + value:"subDelete", + plain:true, + icon:"el-icon-delete", + type:"danger" + },{ + name:"批量添加", + value:"subMutilAdd", + icon:"el-icon-plus", + type:"primary" + }]; public footerActions = [{ name:"选择全部", value:"selectAll", @@ -61,92 +94,16 @@ export default class RulesManagerComponent extends BaseRecordComponent { public showUpdate = false; public currentId = -1; public updateParams = {} as any; - public updateOptions:FormOption[] = [{ - name:"区域编号", - key:"no", - type:"text", - width:"calc(50% - 20px)", - require:true - },{ - name:"区域名称", - key:"areaName", - type:"text", - width:"calc(50% - 20px)", - require:true - },{ - name:"责任部门", - key:"deptId", - type:"select", - width:"calc(50% - 20px)", - require:true, - datas:[{ - name:"部门1", - value:0 - },{ - name:"部门2", - value:1 - }] - },{ - name:"责任人", - key:"person", - type:"select", - width:"calc(50% - 20px)", - require:true, - datas:[{ - name:"人员1", - value:0 - },{ - name:"人员2", - value:1 - }] - },{ - name:"属于重大危险源", - key:"isDangrous", - type:"radio", - width:"calc(50% - 20px)", - require:true, - datas:[{ - name:"是", - value:0 - },{ - name:"否", - value:1 - }] - },{ - name:"重大危险源名称", - key:"dangrousName", - type:"text", - width:"calc(50% - 20px)", - require:true, - },{ - name:"重大危险源等级", - key:"level", - type:"select", - width:"calc(50% - 20px)", - require:true, - datas:[{ - name:"一级", - value:0 - },{ - name:"二级", - value:1 - }] - },{ - type:"btn", - name:"区域绘制", - width:"calc(50% - 20px)", - btn:[{ - name:"开始绘制", - value:"draw", - type:"primary" - }] - }]; - - - public showDraw = false; - - public drawModel = "list"; - + public subUpdateParams = {} as any; + public updateOptions:FormOption[] = []; + public updateTableData = {datas:[]}; + public updateTableColumn = [] as any; + public showSubUpdate = false; + public showSubMutilUpdate = false; + public ruleParams = { + pageSize:10, + pageNum:1 + } public updateActions = [{ name:"取消", @@ -161,68 +118,365 @@ export default class RulesManagerComponent extends BaseRecordComponent { type:"primary" }]; + public subUpdateOptions = [{ + name:"检查项目", + type:"text", + require:true, + showError:false, + width:"100%", + key:"name", + },{ + name:"检查内容", + type:"textarea", + require:true, + width:"100%", + showError:false, + key:"content", + },{ + name:"检查依据", + type:"textarea", + require:true, + width:"100%", + showError:false, + key:"reason", + }] + + public subUpdateActions = [{ + name:"取消", + value:"cancelSub" + },{ + name:"确定", + value:"saveSub", + type:"primary" + }]; + public selectData = []; created(){ + this.loadAreaData(); + this.loadRuleTable(); + } + public loadRuleTable(num?,type?){ + if(type && num){ + this.ruleParams[type] = num + }else{ + this.ruleParams = { + pageSize:10, + pageNum:1 + } + } + this.ruleService.selectByPage(this.ruleParams).then((res:any)=>{ + this.updateTableData = res.data; + this.updateTableData.datas.forEach((item:any,index)=>{ + item.index = index+1; + }) + }) + } + + public buildUpdateForm(){ + this.updateOptions = [{ + name:"检查表编号", + key:"number", + type:"text", + width:"calc(50% - 20px)", + require:true, + disable:true, + },{ + name:"检查表名称", + key:"name", + type:"text", + width:"calc(50% - 20px)", + require:true, + showError:false, + },{ + name:"适用区域", + key:"areas", + type:"select", + multiple:true, + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:this.areaList + },{ + name:"适用单元", + key:"units", + type:"select", + multiple:true, + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:this.unitList + },{ + name:"适用对象", + key:"targets", + type:"select", + multiple:true, + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:[{ + name:"是", + value:"0-12312312312" + },{ + name:"否", + value:"1-12312312312" + }] + },{ + name:"适用部门", + key:"depts", + multiple:true, + type:"select", + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:this.$store.state.deptList + },{ + name:"适用类型", + key:"types", + type:"select", + width:"calc(50% - 20px)", + require:true, + multiple:true, + showError:false, + datas:this.$store.state.prevention_dangrous_type + }] + } + + // 加载区域列表 + public loadAreaData(){ + this.areaService.selectByPage({pageSize:1000}).then((res:any)=>{ + this.areaList = res.data.datas.map(item=>{ + return { + name:item.name, + value:item.id + } + }); + this.buildUpdateForm() + }) + } + // 加载单元列表 + public loadUnitData(ids?){ + this.unitService.getListByIds({areaIds:ids},false).then((res:any)=>{ + this.unitList = res.data.map(item=>{ + return { + name:item.name, + value:item.id + } + }); + this.buildUpdateForm() + }) + } + + public getNumber(){ + this.tableService.getNumber().then(res=>{ + this.updateParams.number = res.data + }) } public buildTable(){ - this.tableColumn.push({name:'序号',key:"areaName"}); - this.tableColumn.push({name:'检查表名称',key:"areaName"}); - this.tableColumn.push({name:'区域名称',key:"deptName"}); - this.tableColumn.push({name:'单元名称',key:"person"}); - this.tableColumn.push({name:'对象名称',key:"isDangrous"}); - this.tableColumn.push({name:'编制部门',key:"isDangrous"}); - this.tableColumn.push({name:'适用类型',key:"isDangrous"}); - this.tableColumn.push({name:'编制人',key:"isDangrous"}); - this.tableColumn.push({name:'编制时间',key:"isDangrous"}); + this.tableColumn.push({name:'检查表名称',key:"name"}); + this.tableColumn.push({name:'区域名称',key:"areas"}); + this.tableColumn.push({name:'单元名称',key:"units"}); + this.tableColumn.push({name:'对象名称',key:"targets"}); + this.tableColumn.push({name:'适用部门',key:"depts"}); + this.tableColumn.push({name:'适用类型',key:"types"}); + this.tableColumn.push({name:'编制人',key:"createBy"}); + this.tableColumn.push({name:'编制时间',key:"createTime"}); + + + this.updateTableColumn.push({name:'序号',key:"index"}); + this.updateTableColumn.push({name:'检查项目',key:"name",showTip:true}); + this.updateTableColumn.push({name:'检查内容',key:"content",showTip:true}); + this.updateTableColumn.push({name:'检查依据',key:"reason",showTip:true}); } - public callback(data){ + public change(data,item){ + + // 区域 + if(item && item.key==="areas"){ + if(this.updateParams.units.length){ + this.updateParams.units = []; + } + this.loadUnitData(data) + } + } + + public callback(data,type?){ + if(type){ + this.params[type] = data; + this.getTableData(); + return + } // 查询 - if(data.value==="search"){ + if(data && data.value==="search"){ this.getTableData() // 重置 - }else if(data.value === "reset"){ + }else if(data &&data.value === "reset"){ this.reset() // 反选 - }else if(data.value === "reverse"){ + }else if(data &&data.value === "reverse"){ this.toggleAll() // 全选 - }else if(data.value === "selectAll"){ + }else if(data && data.value === "selectAll"){ this.selectAll() - }else if(data.value === "add"){ - this.showUpdateModel(-1) - }else if(data.value === "delete"){ + }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.value === "draw"){ - this.drawModel = "area"; - this.showDraw = true; - }else if(data.value === "drawList"){ - this.drawModel = "list"; - this.showDraw = true; + }else if(data && data.value.indexOf("save")>=0){ + this.doSave(data.value!=="save") } } + + public subChange(data,item){ + // + } + + public subCallback(data){ + if(data && data.value==="subAdd"){ + this.showSubUpdateModel() + }else if(data && data.value.indexOf("save")>=0){ + this.doSubSave(data.value!=="save") + }else if(data && data.value==="cancel"){ + this.handleClose() + }else if(data && data.value==="subDelete"){ + this.doSubDelete(this.selectData.map((item:any)=>item.index -1)) + }else if(data && data.value==="subMutilAdd"){ + this.showSubMutilUpdate = true; + this.clearSelect() + } + } + + public doMutilAdd(){ + this.selectData.forEach((item:any)=>{ + if(!this.updateParams.tableItems.find(itm=>itm.id===item.id)){ + this.updateParams.tableItems.push(item) + } + }) + + this.updateParams.tableItems.forEach((item,i)=>{ + item.index = i+1 + }) + this.clearSelect() + this.showSubMutilUpdate=false + } + + public cancelMutilAdd(){ + this.clearSelect() + this.showSubMutilUpdate=false; + + } + + public clearSelect(){ + (this.$refs.multipleTable as any).clearSelection(); + this.selectData = []; + } // 重置数据 public reset(){ this.params = { + name:"", pageNum:1, pageSize:20, } as any; } - - - public showUpdateModel(id){ - if(id!==-1){ + public showSubUpdateModel(row?){ + this.subUpdateParams = {} as any; + if(!row){ + }else{ + this.subUpdateParams = JSON.parse(JSON.stringify(row)) } - this.currentId = id; - this.showUpdate = true + this.showSubUpdate = true; + } + + + + public showUpdateModel(row?,isRead?){ + this.updateParams = {number:null,tableItems:[]} as any; + this.isReadonly = !!isRead; + this.clearSelect() + if(!row){ + this.currentId = -1; + this.getNumber(); + this.showUpdate = true; + }else{ + this.currentId = row.id; + this.tableService.selectById(this.currentId,true).then((res:any)=>{ + if(isRead){ + this.updateParams = Object.assign(res.data,row) + }else{ + this.updateParams = res.data; + this.loadUnitData(res.data.areas) + } + + this.updateParams.tableItems.forEach((item,i)=>{ + item.index = i+1 + }) + this.showUpdate = true; + }) + } + } + public doSubSave(goOn?){ + if(!this.subUpdateParams.index){ + this.subUpdateParams.index = this.updateParams.tableItems.length+1; + this.updateParams.tableItems.push(this.subUpdateParams); + }else{ + this.updateParams.tableItems.splice(this.updateParams.tableItems.findIndex(item=>item.index ===this.subUpdateParams.index),1,this.subUpdateParams) + } + + this.updateParams.tableItems.forEach((item,i)=>{ + item.index = i+1 + }) + this.subUpdateParams = {} as any; + this.showSubUpdate = !!goOn + } + + public doSubDelete(indexs){ + for(let i = this.updateParams.tableItems.length-1;i>=0;i--){ + if(indexs.includes(i)){ + this.updateParams.tableItems.splice(i,1) + } + } + + this.updateParams.tableItems.forEach((item,i)=>{ + item.index = i+1 + }) + this.clearSelect() + } + + public doSave(goOn?){ + this.updateParams.depts = this.updateParams.depts.map(item=>{ + return { + id:item, + name:this.$store.getters.dept_map[item] + } + }) + + this.updateParams.targets = this.updateParams.targets.map(item=>{ + return { + id:item, + name:item + } + }) + this.tableService.addOrUpdate(this.updateParams,this.currentId===-1).then(res=>{ + this.$message.success(this.currentId===-1?"新增成功!":"编辑成功"); + this.getTableData(); + this.showUpdate = !!goOn; + this.updateParams = {areas:[],depts:[],units:[],types:[],targets:[],number:null} as any; + }) } public handleClose(){ + if(this.showSubMutilUpdate){ + this.showSubMutilUpdate = false; + return + } + if(this.showSubUpdate){ + this.showSubUpdate = false; + return + } this.showUpdate = false; } diff --git a/src/views/risk/area/area.component.vue b/src/views/risk/area/area.component.vue index a2a14b8..15ced2c 100644 --- a/src/views/risk/area/area.component.vue +++ b/src/views/risk/area/area.component.vue @@ -321,7 +321,7 @@ export default class AreaManagerComponent extends BaseRecordComponent { }) } - public callback(data,item?){ + public change(data,item?){ // 新增编辑选择部门 if(item && item.key === "chargeDeptId"){ this.updateParams.chargeDeptName = this.$store.getters.dept_map[data]; @@ -335,6 +335,14 @@ export default class AreaManagerComponent extends BaseRecordComponent { this.updateOptions[5].hide = !data; this.updateOptions[6].hide = !data; } + } + + public callback(data,type?){ + if(type){ + this.params[type] = data; + this.getTableData(); + return + } // 查询 if(data && data.value==="search"){ this.getTableData() diff --git a/src/views/risk/areaUnit.component.html b/src/views/risk/areaUnit.component.html index 3764b6c..7410232 100644 --- a/src/views/risk/areaUnit.component.html +++ b/src/views/risk/areaUnit.component.html @@ -1,57 +1,61 @@ -
+
- - + + - +
- +
- - + + *注:安全风险分析对象编码即危险化学品登记综合服务系统中的危险源编码
停用/检修记录
-
@@ -59,13 +63,13 @@
- + - + + @actionCallback="doTurnOffAction" :actions="turnOffAction" btn-position="center">
\ No newline at end of file diff --git a/src/views/risk/assessment/areaAnal/areaAnal.component.html b/src/views/risk/assessment/areaAnal/areaAnal.component.html index 1cd165f..5972526 100644 --- a/src/views/risk/assessment/areaAnal/areaAnal.component.html +++ b/src/views/risk/assessment/areaAnal/areaAnal.component.html @@ -5,11 +5,11 @@ :full-btn="false" @change="callback" btn-position="end">
- + -