点巡检管理添加点检项

This commit is contained in:
zhanghan11 2024-07-23 15:27:10 +08:00
parent 7b8935e332
commit b3835a6892
10 changed files with 1205 additions and 41 deletions

View File

@ -1,7 +1,6 @@
package com.inspur.patrol.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.inspur.common.annotation.Excel;

View File

@ -1,7 +1,6 @@
package com.inspur.patrol.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.inspur.common.annotation.Excel;

View File

@ -5,8 +5,8 @@
"author": "",
"license": "MIT",
"scripts": {
"dev": "vue-cli-service serve",
"build:prod": "vue-cli-service build",
"dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src"

View File

@ -51,4 +51,8 @@ div.el-table tr {
color: white;
background-color: #0b2d57;
}
.el-descriptions__body {
color: white;
background-color: transparent;
}
</style>

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询巡检项目列表
export function listItem(query) {
return request({
url: '/patrol/item/list',
method: 'get',
params: query
})
}
// 查询巡检项目详细
export function getItem(id) {
return request({
url: '/patrol/item/' + id,
method: 'get'
})
}
// 新增巡检项目
export function addItem(data) {
return request({
url: '/patrol/item',
method: 'post',
data: data
})
}
// 修改巡检项目
export function updateItem(data) {
return request({
url: '/patrol/item',
method: 'put',
data: data
})
}
// 删除巡检项目
export function delItem(id) {
return request({
url: '/patrol/item/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询巡检任务项目列表
export function listTaskItem(query) {
return request({
url: '/patrol/taskItem/list',
method: 'get',
params: query
})
}
// 查询巡检任务项目详细
export function getTaskItem(id) {
return request({
url: '/patrol/taskItem/' + id,
method: 'get'
})
}
// 新增巡检任务项目
export function addTaskItem(data) {
return request({
url: '/patrol/taskItem',
method: 'post',
data: data
})
}
// 修改巡检任务项目
export function updateTaskItem(data) {
return request({
url: '/patrol/taskItem',
method: 'put',
data: data
})
}
// 删除巡检任务项目
export function delTaskItem(id) {
return request({
url: '/patrol/taskItem/' + id,
method: 'delete'
})
}

View File

@ -416,9 +416,108 @@
<el-dialog
:title="titleReport"
:visible.sync="openReport"
width="800px"
width="900px"
append-to-body
>
<el-divider>点检项目</el-divider>
<el-table
:data="itemList"
max-height="300px"
>
<el-table-column
label="巡检项名称"
align="center"
prop="name"
fixed="left"
show-overflow-tooltip
width="100"
/>
<el-table-column
label="巡检项编码"
align="center"
prop="code"
fixed="left"
show-overflow-tooltip
width="100"
/>
<el-table-column
label="巡检项类型"
align="center"
prop="type"
fixed="left"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.patrol_item_type"
:value="scope.row.type"
/>
</template>
</el-table-column>
<el-table-column
label="实际值"
align="center"
fixed="left"
prop="actualValue"
show-overflow-tooltip
width="100"
>
<template slot-scope="scope">
<dict-tag
v-if="scope.row.type == 1"
:options="dict.type.is_or_not"
:value="scope.row.actualValue"
/>
<span v-else>{{ scope.row.actualValue }}</span>
</template>
</el-table-column>
<el-table-column
label="是否异常"
align="center"
fixed="left"
prop="isAbnormal"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.patrol_result"
:value="scope.row.isAbnormal"
/>
</template>
</el-table-column>
<el-table-column
label="上限值"
align="center"
prop="maxValue"
show-overflow-tooltip
/>
<el-table-column
label="下限值"
align="center"
prop="minValue"
show-overflow-tooltip
/>
<el-table-column
label="参考值"
align="center"
prop="referenceValue"
show-overflow-tooltip
/>
<el-table-column
label="正常选项"
align="center"
prop="normalOption"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.is_or_not"
:value="scope.row.normalOption"
/>
</template>
</el-table-column>
</el-table>
<el-divider>巡检报告</el-divider>
<el-form
ref="reportForm"
:model="reportForm"
@ -488,13 +587,22 @@ import { historyListTask, getTask, getTaskReport } from "@/api/patrol/task";
import { getInfoByParentId } from "@/api/equip/equip";
import ImagePreview from "../task/imagePreview";
import { deptTreeSelect } from "@/api/system/user";
import { listTaskItem } from "@/api/patrol/taskItem";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "Task",
dicts: ["patrol_task_status", "patrol_type"],
dicts: [
"patrol_task_status",
"patrol_type",
"is_or_not",
"patrol_result",
"patrol_item_type",
],
components: { ImagePreview },
data() {
return {
//
itemList: [],
defaultProps: {
children: "children",
label: "label",
@ -610,6 +718,11 @@ export default {
this.getDeptTree();
},
methods: {
getItemList(taskId) {
listTaskItem({ taskId: taskId }).then((response) => {
this.itemList = response.data;
});
},
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then((response) => {
@ -735,17 +848,10 @@ export default {
};
this.resetForm("form");
},
//
handleReprot(row) {
this.resetReport();
this.reportForm.taskId = row.id;
this.openReport = true;
this.titleReport = "提交巡检报告";
this.key++;
},
//
handleReprotView(row) {
this.resetReport();
this.getItemList(row.id);
getTaskReport(row.id).then((response) => {
this.reportForm = response.data;
this.openReport = true;

View File

@ -0,0 +1,678 @@
<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="80px"
>
<el-form-item
label="巡检项名称"
prop="name"
>
<el-input
v-model="queryParams.name"
placeholder="请输入巡检项名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item
label="巡检项编码"
prop="code"
>
<el-input
v-model="queryParams.code"
placeholder="请输入巡检项编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item
label="巡检项类型"
prop="type"
>
<el-select
v-model="queryParams.type"
placeholder="请选择巡检项类型"
clearable
>
<el-option
v-for="dict in dict.type.patrol_item_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button>
<el-button
icon="el-icon-refresh"
size="mini"
@click="resetQuery"
>重置</el-button>
</el-form-item>
</el-form>
<el-row
:gutter="10"
class="mb8"
>
<!-- <el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['patrol:item:add']"
>新增</el-button>
</el-col> -->
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['patrol:item:export']"
>导出</el-button>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-loading="loading"
:data="itemList"
row-key="id"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column
label="巡检项名称"
prop="name"
show-overflow-tooltip
/>
<el-table-column
label="巡检项编码"
align="center"
prop="code"
show-overflow-tooltip
width="120"
/>
<el-table-column
label="巡检项类型"
align="center"
prop="type"
show-overflow-tooltip
width="120"
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.patrol_item_type"
:value="scope.row.type"
/>
</template>
</el-table-column>
<el-table-column
label="上限值"
align="center"
prop="maxValue"
show-overflow-tooltip
width="80"
/>
<el-table-column
label="下限值"
align="center"
prop="minValue"
show-overflow-tooltip
width="80"
/>
<el-table-column
label="参考值"
align="center"
prop="referenceValue"
show-overflow-tooltip
width="100"
/>
<el-table-column
label="正常选项"
align="center"
prop="normalOption"
show-overflow-tooltip
width="100"
>
<template slot-scope="scope">
<span v-if="scope.row.type != 1">{{ scope.row.normalOption }}</span>
<dict-tag
v-if="scope.row.type == 1"
:options="dict.type.is_or_not"
:value="parseInt(scope.row.normalOption)"
/>
</template>
</el-table-column>
<el-table-column
label="备注"
align="center"
prop="remark"
show-overflow-tooltip
/>
<!-- <el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
v-if="scope.row.isParent == 1"
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['patrol:item:edit']"
>新增</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['patrol:item:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['patrol:item:remove']"
>删除</el-button>
</template>
</el-table-column> -->
</el-table>
<!-- 添加或修改巡检项目对话框 -->
<el-dialog
:title="title"
:visible.sync="open"
width="500px"
append-to-body
>
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="80px"
>
<el-row>
<el-col :span="12">
<el-form-item
label="巡检项名称"
prop="name"
>
<el-input
v-model="form.name"
placeholder="请输入巡检项名称"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="巡检项编码"
prop="code"
>
<el-input
v-model="form.code"
placeholder="请输入巡检项编码"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="是否父项目"
prop="isParent"
>
<el-select
v-model="form.isParent"
placeholder="请选择是否父项目"
>
<el-option
v-for="dict in dict.type.is_or_not"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col
:span="12"
v-if="form.isParent == 0"
>
<el-form-item
label="父项目"
prop="parentId"
>
<treeselect
v-model="form.parentId"
:options="parentList"
:normalizer="normalizer"
placeholder="选择父项目"
/>
</el-form-item>
</el-col>
<el-col
:span="12"
v-if="form.isParent == 0"
>
<el-form-item
label="巡检项类型"
prop="type"
>
<el-select
@change="changeType(form.type)"
v-model="form.type"
placeholder="请选择巡检项类型"
>
<el-option
v-for="dict in dict.type.patrol_item_type"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col
:span="12"
v-if="form.isParent == 0 && form.type"
>
<el-form-item
label="参考值"
prop="referenceValue"
>
<span v-if="form.type == 1">{{form.referenceValue}}</span>
<el-input-number
v-if="form.type == 2"
v-model="form.referenceValue"
placeholder="请输入参考值"
:max=10000
:min=-10000
:step=0.01
/>
<el-input
v-if="form.type == 3"
v-model="form.referenceValue"
placeholder="请输入参考值"
/>
</el-form-item>
</el-col>
<el-col
:span="12"
v-if="form.isParent == 0 && form.type == 1"
>
<el-form-item
label="正常选项"
prop="normalOption"
>
<el-select
v-model="form.normalOption"
placeholder="请选择正常选项"
>
<el-option
v-for="dict in dict.type.is_or_not"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col
:span="12"
v-if="form.isParent == 0 && form.type == 2"
>
<el-form-item
label="上限值"
prop="maxValue"
>
<el-input-number
v-model="form.maxValue"
placeholder="请输入上限值"
:max=10000
:min=-10000
:step=0.01
/>
</el-form-item>
</el-col>
<el-col
:span="12"
v-if="form.isParent == 0 && form.type == 2"
>
<el-form-item
label="下限值"
prop="minValue"
>
<el-input-number
v-model="form.minValue"
placeholder="请输入下限值"
:max=10000
:min=-10000
:step=0.01
/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item
label="备注"
prop="remark"
>
<el-input
type="textarea"
v-model="form.remark"
placeholder="请输入备注"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<el-button
type="primary"
@click="submitForm"
> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listItem,
getItem,
delItem,
addItem,
updateItem,
} from "@/api/patrol/item";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "Item",
dicts: ["patrol_item_type", "is_or_not"],
components: { Treeselect },
data() {
return {
//
isExpandAll: false,
//
loading: true,
//
single: true,
//
multiple: true,
//
showSearch: true,
//
itemList: [],
//
parentList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
parentId: null,
name: null,
code: null,
type: null,
maxValue: null,
minValue: null,
referenceValue: null,
normalOption: null,
isParent: null,
},
//
form: {},
//
rules: {
name: [
{ required: true, message: "巡检项名称不能为空", trigger: "blur" },
{
max: 25,
message: "巡检项名称长度不能超过25个字符",
trigger: ["change", "blur"],
},
],
code: [
{ required: true, message: "巡检项编码不能为空", trigger: "blur" },
{
max: 25,
message: "巡检项编码长度不能超过25个字符",
trigger: ["change", "blur"],
},
],
type: [
{ required: true, message: "请选择巡检项类型", trigger: "blur" },
],
isParent: [
{ required: true, message: "请选择是否父项目", trigger: "blur" },
],
normalOption: [
{ required: true, message: "正常选项不能为空", trigger: "blur" },
{
max: 50,
message: "正常选项长度不能超过50个字符",
trigger: ["change", "blur"],
},
],
referenceValue: [
{ required: true, message: "参考值不能为空", trigger: "blur" },
{
validator: function (rule, value, callback) {
if (value.length > 50) {
return callback(new Error("正常选项长度不能超过50个字符"));
}
return callback();
},
trigger: "blur",
},
],
maxValue: [
{ required: true, message: "上限值不能为空", trigger: "blur" },
],
minValue: [
{ required: true, message: "下限值不能为空", trigger: "blur" },
],
remark: [
{
max: 100,
message: "备注长度不能超过100个字符",
trigger: ["change", "blur"],
},
],
},
};
},
created() {
this.getList();
},
methods: {
/** 巡检项类型改变 */
changeType(type) {
switch (type) {
case 1:
this.form.normalOption = null;
this.form.maxValue = null;
this.form.minValue = null;
this.form.referenceValue = "是/否";
break;
case 2:
this.form.normalOption = null;
this.form.maxValue = null;
this.form.minValue = null;
this.form.referenceValue = null;
break;
case 3:
this.form.normalOption = null;
this.form.maxValue = null;
this.form.minValue = null;
this.form.referenceValue = null;
break;
default:
break;
}
},
/** 查询巡检父项目列表 */
getParentList() {
listItem({ isParent: 1 }).then((response) => {
this.parentList = this.handleTree(response.data, "id");
});
},
/** 查询巡检项目列表 */
getList() {
this.loading = true;
listItem(this.queryParams).then((response) => {
this.itemList = this.handleTree(response.data, "id");
this.loading = false;
});
},
/** 转换数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.name,
children: node.children,
};
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
parentId: null,
name: null,
code: null,
type: null,
maxValue: null,
minValue: null,
referenceValue: null,
normalOption: null,
remark: null,
isParent: null,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd(row) {
this.getParentList();
this.reset();
this.open = true;
if (row.id) {
this.form.parentId = row.id;
this.form.isParent = 0;
}
this.title = "添加巡检项目";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.getParentList();
this.reset();
getItem(row.id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改巡检项目";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateItem(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addItem(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
if (row.children) {
this.$modal.msgError("该项目下存在子项目,请先删除子项目");
return;
}
const name = row.name;
const id = row.id;
this.$modal
.confirm('是否确认删除名称为"' + name + '"的巡检项目?')
.then(function () {
return delItem(id);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download(
"patrol/item/export",
{
...this.queryParams,
},
`item_${new Date().getTime()}.xlsx`
);
},
},
};
</script>
<style scoped>
.el-input-number,
.el-date-editor,
.el-select {
width: 100%;
}
</style>

View File

@ -428,7 +428,7 @@
<editor
v-if="operateType=='add' || operateType=='update'"
v-model="form.patrolContent"
:min-height="192"
:min-height="80"
/>
<div
v-if="operateType=='view'"
@ -454,6 +454,26 @@
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="巡检项目"
prop="itemId"
>
<el-select
v-if="operateType=='add' || operateType=='update'"
v-model="form.itemId"
placeholder="请选择巡检项目"
>
<el-option
v-for="item in itemList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
<span v-if="operateType=='view'">{{ getItemName(form.itemId) }}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="巡检类型"
@ -478,24 +498,6 @@
/>
</el-form-item>
</el-col>
<el-col
:span="12"
v-if="form.type==0"
>
<el-form-item
label="任务时限(天)"
prop="timeLimit"
>
<el-input-number
v-if="operateType=='add' || operateType=='update'"
:min="1"
:step="1"
v-model="form.timeLimit"
placeholder="请输入执行周期"
/>
</el-form-item>
<span v-if="operateType=='view'">{{ form.timeLimit }}</span>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
@ -533,6 +535,7 @@
</el-form-item>
</el-col>
</el-row>
<el-row v-if="form.type==0">
<el-col :span="12">
<el-form-item
@ -574,6 +577,23 @@
</el-form-item></el-col>
</el-row>
<el-row v-if="form.type==0">
<el-col :span="12">
<el-form-item
label="任务时限(天)"
prop="timeLimit"
>
<el-input-number
v-if="operateType=='add' || operateType=='update'"
:min="1"
:step="1"
v-model="form.timeLimit"
placeholder="请输入执行周期"
/>
</el-form-item>
<span v-if="operateType=='view'">{{ form.timeLimit }}</span>
</el-col>
</el-row>
<el-row v-if="operateType=='view' || operateType=='update'">
<el-col :span="12">
<el-form-item
@ -771,6 +791,7 @@ import {
} from "@/api/patrol/plan";
import { getInfo as getEquInfo, getInfoByParentId } from "@/api/equip/equip";
import _ from "lodash";
import { listItem } from "@/api/patrol/item";
import { listUser } from "@/api/system/user";
import { deptTreeSelect } from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
@ -816,6 +837,8 @@ export default {
}
};
return {
//
itemList: [],
defaultProps: {
children: "children",
label: "label",
@ -898,6 +921,13 @@ export default {
message: "请选择所属部门",
},
],
itemId: [
{
required: true,
trigger: ["change", "blur"],
message: "请选择点检项目",
},
],
equipId: [
{
required: true,
@ -1047,6 +1077,21 @@ export default {
this.getDeptTree();
},
methods: {
/** 查询巡检父项目列表 */
getItemList() {
listItem({ isParent: 1 }).then((response) => {
this.itemList = response.data;
});
},
/** 根据巡检ID获得巡检名称 */
getItemName(id) {
const item = this.itemList.find((item) => item.id === id);
if (item) {
return item.name;
} else {
return "";
}
},
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then((response) => {
@ -1123,6 +1168,7 @@ export default {
handleAdd() {
this.operateType = "add";
this.reset();
this.getItemList();
this.open = true;
this.title = "添加巡检计划";
},
@ -1130,6 +1176,7 @@ export default {
handleUpdate(row) {
this.operateType = "update";
this.reset();
this.getItemList();
const id = row.id || this.ids;
getPlan(id).then((response) => {
this.form = response.data;
@ -1148,6 +1195,7 @@ export default {
handleView(row) {
this.operateType = "view";
this.reset();
this.getItemList();
const id = row.id || this.ids;
getPlan(id).then((response) => {
this.form = response.data;
@ -1283,6 +1331,7 @@ export default {
.el-input-number,
.el-date-editor,
.el-cascader,
.el-cascader,
.el-select {
width: 100%;
}

View File

@ -405,9 +405,185 @@
<el-dialog
:title="titleReport"
:visible.sync="openReport"
width="800px"
width="900px"
append-to-body
>
<el-divider>点检项目</el-divider>
<el-form
ref="itemForm"
:model="itemForm"
label-width="100px"
v-if="!isView"
>
<el-row>
<el-col
:span="12"
v-for="(item, index) in itemForm.itemList"
:key="index"
>
<el-form-item
:prop="'itemList.' + index + '.actualValue'"
:rules="[{
required: true, message: '请反馈'+item.name, trigger: ['blur','change']
}]"
>
<template slot="label">
<span :class="{'color-red':item.isAbnormal}">{{item.name}}
<el-tooltip
class="item"
effect="dark"
>
<div slot="content">
{{item.remark}}<br>
参考值{{ item.referenceValue }}<br>
<span v-if="item.type==1">正常选项
<dict-tag
style="display: inline"
:options="dict.type.is_or_not"
:value="item.normalOption"
/>
</span>
<span v-if="item.type==2">上限值{{ item.maxValue }}下限值{{ item.minValue }}</span>
</div>
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<span
v-if="item.isAbnormal == 1"
style="float:right;margin-right: 50px;"
class="color-red"
>点检异常
</span>
</template>
<el-radio-group
v-if="item.type == 1"
v-model="item.actualValue"
@change="itemChange(item)"
>
<el-radio
v-for="dict in dict.type.is_or_not"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
<el-input-number
@change="itemChange(item)"
v-if="item.type == 2"
v-model="item.actualValue"
:max=10000
:min=-10000
:step=0.01
></el-input-number>
<el-input
@change="itemChange(item)"
v-if="item.type == 3"
v-model="item.actualValue"
:maxlength=50
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-table
:data="itemForm.itemList"
max-height="300px"
v-else
>
<el-table-column
label="巡检项名称"
align="center"
prop="name"
fixed="left"
show-overflow-tooltip
width="100"
/>
<el-table-column
label="巡检项编码"
align="center"
prop="code"
fixed="left"
show-overflow-tooltip
width="100"
/>
<el-table-column
label="巡检项类型"
align="center"
prop="type"
fixed="left"
show-overflow-tooltip
width="100"
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.patrol_item_type"
:value="scope.row.type"
/>
</template>
</el-table-column>
<el-table-column
label="实际值"
align="center"
fixed="left"
prop="actualValue"
show-overflow-tooltip
width="100"
>
<template slot-scope="scope">
<dict-tag
v-if="scope.row.type == 1"
:options="dict.type.is_or_not"
:value="scope.row.actualValue"
/>
<span v-else>{{ scope.row.actualValue }}</span>
</template>
</el-table-column>
<el-table-column
label="是否异常"
align="center"
fixed="left"
prop="isAbnormal"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.patrol_result"
:value="scope.row.isAbnormal"
/>
</template>
</el-table-column>
<el-table-column
label="上限值"
align="center"
prop="maxValue"
show-overflow-tooltip
/>
<el-table-column
label="下限值"
align="center"
prop="minValue"
show-overflow-tooltip
/>
<el-table-column
label="参考值"
align="center"
prop="referenceValue"
show-overflow-tooltip
/>
<el-table-column
label="正常选项"
align="center"
prop="normalOption"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.is_or_not"
:value="scope.row.normalOption"
/>
</template>
</el-table-column>
</el-table>
<el-divider>巡检报告</el-divider>
<el-form
ref="reportForm"
:model="reportForm"
@ -417,6 +593,7 @@
<el-form-item
label="巡检结果"
prop="reportResult"
v-if="isView"
>
<el-input
v-if="!isView"
@ -533,6 +710,7 @@ import {
getTaskReport,
} from "@/api/patrol/task";
import { getInfoByParentId } from "@/api/equip/equip";
import { listTaskItem } from "@/api/patrol/taskItem";
import FileUploadVue from "./fileUpload.vue";
import ImageUploadVue from "./imageUpload.vue";
import ImagePreview from "./imagePreview.vue";
@ -541,10 +719,18 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "Task",
dicts: ["patrol_task_status", "patrol_type"],
dicts: [
"patrol_task_status",
"patrol_type",
"is_or_not",
"patrol_result",
"patrol_item_type",
],
components: { FileUploadVue, ImageUploadVue, ImagePreview },
data() {
return {
itemForm: { itemList: [] },
itemRules: [],
defaultProps: {
children: "children",
label: "label",
@ -674,6 +860,40 @@ export default {
this.getDeptTree();
},
methods: {
itemChange(item) {
switch (item.type) {
case 1:
if (item.actualValue) {
if (item.actualValue == item.normalOption) {
item.isAbnormal = 0;
} else {
item.isAbnormal = 1;
}
}
break;
case 2:
if (item.actualValue || item.actualValue == 0) {
if (
item.actualValue >= item.minValue &&
item.actualValue <= item.maxValue
) {
item.isAbnormal = 0;
} else {
item.isAbnormal = 1;
}
}
break;
case 3:
break;
default:
break;
}
},
getItemList(taskId) {
listTaskItem({ taskId: taskId }).then((response) => {
this.itemForm.itemList = response.data;
});
},
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then((response) => {
@ -778,6 +998,7 @@ export default {
//
handleReprot(row) {
this.resetReport();
this.getItemList(row.id);
this.reportForm.taskId = row.id;
this.openReport = true;
this.titleReport = "提交巡检报告";
@ -787,6 +1008,7 @@ export default {
//
handleReprotView(row) {
this.resetReport();
this.getItemList(row.id);
this.isView = true;
getTaskReport(row.id).then((response) => {
this.reportForm = response.data;
@ -812,12 +1034,28 @@ export default {
},
//
submitFormReport() {
this.$refs["reportForm"].validate((valid) => {
if (valid) {
addTaskReport(this.reportForm).then((response) => {
this.$modal.msgSuccess("提交成功");
this.openReport = false;
this.getList();
this.$refs["itemForm"].validate((validItems) => {
if (validItems) {
this.itemForm.itemList.forEach((item) => {
this.itemChange(item);
});
this.$refs["reportForm"].validate((valid) => {
if (valid) {
this.reportForm.itemList = this.itemForm.itemList;
const count = this.reportForm.itemList.filter(
(item) => item.isAbnormal == 1
).length;
if (count > 0) {
this.reportForm.reportResult = "存在异常,异常项个数:" + count;
} else {
this.reportForm.reportResult = "巡检正常,无异常";
}
addTaskReport(this.reportForm).then((response) => {
this.$modal.msgSuccess("提交成功");
this.openReport = false;
this.getList();
});
}
});
}
});
@ -842,4 +1080,7 @@ export default {
.el-table .font-color-red {
color: red !important;
}
.color-red {
color: red;
}
</style>