/** * Created by huangshengtao on 2016-4-12. */ define(function (require) { /** * 自动设置参照 * @param newRow */ function initRefObj(newRow) { if (newRow.FieldName.indexOf('OrgId') >= 0) { initOrgIdRef(newRow); } if (newRow.FieldName.indexOf('OrgCode') >= 0) { initOrgCodeRef(newRow); } if (newRow.FieldName.indexOf('OrgName') >= 0) { initOrgNameRef(newRow); } if (newRow.FieldName.indexOf('CntId') >= 0) { initCntIdRef(newRow); } if (newRow.FieldName.indexOf('CntCode') >= 0) { initCntCodeRef(newRow); } if (newRow.FieldName.indexOf('CntName') >= 0) { initCntNameRef(newRow); } if (newRow.FieldName.indexOf('UserId') >= 0) { initUserIdRef(newRow); } if (newRow.FieldName.indexOf('UserCode') >= 0) { initUserCodeRef(newRow); } if (newRow.FieldName.indexOf('UserName') >= 0) { initUserNameRef(newRow); } if (newRow.FieldName.indexOf('BizType') >= 0) { initBizRef(newRow); } if (newRow.FieldName.indexOf('PluCode') >= 0) { initPluRef(newRow); } } function initDefaultValue(newRow) { var defValue = ''; switch (TypeUtil.toString(newRow.FieldName)) { case 'BillNo': defValue = '*'; break; case 'DataOrgId': defValue = '@CREATEORGID'; break; case 'DataOrgCode': defValue = '@CREATEORGCODE'; break; case 'CrtDate': defValue = '@CREATEDATE'; break; case 'CrtUserId': defValue = '@CREATEUSERID'; break; case 'CrtUserCode': defValue = '@CREATEUSERCODE'; break; case 'SerialNo': defValue = '@NEXTID'; break; } newRow.DefaultValue = defValue; } /** * 更新默认的显示位置 * @param newRow */ function initDispPosition(newRow) { newRow.DispPosition = 3; newRow.DispPosition$ = '全不显示'; } /** * id,和时间戳之外都可是查询项 * @param newRow */ function initIsQrySele(newRow) { if (newRow.FieldName.indexOf('Id') < 0 && newRow.FieldName != 'Timemark') { newRow.IsQrySele = '1'; } } /** * 更新字段默认的小数位数 * @param newRow */ function initDispScale(newRow) { var dispScale = 0; if (newRow.FieldName.indexOf('Count') >= 0) { dispScale = 4; } if (newRow.FieldName.indexOf('Total') >= 0) { dispScale = 2; } if (newRow.FieldName.indexOf('Price') >= 0) { dispScale = 4; } newRow.DispScale = dispScale; if (dispScale > 0) { newRow.EditStyle = '13'; } } function initOrgCodeRef(newRow) { newRow.RefType = '2'; newRow.RefType$ = '表参照'; newRow.RefObj = 'vSmdCobOrg_L'; newRow.RefField = 'OrgCode'; newRow.RefFieldName = 'OrgName'; newRow.IsStrictRef = 1; newRow.Match = '*'; newRow.RefEditWhere = ' '; newRow.RefSearchWhere = 'LangId=\'{SYSVAR:langId}\''; newRow.RefSeparator = '-'; newRow.EditType = '01'; } function initOrgIdRef(newRow) { newRow.RefType = '3'; newRow.RefType$ = '属性参照'; newRow.RefObj = newRow.FieldName.substr(0, newRow.FieldName.length - 2) + 'Code'; newRow.RefField = 'OrgId'; newRow.RefSeparator = ''; } function initOrgNameRef(newRow) { newRow.RefType = '3'; newRow.RefType$ = '属性参照'; newRow.RefObj = newRow.FieldName.substr(0, newRow.FieldName.length - 4) + 'Code'; newRow.RefField = 'OrgName'; newRow.RefSeparator = ''; } function initCntCodeRef(newRow) { newRow.RefType = '2'; newRow.RefType$ = '表参照'; newRow.RefObj = 'vSmdCobCntUsOrg'; newRow.RefField = 'CntCode'; newRow.RefFieldName = 'CntName'; newRow.IsStrictRef = 1; newRow.Match = '*'; newRow.RefEditWhere = ''; newRow.RefSearchWhere = ''; newRow.RefSeparator = '-'; newRow.EditType = '01'; } function initCntIdRef(newRow) { newRow.RefType = '3'; newRow.RefType$ = '属性参照'; newRow.RefObj = newRow.FieldName.substr(0, newRow.FieldName.length - 2) + 'Code'; newRow.RefField = 'CntId'; newRow.RefSeparator = ''; } function initCntNameRef(newRow) { newRow.RefType = '3'; newRow.RefType$ = '属性参照'; newRow.RefObj = newRow.FieldName.substr(0, newRow.FieldName.length - 4) + 'Code'; newRow.RefField = 'CntName'; newRow.RefSeparator = ''; } function initUserCodeRef(newRow) { newRow.RefType = '2'; newRow.RefType$ = '表参照'; newRow.RefObj = 'vFrsUser'; newRow.RefField = 'UserCode'; newRow.RefFieldName = 'UserName'; newRow.IsStrictRef = 1; newRow.Match = '*'; newRow.RefSeparator = '-'; newRow.EditType = '01'; } function initUserIdRef(newRow) { newRow.RefType = '3'; newRow.RefType$ = '属性参照'; newRow.RefObj = newRow.FieldName.substr(0, newRow.FieldName.length - 2) + 'Code'; newRow.RefField = 'UserId'; newRow.RefSeparator = ''; } function initUserNameRef(newRow) { newRow.RefType = '3'; newRow.RefType$ = '属性参照'; newRow.RefObj = newRow.FieldName.substr(0, newRow.FieldName.length - 4) + 'Code'; newRow.RefField = 'UserName'; newRow.RefSeparator = ''; } /** * 自动设置业务类型参照 * @param newRow */ function initBizRef(newRow) { newRow.RefType = '2'; newRow.RefType$ = '表参照'; newRow.RefObj = 'vSmdCobCfgBizType_L'; newRow.RefField = 'BizType'; newRow.RefFieldName = 'BizTypeName'; newRow.IsStrictRef = 1; newRow.Match = '*'; newRow.RefEditWhere = 'LangId=\'{SYSVAR:langId}\' '; newRow.RefSearchWhere = 'LangId=\'{SYSVAR:langId}\''; newRow.RefSeparator = '-'; } /** * 自动设置商品编码参照 * @param newRow */ function initPluRef(newRow) { newRow.RefType = '2'; newRow.RefType$ = '表参照'; newRow.RefObj = 'vSmdCobPlu_L'; newRow.RefField = 'PluCode'; newRow.RefEditWhere = 'LangId=\'{SYSVAR:langId}\' '; newRow.RefSearchWhere = 'LangId=\'{SYSVAR:langId}\''; } /** * 自动设置列头宽度 * @param newRow */ function initHeaderWidth(newRow){ var fieldName = newRow.FieldName; // || fieldName.indexOf('Times') >= 0 if (fieldName.indexOf('BillNo') >= 0 || fieldName.indexOf('Date') >= 0 || fieldName.indexOf('User') >= 0 || fieldName.indexOf('OrgCode') >= 0 || fieldName.indexOf('Plu') >= 0) { newRow.HeaderWidth="13"; } if (fieldName.indexOf('SerialNo') >= 0) { newRow.HeaderWidth="5"; } if (fieldName.indexOf('SendStatus') >= 0) { newRow.HeaderWidth="14"; } if (fieldName.indexOf('CargoNo') >= 0) { newRow.HeaderWidth="10"; } if (fieldName.indexOf('BarCode') >= 0 || fieldName.indexOf('Rate') >= 0 || fieldName.indexOf('Count') >= 0 || fieldName.indexOf('Price') >= 0 || fieldName.indexOf('Total') >= 0 || fieldName.indexOf('SpecDesc') >= 0 || fieldName.indexOf('Times') >= 0) { newRow.HeaderWidth="8"; } } return { importDataObj: function (newRow, objRow) { initRefObj(newRow); initDefaultValue(newRow); initDispScale(newRow); initDispPosition(newRow); initIsQrySele(newRow); initHeaderWidth(newRow); } } })