2022年12月7日 星期三

V120501– 顯示子畫面 - [新增領用登記] - Form - 子視窗

目的: V120501– 開啟子視窗 - [新增領用登記]  - Form

處理說明: 1>開啟子視窗 - 
                       var win = getMyWindow("新增領用登記", J_formFields_Sub1mySub1_Btns);        
                  2>定義子視窗_button
                      var mySub1_Btns = [
                         {
                            xtype: 'button', text: '確定', id: 'OkBtn_mySub1',
                           listeners: {
                               click: function () {  ..  }
                           
                  3>定義子視窗_欄位
                      var J_formFields_Sub1 = [
                  {
                           bodyStyle: "background-color:transparent;", border: false, layout: "vbox", padding: "5", items: [
                  {        



1>*.js

 //按鈕 : [新增領用登記] [掃描登記][查詢領用記錄]
    var BtnAry = [
        {
            xtype: 'button', text: '新增領用登記', id: 'UseRegBtn',
            listeners: {
                click: function () {
                    AddRegBtn_click();                    
                }
            }
        },

//新增 [新增領用登記]鈕    
    function AddRegBtn_click() {
        console.log(" 1 inside - AddRegBtn_Click 新增領用登記: ");
        //1>檢核資料是否正確 - 是否有選擇資料        
        var cur_recs = Ext.getCmp('grid_Single').getSelectionModel().getSelection(); //grid select指向選擇的第一筆        
        var cur_rec = cur_recs[0];
        console.log("cur_rec[raw][QTY]:", cur_rec["raw"]["QTY"]);
        var np1 = {};
        np1["CPNO"] = cur_rec["raw"]["CPNO"];
        np1["MATNR"] = cur_rec["raw"]["MATNR"];
        np1["WH"] = cur_rec["raw"]["WH"];
        np1["SP"] = cur_rec["raw"]["SP"];        
        np1["QTY"] = cur_rec["raw"]["QTY"];
        np1["RQTY"] = cur_rec["raw"]["RQTY"];
        np1["UNIT"] = cur_rec["raw"]["UNIT"];
        np1["CHARG"] = cur_rec["raw"]["CHARG"];        
        np1["NOTE"] = cur_rec["raw"]["NOTE"];
        np1["COMPER"] = loginInfo.id;        
        np1["PQTY"] = "";
        //2>顯示子畫面 - [新增領用登記]
        var mySub1_Btns = [
            {
                xtype: 'button', text: '確定', id: 'OkBtn_mySub1',
                listeners: {
                    click: function () {
                        //1>更新資料庫資料(AMM_COMPQTY)
                        var Tmp_Str = "";
                        if (checkisnull(Ext.getCmp("sub1_PQTY").getValue())){
                            Tmp_Str = "領用數量不可空白<br>"
                                            + " 敬請檢核 !!";
                            mywarnalert(Tmp_Str);
                            return;
                        }
                        if (Number(Ext.getCmp("sub1_PQTY").getValue()) > Number(Ext.getCmp("sub1_RQTY").getValue())) {
                            Tmp_Str = "領用數量(" + Ext.getCmp("sub1_PQTY").getValue() + ")不可大於剩餘數量(" + Ext.getCmp("sub1_RQTY").getValue() + ")<br>"
                                + " 敬請檢核 !!";
                            mywarnalert(Tmp_Str);
                            return;
                        }
                        np1["PQTY"] = Ext.getCmp("sub1_PQTY").getValue();
                        np1["SAPNO"] = Ext.getCmp("sub1_SAPNO").getValue();
                        np1["NOTE"] = Ext.getCmp("sub1_NOTE").getValue();
                        np1["COMPER"] = Ext.getCmp("sub1_COMPER").getValue();
                        np1["COMPDT"] = cnow();                      
                        Ext.Ajax.request({
                            method: 'POST',
                            params: np1,
                            async: false, //將非同步功能關閉
                            url: '../../api/V120501API/Add_AMMCOMPQTY_1',
                            success: function (response, opts) {
                                var obj = Ext.decode(response.responseText);
                                var Tmp_Str = obj["Rtn_Msg"];
                                var Tmp_success = obj["success"];
                                if (Tmp_success) {
                                    Tmp_Str = "[新增領用登記]成功 !!<br>"
                                                    + Tmp_Str;
                                    mysuccessalert(Tmp_Str);                                    
                                }
                                else {
                                    Tmp_Str = "[新增領用登記]失敗 !! <BR> "
                                                     + Tmp_Str;
                                    mywarnalert(Tmp_Str);                                    
                                }
                            },
                            failure: function (response, opts) {
                                var obj = Ext.decode(response.responseText);
                                var Tmp_Str = obj["Rtn_Msg"];
                                Tmp_Str = "[新增領用登記]失敗 !!<br>"                                    
                                                + Tmp_Str;
                                mywarnalert(Tmp_Str);                                
                                return;
                            }
                        });  // end of  Ext.Ajax.Request  for Email
                        //2> close windows
                        this.up("window").close();
                        this.up("window").destroy();
                        //3>重新更新 MDBGrid
                        Ext.getCmp("btn_Show").fireHandler();                        
                    }
                }
            },
            {
                xtype: 'button', text: '取消', id: 'CancelBtn_mySub1',
                listeners: {
                    click: function () {
                        this.up("window").close();
                        this.up("window").destroy();
                    }
                }
            },
        ];
        
        var win = getMyWindow("新增領用登記", J_formFields_Sub1, mySub1_Btns);        
        win.onshow = Sub1_onShow(np1);
        win.width = 600;
        win.height = 450;        
        win.show();
    };

2>V120201_json.js  -  子畫面欄位
// [新增領用登記]鈕  
var J_formFields_Sub1 = [
{
bodyStyle: "background-color:transparent;", border: false, layout: "vbox", padding: "5", items: [
{
xtype: "fieldcontainer", fieldLabel: "編號", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_CPNO", name: "sub1_CPNO", xtype: "textfield", width: 100, padding: "0 4 0 0", readOnly: true, fieldCls: "readonly", },
]
},  //end of 編號
{
xtype: "fieldcontainer", fieldLabel: "件號", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_MATNR", name: "sub1_MATNR", xtype: "textfield", width: 100, padding: "0 4 0 0", readOnly: true, fieldCls: "readonly", },
]
},   // end of 件號
{
xtype: "fieldcontainer", fieldLabel: "庫房", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_WH", name: "sub1_WH", xtype: "textfield", width: 100, padding: "0 4 0 0", readOnly: true, fieldCls: "readonly", },
]
}, // end of 庫房
{
xtype: "fieldcontainer", fieldLabel: "數量", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_QTY", name: "sub1_QTY", xtype: "textfield", width: 100, padding: "0 4 0 0", readOnly: true, fieldCls: "readonly",},
]
},  // end of 數量
{
xtype: "fieldcontainer", fieldLabel: "剩餘數量", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_RQTY", name: "sub1_RQTY", xtype: "textfield", width: 100, padding: "0 4 0 0", readOnly: true, fieldCls: "readonly", },
]
},  // end of 剩餘數量
{
xtype: "fieldcontainer", fieldLabel: "單位", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_UNIT", name: "sub1_UNIT", xtype: "textfield", width: 100, padding: "0 4 0 0", readOnly: true,fieldCls: "readonly", },
]
}, // end of 單位
{
xtype: "fieldcontainer", fieldLabel: "批次", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_CHARG", name: "sub1_CHARG", xtype: "textfield", width: 100, padding: "0 4 0 0", readOnly: true, fieldCls: "readonly", },
] // end of 批次.items
}, // end of 批次
{
xtype: "fieldcontainer", fieldLabel: "儲存位置", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_SP", name: "sub1_SP", xtype: "textfield", width: 100, padding: "0 4 0 0", readOnly: true, fieldCls: "readonly", },
]
}, // end of 儲存位置
{
xtype: "fieldcontainer", fieldLabel: "領用數量", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_PQTY", name: "sub1_PQTY", xtype: "textfield", width: 100, padding: "0 4 0 0", fieldCls: "required",  },
]
}, // end of 領用數量
{
xtype: "fieldcontainer", fieldLabel: "領用人員", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_COMPER", name: "sub1_COMPER", xtype: "textfield", width: 100, padding: "0 4 0 0", fieldCls: "required", },
{ id: "sub1_COMPER_", name: "sub1_COMPER_", xtype: "textfield", width: 100, padding: "0 4 0 0", fieldCls: "readonly", },
{
id: "btn_sub1_COMPER", name: "btn_sub1_COMPER", xtype: "button", text: "...",
//員工編號挑選 , TreeView 挑選    
handler: function () {
console.log(" btn_sub1_COMPER on click");
var treepanel = Ext.create('EmployeeTree', {
id: 'myEmployeeTree',
listeners: {
itemclick: function (view, record, item, index, e) {
if (record.raw.leaf) {
var info = record.raw.text;
var newStr = info.split(":");
Ext.getCmp('sub1_COMPER').setValue(newStr[0]);
Ext.getCmp('sub1_COMPER_').setValue(newStr[1]);
win_tree.close();
}
}
}
});
var win_tree = getWindow('領用人員挑選', treepanel);
win_tree.height = 400;
win_tree.show();
} // end of handler of  btn_sub1_comper
},
]
}, // end of 領用人員
{
xtype: "fieldcontainer", fieldLabel: "領用工號", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_SAPNO", name: "sub1_SAPNO", xtype: "textfield", width: 100, padding: "0 4 0 0",  },
]
}, // end of 領用工號
{
xtype: "fieldcontainer", fieldLabel: "備註(使用架次)", labelWidth: 100, layout: "hbox", items: [
{ id: "sub1_NOTE", name: "sub1_NOTE", xtype: "textarea", width: 200, padding: "0 4 0 0",  },
]
}, // end of 備註
] // end of   layout: "vbox", padding: "5", items: [
}  //end of  J_formFields_Sub1 , items[{
]      //end of  J_formFields_Sub1 , items[

沒有留言:

張貼留言