|
|
Ext.namespace('Shipping');
|
|
|
|
|
|
Shipping.SysUserIndex = function (config) { //创造函数
|
|
|
Ext.applyIf(this, config);
|
|
|
this.initUIComponents();
|
|
|
window.Shipping.SysUserIndex.superclass.constructor.call(this);
|
|
|
};
|
|
|
|
|
|
Ext.extend(Shipping.SysUserIndex, Ext.Panel, {
|
|
|
PageSize: 50,
|
|
|
OprationStatus: null, //仅当弹出界面时使用
|
|
|
SelectedRecord: null,
|
|
|
DEPTNAME:"",
|
|
|
COMPANYID: "",
|
|
|
SELECTUSERID:"",
|
|
|
initUIComponents: function () { //页面初始化函数
|
|
|
//定义模型
|
|
|
Ext.define('ModuleModel', { //公司人员树形图的Model
|
|
|
extend: 'Ext.data.Model',
|
|
|
fields: [
|
|
|
{ name: 'id', type: 'string' },
|
|
|
{ name: 'GID', 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: 'string' },
|
|
|
{ name: 'leaf', type: 'bool' },
|
|
|
{ name: 'expanded', type: 'bool' }
|
|
|
]
|
|
|
});
|
|
|
|
|
|
this.treestore = new Ext.data.TreeStore({ //树列表数据集
|
|
|
model: 'ModuleModel',
|
|
|
nodeParam: 'PARENTID',
|
|
|
proxy: {
|
|
|
type: 'ajax',
|
|
|
url: '/SysMng/SysUser/GetUserTreeRefList',
|
|
|
reader: {
|
|
|
id: 'GID',
|
|
|
root: 'data', //data 对应controller里返回的json里的data
|
|
|
totalProperty: 'totalCount'
|
|
|
}
|
|
|
},
|
|
|
autoLoad: true,
|
|
|
root: {
|
|
|
name: '根节点',
|
|
|
expanded: true,
|
|
|
id: '0'
|
|
|
}
|
|
|
});
|
|
|
|
|
|
var _this = this;
|
|
|
this.tabtree = new Ext.tree.Panel({ //树形图
|
|
|
region: 'west',
|
|
|
title: '分公司/部门信息', //'业务信息',
|
|
|
split: true,
|
|
|
width: 320,
|
|
|
collapsible: true,
|
|
|
margins: '0 0 0 0',
|
|
|
store: this.treestore,
|
|
|
useArrows: true,
|
|
|
rootVisible: false,
|
|
|
hideHeaders: true,
|
|
|
animate: true,
|
|
|
lines: false,
|
|
|
columns: [{
|
|
|
xtype: 'treecolumn',
|
|
|
text: '分公司/部门信息', //'模块名称',
|
|
|
width: 318,
|
|
|
dataIndex: 'DESCRIPTION'
|
|
|
}],
|
|
|
|
|
|
listeners: {
|
|
|
scope: this,
|
|
|
'itemclick': function (_this, record, item, index, e, eOpts) {
|
|
|
if (record.data.TYPE == '0') {
|
|
|
this.COMPANYID = record.data.GID;
|
|
|
this.DEPTNAME = "";
|
|
|
this.SELECTUSERID = "";
|
|
|
}
|
|
|
if (record.data.TYPE == '1') {
|
|
|
this.COMPANYID = "";
|
|
|
this.DEPTNAME = record.data.DESCRIPTION;
|
|
|
this.SELECTUSERID = "";
|
|
|
var condition = "uc.companyid='" + record.data.PARENTID+"' and b.deptname='"+record.data.DESCRIPTION+"'";
|
|
|
this.storeList.load({
|
|
|
params: { start: 0, limit: 500, sort: '', condition: condition },
|
|
|
waitMsg: "正在查询数据...",
|
|
|
scope: this
|
|
|
});
|
|
|
}
|
|
|
if (record.data.TYPE == '2') {
|
|
|
this.SELECTUSERID = record.data.GID;
|
|
|
|
|
|
this.COMPANYID = "";
|
|
|
|
|
|
var condition = " uc.companyid = (select companyid from [user_company] where userid='" + this.SELECTUSERID + "') and b.deptname = (select deptname from[user_baseinfo] where userid = '" + this.SELECTUSERID+"' )";
|
|
|
this.storeList.load({
|
|
|
params: { start: 0, limit: 500, sort: '', condition: condition },
|
|
|
waitMsg: "正在查询数据...",
|
|
|
scope: this,
|
|
|
callback: function (options, success, response) {
|
|
|
if (success) {
|
|
|
if (options.length > 0) {
|
|
|
returnrecord = options[0];
|
|
|
this.DEPTNAME = returnrecord.data.DEPTNAME;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//this.COMPANYID = "";
|
|
|
//this.DEPTNAME = record.data.PARENTID;
|
|
|
|
|
|
//var userid = record.data.GID;
|
|
|
//var condition = " u.GID='" + userid + "' ";
|
|
|
////this.panelcenter.setTitle(record.data.DESCRIPTION + '权限范围');
|
|
|
//this.storeList.load({
|
|
|
// params: { start: 0, limit: 500, sort: '', condition: condition },
|
|
|
// waitMsg: "正在查询数据...",
|
|
|
// scope: this
|
|
|
//});
|
|
|
//_this.opid = userid;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//定义数据集
|
|
|
this.storeList = Ext.create('Ext.data.Store', {
|
|
|
model: 'SysUsermb',
|
|
|
remoteSort: true,
|
|
|
pageSize: this.PageSize,
|
|
|
proxy: {
|
|
|
type: 'ajax',
|
|
|
url: '/SysMng/SysUser/GetDataList',
|
|
|
reader: {
|
|
|
idProperty: 'GID',
|
|
|
root: 'data',
|
|
|
totalProperty: 'totalCount'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.formname = "modSysUserIndex"; //定义当前视图的列表的名字
|
|
|
|
|
|
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { //此类为一个辅助类,它可以传递到Ext.grid.column.Column中作为column列配置项,
|
|
|
//并作为一个可以自动生成数字,为每行提供编号的列。
|
|
|
width: 50 //checkbox后面的一个格宽度
|
|
|
});
|
|
|
|
|
|
this.column = [{
|
|
|
sortable: true,
|
|
|
hidden: true,
|
|
|
dataIndex: 'GID', //对应JS的MODEL
|
|
|
header: 'GID',
|
|
|
width: 80
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'CODENAME',
|
|
|
header: '代码',
|
|
|
width: 80
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'SHOWNAME',
|
|
|
header: '姓名',
|
|
|
width: 80
|
|
|
}
|
|
|
,
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'COMPANYNAME',
|
|
|
header: '所属分公司',
|
|
|
width: 80
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'DEPTNAME',
|
|
|
header: '所属部门',
|
|
|
width: 80
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'OFFICEPHONE',
|
|
|
header: '办公电话',
|
|
|
width: 120
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'MOBILE',
|
|
|
header: '移动电话',
|
|
|
width: 120
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'FAX',
|
|
|
header: '传真',
|
|
|
width: 120
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'EMAIL1',
|
|
|
header: '邮箱1',
|
|
|
width: 120
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'EMAIL2',
|
|
|
header: '邮箱2',
|
|
|
width: 80
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'QQ',
|
|
|
header: 'QQ',
|
|
|
width: 120
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'WECHATACCOUNT',
|
|
|
header: '微信',
|
|
|
width: 120
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'DINGTALKACCOUNT',
|
|
|
header: '钉钉',
|
|
|
width: 120
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'isUseSystem',
|
|
|
header: '是否允许使用本系统',
|
|
|
width: 120,
|
|
|
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
|
|
|
if (isTrue(value)) return '是';
|
|
|
else return '';
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'isDisable',
|
|
|
header: '是否停用',
|
|
|
width: 120,
|
|
|
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
|
|
|
if (isTrue(value)) return '是';
|
|
|
else return '';
|
|
|
}
|
|
|
}
|
|
|
];
|
|
|
|
|
|
//#region 定义Grid
|
|
|
this.Pagenum = Ext.create('Ext.form.field.Number', { //页码条
|
|
|
name: 'bottles',
|
|
|
fieldLabel: '每页记录数',
|
|
|
labelAlign: 'right',
|
|
|
value: this.PageSize,
|
|
|
maxValue: 100000,
|
|
|
width: 180,
|
|
|
minValue: 0,
|
|
|
listeners: {
|
|
|
specialkey: function (field, e) {
|
|
|
if (e.getKey() == e.ENTER) {
|
|
|
_this.onRefreshClick();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.MainCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }); //一个选择模式它将渲染一列可以选中或者反选的复选框. 默认选择模型是多选.
|
|
|
this.gridList = new Ext.grid.GridPanel({ //数据列表
|
|
|
store: this.storeList,
|
|
|
enableHdMenu: false,
|
|
|
region: 'center',
|
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
|
trackMouseOver: true,
|
|
|
disableSelection: false,
|
|
|
stripeRows: true,
|
|
|
selModel: this.MainCB,
|
|
|
viewConfig: {
|
|
|
enableTextSelection: true
|
|
|
},
|
|
|
columns: [new Ext.grid.RowNumberer()],
|
|
|
bbar: [Ext.create('Ext.PagingToolbar', {
|
|
|
store: this.storeList,
|
|
|
displayInfo: true,
|
|
|
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
|
|
|
emptyMsg: "没有数据"
|
|
|
}), this.Pagenum]
|
|
|
});
|
|
|
|
|
|
/////////////以下部分为获取存储的gridpanel显示样式(根据用户不同用户通过GetGridPanel()方法在数据库中取到不同的列表视图数据(每列的宽度等))
|
|
|
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column); //GetGridPanel()方法在BaseP_Master/Areas/CommMng/Viewsjs/Comm/SaveGridPanel.js文件中
|
|
|
this.column.unshift(new Ext.grid.RowNumberer()); //将提供编号的类加到column[]数组最前面
|
|
|
this.gridList.reconfigure(this.storeList, this.column); //用心的store和新的column配置新的grid
|
|
|
////////////////////////////
|
|
|
|
|
|
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
|
|
|
// alert('0....' + dataview.toString() + ',' + record.toString() + ',' + item.toString() + ',' + index.toString() + ',' + e.toString() + ',' + b.toString());
|
|
|
this.SelectedRecord = record;
|
|
|
this.OprationStatus = 'edit';
|
|
|
DsOpenEditWin('/SysMng/SysUser/Edit', record.data.GID, "600", "900","200","200");
|
|
|
}, this);
|
|
|
/* this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
|
|
|
alert(record.get("ContractNo"))
|
|
|
}, this);*/
|
|
|
|
|
|
//查询工具条
|
|
|
var _this = this;
|
|
|
|
|
|
this.panelBtn = new Ext.Panel({
|
|
|
region: "north",
|
|
|
tbar: [
|
|
|
{
|
|
|
id: 'USERNAME',
|
|
|
fieldLabel: '用户名字',
|
|
|
labelWidth:60,
|
|
|
xtype: 'textfield',
|
|
|
name: 'findtextname',
|
|
|
width: 150,
|
|
|
listeners: {
|
|
|
specialkey: function (field, e) {
|
|
|
if (e.getKey() == e.ENTER) {
|
|
|
_this.onRefreshClick();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
text: "执行查询",
|
|
|
iconCls: "btnrefresh",
|
|
|
handler: function (button, event) {
|
|
|
this.onRefreshClick(button, event);
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
{
|
|
|
text: "重置条件",
|
|
|
iconCls: "btnreset",
|
|
|
handler: function (button, event) {
|
|
|
this.onResetClick(button, event);
|
|
|
},
|
|
|
scope: this
|
|
|
}, '-', {
|
|
|
text: "新建用户",
|
|
|
iconCls: "btnadd",
|
|
|
handler: function (button, event) {
|
|
|
this.OprationStatus = 'add';
|
|
|
//首先判断是否已选中一个部门
|
|
|
//如否则报错.getSelectionModel().
|
|
|
nodeList = this.tabtree.getSelectionModel().getSelection();
|
|
|
node = nodeList[0];
|
|
|
|
|
|
if (nodeList.length == 0 || node.data.TYPE != "1") {
|
|
|
alert("请先选中一个部门");
|
|
|
|
|
|
} else {
|
|
|
this.DEPTNAME = node.data.DESCRIPTION;
|
|
|
this.COMPANYID = node.data.PARENTID;
|
|
|
DsOpenEditWin("/SysMng/SysUser/Edit", "新建用户", "450", "800", "200", "200");
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
{
|
|
|
text: "删除",
|
|
|
iconCls: "btndelete",
|
|
|
handler: function (button, event) {
|
|
|
this.onDeleteClick(button, event);
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
'-',
|
|
|
{
|
|
|
text: "保存列表样式",
|
|
|
id: "btntest",
|
|
|
handler: function (button, event) {
|
|
|
|
|
|
var tempcolumns = this.gridList.columns;
|
|
|
|
|
|
DsTruck.SaveGridPanel(USERID, this.formname, tempcolumns, this.column, 1, false);
|
|
|
},
|
|
|
scope: this
|
|
|
}, '-'
|
|
|
//, { text: "打印报表", menu: menu1, scope: this }
|
|
|
]
|
|
|
});
|
|
|
|
|
|
//布局
|
|
|
|
|
|
|
|
|
this.panelTop = new Ext.Panel({
|
|
|
layout: "border",
|
|
|
region: "north",
|
|
|
height: 30,
|
|
|
items: [this.panelBtn]
|
|
|
});
|
|
|
|
|
|
this.panelcenter = new Ext.Panel({
|
|
|
title: '用户信息',
|
|
|
layout: "border",
|
|
|
region: 'center',
|
|
|
animate: true,
|
|
|
autoScroll: true,
|
|
|
// containerScroll: true,
|
|
|
frame: false,
|
|
|
items: [this.panelTop, this.gridList]
|
|
|
});
|
|
|
|
|
|
//Ext.apply(this, {
|
|
|
// items: [this.panelBtn, this.panelTop, this.gridList]
|
|
|
//});
|
|
|
Ext.apply(this, {
|
|
|
items: [this.tabtree, this.panelcenter]
|
|
|
});
|
|
|
|
|
|
this.storeList.on('beforeload', function (store) {
|
|
|
var sql = this.getCondition();
|
|
|
Ext.apply(store.proxy.extraParams, { condition: sql });
|
|
|
}, this);
|
|
|
|
|
|
//this.gridList.addListener('itemcontextmenu', this.itemcontextmenu);
|
|
|
|
|
|
|
|
|
}, //end initUIComponents
|
|
|
|
|
|
|
|
|
getCondition: function () {
|
|
|
//var form = this.panelBtn.getForm();
|
|
|
//if (!form.isValid()) {
|
|
|
// Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
|
|
|
// return '';
|
|
|
//}
|
|
|
|
|
|
var sql = '';
|
|
|
|
|
|
|
|
|
var COMPANYID = this.COMPANYID;
|
|
|
sql = sql + getAndConSql(sql, COMPANYID, " uc.COMPANYID = '" + COMPANYID + "'");
|
|
|
|
|
|
var DEPTNAME = this.DEPTNAME;
|
|
|
sql = sql + getAndConSql(sql, DEPTNAME, " B.DEPTNAME = '" + DEPTNAME + "'");
|
|
|
|
|
|
var showname = Ext.getCmp('USERNAME').getValue();
|
|
|
sql = sql + getAndConSql(sql, showname, " U.showname like '%" + showname + "%'");
|
|
|
|
|
|
return sql;
|
|
|
},
|
|
|
onRefreshClick: function (button, event) {
|
|
|
var conditions = this.getCondition();
|
|
|
|
|
|
//不允许无条件查询
|
|
|
if (isNullorEmpty(conditions)) return;
|
|
|
|
|
|
this.PageSize = this.Pagenum.getValue();
|
|
|
|
|
|
this.storeList.pageSize = this.PageSize;
|
|
|
|
|
|
this.storeList.load({
|
|
|
params: { start: 0, limit: this.PageSize, sort: '', username: conditions }, //传到controller的参数
|
|
|
waitMsg: "正在查询数据...",
|
|
|
scope: this
|
|
|
});
|
|
|
|
|
|
/*
|
|
|
this.treestore.load({
|
|
|
params: { PARENTID: '0' },
|
|
|
waitMsg: "正在刷新数据...",
|
|
|
timeout: 6000000, //60秒
|
|
|
scope: this
|
|
|
});*/
|
|
|
},
|
|
|
|
|
|
|
|
|
onDeleteClick: function (button, event) {
|
|
|
var selections = this.gridList.getSelectionModel().getSelection();
|
|
|
if (selections.length == 0) {
|
|
|
Ext.Msg.show({ title: '提示', msg: '请先选择人员!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var record = selections[0];
|
|
|
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
|
|
|
if (btn == 'yes') {
|
|
|
Ext.Msg.wait('正在删除数据...');
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在删除数据...',
|
|
|
url: '/SysMng/SysUser/Delete',
|
|
|
params: {
|
|
|
data: Ext.JSON.encode(record.data)
|
|
|
},
|
|
|
callback: function (options, success, response) {
|
|
|
if (success) {
|
|
|
var jsonresult = Ext.JSON.decode(response.responseText);
|
|
|
if (jsonresult.Success) {
|
|
|
this.storeList.remove(record);
|
|
|
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
else {
|
|
|
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
failure: function (response, options) {
|
|
|
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
|
},
|
|
|
success: function (response, options) {
|
|
|
},
|
|
|
scope: this
|
|
|
}); //end Ext.Ajax.request
|
|
|
}
|
|
|
}, this);
|
|
|
}, //onDeleteClick
|
|
|
|
|
|
|
|
|
onResetClick: function (button, event) {
|
|
|
Ext.getCmp("USERNAME").setValue("");
|
|
|
},
|
|
|
|
|
|
|
|
|
onGetremind: function (field, newValue, oldValue) {
|
|
|
if (newValue != null) {
|
|
|
this.storeList.load({
|
|
|
params: { start: 0, limit: this.PageSize, sort: '', condition: newValue },
|
|
|
waitMsg: "正在查询数据...",
|
|
|
scope: this
|
|
|
});
|
|
|
|
|
|
}
|
|
|
},
|
|
|
|
|
|
OprationSwap: function () {
|
|
|
var ret = new Array();
|
|
|
ret[0] = this.OprationStatus;
|
|
|
ret[1] = this.storeList;
|
|
|
ret[2] = this.SelectedRecord;
|
|
|
ret[3] = this.DEPTNAME;
|
|
|
ret[4] = this.COMPANYID;
|
|
|
return ret;
|
|
|
}
|
|
|
// alert(this.OprationStatus.ToString());
|
|
|
// alert(this.storeList.toString());
|
|
|
// alert(this.SelectedRecord.toString());
|
|
|
|
|
|
}); |