2024-06-12 设备-检查项维护-导入

yangwl
A0010407 6 months ago
parent bae166014b
commit 52e26a4b28

@ -1,6 +1,13 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="90px"
>
<el-form-item label="检查项编码" prop="itemCode">
<el-input
v-model="queryParams.itemCode"
@ -34,7 +41,11 @@
/>
</el-form-item>
<el-form-item label="维护类型" prop="itemType">
<el-select v-model="queryParams.itemType" placeholder="请选择维护类型" clearable>
<el-select
v-model="queryParams.itemType"
placeholder="请选择维护类型"
clearable
>
<el-option
v-for="dict in dict.type.device_item_type"
:key="dict.value"
@ -119,7 +130,8 @@
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions">
:picker-options="pickerOptions"
>
</el-date-picker>
</el-form-item>
<el-form-item label="更新人" prop="updateBy">
@ -141,12 +153,21 @@
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions">
:picker-options="pickerOptions"
>
</el-date-picker>
</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-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>
@ -197,44 +218,153 @@
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<el-col :span="1.5">
<div>
<el-button
type="warning"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['device:item:import']"
>导入</el-button
>
</div>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="itemList" @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="itemList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column v-if="false" label="主键" align="center" prop="itemId" />
<el-table-column width="60" align="center" label="序号" type="index"></el-table-column>
<el-table-column width="120" label="检查项编码" align="center" prop="itemCode"/>
<el-table-column
width="60"
align="center"
label="序号"
type="index"
></el-table-column>
<el-table-column
width="120"
label="检查项编码"
align="center"
prop="itemCode"
/>
<el-table-column width="200" label="部位" align="left" prop="itemName" />
<el-table-column width="150" label="方法" align="left" prop="itemMethod"/>
<el-table-column
width="150"
label="方法"
align="left"
prop="itemMethod"
/>
<el-table-column width="150" label="工具" align="left" prop="itemTools" />
<el-table-column width="80" label="周期" align="center" prop="itemLoop" />
<el-table-column width="80" label="周期类型" align="center" prop="itemLoopType">
<el-table-column
width="80"
label="周期类型"
align="center"
prop="itemLoopType"
>
<template slot-scope="scope">
<dict-tag :options="dict.type.device_loop_type" :value="scope.row.itemLoopType"/>
<dict-tag
:options="dict.type.device_loop_type"
:value="scope.row.itemLoopType"
/>
</template>
</el-table-column>
<el-table-column width="120" label="维护类型编码" align="center" prop="itemType"/>
<el-table-column width="120" label="维护类型" align="center" prop="itemTypeName"/>
<el-table-column width="200" label="备注" align="center" prop="itemRemark"/>
<el-table-column v-if="false" label="工厂" align="center" prop="factoryCode"/>
<el-table-column v-if="false" label="备用字段1" align="center" prop="attr1"/>
<el-table-column v-if="false" label="备用字段2" align="center" prop="attr2"/>
<el-table-column v-if="false" label="备用字段3" align="center" prop="attr3"/>
<el-table-column v-if="false" label="删除标识" align="center" prop="delFlag"/>
<el-table-column width="180" label="创建时间" align="center" prop="createTime">
<el-table-column
width="120"
label="维护类型编码"
align="center"
prop="itemType"
/>
<el-table-column
width="120"
label="维护类型"
align="center"
prop="itemTypeName"
/>
<el-table-column
width="200"
label="备注"
align="center"
prop="itemRemark"
/>
<el-table-column
v-if="false"
label="工厂"
align="center"
prop="factoryCode"
/>
<el-table-column
v-if="false"
label="备用字段1"
align="center"
prop="attr1"
/>
<el-table-column
v-if="false"
label="备用字段2"
align="center"
prop="attr2"
/>
<el-table-column
v-if="false"
label="备用字段3"
align="center"
prop="attr3"
/>
<el-table-column
v-if="false"
label="删除标识"
align="center"
prop="delFlag"
/>
<el-table-column
width="180"
label="创建时间"
align="center"
prop="createTime"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column width="120" label="创建人" align="center" prop="createBy"/>
<el-table-column width="180" label="更新时间" align="center" prop="updateTime">
<el-table-column
width="120"
label="创建人"
align="center"
prop="createBy"
/>
<el-table-column
width="180"
label="更新时间"
align="center"
prop="updateTime"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.updateTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column width="120" label="更新人" align="center" prop="updateBy"/>
<el-table-column width="180" label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
<el-table-column
width="120"
label="更新人"
align="center"
prop="updateBy"
/>
<el-table-column
width="180"
label="操作"
align="center"
class-name="small-padding fixed-width"
fixed="right"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -265,7 +395,13 @@
/>
<!-- 添加或修改检查项维护对话框 -->
<el-dialog v-loading="itemLoading" :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-dialog
v-loading="itemLoading"
:title="title"
:visible.sync="open"
width="1000px"
append-to-body
>
<el-tabs v-model="activePage" type="border-card">
<el-tab-pane name="check" label="标准配置">
<el-form ref="form" :model="form" :rules="rules" label-width="90px">
@ -274,13 +410,20 @@
<!-- 第一列 -->
<el-col :span="10">
<el-form-item label="检查项">
<el-input v-model="form.itemName" placeholder="请输入检查项"></el-input>
<el-input
v-model="form.itemName"
placeholder="请输入检查项"
></el-input>
</el-form-item>
</el-col>
<!-- 第二列 -->
<el-col :span="8" :offset="1">
<el-form-item label="维护类型">
<el-select v-model="form.itemType" placeholder="请选择维护类型" clearable>
<el-select
v-model="form.itemType"
placeholder="请选择维护类型"
clearable
>
<el-option
v-for="dict in dict.type.device_item_type"
:key="dict.value"
@ -294,19 +437,28 @@
<el-row>
<el-col :span="10">
<el-form-item label="方法">
<el-input v-model="form.itemMethod" placeholder="请输入检查方法"></el-input>
<el-input
v-model="form.itemMethod"
placeholder="请输入检查方法"
></el-input>
</el-form-item>
</el-col>
<el-col :span="8" :offset="1">
<el-form-item label="工具">
<el-input v-model="form.itemTools" placeholder="请输入检查工具"></el-input>
<el-input
v-model="form.itemTools"
placeholder="请输入检查工具"
></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="循环周期" prop="planLoop">
<el-input-number v-model="form.itemLoop" label=""></el-input-number>
<el-input-number
v-model="form.itemLoop"
label=""
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="2">
@ -327,8 +479,12 @@
<el-row>
<el-col :span="7">
<el-form-item label="标准类型">
<el-radio v-model="item.standardType" label="qualitative"></el-radio>
<el-radio v-model="item.standardType" label="quantify"></el-radio>
<el-radio v-model="item.standardType" label="qualitative"
>定性</el-radio
>
<el-radio v-model="item.standardType" label="quantify"
>定量</el-radio
>
</el-form-item>
</el-col>
</el-row>
@ -336,14 +492,29 @@
<el-row v-if="item.standardType === 'qualitative'">
<el-col :span="12">
<el-form-item label="标准名称">
<el-input type="textarea" autosize v-model="item.standardName" placeholder="请输入标准名称"></el-input>
<el-input
type="textarea"
autosize
v-model="item.standardName"
placeholder="请输入标准名称"
></el-input>
</el-form-item>
</el-col>
<!-- 操作 -->
<el-col :span="4" class="my-dynamic-btn">
<el-button size="small" v-if="formStandard.length > 1" @click="removeStandard(index)" type="danger">
<el-button
size="small"
v-if="formStandard.length > 1"
@click="removeStandard(index)"
type="danger"
>删除
</el-button>
<el-button size="small" v-if="index === formStandard.length - 1" @click="addStandard" type="primary">
<el-button
size="small"
v-if="index === formStandard.length - 1"
@click="addStandard"
type="primary"
>
添加
</el-button>
</el-col>
@ -351,29 +522,61 @@
<el-row v-else>
<el-col :span="12">
<el-form-item label="标准名称">
<el-input type="textarea" autosize v-model="item.standardName" placeholder="请输入标准名称"></el-input>
<el-input
type="textarea"
autosize
v-model="item.standardName"
placeholder="请输入标准名称"
></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label-width="50px" label="上限">
<el-input v-model="item.detailUpLimit" step="0.01" type="number" maxlength="9" oninput="value=value.replace(/[^\d.]/g, '')" placeholder="请输入上限"></el-input>
<el-input
v-model="item.detailUpLimit"
step="0.01"
type="number"
maxlength="9"
oninput="value=value.replace(/[^\d.]/g, '')"
placeholder="请输入上限"
></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label-width="50px" label="下限">
<el-input v-model="item.detailDownLimit" step="0.01" type="number" maxlength="9" oninput="value=value.replace(/[^\d.]/g, '')" placeholder="请输入下限"></el-input>
<el-input
v-model="item.detailDownLimit"
step="0.01"
type="number"
maxlength="9"
oninput="value=value.replace(/[^\d.]/g, '')"
placeholder="请输入下限"
></el-input>
</el-form-item>
</el-col>
<el-col :offset="1" :span="6">
<el-form-item label-width="50px" label="单位">
<el-input v-model="item.detailUnit" placeholder="请输入单位"></el-input>
<el-input
v-model="item.detailUnit"
placeholder="请输入单位"
></el-input>
</el-form-item>
</el-col>
<!-- 操作 -->
<el-col :span="6" class="my-dynamic-btn">
<el-button size="small" v-if="formStandard.length > 1" @click="removeStandard(index)" type="danger">
<el-button
size="small"
v-if="formStandard.length > 1"
@click="removeStandard(index)"
type="danger"
>删除
</el-button>
<el-button size="small" v-if="index === formStandard.length - 1" @click="addStandard" type="primary">
<el-button
size="small"
v-if="index === formStandard.length - 1"
@click="addStandard"
type="primary"
>
添加
</el-button>
</el-col>
@ -381,7 +584,10 @@
</div>
<!-- 备注 -->
<el-form-item label="备注">
<el-input v-model="form.itemRemark" placeholder="请输入备注"></el-input>
<el-input
v-model="form.itemRemark"
placeholder="请输入备注"
></el-input>
</el-form-item>
</el-form>
</el-tab-pane>
@ -394,7 +600,8 @@
:filter-method="filterMethod"
filter-placeholder="请输入设备名称"
v-model="selectEquipmentList"
:data="equipmentList">
:data="equipmentList"
>
</el-transfer>
</el-col>
</el-row>
@ -405,6 +612,44 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 用户导入对话框 -->
<el-dialog
:title="upload.title"
:visible.sync="upload.open"
width="400px"
append-to-body
>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link
type="primary"
:underline="false"
style="font-size: 12px; vertical-align: baseline"
@click="importTemplate"
>下载模板
</el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
@ -418,54 +663,80 @@ import {
addItem,
updateItem,
} from "@/api/device/item";
import { Loading } from 'element-ui';
import { Loading } from "element-ui";
import { getToken } from "@/utils/auth";
export default {
name: "Item",
dicts: ['device_item_type','device_loop_type'],
dicts: ["device_item_type", "device_loop_type"],
data() {
return {
activePage: 'check',
//
upload: {
//
open: false,
//
title: "",
//
isUploading: false,
//
updateSupport: 0,
//
headers: {
poolName: localStorage.getItem("USER_POOL_NAME_CURRENT"),
Authorization: "Bearer " + getToken(),
},
//
url: process.env.VUE_APP_BASE_API + "/device/item/importFile",
},
activePage: "check",
//
itemLoading: false,
// 穿
equipmentList: [],
selectEquipmentList: [],
//
formStandard: [{
standardType: 'qualitative',
formStandard: [
{
standardType: "qualitative",
standardName: null,
detailUpLimit: null,
detailDownLimit: null,
detailUnit: null,
}],
},
],
//
pickerOptions: {
shortcuts: [{
text: '最近一周',
shortcuts: [
{
text: "最近一周",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
picker.$emit("pick", [start, end]);
},
},
{
text: "最近一个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
picker.$emit("pick", [start, end]);
},
},
{
text: "最近三个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]
picker.$emit("pick", [start, end]);
},
},
],
},
//
loading: true,
@ -523,7 +794,7 @@ export default {
equipmentCodeList: [],
},
//
rules: {}
rules: {},
};
},
created() {
@ -532,12 +803,16 @@ export default {
methods: {
// List-穿
setTransfer() {
getEquipmentList().then(response => {
getEquipmentList().then((response) => {
for (let i = 0; i < response.data.length; i++) {
this.equipmentList.push({
label: response.data[i].equipmentName + '(' + response.data[i].equipmentCode + ')',
label:
response.data[i].equipmentName +
"(" +
response.data[i].equipmentCode +
")",
key: response.data[i].equipmentCode,
})
});
}
});
},
@ -547,21 +822,21 @@ export default {
//
addStandard() {
this.formStandard.push({
standardType: 'qualitative',
standardType: "qualitative",
standardName: null,
detailUpLimit: null,
detailDownLimit: null,
detailUnit: null,
})
});
},
//
removeStandard(index) {
this.formStandard.splice(index, 1)
this.formStandard.splice(index, 1);
},
/** 查询检查项维护列表 */
getList() {
this.loading = true;
listItem(this.queryParams).then(response => {
listItem(this.queryParams).then((response) => {
this.itemList = response.rows;
this.total = response.total;
this.loading = false;
@ -594,13 +869,15 @@ export default {
formStandard: [],
itemTools: null,
};
this.formStandard = [{
standardType: 'qualitative',
this.formStandard = [
{
standardType: "qualitative",
standardName: null,
detailUpLimit: null,
detailDownLimit: null,
detailUnit: null,
}];
},
];
this.selectEquipmentList = [];
this.equipmentList = [];
this.resetForm("form");
@ -621,17 +898,17 @@ export default {
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.itemId)
this.single = selection.length !== 1
this.multiple = !selection.length
this.ids = selection.map((item) => item.itemId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.setTransfer();
this.form.itemLoop = 1;
this.form.itemLoopType = 'day';
this.activePage = 'check';
this.form.itemLoopType = "day";
this.activePage = "check";
this.open = true;
this.title = "新增检查项";
},
@ -639,16 +916,16 @@ export default {
handleUpdate(row) {
this.loading = true;
this.reset();
this.activePage = 'check';
this.activePage = "check";
this.setTransfer();
const itemId = row.itemId || this.ids
getItem(itemId).then(response => {
const itemId = row.itemId || this.ids;
getItem(itemId).then((response) => {
this.form = response.data;
getEquipmentCodeList(row.itemCode).then(response => {
getEquipmentCodeList(row.itemCode).then((response) => {
for (let i = 0; i < response.data.length; i++) {
this.selectEquipmentList.push(response.data[i]);
}
})
});
this.formStandard = response.data.formStandard;
this.loading = false;
@ -662,23 +939,23 @@ export default {
if (this.form.itemName == null) {
this.$message({
message: "请输入检查项名称!",
type: "warning"
})
return
type: "warning",
});
return;
}
if (this.form.itemType == null) {
this.$message({
message: "请选择维护类型!",
type: "warning"
})
return
type: "warning",
});
return;
}
if (this.form.itemMethod == null) {
this.$message({
message: "请输入检查方法!",
type: "warning"
})
return
type: "warning",
});
return;
}
// if (this.selectEquipmentList.length == 0) {
// this.$message({
@ -689,55 +966,55 @@ export default {
// }
for (let i = 0; i < this.formStandard.length; i++) {
//
if (this.formStandard[i].standardType == 'qualitative') {
if (this.formStandard[i].standardType == "qualitative") {
if (this.formStandard[i].standardName == null) {
this.$message({
message: "请输入标准名称!",
type: "warning"
})
return
type: "warning",
});
return;
}
}
//
if (this.formStandard[i].standardType == 'quantify') {
if (this.formStandard[i].standardType == "quantify") {
if (this.formStandard[i].standardName == null) {
this.$message({
message: "请输入标准名称!",
type: "warning"
})
return
type: "warning",
});
return;
}
if (this.formStandard[i].detailUpLimit == null) {
this.$message({
message: "请输入上限!",
type: "warning"
})
return
type: "warning",
});
return;
}
if (this.formStandard[i].detailDownLimit == null) {
this.$message({
message: "请输入下限!",
type: "warning"
})
return
type: "warning",
});
return;
}
if (this.formStandard[i].detailUnit == null) {
this.$message({
message: "请输入单位!",
type: "warning"
})
return
type: "warning",
});
return;
}
}
}
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
this.itemLoading = true;
if (this.form.itemId != null) {
this.form.formStandard = this.formStandard;
this.form.equipmentCodeList = this.selectEquipmentList;
updateItem(this.form).then(response => {
updateItem(this.form).then((response) => {
this.itemLoading = false;
if (response.code != 500) {
this.$modal.msgSuccess("修改成功");
@ -748,7 +1025,7 @@ export default {
} else {
this.form.formStandard = this.formStandard;
this.form.equipmentCodeList = this.selectEquipmentList;
addItem(this.form).then(response => {
addItem(this.form).then((response) => {
this.itemLoading = false;
if (response.code != 500) {
this.$modal.msgSuccess("新增成功");
@ -764,17 +1041,17 @@ export default {
handleDelete(row) {
const itemIds = row.itemId || this.ids;
var itemCodes = '';
var itemCodes = "";
//
for (let i = 0; i < this.itemList.length; i++) {
for (let j = 0; j < itemIds.length; j++) {
if (itemIds[j] == this.itemList[i].itemId) {
itemCodes = itemCodes + this.itemList[i].itemCode + ',';
itemCodes = itemCodes + this.itemList[i].itemCode + ",";
}
}
}
if (itemCodes == '') {
if (itemCodes == "") {
for (let i = 0; i < this.itemList.length; i++) {
if (itemIds == this.itemList[i].itemId) {
itemCodes = this.itemList[i].itemCode;
@ -782,24 +1059,72 @@ export default {
}
}
this.$modal.confirm('是否确认删除检查项维护编号为"' + itemCodes + '"的数据项?').then(function () {
this.$modal
.confirm('是否确认删除检查项维护编号为"' + itemCodes + '"的数据项?')
.then(function () {
return delItem(itemIds);
}).then(response => {
})
.then((response) => {
if (response.code != 500) {
this.$modal.msgSuccess("删除成功");
this.getList();
}
}).catch(() => {
});
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('device/item/export', {
...this.queryParams
}, `item_${new Date().getTime()}.xlsx`)
}
}
this.download(
"device/item/export",
{
...this.queryParams,
},
`item_${new Date().getTime()}.xlsx`
);
},
// -
handleImport() {
console.log("导入按钮");
this.upload.title = "检查项导入";
this.upload.open = true;
},
// -
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// -
handleFileSuccess(response, file, fileList) {
debugger;
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(
"<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
response.msg +
"</div>",
"导入结果",
{ dangerouslyUseHTMLString: true }
);
this.getList();
},
// -
submitFileForm() {
this.$refs.upload.submit();
},
// -
importTemplate() {
this.download(
"/device/item/importTemplate",
{},
`item_template_${new Date().getTime()}.xlsx`
);
},
},
};
</script>
<style>

Loading…
Cancel
Save