From a2b47a315e95eddd3030ecd3561ee6a51899d1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=BB=B6=E7=A6=8F?= <> Date: Sun, 25 Jun 2023 09:49:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootstrap.ts | 4 +- src/service/task.service.ts | 12 +- src/views/hiddenDanger/clap.component.vue | 47 +- src/views/hiddenDanger/common.component.html | 166 +++---- .../hiddenDanger/safe/action.component.vue | 411 +++++++++++++++++- 5 files changed, 530 insertions(+), 110 deletions(-) diff --git a/src/bootstrap.ts b/src/bootstrap.ts index 8aa8fc0..f6ffe83 100644 --- a/src/bootstrap.ts +++ b/src/bootstrap.ts @@ -12,9 +12,9 @@ import Mock from "mockjs" // import { MockData } from './mock'; Vue.config.productionTip = false; -Vue.config.warnHandler = ()=>{ +// Vue.config.warnHandler = ()=>{ -} +// } document.title = process.env.VUE_APP_TITLE || '汉邦唐全真数字服务平台'; // if(process.env.NODE_ENV==="development"){ diff --git a/src/service/task.service.ts b/src/service/task.service.ts index eade67b..7e472b7 100644 --- a/src/service/task.service.ts +++ b/src/service/task.service.ts @@ -12,7 +12,7 @@ export default class TaskService extends BaseService{ } // 批量删除 public deleteByIds(params):Promise>>{ - const url = this.prefix.prevention+'/danger/task'; + const url = this.prefix.prevention+'/danger/trouble'; return this.deleteBatch(url,params,{},true) } public selectById(id:any,showLoading?:boolean):Promise>>{ @@ -21,13 +21,19 @@ export default class TaskService extends BaseService{ } public getNumber():Promise>>{ - const url = this.prefix.prevention+'/danger/table/number'; + const url = this.prefix.prevention+'/danger/trouble/number'; return this.get(url,null) } + + public getFileUrls(params):Promise>>{ + const url = this.prefix.file+'/getSysFiles'; + return this.get(url,params,false) + } + // 新增或更新 public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise>>{ - const url = this.prefix.prevention+'/danger/task'; + const url = this.prefix.prevention+'/danger/trouble'; if(add){ return this.post(url,params,{},showLoading) }else{ diff --git a/src/views/hiddenDanger/clap.component.vue b/src/views/hiddenDanger/clap.component.vue index b2cb59c..67c64da 100644 --- a/src/views/hiddenDanger/clap.component.vue +++ b/src/views/hiddenDanger/clap.component.vue @@ -488,7 +488,6 @@ export default class HiddenDangerClapComponent extends BaseRecordComponent inspectUserId:this.account.userId, inspectUserName:this.account.nickName, number:null, - photo:1, inspectTime:moment().format("YYYY-MM-DD HH:mm") } if(!row){ @@ -520,28 +519,32 @@ export default class HiddenDangerClapComponent extends BaseRecordComponent this.buildUpdateForm() // 获取url - this.tableService.getFileUrls({ids:res.data.resourceId.split(",")}).then((photos:any)=>{ - this.photoList = photos.data.map(item=>{ - return { - name:item.originalName, - url:item.url, - type:item.type, - id:item.id - } + if(res.data.resourceId){ + this.tableService.getFileUrls({ids:res.data.resourceId.split(",")}).then((photos:any)=>{ + this.photoList = photos.data.map(item=>{ + return { + name:item.originalName, + url:item.url, + type:item.type, + id:item.id + } + }) + this.buildUpdateForm() }) - this.buildUpdateForm() - }) - this.tableService.getFileUrls({ids:res.data.resourceOtherId.split(",")}).then((files:any)=>{ - this.fileList = files.data.map(item=>{ - return { - name:item.originalName, - url:item.url, - type:item.type, - id:item.id - } + } + if(res.data.resourceOtherId){ + this.tableService.getFileUrls({ids:res.data.resourceOtherId.split(",")}).then((files:any)=>{ + this.fileList = files.data.map(item=>{ + return { + name:item.originalName, + url:item.url, + type:item.type, + id:item.id + } + }) + this.buildUpdateForm() }) - this.buildUpdateForm() - }) + } this.showUpdate = true }) } @@ -575,6 +578,7 @@ export default class HiddenDangerClapComponent extends BaseRecordComponent type:res.data.type, id:res.data.id }); + this.updateParams.photo = this.photoList.length } } public onSuccess2(res,file,fileList){ @@ -590,6 +594,7 @@ export default class HiddenDangerClapComponent extends BaseRecordComponent public onRemove(file,fileList){ this.photoList.splice(this.photoList.findIndex(item=>item.id === file.response.data.id),1) + this.updateParams.photo = this.photoList.length } public onRemove2(file,fileList){ this.fileList.splice(this.fileList.findIndex(item=>item.id === file.response.data.id),1) diff --git a/src/views/hiddenDanger/common.component.html b/src/views/hiddenDanger/common.component.html index 7e3ab26..584d023 100644 --- a/src/views/hiddenDanger/common.component.html +++ b/src/views/hiddenDanger/common.component.html @@ -49,6 +49,91 @@ + + +
+ + {{item.name}} + +
+ +
+ + +
{{scope.$index+1}}
+
+ +
{{scope.row.itemName}}
+ +
+ +
{{scope.row.itemContent}}
+ +
+ +
{{scope.row.itemReason}}
+ +
+ +
{{scope.row.itemExecuteNames}}
+
+ +
+ + 正常 + 异常 + +
+
+ +
+ +
+
+
+
+
隐患登记情况
+
+ 添加 + 批量删除 +
+ +
+ + + +
{{scope.$index+1}}
+
+ +
{{$store.getters.prevention_dangrous_type_map[scope.row.classify]}}
+ +
+ +
{{levelMap[scope.row.level]}}
+
+ +
{{reformModeMap[scope.row.reformMode]}}
+
+ +
{{scope.row.description}}
+
+ +
{{scope.row.reformDeptName}}
+
+ +
{{scope.row.reformUserName}}
+
+ +
+ 查看 + 编辑 +
+
+
+
+
+ - - -
- - {{item.name}} - -
- -
- - -
{{scope.$index+1}}
-
- -
{{scope.row.itemName}}
- -
- -
{{scope.row.itemContent}}
- -
- -
{{scope.row.itemReason}}
- -
- -
{{scope.row.itemExecuteNames}}
-
- -
- - 正常 - 异常 - -
-
- -
- -
-
-
-
-
隐患登记情况
-
- 添加 - 批量删除 -
- -
- - -
{{scope.$index+1}}
-
- -
{{scope.row.name}}
- -
- -
{{scope.row.name}}
- -
- -
{{scope.row.name}}
- -
- -
{{scope.row.content}}
- -
- -
{{scope.row.reason}}
- -
- -
-
-
-
-
diff --git a/src/views/hiddenDanger/safe/action.component.vue b/src/views/hiddenDanger/safe/action.component.vue index b797ce3..6584e34 100644 --- a/src/views/hiddenDanger/safe/action.component.vue +++ b/src/views/hiddenDanger/safe/action.component.vue @@ -10,12 +10,16 @@ import FormOption from "hbt-common/models/formOptions" import BtnOption from "hbt-common/models/btnOptions" import DrawComponent from '@/components/draw.component.vue'; import TaskService from '@/service/task.service'; +import MapComponent from "@/components/map.component.vue" +import mapboxgl from "mapbox-gl"; +import moment from 'moment'; @Component({ template, components:{ FormComponent, TableComponent, DrawComponent, + MapComponent }, }) export default class RulesManagerComponent extends BaseRecordComponent { @@ -29,9 +33,12 @@ export default class RulesManagerComponent extends BaseRecordComponent { public isFile = false; public tableActionWidth="60px"; public statusList = ["","检查中","已检查","未检查"]; + public account = JSON.parse(localStorage.getItem("account") as string); public params = {} as any; + public idReadonly = false; + public formActions = [{ name:"查询", value:"search", @@ -42,6 +49,14 @@ export default class RulesManagerComponent extends BaseRecordComponent { icon:"el-icon-tickets", value:"reset" }]; + public updateActions = [{ + name:"取消", + value:"cancel" + },{ + name:"保存", + value:"save", + type:"primary" + }]; public tableActions = []; public footerActions = []; public formOptions:FormOption[] = []; @@ -61,7 +76,24 @@ export default class RulesManagerComponent extends BaseRecordComponent { public currentTableId:any = null; - public troubleTableData = {} as any; + public troubleTableData = [] as any; + public selectData = []; + + public showUpdate = false; + + public showMap = false; + public center = [118.751353,31.969568]; + public marker:any; + public isReadonly = false; + public fileList = [] as any; + public photoList = [] as any; + public map:any; + + public showFile = false; + public currentUrl = ""; + + public levelMap = ["","一般隐患","重大隐患"] + public reformModeMap = ["","即查即改","限期整改"] created(){ @@ -104,17 +136,20 @@ export default class RulesManagerComponent extends BaseRecordComponent { name:"隐患编号", key:"number", disable:true, + width:"100%", require:true, showError:false, type:"text" },{ name:"隐患标题", - key:"name", + key:"title", + width:"100%", require:true, showError:false, type:"text" },{ name:"隐患描述", + width:"100%", key:"description", require:true, showError:false, @@ -134,9 +169,189 @@ export default class RulesManagerComponent extends BaseRecordComponent { name:"重大隐患", value:2 }] + },{ + name:"整改方式", + key:"reformMode", + format:"reformModeName", + type:"select", + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:[{ + name:"即查即改", + value:1 + },{ + name:"限期整改", + value:2 + }] + },{ + name:"隐患位置", + key:"locationName", + type:"text", + width:"calc(50% - 20px)", + require:true, + showError:false, + unit:{ + type:"btn", + name:this.isReadonly?"查看定位":"点击定位", + value:"fixed", + btnType:"primary" + } + },{ + name:"隐患分类", + key:"classify", + format:"classifyName", + type:"select", + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:this.$store.state.prevention_dangrous_type + },{ + name:"整改部门", + key:"reformDeptId", + format:"reformDeptName", + type:"treeSelect", + width:"calc(50% - 20px)", + require:true, + expandLevel:Infinity, + showError:false, + datas:this.$store.state.deptTreeList + },{ + name:"整改责任人", + key:"reformUserId", + format:"reformUserName", + type:"select", + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:this.$store.state.userList, + },{ + name:"验证人", + key:"verifyUserId", + format:"verifyUserName", + type:"select", + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:this.$store.state.userList, + },{ + name:"整改时限", + key:"reformDeadline", + type:"date", + subType:"datetime", + format:"yyyy-MM-dd HH", + width:"calc(50% - 20px)", + require:true, + showError:false, + },{ + name:"隐患类别", + key:"dangerType", + format:"dangerTypeName", + type:"select", + width:"100%", + require:true, + showError:false, + datas:this.$store.state.prevention_danger_type, + },{ + name:"隐患照片", + key:"photo", + ref:"photo", + type:"upload", + width:"calc(50% - 20px)", + require:true, + onSucess:this.onSuccess, + onMove:this.onRemove, + showError:false, + autoUpload:true, + onPreview:this.onPreview, + accept:"image/png, image/jpeg", + listType:"picture-card", + fileList:this.photoList, + icon:"el-icon-plus", + },{ + name:"相关附件", + key:"file", + ref:"file", + type:"upload", + width:"calc(50% - 20px)", + showError:false, + onSucess:this.onSuccess2, + onMove:this.onRemove2, + onPreview:this.onPreview, + autoUpload:true, + accept:"image/png, image/jpeg,.doc,.docx,.xls,.xlsx,.pdf", + listType:"text", + tip:this.isReadonly?"":"请上传.pdf,.png,.jpg,.doc.docx,.xls,.xlsx格式文件", + fileList:this.fileList, + btn:[{ + name:"上传", + value:"upload", + hide:this.isReadonly, + size:"small", + type:"primary" + }] + },{ + name:"违章人数", + key:"violateNumber", + type:"number", + width:"calc(50% - 20px)", + showError:false, + },{ + name:"专业分类", + key:"professionClassify", + format:"professionClassifyName", + type:"select", + width:"calc(50% - 20px)", + require:true, + showError:false, + datas:this.$store.state.prevention_major_type, + },{ + name:"属性分类", + key:"attributeClassify", + format:"attributeClassifyName", + type:"select", + width:"calc(50% - 20px)", + showError:false, + datas:this.$store.state.prevention_safe_reason, + },{ + name:"发生环节", + key:"occurNode", + format:"occurNodeName", + type:"select", + width:"calc(50% - 20px)", + showError:false, + datas:this.$store.state.prevention_occur_step, + },{ + name:"违反规定条款", + key:"violateTerm", + type:"textarea", + width:"100%", + showError:false, + },{ + name:"隐患整改要求", + key:"reformDemand", + type:"textarea", + width:"100%", + showError:false, }] } + public change(data,item){ + if(item && item.key === "inspectUserId"){ + this.updateParams.inspectUserName = this.$store.getters.user_map[data] + } + if(item && item.key === "reformDeptId"){ + this.updateParams.reformDeptName = this.$store.getters.dept_map[data] + } + if(item && item.key === "reformUserId"){ + this.updateParams.reformUserName = this.$store.getters.user_map[data] + } + if(item && item.key === "verifyUserId"){ + this.updateParams.verifyUserName = this.$store.getters.user_map[data] + } + } + + public callback(data){ // 查询 if(data.value==="search"){ @@ -144,8 +359,37 @@ export default class RulesManagerComponent extends BaseRecordComponent { // 重置 }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 === "delete"){ + console.log(this.selectData) + this.deleteData(this.selectData.map((item:any)=>item.id)) + this.getTroubleList(); + }else if(data.value ==="fixed"){ + this.showMap = true + + }else if(data.value.indexOf("save")>=0){ + this.doSave(); + }else{ + this.handleClose() } } + + public doSave(){ + this.updateParams.resourceId = this.photoList.map(item=>item.id).join(",") + this.updateParams.resourceName = this.photoList.map(item=>item.name).join(",") + this.updateParams.resourceOtherId = this.fileList.map(item=>item.id).join(",") + this.updateParams.resourceOtherName = this.fileList.map(item=>item.name).join(",") + this.tableService.addOrUpdate(this.updateParams,!this.updateParams.id).then(res=>{ + this.$message.success(!this.updateParams.id?"新增成功!":"编辑成功"); + this.handleClose(); + this.getTroubleList(); + }) + } // 重置数据 public reset(){ this.params = { @@ -154,7 +398,29 @@ export default class RulesManagerComponent extends BaseRecordComponent { } as any; } + public getMap(map){ + this.map = map; + this.addMarker(); + } + public addMarker(){ + this.marker = new mapboxgl.Marker({draggable:!this.isReadonly}) + .setLngLat(this.center) + .addTo(this.map); + this.map.flyTo({center:this.center}) + } + public handleClose(){ + if(this.showMap){ + this.showMap = false; + this.marker.remove(); + this.marker = null; + return + } + if(this.showUpdate){ + this.showUpdate = false; + this.updateParams = {} as any; + return + } if(this.showRecord){ this.showRecord = false; this.recordParams = { @@ -166,10 +432,129 @@ export default class RulesManagerComponent extends BaseRecordComponent { } } + public onDragEnd() { + const lngLat = this.marker.getLngLat(); + this.updateParams.locationLng = lngLat.lng; + this.updateParams.locationLat = lngLat.lat; + this.center = [lngLat.lng,lngLat.lat] + // this.updateParams.locationName = lngLat.lng+","+lngLat.lat; + this.handleClose() + } + + + public onSuccess(res,file,fileList){ + if(res.code===200){ + this.photoList.push({ + name:res.data.originalName, + url:res.data.url, + type:res.data.type, + id:res.data.id + }); + this.updateParams.photo = this.photoList.length || null + } + } + public onSuccess2(res,file,fileList){ + if(res.code===200){ + this.fileList.push({ + name:res.data.originalName, + url:res.data.url, + type:res.data.type, + id:res.data.id + }) + } + } + + public onRemove(file,fileList){ + this.photoList.splice(this.photoList.findIndex(item=>item.id === file.response.data.id),1) + this.updateParams.photo = this.photoList.length + } + public onRemove2(file,fileList){ + this.fileList.splice(this.fileList.findIndex(item=>item.id === file.response.data.id),1) + } + + public onPreview(file){ + if(file.type.indexOf("png")>=0 || file.type.indexOf("jp")>=0){ + this.currentUrl = file.url; + this.showFile = true; + }else{ + window.open(file.url,"_blank") + } + } + + public showUpdateModel(row?,isRead?){ + this.isReadonly = !!isRead; + this.fileList = []; + this.photoList = []; + this.updateParams = { + taskId:this.recordParams.taskId, + locationName:"", + inspectUserId:this.account.userId, + inspectUserName:this.account.nickName, + number:null, + planId:this.recordParams.planId, + inspectTime:moment().format("YYYY-MM-DD HH:mm") + } + if(!row){ + this.tableService.getNumber().then(res=>{ + this.updateParams.number = res.data; + this.center = [118.751353,31.969568]; + this.getTableCallback(); + this.showUpdate = true; + }) + }else{ + + if(isRead){ + delete this.updateParams.photo; + } + + Object.assign(this.updateParams,{ + classifyName:this.$store.getters.prevention_dangrous_type_map[row.classify], + dangerTypeName:this.$store.getters.prevention_danger_type_map[row.dangerType], + inspectTypeName:this.$store.getters.prevention_danger_check_type_map[row.inspectType], + levelName:this.levelMap[row.level], + attributeClassifyName:this.$store.getters.prevention_safe_reason_map[row.attributeClassify], + professionClassifyName:this.$store.getters.prevention_major_type_map[row.professionClassify], + reformModeName:this.reformModeMap[row.reformMode], + },row) + // 获取url + if(row.resourceId){ + this.tableService.getFileUrls({ids:row.resourceId.split(",")}).then((photos:any)=>{ + this.photoList = photos.data.map(item=>{ + return { + name:item.originalName, + url:item.url, + type:item.type, + id:item.id + } + }) + this.getTableCallback() + }) + } + if(row.resourceOtherId){ + this.tableService.getFileUrls({ids:row.resourceOtherId.split(",")}).then((files:any)=>{ + this.fileList = files.data.map(item=>{ + return { + name:item.originalName, + url:item.url, + type:item.type, + id:item.id + } + }) + this.getTableCallback() + }) + } + + this.center = [row.locationLng,row.locationLat]; + + this.showUpdate = true + } + } + public openRecordModel(row){ this.showRecord = true; this.recordParams.taskId = row.id; + this.recordParams.planId = row.planId this.getTabsData() this.getTroubleList(); } @@ -197,7 +582,7 @@ export default class RulesManagerComponent extends BaseRecordComponent { public getTroubleList(){ this.tableService.getTroubleList(this.recordParams).then(res=>{ - console.log(res) + this.troubleTableData = res.data }) } @@ -205,6 +590,26 @@ export default class RulesManagerComponent extends BaseRecordComponent { this.currentTable = this.tableTabs.find(item=>item.id===data) } + public toggleAll() { + (this.$refs.multipleTable as any).toggleAllSelection(); + } + public selectAll(){ + if(!this.selectData.length){ + this.toggleAll() + }else{ + this.tableData.datas.forEach((item,index)=>{ + const find = this.selectData.find((data:any)=>data.userId === item.userId); + if(!find){ + (this.$refs.multipleTable as any).toggleRowSelection(item); + } + }) + } + } + + public handleSelectionChange(data){ + this.selectData = data; + } + }