You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MainForm/MainForm_reg.js

670 lines
30 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
var ModArr = [{ '0': '标准版' }, { '1': '总账模块' }, { '2': '提单管理模块' }, { '3': '凭证接口' }, { '4': '销售订舱' }, { '5': '运价管理' }, { '6': '陆运管理' }, { '7': '集装箱管理' }, { '8': '进口贸易' }, { '9': '仓储管理' }, { '10': 'OA' }, { '11': 'CRM' }];
Shipping.MainForm = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MainForm.superclass.constructor.call(this);
};
/**
* 打开窗体
* @param {any} typeName
*/
function openDialog(typeName) {
switch (typeName) {
case "message":
var openSet =
"height=500, width=900, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +
(screen.height - 500) / 2 +
",Left= " +
(screen.width - 900) / 2;
var openType = "_blank";
var openUrl = "../message/message.aspx?post=1";
window.open(openUrl, openType, openSet);
break;
case "announce":
//如果已打开
var openSet =
"height=500, width=900, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +
(screen.height - 500) / 2 +
",Left= " +
(screen.width - 900) / 2;
var openType = "_blank";
var openUrl = "../message/SysAnnounceClient.aspx";
window.open(openUrl, openType, openSet);
break;
}
}
/**
* 打开消息
* @param {any} msg
* @param {any} msgtype
* @param {any} url
*/
function openmsg(msg, msgtype, url) {
var eBody = Ext.getBody();
var msgWinConfig = { width: 300, height: 200 };
var msgWin = new Ext.Window({
resizable: false,
title: '消息提示',
alwaysOnTop: true,
bodyStyle: "background-color:#FFFfff;padding:15px 5px 0",
html:
"<span style='font-size: medium'><strong><span><span><span style='color: #ff0000'><a style=\"text-decoration:none;\" onclick=\"" +
"\" style=\"text-decoration:none;\">" +
msg +
"</a></span></span></span></strong></span>",
x: eBody.getWidth() - msgWinConfig.width,
y: eBody.getHeight(),
width: msgWinConfig.width,
height: msgWinConfig.height,
shadow: false,
items: [],
listeners: {
beforeclose: function () {
var win = this;
win.flyOut();
return false;
}
},
flyIn: function () {
var myWin = this;
myWin.show();
myWin.getEl().shift({
x: eBody.getWidth() - myWin.getWidth(),
y: eBody.getHeight() - myWin.getHeight(),
opacity: 10,
easing: 'easeOut',
duration: 30
});
myWin.isFlyIn = true;
setTimeout(function () {
myWin.flyOut();
}, 10000);
},
flyOut: function () {
var myWin = this;
myWin.getEl().shift({
y: eBody.getHeight()
});
myWin.isFlyIn = false;
},
autoPosition: function () {
if (this.isFlyIn) this.flyIn();
else this.flyOut();
}
});
msgWin.flyIn();
}
function about() {
Ext.Ajax.request({
url: '/Softmng/Home/About',
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
var value = result.Message.split('|')[1];
var msg = [];
if (value !== "") {
value = value.split(',').sort(function (a, b) {
return a - b;
});
for (var i = 0; i < value.length; i++) {
msg.push(CommonJson.GetOptionValue(value[i], ModArr));
}
}
Ext.Msg.show({ title: '关于', msg: '软件版本:' + result.Message.split('|')[0] + '<br/>版本功能:' + msg.join(',') + '<br/>限制人数:' + result.Message.split('|')[2], icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
scope: this
});
}
Ext.extend(Shipping.MainForm, Ext.Panel, {
initUIComponents: function () {
//#region 框架结构
Ext.define('DsShipping.ux.ModuleModel',
{
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'string' },
{ name: 'NAME', type: 'string' },
{ name: 'DESCRIPTION', type: 'string' },
{ name: 'MODULEURL', type: 'string' },
{ name: 'SORT', type: 'number' },
{ name: 'PARENTID', type: 'string' },
{ name: 'PARENTNAME', type: 'string' },
{ name: 'TYPE', type: 'number' },
{ name: 'leaf', type: 'bool' },
{ name: 'expanded', type: 'bool' }
]
});
Ext.define('DsExt.ux.RefTableStore',
{
extend: 'Ext.data.Store',
constructor: function (config) {
var proxy = {
type: 'ajax',
url: config.proxy.url,
reader: {
root: 'data'
}
};
config.proxy = proxy;
this.callParent([config]);
}
});
this.msgBox = Ext.create('Ext.window.MessageBox', { id: "msgBox", autoScroll: true });
this.htmlArray = [
'<h6>以下模块已被禁用,请<span style="color:#B22222">重新分配权限</span>或<span style="color:#B22222">申请更多人数</span>以继续使用</h6><hr/><table cellspacing="0" cellpadding="0" border="1" style="width:470px;text-align:center"><thead><tr><td>序号</td><td>模块编码</td><td>模块名称</td><td>已分配人数</td><td>限制人数</td></tr></thead>'
];
this.loadcount = 0;
this.storeModuTree = Ext.create('DsExt.ux.RefTableStore',
{
model: 'DsShipping.ux.ModuleModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetProModuTreeList' },
listeners: {
load: function () {
_this.htmlArray.push('<tbody>');
_this.htmlArray.push('</tbody>');
_this.htmlArray.push('</table>');
try {
var rawData = this.getProxy().getReader().rawData;
if (rawData.message !== "查询成功!") {
var list = eval(rawData.message);
for (var i = 0; i < list.length; i++) {
_this.htmlArray.splice(_this.htmlArray.length - 2,
0,
'<tr><td>' +
(_this.htmlArray.length - 3) +
'</td><td>' +
list[i].Code +
'</td><td>' +
list[i].Name +
'</td><td>' +
list[i].yTimes +
'</td><td>' +
list[i].aTimes +
'</td></tr>');
}
}
} catch (e) {
console.warn(e.message);
}
}
}
});
this.storeModuTree.load({
params: { condition: "" },
callback: function (r, options, success) {
if (success) {
if (this.storeModuTree.getCount() > 0) {
for (var j = 0; j < this.storeModuTree.getCount(); j += 1) {
var member = this.storeModuTree.getAt(j);
var pid = member.data.id;
var treestore = new Ext.data.TreeStore({
model: 'DsShipping.ux.ModuleModel',
nodeParam: 'PARENTID',
proxy: {
type: 'ajax',
url: '/MvcShipping/MsBaseInfo/GetProParentModuTreeList',
reader: {
id: 'id',
root: 'data',
totalProperty: 'totalCount'
}
},
listeners: {
load: function () {
try {
_this.loadcount++;
var rawData = this.getProxy().getReader().rawData;
if (rawData.message !== "查询成功!") {
var list = eval(rawData.message);
for (var i = 0; i < list.length; i++) {
_this.htmlArray.splice(_this.htmlArray.length - 2,
0,
'<tr><td>' +
(_this.htmlArray.length - 3) +
'</td><td>' +
list[i].Code +
'</td><td>' +
list[i].Name +
'</td><td>' +
list[i].yTimes +
'</td><td>' +
list[i].aTimes +
'</td></tr>');
}
}
}
catch (e) {
console.warn(e.message);
}
if (_this.htmlArray.length > 4 && _this.loadcount >= _this.storeModuTree.getCount()) {
if (Ext.getCmp("msgBox").html !== undefined)
_this.msgBox.update(_this.htmlArray.join(''));
else
_this.msgBox.show({
title: '提示',
msg: _this.htmlArray.join(''),
icon: Ext.window.MessageBox.INFO,
buttons: Ext.Msg.OK,
closable: true,
height: 300,
minWidth: 500
});
//重置内容
_this.htmlArray = [
'<h6>以下模块已被禁用,请<span style="color:#B22222">重新分配权限</span>或<span style="color:#B22222">申请更多人数</span>以继续使用</h6><hr/><table cellspacing="0" cellpadding="0" border="1" style="width:470px;text-align:center"><thead><tr><td>序号</td><td>模块编码</td><td>模块名称</td><td>已分配人数</td><td>限制人数</td></tr></thead>'
];
_this.htmlArray.push('<tbody>');
_this.htmlArray.push('</tbody>');
_this.htmlArray.push('</table>');
}
}
},
autoLoad: true,
root: {
name: '根节点',
expanded: true,
id: pid
}
});
var tabtree = new Ext.tree.Panel({
region: 'west',
title: "<a><b><font color='#105cb6'>" + member.data.DESCRIPTION + "</font></b></a>",
split: true,
width: 180,
margins: '0 0 0 0',
store: treestore,
collapsible: true,
rootVisible: false,
hideHeaders: true,
animate: false,
lines: false,
useArrows: true,
columns: [
{
xtype: 'treecolumn',
text: '模块名称',
width: 178,
dataIndex: 'DESCRIPTION'
}
],
listeners: {
scope: this,
'itemclick': function (view, record, item, index, e, eOpts) {
if (record.data.MODULEURL == '#') return;
var finded = false;
var children = _this.MainCenter.items;
if (children) {
for (var i = 0, len = children.length; i < len; i++) {
if (children.items[i].id) {
if (children.items[i].id == 'pnl' + record.data.NAME) {
_this.MainCenter.setActiveTab(i);
finded = true;
}
}
}
}
if (finded == false) {
var paneltabitems = new Ext.Panel({
id: 'pnl' + record.data.NAME,
layout: "fit",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.PARENTNAME + '-' + record.data.DESCRIPTION,
html:
' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' +
record.data.MODULEURL +
'"> </iframe>'
});
this.MainCenter.add(paneltabitems);
this.MainCenter.setActiveTab(paneltabitems);
this.MainCenter.doLayout();
}
}
}
});
_this.topleft.add(tabtree);
};
}
}
},
scope: this
});
this.topleft = Ext.create('Ext.panel.Panel',
{
title: "功能菜单",
layout: "accordion", //设置为手风琴布局
layoutConfig: {
animate: true
},
width: 180,
minWidth: 90,
region: "west", //设置方位
split: true,
collapsible: true
});
this.Mainpanel = new Ext.Panel({
title: '首页',
region: 'center',
iconCls: "img_main",
animate: true,
autoScroll: true,
html: "<iframe id='main' name='main' scrolling='auto' frameborder='0' width='100%' height='100%' src='/SoftMng/Home/Index'></iframe>",
//layout: {
// type: 'table',
// columns: 4
//},
//bodyStyle: {
// background:
// 'url(TruckMng/Content/Images/LogonLog.jpg);background-repeat: no-repeat;background-attachment: fixed; background-size:50% 50%; background-position: 100% 100%',
// padding: '0px'
//},
//loader: {
// url: '/SoftMng/Home/Index',
// scripts: true,
// autoLoad:true
//},
frame: true
});
this.MainCenter = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
id: 'MainCenter',
border: true,
frame: false,
region: 'center',
enableTabScroll: true,
items:
[
this.Mainpanel
]
});
this.topPart = new Ext.Panel({
html: "<a><b><font color='#FFFFFF' size=5>东胜物流信息管理系统</font></b></a>",
region: 'north',
layout: {
type: 'hbox',
pack: 'end',
align: 'middle'
},
margins: '0 0 5 0',
height: 45,
bodyStyle: {
background: 'url(../../images/masthead.jpg) center',
padding: '5px'
},
defaults: {
anchor: '99%',
color: '#FFFFFF',
labelStyle: "font-size:'24px'"
},
items: [
// {
// xtype: 'button',
// text: '我的收藏',
// height: 40,
// icon: "../../images/yellow-folder-open.png"
// ,
// arrowAlign: 'bottom',
// padding:'5 5 3 10',
// style:'color:#FFFFFF;',
// scale: 'large',
// menu:[
// { text: '添加到收藏', iconCls: "btnadd",
// handler: function (button, event) {
// },
// scope: this
// },
// {text: 'Item 2'},
// {text: 'Item 3'},
// {text: 'Item 4'}
// ]
// },
// {
// xtype: 'label',
// id: 'mycollect',
// html: "<a href=\"javascript:void(0)\" style=\"color:#FFFFFF;text-decoration:none;\" "
// + "style=\"color:#FFFFFF;text-decoration:none;\">我的收藏</a>",
// height: 40,
// padding: '5 5 0 10',
// style: 'color:#FFFFFF;',
// scale: 'large'
// },
// {
// xtype: 'label',
// id: 'header-content',
// padding: '8 0 3 0',
//// text: '我的收藏<',
// html: "<img src='../../images/sort_desc.gif'></img>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",
// height: 40,
// style: 'color:#FFFFFF;',
// scale: 'large'
// },
{
xtype: 'label',
html: "用户名:" + SHOWNAME + "(" + COMPANYNAME + ")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",
height: 40,
padding: '5 5 3 10',
style: 'color:#FFFFFF;',
scale: 'large'
},
{
xtype: 'label',
id: 'dvMessage',
padding: '5 5 3 10',
html:
"<a href=\"javascript:void(0)\" style=\"color:#FFFFFF;text-decoration:none;\" onclick=\"openDialog('message')" +
"\" style=\"color:#FFFFFF;text-decoration:none;\">我的消息(0/0)</a>&nbsp;&nbsp;&nbsp;&nbsp",
height: 40
},
{
xtype: 'label',
padding: '5 5 3 10',
html:
"&nbsp;&nbsp;&nbsp;&nbsp<a href=\"javascript:void(0)\" onclick=\"window.open('tools/download.aspx','_blank','height=180, width=380, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no')" +
"\" style=\"color:#FFFFFF;text-decoration:none; \">下载</a>&nbsp;&nbsp;&nbsp;&nbsp",
height: 40
},
{
xtype: 'label',
padding: '5 5 3 10',
html: "&nbsp;&nbsp;&nbsp;&nbsp<a href=\"javascript:void(0)\" onclick=\"about()\" style=\"color:#FFFFFF;text-decoration:none; \">关于</a>&nbsp;&nbsp;&nbsp;&nbsp",
height: 40
},
{
xtype: 'label',
padding: '5 5 3 10',
html: "<a href=\"../SignOn/Logout.aspx\" style=\"color:#FFFFFF;text-decoration:none;\">[退出]</a>",
height: 40
}
]
});
Ext.apply(this,
{
items: [this.topPart, this.topleft, this.MainCenter]
});
//#endregion
//#region 刷新消息 等
var task = { //Ext的定时器每隔2秒刷新store。
run: function () {
Ext.Ajax.request({
url: '/MvcShipping/MsBaseInfo/GetMessageStr',
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
return;
} else {
var messagestr = result.data;
var dvMessage = Ext.getCmp('dvMessage');
// dvMessage.setText(messagestr);
dvMessage.update(
"<a href=\"javascript:void(0)\" style=\"color:#FFFFFF;text-decoration:none;\" onclick=\"openDialog('message')" +
"\" style=\"color:#FFFFFF;text-decoration:none;\">" +
messagestr +
"</a>&nbsp;&nbsp;&nbsp;&nbsp");
}
}
},
scope: this
});
},
interval: 20000
};
Ext.TaskManager.start(task); //启动定时器
Ext.define('SysMessage',
{
extend: 'Ext.data.Model',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'NAME', type: 'string' },
{ name: 'DESCRIPTION', type: 'string' },
{ name: 'ISREAD', type: 'bool' },
{ name: 'MESSAGECONTENT', type: 'string' },
{ name: 'TASKURL', type: 'string' },
{ name: 'TASKID', type: 'string' },
{ name: 'RECVTYPE', type: 'string' },
{ name: 'ISSEND', type: 'string' }
]
});
Notification.requestPermission(function (perm) {
if (perm == "granted") {
this.storeSysMessage = Ext.create('DsExt.ux.RefTableStore',
{
model: 'SysMessage',
proxy: { url: '/MvcShipping/MsBaseInfo/GetMessageList' }
});
var _main = this;
var taskMessage = { //Ext的定时器每隔2秒刷新store。
run: function () {
_main.storeSysMessage.load({
params: { optype: "" },
callback: function (r, options, success) {
if (success) {
if (_main.storeSysMessage.getCount() > 0) {
for (var j = 0; j < _main.storeSysMessage.getCount(); j += 1) {
var member = _main.storeSysMessage.getAt(j);
var notification = new Notification("东胜消息提醒:",
{
dir: "auto",
lang: "hi",
tag: member.data.GID,
vibrate: [200, 100, 200],
icon: "../../images/提醒.ico",
body: member.data.MESSAGECONTENT
});
}
}
}
}
});
},
interval: 2000
};
Ext.TaskManager.start(taskMessage); //启动定时器
}
});
Ext.define('DsShipping.ux.UserMainModule',
{
extend: 'Ext.data.Model',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'MODULEID', type: 'string' },
{ name: 'MODULENAME', type: 'string' },
{ name: 'MODULETITLE', type: 'string' },
{ name: 'MODULEURL', type: 'string' },
{ name: 'SORT', type: 'number' },
{ name: 'MODULEWIDTH', type: 'number' },
{ name: 'ISSYS', type: 'bool' }
]
});
this.storeModuUser = Ext.create('DsExt.ux.RefTableStore',
{
model: 'DsShipping.ux.UserMainModule',
proxy: { url: '/MvcShipping/MsMainForm/GetUserDataList' }
});
this.storeModuUser.load({
params: { condition: "" },
callback: function (r, options, success) {
if (success) {
if (this.storeModuUser.getCount() > 0) {
for (var j = 0; j < this.storeModuUser.getCount(); j += 1) {
var member = this.storeModuUser.getAt(j);
var pid = member.data.id;
var paneltabitems = new Ext.Panel({
layout: "fit",
region: "center",
autoScroll: true,
frame: true,
width: member.data.MODULEWIDTH,
height: 350,
closable: true,
title: member.data.MODULETITLE,
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' +
member.data.MODULEURL +
'"> </iframe>'
});
this.Mainpanel.add(paneltabitems);
};
}
}
},
scope: this
});
//#endregion
} //end initUIComponents
});