完成单点登录功能

This commit is contained in:
wuxw 2024-01-25 21:13:05 +08:00
parent 5d24960b33
commit 8d3d3b740e
7 changed files with 355 additions and 324 deletions

View File

@ -1,94 +1,101 @@
<div id="addMenuCatalogModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div id="addMenuCatalogModel" class="modal fade" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<h3 class="m-t-none m-b ">
<span><vc:i18n name="添加" namespace="addMenuCatalog"></vc:i18n></span>
<vc:i18n name="添加" namespace="addMenuCatalog"></vc:i18n>
</h3>
<div class="ibox-content">
<div>
<div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="名称" namespace="addMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.name" type="text"
:placeholder="vc.i18n('必填,请填写名称','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="图标" namespace="addMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.icon" type="text"
:placeholder="vc.i18n('必填,请填写图标','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="顺序" namespace="addMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.seq" type="text"
:placeholder="vc.i18n('必填,请填写顺序','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="商户类型" namespace="addMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<select class="custom-select" v-model="addMenuCatalogInfo.storeType">
<option selected disabled value="">
{{vc.i18n('必填','addMenuCatalog')}},请选择商户类型
</option>
<option value="800900000001">{{vc.i18n('运营团队','addMenuCatalog')}}</option>
<option value="800900000003">{{vc.i18n('物业','addMenuCatalog')}}</option>
<option value="800900000005">{{vc.i18n('商家','addMenuCatalog')}}</option>
<option value="800900000000">{{vc.i18n('开发团队','addMenuCatalog')}}</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="页面" namespace="addMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.url" type="text"
:placeholder="vc.i18n('必填,请填写页面','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="是否显示" namespace="addMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<select class="custom-select" v-model="addMenuCatalogInfo.isShow">
<option selected disabled value="">
{{vc.i18n('必填','addMenuCatalog')}},请选择是否显示
</option>
<option value="Y">{{vc.i18n('是','addMenuCatalog')}}</option>
<option value="N">{{vc.i18n('否','addMenuCatalog')}}</option>
</select>
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button"
v-on:click="saveMenuCatalogInfo()">
<i class="fa fa-check"></i>&nbsp;保存
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal">
<span><vc:i18n name="取消" namespace="addMenuCatalog"></vc:i18n></span>
</button>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="名称" namespace="addMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.name" type="text"
:placeholder="vc.i18n('必填,请填写名称','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="图标" namespace="addMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.icon" type="text"
:placeholder="vc.i18n('必填,请填写图标','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="顺序" namespace="addMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.seq" type="text"
:placeholder="vc.i18n('必填,请填写顺序','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="商户类型" namespace="addMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<select class="custom-select" v-model="addMenuCatalogInfo.storeType">
<option selected disabled value="">
{{vc.i18n('必填','addMenuCatalog')}},请选择商户类型
</option>
<option value="800900000001">{{vc.i18n('运营团队','addMenuCatalog')}}</option>
<option value="800900000003">{{vc.i18n('物业','addMenuCatalog')}}</option>
<option value="800900000005">{{vc.i18n('商家','addMenuCatalog')}}</option>
<option value="800900000000">{{vc.i18n('开发团队','addMenuCatalog')}}</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="页面" namespace="addMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.url" type="text"
:placeholder="vc.i18n('必填,请填写页面','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="是否显示" namespace="addMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<select class="custom-select" v-model="addMenuCatalogInfo.isShow">
<option selected disabled value="">
{{vc.i18n('必填','addMenuCatalog')}},请选择是否显示
</option>
<option value="Y">{{vc.i18n('是','addMenuCatalog')}}</option>
<option value="N">{{vc.i18n('否','addMenuCatalog')}}</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="权限编号" namespace="addMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="addMenuCatalogInfo.privId" type="text"
:placeholder="vc.i18n('选填,请填写权限编号','addMenuCatalog')" class="form-control">
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button" v-on:click="saveMenuCatalogInfo()">
<i class="fa fa-check"></i>&nbsp;保存
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal">
<span>
<vc:i18n name="取消" namespace="addMenuCatalog"></vc:i18n>
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -12,7 +12,8 @@
seq: '',
storeType: '',
url: '',
isShow: ''
isShow: '',
privId: '',
}
},
_initMethod: function () {
@ -25,99 +26,93 @@
methods: {
addMenuCatalogValidate() {
return vc.validate.validate({
addMenuCatalogInfo: vc.component.addMenuCatalogInfo
addMenuCatalogInfo: $that.addMenuCatalogInfo
}, {
'addMenuCatalogInfo.name': [{
limit: "required",
param: "",
errInfo: "名称不能为空"
},
{
limit: "maxLength",
param: "10",
errInfo: "名称不能超过10"
},
{
limit: "maxLength",
param: "10",
errInfo: "名称不能超过10"
},
],
'addMenuCatalogInfo.icon': [{
limit: "required",
param: "",
errInfo: "图标不能为空"
},
{
limit: "maxLength",
param: "20",
errInfo: "图标不能超过20"
},
{
limit: "maxLength",
param: "20",
errInfo: "图标不能超过20"
},
],
'addMenuCatalogInfo.seq': [{
limit: "required",
param: "",
errInfo: "顺序不能为空"
},
{
limit: "maxLength",
param: "11",
errInfo: "顺序不能超过11"
},
{
limit: "maxLength",
param: "11",
errInfo: "顺序不能超过11"
},
],
'addMenuCatalogInfo.storeType': [{
limit: "required",
param: "",
errInfo: "商户类型不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "商户类型不能超过12"
},
{
limit: "maxLength",
param: "12",
errInfo: "商户类型不能超过12"
},
],
'addMenuCatalogInfo.url': [{
limit: "required",
param: "",
errInfo: "页面不能为空"
},
{
limit: "maxLength",
param: "256",
errInfo: "点击后进入那个页面不能超过256"
},
{
limit: "maxLength",
param: "256",
errInfo: "点击后进入那个页面不能超过256"
},
],
'addMenuCatalogInfo.isShow': [{
limit: "required",
param: "",
errInfo: "是否显示不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "是否显示不能超过12"
},
{
limit: "maxLength",
param: "12",
errInfo: "是否显示不能超过12"
},
]
});
},
saveMenuCatalogInfo: function () {
if (!vc.component.addMenuCatalogValidate()) {
if (!$that.addMenuCatalogValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
//不提交数据将数据 回调给侦听处理
if (vc.notNull($props.callBackListener)) {
vc.emit($props.callBackListener, $props.callBackFunction, vc.component.addMenuCatalogInfo);
$('#addMenuCatalogModel').modal('hide');
return;
}
vc.http.apiPost(
'/menuCatalog.saveMenuCatalog',
JSON.stringify(vc.component.addMenuCatalogInfo), {
emulateJSON: true
},
JSON.stringify($that.addMenuCatalogInfo), {
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#addMenuCatalogModel').modal('hide');
vc.component.clearAddMenuCatalogInfo();
$that.clearAddMenuCatalogInfo();
vc.emit('menuCatalogManage', 'listMenuCatalog', {});
vc.toast("添加成功");
return;
@ -131,13 +126,14 @@
});
},
clearAddMenuCatalogInfo: function () {
vc.component.addMenuCatalogInfo = {
$that.addMenuCatalogInfo = {
name: '',
icon: '',
seq: '',
storeType: '',
url: '',
isShow: ''
isShow: '',
privId:''
};
}
}

View File

@ -1,93 +1,96 @@
<div id="editMenuCatalogModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div id="editMenuCatalogModel" class="modal fade" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<h3 class="m-t-none m-b ">
<span><vc:i18n name="修改菜单目录" namespace="editMenuCatalog"></vc:i18n></span>
<vc:i18n name="修改" namespace="editMenuCatalog"></vc:i18n>
</h3>
<div class="ibox-content">
<div>
<div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="名称" namespace="editMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.name" type="text"
:placeholder="vc.i18n('必填,请填写名称','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="图标" namespace="editMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.icon" type="text"
:placeholder="vc.i18n('必填,请填写图标','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="顺序" namespace="editMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.seq" type="text"
:placeholder="vc.i18n('必填,请填写顺序','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="商户类型" namespace="editMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<select class="custom-select" v-model="editMenuCatalogInfo.storeType">
<option selected disabled value="">{{vc.i18n('必填','editMenuCatalog')}},请选择商户类型
</option>
<option value="800900000001">{{vc.i18n('运营团队','editMenuCatalog')}}</option>
<option value="800900000003">{{vc.i18n('物业','editMenuCatalog')}}</option>
<option value="800900000005">{{vc.i18n('商家','editMenuCatalog')}}</option>
<option value="800900000000">{{vc.i18n('开发团队','editMenuCatalog')}}</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="页面" namespace="editMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.url" type="text"
:placeholder="vc.i18n('必填,请填写页面','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<span><vc:i18n name="是否显示" namespace="editMenuCatalog"></vc:i18n></span>
</label>
<div class="col-sm-10">
<select class="custom-select" v-model="editMenuCatalogInfo.isShow">
<option selected disabled value="">
{{vc.i18n('必填','editMenuCatalog')}},请选择是否显示
</option>
<option value="Y">{{vc.i18n('是','editMenuCatalog')}}</option>
<option value="N">{{vc.i18n('否','editMenuCatalog')}}</option>
</select>
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button"
v-on:click="editMenuCatalog()">
<i class="fa fa-check"></i>&nbsp;保存
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal">
<span><vc:i18n name="取消" namespace="editMenuCatalog"></vc:i18n></span>
</button>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="名称" namespace="editMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.name" type="text"
:placeholder="vc.i18n('必填,请填写名称','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="图标" namespace="editMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.icon" type="text"
:placeholder="vc.i18n('必填,请填写图标','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="顺序" namespace="editMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.seq" type="text"
:placeholder="vc.i18n('必填,请填写顺序','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="商户类型" namespace="editMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<select class="custom-select" v-model="editMenuCatalogInfo.storeType">
<option selected disabled value="">{{vc.i18n('必填,请选择商户类型','editMenuCatalog')}}
</option>
<option value="800900000001">{{vc.i18n('运营团队','editMenuCatalog')}}</option>
<option value="800900000003">{{vc.i18n('物业','editMenuCatalog')}}</option>
<option value="800900000005">{{vc.i18n('商家','editMenuCatalog')}}</option>
<option value="800900000000">{{vc.i18n('开发团队','editMenuCatalog')}}</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="页面" namespace="editMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.url" type="text"
:placeholder="vc.i18n('必填,请填写页面','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="是否显示" namespace="editMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<select class="custom-select" v-model="editMenuCatalogInfo.isShow">
<option selected disabled value="">
{{vc.i18n('必填','editMenuCatalog')}},请选择是否显示
</option>
<option value="Y">{{vc.i18n('是','editMenuCatalog')}}</option>
<option value="N">{{vc.i18n('否','editMenuCatalog')}}</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="权限编号" namespace="editMenuCatalog"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="editMenuCatalogInfo.privId" type="text"
:placeholder="vc.i18n('选填,请填写权限编号','editMenuCatalog')" class="form-control">
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button" v-on:click="editMenuCatalog()">
<i class="fa fa-check"></i>&nbsp;保存
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal">
<vc:i18n name="取消" namespace="editMenuCatalog"></vc:i18n>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -8,88 +8,89 @@
seq: '',
storeType: '',
url: '',
isShow: ''
isShow: '',
privId: ''
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('editMenuCatalog', 'openEditMenuCatalogModal', function (_params) {
vc.component.refreshEditMenuCatalogInfo();
$that.refreshEditMenuCatalogInfo();
$('#editMenuCatalogModel').modal('show');
vc.copyObject(_params, vc.component.editMenuCatalogInfo);
vc.copyObject(_params, $that.editMenuCatalogInfo);
});
},
methods: {
editMenuCatalogValidate: function () {
return vc.validate.validate({
editMenuCatalogInfo: vc.component.editMenuCatalogInfo
editMenuCatalogInfo: $that.editMenuCatalogInfo
}, {
'editMenuCatalogInfo.name': [{
limit: "required",
param: "",
errInfo: "名称不能为空"
},
{
limit: "maxLength",
param: "10",
errInfo: "名称不能超过10"
},
{
limit: "maxLength",
param: "10",
errInfo: "名称不能超过10"
},
],
'editMenuCatalogInfo.icon': [{
limit: "required",
param: "",
errInfo: "图标不能为空"
},
{
limit: "maxLength",
param: "20",
errInfo: "图标不能超过20"
},
{
limit: "maxLength",
param: "20",
errInfo: "图标不能超过20"
},
],
'editMenuCatalogInfo.seq': [{
limit: "required",
param: "",
errInfo: "顺序不能为空"
},
{
limit: "maxLength",
param: "11",
errInfo: "顺序不能超过11"
},
{
limit: "maxLength",
param: "11",
errInfo: "顺序不能超过11"
},
],
'editMenuCatalogInfo.storeType': [{
limit: "required",
param: "",
errInfo: "商户类型不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "商户类型不能超过12"
},
{
limit: "maxLength",
param: "12",
errInfo: "商户类型不能超过12"
},
],
'editMenuCatalogInfo.url': [{
limit: "required",
param: "",
errInfo: "页面不能为空"
},
{
limit: "maxLength",
param: "256",
errInfo: "点击后进入那个页面不能超过256"
},
{
limit: "maxLength",
param: "256",
errInfo: "点击后进入那个页面不能超过256"
},
],
'editMenuCatalogInfo.isShow': [{
limit: "required",
param: "",
errInfo: "是否显示不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "是否显示不能超过12"
},
{
limit: "maxLength",
param: "12",
errInfo: "是否显示不能超过12"
},
],
'editMenuCatalogInfo.caId': [{
limit: "required",
@ -99,15 +100,15 @@
});
},
editMenuCatalog: function () {
if (!vc.component.editMenuCatalogValidate()) {
if (!$that.editMenuCatalogValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.http.apiPost(
'/menuCatalog.updateMenuCatalog',
JSON.stringify(vc.component.editMenuCatalogInfo), {
emulateJSON: true
},
JSON.stringify($that.editMenuCatalogInfo), {
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
@ -123,20 +124,21 @@
},
function (errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
vc.toast(errInfo);
});
},
refreshEditMenuCatalogInfo: function () {
vc.component.editMenuCatalogInfo = {
$that.editMenuCatalogInfo = {
caId: '',
name: '',
icon: '',
seq: '',
storeType: '',
url: '',
isShow: ''
isShow: '',
privId: ''
}
}
}
});
})(window.vc, window.vc.component);
})(window.vc, window.$that);

View File

@ -3,7 +3,7 @@
<ul class="flex flex-start">
<!-- <li class="title"><a href="/">{{vc.i18n('systemName')}}</a></li> -->
<li class="title"><a href="/">{{logo}}</a></li>
<li :class="{'active' :item.active == '1' }" v-for="(item,index) in nav.catalogs" @click="_changeMenuCatalog(item)">
<li :class="{'active' :item.active == '1' }" v-for="(item,index) in nav.catalogs" @click="_changeMenuCatalog(item)" v-if="!item.privId || vc.hasPrivilege(item.privId)">
<i :class="item.icon"></i>{{item.name}}
</li>
</ul>

View File

@ -1,7 +1,7 @@
/**
导航栏
**/
(function(vc) {
(function (vc) {
let DEFAULT_PAGE = 1;
let DEFAULT_ROW = 10;
var vm = new Vue({
@ -31,7 +31,7 @@
logo: '',
userName: ""
},
mounted: function() {
mounted: function () {
this._initSysInfo();
this.getNavCommunity(1, 3);
this.initLang();
@ -39,11 +39,11 @@
// 定义事件名为'build'.
},
methods: {
_initSysInfo: function() {
_initSysInfo: function () {
let sysInfo = vc.getData("java110SystemInfo");
let _that = this;
if (!sysInfo) {
setTimeout(function() {
setTimeout(function () {
sysInfo = vc.getData("java110SystemInfo");
_that.logo = sysInfo.systemSimpleTitle;
}, 2000);
@ -51,7 +51,7 @@
}
this.logo = sysInfo.systemSimpleTitle;
},
initLang: function() {
initLang: function () {
let _lang = vc.getData('JAVA110-LANG')
if (!_lang) {
vc.saveData('JAVA110-LANG', {
@ -62,11 +62,11 @@
this.nav.langName = _lang.name;
}
},
_changeLang: function(_lang) {
_changeLang: function (_lang) {
vc.saveData('JAVA110-LANG', _lang);
location.reload();
},
logout: function() {
logout: function () {
let param = {
msg: 123
};
@ -74,9 +74,9 @@
vc.http.post('nav',
'logout',
JSON.stringify(param), {
emulateJSON: true
},
function(json, res) {
emulateJSON: true
},
function (json, res) {
if (res.status == 200) {
// 清除本地sessionStorage存储的tab
vc.clearTabToLocal();
@ -84,12 +84,12 @@
return;
}
},
function() {
function () {
console.log('请求失败处理');
}
);
},
getUserInfo: function() {
getUserInfo: function () {
//获取用户名
let param = {
msg: '123',
@ -97,7 +97,7 @@
//发送get请求
vc.http.apiGet('/user.getUserInfo',
param,
function(json, res) {
function (json, res) {
if (res.status == 200) {
var tmpUserInfo = JSON.parse(json);
vm.userName = tmpUserInfo.name;
@ -108,12 +108,12 @@
}
}
},
function() {
function () {
console.log('请求失败处理');
}
);
},
getNavCommunity: function(_page, _row) {
getNavCommunity: function (_page, _row) {
var _tmpCurrentCommunity = vc.getCurrentCommunity();
//浏览器缓存中能获取到
if (_tmpCurrentCommunity != null && _tmpCurrentCommunity != undefined) {
@ -136,7 +136,7 @@
vc.http.get('nav',
'getCommunitys',
param,
function(json, res) {
function (json, res) {
if (res.status == 200) {
vm.nav.communityInfos = JSON.parse(json).communitys;
if (vm.nav.communityInfos == null || vm.nav.communityInfos.length == 0) {
@ -155,36 +155,36 @@
}
}
},
function() {
function () {
console.log('请求失败处理');
}
);
},
changeCommunity: function(_community) {
changeCommunity: function (_community) {
vc.setCurrentCommunity(_community);
vm.nav._currentCommunity = _community;
//中心加载当前页
//location.reload();
vc.jumpToPage("/");
},
_noticeDetail: function(_msg) {
_noticeDetail: function (_msg) {
//console.log(_notice.noticeId);
//vc.jumpToPage("/#/noticeDetail?noticeId="+_notice.noticeId);
//标记为消息已读
vc.http.post('nav',
'readMsg',
JSON.stringify(_msg),
function(json, res) {
function (json, res) {
if (res.status == 200) {
vc.jumpToPage(_msg.url);
}
},
function() {
function () {
console.log('请求失败处理');
}
);
},
_getMenuCatalog: function() {
_getMenuCatalog: function () {
let _param = {
params: {
page: 1,
@ -194,7 +194,7 @@
}
vc.http.apiGet('/menu.listCatalog',
_param,
function(json, res) {
function (json, res) {
let _listCatalogs = JSON.parse(json);
if (_listCatalogs.code != 0) {
return;
@ -202,19 +202,43 @@
vm.nav.catalogs = _listCatalogs.data;
vm._emitMsg(_listCatalogs.data[0])
},
function(e) {
function (e) {
console.log('请求失败处理', e);
}
);
},
_emitMsg: function(_param) {
_navJumpToIot: function () {
//获取用户名
let param = {
params:{
targetUrl: '/',
}
};
//发送get请求
vc.http.apiGet('/iot.getIotToken',
param,
function (json, res) {
let _json = JSON.parse(json);
if (_json.code != 0) {
vc.toast(_json.msg);
return;
}
let _url = _json.data.url;
window.open(_url);
},
function () {
console.log('请求失败处理');
}
);
},
_emitMsg: function (_param) {
vm._settingActiveCatalog(_param);
let event = new CustomEvent('loadMenu', {
"detail": _param
});
document.body.dispatchEvent(event);
},
_doMenu: function() {
_doMenu: function () {
let body = document.getElementsByTagName("body")[0];
let className = body.className;
if (className.indexOf("mini-navbar") != -1) {
@ -223,13 +247,13 @@
}
body.className = className + " mini-navbar";
},
_chooseMoreCommunity: function() {
_chooseMoreCommunity: function () {
vc.emit('chooseEnterCommunity', 'openChooseEnterCommunityModel', {});
},
_viewDocument: function() {
_viewDocument: function () {
vc.emit('document', 'openDocument', {});
},
_settingActiveCatalog: function(_catalog) {
_settingActiveCatalog: function (_catalog) {
let _catalogs = this.nav.catalogs;
_catalogs.forEach(item => {
item.active = '0'
@ -240,11 +264,15 @@
//this.nav.catalogs = _catalogs;
this.$forceUpdate();
},
_changeMenuCatalog: function(_catalog) {
_changeMenuCatalog: function (_catalog) {
//_showModelDiv(item)
if (vm._showModelDiv(_catalog)) {
return;
}
if (_catalog.url == 'IOT') {
vm._navJumpToIot();
return;
}
if (_catalog.url != '#') {
vm._settingActiveCatalog(_catalog);
vc.jumpToPage(_catalog.url);
@ -252,11 +280,11 @@
}
vm._emitMsg(_catalog);
},
_showModelDiv: function(_catalog) {
_showModelDiv: function (_catalog) {
if (_catalog.url.startsWith('?')) {
let _modelName = _catalog.url.substring(1, _catalog.url.length);
$('#' + _modelName).modal('show');
vc.emit(_modelName, '_loadData',{})
vc.emit(_modelName, '_loadData', {})
return true;
}
return false;
@ -268,35 +296,35 @@
function newWebSocket() {
let clientId = vc.uuid();
let heartCheck = {
timeout: 30000, // 9分钟发一次心跳比server端设置的连接时间稍微小一点在接近断开的情况下以通信的方式去重置连接时间。
serverTimeoutObj: null,
pingTime: new Date().getTime(),
reset: function() {
clearTimeout(this.serverTimeoutObj);
return this;
},
start: function() {
let self = this;
this.serverTimeoutObj = setInterval(function() {
if (websocket.readyState == 1) {
console.log("连接状态,发送消息保持连接");
let _pingTime = new Date().getTime();
//保护,以防 异常
if (_pingTime - self.pingTime < 15 * 1000) {
return;
}
websocket.send("{'cmd':'ping'}");
self.pingTime = _pingTime;
heartCheck.reset().start(); // 如果获取到消息,说明连接是正常的,重置心跳检测
} else {
console.log("断开状态,尝试重连");
newWebSocket();
timeout: 30000, // 9分钟发一次心跳比server端设置的连接时间稍微小一点在接近断开的情况下以通信的方式去重置连接时间。
serverTimeoutObj: null,
pingTime: new Date().getTime(),
reset: function () {
clearTimeout(this.serverTimeoutObj);
return this;
},
start: function () {
let self = this;
this.serverTimeoutObj = setInterval(function () {
if (websocket.readyState == 1) {
console.log("连接状态,发送消息保持连接");
let _pingTime = new Date().getTime();
//保护,以防 异常
if (_pingTime - self.pingTime < 15 * 1000) {
return;
}
}, this.timeout)
}
websocket.send("{'cmd':'ping'}");
self.pingTime = _pingTime;
heartCheck.reset().start(); // 如果获取到消息,说明连接是正常的,重置心跳检测
} else {
console.log("断开状态,尝试重连");
newWebSocket();
}
}, this.timeout)
}
//建立websocket 消息连接
}
//建立websocket 消息连接
let user = vc.getData('/nav/getUserInfo');
if (!user) {
return;
@ -324,7 +352,7 @@
websocket = new SockJS(url);
}
//连接发生错误的回调方法
websocket.onerror = function(_err) {
websocket.onerror = function (_err) {
console.log("初始化失败", _err);
// this.$notify.error({
// title: "错误",
@ -332,12 +360,12 @@
// });
};
//连接成功建立的回调方法
websocket.onopen = function() {
websocket.onopen = function () {
heartCheck.reset().start();
console.log("ws初始化成功");
};
//接收到消息的回调方法
websocket.onmessage = function(event) {
websocket.onmessage = function (event) {
heartCheck.reset().start();
console.log("event", event);
let _data = event.data;
@ -353,7 +381,7 @@
}
};
//连接关闭的回调方法
websocket.onclose = function() {
websocket.onclose = function () {
console.log("初始化失败");
//newWebSocket();
// this.$notify.error({
@ -362,7 +390,7 @@
// });
};
//监听窗口关闭事件当窗口关闭时主动去关闭websocket连接防止连接还没断开就关闭窗口server端会抛异常。
window.onbeforeunload = function() {
window.onbeforeunload = function () {
websocket.close();
};
}

View File

@ -61,12 +61,10 @@
<div class="col-sm-2">
<button type="button" class="btn btn-primary btn-sm"
v-on:click="_queryMenuCatalogMethod()">
<i class="fa fa-search"></i>
<vc:i18n name="查询" namespace="menuCatalogManage"></vc:i18n>
</button>
<button type="button" class="btn btn-primary btn-sm"
v-on:click="_resetMenuCatalogMethod()">
<i class="fa fa-repeat"></i>
<vc:i18n name="重置" namespace="menuCatalogManage"></vc:i18n>
</button>
</div>
@ -114,6 +112,9 @@
<th class="text-center">
<vc:i18n name="是否显示" namespace="menuCatalogManage"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="权限编号" namespace="menuCatalogManage"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="操作" namespace="menuCatalogManage"></vc:i18n>
</th>
@ -128,6 +129,7 @@
<td class="text-center">{{_getStoreTypeName(menuCatalog.storeType)}}</td>
<td class="text-center">{{menuCatalog.url}}</td>
<td class="text-center">{{menuCatalog.isShow == 'Y'?'是':'否'}}</td>
<td class="text-center">{{menuCatalog.privId}}</td>
<td class="text-center">
<div class="btn-group">
<button class="btn-white btn btn-xs"
@ -151,13 +153,6 @@
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="8">
<ul class="pagination float-right"></ul>
</td>
</tr>
</tfoot>
</table>
<!-- 分页 -->
<vc:create path="frame/pagination"></vc:create>