You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LanJu_UI/src/views/device/repairOrder/selectSingleEquipment.vue

334 lines
9.1 KiB
Vue

<template>
<el-dialog
title="设备选择"
v-if="showFlag"
:visible.sync="showFlag"
:modal="false"
width="1200px"
center
:before-close="cancelEquipmentForm"
>
<el-row :gutter="20">
<!--分类数据-->
<el-col :span="5" :xs="24">
<el-card>
<span>请选择设备类型:</span>
<div class="head-container" style="text-align: center">
<el-tree
:data="treeData"
:props="{ id: 'equipmentTypeCode', label: 'equipmentTypeName' }"
node-key="id"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
default-expand-all
@node-click="handleNodeClick"
/>
</div>
</el-card>
</el-col>
<!--设备数据-->
<el-col :span="19" :xs="24">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="设备编码" prop="itemCode">
<el-input
v-model="queryParams.itemCode"
placeholder="请输入设备编码"
clearable
style="width: 160px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备名称" prop="itemName">
<el-input
v-model="queryParams.itemName"
placeholder="请输入设备名称"
clearable
style="width: 160px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="组线" prop="groupLine">
<template>
<el-select
v-model="queryParams.groupLine"
filterable
placeholder="请选择组线"
style="width: 160px"
>
<el-option
v-for="item in options"
:key="item.equipmentCode"
:label="item.equipmentName"
:value="item.equipmentCode"
>
</el-option>
</el-select>
</template>
</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-table
v-loading="loading"
:data="itemList"
@selection-change="handleEquipmentSelectionChange"
ref="myTable"
>
<el-table-column width="50" align="center" type="selection">
<!-- <template v-slot="scope">
<el-radio v-model="selectedItemId" :label="scope.row.itemId" @change="handleRowChange(scope.row)">{{""}}</el-radio>
</template> -->
</el-table-column>
<!-- 序号 -->
<el-table-column
type="index"
width="90"
align="center"
:index="indexMethod"
label="序号"
></el-table-column>
<el-table-column
label="设备编码"
align="center"
key="itemCode"
prop="equipmentCode"
v-if="columns[0].visible"
>
</el-table-column>
<el-table-column
label="设备类型编码"
align="center"
key="itemTypeCode"
prop="equipmentTypeCode"
v-if="columns[2].visible"
>
</el-table-column>
<el-table-column
label="设备名称"
align="left"
key="itemName"
prop="equipmentName"
v-if="columns[1].visible"
:show-overflow-tooltip="true"
/>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitEquipmentForm">确 定</el-button>
<el-button @click="cancelEquipmentForm"> </el-button>
</div>
</el-dialog>
</template>
<script>
import {
getEquipmentList,
getEquipmentTypeList,
getGroupLineList,
} from "@/api/device/faultReport";
import {getEquList} from "@/api/device/plan";
import { treeselect } from "@/api/wms/equipment";
import { Message } from "element-ui";
export default {
name: "MdItemSingle",
data() {
return {
treeData: [],
showFlag: false,
// 选中数组
selectedItemId: undefined,
selectedRows: undefined,
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备产品表格数据
itemList: null,
// 树选项
itemTypeOptions: undefined,
//树名称
equipmentTypeCode: undefined,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
itemName: undefined,
equipmentTypeCode: undefined,
itemTypeId: 0,
itemCodeGet: "",
itemCode: undefined,
equipmentCode: null,
equipmentName: null,
groupLine: null,
},
// 列信息
columns: [
{ key: 0, label: `设备编码`, visible: true },
{ key: 1, label: `设备名称`, visible: true },
{ key: 2, label: `设备类型`, visible: true },
],
};
},
created() {
this.getList();
this.getEquipmentType();
},
methods: {
// 表单重置
reset() {
this.form = {
itemId: null,
itemCode: null,
itemType: null,
groupLine :null,
};
this.resetForm("form");
},
handleEquipmentSelectionChange(val) {
this.itemList = val;
},
// 生成表头序号
indexMethod(index) {
return index + 1;
},
/** 查询设备编码列表*/
getList() {
this.loading = true;
this.queryParams.equipmentCode = this.queryParams.itemCode;
this.queryParams.equipmentName = this.queryParams.itemName;
getEquipmentList(this.queryParams).then((response) => {
this.itemList = response.rows;
this.total = response.total;
this.loading = false;
});
//组线列表
getGroupLineList().then((response) => {
this.options = response.rows;
});
},
//查询
getEquList() {
this.loading = true;
this.queryParams.equipmentCode = this.queryParams.itemCode;
this.queryParams.equipmentName = this.queryParams.itemName;
getEquList(this.queryParams).then((response) => {
this.itemList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 查询分类下拉树结构 */
getEquipmentType() {
getEquipmentTypeList().then((response) => {
this.treeData = response.rows;
});
},
// 筛选节点
filterNode(value, data) {
console.log(value, data);
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
// 节点单击事件
handleNodeClick(data) {
this.queryParams.equipmentTypeCode = data.equipmentTypeCode;
console.log(this.queryParams.equipmentTypeCode);
this.queryParams.pageNum = 1;
this.getList();
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getEquList();
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams.equipmentTypeCode = null;
this.resetForm("queryForm");
this.queryParams.pageNum = 1;
this.getList()
},
// 多选框选中数据
handleEquipmentSelectionChange(selection) {
this.ids = selection.map((item) => item.equipmentCode);
this.single = selection.length !== 1;
this.multiple = !selection.length;
console.log("多选框", this.ids);
},
submitEquipmentForm() {
const data = this.ids;
if (data.length > 1) {
Message.warning("只能选择一个维修机器,请勿选择多个!");
} else {
const equipmentCode = data.toString();
if (this.queryParams.itemCodeGet == "") {
this.queryParams.itemCodeGet = equipmentCode;
} else {
this.queryParams.itemCodeGet =
this.queryParams.itemCodeGet + "," + equipmentCode;
}
this.selectedRows = this.queryParams.itemCodeGet;
this.$emit("onSelected", this.selectedRows);
this.queryParams.equipmentTypeCode = null;
this.getList();
this.showFlag = false;
this.queryParams.itemCodeGet = "";
}
},
cancelEquipmentForm() {
this.queryParams.equipmentTypeCode = null;
this.getList();
this.showFlag = false;
},
},
};
</script>