顯示具有 RadioGroup 標籤的文章。 顯示所有文章
顯示具有 RadioGroup 標籤的文章。 顯示所有文章

2023年10月10日 星期二

V120602E – 取得/設定RadioGroup欄位值(Ext.getCmp("sub_PRN").getValue()) 為 Object {sub_PRN: ‘A’} - V20305

目的: V120602E –取得/設定RadioGroup欄位值(Ext.getCmp("sub_PRN").getValue())為Object {sub_PRN: ‘A’} 

處理說明: 1>前端 RadioGroup欄位值(Ext.getCmp("sub_PRN").getValue())為Object

                  2>前端取得 RadioGroup欄位值必需 Object.sub_PRN

                  3>設定 RadioGroup checked
                      Ext.getCmp("s_STAUOCD").items.items[2].setValue(true); 


 1>*.js
        //更新單況   
                    var Tmp_url = "";
                        var np1 = {};
                    np1["sub_PRE_DATE"] = Ext.getCmp("sub_PRE_DATE").getValue();                        
                    np1["sub_PRN"] = (Ext.getCmp("sub_PRN").getValue()).sub_PRN;                        
                    if (np1["sub_PRN"] == 'A')  ////列印 & 儲存目前 QDR現況
                        Tmp_url = '../../api/V120602EAPI/UPDATE_PRN_QDR';
                    else //僅列印
                        Tmp_url = '../../api/V120602EAPI/XlsOut';
                    f_downloadFile('EX_DFile', Tmp_url, np1, 'POST', function () {
                        var r = r_cookies('EX_DFile');
                        if (!checkisnull(r))
                            mysuccessalert(r);
                    });


var cmp_PRN = get_cmp_rdgrp1('列印選項', 'sub_PRN', 80);
    var cmp_PRN1 = get_cmp_rd0('列印並儲存目前QDR現況', 'sub_PRN', 250, 'A');
    var cmp_PRN2 = get_cmp_rd0('僅列印', 'sub_PRN', 250, 'B');
    cmp_PRN.items.push(cmp_PRN1, cmp_PRN2);
    cmp_PRN.flex = 10;
    cmp_PRN1.width = 200;  //避免 radio字折行
    cmp_PRN1.checked = true;

    // [Call_V120602E]鈕  - 子畫面欄位
    var J_formFields_V120602E = [
        {
            bodyStyle: "background-color:transparent;", border: false, layout: { type: 'vbox', align: 'stretch' }, padding: "5",
            items: [cmp_PRE_DATE, 
                          {
                    xtype: 'panel', id: 'sub_panel1', layout: { type: 'vbox', align: 'stretch' }, flex: 20, border: 0,
                              items: [cmp_PRN,],
                },  // end of sub_panel1
                {
                    xtype: 'panel', id: 'sub_panel2', layout: { type: 'vbox', align: 'stretch' }, flex: 10, border: 0,
                    items: [],
                },  // end of sub_panel1
            ],
        }  //end of  J_formFields_Sub1 , items[{
    ]      //end of  J_formFields_Sub1 , items[


Sample: V20305 - 設定 checkboxgroup  為true


 //請料提出   checkboxgroup - STAUOCD
    var cmp_STAUOCD = get_cmp_rdgrp1('請料狀態', 's_STAUOCD', 80);    
    var cmp_STAUOCD1 = get_cmp_rd0('未提出', 's_STAUOCD', 50, 'A');
    var cmp_STAUOCD2 = get_cmp_rd0('已提出', 's_STAUOCD', 50, 'B');
    var cmp_STAUOCD3 = get_cmp_rd0('全部', 's_STAUOCD', 50, 'ALL');
    cmp_STAUOCD1.checked = true;
    cmp_STAUOCD.items.push(cmp_STAUOCD1, cmp_STAUOCD2, cmp_STAUOCD3);
Ext.getCmp("s_STAUOCD").items.items[2].setValue(true);



2>*.cs
 //查詢 - 列印並儲存目前QDR現況
        [HttpPost]
        public void UPDATE_PRN_QDR()
        {
            var c = HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;
            string Tmp_Str;
            string Tmp_PRE_DATE = nvc["sub_PRE_DATE"];
            string Tmp_sub_PRN = nvc["sub_PRN"];
            if (Tmp_sub_PRN == "A")
                Tmp_Str = "列印並儲存目前QDR現況";
            else
                Tmp_Str = "僅列印";

2023年5月31日 星期三

V120202 – radioGroup 排成2行 – 垂直 , columns - V80202F – 列印- radioGroup : 橫向排列 layout: ‘hbox’

 目的: V120202 – radioGroup 排成2 垂直

           V80202F – 列印- radioGroup : 橫向排列 layout: ‘hbox’

處理說明: 1> V120202 – radioGroup 排成2 垂直 {
                                xtype: 'radiogroup', fieldLabel: '單況', labelWidth: 100,
                                //layout: 'vbox',  //vbox:直向  , hbox: 橫向 , 不可設為 vbox,否則仍會排成一行
                                vertical: true,    columns: [50, 50],
                                id: 's_STAT', 
                                items: [
                                    {
                                        boxLabel: '待撥料',
                                        name: 's_STAT',
                                        inputValue: 'A',
                                        width: 70,
                                        //checked: true,
                                        //id: 's_checkbox1'
                                    }, .....
                           






1>*.js
 //交機現況: 在廠機/已交機/全部
    var cmp_ARPSTS = get_cmp_rdgrp1('交機現況', 'sub_ARPSTS',   100,'hbox');
    var cmp_ARPSTS1 = get_cmp_rd0('在廠機', 'sub_ARPSTS', 80, '1');
    var cmp_ARPSTS2 = get_cmp_rd0('已交機', 'sub_ARPSTS', 80, '2');
    var cmp_ARPSTS3 = get_cmp_rd0('全部', 'sub_ARPSTS', 80, '3');
    cmp_ARPSTS.items.push(cmp_ARPSTS1, cmp_ARPSTS2, cmp_ARPSTS3);    
    cmp_ARPSTS1.checked = true;

2>myfunc.js - get_cmp_rdgrp1
//get_cmp_rdgrp1 - 取得 checkgroup 元件,
//par_layout: 'vbox' - 直向  radio   , 'hbox' : 橫向 radio
function get_cmp_rdgrp1(par_caption, par_id, par_l_width, par_layout, par_flex) {
    if (checkisnull(par_flex)) {
        par_flex = 10;
    }
    if (checkisnull(par_layout)) {
        par_layout = 'vbox';  //預設直向 radio
    }
    var rtn_cmp =
    { //已完工, 未完工 --> 兩者不能同時勾選
        xtype: 'radiogroup', fieldLabel: par_caption,
        labelWidth: par_l_width, 
        layout: par_layout,        
        width: '100%',
        id: par_id,        
        items: [],
    }
    return rtn_cmp;
}


2022年8月30日 星期二

V20306 - RadioGroup 存回資料庫 - 欄位值取得MAX+1

 目的: 編輯畫面 RadioGroup 欄位存回資料庫, PK=MAX(PK)+1

處理說明:  1> PK=MAX(PK)+1
  1>>*.js   np["ASPNO"] = "ASP" + DatetoStr(now, "Ymd");
  2>>*.cs   Tmp_NEXT_ASPNO = Tmp_ASPNO + (int.Parse(Tmp_MAX_ASPNO.Substring(11, 3))+1).ToString("000");
  
                 2> RadioGroup欄位值
1>>每一Radio.id均不同, 傳回後端每一Radio均有一值(true/false)
2>>RadioGroup欄位值由 np["STAT"]=Ext.getCmp("name").getValue(); 取得送至後端



1>*.js  - 設定  PK=MAX(PK)+1

var buttonModel = Ext.create('G_buttonModel');        

//存檔時,自動設定欄位值 : PK,
Ext.getCmp('btn_save').setFormValue = function () {
       //1>取得 PK= MAX(PK)+1 , 新增時,才設定 PK 欄位值, 編輯時 , 不設定欄位值
        var modelType = buttonModel.getModelType();
         if (!(modelType == 1))
             return true;
        var Tmp_NEXT_ASPNO = get_NEXT_ASPNO();
        Ext.getCmp("ASPNO").setValue(Tmp_NEXT_ASPNO);

        //2>設定 RadioGroup 欄位值 , 由 S_DB.add_np 設定特別的欄位值
        S_DB.add_np = {};
        S_DB.add_np["WTLV"] = Ext.getCmp("WTLV").getValue();
        S_DB.add_np["ITPR"] = Ext.getCmp("ITPR").getValue();
return true;
}

var np=s_JSON('myform');
--> Template 先執行 setFormValue() , 再執行  np 取欄位值,
      所以  setFormValue() 的欄位值, 會存入 np 參數



2>*.cs

1>>取得 MAX(PK)+1
[HttpPost]
        public HttpResponseMessage GET_NEXT_ASPNO()
        {
            var c = HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;
            var response = this.Request.CreateResponse();
            string Tmp_ASPNO = nvc["ASPNO"];
            string Tmp_Str = "";            

            OracleConnection conn = new OracleConnection(DBService.ConnectionString(DBLINK));//
            OracleCommand cmd = new OracleCommand();
            OracleDataReader reader;

            conn.Open();
            conn.ClientInfo = User.Identity.Name;
            conn.ModuleName = BaseSYS + "_" + BaseMODID;
            conn.ActionName = ActionName;
            cmd.Connection = conn;
            string Tmp_MAX_ASPNO = "", Tmp_NEXT_ASPNO = "";
            try
            {
                string Tmp_Sql = "  SELECT MAX(ASPNO)  as MAX_ASPNO "
                                           + "  FROM   AMM_ASP "
                                           + "  WHERE ASPNO   LIKE  " + myfunc.AA(Tmp_ASPNO+"%");
                cmd.CommandText = Tmp_Sql;
                reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    Tmp_MAX_ASPNO = reader["MAX_ASPNO"].ToString();
                    if (myfunc.checkisnull(Tmp_MAX_ASPNO))
                        Tmp_NEXT_ASPNO = Tmp_ASPNO + "001";
                    else
                    {
                        Tmp_NEXT_ASPNO = Tmp_ASPNO + (int.Parse(Tmp_MAX_ASPNO.Substring(11, 3))+1).ToString("000");
                    }
                }
                Tmp_Str = "{success: true ,  NEXT_ASPNO:" + myfunc.AA(Tmp_NEXT_ASPNO) + ","
                                            + " }";

                response.Content = new StringContent(Tmp_Str);    // 回應內容
                return response;
            }// end of try
            catch (Exception e)
            {
                Tmp_Str = "{success: false ,  NEXT_ASPNO:" + myfunc.AA(Tmp_NEXT_ASPNO) + ","
                                            + " }";
                response.Content = new StringContent(Tmp_Str);    // 回應內容
                return response;
            }
            finally
            {
                conn.Close();
            }
        }  // end of get_NEXT_ASPNO


//移除 nvc 由 RadioGroup 的每一Radio欄位值(true/false)
2>>
[HttpPost]
        public void Insert()
        {
            var c = System.Web.HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;
            NameValueCollection nvc1= new NameValueCollection();
            //nvc 移除 radio開頭的 key , 以免加入 Insert Sql
            var Tmp_key = "";
            foreach(string key in nvc.Keys)
            {
                if (!key.Contains("radio"))
                    nvc1[key] = nvc[key];
            }
            excuteInsert(nvc1, DBTable);
        }

2022年8月29日 星期一

V20306 - RadioGroup 的設定 - 1>含TextField 2>Label文字太長

 目的: 設定 RadioGroup  1>含TextField  2>Label文字太長

處理說明: 1>Radio  Label太長, 加大 width
                  2>Radio含 TextField, 以 Panel 包含 Radio+TextField






1>*.js
{
xtype: 'radiogroup', fieldLabel: '重量等級', labelWidth: 100, layout: 'vbox',
id: 'WTLV',
items: [
{
boxLabel: '極重(木箱)',
name: 'WTLV',
inputValue: 'A',
border: 1,
width: 300,
}, {
boxLabel: '很重(七層紙箱)',
//boxLabel: '七層紙箱',
name: 'WTLV',
inputValue: 'B',
border: 1,
}, {
boxLabel: '重(五層紙箱)',
name: 'WTLV',
inputValue: 'C',
checked: true,
},
{
boxLabel: '一般(三層紙箱)',
name: 'WTLV',
inputValue: 'D',
}
]
}, // end of WTLV重量等級
{
xtype: 'radiogroup', fieldLabel: '內層包裝需求', labelWidth: 100, layout: 'vbox',
id: 'ITPR',
items: [
{
boxLabel: '旭化層',
name: 'ITPR',
inputValue: 'A',
}, {
boxLabel: '大氣泡布',
name: 'ITPR',
inputValue: 'B',
}, {
boxLabel: '小氣泡布',
name: 'ITPR',
inputValue: 'C',
checked: true,
},
{
xtype: 'panel', layout: { type: 'hbox' }, border: 0,
items: [
{xtype: 'radio',boxLabel: '其他',name: 'ITPR',inputValue: 'E', },
{xtype: 'textfield', id: 'ITPR1', width: 150, padding: "0 5 0 5" },
]
},
]
}, // end of ITPR
]
}

2022年8月28日 星期日

V120402 - Radiobox 處理 - 取得 radioGroup 欄位值

 目的:  在畫面上顯示 Radiobox

處理說明: 1> {xtype: 'radiogroup', fieldLabel: '現況', labelWidth: 40, layout: 'vbox', 
                                id: 's_STAT',

                                items: [
                                    {
                                        boxLabel: '全部(不含已刪除)',
                                        name: 's_STAT',

                                        inputValue: 'ALL',                                        
                                        width: 200,
                                        checked: true,                                        
                                    }, {
                                        boxLabel: ' 可借閱',
                                        name: 's_STAT',

                                        inputValue: 'A',    
                                        //width: 200,
                                    }, {  :



1>*.js
 {
    xtype: 'radiogroup', fieldLabel: '現況', labelWidth: 40, layout: 'vbox', 
    id: 's_STAT',
    items: [
                                    {
                                        boxLabel: '全部(不含已刪除)',
                                        name: 's_STAT',
                                        inputValue: 'ALL',                                        
                                        width: 200,
                                        checked: true,                                        
                                    }, {
                                        boxLabel: ' 可借閱',
                                        name: 's_STAT',

                                        inputValue: 'A',    
                                    }, {
                                        boxLabel: '已借出',
                                        name: 's_STAT',
                                        inputValue: 'B',    
                                    },
                                    {
                                        boxLabel: '已刪除',
                                        name: 's_STAT',
                                        inputValue: 'Z',                                            
                                    }



//顯示資料
  {
                //xtype: 'toolbar',
                xtype: 'panel',
                id: 'panel2',
                layout: { type: 'vbox', align: 'right' },
                flex: 1,
                border: 0,
                items: [
                    {
                        xtype: 'button',
                        id: 'btn_Show',
                        flex: 2,
                        border: 1,
                        text: '資料顯示',
                        iconCls: 'icon-search',
                        handler: function () {
                           var np = s_JSON('s_form'); //TMFunction.js, 組合form上的查詢條件為json參數傳遞
                            np["s_STAT"] = Ext.getCmp('s_STAT').getValue();

                            gridstore.getProxy().url = '../api/V120402API/getGridData_M';
                            gridstore.getProxy().extraParams = np; //分頁OK,篩選條件OK

                            Ext.getCmp('grid_M').reloadGridData();                            
                        }
                    },  // end of 顯示資料
                    {
                        xtype: 'button',
                        id: 'btn_clear',
                        flex: 2,
                        border: 1,
                        text: '清除條件',
                        iconCls: 'icon-clear',
                        handler: function () {
                            var f = Query.getForm();
                            f.reset();
                        }
                    },  // end of 清除條件                    
                    { xtype: 'label', id: 'label151', flex: 2, border: 0, text: '', },  // end of label
                    { xtype: 'label', id: 'label152', flex: 2, border: 0, text: '', },  // end of label                    
                ]  // end of items of [顯示資料][清除條件]
            }   // end of panel2
        ]  // end of  items of Query


2>V20107.js  - 下載匯入格式  - 出現子視窗 - 勾選下載類別
//[下載匯入格式]鈕 - 子視窗    
    function downloadBtn_click() {
        console.log("step1");
        //按鈕 : [確認] [取消]  - [借閱登記]鈕
        var sub_downloadFlds_Btns = [
            {
                xtype: 'button', text: '確定', id: 'sub_downloadFlds_OkBtn',
                listeners: {
                    click: function () {
                        //mysuccessalert("mysub2_確定 ");
                        sub_downloadFlds_OkBtn();
                    }
                }
            },            
            {
                xtype: 'button', text: '取消', id: 'sub_downloadFlds_CancelBtn',
                listeners: {
                    click: function () {
                        //mysuccessalert("mysub2_取消");
                        var Tmp_win = this.up("window");
                        if (Tmp_win == undefined) {
                            Ext.Msg.alert("取消時未取到Window Object");
                        }
                        this.up("window").close();
                        this.up("window").destroy();
                    }
                }
            },
        ];

        console.log("step2");

        // [下載匯入格式]鈕  - 子畫面欄位
        var sub_downloadFlds = [
            {
                type: 'panel', bodyStyle: "background-color:transparent;", border: 0, padding: "5",                
                layout: { type: 'vbox', align: 'stretch' }, 
                //layout: 'border',
                items: [                    
                            {
                                xtype: 'radiogroup', fieldLabel: '選擇匯入格式', labelWidth: 100, layout: 'vbox',
                                id: 'sub_MAIN_SUB',
                                items: [
                                    {
                                        boxLabel: 'V20107_主檔匯入格式 ',
                                        name: 'sub_MAIN_SUB',
                                        inputValue: 'MAIN',
                                        width: 200,
                                        flex: 50,
                                        checked: true,
                                    }, {
                                        boxLabel: ' V20107_子步序匯入格式 ',
                                        name: 'sub_MAIN_SUB',
                                        inputValue: 'SUB',
                                        flex: 50,
                                        //width: 200,
                                    }, 
                                ]
                            }, //end of sub2_panel11 , flex:20                               
                ] // end of   layout: "vbox", padding: "5", items: [
            }  //end of   sub_downloadFlds , [{}
        ]      //end of  sub_downloadFlds , [        

        var win = getMyWindow("選擇要下載的匯入格式", sub_downloadFlds, sub_downloadFlds_Btns);
        win.setWidth(350);
        win.setHeight(200);
        win.show();                
    } // end of   function downloadBtn_click() {

    //下載匯入格式
    function sub_downloadFlds_OkBtn() {
        var Tmp_MAIN_SUB; 
        //radioGroup取得欄位值為 Object  需 Object.["sub_MAIN_SUB"] 才是字串
        Tmp_MAIN_SUB = Ext.getCmp('sub_MAIN_SUB').getValue();   
        console.log("Tmp_MAIN_SUB:", Tmp_MAIN_SUB);
        var Tmp_FName=""
        if (Tmp_MAIN_SUB["sub_MAIN_SUB"] == "MAIN")
        //if (Tmp_MAIN_SUB == "MAIN")
            Tmp_FName = "V20107_主檔匯入格式.xlsx"
        else 
            Tmp_FName = "V20107_子步序匯入格式.xlsx"
        console.log("Tmp_FName:", Tmp_FName);
        document.location = "../api/VUTLAPI/dnloadSS_File?FNAME="+Tmp_FName;           
    };