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/faultReport/selectSinglePerson.vue

222 lines
5.5 KiB
Vue

<template>
<el-dialog
title="人员选择"
v-if="showFlag"
:visible.sync="showFlag"
:modal="false"
width="800px"
center
:before-close="cancel"
>
<el-row :gutter="20">
<!--人员数据-->
<el-col :span="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: 150px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="人员名称" prop="itemName">
<el-input
v-model="queryParams.itemName"
placeholder="请输入人员名称"
clearable
style="width: 150px"
@keyup.enter.native="handleQuery"
/>
</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="handleSelectionChange"
ref="multipleTable"
>
<el-table-column
width="50"
align="center"
type="selection"
></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="userName"
v-if="columns[0].visible"
>
</el-table-column>
<el-table-column
label="人员名称"
align="left"
key="itemName"
prop="nickName"
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="submitForm" :disabled="multiple"
>确 定</el-button
>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { getRepairPersonList } from "@/api/device/faultReport";
import { Message } from "element-ui";
export default {
name: "MdItemSingle",
data() {
return {
treeData1: [],
showFlag: false,
// 选中数组
selectedItemId: undefined,
selectedRows: undefined,
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 人员表格数据
itemList: null,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
itemName: null,
itemCodeGet: "",
itemCode: null,
nickName: null,
userName: null,
},
// 列信息
columns: [
{ key: 0, label: `人员编码`, visible: true },
{ key: 1, label: `人员名称`, visible: true },
],
};
},
created() {
this.getList();
},
methods: {
// 取消按钮
cancel() {
this.showFlag = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
itemId: null,
itemCode: this.processId,
itemType: null,
};
this.resetForm("form");
},
handleSelectionChange(val) {
this.itemList = val;
},
// 生成表头序号
indexMethod(index) {
return index + 1;
},
/** 查询设备编码列表*/
getList() {
this.loading = true;
this.queryParams.userName = this.queryParams.itemCode;
this.queryParams.nickName = this.queryParams.itemName;
getRepairPersonList(this.queryParams).then((response) => {
this.itemList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams.equipmentTypeCode = null;
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.userId);
this.userCodes = selection.map((item) => item.userName);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
submitForm() {
if (this.$refs.multipleTable.selection.length > 1) {
Message.warning("只能选择一个报修人,请勿选择多个!");
} else {
this.$emit("onSelected", this.$refs.multipleTable.selection);
this.showFlag = false;
this.getList();
}
},
},
};
</script>