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

View File

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

View File

@@ -192,7 +192,18 @@ export default {
}, },
// 确认选择商品 // 确认选择商品
selectConfirmGoods(res) { 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 // 切换tab
tabChange() { tabChange() {

View File

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