This commit is contained in:
PQZ 2025-06-30 16:02:03 +08:00
commit 433677db90
5 changed files with 82 additions and 15 deletions

View File

@ -42,12 +42,15 @@ public class BusiCategoryServiceImpl extends ServiceImpl<BusiCategoryMapper, Bus
public List<BusiCategoryVO> treeCategory(BusiCategory category) {
//查询全部栏目
LambdaQueryWrapper<BusiCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag, 0)
.eq(BusiCategory::getTenantId, category.getTenantId())
.orderByAsc(DlBaseEntity::getCreateTime);
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag,0)
.eq(BusiCategory::getTenantId,category.getTenantId());
if(StringUtils.isNotEmpty(category.getCatgType())){
lambdaQueryWrapper.eq(BusiCategory::getCatgType,category.getCatgType());
}
if (!StringUtils.isEmpty(category.getCatgName())) {
lambdaQueryWrapper.like(BusiCategory::getCatgName, category.getCatgName());
}
lambdaQueryWrapper.orderByDesc(BusiCategory::getSort);
List<BusiCategory> list = list(lambdaQueryWrapper);
return buildCategoryTree(list);
}
@ -170,8 +173,8 @@ public class BusiCategoryServiceImpl extends ServiceImpl<BusiCategoryMapper, Bus
// 先将所有节点转换为VO并放入Map
for (BusiCategory category : list) {
BusiCategoryVO vo = new BusiCategoryVO();
BeanUtils.copyProperties(category, vo);
vo.setValue(category.getId());
BeanUtils.copyProperties(category,vo);
vo.setId(category.getId());
vo.setLabel(category.getCatgName());
idToNodeMap.put(vo.getId(), vo);
}

View File

@ -19,12 +19,10 @@ import java.util.List;
@Data
public class BusiCategoryVO extends BusiCategory {
private String value;
private String label;
/**
* 子集
*/
private List<BusiCategory> children = new ArrayList<>();
private List<BusiCategoryVO> children = new ArrayList<>();
}

View File

@ -1,6 +1,9 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="分类" prop="catgId">
<treeselect style="width: 200px" v-model="queryParams.catgId" :options="catgOptions" :normalizer="normalizer" :noResultsText="'暂无数据'" placeholder="选择分类" />
</el-form-item>
<el-form-item label="产品名称" prop="title">
<el-input
v-model="queryParams.title"
@ -234,13 +237,17 @@
</template>
<script>
import { listCategory } from "@/api/busi/category";
import { listProdNew, getProdNew, delProdNew, addProdNew,delProdRandom, updateProdNew,listRandomProd,saveRandom } from "@/api/busi/prod";
import { addRelation } from "@/api/busi/relation";
import selectAllUser from "@/views/system/user/selectAllUser";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "Prod",
dicts: ['sys_yes_no'],
components: { selectAllUser },
components: { selectAllUser ,Treeselect},
data() {
return {
//
@ -253,6 +260,8 @@ export default {
selectOpen: false,
//
loading: true,
//
catgOptions:[],
//
single: true,
@ -351,9 +360,27 @@ export default {
break;
}
},
/** 转换部门数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.label,
children: node.children
};
},
/** 查询产品、文章列表 */
getList() {
this.loading = true;
//
listCategory({catgType:"cp"}).then(response => {
response.data.map((item)=>{
item.parentId=0
})
this.catgOptions = response.data
});
listProdNew(this.queryParams).then(response => {
this.prodList = response.data.records;
this.total = response.data.total;

View File

@ -18,7 +18,7 @@
<el-col :span="10">
<el-form-item label="所属分类" prop="catgId">
<div class="dl-flex-column">
<el-input v-model="form.catgId" placeholder="请输入产品名称"/>
<treeselect style="width: 200px" v-model="form.catgId" :options="catgOptions" :normalizer="normalizer" :noResultsText="'暂无数据'" placeholder="请选择产品分类" />
<div class="dl-add-catg">添加产品分类</div>
</div>
</el-form-item>
@ -88,14 +88,19 @@
</template>
<script>
import { listCategory } from "@/api/busi/category";
import { listProdNew, getProdNew, delProdNew,getMaxSort, addProdNew, updateProdNew } from '@/api/busi/prod'
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: 'prodForm',
components: { Treeselect},
data() {
return {
//--
cursorPos: null,
//
catgOptions:[],
//
form: {
id: null,
@ -142,23 +147,52 @@ export default {
}
},
mounted() {
this.initCatg()
if(this.$route.query.id){
if(this.$route.query.similar){
//
this.getProdInfo(this.$route.query.id,this.$route.query.similar)
}else{
//
this.getProdInfo(this.$route.query.id)
}
}else{
this.initData()
}
},
methods: {
initCatg(){
//
listCategory({catgType:"cp"}).then(response => {
response.data.map((item)=>{
item.parentId=0
})
this.catgOptions = response.data
});
},
/** 转换部门数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.label,
children: node.children
};
},
initData(){
getMaxSort({}).then(response => {
this.form.sort = response.data
})
},
getProdInfo(id){
getProdInfo(id,similar){
getProdNew(id).then(response => {
this.form= response.data
if(similar){
this.form.id=null
this.initData()
}
})
},
/**
@ -189,6 +223,7 @@ export default {
},
/** 暂存 */
saveTmp(){
this.form.ifPublic=0
if (this.form.id != null) {
updateProdNew(this.form).then(response => {
this.$modal.msgSuccess('修改成功')
@ -219,6 +254,9 @@ export default {
</script>
<style scoped>
/deep/.vue-treeselect__input{
vertical-align: middle !important;
}
.dl-add-catg {
cursor: pointer;
width: 130px;

View File

@ -101,6 +101,7 @@ export default {
initData(){
listDept().then(response => {
this.deptOptions = this.handleTree(response.data, "deptId");
console.log(this.deptOptions,"de")
});
},
/** 转换部门数据结构 */