设备管理-检查项维护V2(关联设备)

yangwl
wws 1 year ago
parent 79d9409097
commit 0acdfa4f57

@ -1,5 +1,21 @@
import request from '@/utils/request'
// 查询检查项维护详细
export function getEquipmentCodeList(itemCode) {
return request({
url: '/device/item/getEquipmentCodeList/' + itemCode,
method: 'get'
});
}
// 查询检查项维护详细
export function getEquipmentList() {
return request({
url: '/device/item/getEquipmentList',
method: 'get'
});
}
// 查询检查项维护列表
export function listItem(query) {
return request({

@ -251,6 +251,8 @@
<!-- 添加或修改检查项维护对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-tabs type="border-card">
<el-tab-pane label="检查项配置">
<el-form ref="form" :model="form" :rules="rules" label-width="90px">
<!-- 第一行 -->
<el-row>
@ -261,7 +263,7 @@
</el-form-item>
</el-col>
<!-- 第二列 -->
<el-col :span="6" :offset="0.9">
<el-col :span="6" :offset="1">
<el-form-item label="维护类型">
<el-select v-model="form.itemType" placeholder="请选择维护类型" clearable>
<el-option
@ -274,7 +276,7 @@
</el-form-item>
</el-col>
<!-- 第三列 -->
<el-col :span="7" offset="1">
<el-col :span="7" :offset="1">
<el-form-item label-width="100px" label="检查方法/工具">
<el-input v-model="form.itemMethod" placeholder="请输入检查方法/工具"></el-input>
</el-form-item>
@ -302,7 +304,8 @@
<el-col :span="4" class="my-dynamic-btn">
<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>
</el-row>
@ -331,7 +334,8 @@
<el-col :span="4" class="my-dynamic-btn">
<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>
</el-row>
@ -341,6 +345,23 @@
<el-input v-model="form.itemRemark" placeholder="请输入备注"></el-input>
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="关联设备">
<el-row>
<el-col :span="20" :offset="2">
<el-transfer
:button-texts="['取消关联', '添加关联']"
:titles="['设备列表','已关联设备']"
filterable
:filter-method="filterMethod"
filter-placeholder="请输入设备名称"
v-model="selectEquipmentList"
:data="equipmentList">
</el-transfer>
</el-col>
</el-row>
</el-tab-pane>
</el-tabs>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
@ -350,13 +371,24 @@
</template>
<script>
import {listItem, getItem, delItem, addItem, updateItem} from "@/api/device/item";
import {
getEquipmentCodeList,
getEquipmentList,
listItem,
getItem,
delItem,
addItem,
updateItem,
} from "@/api/device/item";
export default {
name: "Item",
dicts: ['device_item_type'],
data() {
return {
// 穿
equipmentList: [],
selectEquipmentList: [],
//
formStandard: [{
standardType: 'qualitative',
@ -440,6 +472,7 @@ export default {
itemMethod: null,
itemRemark: null,
formStandard: [],
equipmentCodeList: [],
},
//
rules: {}
@ -449,6 +482,20 @@ export default {
this.getList();
},
methods: {
// List-穿
setTransfer() {
getEquipmentList().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.equipmentList.push({
label: response.data[i].equipmentName,
key: response.data[i].equipmentCode,
})
}
});
},
filterMethod(query, item) {
return item.label.indexOf(query) > -1;
},
//
addStandard() {
this.formStandard.push({
@ -505,6 +552,8 @@ export default {
detailDownLimit: null,
detailUnit: null,
}];
this.selectEquipmentList = [];
this.equipmentList = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
@ -529,15 +578,24 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.setTransfer();
this.open = true;
this.title = "新增检查项";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.setTransfer();
const itemId = row.itemId || this.ids
getItem(itemId).then(response => {
this.form = response.data;
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.open = true;
this.title = "修改检查项";
@ -567,6 +625,13 @@ export default {
})
return
}
if (this.selectEquipmentList.length == 0) {
this.$message({
message: "请关联设备!",
type: "warning"
})
return
}
for (let i = 0; i < this.formStandard.length; i++) {
//
if (this.formStandard[i].standardType == 'qualitative') {
@ -615,6 +680,7 @@ export default {
if (valid) {
if (this.form.itemId != null) {
this.form.formStandard = this.formStandard;
this.form.equipmentCodeList = this.selectEquipmentList;
updateItem(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
@ -622,6 +688,7 @@ export default {
});
} else {
this.form.formStandard = this.formStandard;
this.form.equipmentCodeList = this.selectEquipmentList;
addItem(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
@ -634,7 +701,26 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const itemIds = row.itemId || this.ids;
this.$modal.confirm('是否确认删除检查项维护编号为"' + itemIds + '"的数据项?').then(function () {
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 + ',';
}
}
}
if (itemCodes == '') {
for (let i = 0; i < this.itemList.length; i++) {
if (itemIds == this.itemList[i].itemId) {
itemCodes = this.itemList[i].itemCode;
}
}
}
this.$modal.confirm('是否确认删除检查项维护编号为"' + itemCodes + '"的数据项?').then(function () {
return delItem(itemIds);
}).then(() => {
this.getList();
@ -655,6 +741,7 @@ export default {
.my-select-input {
width: 130px;
}
.my-dynamic-btn {
margin-left: 10px;
}

@ -162,7 +162,7 @@ export default {
//--------------------->
leftList: [],
rightList: [],
titles: ["未关联产品", "已关联产品"],
titles: ["未factoryCode", "已关联产品"],
//
Ltotal: "",
LPageNum: "1",

Loading…
Cancel
Save