flx:去重app图标

This commit is contained in:
Rain_ 2025-03-26 17:52:00 +08:00
parent 14e32965f2
commit ac112ab4b3
6 changed files with 52 additions and 15 deletions

19
main.js
View File

@ -239,11 +239,28 @@ export function createApp() {
} }
return fmt return fmt
} }
function recursiveSearchFn(dataList, resultList = []) {
dataList.forEach(item => {
if (item.appShow == 1) {
// return item;
item.operation = true;
resultList.push(item);
}
if (Array.isArray(item.menuList) && item.menuList.length > 0) {
return recursiveSearchFn(item.menuList, resultList);
}
});
return resultList;
};
app.config.globalProperties.$recursiveSearchFn = recursiveSearchFn;
function recursiveSearch(dataList, appPath) { function recursiveSearch(dataList, appPath) {
return dataList.find(item => { return dataList.find(item => {
// console.log(item.path, appPath, item.menuName) // console.log(item.path, appPath, item.menuName)
if (item.path == appPath) { const path = item.path ? item.path : item.modulePath;
if (path == appPath) {
return item; return item;
} }
if (Array.isArray(item.menuList) && item.menuList.length > 0) { if (Array.isArray(item.menuList) && item.menuList.length > 0) {

View File

@ -316,7 +316,7 @@
success(result) { success(result) {
if (result.success) { if (result.success) {
that.haveModuleList = result.result.moduleList.filter( that.haveModuleList = result.result.moduleList.filter(
(item) => item.moduleType == 2 && item.pcShow != 2 (item) => (item.moduleType == 2 || item.moduleType == 10) && item.pcShow != 2
); );
uni.setStorageSync("haveModuleList", that.haveModuleList); uni.setStorageSync("haveModuleList", that.haveModuleList);
// alert(""); // alert("");

View File

@ -50,7 +50,7 @@
<!-- <view class="moudleTitle"> ·已有产品·</view> --> <!-- <view class="moudleTitle"> ·已有产品·</view> -->
<view class="moudleBox"> <view class="moudleBox">
<view @click.stop="goMoudleFn(item)" v-for="(item, index) in list" :key="index"> <view @click.stop="goMoudleFn(item)" v-for="(item, index) in list" :key="index">
<view class="moudleItem" v-if="item.operation && item.moduleType == 2 && item.appShow == 1"> <view class="moudleItem" v-if="item.operation && (item.moduleType == 2 || item.moduleType == 10) && item.appShow == 1">
<view class="inner" :class="{'inner_active': !commonModuleIdFlag(item)}"> <view class="inner" :class="{'inner_active': !commonModuleIdFlag(item)}">
<!-- <view class="imgBox" v-if="iconType == 1"> <!-- <view class="imgBox" v-if="iconType == 1">
<image class="img" :src="'/static/moudleImg/' + item.moduleIcon + '.png'"></image> <image class="img" :src="'/static/moudleImg/' + item.moduleIcon + '.png'"></image>
@ -189,16 +189,24 @@
}); });
console.log("all111", all); console.log("all111", all);
console.log("all222", that.haveModuleList); console.log("all222", that.haveModuleList);
// const newList = that.$recursiveSearchFn(all);
that.list = all.filter(item => { that.list = all.filter(item => {
if(that.haveModuleList.length > 0) { if (that.haveModuleList.length > 0) {
const res = that.$recursiveSearch(that.haveModuleList, item.path) const path = item.path ? item.path : item.modulePath;
return res ? true :false const res = that.$recursiveSearch(that.haveModuleList, path)
return res ? true : false
} }
// console.log(5555555, res); // console.log(5555555, res);
// debugger // debugger
return res; return res;
}); }).reduce((prev,item) => {
const findIndex = prev.findIndex(ele => ele.plugin == item.plugin);
if(findIndex == -1) {
prev.push(item);
}
return prev
}, []);
console.log(that.list);
} }
}) })
}, },
@ -644,7 +652,7 @@
commonModuleIdFlag() { commonModuleIdFlag() {
return (row) => { return (row) => {
const findIndex = this.commonModuleIdsList.findIndex(item => item.moduleId == row.moduleId); const findIndex = this.commonModuleIdsList.findIndex(item => item.moduleId == row.moduleId);
// console.log(findIndex, row.moduleId, this.commonModuleIdsList) console.log(findIndex, row.moduleId, this.commonModuleIdsList)
return findIndex > -1 ? false : true return findIndex > -1 ? false : true
} }
} }

View File

@ -14,7 +14,8 @@
<!-- <view class="moudleTitle"> ·已有产品·</view> --> <!-- <view class="moudleTitle"> ·已有产品·</view> -->
<view class="moudleBox"> <view class="moudleBox">
<view @click="goMoudleFn(item)" v-for="(item, index) in list" :key="index"> <view @click="goMoudleFn(item)" v-for="(item, index) in list" :key="index">
<view class="moudleItem" v-if="item.operation && item.moduleType == 2 && item.appShow == 1"> <view class="moudleItem"
v-if="item.operation && (item.moduleType == 2 || item.moduleType == 10) && item.appShow == 1">
<view class="inner" v-if="COMPANY=='sanjiang'"> <view class="inner" v-if="COMPANY=='sanjiang'">
<!-- <view class="imgBox" v-if="iconType == 1"> <!-- <view class="imgBox" v-if="iconType == 1">
<image class="img" :src="'/static/moudleImg/' + item.moduleIcon + '.png'"></image> <image class="img" :src="'/static/moudleImg/' + item.moduleIcon + '.png'"></image>
@ -546,6 +547,7 @@
} }
}) })
}, },
getAllModule(arr) { getAllModule(arr) {
console.log('获取的模块', arr) console.log('获取的模块', arr)
@ -574,9 +576,13 @@
}); });
console.log("all111", all); console.log("all111", all);
console.log(all, that.haveModuleList) console.log(all, that.haveModuleList)
// const newList = that.$recursiveSearchFn(all);
// console.log(111, newList)
that.list = all.filter(item => { that.list = all.filter(item => {
if (that.haveModuleList.length > 0) { if (that.haveModuleList.length > 0) {
const res = that.$recursiveSearch(that.haveModuleList, item.path) const path = item.path ? item.path : item.modulePath;
const res = that.$recursiveSearch(that.haveModuleList, path)
return res ? true : false return res ? true : false
} }
@ -584,8 +590,14 @@
// console.log(5555555, res); // console.log(5555555, res);
// debugger // debugger
return res; return res;
}); }).reduce((prev, item) => {
console.log(that.list) const findIndex = prev.findIndex(ele => ele.plugin == item.plugin);
if (findIndex == -1) {
prev.push(item);
}
return prev
}, []);
console.log("我是", that.list)
} }
} }
}) })

View File

@ -74,7 +74,7 @@
<view class="moudleTitle"> ·已有产品·</view> <view class="moudleTitle"> ·已有产品·</view>
<view class="moudleBox"> <view class="moudleBox">
<view class="moudleItem" @click="goMoudleFn(item)" v-for="(item, index) in list" :key="index" <view class="moudleItem" @click="goMoudleFn(item)" v-for="(item, index) in list" :key="index"
v-if="item.operation && item.moduleType == 2 && item.appShow == 1"> v-if="item.operation && (item.moduleType == 2 || item.moduleType == 10) && item.appShow == 1">
<view class="inner" v-if="COMPANY=='sanjiang'"> <view class="inner" v-if="COMPANY=='sanjiang'">
<!-- <view class="imgBox" v-if="iconType == 1"> <!-- <view class="imgBox" v-if="iconType == 1">
<image class="img" :src="'/static/moudleImg/' + item.moduleIcon + '.png'"></image> <image class="img" :src="'/static/moudleImg/' + item.moduleIcon + '.png'"></image>

View File

@ -69,7 +69,7 @@
<view class="moudleBox"> <view class="moudleBox">
<view v-for="(item, index) in list" :key="index" <view v-for="(item, index) in list" :key="index"
> >
<view class="moudleItem" @click="goMoudleFn(item)" v-if="item.operation && item.moduleType == 2 && item.appShow == 1"> <view class="moudleItem" @click="goMoudleFn(item)" v-if="item.operation && (item.moduleType == 2 ||item.moduleType == 10) && item.appShow == 1">
<view class="inner" v-if="COMPANY=='sanjiang'"> <view class="inner" v-if="COMPANY=='sanjiang'">
<!-- <view class="imgBox" v-if="iconType == 1"> <!-- <view class="imgBox" v-if="iconType == 1">
<image class="img" :src="'/static/moudleImg/' + item.moduleIcon + '.png'"></image> <image class="img" :src="'/static/moudleImg/' + item.moduleIcon + '.png'"></image>