EXT---小结

// 设值
myform.form.setValues({links_img:upfile_url}); 






// 取值
Ext.getCmp("id").getForm().findField("name").getValue();


myform.getForm().findField("name").getValue();




// 隐藏
Ext.getCmp("item_name").hide(); 
myform.getForm().findField("item_name").hide();


// radiogroup单选取值
var linksTypeValue = myform.getForm().findField("links_type").getGroupValue();




// 按扭居中
buttonAlign : 'center',


// 单选复选-选中
checked: true,




// 清空表单
myform.form.reset();
// 光标聚焦
Ext.getCmp('hp_bm').focus(false,100);
contentEl: 'bgTop_red',


// 表单向内空
insetPadding: 10,


// 表格复选
selType:'checkboxmodel',
multiSelect:true,


// 序号
xtype: 'rownumberer',
width: 40


// 禁用
disabled: true


// 显示
xtype: 'displayfield',




readOnly:true,
 


bodyStyle:{background:"#232d38"},






{
defaults: {
anchor: '100%'
},
border: false,
defaultType: 'datefield',
items: [{
fieldLabel: '交货期限',
name: 'fhd_jhqx',
format: 'Y-m-d'
}]
}






{
xtype: 'textfield',
name: 'user_username',
fieldLabel: '登陆账号',
regex:/^[a-zA-Z][a-zA-Z0-9_]{2,15}$/,
disabled: true
},{
xtype: 'textfield',
name: 'jzd_je',
regex:/^[0-9.]{1,15}$/,
fieldLabel: '进账金额'
},{
xtype: 'textfield',
name: 'user_mail',
fieldLabel: '电子邮件',
regex:/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
regexText:"格式不正确"
}









  switch(n)
     {
     case 1:
       执行代码块 1
       break
     case 2:
       执行代码块 2
       break
     default:
       如果n即不是1也不是2,则执行此代码
     }



--------------------------------------------------------------------------------------------------------------------------


// ajax联动装载对应数据
if ($_GET['action']=='ajax'){
   $sql="SELECT `user_id`,`user_name` FROM `user` where `bm_id`= '$_GET[id]'";
$query=mysql_query($sql);
$i = 0;
echo "[";
while ( $row = mysql_fetch_array ( $query ) ) {
++ $i;
$str = "{'Id':'" . $row [user_id] . "','Name':'" . $row [user_name] . "'}";
if ($i != '1') {
echo "," . $str;
} else {
echo $str;
}
}
echo "]";

}

****************

// 部门
var Store_bm = Ext.create('Ext.data.Store', {
fields: ['Id','Name'],
data : [
<?php
$SQL="SELECT * FROM `department` order by `bm_id` desc";
$query=mysql_query($SQL);
$i=0;
while($row=mysql_fetch_array($query)){
++$i;
$str =  "{'Id':'".$row[bm_id]."','Name':'".$row[bm_mc]."'}";
if ($i != '1'){
echo ",".$str;
}else{
echo $str;
}

}
?>
]
});

// 经办人姓名
var Store_user = Ext.create('Ext.data.Store', {
fields: ['Id','Name'],
proxy : {
type : 'ajax',
url : 'save.php'
}
});


// 表单
var myform = Ext.create('Ext.form.Panel', {
border: false,
headerPosition: 'top',
margin: 10,
items: [{
xtype: 'fieldset',
defaults: {
margin: 10,
labelWidth: 80,
anchor: '100%'
},
items: [{
xtype: 'combobox',
id:'item_jzd_jbbm',
name: 'jzd_jbbm',
typeAhead: true,
fieldLabel: '经办部门',
allowBlank: false,
store: Store_bm,
queryMode: 'local',
displayField: 'Name',
valueField: 'Id',
emptyText: '请选择部门...',
listeners:{
select:function (){
var bm_id =Ext.getCmp('item_jzd_jbbm').getValue();
var user_id = Ext.getCmp('item_jzd_jbr');
user_id.clearValue();
user_id.store.load({
params:{id:bm_id,action:'ajax'}
}); 
}
}
},{
xtype: 'combobox',
id:'item_jzd_jbr',
name: 'jzd_jbr',
typeAhead: true,
fieldLabel: '经办人',
allowBlank: false,
store: Store_user,
queryMode: 'local',
displayField: 'Name',
valueField: 'Id',
emptyText: '请选择经办人...'
}]
}]

});

----------------------------------------------------------------------------------------
// grid里的数据处理



    function redFn(val) {
        return '<span style="color:red;font-weight:bold">' + val + '</span>';
        return val;
    }


    function greenFn(val) {
        return '<span style="color:green;font-weight:bold">' + val + '</span>';
        return val;
    }

    function changeFn(val) {
        if (val == 1) {
            return '<span style="color:green;">入库</span>';
        } else if (val == 2) {
            return '<span style="color:red;">出库</span>';
        }
        return val;
    }




columns: [
{
text     : 'Change',
width    : 75,
sortable : true,
renderer : changeFn,
dataIndex: 'change'
},
{
xtype: 'actioncolumn',
width: 50,
items: [{
getClass: function(v, meta, rec) {          // Or return a class
// from a function
if (rec.get('change') < 0) {
return 'alert-col';
} else {
return 'buy-col';
}
}
}]
}
]




------------------------------------------------




// 下拉框combobox 联动
var store_name = Ext.create('Ext.data.Store', {
fields: ['Id', 'Name'],
data : [

{'Id':'1111111', 'Name':'aaaaaaaaaa'},
{'Id':'22222222', 'Name':'bbbbbbbbbb'},

/*
 * <?php $SQL="SELECT * FROM `catalogs` where `hpfl_sjflid`!='0' order by
 * `hpfl_id` desc"; $query=mysql_query($SQL); $i=0;
 * while($row=mysql_fetch_array($query)){ ++$i; $str =
 * "{'cateId':'".$row[hpfl_id]."', 'cateName':'".$row[hpfl_flmc]."'}"; if ($i !=
 * '1'){ echo ",".$str; }else{ echo $str; } } ?>
 */
]
});


items: [{
xtype: 'combobox',
id:'item_name',
name: 'stock_name',
typeAhead: true,
fieldLabel: '物品名称',
allowBlank: false,
store: store_name,
queryMode: 'local',
valueField: 'Id',
displayField: 'Name',
emptyText: '请选择物品名称...',
listeners:{
select:function (){
var c =Ext.getCmp('item_name').getValue();
alert(c);
myform.form.setValues({stock_cate:c}); 
}
}
},{
xtype: 'textfield',
name: 'stock_cate',
fieldLabel: '所属分类'
}]






-----------------------------------------------------------


Ext.create('Ext.container.Viewport', {
    layout: 'border',
    items: [{
        region: 'north',// 北
        html: '<h1 class="x-panel-header">Page Title</h1>',
        autoHeight: true,
        border: false,
        margins: '0 0 5 0'
    }, {
        region: 'west',  // 西
        collapsible: true,
        title: 'Navigation',
        width: 150
        // could use a TreePanel or AccordionLayout for navigational items
    }, {
        region: 'south', // 南
        title: 'South Panel',
        collapsible: true,
        html: 'Information goes here',
        split: true,
        height: 100,
        minHeight: 100
    }, {
        region: 'east',// 东
        title: 'East Panel',
        collapsible: true,
        split: true,
        width: 150
    }, {
        region: 'center',
        xtype: 'tabpanel', // TabPanel itself has no title
        activeTab: 0,      // First tab active by default
        items: {
            title: 'Default Tab',
            html: 'The first tab\'s content. Others may be added dynamically'
        }
    }]
});


----------------------------------------------------------------


    // 创建表格
    var grid = Ext.create("Ext.grid.GridPanel",{
        store: vstore,
border: false,
width:600, 
height:600,
autoScroll:true, // 滚动条
selType:'checkboxmodel', // 复选框
multiSelect:true,  // 允许多选
        columns: [{
xtype: 'rownumberer',
width: 40  
},{
text: 'ID',
                dataIndex: 'Field_1',
width: 40
            },{
                text: '姓名',
                dataIndex: 'Field_2',
flex: 1
            },{
                text: '电话',
                dataIndex: 'Field_3',
flex: 1
            },{
xtype: 'actioncolumn',
width: 25,
icon   : '../../images/iconShow.png',
tooltip: '查看',
handler: function(ID, Field_1) {
var rec = vstore.getAt(Field_1);
window.location.href="show.php?id="+rec.get('Field_1'); 
}
},{
xtype: 'actioncolumn',
width: 25,
icon   : '../../images/iconDel.png',
tooltip: '删除',
handler: function(ID, id) {
Ext.MessageBox.confirm('提示', '确认删除数据吗?', showResult);
function showResult(btn){  
if (btn == 'yes'){   
var rec = vstore.getAt(id);
Ext.Ajax.request({
url:'save.php',
params:{id:rec.get('id'),action:'del'},
method:'POST',
timeout:2000,
success:function(response,opts){
Ext.Msg.alert("提示", "删除成功");
vstore.load();
}
});

};   
}
        }]
    });
    vstore.load();


--------------------------------------------------------------------


// 登陆账号提交账号 窗口
var win = new Ext.Window ({
title: '用户登陆',
width: 300,
closeAction:'hide',
collapsible: true,
animCollapse: true,
plain:true,// 背景色透明
minimizable:true,// 小最化
maximizble:false,// 最大化
maximized:false,// 窗体程现时最大化
closable:false,// 关窗按钮
draggable:false,// 拖动窗口
border: false,
items:[{
id:'myform',
xtype:'form',
defaults: {
margin: 10,
labelWidth: 60,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'id',
allowBlank: false,
fieldLabel: '登陆账号'
},{
xtype: 'textfield',
name: 'pw',
allowBlank: false,
inputType: 'password',
fieldLabel: '登陆密码'
}]
}],
buttons: [{
text: '登陆系统',
iconCls: 'iconUser',
handler: function(){
Ext.getCmp("myform").getForm().submit({
url:'inc/login.php',
params:{action:'login'},
success: function() {
win.hide();
Loading();
}
});
}
},{
text:'取消',
iconCls:'iconClose',
handler: function(){
Ext.getCmp("myform").getForm().reset();
}

},{
text:'取值看看',
handler: function(){
var text = Ext.getCmp("myform").getForm().findField("id").getValue();
alert(text);
}

}]

});



---------------------------------------------


xtype: 'displayfield',// 下面是用法




var myform = Ext.create('Ext.form.Panel', {
border: false,
headerPosition: 'top',
margin: 10,
items: [{
xtype: 'fieldset',
defaultType: 'textfield',
defaults: {
margin: 10,
labelWidth: 80,
anchor: '100%'
},
items: [{
xtype: 'displayfield',
name: 'Field_1',
allowBlank: false,
fieldLabel: '姓名',
value:'高兴'
},{
xtype: 'displayfield',
name: 'Field_2',
fieldLabel: '电话',
value:'18665260307'
}]
}]

});




------------------------------------------------------------------




Ext.MessageBox.confirm('提示', '确认删除数据吗?', showResult);
function showResult(btn){  
if (btn == 'yes'){   
Ext.MessageBox.alert("消息!","您点击了 yes 按钮");  
}else{   
Ext.MessageBox.alert("消息!","你点击了 no 按钮");  
}    
}; 






--------------------------------------------------------------------------------






// 双击
grid.on('itemdblclick',function(value,o){


var vid = o.raw.id;
alert(vid);

window.location.href="data.html?id="+vid; 


});






// 双击事件
grid.addListener('itemdblclick', click, this);
function click(grid, rowindex, e){
alert(11);
}




------------------------------------------------------------


columns: [{
xtype: 'rownumberer',
width: 20
},{
text: '培训主题',
dataIndex: 'Field_2',
flex: 1
},{
text: '活动时间',
dataIndex: 'Field_3',
flex: 1
}]




---------------------------------------------------------------------




Ext.Ajax.request({
url:'inc/login.php',
params:{action:'info'},
success: function(response){
var text = response.responseText;
if (text=="yes"){
win.hide();
Loading();
}else{
win.show();
}
}
});


-------------------------------------------------------------




// 装载
window.Loading = function(n, floor){
Ext.MessageBox.show({
  title: '登陆成功',
  msg: '即将进入操作中心 ...',
  progressText: 'Loading ...',
  width:300,
  progress:true,
  closable:false
  });
  var f = function(v){
return function(){
if(v == 5){
window.location.href="admin/index.php";  
}else{
var i = v/4;
Ext.MessageBox.updateProgress(i, Math.round(100*i)+'%');
}
  };
  };
  for(var i = 1; i < 6; i++){
setTimeout(f(i), i*500);
  }
}


------------------------------------------------------------------------------








// 刷新记录
function rsEmployee (){
vstore.load();
}


// 搜索记录
function searchEmployee (){
var keyword = Ext.getCmp("keyword").getValue(); 
Ext.Ajax.request({
url:'a_json.php',
params:{keyword:keyword,action:'search',start:'0'},
timeout:2000,
method:'GET',
success:function(){
vstore.load({
params:{keyword:keyword,action:'search',start:'0'}
});
}
});
}



-----------------------------------------------------------------------------------




// 批量删除
function removeEmployee (o){
var gird = o.ownerCt.ownerCt;
var data = grid.getSelectionModel().getSelection();
if (data.length == 0){
Ext.Msg.alert("提示","您最少要选择一条数据");
}else{
var ids = grid.getSelectionModel().getLastSelected();
var ids = [];
Ext.Array.each(data,function(record){
ids.push(record.get('id'));
});
Ext.Ajax.request({
url:'a_save.php',
params:{ids:ids.join(","),action:'del'},
method:'POST',
timeout:2000,
success:function(response,opts){
Ext.Msg.alert("提示", "已经删除");
vstore.load();
}
});
}
}




-----------------------------------------------------------------------------


// 双击查看修改
grid.on('itemdblclick',function(value,o){
var vid = o.raw.id;
myform.getForm().load({
url:'save.php',
params:{id:vid,action:'load'}
});
var FormWin = new Ext.Window ({
title: '查看详细',
modal: true,
width: 300,
maximizable: true,
closeAction:'hide',
bodyStyle:{<?=$background?>},
defaults: {
margin: 20
},
items:myform,
buttons: [{
text: '保存修改',
iconCls: 'iconSave',
// disabled: true, //判断是否有修改权限
handler: function(){
myform.getForm().submit({
url:'save.php',
params:{id:vid,action:'edit'},
success: function() {
Ext.Msg.alert("提示", "保存成功");
myform.form.reset();
FormWin.close();
vstore.load();
}
});
}
},{
text:'关闭窗口',
iconCls:'iconClose',
handler: function(){
FormWin.close();
}
}]
});
FormWin.show();
});

-----------------------------------------------------------------------------

// 添加记录
function addEmployee (){
var win = new Ext.Window ({
title: '添加账号',
width: 800,
modal: true,
closeAction:'hide',
bodyStyle:{<?=$background?>},
items:myform,
buttons: [{
text: '提交信息',
iconCls: 'iconSave',
handler: function(){
myform.getForm().submit({
url:'a_save.php',
params:{action:'add'},
success: function() {
Ext.Msg.alert("提示", "添加成功");
myform.form.reset();
win.close();
vstore.load();
}

});
}
},{
text:'取消',
iconCls:'iconClose',
handler: function(){
win.close();
}

}]

});
win.show();
}

-----------------------------------------------------------------------------------------

// 修改记录
function editEmployee (){
var data = grid.getSelectionModel().getSelection();
if (data.length == 0){
Ext.Msg.alert("提示","请选择一条数据");
}else{
var record = grid.getSelectionModel().getLastSelected();
var ids = record.get("id");
myform2.getForm().load({
url:'a_save.php',
params:{id:ids,action:'load'},
success: function() {
// Ext.Msg.alert("提示", "载入成功");
var admin_power = this.result.data.admin_power;
var power=admin_power.split("|");
for(var i=0;i<power.length;i++){
var p101=myform2.getForm().findField("p101");
if(p101.inputValue==power[i]){
p101.setValue(true);
}
var p102=myform2.getForm().findField("p102");
if(p102.inputValue==power[i]){
p102.setValue(true);
}
}

}
});


var win = new Ext.Window ({
title: '修改账号',
width: 700,
modal: true,
closeAction:'hide',
bodyStyle:{<?=$background?>},
items:myform2,
buttons: [{
text: '保存修改',
iconCls: 'iconSave',
handler: function(){
myform2.getForm().submit({
url:'a_save.php',
params:{id:ids,action:'editAll'},
success: function() {
Ext.Msg.alert("提示", "保存成功");
myform2.form.reset();
win.close();
vstore.load();
}
});
}
},{
text:'取消修改',
iconCls:'iconClose',
handler: function(){
myform2.form.reset();
win.close();
}
}]

});
win.show();
}
}


----------------------------------------------------------------------------------



// 用户资料
var myform = Ext.create('Ext.form.Panel', {
border: false,
headerPosition: 'top',
margin: 20,
items: [{
xtype: 'fieldset',
title: '基本信息',
defaultType: 'textfield',
defaults: {
margin: 10,
labelWidth: 60,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'user_username',
fieldLabel: '登陆账号',
regex:/^[a-zA-Z][a-zA-Z0-9_]{2,15}$/,
disabled: true
},{
xtype: 'textfield',
name: 'user_truename',
fieldLabel: '真实姓名',
disabled: true
},{
xtype: 'textfield',
name: 'user_tel',
fieldLabel: '联系电话'
},{
xtype: 'textfield',
name: 'user_mail',
fieldLabel: '电子邮件',
regex:/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
regexText:"格式不正确"
},{
xtype: 'checkboxgroup',
fieldLabel: '所有权限',
vertical: true,
allowBlank: false,
columns: [100,100],
items: [
{boxLabel: '系统管理', name:'admin_power[]',inputValue:'101'},
{boxLabel: '账号管理', name:'admin_power[]',inputValue:'102'}
]
}]
},{

border:false,
items:[{
xtype:'fieldset',
title: '修改密码 (不修改请留空)',
defaultType: 'textfield',
defaults: {
margin: 10,
labelWidth: 60,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'pw1',
fieldLabel: '填写新密',
inputType: 'password'
},{
xtype: 'textfield',
name: 'user_password',
fieldLabel: '重复新码',
inputType: 'password'
}]
}]
}]

});

---------------------------------------------------------------------------------


Ext .onReady(function() {




// 用户资料
var myform = Ext.create('Ext.form.Panel', {
border: false,
headerPosition: 'top',
margin: 20,
items: [{
xtype: 'fieldset',
title: '基本信息',
defaultType: 'textfield',
defaults: {
margin: 10,
labelWidth: 60,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'user_username',
fieldLabel: '登陆账号',
disabled: true
},{
xtype: 'textfield',
name: 'user_truename',
fieldLabel: '真实姓名',
disabled: true
},{
xtype: 'textfield',
name: 'user_tel',
fieldLabel: '联系电话'
},{
xtype: 'textfield',
name: 'user_mail',
fieldLabel: '电子邮件',
regex:/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
regexText:"格式不正确"
}]
},{

border:false,
items:[{
xtype:'fieldset',
title: '修改密码 (不修改请留空)',
defaultType: 'textfield',
defaults: {
margin: 10,
labelWidth: 60,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'pw1',
fieldLabel: '填写新密',
inputType: 'password'
},{
xtype: 'textfield',
name: 'user_password',
fieldLabel: '重复新码',
inputType: 'password'
}]
}]
}]

});


Ext.win = Ext.create('Ext.window.Window', {
title: '我的资料设置',
width: 400,
modal:true,
closeAction:'hide',
bodyStyle: {
background: '#fff'
},
items:myform,
buttons: [{
xtype:'button',
text: '保存修改',
iconCls: 'iconSave',
handler: function(){
myform.getForm().submit({
url:'user/save.php',
params:{id:'1',action:'edit'},
success: function() {
Ext.Msg.alert("提示", "修改成功");
Ext.win.close();
}
});
}
},{
xtype:'button',
text: '取消修改',
iconCls: 'iconClose',
handler: function(){
Ext.win.close();
}
}]
});


// 顶部分
var head = new Ext.Panel( {
id: 'app-header',
region: 'north',
contentEl: 'bgTop_red',
xtype: 'box',
html:'<div class="bg_top"></div>',
height: 120,
border:true,
bbar: [{
text: '返回主页',
iconCls: 'iconHome',
target:'_self',
href: 'index.html'
},'-',{
xtype: 'button',
text: '我的资料',
iconCls: 'iconSet',
handler: function(){
Ext.win.show();
}
},'-',{
text: '0 条新消息',
iconCls: 'iconMail'
},'-',{
text: '退出系统',
iconCls: 'iconExit',
target:'_self',
href: '../index.html'
},'->',{
text: DateString+cDateString,
iconCls: 'iconTime'
}]

});
    
    // 主内容
var mainTab = new Ext.Panel( {
region : 'center',
autoScroll: true,
margins:'5',
html:'<iframe src="main.html" width="100%" height="100%" frameborder="0" scrolling="auto" name="mainTab"></iframe>'


});

// 创建leftMenu部分
var leftmenu = new Ext.Panel( {
region:'west',
id:'west-panel',
title:'管理面版',
split:true,
width: 200,
minSize: 175,
maxSize: 400,
collapsible: true,
margins:'5 0 5 5',
cmargins:'5 5 5 5',
layout:'accordion',
layoutConfig:{
animate:true
},
items: [menu,Calendar]

});


// 布局
new Ext.Viewport ( {
layout : 'border',
items : [head, leftmenu, mainTab]
});
  
});  


-------------------------------------------------------------------------------




Ext .onReady(function() {


Ext.ImgWin = Ext.create('Ext.Window', {
title: '形象图片',
width: 645,
height: 430,
modal: true,
maximizable: true,
closeAction:'hide',
headerPosition: 'top',
layout: 'fit',
items: {
border: false,
html:'<img src="../../<?=$row[sys_photo]?>" width="645"/>'
}
});


// 上传图片
Ext.upImgWin = Ext.create('Ext.window.Window', {
title: '上传图片',
width: 300,
modal: true,
closeAction:'hide',
bodyStyle: {
background: '#fff'
},
items:[{
xtype:'form',
id:'upImgForm',
border: false,
margin: 20,
items: [{
labelWidth: 60,
anchor: '100%',
xtype: 'filefield',
emptyText: '上传图片...',
buttonText:'浏览选择',
name:'upfile',
buttonConfig: {
iconCls: 'iconImg'
}
}]
}],
buttons: [{
text: '上传图片',
iconCls: 'iconSave',
handler: function() { 
if (Ext.getCmp("upImgForm").getForm().isValid()) {  
Ext.getCmp("upImgForm").getForm().submit({ 
url:'../../upfile.php', 
waitMsg: '正在上传,请等待...',
success: function(fp, o) {
// Ext.Msg.alert('成功',
// o.result.path);
Ext.Msg.alert('成功', "保存才能生效喔");
var upfile_url = o.result.path;
myform.form.setValues({sys_photo:upfile_url});
Ext.upImgWin.close();
},
failure: function(fp, o) {
Ext.Msg.alert('失败', o.result.msg);
}
});  


}]
});


// 上传文件
Ext.upFileWin = Ext.create('Ext.window.Window', {
title: '上传文件',
width: 300,
modal: true,
closeAction:'hide',
bodyStyle:{<?=$background?>},
items:[{
xtype:'form',
id:'upFileForm',
border: false,
margin: 20,
items: [{
labelWidth: 60,
anchor: '100%',
xtype: 'filefield',
emptyText: '上传文件...',
buttonText:'浏览选择',
name:'upfile',
buttonConfig: {
iconCls: 'iconImg'
}
}]
}],
buttons: [{
text: '上传文件',
iconCls: 'iconSave',
handler: function() { 
if (Ext.getCmp("upFileForm").getForm().isValid()) {  
Ext.getCmp("upFileForm").getForm().submit({ 
url:'../../upfile.php', 
waitMsg: '正在上传,请等待...',
success: function(fp, o) {
Ext.Msg.alert('成功', o.result.path);
var upfile_url = o.result.path;
myform.form.setValues({news_url:upfile_url});
Ext.upFileWin.close();
},
failure: function(fp, o) {
Ext.Msg.alert('失败', o.result.msg);
}
});  


}]
});

// 基本资料
var myform = Ext.create('Ext.form.Panel', {
border: false,
headerPosition: 'top',
margin: 20,
items: [{
xtype: 'fieldset',
title: '基本信息',
defaults: {
margin: 10,
labelWidth: 60,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'sys_companyname',
fieldLabel: '公司名称',
value:'<?=$row[sys_companyname]?>'
},{
xtype: 'htmleditor',
name: 'sys_content',
fieldLabel: '园区简介',
value:'<?=rep_cx($row[sys_content])?>'.replace(/(&gt;|&lt;)/ig,function(s){return s=="&lt;"?"<":">"})
},{
layout:'column',
id:'upFileBox',
border: false,
items :[{
columnWidth: 0.5,
xtype: 'textfield',
labelWidth: 60,
name: 'news_url',
fieldLabel: '文件地址'
},{
xtype:'button',
text: '上传文件',
style:'margin-left:5px',
iconCls: 'iconImg',
handler: function(){
Ext.upFileWin.show();
}
}]
},{
layout:'column',
id:'upFileBox',
border: false,
items :[{
// columnWidth: '.7',
xtype: 'textfield',
labelWidth: 60,
name: 'sys_photo',
fieldLabel: '图片地址',
value:'<?=$row[sys_photo]?>'
},{
xtype:'button',
text: '查看现图',
style:'margin-left:5px',
iconCls: 'iconSearch',
handler: function(){
Ext.ImgWin.show();
}
},{
xtype:'button',
text: '更换图片',
style:'margin-left:5px',
iconCls: 'iconImg',
handler: function(){
Ext.upImgWin.show();
}
}]
}]
},{
xtype: 'fieldset',
title: '联系方式',
defaults: {
margin: 10,
labelWidth: 60,
anchor: '100%'
},
items: [{
xtype: 'radiogroup',
fieldLabel: '性  别',
vertical: true,
allowBlank: false,
columns: [60,60],
items: [
{ boxLabel: '先生', name: 'sys_sex', inputValue: '先生'<? if ($row[sys_sex]=='先生'){ echo ", checked: true";} ?>},
{ boxLabel: '女士', name: 'sys_sex', inputValue: '女士'<? if ($row[sys_sex]=='女士'){ echo ", checked: true";} ?>}
]
},{
xtype: 'textfield',
name: 'sys_tel',
fieldLabel: '联系电话',
value:'<?=$row[sys_tel]?>'
}]
}]

});


    // 主内容
var mainTab = new Ext.Panel( {
title:'修改资料',
region : 'center',
autoScroll: true,
margins:'2',
items:myform,
buttons: [{
text: '保存信息',
iconCls: 'iconSave',
handler: function(){
myform.getForm().submit({
url:'save.php',
params:{id:'1',action:'systemSet'},
success: function() {
Ext.Msg.alert("提示", "保存成功");
}
});
}
}]


});

// 布局
new Ext.Viewport ( {
layout : 'border',
items : [mainTab]
});


});




-----------------------------------------------------------------------------------






// 建模型
Ext.define('Data', {
extend: 'Ext.data.Model',
fields: ['Field_1', 'Field_2', 'Field_3','Field_4','Field_5','Field_6','Field_7']
});

// 代理
var vstore = Ext.create('Ext.data.Store', {
model: 'Data',
pageSize:20,
proxy: {
type: 'ajax',
url : 'json.php', // 下面新建文件
reader:{
type:'json',
            root: 'lists',
totalProperty:'rowCount'
}
}
});

*************************************************


// json.php 代码
{rowCount:23,lists:[
{
Field_1:'1',
Field_2:'张三',
Field_3:'13823298685',
Field_4:'0752-2063555',
Field_5:'广东省广州市',
Field_6:'天河区',
Field_7:'2012-06-15 11:55:46'
},{
Field_1:'2',
Field_2:'高兴',
Field_3:'18665260707',
Field_4:'0752-2666653',
Field_5:'广东省惠州市江北金泽国际物流园',
Field_6:'惠城区',
Field_7:'2012-06-15 11:55:46'
}
]}


**************************************************


    // 创建表格
    var grid = Ext.create("Ext.grid.GridPanel",{
        store: vstore,
border: false,
// selType:'checkboxmodel',
// multiSelect:true,
        columns: [{
text: 'ID',
                dataIndex: 'Field_1',
width: 40
            },{
                text: '姓名',
                dataIndex: 'Field_2',
flex: 1
            },{
                text: '电话',
                dataIndex: 'Field_3',
flex: 1
            },{
                text: '传真',
                dataIndex: 'Field_4',
flex: 1
            },{
                text: '地址',
                dataIndex: 'Field_5',
flex: 1
            },{
                text: '区域',
                dataIndex: 'Field_6',
flex: 1
},{
                text: '记录时间',
                dataIndex: 'Field_7',
flex: 1
},{
xtype: 'actioncolumn',
width: 25,
icon   : '../../images/iconShow.png',
tooltip: '查看',
handler: function(ID, Field_1) {
var rec = vstore.getAt(Field_1);
window.location.href="show.php?id="+rec.get('Field_1'); 
}
},{
xtype: 'actioncolumn',
width: 25,
icon   : '../../images/iconDel.png',
tooltip: '删除',
handler: function(ID, id) {
Ext.MessageBox.confirm('提示', '确认删除数据吗?', showResult);
function showResult(btn){  
if (btn == 'yes'){   
var rec = vstore.getAt(id);
Ext.Ajax.request({
url:'save.php',
params:{id:rec.get('id'),action:'del'},
method:'POST',
timeout:2000,
success:function(response,opts){
Ext.Msg.alert("提示", "删除成功");
vstore.load();
}
});

};   
}
        }]
    });
    vstore.load();


Ext.onReady(function() {


        
    // 主内容部分
var mainTab = new Ext.Panel( {
title:'返品单列表',
iconCls: 'iconList',
                region:'center',
autoScroll:true,
                margins:'2',
tbar:[
{text:'新增记录',iconCls:'iconAdd',handler:addEmployee},
{text:'更新列表',iconCls:'iconRs',handler:rsEmployee},
'->',
{
width: 200,
labelWidth: 50,
id:'keyword',
fieldLabel: 'Search',
allowBlank: false,
selectOnFocus: true,
xtype: 'textfield'
},
{text:'查找',iconCls:'iconSearch',handler:searchEmployee}
],
items: {
border: false,
items: grid
},
bbar: new Ext.PagingToolbar({
store: vstore,
displayInfo:true
})
});

// 页面布局
new Ext.Viewport ({
layout : 'border',
items : [mainTab]
});

});
-----------------------------------------------------------------------------------
// 选项卡


Ext .onReady(function() {




    // 实名企业查询
var CompanyTab = new Ext.Panel( {
                region:'center',
autoScroll:true,
                margin:10,
items: {
border: false,
items: grid
}
}).hide();

        
    // 主内容部分
var mainTab = Ext.create('Ext.tab.Panel', {
                region:'center',
                margins:'2',
activeTab: 0, 
items: [{
title   : '实名企业查询',
iconCls: 'iconHome',
border: false,
items:[{
border: false,
headerPosition: 'top',
margin: 5,
layout:'column',
bodyStyle: {
background: '#fff'
},
defaults:{
margin:5,
columnWidth: 1/2,
},
buttonAlign : 'center',
items: [{
xtype: 'fieldset',
padding:'10',
defaults: {
labelWidth: 80,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'Field_2',
fieldLabel: '企业名称'
},{
xtype: 'textfield',
name: 'Field_3',
fieldLabel: '注册地址'
}]
},{

xtype: 'fieldset',
padding:'10',
defaults: {
labelWidth: 80,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'Field_5',
fieldLabel: '营业执照'
},{
xtype: 'textfield',
name: 'Field_6',
fieldLabel: '组织代码'
}]

}],
buttons: [{
text:'搜索查找',
iconCls:'iconSearch',
handler: function(){
CompanyTab.show();
}
}]

},CompanyTab]


},{
title: '运输车辆查询',
iconCls: 'iconCar',
width:'100%',
height:'100%',
layout: 'fit',
border: false,
html:'正在载入数据...'
},{
title: '物流操作员查询',
iconCls: 'iconUser',
width:'100%',
height:'100%',
layout: 'fit',
border: false,
html:'正在载入数据...'
}]
});

// 创建布局
var viewport = Ext.create('Ext.Viewport', {
layout : 'border',
items : [mainTab]
});
  
});   


----------------------------------------------------------------
// 树


/*
 * tree.php的内容 [ { checked:false, id:'1', text:'童装系列', children:[
 * {checked:false,id:'11',text:'童衫',leaf:true},
 * {checked:false,id:'12',text:'童鞋',leaf:true} ] },{ checked:false, id:'2',
 * text:'女装系列', children:[ {checked:false,id:'21',text:'连衣裙',leaf:true},
 * {checked:false,id:'22',text:'短裤/短裙',leaf:true} ] },{ checked:false, id:'3',
 * text:'男装系列', children:[ {checked:false,id:'31',text:'男裤',leaf:true},
 * {checked:false,id:'32',text:'衫衣',leaf:true} ] } ]
 */


Ext.onReady(function() {


    Ext.QuickTips.init();


// 分类设置 - 代理树
    var Tstore = Ext.create('Ext.data.TreeStore', {
        proxy: {
            type: 'ajax',
            url: 'tree.php'
        },
        root: {
            text: '根目录',
            id: '0',
            expanded: true
        },
        folderSort: true,
        sorters: [{
            property: 'id',
            direction: 'ASC'
        }]
    });

// 分类设置 - 种树
    var tree = Ext.create('Ext.tree.Panel', {
        store: Tstore,
rootVisible:true,// 设为false将隐藏根节点,
        viewConfig: {
            plugins: {
                ptype: 'treeviewdragdrop',
appendOnly:true
            },
listeners:{
drop:function ( node, data, overModel, dropPosition, options){
Ext.Ajax.request({
url:'save.php',
params:{id:data.records[0].get('id'),fjid:overModel.get('id'),action:'moveCate'},
method:'POST',
success:function(response,opts){
Ext.Msg.alert("提示", data.records[0].get('text')+" >> 成功移动到 >> "+overModel.get('text'));
vstore.load();
}
});
}
}
        },
        height: '100%',
border: false,
        useArrows: true,
tbar:[{


text: '增加',
id:'cateAdd',
iconCls:'iconAdd',
handler: function(){


var nodes = tree.getChecked();
if (nodes.length==1){
var node = nodes[0];
var nodeid = node.get("id");
}else{
var nodeid = 0;
}


// 添加分类
var addCateWin = new Ext.Window ({
title: '添加分类',
modal: true,
width: 200,
closeAction:'hide',
items:[{
id:'addCateForm',
xtype:'form',
border:false,
items: [{
xtype: 'textfield',
name: 'hpfl_flmc',
margin: 10,
anchor: '100%',
allowBlank: false
}]
}],
buttons: [{
text: '保存分类',
iconCls: 'iconSave',
handler: function(){
Ext.getCmp("addCateForm").getForm().submit({
url:'save.php',
params:{id:nodeid,action:'addCate'},
success: function() {
Ext.Msg.alert("提示", "添加成功");
Ext.getCmp("addCateForm").form.reset();
addCateWin.close();
Tstore.load();
}
});
}
}]
});
addCateWin.show();
}
},{
text: '修改',
id:'cateEdit',
iconCls:'iconEdit',
handler: function(){

var nodes = tree.getChecked();
if (nodes.length==1){
var node = nodes[0];
var nodeid = node.get("id");
var nodetext = node.get("text");

// 修改分类
var editCateWin = new Ext.Window ({
title: '修改分类',
modal: true,
width: 200,
closeAction:'hide',
items:[{
id:'editCateForm',
xtype:'form',
border:false,
items: [{
xtype: 'textfield',
name: 'hpfl_flmc',
margin: 10,
anchor: '100%',
value:nodetext,
allowBlank: false
}]
}],
buttons: [{
text: '保存分类',
iconCls: 'iconSave',
handler: function(){
Ext.getCmp("editCateForm").getForm().submit({
url:'save.php',
params:{id:nodeid,action:'editCate'},
success: function() {
Ext.Msg.alert("提示", "修改成功");
Ext.getCmp("editCateForm").form.reset();
editCateWin.close();
Tstore.load();
}
});
}
}]
});
editCateWin.show();

}else{
Ext.Msg.alert("提示", "请选择一个节点");
}

}
},{
text: '删除',
id:'cateDel',
iconCls:'iconDel',
handler: function(){
var nodes = tree.getChecked();
if (nodes.length==0){
Ext.Msg.alert("提示", "请选择节点");
}else{
var nodeArray=[];
Ext.Array.each(nodes,function(record){
nodeArray.push(record.get('id'));
});

var nodeid=nodeArray.join(",");

Ext.Ajax.request({
url:'save.php',
params:{ids:nodeid,action:'delCate'},
callback:function(){
Ext.Msg.alert("提示", "已经删除");
Tstore.load();
}
});
}
}


},{
text: '展开',
id:'expand',
iconCls:'iconExpand',
handler: function(){
   tree.expandAll();
var e = Ext.getCmp("expand");
if (e) {
e.hide();
}
var o = Ext.getCmp("collapse");
if (o) {
o.show();
}
}
},{
text: '收回',
id:'collapse',
iconCls:'iconCollapse',
handler: function(){
   tree.collapseAll();
var c = Ext.getCmp("collapse");
if (c) {
c.hide();
}
var e = Ext.getCmp("expand");
if (e) {
e.show();
}
}
}]
    });

// 分类设置 - 载入树
var mainTab = new Ext.Panel( {
region:'center',
id:'tree-cate',
title:'分类设置',
margins:'2',
iconCls:'iconGroup',
items: [tree]
});

Ext.getCmp("expand").hide();

// 页面布局
new Ext.Viewport ({
layout : 'border',
items : [mainTab]
});

});


------------------------------------------------------------------
// combobox下拉选择例子


// 加载的数据格式
var store_data = Ext.create('Ext.data.Store', {
fields: ['Id', 'Name'],
data : [
{'Id':'1', 'Name':'aaa'},
{'Id':'2', 'Name':'bbb'}
]
});


// form里的使用方法
items: [{
xtype: 'combobox',
id:'item_cate',
name: 'bm_id',
typeAhead: true,
fieldLabel: '所属部门',
allowBlank: false,
store: store_data,
queryMode: 'local',
displayField: 'Name',
valueField: 'Id',
emptyText: '请选择所属部门...',
listeners:{
select:function (){
var c =Ext.getCmp('item_cate').getValue();
alert(c);
}
}
}]

-----------------------------------------------------------


layout:'column',
defaults:{
margin:5,
columnWidth: 1/2,
},
items: [{
xtype: 'fieldset',
padding:'10',
defaults: {
labelWidth: 80,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'Field_2',
fieldLabel: '企业名称'
},{
xtype: 'textfield',
name: 'Field_3',
fieldLabel: '注册地址'
}]
},{


xtype: 'fieldset',
padding:'10',
defaults: {
labelWidth: 80,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'Field_5',
fieldLabel: '营业执照'
},{
xtype: 'textfield',
name: 'Field_6',
fieldLabel: '组织代码'
}]


}]

---------------------------------------------------------------


defaults: {
flex: 1,
margin: 5,
border: false,
layout: 'anchor'
},
layout: 'hbox',
items: [{
defaults: {
margin: 5,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'xsd_bz',
fieldLabel: '111111111111'
}]
},{
defaults: {
margin: 5,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'xsd_zjs',
fieldLabel: '2222222222222'
}]
},{
defaults: {
margin: 5,
anchor: '100%'
},
items: [{
xtype: 'textfield',
name: 'xsd_zjs',
fieldLabel: '333333333333'
}]
}]


-------------------------------------------


动态控制actioncolumn
getClass: function(v, meta, record) { 
    if (record.get('xsd_sfsdcgd') == 1) {
        return this.disabledCls;
    } 
 },
handler: function(ID, id) {
var rec = vstore.getAt(id);
if (rec.get('xsd_sfsdcgd') == 1) {
Ext.Msg.alert("提示", "已生成采购单的销售单不能修改!");
      }else{
      var url="show.php?id="+rec.get('Field_1');
window.open(url);
      }  
}
 loadMask: false,
 
 // 异步验证
 xtype: 'textfield',
name: 'hp_bm',
id:'hp_bm',
fieldLabel: '货品编码',
textValid:true,
vtype: 'checkBm',
validateOnBlur: true,
validateOnChange:false
 
 Ext.apply(Ext.form.field.VTypes, {
 checkBm: function(val, field) {
  Ext.Ajax.request({
url:'save.php',
params:{bm:val,action:'checkBm'},
method:'POST',
timeout:2000,
success:function(response,opts){
var text = response.responseText;
if('1'==text){
isPersonNameOK = true;
           Ext.getCmp('hp_bm').clearInvalid();
} else {
isPersonNameOK= false;
Ext.getCmp('hp_bm').markInvalid('货品编码已经存在!');
}
}
});
return isPersonNameOK;
 },
 checkBmText: '货品编码已经存在!'
});




combox store ajax代理默认选中:
,
listeners: {
load : function(combo) {
if(Store_xsj.getAt(0)){
var firstValue = Store_xsj.getAt(0).get("hp_xsj");
       Ext.getCmp("hp_yj").setValue(firstValue);
}else{
Ext.getCmp("hp_yj").setValue(0);
}        
     }
}


$list = array ();
while ( $row = mysql_fetch_assoc ( $query ) ) {
if (! isset ( $list [$row ['mk_fmkid']] )) {
$list [$row ['mk_fmkid']] = array ();
}
$list [$row ['mk_fmkid']] [$row ['mk_id']] = $row;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值