<template>
|
<view class="uni-page-index">
|
<view class="v-area" v-for="(area,index) in data">
|
<p :data-key="area.ID?area.ID:area.id">{{ area.Name?area.Name:area.name }}</p>
|
<ul class="areaList">
|
<!-- Mobox2 -->
|
<li v-for="(app,key) in area.App">
|
<a @tap="appCreate(app)" class="logo" :style="{'background-color':app.BkColor,'color':app.BkColor}">
|
<i :class="app.ImgFontStyle" :style="{'color':app.TxtColor}"></i>
|
</a>
|
<p :data-key="app.ID">{{ app.Name }}</p>
|
</li>
|
<!-- Mobox3 -->
|
<li v-for="(app,key) in area.app_list">
|
<a @tap="appCreate(app)" class="logo"
|
:style="{'background-color':app.bk_color,'color':app.bk_color}">
|
<i :class="app.img_font_style" :style="{'color':app.txt_color}"></i>
|
</a>
|
<p :data-key="app.id">{{ app.list_name|| app.name}}</p>
|
</li>
|
|
</ul>
|
</view>
|
|
</view>
|
</template>
|
|
<script>
|
import Base64 from '../../components/js-base64/base64.js'
|
import utils from "@/js/utils.js"
|
import {
|
areaFunc
|
} from "@/api/index.js"
|
import {
|
getFuncTree
|
} from "@/api/mobox.js"
|
|
export default {
|
modules: {
|
Base64,
|
},
|
onNavigationBarButtonTap(e) {
|
this.loadData()
|
},
|
data() {
|
return {
|
title: 'Hello',
|
data: []
|
}
|
},
|
onLoad(options) {
|
console.log(options);
|
// 获取所有AppType="MES",ClientType="2"(PDA)的引用领域功能点信息
|
this.loadData()
|
|
},
|
methods: {
|
setData: function(obj) {
|
let that = this;
|
let keys = [];
|
let val, data;
|
|
Object.keys(obj).forEach(function(key) {
|
keys = key.split(".");
|
val = obj[key];
|
data = that.$data;
|
keys.forEach(function(key2, index) {
|
if (index + 1 == keys.length) {
|
that.$set(data, key2, val);
|
} else {
|
if (!data[key2]) {
|
that.$set(data, key2, {});
|
}
|
}
|
data = data[key2];
|
});
|
});
|
},
|
|
async loadData() {
|
try {
|
this.setData({
|
data: []
|
})
|
const appType = utils.session.getValue('app_type') || "MES";
|
const list = await areaFunc(appType, 1) || []
|
const app = getApp()
|
if (app.globalData.isMobox3) {
|
const list2 = []
|
for (let i in list) {
|
const area = list[i]
|
area.app_type = appType
|
const areaApp = await this.GetFuncTree(i, area)
|
console.log(areaApp)
|
if (areaApp) {
|
list2.push(areaApp)
|
}
|
}
|
this.setData({
|
data: list2
|
})
|
} else {
|
this.setData({
|
data: list
|
})
|
}
|
} catch (ex) {
|
console.log(ex);
|
let exStr = JSON.stringify(ex)
|
if (exStr == "{}")
|
exStr = ex
|
let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
|
uni.showModal({
|
title: this.translateSys("error"),
|
content: tip,
|
showCancel: false,
|
confirmText: this.translateSys("cancel")
|
});
|
}
|
|
|
},
|
async GetFuncTree(index, area) { //Mobox3获取应用领域的功能点
|
try {
|
var param = {
|
app_type: area.app_type,
|
area_id: area.id,
|
area_client_type: area.client_type,
|
need_ace: 1,
|
};
|
const res = await getFuncTree(param) || []
|
if (res.length > 0)
|
return res[0]
|
else
|
return undefined
|
} catch (ex) {
|
console.log(ex);
|
let exStr = JSON.stringify(ex)
|
if (exStr == "{}")
|
exStr = ex
|
let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
|
uni.showModal({
|
title: this.translateSys("error"),
|
content: tip,
|
showCancel: false,
|
confirmText: this.translateSys("cancel")
|
});
|
return undefined
|
}
|
},
|
appCreate(appInfo) { //点击功能点跳转页面
|
console.log(appInfo);
|
const app = getApp()
|
|
var paramStr = app.globalData.isMobox3 ? appInfo.param : appInfo.Param;
|
var appName = app.globalData.isMobox3 ? (appInfo.list_name || appInfo.name) : appInfo.Name;
|
var defCode = app.globalData.isMobox3 ? appInfo.def_code : appInfo.DefCode;
|
var param = "";
|
if (paramStr) {
|
//mobox2的param是json字符串
|
param = paramStr.replace(/\\/g, "");
|
//mobox3的param是base64字符串
|
if (!paramStr.includes('"')) param = Base64.decode(paramStr);
|
}
|
|
if (!param) {
|
uni.showModal({
|
title: this.translateSys("tip"),
|
content: this.translate('tip_no_app_param'),
|
showCancel: false,
|
confirmText: this.translateSys("cancel")
|
});
|
return;
|
}
|
if (defCode == '3018') {
|
if (app.globalData.isMobox3) { //Mobox3
|
uni.navigateTo({
|
// url:'../modal/3018?param='+param+"&titlename="+appName
|
url: '../modal/3018_2?param=' + param + "&titlename=" + appName
|
});
|
} else { //Mobox2
|
uni.navigateTo({
|
url: '../modal/classAttr?param=' + param + "&titlename=" + appName
|
});
|
}
|
} else if (defCode == '3037') {
|
if (app.globalData.isMobox3) { //Mobox3
|
uni.navigateTo({
|
// url:'../modal/3037?param='+param+"&titlename="+appName
|
url: '../modal/3037_2?param=' + param + "&titlename=" + appName
|
});
|
} else { //Mobox2
|
uni.navigateTo({
|
url: '../modal/ms_classAttr?param=' + param + "&titlename=" + appName
|
});
|
}
|
} else if (defCode == '3200') {
|
if (app.globalData.isMobox3) { //Mobox3
|
uni.navigateTo({
|
url: '../modal/3200?param=' + param + "&titlename=" + appName
|
});
|
}
|
} else if (defCode == '3201') {
|
if (app.globalData.isMobox3) { //Mobox3
|
uni.navigateTo({
|
url: '../modal/3201?param=' + param + "&titlename=" + appName
|
});
|
}
|
} else if (defCode == '5600') { //码盘
|
if (app.globalData.isMobox3) { //Mobox3
|
uni.navigateTo({
|
url: '../modal/5600?param=' + param + "&titlename=" + appName
|
});
|
}
|
} else if (defCode == '5601') { //码盘
|
if (app.globalData.isMobox3) { //Mobox3
|
uni.navigateTo({
|
url: '../modal/5601?param=' + param + "&titlename=" + appName
|
});
|
}
|
} else if (defCode == '5602') { //分拣
|
if (app.globalData.isMobox3) { //Mobox3
|
uni.navigateTo({
|
url: '../modal/5602?param=' + param + "&titlename=" + appName
|
});
|
}
|
}
|
|
// uni.redirectTo({
|
// url:'../index/index?args=9999999999'
|
// });
|
},
|
ontap(e) { //扫码功能
|
// console.log(e.target)
|
getApp().onScan((result) => {
|
// console.log(result.decodedata);
|
this.$data.data[e.target.dataset['key']] = result.decodedata;
|
})
|
},
|
translate(t) {
|
if (typeof this.$t == "function") return this.$t(`page.${t}`)
|
else return t;
|
},
|
translateSys(t) {
|
if (typeof this.$t == "function") return this.$t(`sys.${t}`)
|
else return t;
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
.uni-page-index {
|
|
width: 100vw;
|
min-height: 100vh;
|
background: #EAEAEA;
|
padding: 1rpx 0rpx;
|
|
|
.v-area {
|
border-radius: 12rpx;
|
margin: 30rpx;
|
padding: 10rpx;
|
background: #FFFFFF;
|
}
|
|
.areaList {
|
padding: 0;
|
}
|
|
.areaList li {
|
/* border: 1px solid #0062CC; */
|
list-style: none;
|
/* width: 120rpx; */
|
display: inline-block;
|
padding: 30rpx 10rpx 16rpx 10rpx;
|
text-align: center;
|
font-size: 14px;
|
width: 100px;
|
vertical-align: text-top;
|
}
|
|
.logo {
|
height: 120rpx;
|
width: 120rpx;
|
border-radius: 20rpx;
|
display: inline-block;
|
text-align: center;
|
padding: 18rpx;
|
color: #000000;
|
border: 0px solid rgb(221, 221, 221);
|
}
|
|
.logo i {
|
color: #000000;
|
font-size: 40px;
|
line-height: 53px;
|
}
|
}
|
</style>
|