This commit is contained in:
魏啾 2024-11-26 09:36:27 +08:00
commit 56c47a1ab2
3 changed files with 45 additions and 5 deletions

View File

@ -54,7 +54,7 @@
</template>
</el-table-column>
<el-table-column label="分类名称" prop="categoryName"></el-table-column>
<el-table-column label="操作">
<el-table-column label="操作" v-if="radio">
<template v-slot="scope">
<el-button type="primary" @click="selectHandle(scope.row)">选择</el-button>
</template>

View File

@ -192,7 +192,18 @@ export default {
},
//
selectConfirmGoods(res) {
this.$set(this.form.list, this.activeItem, { ...res[0] })
// this.form.list = res
const flag = this.form.list.filter(item => item.id == res[0].id)
if (flag.length) {
this.$notify({
title: '注意',
message: '请勿重复添加',
type: 'error'
})
} else {
this.$set(this.form.list, this.activeItem, { ...res[0] })
}
},
// tab
tabChange() {

View File

@ -7,8 +7,12 @@
</el-input>
</div>
<div class="tree_wrap">
<el-tree :data="treeData" node-key="id" highlight-current :props="{ label: 'name' }" default-expand-all
@node-click="treeItemClick"></el-tree>
<!-- <el-tree :data="treeData" node-key="id" highlight-current :props="{ label: 'name' }" default-expand-all
@node-click="treeItemClick"></el-tree> -->
<div class="item" :class="{ active: selectCatoryIndex == index }" v-for="(item, index) in treeData"
:key="item.id" @click="treeItemClick(item, index)">
{{ item.name }}
</div>
</div>
</div>
<div class="table_wrap">
@ -62,6 +66,7 @@ export default {
query: {
name: ''
},
selectCatoryIndex: 0,
selectCatory: '',
treeDataOrgin: [],
treeData: [],
@ -88,6 +93,12 @@ export default {
this.treeData = this.treeDataOrgin.filter(item => {
return item.name.includes(this.query.name)
})
if (this.treeData.length) {
this.selectCatoryIndex = 0
this.selectCatory = this.treeData[this.selectCatoryIndex]
this.getTableData()
}
},
//
tableDrag() {
@ -147,7 +158,8 @@ export default {
}
},
//
treeItemClick(data) {
treeItemClick(data, index) {
this.selectCatoryIndex = index
this.selectCatory = data
this.tableData.page = 1
this.getTableData()
@ -164,6 +176,7 @@ export default {
})
this.treeDataOrgin = res.content
this.treeData = res.content
this.selectCatory = res.content[this.selectCatoryIndex]
this.getTableData()
} catch (error) {
console.log(error)
@ -235,6 +248,22 @@ export default {
width: 100%;
height: calc(100% - 70px);
overflow-y: auto;
.item {
padding: 10px 15px;
font-size: 14px;
display: flex;
align-items: center;
&:hover {
cursor: pointer;
}
&.active {
background-color: #1890ff;
color: #fff;
}
}
}
}