ext 编辑form 多文件上传 显示图片

  var storeAttach = Ext.create('Ext.data.Store', {
                autoLoad: false,
                model: 'Tgoodsimage',
                proxy: {
                    type: 'ajax',
                    url: '<%=basePath%>goods/goods!goodsAttach.do',
                    reader: { type: 'json', root: 'dataList' }
                    
                },
                listeners: {
                    load: function (store, options) {
                    	
                    	  var fieldset =  {
                                  // Fieldset in Column 1 - collapsible via toggle button
                                  xtype:'fieldset',
                                  columnWidth: 0.5,
                                  title: '附属图片',
                                  collapsible: true,
                                  defaultType: 'textfield',
                                  defaults: {anchor: '100%'},
                                  layout: 'anchor',
                               //   items :[field ]
                                 items :[ ]
//                                   items :[field, {  
//                                   	 fieldLabel : "预览图片", 
//                                       xtype: 'box', //或者xtype: 'component',  
                                     
//                                       autoEl: {  
//                                           width: 300, //图片宽度  
//                                           tag: 'img',    //指定为img标签  
  <%--                                         src: '<%=basePath%>upload'+record.get('filePath')    //指定url路径   --%>
//                                       }  
//                                   } ]
                              }
                    	  
                    	 if(store.getCount()>0){
                    		 for(var i=0;i<store.getCount();i++){  
                                 var record = store.getAt(i);  
                                 
                                 var field=  {
                                     	margin:'10px',
                                         xtype: 'fieldcontainer',
                                         layout: { type: 'hbox' },
                                         fieldDefaults: { labelAlign: 'right', labelWidth: 90, width: 290 },
                                         //items: [inventoryField ]
                                         items: [ {
                                         	
                                         	
                                         }, {
                                             xtype: 'filefield',
                                           //  name: 'attach['+i+']',
                                             name: 'attach',
                                             fieldLabel: '图片',
                                             allowBlank: ((action == 'update') ? true : false),
                                             anchor: '100%',
                                             buttonText: '选择图片',
                                             emptyText: '--请选择图片--',
                                             value:record.get('filePath')
                                         },{  
                                             xtype : 'button',  
                                             text : '删除',  
                                             iconCls : 'silk_page_add',  
                                             handler : function(button ) {  
                                             
                                             	 Ext.Ajax.request({
                                          			url: '<%=basePath%>goods/goods!delAttach.do',
                                          			method: 'post',
                                          			async: true,
                                          			params: { attachId: record.get('id') },
                                          			success: function(response){
                                          				var result = Ext.decode(response.responseText);
                                          				if(result.success){
                                          					alert(result.msg);
    	                                     				button .up('fieldset').remove(button.up('fieldcontainer'));
                                          				}else{
                                          					alert(result.msg);
                                          				}
                                          			}
                                          		});
                                             }  
                                         },{  
                                         	xtype:'panel', 
                                         	
                                         	height:60,
                                            // margin-left: 100,
                                         	html:'<img style=" width: 100;" src="<%=basePath%>upload'+record.get('filePath')+'"/>' 
                                         	   
                                         	
                                         }  ]
                                     };
                                 
                                 fieldset.items.push(field);
                                 
                                 imgCount++;
//                                   console.log(field);
//                          		field.down('[name^=attach]').setValue(record.get('filePath'));
                             }
                    		 var _form = formPanel;
                       		  _form.add(fieldset);
                    	 } 
                    	        
                    	 
//                         var type = store.getAt(0).data['data.type'];
//                         cboType.setValue(storeType.getAt(type-1));
                    }
                }
        	});

 



 待完善:修改附属图片时候,会全部删除附属图片。原因就是,无法在修改图片的时候,传相应的ID到后台,从而不知道是修改的哪张图片。

怎么才能传ID到后台?

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值