目的: V20304A - 工時提列 - Grid的 Columns 不對 - 相同變數名稱被覆蓋
處理說明: 1>JavaScript 的相同變數宣告, 相同變數名稱, 會被最新的變數覆蓋
V20304A_JSON.js 定義 sub_Columns
V20304D1_JSON.js 也定義 sub_Columns
2>因V20304D1_JSON.js 最後載進來
所 sub_Columns 會覆蓋 V20304A_JSON.js 的 sub_Columns
3>若同時載進來的子程式(V20304*.js )
其全域的變數名稱(*_JSON.js)不可重覆, 以免彼此互相覆蓋
4>全域變數名稱取不同名稱, 即可解決該問題
V20304A_JSON.js 定義 sub_Columns_V20304A
V20304D1_JSON.js 也定義 sub_Columns_V20304D1
Ext.Loader.loadScript({
url: '../JsFunction/V20304_JSON.js',
onLoad: function(){
Ext.syncRequire('TM.TMMDViewEdit');
}
});
//將載入 V20304A/B/C/D/D1/E/F/H.js , 並載入V20304A_JSON.js V20304D1_JSON.js
Ext.Loader.loadScript({ url: '../JsFunction/myfunc.js' });
Ext.Loader.loadScript({ url: '../JsFunction/V20304A.js' }); //工時提列
Ext.Loader.loadScript({ url: '../JsFunction/V20304B.js' }); //單筆匯出
Ext.Loader.loadScript({ url: '../JsFunction/V20304C.js' }); //單筆匯入
Ext.Loader.loadScript({ url: '../JsFunction/V20304D.js' }); //確認轉TLS
Ext.Loader.loadScript({ url: '../JsFunction/V20304E.js' }); //批次匯出
Ext.Loader.loadScript({ url: '../JsFunction/V20304F.js' }); //批次匯入
Ext.Loader.loadScript({ url: '../JsFunction/V20304H.js' }); //維修附檔
1>>V20304A.js
Ext.Loader.loadScript({ url: '../JsFunction/myfunc.js', });
Ext.Loader.loadScript({ url: '../GUITemplate/EmployeeTree.js' });
Ext.Loader.loadScript({ url: '../JsFunction/V20304A_JSON.js',});
2>>V20304A_JSON.js - 宣告的變數為 全域變數
// [工時提列]鈕 - Grid子畫面欄位 - AMM_AR
var sub_model = [
{ name: "FMNO" },
{ name: "AMINO" },
{ name: "ITM" },
{ name: "ITMNO" },
{ name: "WKDESC" },
{
name: "STDHR",
convert: function (value, record) { return Ext.util.Format.round(value, 2); }
},
{
name: "RQHR",
convert: function (value, record) { return Ext.util.Format.round(value, 2); }
},
{ name: "REMARK" },
{ name: "PNSHTNO" }
];
var sub_Columns = [
{ header: "", xtype: "rownumberer", width: 40, align: "center", sortable: false },
//{ header: "系統件單號", dataIndex: "FMNO", width: 130, sortable: false, TMType: "string" },
{ header: "AMM項次", dataIndex: "AMINO", width: 80, sortable: false, TMType: "string" },
//{ header: "流水序號", dataIndex: "ITM", width: 50, sortable: false, TMType: "string" },
{ header: "項次", dataIndex: "ITMNO", width: 70, sortable: false, TMType: "string" },
{ header: "工作項目", dataIndex: "WKDESC", width: 150, sortable: false, TMType: "string" },
{ header: "標準工時", dataIndex: "STDHR", width: 70, sortable: false, align: "right", TMType: "float", renderer: Ext.util.Format.numberRenderer('0,000.00') },
{
header: "需求工時", dataIndex: "RQHR", width: 70, sortable: false, align: "right", TMType: "float", renderer: Ext.util.Format.numberRenderer('0,000.00'),
editor: { xtype: 'textfield', allowBlank: true }, //允許空白
//editor: 'textfield',
},
{
header: "備註", dataIndex: "REMARK", width: 250, sortable: false, TMType: "string",
editor: { xtype: 'textfield', allowBlank: true }, //允許空白
},
//{ header: "件號專用表單編號", dataIndex: "PNSHTNO", width: 500, sortable: false, TMType: "string" }
];
3>>V20304D.js
Ext.Loader.loadScript({ url: '../JsFunction/myfunc.js' });
Ext.Loader.loadScript({ url: '../JsFunction/V20304D1.js' });
4>>V20304D1.js
Ext.Loader.loadScript({ url: '../GUITemplate/EmployeeTree.js' });
Ext.Loader.loadScript({ url: '../JsFunction/V20304D1_JSON.js',});
5>V20304D1_JSON.js
// JavaScript source code
var sub_Fields = [
{ name: "EMPLYNM" },
{ name: "NOTES_MAIL" },
];
var sub_Columns = [
{ header: "姓名", dataIndex: "EMPLYNM", width: 80, TMType: "string" },
{ header: "Email", dataIndex: "NOTES_MAIL", width: 130, TMType: "string" },
];
沒有留言:
張貼留言