| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- /**
- * Created by zhouy on 2018/10/18.
- */
- Ext.define('KitchenSink.view.binding.ChildForm', {
- extend: 'Ext.window.Window',
- xtype: 'document-kind-childwin',
- layout: 'fit',
- modal: true,
- width: 400,
- //工具类
- FormUtil: Ext.create('saas.util.FormUtil'),
- BaseUtil: Ext.create('saas.util.BaseUtil'),
- height: 220,
- listeners:{
- show:function(w){
- if(w.record){
- w.down('form').loadRecord(w.record);
- }
- }
- },
- initComponent:function(){
- var me=this;
- Ext.apply(me,{
- items:me.setFormItems()
- });
- me.callParent();
- },
- etc:{
- customerkind:{
- items:[{
- xtype:'hidden',
- name:'ck_id'
- },{
- xtype:'textfield',
- name:'ck_kind',
- allowBlank:false,
- fieldLabel:'类型'
- }],
- keyField:'ck_id',
- saveUrl:''
- },
- vendorkind:{
- items:[{
- xtype:'hidden',
- name:'id'
- },{
- xtype:'textfield',
- name:'vk_name',
- allowBlank:false,
- fieldLabel:'类型'
- }],
- },
- productkind:{
- items:[{
- xtype:'hidden',
- name:'pk_id'
- },{
- xtype:'textfield',
- name:'pk_kind',
- allowBlank:false,
- fieldLabel:'类型'
- }],
- },
- inoutkind:{
- }
- },
- setFormItems:function() {
- var me = this, kind = me.dataKind;
- var conf = {
- xtype: 'form',
- bodyPadding: 10,
- border: false,
- modelValidation: true,
- layout: {
- type: 'vbox',
- align: 'stretch'
- },
- defaults: {
- xtype: 'textfield'
- },
- buttons: [{
- text: '保存',
- formBind:true,
- handler: me.onSave,
- scope:me
- }, {
- text: '取消',
- handler: me.onCancel,
- scope:me
- }]
- };
- return Ext.apply(conf, me.etc[kind]);
- },
- onSave:function(){
- var belong = this.belong;
- var form=this.down('form');
- var dataField = form.down('[name='+belong.dataField+']');
- if(!dataField.value){
- Ext.Msg.alert('提示','数据有误');
- return false;
- }
- var keyField = form.down('[name='+belong.keyField+']');
- //保存接口
- var params = {};
- params[belong.dataField] = dataField.value;
- params[belong.keyField] = keyField.value || 0;
- this.BaseUtil.request({
- url: belong.reqUrl,
- params: JSON.stringify(params),
- method: 'POST',
- })
- .then(function(res) {
- var localJson = new Ext.decode(res.responseText);
- if(localJson.success){
- Ext.Msg.alert('提示','保存成功');
- var grid = form.ownerCt._parent.lookup('document-kind-Grid');
- grid.store.load();
- form.ownerCt.close();
- }
- })
- .catch(function() {
- Ext.Msg.alert('提示','保存失败');
- });
- },
- onCancel:function(){
- this.hide();
- }
- });
|