var wmsAdmin = new Vue({
|
el: '#wmsAdmin',
|
mixins: [useAutoHeight],
|
watch: {
|
themeColor: function (val) {
|
document.documentElement.style.setProperty("--theme-color", val);
|
var $content = $('.admin-nav-card .layui-tab-content');
|
$content.find('iframe').each(function () {
|
var currentIframeDocument = $(this).context.contentDocument;
|
if (currentIframeDocument) {
|
currentIframeDocument.documentElement.style.setProperty("--theme-color", val);
|
}
|
});
|
this.setCookie("WmsThemeColor", val);
|
}
|
},
|
data: {
|
//默认颜色
|
themeColor: "#3a93d4",
|
//一级菜单数组
|
firstMenu: [],
|
//不包括一级菜单
|
otherMenu: [],
|
//当前选中菜单id
|
currentId: "",
|
//弹窗table列表属行初始化
|
dialogList: {
|
title: '',
|
condition: '',
|
show: false,
|
itemCols: [],
|
paging: true,
|
url: null,
|
data: {},
|
height: 330,
|
single: false,
|
btnSure: function (selections) { }
|
},
|
dialogFrame: {
|
title: '',
|
show: false,
|
url: '',
|
dh: 0,
|
height: "50%",
|
width: "80%",
|
btn: false,
|
callBack: function (frame) { },
|
cb: function () { }
|
},
|
//dialog列表为item时查询条件
|
formItem: {
|
itemCode: '',
|
itemName: '',
|
itemModel: '',
|
itemFigureNo: ''
|
},
|
formCustomer: {
|
customerName: ''
|
},
|
formVendor: {
|
vendorName: ''
|
},
|
loading: null,
|
pageSetList: [],
|
pageSetReadOnly: []
|
},
|
computed: {
|
dialogFrameHeight: function () {
|
if (this.dialogFrame.dh == 0)
|
return this.dialogFrame.height;
|
return (this.autoHeight - this.dialogFrame.dh) + "px";
|
}
|
},
|
methods: {
|
updatePassword: function () {
|
this.showDialogFrame({
|
title: '修改密码',
|
height: "160px",
|
width: "400px",
|
url: "../Home/UpdatePassword"
|
});
|
},
|
setCookie: function (name, value) {//设置cookie,时间30天
|
var days = 30;
|
var expires = new Date();
|
expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
|
document.cookie = name + "=" + escape(value) + ";expires=" + expires.toGMTString();
|
},
|
getCookie: function (name) {
|
if (document.cookie.length > 0) {
|
c_start = document.cookie.indexOf(name + "=")
|
if (c_start != -1) {
|
c_start = c_start + name.length + 1
|
c_end = document.cookie.indexOf(";", c_start)
|
if (c_end == -1) c_end = document.cookie.length
|
return unescape(document.cookie.substring(c_start, c_end))
|
}
|
}
|
return ""
|
},
|
loadingById: function (id) {
|
var $this = this;
|
var styles = getComputedStyle(document.documentElement);
|
var value = styles.getPropertyValue("--theme-color");
|
$(id).loading({
|
loadingWidth: 120,
|
title: '正在加载...',
|
name: 'content',
|
discription: '',
|
direction: 'column',
|
type: 'origin',
|
originBg: value,
|
originDivWidth: 40,
|
originDivHeight: 40,
|
originWidth: 6,
|
originHeight: 6,
|
smallLoading: false,
|
titleColor: value,
|
loadingBg: 'rgba(0,0,0,0)',
|
//loadingMaskBg: 'rgba(0,0,0,0.1)'
|
});
|
},
|
showWmsContentLoading: function () {
|
this.loadingById('#_wmsContent');
|
},
|
closeLoading: function () {
|
removeLoading('content');
|
},
|
showDialogFrame: function (options) {
|
var $this = this;
|
$this.loadingById('#_dialogFrame');
|
$this.dialogFrame.btn = false;
|
this.dialogFrame.dh = 0;
|
$this.dialogFrame = $.extend($this.dialogFrame, options);
|
if ($this.dialogFrame.url.indexOf("?") > 0) {
|
$this.dialogFrame.url += ("&_t=" + (new Date()).valueOf());
|
} else {
|
$this.dialogFrame.url += ("?_t=" + (new Date()).valueOf());
|
}
|
$this.dialogFrame.cb = function () {
|
if ($this.$refs.iframeDialog) {
|
$this.dialogFrame.callBack($this.$refs.iframeDialog.contentWindow);
|
$this.dialogFrame.show = false;
|
}
|
};
|
$this.dialogFrame.show = true;
|
},
|
searchItem: function () {
|
var $this = this;
|
this.$refs.parentDialogList.pagingOptions.pageIndex = 1;
|
var searchModel = {
|
itemCode: $this.formItem.itemCode,
|
itemName: $this.formItem.itemName,
|
itemModel: $this.formItem.itemModel,
|
itemFigureNo: $this.formItem.itemFigureNo
|
};
|
searchModel = $.extend(searchModel, $this.dialogList.data);
|
this.$refs.parentDialogList.loadData(searchModel);
|
},
|
searchCustomer: function () {
|
var $this = this;
|
this.$refs.parentDialogList.pagingOptions.pageIndex = 1;
|
var searchModel = {
|
customerName: $this.formCustomer.customerName,
|
};
|
this.$refs.parentDialogList.loadData(searchModel);
|
},
|
searchVendor: function () {
|
var $this = this;
|
this.$refs.parentDialogList.pagingOptions.pageIndex = 1;
|
var searchModel = {
|
vendorName: $this.formVendor.vendorName,
|
};
|
this.$refs.parentDialogList.loadData(searchModel);
|
},
|
//退出登录
|
exit: function () {
|
this.confirm("确认退出登录吗?", function () {
|
$.ajax({
|
type: 'GET',
|
async: false,
|
data: { endType: "hand" },
|
url: '/Home/Exit',
|
success: function (data) {
|
location.href = 'Login';
|
}
|
});
|
});
|
},
|
customConfirm: function (options) {
|
var defaultOptions = {
|
title: "提示",
|
content: "",
|
confirmText: "确定",
|
cancelText: "取消",
|
customClass: "",
|
showConfirmButton: true,
|
dangerouslyUseHTMLString: true,
|
callback: function () { }
|
};
|
var option = $.extend(defaultOptions, options);
|
this.$confirm(option.content, option.title, {
|
dangerouslyUseHTMLString: option.dangerouslyUseHTMLString,
|
confirmButtonText: option.confirmText,
|
cancelButtonText: option.cancelText,
|
showConfirmButton: option.showConfirmButton,
|
customClass: option.customClass,
|
callback: option.callback
|
});
|
},
|
//确认框
|
confirm: function (confirmMsg, then, catchEvent) {
|
this.$confirm(confirmMsg, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(function () {
|
if (then)
|
then();
|
}).catch(function () {
|
if (catchEvent)
|
catchEvent();
|
});
|
},
|
//根据OperateResult实体弹出消息
|
showMsg: function (data, successCallBack, errorCallBack, warningCallBack) {
|
if (data) {
|
if (data.Success) {
|
if (successCallBack)
|
successCallBack();
|
else {
|
this.success("保存成功");
|
}
|
}
|
else {
|
switch (data.Status) {
|
case 0:
|
this.error(data.Msg);
|
break;
|
case 2:
|
this.warning(data.Msg);
|
break;
|
default:
|
this.error(data.Msg);
|
}
|
if (errorCallBack)
|
errorCallBack();
|
if (warningCallBack)
|
warningCallBack();
|
}
|
} else
|
this.error("系统错误");
|
},
|
//成功消息
|
success: function (msg) {
|
this.$message({
|
showClose: true,
|
message: msg,
|
type: 'success'
|
});
|
},
|
//警告消息
|
warning: function (msg) {
|
this.$message({
|
showClose: true,
|
message: msg,
|
type: 'warning'
|
});
|
},
|
//错误消息
|
error: function (msg) {
|
this.$message({
|
showClose: true,
|
message: msg,
|
type: 'error'
|
});
|
},
|
//弹窗table列表
|
showDialogList: function (options) {
|
var $this = this;
|
//每次打开先清空上次选中
|
this.formItem.itemCode = '';
|
this.formItem.itemName = '';
|
this.formItem.itemModel = '';
|
this.formItem.itemFigureNo = '';
|
this.formCustomer.customerName = '';
|
this.formVendor.vendorName = '';
|
if (options.url == $this.dialogList.url) {
|
this.$refs.parentDialogList.pagingOptions.pageIndex = 1;
|
this.$refs.parentDialogList.param = {};
|
this.$refs.parentDialogList.loadData();
|
}
|
$this.dialogList.show = true;
|
$this.dialogList.single = false;
|
$this.dialogList.paging = true;
|
$this.dialogList.condition = '';
|
$this.dialogList.data = {};
|
$this.dialogList = $.extend($this.dialogList, options);
|
},
|
//弹窗table列表确认事件
|
dialogListBtnSure: function () {
|
//dialog中选中的物料集合
|
var selections = this.$refs.parentDialogList.selections;
|
//调用确定回调函数
|
this.dialogList.btnSure(selections);
|
this.dialogList.show = false;
|
},
|
//id获取菜单
|
getMenuById: function (id) {
|
var menus = [];
|
for (var i = 0; i < this.otherMenu.length; i++) {
|
if (this.otherMenu[i].pId == id) {
|
var menuEntity = {
|
id: this.otherMenu[i].id,
|
title: this.otherMenu[i].name,
|
icon: this.otherMenu[i].iconSkin,
|
spread: false,
|
href: this.otherMenu[i].url
|
};
|
menus.push(menuEntity);
|
}
|
}
|
return menus;
|
},
|
//获取当前菜单的所有子菜单
|
getCurrentMenuChildren: function (menu) {
|
var $this = this;
|
var secondMenu = $this.getMenuById(menu.id);
|
if (secondMenu.length > 0) secondMenu[0].spread = true;
|
secondMenu.forEach(function (m) {
|
m.children = $this.getMenuById(m.id);
|
});
|
return secondMenu;
|
},
|
//初始化菜单
|
setNavbar: function (setMenu) {
|
var currentSecondMenu = this.getCurrentMenuChildren(setMenu);
|
navbar.set({
|
spreadOne: true,
|
elem: '#admin-navbar-side',
|
cached: true,
|
data: currentSecondMenu
|
});
|
//渲染navbar
|
navbar.render();
|
//监听点击事件
|
navbar.on('click(side)', function (data) {
|
tab.tabAdd(data.field);
|
});
|
},
|
//一级菜单点击事件
|
firstMenuClick: function (id) {
|
var $this = this;
|
$this.currentId = id;
|
var currentMenu = null;
|
$.each($this.firstMenu, function (i, n) {
|
if (n.id == id) {
|
currentMenu = n;
|
n.open = true;
|
} else n.open = false;
|
});
|
if (currentMenu)
|
$this.setNavbar(currentMenu);
|
},
|
loadMenu: function () {//初始化菜单
|
var $this = this;
|
$.ajax({
|
type: 'GET',
|
async: false,
|
url: '../Power/GetMenu',
|
success: function (d) {
|
var d_json = (new Function("return " + d))();
|
var flag = true;
|
d_json.UserMenuList.forEach(function (m, n) {
|
var _menu = {
|
id: m.id,
|
name: m.name,
|
open: false,
|
pId: m.pId,
|
iconSkin: "&" + m.iconSkin,
|
url: m.url
|
};
|
if (m.pId == "-1") {
|
$this.firstMenu.push(_menu);
|
//默认选中第一个
|
if (flag) {
|
_menu.open = true;
|
flag = false;
|
}
|
} else
|
$this.otherMenu.push(_menu);
|
});
|
},
|
error: function (msg) {
|
$this.error("获取菜单异常!");
|
}
|
});
|
},
|
loadThemeColor: function () {
|
var wmsThemeColor = this.getCookie("WmsThemeColor") || "#3a93d4";
|
document.documentElement.style.setProperty("--theme-color", wmsThemeColor);
|
this.themeColor = wmsThemeColor;
|
},
|
loadPageSetList: function () {
|
var $this = this;
|
if (this.pageSetList.length == 0) {
|
$.ajax({
|
type: 'GET',
|
async: false,
|
dataType: 'json',
|
url: "/Sys/PageSet/GetPageSetList",
|
success: function (data) {
|
$this.showMsg(data, function () {
|
var readonlyData = Enumerable.From(data.Data).Where("x=>x.CN_B_READONLY").ToArray();
|
$this.pageSetReadOnly = readonlyData.map(function (n) {
|
return $.trim(n.CN_S_POWER_CODE);
|
});
|
$this.pageSetList = Enumerable.From(data.Data).Where("x=>!x.CN_B_READONLY").ToArray();
|
});
|
}
|
});
|
}
|
}
|
},
|
//页面初始化
|
mounted: function () {
|
//初始化菜单
|
this.loadMenu();
|
//初始化主题颜色
|
this.loadThemeColor();
|
//初始化功能配置数据
|
this.loadPageSetList();
|
}
|
});
|