2026年10月2日 星期五

V60202Q-[現場領用]鈕-識別證2員工編號 -SMS_AIDC -MSSQL -SQLSERVER - 按[ENTER]鍵 - 員工帳號 - CARDNO - SqlConnection - 輸入字元

 目的: V60202Q-[現場領用]鈕-刷識別證2員工編號 -  MSSQL -SQLSERVER - SQL SERVER

處理說明: 1>刷識別證2員工編號
                      myfunc.get_CARDNO2EMPLYID(par_CARDNO);
                   2>由 SQLServer 的 SMS_AIDC 取得資料
                         string Tmp_Sql = "  SELECT  TOP 1 PSNNO  "
                                                   + "  FROM    SMS_AIDC.dbo.V_CARD "
                                                  + " WHERE   CARDNO=" + myfunc.AA(Tmp_CARDNO);
                         DataSet ds = Tmp_BaseController.getDataTable_MSSQL("SMS_AIDC", Tmp_Sql);

                   3>判斷輸入的字元,是否 [ENTER]鍵
                        Ext.getCmp("sub_COMPER").on("specialkey", function (field, e) {
                                 if (e.getKey() === e.ENTER) {
                                 }
                       });  
 


1>*.js

//按[ENTER]時,咷至下一欄位
    Ext.getCmp("sub_COMPER").on("specialkey", function (field, e) {
        if (e.getKey() === e.ENTER) {
            //field.next().focus();            
            //Ext.getCmp("sub_COMPER").setValue("ABC");
            Ext.getCmp("sub_COMPER").fireEvent("blur", Ext.getCmp("sub_COMPER"));
            Ext.getCmp("sub_BKMG").focus();
        }
    });

 Ext.getCmp("sub_COMPER").on('blur', function (me, eOpts) {
        //STEP1 將[識別證卡號] 轉成 [員工編號]
        var Tmp_CARDNO = me.getValue();
        if (Tmp_CARDNO.length > 8) {
            console.log("卡號:", Tmp_CARDNO);
            var Tmp_EMPLYID = "";  //所有資料 PK 字串, 以 , 分隔
            var Tmp_EMPLYNM = "";
            var Tmp_url = "../../api/V60202QAPI/get_EMPLYID_EMPLYNM";
            var np = {};
            np["CARDNO"] = Tmp_CARDNO;
            var Tmp_Str = getUrlStr(Tmp_url, np, "識別證編號2員工編號");
            Tmp_EMPLYID = StrExtract1(Tmp_Str, 1);
            Tmp_EMPLYNM = StrExtract1(Tmp_Str, 2);
            if (checkRtnOK(Tmp_EMPLYID)) {
                me.setValue(Tmp_EMPLYID);
                Ext.getCmp("sub_COMPER_").setValue(Tmp_EMPLYNM);
            }
        }
        else {  //直接輸入帳號 
            Tmp_EMPLYID = Tmp_CARDNO;
            Tmp_EMPLYNM = getEmp_NM(Tmp_EMPLYID);
            Ext.getCmp("sub_COMPER_").setValue(Tmp_EMPLYNM);
        }
    });


2>*.cs  - myfunc.get_CARDNO2EMPLYID
//由識別證號碼取得員工帳號
        [HttpPost]
        public string get_EMPLYID_EMPLYNM()
        {
            var c = HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;
            string Tmp_Str;
            string Tmp_CARDNO = nvc["CARDNO"];
            string Tmp_EMPLYID = myfunc.get_CARDNO2EMPLYID(Tmp_CARDNO);
            string Tmp_Sql = " SELECT  EMPLYNM "
                                      + " FROM    HR_EMPLYM "
                                      + " WHERE  EMPLYID=" + myfunc.AA(Tmp_EMPLYID);
            string Tmp_EMPLYNM = myfunc.SqlValue(Tmp_Sql);
            Tmp_Str = Tmp_EMPLYID + ";" + Tmp_EMPLYNM;
            return Tmp_Str;
        }  // end of get_EMPLYID


public static string get_CARDNO2EMPLYID(string par_CARDNO)
        {
            string Tmp_CARDNO = par_CARDNO;
            string Tmp_EMPLYID = "";
            BaseAPIController Tmp_BaseController = new BaseAPIController();
            try
            {
                string Tmp_Sql = "  SELECT  TOP 1 PSNNO  "
                                       + "  FROM    SMS_AIDC.dbo.V_CARD "
                                       + " WHERE   CARDNO=" + myfunc.AA(Tmp_CARDNO);
                DataSet ds = Tmp_BaseController.getDataTable_MSSQL("SMS_AIDC", Tmp_Sql);
                int Tmp_cnt = ds.Tables[0].Rows.Count;
                if (Tmp_cnt > 0)
                {
                    string Tmp_PSNNO = ds.Tables[0].Rows[0]["PSNNO"].ToString();                 
                    Tmp_EMPLYID = Tmp_PSNNO;                    
                }
                return Tmp_EMPLYID;
            }  // end of try 
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return Tmp_EMPLYID;
        }  // end of         public string get_CARDNO2EMPLYID(string par_CARDNO)

2026年10月1日 星期四

V60202Q – [領用人員] – 按[Enter]鍵時,跳至下一欄位 - key - 取得欄位新值(取得識別證的員工編號)

 目的: V60202Q – [領用人員] – 按[Enter]鍵時,跳至下一欄位

處理說明:   1> specialkey event :   有輸入字元時觸發 
                       Ext.getCmp("sub_COMPER").on("specialkey", function (field, e) {
                       if (e.getKey() === e.ENTER) {
                            //field.next().focus();
                            //本元件的欄位值,設成新值 
                            Ext.getCmp("sub_COMPER").setValue("ABC");
                            Ext.getCmp("sub_BKMG").focus();
                       }
                       });


1>*.js
    //按[ENTER]時,咷至下一欄位
    Ext.getCmp("sub_COMPER").on("specialkey", function (field, e) {
        if (e.getKey() === e.ENTER) {
            //field.next().focus();
            Ext.getCmp("sub_BKMG").focus();
        }
    });
 
    Ext.getCmp("sub_BKMG").on("specialkey", function (field, e) {
        if (e.getKey() === e.ENTER) {
            //field.next().focus();
            Ext.getCmp("sub_MATNR").focus();
        }
    });
 
    Ext.getCmp("sub_MATNR").on("specialkey", function (field, e) {
        if (e.getKey() === e.ENTER) {
            //field.next().focus();
            Ext.getCmp("sub_SAPNO").focus();
        }
    });

2026年9月30日 星期三

V80403 – 設定 TextField 的欄位名稱 – 字體大小 – 字體顏色 - font-size

 目的: V80403 – 設定 TextField 的欄位名稱 – 字體大小 – 字體顏色

處理說明: 1> //取得 text欄位(GPASS1).up.fieldcontainer
                          Ext.getCmp("GPASS1").up("fieldcontainer").labelStyle = "color: blue; font-size: 14px";


1>*.js
//取得 text欄位.up.fieldcontainer
Ext.getCmp("GPASS1").up("fieldcontainer").labelStyle = "color: blue; font-size: 14px";


V80403 –[子件無架構發工]鈕 - 呼叫 V20301 子功能畫面 -iframe

 目的: V80403 –[子件無架構發工]鈕   - 呼叫 V20301 子功能畫面
處理說明: 1> 呼叫 V20301  子功能畫面  
                       - 利用  HTML  <iframe src= ?FUNID  > 開啟子功能 Windows 畫面 
                              var ParamStr = "?FUNID=V20301&GAMMNO=" + Tmp_AMMNO + "&GPASS1=" + Tmp_GPASS1;
                         src="/Home/CenterTab' + ParamStr + '">
                  2>利用 location.search 取得傳入參數值(ParamStr)
                      var Values = GetURLParamValues(location.search);    
                  3>嵌入框架:<iframe> 是 HTML 標籤,用來在一個網頁裡嵌入另一個網頁。




1>V80403.js
[子件無架構發工]鈕: 呼叫函式 CALL_V20301_f_V40105(cur_rec);
  var cur_recs = Ext.getCmp('grid_Single').getSelectionModel().getSelection();
                    if (cur_recs.length == 0) {
                        mywarnalert("請先選擇資料(母AMM單號-AMMNO)");
                        return false;
                    }
                    cur_rec = cur_recs[0];
                    var Tmp_Str = "確認要新增目前AMM號(" + cur_rec.data["AMMNO"].toString() + ")<br>"
                        + "件號(" + cur_rec.data["AMMNO"].toString() + ")<br>"
                        + "的子件發工資料嗎?";
                    Tmp_Str=Tmp_Str.replace(/<br>/g, "\n");
                    var id = confirm(Tmp_Str);
                    if (id) {
                        CALL_V20301_f_V40105(cur_rec);
                    }    }          }


function CALL_V20301_f_V40105(cur_rec) {

     var Tmp_AMMNO = nulltoStr(cur_rec.data['AMMNO']).toString();
     var Tmp_GPASS1 = 'GPASS1'; //傳回AMMNO字串的欄位名稱
var ParamStr = "?FUNID=V20301&GAMMNO=" + Tmp_AMMNO + "&GPASS1=" + Tmp_GPASS1;
var win = new Ext.Window({
layout: 'fit',
id: 'win_V20301',
title: 'V20103',
closable: false,
closeAction: 'destroy',
modal: true, //有pick視窗時,下面的不能按
html: '<iframe id="ifrm" scrolling="auto" frameborder="0" width="100%" height="100%" src="/Home/CenterTab' + ParamStr + '"></iframe>',
buttons: [
{
id: 'btnClose1', text: '關閉',
handler: function () {
this.up('window').close();
}}]
});
win.setHeight(700);
win.setWidth(1200);
win.show();
};

2>V20301.js
[確認轉發]鈕 : 傳回 新產生的子AMM單號至 GPASS1 元件
//傳回V40105
var AMMNOStr; // ex: 格式要為'NO1'+','+'NO2', 不要是 AA('NO1')+','+AA('NO2')
if (Tmp_isV40105) {
Tmp_AMMNO_Str = Tmp_Obj["Rtn_Msg"];
AssignParentValue_v([Tmp_GPASS1], [Tmp_AMMNO_Str]); //傳回的 AMMNOStr 至 GPASS1元件 CloseChildWin();
}









2026年9月29日 星期二

V80403 - iframe 和 windows 的差異 - 呼叫 V20301 的子功能畫面 - iframe


iframe 和 window 在網頁開發中是兩個不同層次的概念,雖然都能顯示內容,但用途和行為差異很大:

📌 iframe

  • 嵌入框架:<iframe> 是 HTML 標籤,用來在一個網頁裡嵌入另一個網頁。

  • 作用範圍:它存在於同一個瀏覽器視窗中,只是頁面的一部分。

  • 用途:常用來載入外部頁面、報表、或第三方內容(例如地圖、影片)。

  • 限制:受同源政策影響,跨網域存取內容會有限制。

  • 控制方式:透過 DOM 操作 (document.getElementById("ifrm")) 來改變 src 或內容。

📌 window

  • 獨立視窗:window 是瀏覽器提供的物件,代表一個完整的瀏覽器視窗或彈出視窗。

  • 作用範圍:它是最上層的容器,包含整個 DOM、iframe、script 等。

  • 用途:可用來開新視窗 (window.open)、或在 ExtJS 中建立彈出視窗 (Ext.Window)。

  • 控制方式:可操作整個視窗的屬性與事件,例如大小、位置、關閉。




1>*.js
{ //測試用按鈕 - 模擬 V40105 呼叫 V20301 子功能
xtype: 'button', text: '子件無架構發工', id: 'btn_V80403C',
listeners: {
click: function () {
console.log(" 2 btn_V80403B click ");
var cur_recs = Ext.getCmp('grid_Single').getSelectionModel().getSelection();
if (cur_recs.length == 0) {
mywarnalert("請先選擇資料(母AMM單號-AMMNO)");
return false;
}
cur_rec = cur_recs[0];
CALL_V20301_f_V40105(cur_rec);
}
}
},

cmp_GPASS1,
}


2>V80403.js
//此函式不可寫在 V20301 因為 id 會和 V40105 相同,
// Ext.Loader.loadScript({ url: '../JsFunction/V20301.js' }); --> 會 Error

//只能利用 iframe 的方式 , 開啟 V20301 - id 重覆沒關係

function CALL_V20301_f_V40105(cur_rec) {
    var Tmp_AMMNO = nulltoStr(cur_rec.data['AMMNO']).toString();
    var Tmp_GPASS1 = 'GPASS1';
    var ParamStr = "?FUNID=V20301&GAMMNO=" + Tmp_AMMNO + "&GPASS1=" + Tmp_GPASS1;

var win = new Ext.Window({
layout: 'fit',
id: 'win_V20301',
title: 'V20103',
closable: false,
closeAction: 'destroy',
modal: true, //有pick視窗時,下面的不能按
html: '<iframe id="ifrm" scrolling="auto" frameborder="0" width="100%" height="100%" src="/Home/CenterTab' + ParamStr + '"></iframe>',
buttons: [
{
id: 'btnClose1', text: '關閉',
handler: function () {
this.up('window').close();
}
}
]
});

win.setHeight(700);
win.setWidth(1200);
win.show();

};

V60202R- 多張標籤列印(不同內容的標籤) - 每頁含 [內容+標籤]+[分頁]

 目的: V60202R- 多張標籤列印(不同內容)

處理說明: 1>$('#div_print_area').printThis({}); 利用 div_print_area - 包含多張內容來預覽列印
                        $("#div_print_area").printThis({});
                  2>my_div_x: 每頁內容=div_內容+div_分頁
                  3>my_tbl_x: 每頁資料=tbl_內容+tbl_barcode
                  4>my_tbl_x1,my_tbl_x2: tbl_內容, tbl_barcode




1>*.js
 pub_print_area_Str1 = "<div id='div_print_area' style='border: 1px solid black;'>"
                                                   +pub_print_area_Str1
                                  +" </div >  <!--  end of div id='div_print_area' -->";
            $("#div_print_area").remove();
            var Tmp_sub_panel4 = $('#sub_panel4');
            Tmp_sub_panel4.append(pub_print_area_Str1);
       
            var Tmp_prn_div_Str = "#div_print_area";
            //printThis  - 會開啟預覽列印.html  , 原本子畫面.html 已被預覽列印取代, 所以 header  也不同了..
            //所以 printThis(loadCSS:  )   --> 才是 [預覽列印] 視窗 戴入的 *.css
            $(Tmp_prn_div_Str).printThis({                
                loadCSS: "../JsFunction/print_V60202R.css?v=@date", 
            });


var Tmp_PageCnt = CHK_PK_OBJ.PK_LIST.length;

for (var i = 0; i < Tmp_PageCnt; i++)
            {
            Tmp_uni = (i + 1).toString();
            cur_rec = CHK_PK_OBJ.ALL_LIST[i];      

            Tmp_MATNR = nulltoStr(cur_rec['MATNR']).toString();
            Tmp_WH = nulltoStr(cur_rec['WH']).toString();
            Tmp_SP = nulltoStr(cur_rec['SP']).toString();
            Tmp_NAME = nulltoStr(cur_rec['NAME']).toString();
            Tmp_MAKTX = nulltoStr(cur_rec['MAKTX']).toString();
            Tmp_barcode_text = Tmp_MATNR+"&"+Tmp_WH+"&"+Tmp_SP;

        //預覽列印的 HTML 內容        
            pub_print_area_Str1 = pub_print_area_Str1
                    +"<div id = 'my_div_" + Tmp_uni + "' style = 'width:10cm;height:3.8cm;border:1px solid black;font-size:9pt;' > "
                    + "<table id='my_tbl_" + Tmp_uni + "' style='width: 100%;height: 100%;' border=1 bordercolor = 'black' cellspacing = 0 >  "
                + "   <tr>   <!-- 包含 左邊文字內容 + 右邊barcode -->"
                    + "    <td width=70%> <!-- 左邊文字內容  --> "
                    + " <table id='my_tbl_" + Tmp_uni + "1' style='width:100%;height: 100%;' border=1 bordercolor='black' cellspacing=0>   "
                    + " <tr>  "
                    + " <th width=30% style='margin: 0 0 0 0 ;'>件號<br>(Parts No) : </th>  "
                    + " <td width=70%>" + Tmp_MATNR + "</td>  "
                    + " </tr>  "
                    + " <tr>  "
                    + " <th width=30%>名稱<br>(Name) :</th>   "
                    + " <td width=70%>" + Tmp_NAME + "<br>" + Tmp_MAKTX + "</td>  "
                    + "</tr>  "
                    + "<tr> "
                    + "<th width=30%>庫房 :</th> "
                    + "<td width=70 %>" + Tmp_WH + "</td>  "
                    + "</tr>  "
                    + "<tr> "
                    + "<th width=30%>儲位 :</th>  "
                    + "<td width=70 %>" + Tmp_SP + "</td>"
                    + "</tr>  "
                    + "</table>  <!--  end of table id='my_tbl_x1' -->"
                + " </td >   <!-- end of  <td width=70%>   -->"
                    + "<td  width=30%>  "
                    + " <table id='my_tbl_" + Tmp_uni + "2' style='width:100%;height: 100%;' border=1 bordercolor='black' cellspacing=0>  "
                    + "<tr>  "
                    + "<td>  " + genQRcodeStr(Tmp_barcode_text, 90, 90, false) + " </td> "
                    + "</tr> "
                    + " </table>  <!--  end of table id='my_tbl_x2' -->"
                + " </td>   <!-- width= 30# 左邊文字內容  -->"
                + "</tr>   <!-- 包含  左邊文字內容+右邊barcode  -->"
                + " </table>   <!--  end of table id='my_tbl_x' -->"                    
                    + "  <div class='display'  style='break-after:page'>   "
                    + "  </div>   <!--  end of div break-after:page   -->"
                    + "</div>  <!--  <div id = 'my_div_x'   --> ";
            }   // end of for  for (var i = 0; i < Tmp_PageCnt; i++) {


2026年9月28日 星期一

V60202P – Label字體顏色 –字體大小 – style:"text-align:left; color:blue;fontSize: 14px"

 目的: V60202P – Label字體顏色 –字體大小 – style:"text-align:left; color:blue;fontSize: 14px"

處理說明: 1>style: "text-align:left; color:blue;fontSize: 14px"



1>*.js

 var cmp_sub_prnlbl = get_cmp_lbl0('(標籤格式: 10cm*6cm)', 180, 
                                                                "text-align:left; color:blue;fontSize: 14px");
    var sub_V60202P_Btns = [            
            {
                xtype: 'button', text: '列印標籤', id: 'sub_V60202P_OkBtn',
                //flex: 5,
                listeners: {
                    click: function () {
                        //mysuccessalert("mysub2_確定 ");
                        //檢核 AMM項次的需求工時正確, 若有問題,則 Tmp_isOk=false, 若沒問題, Tmp_isOk=true, 才執行[確認]的處理
                        V60202P_OK();
                    }
                }
            },
            {
                xtype: 'button', text: '離開', id: 'sub_V60202P_CancelBtn',
                //flex: 5,
                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();
                    }
                }
        },
        cmp_sub_prnlbl,
        ];

     var win1 = getMyWindow("膠漆料管制標簽查詢", sub_V60202P_Flds, sub_V60202P_Btns, "P");
        win1.x = 100;
        win1.setWidth(800);
        win1.setHeight(300);
        win1.show();