|
|
@@ -14,7 +14,7 @@
|
|
|
width="244px"
|
|
|
allow-collapse
|
|
|
:right-style="{ overflow: 'hidden' }"
|
|
|
- >
|
|
|
+ >
|
|
|
<div class="ele-border-lighter split-layout-right-content">
|
|
|
<el-tree
|
|
|
:data="treeList"
|
|
|
@@ -39,7 +39,18 @@
|
|
|
:selection.sync="selection"
|
|
|
row-key="id"
|
|
|
:initLoad="false"
|
|
|
+ cache-key="main-material-add-2511121044"
|
|
|
>
|
|
|
+ <template v-slot:radio="{ row }">
|
|
|
+ <el-radio
|
|
|
+ v-model="currentId"
|
|
|
+ :label="row.id"
|
|
|
+ @change="currentInfo = row"
|
|
|
+ >
|
|
|
+ <i></i>
|
|
|
+ </el-radio>
|
|
|
+ </template>
|
|
|
+
|
|
|
<template v-slot:modelType="{ row }">
|
|
|
<span>{{ row.category.modelType }}</span>
|
|
|
</template>
|
|
|
@@ -68,6 +79,16 @@
|
|
|
import { getAssetList } from '@/api/ruleManagement/plan';
|
|
|
import { getTreeByPid, getTreeByGroup } from '@/api/classifyManage';
|
|
|
export default {
|
|
|
+ components: {
|
|
|
+ ProductSearch
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ // 是否支持多选
|
|
|
+ multiple: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
ruleIdListIndex: 0,
|
|
|
@@ -82,19 +103,18 @@
|
|
|
label: 'name'
|
|
|
},
|
|
|
type: null,
|
|
|
- // 表格列配置
|
|
|
- columns: [
|
|
|
- {
|
|
|
- columnKey: 'selection',
|
|
|
- type: 'selection',
|
|
|
- width: 45,
|
|
|
- align: 'center',
|
|
|
- selectable: (row, index) => {
|
|
|
- return !this.processData.some((id) => id == row.id);
|
|
|
- },
|
|
|
- reserveSelection: true,
|
|
|
- fixed: 'left'
|
|
|
- },
|
|
|
+ // 表格选中数据
|
|
|
+ selection: [],
|
|
|
+ processData: [],
|
|
|
+ checkedKeys: [],
|
|
|
+ currentId: null,
|
|
|
+ currentInfo: null
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ // 表格列配置
|
|
|
+ columns() {
|
|
|
+ let list = [
|
|
|
{
|
|
|
label: '设备名称',
|
|
|
prop: 'name'
|
|
|
@@ -142,16 +162,31 @@
|
|
|
prop: 'pathName',
|
|
|
slot: 'pathName'
|
|
|
}
|
|
|
- ],
|
|
|
+ ];
|
|
|
|
|
|
- // 表格选中数据
|
|
|
- selection: [],
|
|
|
- processData: [],
|
|
|
- checkedKeys: []
|
|
|
- };
|
|
|
- },
|
|
|
- components: {
|
|
|
- ProductSearch
|
|
|
+ if (this.multiple) {
|
|
|
+ list.unshift({
|
|
|
+ columnKey: 'selection',
|
|
|
+ type: 'selection',
|
|
|
+ width: 45,
|
|
|
+ align: 'center',
|
|
|
+ selectable: (row, index) => {
|
|
|
+ return !this.processData.some((id) => id == row.id);
|
|
|
+ },
|
|
|
+ reserveSelection: true,
|
|
|
+ fixed: 'left'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ list.unshift({
|
|
|
+ slot: 'radio',
|
|
|
+ width: 50,
|
|
|
+ align: 'center',
|
|
|
+ fixed: 'left'
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
/* 表格数据源 */
|
|
|
@@ -224,18 +259,28 @@
|
|
|
handleClose() {
|
|
|
this.visible = false;
|
|
|
this.$refs.table.setSelectedRows([]);
|
|
|
+ this.currentInfo = null;
|
|
|
+ this.currentId = null;
|
|
|
this.selection = [];
|
|
|
},
|
|
|
selected() {
|
|
|
- if (!this.selection.length) {
|
|
|
- this.$message.error('请至少选择一条数据');
|
|
|
- return;
|
|
|
+ if (this.multiple) {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message.error('请选择设备');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!this.currentInfo) {
|
|
|
+ this.$message.error('请选择设备');
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
const selectList = this.$refs.treeRef.getCheckedNodes();
|
|
|
console.log('selectList-----------', selectList);
|
|
|
this.$emit(
|
|
|
'chooseEquipment',
|
|
|
- this.selection,
|
|
|
+ this.multiple ? this.selection : this.currentInfo,
|
|
|
this.ruleIdListIndex,
|
|
|
this.categoryId
|
|
|
);
|