2026年10月7日 星期三

V60202Q : 設定 Grid.row.字體顏色 – getRowClass - 載入mycss.css

目的: V60202Q : 設定 Grid.row.字體顏色 – getRowClass  - 載入mycss.css

處理說明: 1>載入 mycss.css                 
                       var Tmp_Str = "<link type='text/css' rel='stylesheet' href='../JsFunction/mycss.css'  >";
                       $('head').append(Tmp_Str);
                  2>設定  Grid.Row 字體顏色  
    Ext.getCmp('grid_M').getView().getRowClass = function (record, rowIndex, rowParams, store) {
        if (record.data.STAT == "B") {
            return "my-blue-color";            
        }

                 3>mycss.css  - class 內容
                     .my-blue-color {
                       color: blue;
                      }
   
 

1>*.js
    //先載入 mycss.css     
    var Tmp_Str = "<link type='text/css' rel='stylesheet' href='../JsFunction/mycss.css'  >";
    $('head').append(Tmp_Str);

    //設定Grid.欄位值.字體顏色
    //1>若狀態為延測中(AMM_COMP.STAT='B'),則整筆資料字型色彩=[藍色]    
    //getRowClass : 傳回 class 名稱, 非 style
    Ext.getCmp('grid_M').getView().getRowClass = function (record, rowIndex, rowParams, store) {
        if (record.data.STAT == "B") {
            return "my-blue-color";            
        }

        //日期加7,
        var Tmp_LIM_DT = DATE_ADD(cnow(), "C", 7);
        var Tmp_LIM_DT_STR = Ext.Date.format(new Date(Tmp_LIM_DT), 'Ymd');
        if (      (record.data.TERM == "Y")
            && (record.data.STAT == "A")
            && (record.data.VFDAT <= Tmp_LIM_DT_STR)   ) {          
            return "my-red-color";
        }
    };  // end of function 


2026年10月6日 星期二

V60202Q -[列印標籤] –一維條碼 - barcode - JsBarcode.all.min.js - JsBarcode.all.min.js

 目的: V60202Q -[列印標籤] –一維條碼 - barcode

處理說明: 1>先建立好 HTML - 包含 id= JSBarCode_MATNR_1 的<svg>  </svg>
                      <td colspan='2'>
                          <svg id='JSBarCode_MATNR_1' width=50 height = 15 >                    
                           </svg >
                      </td > 
                 2>利用 Barcode 函式 of JsBarcode.all.min.js  , 產生 <svg>一維條碼內容 至指定id元件
                      JsBarcode("#BarCode_MATNR_1", Tmp_MATNR, barcode_settings);
                      --> 找到  id=BarCode_MATNR_1 元件 , 並產生 Tmp_MATNR 的一維條碼
                             barcode_settings : 設定一維條碼的格式(CODE39,CODE128)
                3><svg> 的內容 : 四方形*n
                    <rect x="0" y="0" width="1.6" height="17"></rect>
                    <rect x="2.4000000000000004" y="0" width="0.8" height="17"></rect>
                    <rect x="4.800000000000001" y="0" width="0.8" height="17"></rect>
                            :

1>*.js

function V60202Q_PRN() {
        //取得[工號].工單件號(AMM_SRO.PN)
        var Tmp_SAPNO = Ext.getCmp("sub_SAPNO").getValue();
        var Tmp_PN = "";  //工單件號
        var np = {};
        np["SAPNO"] = Tmp_SAPNO;        
        var Tmp_url = '../../api/V60202QAPI/get_SAPNO2PN';
        var Tmp_PN = getUrlStr(Tmp_url, np, "取得[工號].工單件號(AMM_SRO.PN)");
        
        //1>目前挑選資料        
        //var pub_print_area_Str0 = "<div id='div_print_area' style='border: 5px solid green;'>";
        var pub_print_area_Str1 = "";
        var Tmp_uni = "0";
        var Tmp_PageCnt = Ext.getCmp("sub_Grid").store.getCount();
        var Tmp_MATNR = "", Tmp_WH = "", Tmp_SP = "";
        var Tmp_ASN = Ext.getCmp("sub_USED_ASN").getValue();
        var Tmp_TMNO = Ext.getCmp("sub_USED_TMNO").getValue();
        var Tmp_COMPER = Ext.getCmp("sub_COMPER").getValue();
        var Tmp_COMPER_ = Ext.getCmp("sub_COMPER_").getValue();        
        var Tmp_NAME = "";                
        var Tmp_USED_QTY = "";
        var Tmp_UNIT = "";

        try {
            /* { name: "MATNR" }, { name: "WH" }, { name: "SP" },
                { name: "NAME" }, { name: "SQTY" }, { name: "USED_QTY" },
                { name: "UNIT" }, { name: "CLASS" }, { name: "CLASS_" },  */            
            for (var i = 0; i < Tmp_PageCnt; i++) {
                Tmp_uni = (i + 1).toString();
                cur_rec = Ext.getCmp("sub_Grid").store.getAt(i).data;
                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_USED_QTY = nulltoStr(cur_rec['USED_QTY']).toString();
                Tmp_UNIT = nulltoStr(cur_rec['UNIT']).toString();
                Tmp_barcode_text = Tmp_MATNR;
                //預覽列印的 HTML 內容        
                pub_print_area_Str1 = pub_print_area_Str1
                    //+"<div id='div_print_area' style='width:10cm;height:4cm;border: 1px solid green;'> "
                    //my_div_x - 包佲 my_tbl_1 + my_break
                    + "<div id = 'div_data_" + Tmp_uni + "' style = 'width:10cm;height:3.8cm;border:1px solid black;font-size:8pt;' > "
                    //+ "<table id='tbl_" + Tmp_uni + "'   style='width: 100%;height: 100%;' border=1 bordercolor = 'black' cellspacing = 0 >  "
                    //+ "  <tr>   <!-- 包含 tbl_11 & tbl_12 -->"
                    + " <table id='tbl_" + Tmp_uni + "1' style='width:100%;height: 15%;' border=1px solid black;' cellspacing=0>   "
                    + " <tr>  "
                    + "<td>機號:" + Tmp_ASN + "</td>";
                if (!checkisnull(Tmp_SAPNO)) {
                    pub_print_area_Str1 = pub_print_area_Str1
                        + "<td>工號:" + Tmp_SAPNO + "</td>"
                        + "<td>工單件號:" + Tmp_PN + "</td>";
                }
                else {
                    pub_print_area_Str1 = pub_print_area_Str1
                        + "<td>參考文件編號:" + Tmp_TMNO + "</td>";
                }                    
                pub_print_area_Str1 = pub_print_area_Str1
                    + "</tr>"
                    +"</table > <!-- end of table id = 'tbl_x1' -->  "
                    + "<table id='tbl_" + Tmp_uni + "2' style='width:100%;height: 85%;' border=1px solid black;' cellspacing=0>   "
                    +"<tr>  "                  
                    +"<td colspan='2'>領用件號:"+Tmp_MATNR+"</td>"
                    +"</tr>"
                    +"<tr>"
                    + "<td colspan='2'>"
                    + "<svg id='JSBarCode_MATNR_"+Tmp_uni+"' width=50 height = 15 >"                   
                    + "</svg >"
                    +"</td > "
                    +"</tr>"
                    +"<tr>"
                    +"<td style='width:50%;'>領料數量:"+Tmp_USED_QTY+"</td>"
                    +"<td style='width:50%;'>單位:"+Tmp_UNIT+"</td>"
                     +"</tr>"
                     +"<tr>"
                     +"<td colspan='2'>名稱:"+Tmp_NAME+"</td>"
                     +"</tr>"
                    +"<tr>"
                    +"<td style='width:50%;'>庫房:"+Tmp_WH+"</td>"
                    +"<td style='width:50%;'>儲位:"+Tmp_SP+"</td>"
                    +"</tr>"
                    +"<tr>"
                    + "<td style='width:50%;'>領料人員:" + Tmp_COMPER +"&nbsp;"+Tmp_COMPER_+"</td>"
                    +"<td style='width:50%;'>"+cnow()+"</td>"
                    +"</tr>"
                    + "</table > <!-- end of table id = 'my_tbl_x2' -->"
                 //+"</tr>"                    
             //+ " </table>   <!--  end of table id='tbl_x' -->"
             + "  <div class='display'  style='break-after:page'>   "
              + "  </div>   <!--  end of div break-after:page   -->"
              + "</div>  <!--  <div id = 'div_data_x'   --> ";
            }   // end of for  for (var i = 0; i < Tmp_PageCnt; i++) {
            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);



            //填寫 一維 barcode 值
            //測  JSBarcode 是否正常 , 填寫 BarCode 圖形 
            //console.log(JsBarcode);
            //console.log(JsBarcode("#JSBarCode_MATNR_1", "123456789", {
            //    format: "CODE128"
            //}));
            
            for (var i = 0; i < Tmp_PageCnt; i++) {
                //取得目前所選資燉
                cur_rec = Ext.getCmp("sub_Grid").store.getAt(i).data;
                Tmp_uni = (i + 1).toString();                
                Tmp_MATNR = cur_rec.MATNR;                
                //列印條碼   
                //Q20170922001   width: 0.8  height: 20
                //LMAERO - 73428 - 0001   width: 1  height: 20
                var barcode_settings = {
                    width: 0.8,  // Q20170922001
                    height: 20,
                    displayValue: true,
                    fontSize: 10,
                    textAlign: 'left',
                    margin: 0,
                    marginLeft: 3,
                    //marginBottom: 5,
                    font: "Arial",
                    format: "CODE128",
                };                
                var Tmp_barcode_id = "";
                if (!checkisnull(Tmp_MATNR)) {
                    barcode_settings.height = 17;
                    barcode_settings.displayValue = false;
                    Tmp_barcode_id = "#JSBarCode_MATNR_" + Tmp_uni;
                    //JsBarcode("#BarCode_APNO_1", Tmp_APNO, barcode_settings);
                    JsBarcode(Tmp_barcode_id, Tmp_MATNR, barcode_settings);
                }                
            }  // end of for (i=0 ;i<cbxArr.lenght; i++)



            var Tmp_prn_div_Str = "#div_print_area";
            var Tmp_prn_div_obj = $(Tmp_prn_div_Str);
            console.log("Tmp_prn_div_obj:", Tmp_prn_div_obj);
            //printThis  - 會開啟預覽列印.html  , 原本子畫面.html 已被預覽列印取代, 所以 header  也不同了..
            //所以 printThis(loadCSS:  )   --> 才是 [預覽列印] 視窗 戴入的 *.css
            $(Tmp_prn_div_Str).printThis({
                //importCSS: false, // import parent page css  
               // importStyle: false, // import style tags        
                loadCSS: "../JsFunction/print_V60202Q.css?v=@date", // path to additional css file - use an array [] for multiple                
            });
        }  // end of try
        catch (e) {
            var Tmp_Str = "物料儲位標籤列印失敗!!<br>"
                + "件號(" + Tmp_MATNR + ")<br>"
                + "庫存(" + Tmp_WH + ")<br>"
                + "儲位(" + Tmp_SP + ")<br>"
                + "錯誤訊息:" + e.message;
            mywarnalert(Tmp_Str);
        }   //膠漆料管制標籤-查詢失敗
    }// end of  function V60202Q_PRN() {

2><svg>內容 - 產生的一維條碼內容

<svg id="JSBarCode_MATNR_1" width="111px" height="17px" x="0px" y="0px" viewBox="0 0 111 17" 
 xmlns="http://www.w3.org/2000/svg" version="1.1" style="transform: translate(0,0)">
<rect x="0" y="0" width="111" height="17" style="fill:#ffffff;"></rect>
<g transform="translate(3, 0)" style="fill:#000000;">
<rect x="0" y="0" width="1.6" height="17"></rect>
<rect x="2.4000000000000004" y="0" width="0.8" height="17"></rect>
<rect x="4.800000000000001" y="0" width="0.8" height="17"></rect>
<rect x="8.8" y="0" width="0.8" height="17"></rect>
<rect x="12" y="0" width="0.8" height="17"></rect>
<rect x="15.200000000000001" y="0" width="1.6" height="17"></rect>
<rect x="17.6" y="0" width="0.8" height="17"></rect>
<rect x="20.8" y="0" width="0.8" height="17"></rect>
<rect x="24" y="0" width="1.6" height="17"></rect>
<rect x="26.400000000000002" y="0" width="0.8" height="17"></rect>
<rect x="29.6" y="0" width="0.8" height="17"></rect>
<rect x="32.8" y="0" width="1.6" height="17"></rect>
<rect x="35.2" y="0" width="0.8" height="17"></rect>
<rect x="37.6" y="0" width="1.6" height="17"></rect>
<rect x="40.00000000000001" y="0" width="2.4000000000000004" height="17"></rect>
<rect x="44.00000000000001" y="0" width="0.8" height="17"></rect>
<rect x="47.2" y="0" width="0.8" height="17"></rect>
<rect x="50.4" y="0" width="1.6" height="17"></rect>
<rect x="52.800000000000004" y="0" width="0.8" height="17"></rect>
<rect x="55.2" y="0" width="1.6" height="17"></rect>
<rect x="57.6" y="0" width="2.4000000000000004" height="17"></rect>
<rect x="61.6" y="0" width="1.6" height="17"></rect>
<rect x="64.80000000000001" y="0" width="0.8" height="17"></rect>
<rect x="67.2" y="0" width="2.4000000000000004" height="17"></rect>
<rect x="70.4" y="0" width="1.6" height="17"></rect>
<rect x="73.60000000000001" y="0" width="0.8" height="17"></rect>
<rect x="76" y="0" width="2.4000000000000004" height="17"></rect>
<rect x="79.2" y="0" width="0.8" height="17"></rect>
<rect x="81.6" y="0" width="2.4000000000000004" height="17"></rect>
<rect x="84.80000000000001" y="0" width="1.6" height="17"></rect>
<rect x="88.00000000000001" y="0" width="0.8" height="17"></rect>
<rect x="89.60000000000001" y="0" width="0.8" height="17"></rect>
<rect x="92.80000000000001" y="0" width="1.6" height="17"></rect>
<rect x="96.80000000000001" y="0" width="1.6" height="17"></rect>
<rect x="100.8" y="0" width="2.4000000000000004" height="17"></rect>
<rect x="104.00000000000001" y="0" width="0.8" height="17"></rect>
<rect x="105.60000000000001" y="0" width="1.6" height="17"></rect>
</g>
</svg>

2026年10月5日 星期一

V60202Q – Grid欄位顏色- 欄位允許編輯 –依欄位值,設定字體顏色 -Grid顏色

 目的: V60202Q – Grid欄位顏色- 欄位允許編輯 –依欄位值,設定字體顏色

處理說明: 1>



1>*.js
{
header: "領用數量", dataIndex: "USED_QTY", width: 100, sortable: false, TMType: "string",
style: 'color: blue;',
editor: { xtype: 'textfield',  },
},

var sub_Grid = Ext.create('TMGrid', {
grid_id: 'sub_Grid',
columns: sub_Columns_V60202Q,
//autoScroll: true,
flex: 1,
store: Ext.create('gridstore', { model: sub_model_V60202Q }),
plugins: [
    Ext.create('Ext.grid.plugin.CellEditing', { // 不會出現[Update][Cancel]鈕, 直接編輯
                     clicksToEdit: 1, // 按一下進行編輯,預設為按兩下
                     clicksToMoveEditor: 1, 
            //在編輯模式下切換編輯另一行的行為1表示點選一就切換; //2表示點2下才切換。
})],
});

2>V80202.js -  依欄位值,設定字體顏色

{header:"是否曾展BOM",dataIndex:"ISBOMIN",width:100,sortable:false,TMType:"string"},
{
header: "
停工中", dataIndex: "ISSTOP", width: 60, sortable: false, TMType: "string",

style: 'color: blue;'   ,  // 設定標題文字顏色

// 設定欄位值.顏色
renderer
: function (value) {
if (value == "Y") {
    return "<span style='color:red'>" + value + "</span>";
}
else {
return value;
}}},
{header:"
專案委託人",dataIndex:"PJER",width:100,sortable:false,TMType:"string"},

V60202QA – 新增 store 資料 – store 自行定義欄位 –store.add(np);

 目的:V60202QA – 新增 store 資料 – store 自行定義欄位 –store.add(np);

處理說明: 1>  var np = {};
                        np["MATNR"] = Tmp_MATNR;
                        np["WH"] = Tmp_WH;
                        np["SP"] = Tmp_SP;
                                  :
                  2>Ext.getCmp('sub_Grid').store.add(np)  ;
                       --> 自動依 np 的欄位名稱值, 寫入對應的 store 欄位名稱


1>*.js
{
xtype: 'button', text: '確定', id: 'OkBtn_V60202QA',
listeners: {
click: function (me, e, eOpts) {
//[確定]鈕,將, 將目前 件號 + 庫存 + 儲存位置"不存在 store, 則顯示子視窗,
// { name: "MATNR" }, { name: "WH" }, { name: "SP" }, { name: "NAME" },
//{ name: "SQTY" }, { name: "USED_QTY" },
//{ name: "UNIT" }, { name: "CLASS" }, { name: "CLASS_" },
//出現子畫面, 輸入[領用數量]後,再加入 store
var Tmp_USED_QTY = Ext.getCmp("sub1_QTY").getValue();
var Tmp_MATNR = par_MATNR;
var Tmp_WH = par_WH;
var Tmp_SP = par_SP;
var np = {};
np["MATNR"] = Tmp_MATNR;
np["WH"] = Tmp_WH;
np["SP"] = Tmp_SP;
//STEP1: 檢核 件號.標準工時檔(AMM_PNTMSHT)是否已存在 , 若不存在,則顯示訊息後, 離開
var Tmp_url = '../../api/V60202QAAPI/get_data_MATNR_WH_SP';
var Tmp_RtnStr = getUrlStr(Tmp_url, np, "取得MATNR+WH+SP相關資料(名稱,剩餘數量,單位,類別,類別名稱)");
if (checkRtnOK(Tmp_RtnStr)) {
      np["UNIT"] = StrExtract(Tmp_RtnStr, 4);
      np["SQTY"] = StrExtract(Tmp_RtnStr, 5);
      np["USED_QTY"] = Tmp_USED_QTY; //領用數量
      np["NAME"] = StrExtract(Tmp_RtnStr, 6);
      np["CLASS"] = StrExtract(Tmp_RtnStr, 7);
      np["CLASS_"] = StrExtract(Tmp_RtnStr, 8);
Ext.getCmp('sub_Grid').store.add(np);
Ext.getCmp("sub_MATNR").setValue("");
//離開前,關閉本子畫面
Ext.getCmp("CancelBtn_V60202QA").fireEvent('click', Ext.getCmp("CancelBtn_V60202QA"));
//return ;
}
else {
mywarnalert(Tmp_RtnStr);
//離開前,關閉本子畫面
Ext.getCmp("CancelBtn_V60202QA").fireEvent('click', Ext.getCmp("CancelBtn_V60202QA"));
//return ;
}
} //end of click
} // end of listener
},


//sub_Grid 的欄位名稱 
//--> Ext.getCmp('sub_Grid').store.add(np);  
//--> store.add(np)  , 會自動依 np.欄位名稱 ,填入 store 相對應的欄位值
var sub_model_V60202Q = [
{ name: "MATNR" },
{ name: "WH" },
{ name: "SP" },
{ name: "NAME" },
{ name: "SQTY" },
{ name: "USED_QTY" },
{ name: "UNIT" },
{ name: "CLASS" },
{ name: "CLASS_" },
];

2026年10月4日 星期日

V60202Q – [現場領用] – blue event 被觸發兩次 - 由 eOpts 過濾

目的: V60202Q – [現場領用] – blue event 被觸發兩次    (1>按Enter , 2>開啟子畫面)

處理說明:  1>按[Enter]鍵時, 程式觸發 blur  event   
                        --> 開啟子畫面(輸入領用數量) , eOpts=undefined
                   2>開啟子畫面時,又觸發 blur event 一次  
                       --> 又開啟子畫面,導致子畫面排版不對  , eOpts 非空白
                   3>只需觸發一次(eOpts=undefined) 



1>*.js
//輸入[物料編號]&[庫房]&[儲存位置]後 , 加入  store       
    //blur 會被觸發 2 次,以致 V60202QA 被呼叫兩次, --> 子畫面排版不對
    Ext.getCmp("sub_MATNR").on('blur', function (me, eOpts) {
        ////STEP1 將BarCode碼([物料編號]&[庫房]&[儲存位置]) 轉成 [物料編號],[庫房],[儲存位置]
        var Tmp_Str = Ext.getCmp("sub_MATNR").getValue();
        if (checkisnull(Tmp_Str))
            return;
        //因為 blur 會被呼叫兩次, 子畫面重複出現兩次,所以子畫面排版不對, 
        //  e.getKey() === e.ENTER   --> eOpts = undefined , 才執行, 
        // 若其他的  trigger event , 不重複執行
        if (eOpts != undefined)
            return;
        var Tmp_MATNR = StrExtract(Tmp_Str, 1, "&");
        var Tmp_WH = StrExtract(Tmp_Str, 2, "&");
        var Tmp_SP = StrExtract(Tmp_Str, 3, "&");
        var gridstore = Ext.getCmp("sub_Grid").store;
        //檢核  [物料編號]&[庫房]&[儲存位置]  是否已存在  store
        //若存在,則傳回 index, 否則傳回 -1
        var Tmp_index = gridstore.findBy(function (rec, id) {
            var Tmp_bol = true;
            Tmp_bol = rec.data["MATNR"].toString() == Tmp_MATNR
                && rec.data["WH"].toString() == Tmp_WH
                && rec.data["SP"].toString() == Tmp_SP;
            return Tmp_bol;   // true : 有找到
        });
        //若已存在,則顯示訊息"件號+庫存+儲存位置已存在,不可重覆"
        //若不存在,則將"件號+庫存+儲存位置+..", 加入 store
        if (Tmp_index > -1) {
            Tmp_Str = "件號(" + Tmp_MATNR + ")<br>"
                + "庫房(" + Tmp_WH + ")<br>"
                + "儲存位置(" + Tmp_SP + ")<br>"
                + "已存在,不可重覆挑選<br>"
                + "請檢核!!<br>";
            mywarnalert(Tmp_Str);
            Ext.getCmp("sub_MATNR").setValue("");
            return;
        }
        else {   //將目前 件號+庫存+儲存位置"不存在 store, 則顯示子視窗,
            // { name: "MATNR" },            { name: "WH" },            { name: "SP" },            { name: "NAME" },            
            //{ name: "SQTY" }, { name: "USED_QTY" },
            //{ name: "UNIT" },            { name: "CLASS" },            { name: "CLASS_" },
            //出現子畫面, 輸入[領用數量]後,再加入 store
            console.log("CALL_V60202QA(Tmp_MATNR, Tmp_WH, Tmp_SP)", Tmp_cnt);
            console.log("me", me);
            console.log("eOpts", eOpts);
            CALL_V60202QA(Tmp_MATNR, Tmp_WH, Tmp_SP);
        }
    });  // end of  Ext.getCmp("sub_MATNR").on('blur', function (me, eOpts) {



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();
        }
    });