Netsuite 中 js 扫描枪应用 解读一-CarlZeng

function Syncdepartment(fieldspec, linenum, onlySlaveSelect, mach, addlparams) { var sel = document.forms[‘item_form’].elements[‘department’+linenum]; var value = sel != null ? getSelectValue(sel) …

function Syncdepartment(fieldspec, linenum, onlySlaveSelect, mach, addlparams)
{
var sel = document.forms[‘item_form’].elements[‘department’+linenum];
var value = sel != null ? getSelectValue(sel) : -1;
if (value == -1) {resetlist(sel);
nlOpenWindow(‘/app/common/otherlists/departmenttype.nl?target=item:department’+linenum+’&label=Department’, ‘newitemdepartment’,’width=400,height=175,resizable=yes,scrollbars=no’);
return; }
sizeLowerTabBGDiv(‘item’);
}
function Listdepartment(fld, multi,linenum,addlparams) {
var displayField = document.forms[‘item_form’].elements[‘department’+linenum];if ( displayField != null && !displayField.isvalid) { displayField.isvalid = true; window.isvalid = true; displayField.value = ‘’;}NLPopupSelect_displayLoadingDiv(‘department’, false);var serverUrl = ‘/app/accounting/transactions/itemship.nl?cp=T&nexus=1&memdoc=0&transform=salesord&advbilltransform=T&at=T&cf=305&purchase=F&fromtrnfrord=F&shipper=ns&e=T&q=department&id=’+trim(document.forms[‘main_form’].elements[‘id’].value)+’&l=T&t=item:department&machine=item’+(multi ? ‘&multi=T’ : ‘’)+’’+’&ln=’+linenum+(addlparams?’&’+addlparams:’’)+’’;
document.getElementById(‘server_commands’).src=serverUrl; }

//扫描枪自动回车以后查询扫描码的事件。

function itemLocateField(val) {
var frm = document.forms[‘item_form’];
var linenum = findEncodedValue(‘item’,’itemname_selector’,val);
if (linenum < 0)
linenum = findEncodedValue(‘item’,’itemupc’,val);
if (linenum >= 0)
{ frm.elements[‘quantity’+linenum].value = frm.elements[‘quantity’+linenum].value.length == 0 ? ‘1’ : parseFloat(frm.elements[‘quantity’+linenum].value)+1;frm.elements[‘quantity’+linenum].onchange(); }
else alert(‘No Match.’); }

function findEncodedValue(machine_name, fieldname, value)
{
var i = getEncodedFieldPosition(machine_name, fieldname);
if (i == -1)
return -1;
for (var linenum=0;linenum < getLineCount(machine_name);linenum++)
{
var linedata = getLineArrayLine(machine_name,linenum);
if (value == linedata[i])
return linenum+1;
}
return -1;
}
function getEncodedFieldPosition(machine_name, fieldname)
{
var fieldnames = getFieldNamesArray(machine_name);
if ( fieldnames != null )
{

return fieldnames[fieldname] != null ? fieldnames[fieldname] : -1;

}
return -1;
}

货品编码不是动态去货品那里每次扫描去查询的,而在加载单据时,那么货品码早就在那里等待匹配了。这样效率就能有保证。 12:13 2010-03-03

-—————————————————

onblur

event.cancelBubble = true 用来阻止enter键向父级传递(导致系统会认为要保存单据了),itemLocateField(value); 是回车以后查询扫描码的事件。

个性化需求沟通 扫客服加V加群: