hbt-prevention-ui/src/views/risk/assessment/work/workAnal.component.vue

967 lines
36 KiB
Vue

<script lang="ts">
import { Component, Watch } from 'vue-property-decorator';
import template from "./workAnal.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 FormOption from "hbt-common/models/formOptions"
import BtnOption from "hbt-common/models/btnOptions"
import DrawComponent from '@/components/draw.component.vue';
import UnitTreeComponent from '@/components/tree.component.vue';
import AnalEvaluationComponent from '@/components/analEvaluation.component.vue';
import WorkService from '@/service/work.service';
import UnitService from '@/service/unit.service';
import AreaService from '@/service/area.service';
import SystemService from "hbt-common/service/system.service"
import JobHazardService from '@/service/jobHazard.service';
import ButtonListComponent from "hbt-common/components/common/buttonList.component.vue";
import moment from "moment";
@Component({
template,
components: {
FormComponent,
TableComponent,
DrawComponent,
AnalEvaluationComponent,
UnitTreeComponent,
ButtonListComponent
},
})
export default class WorkAnalManagerComponent extends BaseRecordComponent<any> {
public tableService = new JobHazardService();
public unitService = new UnitService();
public areaService = new AreaService();
public systemService = new SystemService();
// public diviceService = new DiviceService();
public workService = new WorkService();
public params = {
areaName: "",
unitName: "",
} as any;
public treeData = [] as any;
public areaList = [] as any;
public unitList = [];
public jobList = [];
public isReadonly = false;
public isModifyonly = false;
public subTableColumn = [] as any;
public currentId = -1;
public sourceMap = {} as any;
public craftMap = {} as any;
public chemicaltMap = {} as any
public majorsignMap = {} as any;
//检查项目
public showProtable = false;
public proTableColumn = [] as any;
public currentProTableData = {
datas: []
} as any;
public proActions = [{
name: "取消",
value: "cancel"
}];
//数据字典
public dictData = {
source: [],
craft: [],
chemical: [],
mainPerson: [],
craftPerson: [],
operatePerson: [],
measuresSort: [],
riskControlLevel: [],
seriousResult: [],
identifier: [],
majorsign: [],
} as any;
//评估矩阵
public showMatrixModal = false;
//评价
public showSubUpdate = false;
public analyIsReadonly = false;
//危害分析评价
public analysisUpdateParams = {
riskChoose: [],
remainChoose: [],
remainLevel: null,
riskLevel: null,
datas: []
} as any;
//评估方法
public checkRiskType = {
risk: [],
remain: [],
type: null,
} as any;
public formActions = [{
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"
}];
public footerActions = [{
name: "选择全部",
value: "selectAll",
type: "primary"
}, {
name: "反向选择",
value: "reverse"
}];
public formOptions: FormOption<BtnOption>[] = [{
name: "区域名称",
key: "areaName",
type: "text",
}, {
name: "单元名称",
key: "unitName",
type: "text",
},];
public showUpdate = false;
public account = JSON.parse(localStorage.getItem("account") as any);
public updateParams = {
majorSign: [],
steps: [],
evaluateTime: moment().format('YYYY-MM-DD'),
evaluateUserId: this.account.userId,
evaluateUserName: this.account.nickName,
} as any;
public selectData = [];
public subSelectData = []
public updateOptions: FormOption<BtnOption>[] = [];
public subBasicRiskOptions: FormOption<BtnOption>[] = [];
public subTableActions: BtnOption[] = [];
public buildUpdateForm() {
this.updateOptions = [{
name: "区域名称",
key: "areaId",
format: "areaName",
type: "select",
require: true,
width: "calc(50% - 20px)",
showError: false,
datas: this.areaList
}, {
name: "单元名称",
key: "unitId",
format: "unitName",
type: "select",
require: true,
width: "calc(50% - 20px)",
showError: false,
datas: this.unitList
}, {
name: "责任部门",
key: "chargeDeptName",
type: "text",
require: true,
width: "calc(50% - 20px)",
disable: true,
}, {
name: "责任人",
key: "chargeUserName",
type: "text",
require: true,
width: "calc(50% - 20px)",
showError: false,
disable: true,
}, {
name: "作业名称",
key: "jobInventoryId",
format: 'jobInventoryName',
type: "select",
require: true,
width: "calc(50% - 20px)",
showError: false,
datas: this.jobList,
}, {
name: "作业地点",
key: "location",
type: "text",
require: true,
width: "calc(50% - 20px)",
disable: true,
}, {
name: "涉及岗位",
key: "postName",
type: "text",
width: "calc(100% - 20px)",
require: true,
disable: true,
}, {
name: "评价人",
key: "evaluateUserId",
format: "evaluateUserName",
require: true,
width: "calc(50% - 20px)",
type: "select",
showError: false,
datas: this.$store.state.userList
}, {
name: "评价时间",
key: "evaluateTime",
type: "date",
subType: "date",
width: "calc(50% - 20px)",
require: true,
showError: false,
format: "yyyy-MM-dd"
}, {
name: "区域固有风险等级",
key: "analRiskLevel",
format: "analRiskLevelName",
require: true,
width: "calc(50% - 20px)",
type: "select",
showError: false,
disable: true,
datas: this.$store.state.prevention_risk_level
}, {
name: "是否为两大一重",
key: "majorSign",
format: "majorSignName",
type: "checkbox",
width: "calc(100% - 20px)",
require: true,
datas: [{
name: "不涉及",
disable: false,
value: 0
}, {
name: "重大危险源",
disable: this.updateParams.majorSign.includes(0),
value: 1
}, {
name: "重大监管化工工艺",
disable: this.updateParams.majorSign.includes(0),
value: 2
}, {
name: "重点监管危化品",
disable: this.updateParams.majorSign.includes(0),
value: 3
}],
}, {
name: "重大危险源",
key: "majorHazard",
hide: !this.updateParams.majorSign || this.updateParams.majorSign.length === 0 || (!this.updateParams.majorSign.includes(1) || this.updateParams.majorSign.includes(0)),
type: "select",
format: "majorHazardName",
width: "calc(50% - 20px)",
require: true,
multiple: true,
datas: this.dictData.source
}, {
name: "重点监管工艺",
key: "regulatoryProcess",
format: "regulatoryProcessName",
hide: !this.updateParams.majorSign || this.updateParams.majorSign.length === 0 || !this.updateParams.majorSign.includes(2) || this.updateParams.majorSign.includes(0),
type: "select",
width: "calc(50% - 20px)",
require: true,
multiple: true,
datas: this.dictData.craft,
}, {
name: "重点监管化学品",
key: "regulatoryChemical",
format: "regulatoryChemicalName",
hide: !this.updateParams.majorSign || this.updateParams.majorSign.length === 0 || !this.updateParams.majorSign.includes(3) || this.updateParams.majorSign.includes(0),
type: "select",
width: "calc(50% - 20px)",
require: true,
multiple: true,
datas: this.dictData.chemical,
}];
this.subTableActions = [{
name: "批量删除",
value: "subDelete",
plain: true,
icon: "el-icon-delete",
type: "danger"
}, {
name: "评估矩阵",
value: "estimateMatrix",
type: "primary"
}];
this.subBasicRiskOptions = [{
name: "风险等级",
key: "riskLevel",
format: 'riskLevelName',
type: "select",
require: true,
width: "calc(50% - 20px)",
disable: true,
datas: this.$store.state.prevention_risk_level
}, {
name: "残余风险等级",
key: "remainRiskLevel",
format: "remainRiskLevelName",
type: "select",
require: true,
width: "calc(50% - 20px)",
disable: true,
datas: this.$store.state.prevention_risk_level
}]
}
public updateActions = [] as any;
public buildActionsForm() {
this.updateActions = [{
name: "取消",
value: "cancel"
}, {
name: '存草稿',
value: 'addDraft',
type: "primay",
hide: !this.updateParams.status || this.updateParams.status === 1 ? false : true
}, {
name: "保存并继续添加",
value: "saveAndContinue",
type: "primary",
hide: this.updateParams.id ? true : false
}, {
name: "保存",
value: "save",
type: "primary"
}];
}
@Watch("$store.state.deptList", { immediate: true, deep: true })
onChanges() {
this.loadAreaData()
}
@Watch("updateParams", { immediate: true, deep: true })
onCountValueChange() {
this.buildUpdateForm()
}
created() {
Promise.all([
this.systemService.getDictData("prevention_risk_source"),
this.systemService.getDictData("prevention_risk_craft"),
this.systemService.getDictData("prevention_risk_chemical"),
]).then(((results: any) => {
this.dictData.source = results[0].data.map((item) => {
this.sourceMap[item.dictValue] = item.dictLabel;
return {
name: item.dictLabel,
value: isNaN(+item.dictValue) ? item.dictValue : +item.dictValue
}
})
this.dictData.craft = results[1].data.map((item) => {
this.craftMap[item.dictValue] = item.dictLabel;
return {
name: item.dictLabel,
value: isNaN(+item.dictValue) ? item.dictValue : +item.dictValue
}
})
this.dictData.chemical = results[2].data.map((item) => {
this.chemicaltMap[item.dictValue] = item.dictLabel;
return {
name: item.dictLabel,
value: isNaN(+item.dictValue) ? item.dictValue : +item.dictValue
}
})
this.buildUpdateForm()
}));
}
// 加载区域列表
public loadAreaData() {
this.unitList = [];
this.jobList = [];
this.areaService.selectByPage({ pageSize: 1000 }).then((res: any) => {
this.areaList = res.data.datas.map(item => {
return {
name: item.name,
value: item.id,
analRiskLevel: item.analRiskLevel ? item.analRiskLevel : null,
}
});
this.buildUpdateForm()
})
}
// 加载单元列表
public loadUnitData(id?) {
this.unitService.selectByPage({ pageSize: 1000, areaId: id }, false).then((res: any) => {
this.unitList = res.data.datas.map(item => {
return {
name: item.name,
value: item.id,
deptId: item.chargeDeptId,
userId: item.chargeUserId,
deptName: item.chargeDeptName,
userName: item.chargeUserName,
}
});
this.buildUpdateForm()
})
}
// 树点击
public handleNodeClick(data) {
this.params.unitName = "";
this.params.areaName = "";
if (data.areaId) {
this.params.unitName = data.name
} else {
this.params.areaName = data.name === "全部" ? "" : data.name
}
this.getTableData()
}
public buildTable() {
this.tableColumn.push({ name: '区域名称', key: "areaName", width: "150px" });
this.tableColumn.push({ name: '风险分析单元', key: "unitName", width: "150px" });
this.tableColumn.push({ name: '作业活动', key: "jobInventoryName", });
this.tableColumn.push({
name: '作业步骤', key: "stepNum", render: (data) => {
return "<span class='link'>" + (data.stepNum ? data.stepNum : 0) + "</span>"
}
});
this.tableColumn.push({ name: '责任部门', key: "chargeDeptName" });
this.tableColumn.push({ name: '责任人', key: "chargeUserName" });
this.tableColumn.push({
name: '风险等级', key: "riskLevel", width: "150px", render: (data) => {
return "<span class='color_" + data.riskLevel + "'>" + (data.riskLevel ? (this.$store.getters.prevention_risk_level_map[data.riskLevel]) : '') + "</span>"
},
filters: this.$store.state.prevention_risk_level.map(item => {
return {
text: item.name,
value: item.value,
}
}), filterMethod: (data, row) => {
return row.riskLevel === data;
}
});
this.tableColumn.push({
name: '残余风险等级', key: "remainRiskLevel", width: "150px", render: (data) => {
return "<span class='color_" + data.remainRiskLevel + "'>" + (data.remainRiskLevel ? (this.$store.getters.prevention_risk_level_map[data.remainRiskLevel]) : '') + "</span>"
}
});
this.tableColumn.push({
name: '状态', key: "status", render: (data) => {
if (data.status) {
let tmpstatus: any = data.status
if (data.status === 1) {
tmpstatus = 2
} else if (data.status === 2) {
tmpstatus = 1
}
return "<span class='color_" + tmpstatus + "'>" + (data.status ? (this.$store.getters.prevention_evaluate_status_map[data.status]) : '') + "</span>"
}
},
filters: this.$store.state.prevention_evaluate_status.map(item => {
return {
text: item.name,
value: item.value,
}
}), filterMethod: (data, row) => {
return row.status === data;
}
});
//分析评价
this.subTableColumn.push({ name: '序号', key: "index", width: "50px" });
this.subTableColumn.push({
name: '状态', key: "status", width: "80px", render: (data) => {
if (data.status && data.status !== 1) {
let tmpstatus: any = data.status
if (data.status === 2) {
tmpstatus = 1
}
if (data.status) {
return "<span class='color_" + tmpstatus + "'>" + (data.status ? (this.$store.getters.prevention_evaluate_status_map[data.status]) : '') + "</span>"
}
}
}
});
this.subTableColumn.push({ name: '步骤名称', key: "name" });
this.subTableColumn.push({ name: '作业步骤描述', key: "description", showTip: true, width: "200px" });
this.subTableColumn.push({ name: '作业地点', key: "location" }); this.subTableColumn.push({ name: '风险源', key: "riskSource" });
this.subTableColumn.push({ name: '危害分析', key: "hazardAnalysis", width: "200px" });
this.subTableColumn.push({
name: '最严重后果', key: "seriousResult", width: "100px", render: (data) => {
if (data.seriousResult) {
return data.seriousResult.split(";").map(item => this.$store.getters.prevention_serious_result_map[item]).join(";")
}
}
});
this.subTableColumn.push({
name: '风险等级', key: "riskLevel", width: "100px", render: (data) => {
if (data.riskLevel) {
return this.$store.getters.prevention_risk_level_map[data.riskLevel]
}
}
});
this.subTableColumn.push({ name: '评估方法', key: "riskChoose", width: "100px", });
this.subTableColumn.push({
name: '残余风险等级', key: "remainLevel", width: "130px", render: (data) => {
if (data.remainLevel) {
return this.$store.getters.prevention_risk_level_map[data.remainLevel]
}
}
});
this.subTableColumn.push({ name: '评估方法', key: "remainChoose", });
this.subTableColumn.push({
name: '管控措施', key: "measuresNum", render: (data) => {
if (data.measuresNum) {
return data.measuresNum
} else {
if (data.measures && data.measures.length) {
return data.measures.length
}
}
}
});
//作业步骤
this.proTableColumn.push({ name: '序号', key: "index", width: "80px" });
this.proTableColumn.push({ name: '步骤名称', key: "name" });
this.proTableColumn.push({ name: '作业步骤描述', key: "description", showTip: true, width: "200px" });
this.proTableColumn.push({ name: '作业地点', key: "location" });
this.proTableColumn.push({ name: '风险源', key: "riskSource", width: "100px", });
this.proTableColumn.push({
name: '可能发生事故', key: "seriousResult", width: "150px", render: (data) => {
if (data.seriousResult) {
return data.seriousResult.split(";").map(item => this.$store.getters.prevention_serious_result_map[item]).join(";")
}
}
});
this.proTableColumn.push({
name: '风险等级', key: "riskLevel", render: (data) => {
if (data.riskLevel) {
return "<span class='color_" + data.riskLevel + "'>" + (data.riskLevel ? (this.$store.getters.prevention_risk_level_map[data.riskLevel]) : '') + "</span>"
}
}
});
this.proTableColumn.push({
name: '残余风险等级', key: "remainLevel", width: "120px", render: (data) => {
if (data.remainLevel) {
return "<span class='color_" + data.remainLevel + "'>" + (data.remainLevel ? (this.$store.getters.prevention_risk_level_map[data.remainLevel]) : '') + "</span>"
}
}
});
}
public callback(data, type) {
if (type) {
this.params[type] = data;
this.getTableData();
return
}
// 查询
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 === "delete") {
this.deleteData(this.selectData.map((item: any) => item.id))
} else if (data.value === "add") {
this.isReadonly = false;
this.isModifyonly = false;
this.showUpdate = true
this.jobList = []
this.unitList = []
this.updateParams = {
majorSign: [],
items: [],
evaluateTime: moment().format('YYYY-MM-DD'),
evaluateUserId: this.account.userId,
evaluateUserName: this.account.nickName,
} as any
this.buildActionsForm()
} else if (data.value === "cancel") {
this.handleClose()
} else if (data.value === "estimateMatrix") {
this.showMatrixModal = true
} else if (data && data.value.indexOf("save") >= 0) {
this.doSave(data.value !== "save")
this.isReadonly = false;
} else if (data && data.value === 'addDraft') {
this.doSaveDraft()
this.isReadonly = false;
} else if (data && data.value === "subDelete") {
if (this.subSelectData.length > 0) {
this.$confirm('确认删除所选数据', '确认数据', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (!this.updateParams.deleteIds) {
this.updateParams.deleteIds = []
}
this.subSelectData.map((itemData: any) => {
this.updateParams.deleteIds.push(itemData.id)
this.updateParams.steps.splice(this.updateParams.steps.findIndex(item => item.index === itemData.index), 1)
})
this.updateParams.steps.forEach((item, index) => {
item.index = index + 1
return item
})
this.updateParams.stepNum = this.updateParams.steps.length
}).catch(() => {
//
});
}
}
}
// 重置数据
public reset() {
this.params = {
pageNum: 1,
pageSize: 20,
} as any;
}
// 分页数据
public getTableData() {
this.tableService.selectByPage(this.params).then(res => {
this.tableData = res.data as any;
})
}
public changes(data, item) {
// 区域
if (item && item.key === "areaId") {
this.jobList = [];
if (this.updateParams.unitId) {
this.updateParams.unitId = null;
}
const areaData = this.areaList.find((itm: any) => itm.value === data) as any;
this.updateParams.analRiskLevel = areaData.analRiskLevel
// this.updateParams.analRiskLevel = areaData.analRiskLevel
this.updateParams.chargeDeptName = null;
this.updateParams.chargeUserId = null;
this.updateParams.chargeUserName = null;
this.updateParams.chargeDeptId = null;
this.updateParams.type = null;
this.updateParams.postName = null;
this.updateParams.postCode = null;
this.updateParams.jobInventoryName = null;
this.updateParams.jobInventoryId = null;
this.updateParams.name = null;
this.updateParams.steps = [];
this.updateParams.stepNum = 0;
this.loadUnitData(data)
}
//单元
if (item && item.key === 'unitId') {
const unitData = this.unitList.find((itm: any) => itm.value === data) as any;
this.updateParams.chargeDeptName = unitData.deptName;
this.updateParams.chargeUserId = unitData.userId;
this.updateParams.chargeUserName = unitData.userName;
this.updateParams.chargeDeptId = unitData.deptId;
this.updateParams.type = null;
this.updateParams.postName = null;
this.updateParams.postCode = null;
this.updateParams.jobInventoryName = null;
this.updateParams.jobInventoryId = null;
this.updateParams.name = null;
this.updateParams.steps = [];
this.updateParams.stepNum = 0;
this.loadJobData(data)
}
//作业清单
if (item && item.key === 'jobInventoryId') {
const jobData = this.jobList.find((itm: any) => itm.value === data) as any;
this.updateParams.location = jobData.location;
this.updateParams.postCode = jobData.postCode;
this.updateParams.postName = jobData.postName;
this.updateParams.steps = jobData.steps;
this.updateParams.jobInventoryName = jobData.name;
this.updateParams.stepNum = jobData.steps.length;
this.updateParams.steps.forEach((item, i) => {
item.index = i + 1
})
}
//是否为两大一重
if (item && item.key === 'majorSign') {
if (!data) {
data = []
}
if (data.includes(0)) {
data = []
this.updateParams.majorSign = []
data.push(0)
this.updateParams.majorSign.push(0)
}
}
this.buildUpdateForm()
}
//加载作业清单列表
public loadJobData(id?) {
this.tableService.selectWorkByUnit({ unitId: id, id: this.updateParams.id ? this.updateParams.id : null }).then((res: any) => {
this.jobList = res.data.map(item => {
return {
name: item.name,
value: item.id,
location: item.location,
postCode: item.postCode,
postName: item.postName,
steps: item.steps,
stepNum: item.stepNum
}
});
this.buildUpdateForm()
})
}
//作业步骤
public showPros(el, data) {
const isTarget = el.target.classList.contains("link");
if (isTarget) {
this.showProtable = true;
this.currentProTableData.datas = data.steps.map((item, index) => {
item.index = index + 1;
return item
})
}
}
//作业步骤--关闭
public proCallback() {
this.showProtable = false;
}
//评价信息
public showUpdateModel(row, isReadonly, isModifyonly) {
this.updateParams = { majorSign: [], steps: [], } as any;
if (!row) {
this.currentId = -1;
this.showUpdate = true;
} else {
this.currentId = row.id;
this.tableService.selectById(this.currentId).then((res: any) => {
if (isReadonly) {
const areaAnalRiskLevel = this.areaList.filter((item) => item.value === res.data.areaId)[0]['analRiskLevel']
this.updateParams = Object.assign({
majorHazardName: !res.data.majorHazard ? null : res.data.majorHazard.split(";").map(item => this.sourceMap[item]).join(";"),
regulatoryProcessName: !res.data.regulatoryProcess ? null : res.data.regulatoryProcess.split(";").map(item => this.craftMap[item]).join(";"),
regulatoryChemicalName: !res.data.regulatoryChemical ? null : res.data.regulatoryChemical.split(";").map(item => this.chemicaltMap[item]).join(";"),
majorSignName: !res.data.majorSign ? null : res.data.majorSign.split(";").map(item => this.$store.getters.prevention_majorsign_map[item]).join(";"),
riskLevelName: this.$store.getters.prevention_risk_level_map[res.data.riskLevel],
remainRiskLevelName: this.$store.getters.prevention_risk_level_map[res.data.remainRiskLevel],
typeName: this.$store.getters.prevention_device_type_map[res.data.type],
analRiskLevelName: this.$store.getters.prevention_risk_level_map[areaAnalRiskLevel]
}, res.data)
this.updateParams.majorSign = this.stringChangeArray(res.data.majorSign)
this.updateParams.majorHazard = this.stringChangeArray(res.data.majorHazard)
this.updateParams.regulatoryProcess = this.stringChangeArray(res.data.regulatoryProcess)
this.updateParams.regulatoryChemical = this.stringChangeArray(res.data.regulatoryChemical)
this.updateParams.steps = this.updateParams.steps.map((item, index) => {
item.index = index + 1;
return item
})
this.isReadonly = true;
this.isModifyonly = false
} else {
this.isReadonly = false
this.isModifyonly = true
this.updateParams = res.data;
this.updateParams.majorSign = res.data.majorSign ? this.stringChangeArray(res.data.majorSign) : []
this.updateParams.majorHazard = this.stringChangeArray(res.data.majorHazard)
this.updateParams.regulatoryProcess = this.stringChangeArray(res.data.regulatoryProcess)
this.updateParams.regulatoryChemical = this.stringChangeArray(res.data.regulatoryChemical)
const areaAnalRiskLevel = this.areaList.filter((item) => item.value === res.data.areaId)[0]['analRiskLevel']
this.updateParams.analRiskLevel = areaAnalRiskLevel
this.loadUnitData(res.data.areaId)
this.loadJobData(res.data.unitId)
this.updateParams.steps.forEach((item, i) => {
item.index = i + 1
})
}
this.buildUpdateForm();
this.buildActionsForm();
this.showUpdate = true;
})
}
}
public handleClose() {
this.showUpdate = false;
}
//保存 更新
public doSave(goOn?) {
// 如果是新增工作危害分析清单
this.updateParams.majorSign = this.arrayChangeString(this.updateParams.majorSign)
this.updateParams.regulatoryProcess = this.arrayChangeString(this.updateParams.regulatoryProcess)
this.updateParams.regulatoryChemical = this.arrayChangeString(this.updateParams.regulatoryChemical)
this.updateParams.majorHazard = this.arrayChangeString(this.updateParams.majorHazard)
this.updateParams.safetyFactor = this.arrayChangeString(this.updateParams.safetyFactor)
this.tableService.addOrUpdate(this.updateParams, !this.updateParams.id || this.updateParams.status === 1 ? true : false).then((res) => {
this.$message.success(!this.updateParams.id ? "新增成功!" : "编辑成功!");
this.showUpdate = !!goOn;
this.getTableData();
})
}
//存草稿
public doSaveDraft() {
// 如果是新增工作危害分析清单
this.updateParams.majorSign = this.arrayChangeString(this.updateParams.majorSign)
this.updateParams.regulatoryProcess = this.arrayChangeString(this.updateParams.regulatoryProcess)
this.updateParams.regulatoryChemical = this.arrayChangeString(this.updateParams.regulatoryChemical)
this.updateParams.majorHazard = this.arrayChangeString(this.updateParams.majorHazard)
this.updateParams.safetyFactor = this.arrayChangeString(this.updateParams.safetyFactor)
this.tableService.addOrDraft(this.updateParams, !this.updateParams.id).then((res) => {
this.$message.success(!this.updateParams.id ? "新增成功!" : "编辑成功!");
this.showUpdate = false;
this.getTableData();
})
}
public toggleAll() {
this.tableData.datas.forEach((item,index)=>{
(this.$refs.multipleTable as any).toggleRowSelection(item);
})
}
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;
}
public handleSubSelectionChange(data) {
this.subSelectData = data
}
//分析评价
public showSubModel(row, isReadonly) {
this.analysisUpdateParams = {
riskChoose: [],
remainChoose: [],
} as any;
if (row) {
if (isReadonly) {
this.analyIsReadonly = true;
this.analysisUpdateParams = Object.assign({
seriousResultName: row.seriousResult.split(";").map(item => this.$store.getters.prevention_serious_result_map[item]).join(";"),
safetySignName: row.safetySign.split(";").map(item => this.$store.getters.prevention_security_identifier_map[item]).join(";"),
riskLevelName: this.$store.getters.prevention_risk_level_map[row.riskLevel],
remainLevelName: this.$store.getters.prevention_risk_level_map[row.remainLevel],
riskControlLevelName: this.$store.getters.prevention_control_level_map[row.riskControlLevel],
}, row)
this.analysisUpdateParams = { ...this.analysisUpdateParams, ...JSON.parse(JSON.stringify(row)) };
if (!this.analysisUpdateParams.measures) {
this.analysisUpdateParams.measures = []
}
this.analysisUpdateParams.measures.forEach((item, index) => {
item.index = index + 1
return item
})
} else {
this.analyIsReadonly = false
// 暂存数据 用于取消修改
this.analysisUpdateParams = { ...this.analysisUpdateParams, ...JSON.parse(JSON.stringify(row)) };
this.analysisUpdateParams.seriousResult = this.stringChangeArray(row.seriousResult)
this.analysisUpdateParams.safetySign = this.stringChangeArray(row.safetySign)
this.analysisUpdateParams.riskChoose = row.riskChoose ? row.riskChoose.split(";") : []
this.analysisUpdateParams.remainChoose = row.remainChoose ? row.remainChoose.split(";") : []
this.analysisUpdateParams.chargeUserName = this.updateParams.chargeUserName
this.checkRiskType.risk = this.analysisUpdateParams.riskChoose
this.checkRiskType.remain = this.analysisUpdateParams.remainChoose
if (!this.analysisUpdateParams.measures) {
this.analysisUpdateParams.measures = []
}
this.analysisUpdateParams.measures.forEach((item, index) => {
item.index = index + 1
return item
})
}
}
this.showSubUpdate = true
}
//数组转字符串
public arrayChangeString(data) {
if (data && data.length > 0) {
if (data instanceof Array) {
return data.join(";")
} else {
return data
}
} else {
return null
}
}
//字符串转数组
public stringChangeArray(data) {
if (data) {
return data.split(";").map((item) => parseInt(item))
}
}
}
</script>
<style lang="scss" scoped src="../../../common.component.scss"></style>