From 0608cdd7c003db20d840cb5b82153d5ccc373cb4 Mon Sep 17 00:00:00 2001 From: kongyeqing <2697454777@qq.com> Date: Tue, 20 Jun 2023 16:13:48 +0800 Subject: [PATCH] =?UTF-8?q?fetch:=E8=AE=BE=E5=A4=87=E8=AE=BE=E6=96=BD?= =?UTF-8?q?=E6=B8=85=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/device.service.ts | 23 +- src/store/index.ts | 13 +- src/views/blank.component.vue | 11 +- .../assessment/device/device.component.html | 79 ++- .../assessment/device/device.component.vue | 476 +++++++++++++----- .../device/deviceAnal.component.vue | 245 +++++---- 6 files changed, 580 insertions(+), 267 deletions(-) diff --git a/src/service/device.service.ts b/src/service/device.service.ts index d340dc8..adc7811 100644 --- a/src/service/device.service.ts +++ b/src/service/device.service.ts @@ -6,11 +6,28 @@ export default class DeviceService extends BaseService{ super() } public selectByPage(params: any):Promise>>{ - const url = this.prefix.system+'/user/list'; - return this.get(url,params,true) + const url = this.prefix.prevention+'/device/inventory/getList'; + return this.post(url,params) } + + public selectById(id):Promise>>{ + const url = this.prefix.prevention+'/device/inventory/detail?id='+id; + return this.get(url,null,true) + } + // 新增或更新 + public addOrUpdate(params: any, add: boolean,showLoading?:boolean): Promise>>{ + + if(add){ + const url = this.prefix.prevention+'/device/inventory/add'; + return this.post(url,params,{},showLoading) + }else{ + const url = this.prefix.prevention+'/device/inventory/update'; + return this.put(url,params,{},showLoading) + } + } + public deleteByIds(params):Promise>>{ - const url = this.prefix.system+'/user/list'; + const url = this.prefix.prevention +'/device/inventory/delete'; return this.deleteBatch(url,params,{},true) } } \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index d60e406..cc9ff77 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -14,6 +14,7 @@ export default new Vuex.Store({ prevention_risk_level:[], prevention_safe_reason:[], prevention_dangrous_type:[], + prevention_device_type:[] }, getters: { dept_map:(state)=>{ @@ -71,7 +72,14 @@ export default new Vuex.Store({ map[item.value] = item.name }) return map - } + }, + prevention_device_type_map:(state)=>{ + const map = {}; + state.prevention_device_type.forEach((item:any)=>{ + map[item.value] = item.name + }) + return map + }, }, mutations: { @@ -102,6 +110,9 @@ export default new Vuex.Store({ }, set_prevention_dangrous_type(state,data){ state.prevention_dangrous_type = data; + }, + set_prevention_device_type(state,data){ + state.prevention_device_type = data; } }, actions: { diff --git a/src/views/blank.component.vue b/src/views/blank.component.vue index 25cb86c..9a4fe75 100644 --- a/src/views/blank.component.vue +++ b/src/views/blank.component.vue @@ -22,7 +22,8 @@ export default class BlankComponent extends Vue { this.systemService.getDictData("prevention_dangrous_level"), this.systemService.getDictData("prevention_risk_level"), this.systemService.getDictData("prevention_safe_reason"), - this.systemService.getDictData("prevention_dangrous_type") + this.systemService.getDictData("prevention_dangrous_type"), + this.systemService.getDictData("prevention_device_type"), ]).then(((results: any) => { this.$store.commit("setDeptTreeList", results[0].data); this.$store.commit("setUserList", results[2].data.datas.map((item) => { @@ -71,8 +72,12 @@ export default class BlankComponent extends Vue { value: isNaN(+item.dictValue) ? item.dictValue : +item.dictValue } })) - - + this.$store.commit("set_prevention_device_type", results[9].data.map(item => { + return { + name: item.dictLabel, + value: isNaN(+item.dictValue) ? item.dictValue : +item.dictValue + } + })) this.$store.commit("setDeptList", results[1].data.map((item) => { return { diff --git a/src/views/risk/assessment/device/device.component.html b/src/views/risk/assessment/device/device.component.html index 332ccd5..858b473 100644 --- a/src/views/risk/assessment/device/device.component.html +++ b/src/views/risk/assessment/device/device.component.html @@ -1,7 +1,6 @@
-
- - +
+
- - + + +
检查项目
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/src/views/risk/assessment/device/device.component.vue b/src/views/risk/assessment/device/device.component.vue index 8fe673a..88c5acf 100644 --- a/src/views/risk/assessment/device/device.component.vue +++ b/src/views/risk/assessment/device/device.component.vue @@ -1,6 +1,6 @@ diff --git a/src/views/risk/assessment/device/deviceAnal.component.vue b/src/views/risk/assessment/device/deviceAnal.component.vue index 531c31a..697f322 100644 --- a/src/views/risk/assessment/device/deviceAnal.component.vue +++ b/src/views/risk/assessment/device/deviceAnal.component.vue @@ -11,7 +11,7 @@ import DrawComponent from '@/components/draw.component.vue'; import DeviceService from '@/service/device.service'; @Component({ template, - components:{ + components: { FormComponent, TableComponent, DrawComponent, @@ -20,170 +20,153 @@ import DeviceService from '@/service/device.service'; export default class DeviceAnalManagerComponent extends BaseRecordComponent { public tableService = new DeviceService(); - public params = {} as any; + public params = { + areaName: "", + unitName: "", + } as any; - public treeData = [{ - label: '一级 1', - children: [{ - 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 treeData = [] as any; public formActions = [{ - name:"查询", - value:"search", - icon:"el-icon-search", - type:"primary" - },{ - name:"清空", - icon:"el-icon-tickets", - value:"reset" + name: "查询", + value: "search", + icon: "el-icon-search", + type: "primary" + }, { + name: "清空", + icon: "el-icon-tickets", + value: "reset" }]; public tableActions = [{ - name:"添加", - value:"add", - icon:"el-icon-plus", - type:"primary" - },{ - name:"批量删除", - value:"delete", - plain:true, - icon:"el-icon-delete", - type:"danger" + name: "添加", + value: "add", + icon: "el-icon-plus", + type: "primary" + }, { + name: "批量删除", + value: "delete", + plain: true, + icon: "el-icon-delete", + type: "danger" }]; public footerActions = [{ - name:"选择全部", - value:"selectAll", - type:"primary" - },{ - name:"反向选择", - value:"reverse" + name: "选择全部", + value: "selectAll", + type: "primary" + }, { + name: "反向选择", + value: "reverse" }]; - public formOptions:FormOption[] = [{ - name:"区域名称", - key:"areaId", - type:"text", - },{ - name:"单元名称", - key:"unitId", - type:"text", - },{ - name:"作业活动", - key:"unitId", - type:"select", - datas:[{ - name:"单元1", - value:0 - },{ - name:"单元2", - value:1 + public formOptions: FormOption[] = [{ + name: "区域名称", + key: "areaId", + type: "text", + }, { + name: "单元名称", + key: "unitId", + type: "text", + }, { + name: "作业活动", + key: "unitId", + type: "select", + datas: [{ + name: "单元1", + value: 0 + }, { + name: "单元2", + value: 1 }] }]; public showUpdate = false; - public updateParams = {} as any; + public updateParams = {} as any; public selectData = []; - created(){ + created() { } // 树点击 - public handleNodeClick(data){ - console.log('data',data) + public handleNodeClick(data) { + console.log('data', data) + this.params.unitName = ""; + this.params.areaName = ""; + if (data.areaId) { + this.params.unitName = data.name + } else { + this.params.areaName = data.name + } + this.getTableData() } - public buildTable(){ - this.tableColumn.push({name:'序号',key:"index"}); - this.tableColumn.push({name:'区域名称',key:"deptName",width:"200px"}); - this.tableColumn.push({name:'风险分析单元',key:"deptName",width:"200px"}); - this.tableColumn.push({name:'设备名称',key:"person"}); - this.tableColumn.push({name:'设备类别',key:"person"}); - this.tableColumn.push({name:'检查项目',key:"status",render:(data)=>{ - if(data.status==0){ - return "未绘制" - }else{ - return "已绘制" + public buildTable() { + this.tableColumn.push({ name: '序号', key: "index" }); + this.tableColumn.push({ name: '区域名称', key: "deptName", width: "200px" }); + this.tableColumn.push({ name: '风险分析单元', key: "deptName", width: "200px" }); + this.tableColumn.push({ name: '设备名称', key: "person" }); + this.tableColumn.push({ name: '设备类别', key: "person" }); + this.tableColumn.push({ + name: '检查项目', key: "status", render: (data) => { + if (data.status == 0) { + return "未绘制" + } else { + return "已绘制" + } } - }}); - this.tableColumn.push({name:'责任人',key:"person"}); - this.tableColumn.push({name:'责任部门',key:"person"}); - this.tableColumn.push({name:'风险等级',key:"status",render:(data)=>{ - if(data.status==0){ - return "未绘制" - }else{ - return "已绘制" + }); + this.tableColumn.push({ name: '责任人', key: "person" }); + this.tableColumn.push({ name: '责任部门', key: "person" }); + this.tableColumn.push({ + name: '风险等级', key: "status", render: (data) => { + if (data.status == 0) { + return "未绘制" + } else { + return "已绘制" + } } - }}); - this.tableColumn.push({name:'残余风险等级',key:"status",render:(data)=>{ - if(data.status==0){ - return "未绘制" - }else{ - return "已绘制" + }); + this.tableColumn.push({ + name: '残余风险等级', key: "status", render: (data) => { + if (data.status == 0) { + return "未绘制" + } else { + return "已绘制" + } } - }}); + }); } - public callback(data){ + public callback(data) { // 查询 - if(data.value==="search"){ + if (data.value === "search") { this.getTableData() - // 重置 - }else if(data.value === "reset"){ + // 重置 + } else if (data.value === "reset") { this.reset() - // 反选 - }else if(data.value === "reverse"){ + // 反选 + } else if (data.value === "reverse") { this.toggleAll() - // 全选 - }else if(data.value === "selectAll"){ + // 全选 + } else if (data.value === "selectAll") { this.selectAll() - }else if(data.value === "delete"){ - this.deleteData(this.selectData.map((item:any)=>item.id)) + } else if (data.value === "delete") { + this.deleteData(this.selectData.map((item: any) => item.id)) } } // 重置数据 - public reset(){ + public reset() { this.params = { - pageNum:1, - pageSize:20, + pageNum: 1, + pageSize: 20, } as any; } - public showUpdateModel(id){ + public showUpdateModel(id) { this.showUpdate = true } - public handleClose(){ + public handleClose() { this.showUpdate = false; } @@ -191,20 +174,20 @@ export default class DeviceAnalManagerComponent extends BaseRecordComponent public toggleAll() { (this.$refs.multipleTable as any).toggleAllSelection(); } - public selectAll(){ - if(!this.selectData.length){ + 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){ + } 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){ + public handleSelectionChange(data) { this.selectData = data; } }