/**
* grid render
*/
Ext.QuickTips.init();
Ext.define('erp.util.RenderUtil', {
/**
* @PLM
*/
render_change: function(val, meta, record){
if(record && record.data.percentdone < 30)
return ''+'' + val + '';
else if(record && record.data.percentdone > 30 && record.data.percentdone < 50)
return ''+'' + val + '';
else if(record && record.data.point == 100){
return ''+'' + val + '';
}else if(record && record.data.point > 80){
return ''+'' + val + '';
}
else return val;
},
/**
* @PLM
*/
plm_recordchange: function(val, meta, record){
if(record && record.data.wr_percentdone == 100){
if(record.data.wr_haveattach==1){
return ''+'' + val + '';
}
else return ''+'' + val + '';
}
else {
if(record.data.wr_haveattach==1){
return '' + val + '';
}
else return '' + val + '';
}
},
/**
* @PLM
*/
plm_projectbudget:function(val,meta,record){
if(record.data.cost>record.data.budget){
return '
';
}else return '
';
},
plm_projectchange: function(val, meta, record){
if(record && record.data.prjplan_prjname == 'ERP')
return ''+'' + val + '';
else return '' + val + '';
},
plm_reduce: function(val, meta, record, x, y, store, view){
var me = this.RenderUtil || this;
var field = this.columns[y].dataIndex;
if(me.args){
var arg = me.args.plm_reduce[field];
var maxValue = 0;
if(arg && arg.length > 0){
var v = 0;
Ext.each(arg, function(a, index){
if(Ext.isNumber(a)){
v = a;
} else {
v = record.data[a] || 0;
}
if(index == 0){
maxValue = Number(v);
} else {
maxValue -= Number(v);
}
});
}
val = (val == null || val == 0) ? maxValue : val;
if(record.data[field] != val){
record.set(field, val);
}
if(val > 0){
return '' +
'' + val + '';
} else if(val < 0){
return 0;
} else {
return val;
}
} else {
return val;
}
},
/**
* @PLM
*/
plm_resource_rank:function(val,meta,record){
if(record&&record.data.percentdone>89){
return ''+''+''+'' + val + '';
}else if(record&&record.data.percentdone>69&&record.data.percentdone<90){
return ''+''+'' + val + '';
}else if(record&&record.data.percentdone>50&&record.data.percentdone<70){
return ''+''+'' + val + '';
}
},
/**
*@PLM
* */
PLM_planstatus:function(val,meta,record){
var statuscode=record.data['prjplan_statuscode'];
if(statuscode=='FINISHED'){
return '' +
'' + val + '';
}else if(statuscode=='DOING'){
return '' +
'' + val + '';
}else return ''+'' + val + '';
},
PLM_MainTaskStatus:function(val,meta,record){
var statuscode=record.data['handstatuscode'];
if(statuscode=='FINISHED'){
return '' +
'' + val + '';
}else if(statuscode=='DOING'){
return '' +
'' + val + '';
}else if(statuscode=='ACTIVE'||statuscode=='STOP'){
return '' +
'' + val + '';
}else {
return ''+'' + val + '';
}
},
PLM_TaskStatus:function(val,meta,record){
var statuscode=record.data['ra_statuscode'];
if(statuscode=='FINISHED'){
return '' +
'' + val + '';
}else if(statuscode=='START'){
return '' +
'' + val + '';
}else if(statuscode=='STOP'){
return ''+'' + val + '';
}else {
return ''+'' + val + '';
}
},
/**
*@PLM
* */
plm_BUGAttach:function(val,meta,record){
if(record&&record.data.cld_attach!=null&&record.data.cld_attach!=""){
var attach=record.data.cld_attach;
//var path="dsd";
// return '下载';
return ''+val+'' + attach.split(";")[0] + '';
}else return '' +
'' + val + '';
},
plm_BUGTurn:function(val,meta,record){
if(record&&record.data.cc_turn!=null&&record.data.cc_turn!=""){
var turn=record.data.cc_turn;
meta.style = "text-align:center";
return ''+turn.split(";")[0]+''+turn.split(";")[1];
}else return "";
},
/**
*@PLM
* */
plm_BUGStatus:function(val,meta,record){
var statuscode=record.data.cld_statuscode?record.data.cld_statuscode:record.data.cbd_statuscode;
if(statuscode=='PENDING'){
return '' +
'' + val + '';
}else if(statuscode=='TESTING'){
return '' +
'' + val + '';
}else if(statuscode=='HANDED'){
return '' +
'' + val + '';
}else if(statuscode=='NOTDEAL'){
return '' +
'' + val + '';
}
},
plm_BUGTest:function(val,meta,record){
if(val&&val!=null){
if(val=='-1'){
return '测试通过';
}else if(val=='0'){
return '测试失败';
}
}else return null;
},
/**
*稽核查看单据信息
* */
SysCheckHref:function(val,meta,record){
var url=null;
if(record.data.scd_url.indexOf('?')>0){
if(record.data.sf_mainfield){
//主从记录都有
url=record.data.scd_url+"&formCondition="+record.data.sf_keyfield+"IS"+record.data.scd_sourceid+"&gridCondition="+record.data.sf_mainfield+"IS"+record.data.scd_sourceid;
}else url=record.data.scd_url+"&formCondition="+record.data.sf_keyfield+"IS"+record.data.scd_sourceid;
}else {
if(record.data.sf_mainfield){
//主从记录都有
url=record.data.scd_url+"?formCondition="+record.data.sf_keyfield+"IS"+record.data.scd_sourceid+"&gridCondition="+record.data.sf_mainfield+"IS"+record.data.scd_sourceid;
}else url=record.data.scd_url+"?formCondition="+record.data.sf_keyfield+"IS"+record.data.scd_sourceid;
}
return '' + val + '';
},
/**
*查看工作日程
* */
seeCalendar:function(val,meta,record){
if(record.data.epd_emcode!=''&&record.data.epd_starttime!=null && record.data.epd_epid!=0){
var time=Ext.Date.format(record.data.epd_starttime, 'Y-m-d');
return "";
}
return '';
},
/**
* 生产计划链接
* */
MakePlanHref:function(val,meta,record){
var url='jsps/pm/make/makeBase.jsp?whoami=Make!Base';
var code=record.data.ma_code;
var keyValue=record.data.ma_id;
url+='&formCondition=ma_idIS'+keyValue+'&gridCondition=mm_maidIS'+keyValue;
return '' + code + '';
},
/**
* 生产计划链接
* */
MakeHref:function(val,meta,record){
var url='jsps/pm/make/makeBase.jsp?whoami=Make';
var code=record.data.ma_code;
var keyValue=record.data.ma_id;
url+='&formCondition=ma_idIS'+keyValue+'&gridCondition=mm_maidIS'+keyValue;
return '' + code + '';
},
/**
* 应付发票 付款详情
* */
PayApbillHref:function(val,meta,record){
var url='jsps/common/commonpage.jsp?whoami=PayAPBill';
var code=record.data.ppdd_billcode;
url+='&formCondition=ab_codeIS'+code+'&gridCondition=pa_codeIS'+code;
return '' + code + '';
},
/**
* 采购订单链接
* */
PurchaseHref:function(val,meta,record){
var url='jsps/scm/purchase/purchase.jsp';
var code=record.data.vad_pucode;
url+='?formCondition=pu_codeIS'+code+'&gridCondition=pd_codeIS'+code;
return '' + code + '';
},
/**
* 付款申请单 应付发票链接
* */
ApbillHref:function(val,meta,record){
var url='jsps/fa/ars/apbill.jsp?whoami=APBill!CWIM';
var code=record.data.ppdd_billcode;
url+='&formCondition=ab_codeIS'+code+'&gridCondition=abd_codeIS'+code;
return '' + code + '';
},
/**
* 预付款申请单 采购订单链接
* */
PurcYFHref:function(val,meta,record){
var url='jsps/scm/purchase/purchase.jsp';
var code=record.data.ppdd_pucode;
url+='?formCondition=pu_codeIS'+code+'&gridCondition=pd_codeIS'+code;
return '' + code + '';
},
/**
*
* 检验单链接
* */
IQCHref:function(val,meta,record){
var url='jsps/scm/qc/verifyApplyDetail2.jsp?whoami=VerifyApplyDetail';
var code=record.data.ve_code;
url+='&formCondition=ve_codeIS'+code+'&gridCondition=ved_codeIS'+code;
return '' + code + '';
},
/**
* 检验单链接 --第二个明细表只能传关联id
*/
newIQCHref:function(val,meta,record){
if(!Ext.isEmpty(val)) {
if(!window.__fn) {
var fn = function(ve_code) {
Ext.Ajax.request({
url: basePath + 'common/getFieldData.action',
params: {
caller: 'QUA_VerifyApplyDetail',
field: 've_id',
condition: 've_code=\'' + ve_code + '\''
},
callback: function(opt, s, r) {
if(s) {
var rs = Ext.decode(r.responseText);
if(rs.data != null && rs.data > 0) {
openUrl('jsps/scm/qc/verifyApplyDetail2.jsp?whoami=VerifyApplyDetail&formCondition=ve_idIS' + rs.data +
'&gridCondition=ved_veidIS' + rs.data);
}
}
}
});
};
window.__fn = fn;
}
val = '' + val + '';
}
return val;
},
/**
* 订阅项链接 SubsFormula
*/
SubsFHref:function(val,meta,record){
if(!Ext.isEmpty(val)) {
if(!window.__fn) {
var fn = function(code_) {
Ext.Ajax.request({
url: basePath + 'common/getFieldData.action',
params: {
caller: 'SubsFormula',
field: 'id_',
condition: 'code_=\'' + code_ + '\''
},
callback: function(opt, s, r) {
if(s) {
var rs = Ext.decode(r.responseText);
if(rs.data != null && rs.data > 0) {
openUrl('jsps/common/subsformula.jsp?formCondition=id_IS' + rs.data +
'&gridCondition=formula_id_IS' + rs.data);
}
}
}
});
};
window.__fn = fn;
}
val = '' + val + '';
}
return val;
},
/*
*点开链接
*/
Href: function(val, meta, record,x,y){
var me = this.RenderUtil || this;
var field = this.columns[y].dataIndex;
var KeyValue = 0;
var url='';
var title='';
var arg = me.args.Href[field];
var keyField=arg[0];
var data=record.data;
if(arg && arg.length > 0){
KeyValue=data[keyField];
url=arg[1];
title=arg[2];
}
if(val==''||val==$I18N.common.grid.emptyText) return val;
if(keyField.indexOf('code')>=0){
return '' + val + '';
}
return '' + val + '';
},
/**
* 生产计划已分拆
* */
MakePlanSplited:function(val,meta,record){
if(record.data.ma_version){
meta.tdCls = "x-grid-cell-renderer-cl";
}
},
SysCheckStatus:function(val,meta,record){
var statuscode=record.data.scd_statuscode;
if(statuscode=='UNEXECUTE'){
return '' +
'' + val + '';
}else if(statuscode=='EXECUTE'){
return '' +
'' + val + '';
}else if(statuscode='FREEZE') return '' +
'' + val+ '';
else return null;
},
SysCheckMethod:function(val,meta,record){
var method=record.data.scd_method;
if(method=='-1'){
return '扣分';
}else if(method=='0') return '提醒';
else return null;
},
SysCheckPunish:function(val,meta,record){
var method=record.data.scd_method;
meta.align='left';
if(record.data.scd_ispunished=='-1'){
return '已生成';
}else if(record.data.scd_ispunished=='0'&&method=='-1'){
return '未生成';
}else return '无';
},
/**
* 显示所有信息
* */
showAll:function(val,meta,record){
if(val&&val!=null&&val.length>20){
return val.substring(0,20)+'';
}else return val;
},
/**
* 通过args传递参数到function
*/
args: new Object(),
/**
* 公式计算
* 通用方法
* @expression formula:pd_orderprice/(1+pd_taxrate/100)*pd_inqty
*
*/
formula: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
var editvalue=val;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var arg = me.args.formula[field];
if(arg && arg.length > 0){
var data = record.data,keys = Ext.Object.getKeys(data),formu = arg[0];
Ext.each(keys, function(k){
if(contains(formu, k, true)) {
formu = formu.replace(new RegExp(k,"gm"), '(' + data[k] + ')');
}
});
var d = 0;
try {
d = eval(formu);
} catch (e) {
d = 0;
}
if(d == null || d == '' || String(d) == 'NaN' || String(d).length == 0)
d = 0;
var _val = val, _d = d,dic=2;
if(column.format) {
dic=column.format.substr(column.format.indexOf('.')+1).length;
d=d.toFixed(dic);
_val = Ext.util.Format.number(val, column.format);
_d = Ext.util.Format.number(d, column.format);
}
val = _val;
//用原值赋值
if(_val != _d) {
val = d;
record.set(field, d);
val = _d;
}
}
if(record.get(field) != 0)
return val;
return "";
},
/**
* 通过args传递参数到function
*/
args: new Object(),
/**
* 公式计算
* 通用方法
* @expression formula:pd_orderprice/(1+pd_taxrate/100)*pd_inqty
*/
_formula: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var arg = me.args._formula[field];
if(arg && arg.length > 0){
var data = record.data,keys = Ext.Object.getKeys(data),formu = arg[0];
Ext.each(keys, function(k){
if(contains(formu, k, true)) {
formu = formu.replace(new RegExp(k,"gm"), '(' + data[k] + ')');
}
});
var d = 0;
try {
d = eval(formu);
} catch (e) {
d = 0;
}
if(d == null || d == '' || String(d) == 'NaN' || String(d).length == 0)
d = 0;
var fsize = (column.format && column.format.indexOf('.') > -1) ?
column.format.substr(column.format.indexOf('.') + 1).length : 2,
_d = d.toFixed(fsize);
//按设置的格式长度赋值
if(val != _d) {
record.set(field, _d);
val = _d;
}
val = Ext.util.Format.number(val, column.format || '0,000.00');
}
if(record.get(field) != 0)
return val;
return "";
},
/**
* 公式计算
* 通用方法
* @expression formula:pd_orderprice/(1+pd_taxrate/100)*pd_inqty
*/
overqty: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var arg = me.args.overqty[field];
if(arg && arg.length > 0){
var data = record.data,keys = Ext.Object.getKeys(data),formu = arg[0];
Ext.each(keys, function(k){
if(contains(formu, k, true)) {
formu = formu.replace(new RegExp(k,"gm"), '(' + data[k] + ')');
}
});
var d = 0;
try {
d = eval(formu);
} catch (e) {
d = 0;
}
if(d == null || d == '' || String(d) == 'NaN' || String(d).length == 0)
d = 0;
var _val = val, _d = d;
if(column.format) {
_val = Ext.util.Format.number(val, column.format);
_d = Ext.util.Format.number(d, column.format);
}
val = _val;
if(_val != _d) {
//鉴于小数问题 保留2位小数
if(column.editor || (column.getEditor && column.getEditor())) {
val = (!Ext.isNumber(val) || val == 0) ? d : val;
if(Number(val) - d > 0){
val = d;
showError('请不要输入超过最大数量' + d + "的值!");
}
} else {
val = d;
}
var _v = val;
if(column.xtype == 'numbercolumn') {
_v = Ext.util.Format.number(val, column.format);
}
if(Ext.util.Format.number(record.data[field], column.format) != _v){
record.set(field, val);
}
return _v;
} else {
return val;
}
}
},
/**
* 公式计算
* 通用方法
* @expression eval:pd_orderprice/(1+pd_taxrate/100)*pd_inqty
*/
eval: function(val, meta, record, x, y, store, view){
meta.tdCls = "x-grid-cell-renderer-bl";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var arg = me.args.eval[field];
if(arg && arg.length > 0){
val = record.get(field);
var data = record.data,keys = Ext.Object.getKeys(data),formu = arg[0];
Ext.each(keys, function(k){
if(contains(formu, k, true)) {
formu = formu.replace(new RegExp(k,"gm"), '(' + data[k] + ')');
}
});
var d = 0;
try {
d = eval(formu);
} catch (e) {
d = 0;
}
if(d == null || d == '' || String(d) == 'NaN' || String(d).length == 0)
return val;
var _val = val, _d = d;
if(column.format) {
_val = Ext.util.Format.number(val, column.format);
_d = Ext.util.Format.number(d, column.format);
}
if(_val != _d) {
if(record.modified == null || record.modified[field] == null) {
val = d;
record.set(field, d);
record.modified[field] = d;
}
}
}
return val;
},
/**
* 适用于所有日期类型
* 超时提示
* 当v < 当前日期时,表示超时
* 需要在dataListDetail表的dld_render 配置 overtime:{dateField}
* 注意:日期类型貌似不能直接render,所以要借助其他字段
* @expression overtime:pu_delivery
*/
overtime: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var d = new Date();
var arg = me.args.overtime[field];
if(arg && arg.length > 0){
d = record.data[arg[0]];//me.args[0]为需要逻辑判断的日期字段
}
if(!Ext.isDate(d)){
d = Ext.Date.parse(d, 'Y-m-d H:i:s') || Ext.Date.parse(d, 'Y-m-d');
}
if(d < new Date()){
return '' +
'' + val + '';
} else {
return val;
}
},
pd_auditstatus_show:function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,column = grid.columns[y],field = column.dataIndex;
var returnStr;
if(val == 'PARTAR'||val == '部分开票'){
returnStr = '部分开票';
}else if(val == 'TURNAR'||val == '已开票'){
returnStr = '已开票';
}else{
returnStr = '未开票';
}
if(val != returnStr) {
val = returnStr;
record.set(field, val);
}
return val;
},
defaultValue:function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(val == null || val == '' || val == 0){
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var v = record.data[field];
if(v == null || v == '' || (column.xtype == 'numbercolumn' && v == 0)){
var arg = me.args.defaultValue[field];
if(arg && arg.length > 0){
val = arg[0];
}
if(val != null && val != '' && val != 0){
record.set(field, val);
}
}
}
if(column.xtype == 'numbercolumn' && val != 0){
val = Ext.util.Format.number(val, column.format);
}
return val;
},
/**
* 解析链接,并打开
* @expression jsps/scm/sale/sendnotify.jsp?formConditionISsn_id={snd_snid}&gridConditionISsnd_snid={snd_snid}
*/
link: function(val, m, record, x, y, store, view) {
var grid = view.ownerCt, me = grid.RenderUtil,column = grid.columns[y], url = column.logic|| (me && me.args ? me.args.link[column.dataIndex][0] : '');
if(url) {
var res = '';
if(url == 'necessaryField' || url == 'orNecessField') {
if(!val)
res = '';
url = me.args ? me.args.link[column.dataIndex][0] : '';
}
var index = 0, length = url.length, s, e;
while(index < length) {
if((s = url.indexOf('{', index)) != -1 && (e = url.indexOf('}', s + 1)) != -1) {
url = url.substring(0, s) + record.get(url.substring(s+1, e)) + url.substring(e+1);
index = e + 1;
} else {
break;
}
}
return res + '' + val + '';
}
return val;
},
/**
* val不能小于当前日期
* @expression undertime
*/
undertime: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var d = Ext.Date.parse(Ext.Date.toString(new Date()), 'Y-m-d');
var grid = view.ownerCt,column = grid.columns[y],field = column.dataIndex;
val = record.data[field];
if(val == null) {
val = Ext.Date.toString(d);
} else {
if(!Ext.isDate(val)){
val = Ext.Date.parse(val, 'Y-m-d');
}
if(val < d){
val = Ext.Date.toString(d);
showError("日期不能小于当前日期!");
} else {
val = Ext.Date.toString(new Date(val));
}
}
if(Ext.isDate(record.data[field])){
if(Ext.Date.toString(record.data[field]) != val){
record.set(field, val);
}
} else {
if(record.data[field] != val){
record.set(field, val);
}
}
return val;
},
/**
* 适用于所有数字类型
* 数量过大提示
* 当val > d时,表示过大
* 需要在dataListDetail表的dld_render 配置 oversize:{num}
* @expression oversize:100
* @expression oversize:pd_qty
*/
oversize: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var d = val;
var arg = me.args.oversize[field];
if(arg && arg.length > 0){
if(Ext.isNumber(arg[0])){
d = Number(arg[0]);
} else {
d = Number(record.data[arg[0]]);
}
}
if(val > d){
return '' +
'' + val + '';
} else {
return val;
}
},
/**
* 适用于所有数字类型
* 数量过小提示
* 当val < d时,表示过小
* 需要在dataListDetail表的dld_render 配置 undersize:{num}
* @param arg为number类型或某字段
* @expression undersize:100
* @expression undersize:pd_yqty
*/
undersize: function(val, meta, record, x, y, store, view){
meta.style = "background:#CDB5CD;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex,uCol = null;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var d = val;
var arg = me.args.undersize[field];
if(arg && arg.length > 0){
if(!Ext.isNumber(Number(arg[0]))){
d = Number(record.data[arg[0]]);
var rr = grid.columns.filter(function(c){
return c.dataIndex == arg[0];
});
if(rr.length > 0) {
uCol = rr[0];
}
} else {
d = Number(arg[0]);
}
}
if(record.data[field] != val){
record.set(field, val);
}
if(!Ext.isNumber(val)){
val = d;
record.set(field, val);
showError('请输入数字!');
} else{
if(val < d){
if(val != 0) {
var err = '请不要输入低于';
if(uCol != null) {
err += '<' + uCol.text + '>';
}
showError(err + '<' + d + ">的值!");
}
val = d;
record.set(field, val);
}
}
var str = val;
if(column.format) {
str = Ext.util.Format.number(val, column.format);
}
if(val < d){
return '' +
'' + str + '';
} else {
return str;
}
},
/**
* 适用于所有数字类型
* 数量介于{min}~{max}
* @expression betweensize:0:100
* @expression betweensize:0:pd_qty
* @expression betweensize:pd_tqty:pd_qty
*/
betweensize: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var arg = me.args.betweensize[field];
var min = 0;
var max = 0;
if(arg && arg.length > 0){
if(!Ext.isNumber(Number(arg[0]))){
min = record.modified[arg[0]];
} else {
min = Number(arg[0]);
}
if(!Ext.isNumber(Number(arg[1]))){
max = record.modified[arg[1]];
} else {
max = Number(arg[1]);
}
}
if(record.data[field] != val){
record.set(field, val);
}
if(!Ext.isNumber(val)){
val = max;
record.set(field, val);
showError('请输入数字!');
} else{
if(val < min){
val = max;
record.set(field, val);
showError('请不要输入低于' + min + "的值!");
} else if(val > max){
val = max;
record.set(field, val);
showError('请不要输入大于' + max + "的值!");
}
}
if(val < min){
return '' +
'' + val + '';
} else if(val > max){
return '' +
'' + val + '';
} else {
return val;
}
},
/**
* 通用方法
* 值是否为空
* @expression isnull
*/
isnull: function(val, meta, record){
meta.style = "background:#C6E2FF;";
if(val == null || val == ''){
return '' +
'' + val + '';
} else {
return val;
}
},
/**
* 通用方法
* 值=arg[0]+arg[1]+...
* @expression plus:pd_tqty:pd_yqty
* @expression plus:pd_tqty:100:pd_yqty
*/
plus: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex,format = column.format,type = column.xtype;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var d = 0;
var arg = me.args.plus[field];
if(arg && arg.length > 0){
Ext.each(arg, function(a, index){
if(Ext.isNumber(a)){
d += Number(a);
} else {
d += Number(record.data[a]);
}
});
}
if(record.data[field] != d){
record.set(field, d);
}
if(format && type =='numbercolumn'){
d = Ext.util.Format.number(d, format);
}
return '' +
'' + d + '';
},
/**
* 通用乘法方法
* 值=arg[0]*arg[1]*...
* @expression multiply:pd_tqty:pd_price
* @expression multiply:pd_tqty:100:pd_rate
*/
multiply: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt, me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex,format = column.format,type = column.xtype;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var d = 1;
var red= d;
var arg = me.args.multiply[field];
if(arg && arg.length > 0){
Ext.each(arg, function(a, index){
if(Ext.isNumber(a)){
d = d * Number(a);
} else {
d = d * Number(record.data[a]);
}
if(format&&type =='numbercolumn'){
red = Ext.util.Format.number(d,format);
}else{
red = d;
}
});
}
if(record.data[field] != d){
record.set(field, d);
}
return '' +
'' + red + '';
},
/**
* 通用方法
* A floating:B
* 比较A相对于B的浮动变化
* @expression floating:B
*/
floating: function(val, meta, record, x, y, store, view) {
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
return val;
}
var arg = me.args.floating[field], a = null, b = null, f = null, n = null, istxt = true;
if(column.xtype == 'datecolumn') {
if(!val) return null;
a = record.get(arg);
b = val;
f = (column.format || 'Y-m-d');
n = Ext.Date.format(val, f);
istxt = false;
} else if(column.xtype == 'numbercolumn') {
a = Number(record.get(arg));
b = Number(val);
f = (column.format || '0,000');
n = Ext.util.Format.number(val, f);
istxt = false;
} else {
a = record.get(arg);
b = val;
}
if(istxt) {
if(a != b) {
return '' + val + '';
} else {
return val;
}
} else {
if(a < b) {
return '' +
'' + n + '';
} else if(a > b) {
return '' +
'' + n + '';
} else if(a == 0 && b == 0) {
return '';
}
}
return n;
},
ars_prodtoapbill_outqty:function(val, meta, record, x, y){
var inqty = 0;
var outqty = 0;
var returnqty = 0;
if(record.data['pd_inqty']!=null&&record.data['pd_inqty']){
inqty = Ext.Number.from(record.data['pd_inqty'],0);
}
if(record.data['pd_outqty']!=null&&record.data['pd_outqty']){
inqty = Ext.Number.from(record.data['pd_inqty'],0);
}
returnqty=outqty-inqty;
if(val != returnqty){
record.set('pd_outqty', returnqty);
val = returnqty;
}
return val;
},
ars_prodtoarbill_price:function(val, meta, record, x, y){
var orderprice = 0.00;
var sendprice = 0.00;
var returnprice = 0.00;
if(record.data['pd_orderprice']!=null&&record.data['pd_orderprice']){
orderprice = Ext.Number.from(record.data['pd_orderprice'],0.00);
}
if(record.data['pd_sendprice']!=null&&record.data['pd_sendprice']){
sendprice = Ext.Number.from(record.data['pd_sendprice'],0.00);
}
returnprice=Math.abs(orderprice-sendprice);
returnprice=Ext.util.Format.number(returnprice,'0.00');
if(val != returnprice){
record.set('pd_showprice', returnprice);
val = returnprice;
}
return val;
},
/**
* 出货数量 outqty - inqty
* @param val
* @param meta
* @param record
* @param x
* @param y
* @returns
*/
ars_prodtoapbill_outqty:function(val, meta, record, x, y){
var inqty = 0;
var outqty = 0;
var returnqty = 0;
if(record.data['pd_inqty']!=null&&record.data['pd_inqty']){
inqty = Ext.Number.from(record.data['pd_inqty'],0);
}
if(record.data['pd_outqty']!=null&&record.data['pd_outqty']){
outqty = Ext.Number.from(record.data['pd_outqty'],0);
}
returnqty=outqty-inqty;
if(val != returnqty){
record.set('pd_showqty', returnqty);
val = returnqty;
}
return val;
},
/**
* @CRM
* 客户关系商机状态显示
*/
chanceAllstatus: function(val, meta, record,x,y){
var code=record.data['cd_chancecode'];
var str=val.replace(/1/g,'√');
str=str.replace(/0/g,'O');
return '' + str + '';
},
/**
* @CRM
* 客户关系商机状态显示
*/
chancestatus: function(val, meta, record,x,y){
var str='';
if(val=='0'){
str='O';
}
if(val=='1'){
str='√';
}
return str;
},
/**
* @CRM
* 客户关系商机状态显示
*/
inquiryturnstatus: function(val, meta, record,x,y){
var str='';
if(val=='0'){
str='否';
}
if(val=='1'){
str='未选择';
}
if(val=='-1'){
str='是';
}
return str;
},
oameeting:function(val,meta, record){
if(val=='0'){
return ' ';
}
var url='jsps/oa/meeting/meetingroomapply.jsp';
var title='会议室申请单';
return '' + '√' + '';
},
/**
* 验收数量 inqty - outqty
* @param val
* @param meta
* @param record
* @param x
* @param y
* @returns
*/
ars_prodtoapbill_inqty:function(val, meta, record, x, y){
var inqty = 0;
var outqty = 0;
var returnqty = 0;
if(record.data['pd_inqty']!=null&&record.data['pd_inqty']){
inqty = Ext.Number.from(record.data['pd_inqty'],0);
}
if(record.data['pd_outqty']!=null&&record.data['pd_outqty']){
outqty = Ext.Number.from(record.data['pd_outqty'],0);
}
returnqty=inqty-outqty;
if(val != returnqty){
record.set('pd_showqty', returnqty);
val = returnqty;
}
return val;
},
/**
* 验收数量的绝对值 pd_inqty -已经转发票数量 pd_showinvoqty = 本次可转发票数量 pd_thisvoqty
* @param val
* @param meta
* @param record
* @param x
* @param y
* @returns
*/
ars_prodtoapbill_thisqty:function(val, meta, record, x, y){
meta.style = "background:#C6E2FF;";
//pd_thisvoqty = pd_inqty-pd_showinvoqty inqty要绝对值
var thisvoqty = 0;
var inqty = 0;
var invoqty = 0;
if(record.data['pd_showqty']!=null&&record.data['pd_showqty']!=''){
inqty = Math.abs(Ext.Number.from(record.data['pd_showqty'],0));
}
if(record.data['pd_showinvoqty']!=null&&record.data['pd_showinvoqty']){
invoqty = Ext.Number.from(record.data['pd_showinvoqty'],0);
}
thisvoqty=inqty-invoqty;
if(val != thisvoqty){
record.set('pd_thisvoqty', thisvoqty);
val = thisvoqty;
}
return val;
},
/**
* 出入库单号链接
*
**/
ProdioHref:function(val,meta,record){
var url='jsps/scm/reserve/prodInOut.jsp?whoami=';
var caller;
var piclass=record.data.pi_class, piid = record.data.pi_id;
if(piclass == '采购验收单'){
caller = 'ProdInOut!PurcCheckin';
} else if(piclass == '采购验退单'){
caller = 'ProdInOut!PurcCheckout';
} else if(piclass == '其它采购入库单'){
caller = 'ProdInOut!OtherPurcIn';
} else if(piclass == '完工入库单'){
caller = 'ProdInOut!Make!In';
} else if(piclass == '其它采购出库单'){
caller = 'ProdInOut!OtherPurcOut';
} else if(piclass == '换货出库单'){
caller = 'ProdInOut!ExchangeOut';
} else if(piclass == '换货入库单'){
caller = 'ProdInOut!ExchangeIn';
} else if(piclass == '出货单'){
caller = 'ProdInOut!Sale';
} else if(piclass == '委外领料单'){
caller = 'ProdInOut!OutsidePicking';
} else if(piclass == '研发退料单'){
caller = 'ProdInOut!YFIN';
} else if(piclass == '研发领料单'){
caller = 'ProdInOut!YFOUT';
} else if(piclass == '辅料入库单'){
caller = 'ProdInOut!FLIN';
} else if(piclass == '辅料出库单'){
caller = 'ProdInOut!FLOUT';
} else if(piclass == '借货出货单'){
caller = 'ProdInOut!SaleBorrow';
} else if(piclass == '借货归还单'){
caller = 'ProdInOut!OutReturn';
} else if(piclass == '委外补料单'){
caller = 'ProdInOut!OSMake!Give';
} else if(piclass == '不良品入库单'){
caller = 'ProdInOut!DefectIn';
} else if(piclass == '不良品出库单'){
caller = 'ProdInOut!DefectOut';
} else if(piclass == '库存初始化'){
caller = 'ProdInOut!ReserveInitialize';
} else if(piclass == '报废单'){
caller = 'ProdInOut!StockScrap';
} else if(piclass == '盘亏调整单'){
caller = 'ProdInOut!StockLoss';
} else if(piclass == '盘盈调整单'){
caller = 'ProdInOut!StockProfit';
} else if(piclass == '拆件入库单'){
caller = 'ProdInOut!PartitionStockIn';
} else if(piclass == '其它入库单'){
caller = 'ProdInOut!OtherIn';
} else if(piclass == '生产领料单'){
caller = 'ProdInOut!Picking';
} else if(piclass == '生产退料单'){
caller = 'ProdInOut!Make!Return';
} else if(piclass == '销售退货单'){
caller = 'ProdInOut!SaleReturn';
} else if(piclass == '委外验收单'){
caller = 'ProdInOut!OutsideCheckIn';
} else if(piclass == '委外验退单'){
caller = 'ProdInOut!OutesideCheckReturn';
} else if(piclass == '委外退料单'){
caller = 'ProdInOut!OutsideReturn';
} else if(piclass == '拨出单'){
caller = 'ProdInOut!AppropriationOut';
} else if(piclass == '拨入单'){
caller = 'ProdInOut!AppropriationIn';
} else if(piclass == '销售拨出单'){
caller = 'ProdInOut!SaleAppropriationOut';
} else if(piclass == '销售拨入单'){
caller = 'ProdInOut!SalePutIn';
} else if(piclass == '其它出库单'){
caller = 'ProdInOut!OtherOut';
} else if(piclass == '生产补料单'){
caller = 'ProdInOut!Make!Give';
}
url = url + caller + '&formCondition=pi_idIS'+piid+'&gridCondition=pd_piidIS'+piid;
return '' + val + '';
},
/**
* 采购单号链接
*
**/
PuWithOAHref:function(val,meta,record){
var url=null;
var caller;
var piclass=record.data.ppdd_type, pucode = record.data.ppdd_pucode;
if(piclass == '采购单'){
url='jsps/scm/purchase/purchase.jsp?formCondition=pu_codeIS'+pucode+'&gridCondition=pd_codeIS'+pucode;
} else if(piclass == '模具采购单'){
url='jsps/pm/mould/purcMould.jsp?whoami=Purc!Mould&formCondition=pm_codeIS'+pucode+'&gridCondition=pmd_codeIS'+pucode;
} else if(piclass == '用品采购单'){
url='jsps/oa/appliance/oapurchase.jsp?formCondition=op_codeIS'+pucode+'&gridCondition=od_codeIS'+pucode;
} else if(piclass == '印章申请单'){
url='jsps/oa/fee/feePleaseYZSYSQ.jsp?whoami=FeePlease!YZSYSQ&formCondition=fp_codeIS'+pucode+'&gridCondition=fpd_codeIS'+pucode;
}
if(url != null){
return '' + val + '';
}
return val;
},
/**
* 应收发票维护 计算不含税金额 不含税金额,需要改为“本次开票不含税金额”=本次开票价税合计 / (1+税率)
*
*
*
*/
ars_arbill_tax: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var tax = Number(record.data['abd_qty'])*Number(record.data['abd_thisvoprice'])/(1+Number(record.data['abd_taxrate'])/100);
if(tax != null && tax >= 0) {
record.set('abd_noaramount', tax);
val = tax;
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* 应收发票维护 计算不含税金额 不含税金额,需要改为“本次开票不含税金额”=本次开票价税合计 / (1+税率)
*
*
*
*/
arp_apbill_tax: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var tax = Number(record.data['abd_apamount'])/(1+Number(record.data['abd_taxrate'])/100);
if(tax != null && tax >= 0) {
record.set('abd_noapamount', tax);
val = tax;
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* 应收发票维护 计算不含税金额 不含税金额,需要改为“本次开票不含税金额”=本次开票价税合计 / (1+税率)
*
*
*
*/
arbill_show_invototal: function(val, meta, record, x, y, store, view){
var sourcekind = record.data['abd_sourcekind'];
var grid = view.ownerCt,column = grid.columns[y];
var pd_invototal = Number(record.data['pd_invototal']); //出入库单转出
var gsd_invototal = Number(record.data['gsd_invototal']); //发出商品数据
var abd_totalbillprice = Number(record.data['abd_totalbillprice']);//初始化数据
//转发类型是发出商品
if(sourcekind == 'GOODSSEND'){
if(val!=gsd_invototal){
record.set('abd_totalbillprice', gsd_invototal);
gsd_invototal=val;
}
return Ext.util.Format.number(gsd_invototal, column.format);
//出入库单转出
}else if(sourcekind == 'PRODIODETAIL'){
if(val!=pd_invototal){
record.set('abd_totalbillprice', pd_invototal);
pd_invototal=val;
}
return Ext.util.Format.number(pd_invototal, column.format);
//初始化
}else if(sourcekind == 'INITIALIZATION'){
if(val!=abd_totalbillprice){
record.set('abd_totalbillprice', abd_totalbillprice);
abd_totalbillprice=val;
}
return Ext.util.Format.number(abd_totalbillprice, column.format);
}
},
/**
* 应收发票维护 计算不含税金额 不含税金额,需要改为“本次开票不含税金额”=本次开票价税合计 / (1+税率)
*
*
*
*/
apbill_show_invototal: function(val, meta, record, x, y, store, view){
var sourcekind = record.data['abd_sourcekind'];
var grid = view.ownerCt,column = grid.columns[y];
var pd_invototal = Number(record.data['pd_invototal']); //出入库单转出
var esd_invototal = Number(record.data['esd_invototal']); //发出商品数据
var abd_totalbillprice = Number(record.data['abd_totalbillprice']);//初始化数据
//转发类型是发出商品
if(sourcekind == 'ESTIMATE'){
if(val!=esd_invototal){
record.set('abd_totalbillprice', esd_invototal);
esd_invototal=val;
}
return Ext.util.Format.number(esd_invototal,column.format);
//出入库单转出
}else if(sourcekind == 'PRODIODETAIL'){
if(val!=pd_invototal){
record.set('abd_totalbillprice', pd_invototal);
pd_invototal=val;
}
return Ext.util.Format.number(pd_invototal,column.format);
//初始化
}else if(sourcekind == 'INITIALIZATION'){
if(val!=abd_totalbillprice){
record.set('abd_totalbillprice', abd_totalbillprice);
abd_totalbillprice=val;
}
return Ext.util.Format.number(abd_totalbillprice, column.format);
}
},
/**
* 应付发票维护 计算不含税金额 不含税金额,需要改为“本次开票不含税金额”=本次开票价税合计 / (1+税率)
*
*
*
*/
ars_apbill_tax: function(val, meta, record, x, y){
var tax = Number(record.data['abd_apamount'])/(1+Number(record.data['abd_taxrate'])/100);
var tval=Ext.util.Format.number(tax,'0.00');
if(val != tval){
record.set('abd_noapamount', tval);
val = tval;
}
return tval;
},
colspan: function(val, meta, record, x, y, store, view){
meta.tdAttr = "rowspan=8;";
},
nullcolspan: function(val, meta){
meta.tdAttr = "rowspan=0;";
},
CRMHref:function(val, meta, record,x,y){
var me = this.RenderUtil || this;
var field = this.columns[y].dataIndex;
var KeyValue = 0;
var url='';
var title='';
var arg = me.args.CRMHref[field];
var keyField=arg[0];
var data=record.data;
if(arg && arg.length > 0){
KeyValue=data[field];
url=arg[1];
title=arg[2];
}
if(keyField.indexOf('code')>=0){
url+='?mr_taskcode='+KeyValue;
Ext.Ajax.request({
url: basePath+'crm/getReportCode.action',
async:false,
params:{
mt_code:KeyValue
},
method:'post',
callback:function(options,success,response){
var res = new Ext.decode(response.responseText);
url+='&whoami='+res.mt_reportcode;
}
});
}else{
url+='?mr_id='+KeyValue;
url+='&formCondition=mr_idIS'+KeyValue+'&gridCondition=mrd_mridIS'+KeyValue;
Ext.Ajax.request({
url: basePath+'crm/getReportCodeById.action',
async:false,
params:{
mr_id:KeyValue
},
method:'post',
callback:function(options,success,response){
var res = new Ext.decode(response.responseText);
url+='&whoami='+res.mr_reportcode;
}
});
}
if(val==''||val==$I18N.common.grid.emptyText) return val;
if(keyField.indexOf('code')>=0){
return '' + val + '';
}
return '' + val + '';
},
CRMtaskHref:function(val, meta, record,x,y){
var me = this.RenderUtil || this;
var rt_foid=record.data['rt_foid'];
var url='jsps/crm/marketmgr/marketresearch/multiform.jsp?'+
'formCondition=fo_idIS'+rt_foid+'&gridCondition=fd_foidIS'+rt_foid+'&whoami='+record.data['rt_code']+'&cond=rt_idIS'+record.data['rt_id']+'&type=crm';
var keyField='rt_code';
var KeyValue=record.data['rt_code']
var title='调研模板';
return '' + KeyValue + '';
},
PXtaskHref:function(val, meta, record,x,y){
var me = this.RenderUtil || this;
var rt_foid=record.data['px_foid'];
var url='jsps/crm/marketmgr/marketresearch/multiform.jsp?'+
'formCondition=fo_idIS'+rt_foid+'&gridCondition=fd_foidIS'+rt_foid+'&whoami='+record.data['px_code']+'&cond=px_idIS'+record.data['px_id']+'&type=ProductTrain';
var keyField='px_code';
var KeyValue=record.data['px_code']
var title='考核模板';
return '' + KeyValue + '';
},
CRMtaskReport:function(val, meta, record,x,y){
var me = this.RenderUtil || this;
var reporttemplatecode=record.data['reporttemplatecode'];
var url='jsps/crm/marketmgr/marketresearch/taskReport.jsp?'+
'whoami='+reporttemplatecode+'&cond=idIS'
+record.data['id'];
var keyField='taskcode';
var KeyValue=record.data['taskcode']
var title='调研报告';
return '' + KeyValue + '';
},
CRMResearchReport:function(val, meta, record,x,y){
var me = this.RenderUtil || this;
var reporttemplatecode=record.data['manuallyscheduled'];
var url='jsps/crm/marketmgr/marketresearch/researchReport.jsp?'+
'whoami='+reporttemplatecode+'&cond=idIS'
+record.data['id'];
if(record.data['mr_id']!=0){
url=url+'&formCondition=mr_idIS'+record.data['mr_id']+'&gridCondition=mrd_mridIS'+record.data['mr_id'];
}
var keyField='taskcode';
var KeyValue=record.data['taskcode']
var title='调研报告';
return '' + KeyValue + '';
},
CRMTrainReport:function(val, meta, record,x,y){
var me = this.RenderUtil || this;
var reporttemplatecode=record.data['to_tpcode'];
var url="jsps/crm/marketmgr/resourcemgr/trainReport.jsp?whoami="
+reporttemplatecode+"&cond=to_idIS"+record.data['to_id']+"&formCondition=tr_idIS"+record.data['tr_id'];
var keyField='tr_code';
var KeyValue=record.data['tr_code']
var title='产品培训考核报告';
return '' + KeyValue + '';
},
CRMReport:function(val, meta, record,x,y){
var me = this.RenderUtil || this;
var reporttemplatecode=record.data['mr_reportcode'];
var url='jsps/crm/marketmgr/marketresearch/researchReport.jsp?'+
'whoami='+reporttemplatecode+'&cond=idIS'
+record.data['id']+"&formCondition=mr_idIS"+record.data['mr_id']+'&gridCondition=mrd_mridIS'+record.data['mr_id'];
var keyField='mr_code';
var KeyValue=record.data['mr_code']
var title='调研报告';
return '' + KeyValue + '';
},
Vehicle:function(val, meta, record,x,y){
var url='jsps/oa/vehicle/vehiclereturn.jsp?cond=va_code='+val;
var title='返车维护单';
var keyField='va_code';
return '' + val + '';
},
/**
* 会议室申请,确认出席人员,如果已经确认出席的默认选上
*/
confirmMan:function(val, meta, record, x, y, store, view){
var grid = view.ownerCt;
if(record.data['md_attend']=='是'){
grid.selModel.select(record,true);
}
return val;
},
/**
* 会议室申请,确认出席人员,如果已经确认出席的默认选上
*/
oa_confirmMan:function(val, meta, record, x, y, store, view){
var grid = view.ownerCt;
if(record.data['md_isconfirmed']=='-1'){
grid.selModel.select(record,true);
}
return val;
},
/**
* 通用方法
* 值=arg[0]-arg[1]-...
* @expression reduce:pd_qty:pd_yqty
* @expression reduce:pd_qty:100:pd_yqty
*/
reduce: function(val, meta, record, x, y, store, view){
meta.tdCls = "x-grid-cell-renderer-bl";
var grid = view.ownerCt, me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex,
format = (column.format || '0,000.00'), perc = format.substring(format.indexOf('.') + 1).length;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
if(me.args){
var arg = me.args.reduce[field];
var maxValue = 0;
if(arg && arg.length > 0){
var v = 0;
Ext.each(arg, function(a, index){
if(Ext.isNumber(a)){
v = a;
} else {
v = record.data[a] || 0;
}
if(index == 0){
maxValue = Number(v);
} else {
maxValue -= Number(v);
}
});
}
//鉴于小数问题 保留2位小数
//maxValue=maxValue.toFixed(4);
if(column.editor || (column.getEditor && column.getEditor())) {//在允许编辑的情况下,修改值不能大于maxValue
val = (!Ext.isNumber(val) || val == 0) ? maxValue : val;
if(Number(val) > Ext.Number.toFixed(maxValue, perc) ){
val = maxValue;
showError('请不要输入超过最大数量' + maxValue + "的值!");
}
} else {
val = maxValue;
}
var f = Ext.Number.toFixed(val, perc), v = record.get(field), _v = val;
if(column.xtype == 'numbercolumn'){
_v = Ext.util.Format.number(val, column.format);
}
//f != val || f != v
if( f != v) {
record.set(field, f);
}
return _v;
} else {
return val;
}
},
/**
* @OA
* 信息发布 Note
*/
emergency: function(val, meta, record){
var d = Number(val);
var str = '';
switch (d){
case 1:
str = '一般';
break;
case 2:
str = '' +
'平急';
break;
case 3:
str = '' +
'特急';
break;
}
return str;
},
/**
* @OA流程催办
* */
remindprocess:function(val,meta,record){
var min=0,a=0,b=0,str='';
if(record && record.data.jp_id){
var launchTime=record.data.jp_launchTime;
min=parseInt((new Date().getTime()-new Date(launchTime).getTime())/60000);
a=parseInt(min/60);
b=min%60;
if(a>0) str+=a+'小时';
if(b>0) str+=b+'分钟';
if(a>2) meta.style = 'color:red;';
else meta.style='color:green';
return str;
}
else return null;
},
/**
*@OA 版本管理
**/
Version: function(val, meta, record){
if(val == 0)
return '当前版本|阅读版本';
else
return '';
},
/**
*@OA 阅读状态
*/
State: function(val, meta, record){
if(val == 0){
var str = '' +
'未阅';
return str ;
} else
return '已阅';
},
/**
*@OA attentionGrade
*/
Grade:function(val,meta,record,x,y){
var field = this.columns[y].dataIndex;
var me = this.RenderUtil || this;
var arg = me.args.Grade[field];
var colorfield=arg[0];
var color=record.data[colorfield];
if(color) return ''+val+'';
},
GradeColor:function(val,meta,record){
meta.style = "background:#"+val+";";
return '';
} ,
/**
*@OA 知识权限控制
*/
OAHref: function(val, meta, record,x,y){
var scanpersonid=record.data.kl_scanpersonid+'#';
var authorid=record.data.kl_authorid;
var me = this.RenderUtil || this;
var field = this.columns[y].dataIndex;
var KeyValue = 0;
var url='';
var title='';
var arg = me.args.OAHref[field];
var keyField=arg[0];
var data=record.data;
if(arg && arg.length > 0){
KeyValue=data[keyField];
url=arg[1];
title=arg[2];
}
if(val==''||val==$I18N.common.grid.emptyText) return val;
if(scanpersonid.indexOf(emid)>0||authorid==emid){
return ''+'' + val + '';
}
return ''+'' + val + '';
},
oa_oaacceptancedetail_status:function(val, meta, record){
if(val=='1'){
return '已转采购';
}else{
return '未转采购';
}
},
/**
* @SCM.Purchase
* 采购明细数量的修改限制
*/
scm_purc_pdqty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
if(!Ext.isNumber(val)) {
record.set('pd_qty', 0);
return 0;
} else {
var adid = record.data['ad_qty'];oldqty = 0;
if(adid != null && adid > 0 ) {
if(val > adid) {
oldqty = record.modified.pd_qty || record.data.pd_qty || adid;
if (val != oldqty){
val = oldqty;
record.set('pd_qty', oldqty);
showError('请不要超过请购数<' + adid + '>修改!');
}
}
}
return val;
}
},
/**
* @PM.MakeNotice
* 制造通知单明细数量的修改限制
*/
pm_mano_mndqty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var sdid = record.data['sd_qty'];oldqty = 0;
if(sdid != null && sdid > 0) {
if(val > sdid) {
oldqty = record.modified.mnd_qty || record.data.mnd_qty || sdid;
val = oldqty;
record.set('mnd_qty', oldqty);
showError('请不要超过订单数<' + sdid + '>修改!');
}
}
return val;
},
/**
* @SCM.Sale
* 销售通知单明细数量的修改限制
*/
scm_send_sndqty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var sdid = record.data['sd_qty'];oldqty = 0;
if(sdid != null && sdid > 0) {
if(val > sdid) {
oldqty = record.modified.snd_outqty || record.data.snd_outqty || sdid;
val = oldqty;
record.set('snd_outqty', oldqty);
showError('请不要超过订单数<' + sdid + '>修改!');
}
}
return val;
},
/**
* @SCM.AcceptNotify
* 收料通知单明细数量的修改限制
*/
scm_acceptnotify_andinqty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var sdid = record.data['pd_qty'];oldqty = 0;
if(sdid != null && sdid > 0) {
if(val > sdid) {
oldqty = record.modified.and_inqty || record.data.and_inqty || sdid;
val = oldqty;
record.set('and_inqty', oldqty);
showError('请不要超过采购单数<' + sdid + '>修改!');
}
}
return val;
},
/**
* @SCM.VerifyApply
* 收料单明细数量的修改限制
*/
scm_acceptnotify_vadqty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var sdid = record.data['pd_qty'];oldqty = 0;
if(sdid != null && sdid > 0) {
if(val > sdid) {
oldqty = record.modified.vad_qty || record.data.vad_qty || sdid;
val = oldqty;
record.set('vad_qty', oldqty);
showError('请不要超过采购单数<' + sdid + '>修改!');
}
}
return val;
},
/**
* @SCM.ProdIODetail
* 出货单明细数量的修改限制
*/
scm_prodio_pdqty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
if(record.get('pd_snid') != null && record.get('pd_snid') != 0) {
var snid = record.data['snd_outqty'];oldqty = 0;
if(snid != null && snid > 0) {
if(val > snid) {
oldqty = record.modified.pd_outqty || record.data.pd_outqty || sdid;
val = oldqty;
record.set('pd_outqty', oldqty);
showError('请不要超过通知单数<' + snid + '>修改!');
}
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @PM.Dispatch
* 完成数不能大于流程单数量
*/
pm_dispatch_overqty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var q = record.data['mf_qty'];
if(q != null && q > 0) {
if(val > q) {
val = q;
record.set('did_overqty', q);
showError('完成数请不要超过流程单数量<' + q + '>!');
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @SCM.Sale.ReturnApply
* 退货申请单
*/
returnapply_qty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var q = record.data['sd_sendqty'];
if(q != null && q > 0) {
if(val > q) {
val = q;
record.set('rad_qty', q);
showError('请不要超过订单发货数<' + q + '>退货!');
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @SCM.ProdIODetail
* 采购验收单明细数量的修改限制
*/
scm_prodio_okqty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
if(record.get('pd_vacode') != null&&record.get('pd_vacode')!="") {
var vadid = record.data['ve_okqty'];oldqty = 0;
if(vadid != null && vadid > 0) {
if(val > vadid) {
oldqty = record.modified.pd_inqty || record.data.pd_inqty || vadid;
val = oldqty;
record.set('pd_inqty', oldqty);
showError('请不要超过收料合格数<' + vadid + '>修改!');
}
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* 研发采购变更 限制数量
* @param val
* @param meta
* @param record
* @returns
*/
plm_pc_yqty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var vadid = record.data['pcd_newqty'];
if(vadid != null && vadid > 0) {
if(val > vadid) {
val = oldqty;
record.set('pcd_newqty', val);
showError('新采购数请不要小于已转数量<' + val + '>!');
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @SCM.ProdIODetail
* 不良品入库单明细数量的修改限制
*/
scm_prodio_ngqty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
if(record.get('pd_vacode') != null) {
var vadid = record.data['ve_notokqty'];oldqty = 0;
if(vadid != null && vadid > 0) {
if(val > vadid) {
oldqty = record.modified.pd_inqty || record.data.pd_inqty || vadid;
val = oldqty;
record.set('pd_inqty', oldqty);
showError('请不要超过收料不合格数<' + vadid + '>修改!');
}
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* PM.makeScrap 生产报废单报废数量限制
*/
md_qty_mm_havegetqty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var have = record.data['mm_havegetqty'] || 0,
oldqty = 0;
if(val > have) {
oldqty = record.modified.md_qty || record.data.md_qty || have;
val = oldqty;
if(record.data.md_qty != oldqty) {
record.set('md_qty', oldqty);
showError('请不要超过已领数<' + have + '>!');
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @SCM.Sale.SaleChange
* 销售变更单新数量(原数量为0的时候不考虑)
*/
scm_sale_change_qty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var adq = record.data['sd_qty'];
var acq = record.data['sd_sendqty'];
var yq = Math.min(record.data['sd_yqty'], adq);
if(adq != null && adq > 0) {
if(val > adq) {
showError('请不要超过原订单数<' + adq + '>!');
val = adq;
record.set('scd_newqty', adq);
}
}
if(acq != null && acq > 0) {
if(val == 0) {
val = acq;
record.set('scd_newqty', acq);
} else if(val < acq) {
showError('请不要小于已发货数<' + acq + '>!');
val = acq;
record.set('scd_newqty', acq);
}
}
if(yq != null && yq > 0) {
if(val == 0) {
val = yq;
record.set('scd_newqty', yq);
} else if(val < yq) {
showError('请不要小于已转发货通知数<' + yq + '>!');
val = yq;
record.set('scd_newqty', yq);
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @SCM.Sale.SaleChange
* 销售变更单新数量(原数量为0的时候也要考虑)
*/
scm_sale_change_qty2: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var adq = record.data['sd_qty'];
var acq = record.data['sd_sendqty'];
var yq = Math.min(record.data['sd_yqty'], adq);
if(adq != null && adq >= 0) {
if(val > adq) {
showError('请不要超过原订单数<' + adq + '>!');
val = adq;
record.set('scd_newqty', adq);
}
}
if(acq != null && acq >= 0) {
if(val == 0) {
val = acq;
record.set('scd_newqty', acq);
} else if(val < acq) {
showError('请不要小于已发货数<' + acq + '>!');
val = acq;
record.set('scd_newqty', acq);
}
}
if(yq != null && yq >= 0) {
if(val == 0) {
val = yq;
record.set('scd_newqty', yq);
} else if(val < yq) {
showError('请不要小于已转发货通知数<' + yq + '>!');
val = yq;
record.set('scd_newqty', yq);
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @SCM.Purchase.PurchaseChange
* 采购变更单新数量
*/
scm_purc_change_qty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var adq = record.data['ad_qty'];oldqty = 0;
var acq = record.data['pd_acceptqty'];
var yq = record.data['pd_yqty'];
if(adq != null && adq > 0) {
if(val > adq) {
val = adq;
showError('请不要超过请购数<' + adq + '>!');
}
}
if(acq != null && acq > 0) {
if(val == 0) {
val = acq;
} else if(val < acq) {
val = acq;
showError('请不要小于验收数<' + acq + '>!');
}
}
if(yq != null && yq > 0) {
if(val == 0) {
val = yq;
} else if(val < yq) {
val = yq;
showError('请不要小于采购已转数<' + yq + '>!');
}
}
if(record.get('pcd_newqty') != val) {
record.set('pcd_newqty', val);
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @SCM.Purchase.PurchaseChange
* 采购变更单新数量(易方)
*/
scm_purc_change_qty2: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var adq = record.data['pcd_oldqty'];oldqty = 0;
var acq = record.data['pd_acceptqty'];
var yq = record.data['pd_yqty'];
if(adq != null && adq > 0) {
if(val > adq) {
val = adq;
showError('请不要超过原采购订单数<' + adq + '>!');
}
}
if(acq != null && acq > 0) {
if(val == 0) {
val = acq;
} else if(val < acq) {
val = acq;
showError('请不要小于验收数<' + acq + '>!');
}
}
if(yq != null && yq > 0) {
if(val == 0) {
val = yq;
} else if(val < yq) {
val = yq;
showError('请不要小于采购已转数<' + yq + '>!');
}
}
if(record.get('pcd_newqty') != val) {
record.set('pcd_newqty', val);
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @PM.Make.MakeChange
* 制造变更单新数量(易方)
*/
pm_make_change_qty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var adq = record.data['md_qty'];oldqty = 0;
var acq = record.data['ma_madeqty'];
var yq = record.data['ma_toquaqty'];
if(adq != null && adq > 0) {
if(val > adq) {
val = adq;
showError('请不要超过原制造单数<' + adq + '>!');
}
}
if(acq != null && acq > 0) {
if(val == 0) {
val = acq;
} else if(val < acq) {
val = acq;
showError('请不要小于已完工数<' + acq + '>!');
}
}
if(yq != null && yq > 0) {
if(val == 0) {
val = yq;
} else if(val < yq) {
val = yq;
showError('请不要小于已转检验数<' + yq + '>!');
}
}
if(record.get('md_newqty') != val) {
record.set('md_newqty', val);
}
return val;
},
/**
* @PM.Make.MakeChangeOS
* 委外变更单新数量(易方)
*/
pm_makeos_change_qty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var adq = record.data['md_oldqty'];oldqty = 0;
var acq = record.data['ma_madeqty'];
var yq = record.data['ma_haveqty'];
if(adq != null && adq > 0) {
if(val > adq) {
val = adq;
showError('请不要超过原委外单数<' + adq + '>!');
}
}
if(acq != null && acq > 0) {
if(val == 0) {
val = acq;
} else if(val < acq) {
val = acq;
showError('请不要小于已生产数量<' + acq + '>!');
}
}
if(yq != null && yq > 0) {
if(val == 0) {
val = yq;
} else if(val < yq) {
val = yq;
showError('请不要小于已转收料数<' + yq + '>!');
}
}
if(record.get('md_newqty') != val) {
record.set('md_newqty', val);
}
return val;
},
/**
* @SCM.Sale.SendNotify
* 出货通知变更单新数量
*/
scm_sendnotify_change_qty: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y];
var adq = record.data['scd_oldqty'];
var yq = Math.min(record.data['snd_yqty'], adq);
if(adq != null && adq > 0) {
if(val > adq) {
showError('请不要超过原通知单数<' + adq + '>!');
val = adq;
record.set('scd_qty', adq);
}
}
if(yq != null && yq > 0) {
if(val == 0) {
val = yq;
record.set('scd_qty', yq);
} else if(val < yq) {
showError('请不要小于已转出货数<' + yq + '>!');
val = yq;
record.set('scd_qty', yq);
}
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
return val;
},
/**
* @SCM.Sale.SaleForecastChange
* 预测变更单明细数量的修改限制
*/
scm_sale_sfchange_qty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var sdq = record.data['scd_oldqty'];
var kq = record.data['scd_minqty'];
if(sdq != null && sdq > 0) {
if(val > sdq) {
val = sdq;
showError('请不要超过原预测数量<' + sdq + '>!');
}
}
if(kq != null && kq > 0) {
if(val == 0) {
val = kq;
} else if(val < kq) {
val = kq;
showError('请不要小于最小变更数<' + kq + '>!');
}
}
if(record.get('scd_newqty') != val) {
record.set('scd_newqty', val);
}
return val;
},
/**
* @SCM.Sale
* 销售单明细数量的修改限制
*/
scm_sale_sdqty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var status = Ext.getCmp('sa_statuscode') == null ? null : Ext.getCmp('sa_statuscode').value;
var maxValue = record.modified.sd_qty || record.data.sd_qty;
if(status == null || status == 'ENTERING' || status == 'COMMITED'){
var sd_sourceid = record.data['sd_sourceid'];
if(sd_sourceid != null && sd_sourceid != '0' && sd_sourceid != 0){//有来源
//限制val maxValue){
val = maxValue;
record.set('sd_qty', val);
showError('请不要输入超过来源数量' + maxValue + "的值!");
}
}
if(!Ext.isNumber(val)){
val = maxValue;
record.set('sd_qty', val);
showError('请输入数字!');
}
if(val < 0){
val = maxValue;
record.set('sd_qty', val);
showError("请不要输入小于0的值!");
}
} else {
if(val != maxValue){
val = maxValue;
record.set('sd_qty', val);
showError("该单据已审核,无法修改,请申请变更!");
}
}
return val;
},
/**
* @SCM.Purchase.VerifyApply
* 收料单明细数量的修改限制
*/
scm_purc_vadqty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var andid = record.data['vad_andid'];
if(andid == null || andid == 0){
var pdid = record.data['pd_qty'],qty = 0;
if(pdid != null && pdid > 0) {
if(val > pdid) {
qty = record.modified.vad_qty || record.data.vad_qty || pdid;
val = qty;
record.set('vad_qty', qty);
showError('请不要超过采购数<' + pdid + '>修改!');
}
}
} else {
var andqty = record.data['and_inqty'],oldqty = 0;
if(andqty != null && andqty > 0) {
if(val > andqty) {
oldqty = record.modified.vad_qty || record.data.vad_qty || andqty;
val = oldqty;
record.set('vad_qty', oldqty);
showError('请不要超过收料通知单数<' + andqty + '>修改!');
}
}
}
return val;
},
/**
* 通用方法
* 仅仅是改变该列的背景颜色
* @arg red/black.../C6E2FF/B376F5/..null..
* @expression color:red
* @expression color:#C1D0D9
*/
color: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
meta.style = "background:#C6E2FF;";
return val;
}
me.args.color = me.args.color || new Object();
var arg = me.args.color[field];
if(arg && arg.length > 0){
meta.style = "background:" + arg[0] + ";";
} else {
meta.style = "background:#C6E2FF;";
}
return val;
},
/**
* 通用方法
* 如果当前字段的值为空或空字符串,就获取指定字段的值赋给当前字段
* @expression copy:pcd_oldprodcode
*/
copy: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(val == null || val == '' || val == 0){
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var v = record.data[field];
if(v == null || v == '' || (column.xtype == 'numbercolumn' && v == 0)){
var arg = me.args.copy[field];
if(arg && arg.length > 0){
val = record.data[arg[0]];
}
if(val != null && val != '' && val != 0){
record.set(field, val);
}
}
}
if(column.xtype == 'numbercolumn' && val != 0){
val = Ext.util.Format.number(val, column.format);
}
if(column.xtype == 'datecolumn') {
if(!val) return null;
val = Ext.Date.format(val, (column.format || 'Y-m-d'));
}
return val;
},
/**
* 通用方法
* 如果指定字段的值为空或空字符串,就获取当前值赋给指定字段
* @expression paste:pcd_newprodcode
*/
paste: function(val, meta, record, x, y, store, view){
meta.style = "background:#C6E2FF;";
if(val != null && val != ''){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var arg = me.args.paste[field];
var value = null;
if(arg && arg.length > 0){
value = record.data[arg[0]];
if(value == null || value == ''){
if(column.xtype == 'numbercolumn' && val != 0){
record.set(arg[0], val);
} else {
if(Ext.isDate(val)){
val = Ext.Date.toString(val);
}
record.set(arg[0], val);
}
}
}
}
return val;
},
/**
* 必填字段
*/
necessary: function(val, meta, record, x, y, store, view){
return '' +
'' + val + '';
},
/**
* @FA
* 应收系统参数设置
*/
stringToDate: function(val, meta, record, x, y){
meta.style = "background:#C6E2FF;";
var reg = /\d{2}-\d{1,2}月-\d{2}/;
var field = this.columns[y].dataIndex;
if(val == 'true'){
record.set(field,'是');
}
if(val == 'false'){
record.set(field,'否');
}
if(reg.test(val)){
var day = val.split('-')[0];
var month = val.split('-')[1].replace('月', '');
if(Number(month) < 10){
month = '0' + month;
}
var year = '20' + val.split('-')[2];
val = year + '-' + month + '-' + day;
record.set(field, val);
}
return val;
},
/**
* @PM.Make
* 成套发料,本次发料套数
*/
pm_make_issue_thisqty: function(val, meta, record, x, y){
var code = record.data['ma_code'], busy = Ext.getCmp('grid').busy;
record.hasdataChanged=false;
if(!Ext.isEmpty(record.data['ma_id']) && !Ext.isEmpty(code)) {
var nQty = record.data['ma_qty'] - record.data['ma_haveqty'];
if(record.maxQty!=nQty){
record.maxQty=nQty;
record.hasdataChanged=true;
}
var maxQty = nQty;
if(val > maxQty) {
if(!busy && !record.hasdataChanged)
showError('本次发料套数不能超过<' + maxQty + '>,单号:' + code);
val = maxQty;
if(record.data['ma_thisqty'] != val) {
record.set('ma_thisqty', val);
}
} else{
if(record.hasdataChanged) val=maxQty;
val= val==0?maxQty:val;
if(record.data['ma_thisqty'] != val) {
record.set('ma_thisqty', val);
}
}
var grid = Ext.getCmp('editorColumnGridPanel'),items = grid.store.data.items;
if(!grid.lockrender && Ext.getCmp('set').value) {
Ext.each(items, function(item){
if(item.data['mm_code'] == code){
var max = item.data['mm_oneuseqty'] * val;
var t = 0;
if(item.data.isrep) {
t = item.data['mm_canuserepqty'] - item.data['mm_totaluseqty'];
} else {
t = item.data['mm_qty'] - item.data['mm_canuserepqty'] - (item.data['mm_havegetqty'] +
item.data['mm_returnmqty'] - item.data['mm_addqty'] - item.data['mm_haverepqty']) -
item.data['mm_totaluseqty'];
}
max = Math.min(t, max);
if(item.data['mm_thisqty'] > max){
item.set('mm_thisqty', max);
}
}
});
}
}
return val;
},
/**
* @PM.Make
* 制造单本次领料数mm_thisqty=mm_qty(制单数)-mm_canuserepqty(替代维护数)-mm_havegetqty(已领)+mm_returnmqty(不良数)
* -mm_addqty(补料数)-mm_haverepqty(替代已领)-mm_totaluseqty(已转领料)
*/
pm_make_thisqty: function(val, meta, record, x, y){
meta.tdCls = "x-grid-cell-renderer-bl";
var t = 0,r=0,busy = Ext.getCmp('editorColumnGridPanel').busy;
//r为该序号总剩余未发料数
r = record.data['mm_qty'] - (record.data['mm_havegetqty'] - record.data['mm_addqty'] + record.data['mm_returnmqty'] ) - record.data['mm_totaluseqty'] ;
if(record.data.isrep) {
t = record.data['mm_qty'] - (record.data['mm_havegetqty'] - record.data['mm_addqty'] + record.data['mm_returnmqty'] ) - record.data['mm_totaluseqty'] ;
} else {
t = record.data['mm_qty'] - record.data['mm_canuserepqty'] - (record.data['mm_havegetqty'] - record.data['mm_haverepqty'] +
record.data['mm_returnmqty'] - record.data['mm_repreturnmqty'] - record.data['mm_addqty'] + record.data['mm_repaddqty']) -
record.data['mm_totaluseqty'];
}
//大于总剩余未发料数则默认等于剩余未发料数
t = t > r ? r : t;
t = t < 0 ? 0 : t;
var max = t.toFixed(3);
max = max < 0 ? 0 : max;
//ma_thisqty*mm_oneuseqty
var tqty = max;
if(Ext.getCmp('set').value) {
var items = Ext.getCmp('grid').store.data.items,mItem = null;
if(ifIncludingLoss){//套料发料包含损耗
Ext.each(items, function(item){
if(item.data['ma_code'] != null && item.data['ma_code'].toString().trim() != ''
&& item.data['ma_code'] == record.data['mm_code']){
mItem = item;
if(item.data['ma_thisqty'] > 0){
max = item.data['ma_thisqty'] * record.data['mm_qty']/item.data['ma_qty'];
if(parseInt(record.data['mm_qty'])== record.data['mm_qty']){//需求数为整数,取整
max = Math.ceil(max);
}
tqty = Math.min(max, t);
tqty = Number(tqty.toFixed(3));
}
}
});
}else{
Ext.each(items, function(item){
if(item.data['ma_code'] != null && item.data['ma_code'].toString().trim() != ''
&& item.data['ma_code'] == record.data['mm_code']){
mItem = item;
if(item.data['ma_thisqty'] > 0 && record.data['mm_oneuseqty'] > 0){
max = item.data['ma_thisqty'] * record.data['mm_oneuseqty'];
tqty = Math.min(max, t);
tqty = Number(tqty.toFixed(3));
}
}
});
}
}
val = Number(val.toFixed(3));
if(!record.dirty){//未被修改过,并且mm_thisqty与计算值不等
if(val != tqty){
val = tqty;
record.set('mm_thisqty', val);
}
}else{
if(val > tqty) {
//如果参数设置为不考虑可替代数
if (ifCanrepqty != true){
if(!busy)
showError("本次领料数不得超过" + tqty);
}else{
if(val > r){
showError("本次领料数不得超过" + r);
}
}
val = tqty;
record.set('mm_thisqty', val);
} else if(val < 0){
if(!busy)
showError("本次领料数不能是负数");
val = tqty;
record.set('mm_thisqty', val);
} else if(val == 0 && tqty != 0){
val = tqty;
record.set('mm_thisqty', val);
} else {
// if(val < max && mItem) {//本次领料数 <本次发料套数*单位用量
// mItem.maxQty = Math.ceil(val/record.data['mm_oneuseqty']);
// mItem.set('ma_thisqty', mItem.maxQty);
// }
}
}
return val;
},
/**
* @PM.Make
* 替代料,特殊样式
*/
pm_isrep: function(val, meta, record, x, y){
var field = this.columns[y].dataIndex;
if(record.data.isrep) {
meta.tdCls = "x-grid-cell-renderer-cl";
if(field == 'mm_code') {
return '' +
'替代料';
} else {
return val;
}
}
return val;
},
/**
* @PM.Make
* 成套退料,本次退料套数 成套报废,本次报废套数
*/
pm_make_return_thisqty: function(val, meta, record, x, y){
var code = record.data['ma_code'], busy = Ext.getCmp('grid').busy;
record.hasdataChanged=false;
if(!Ext.isEmpty(record.data['ma_id']) && !Ext.isEmpty(code)) {
var nQty = record.data['ma_qty'];
if(!record.maxQty || record.maxQty!=nQty){
record.maxQty=nQty;
record.hasdataChanged=true;
}
var maxQty = Math.min(record.maxQty, nQty);
if(val > maxQty) {
if(!busy && !record.hasdataChanged)
showError('套数不能超过<' + maxQty + '>,单号:' + code);
val = maxQty;
if(record.data['ma_thisqty'] != val) {
record.set('ma_thisqty', val);
}
} else if(val < 0){
val= 0;
if(record.data['ma_thisqty'] != val) {
record.set('ma_thisqty', val);
}
}
var grid = Ext.getCmp('editorColumnGridPanel'),items = grid.store.data.items;
if(!grid.lockrender) {
Ext.each(items, function(item){
if(item.data['mm_code'] == code){
var max = item.data['mm_oneuseqty'] * val;
var t = item.data['mm_onlineqty'] || item.data['mm_thisqty'];
max = Math.min(t, max);
if(item.data['mm_thisqty'] != max){
item.set('mm_thisqty', max);
}
}
});
}
}
return val;
},
/**
* @PM.Make
* 制造单本次退料数mm_thisqty<=mm_onlineqty(在制数) ,本次报废数
*/
pm_make_rqty: function(val, meta, record, x, y, store){
meta.style = "background:#C6E2FF;";
if(record.data['mm_onlineqty'] < 0) {// 返修工单退料
return val;
}
var mrec = record;
if(record.data.isrep) {
//替代料 本次数量 按主料本次数量计算
store.each(function(d){
if(d.data.mm_id == record.data.mm_id && !d.data.isrep) {
mrec = d;return;
}
});
}
var t = ((mrec.data['mm_onlineqty'] || val) - (mrec.data['mm_backqty'] || 0)),
busy = Ext.getCmp('editorColumnGridPanel').busy;
var max = t;
max = max < 0 ? 0 : max;
var tqty = max;
var items = Ext.getCmp('grid').store.data.items;
Ext.each(items, function(item){
if(item.data['ma_code'] != null && item.data['ma_code'].toString().trim() != ''
&& item.data['ma_code'] == mrec.data['mm_code']){
mItem = item;
if(item.data['ma_thisqty'] > 0 && mrec.data['mm_oneuseqty'] > 0){
max = item.data['ma_thisqty'] * mrec.data['mm_oneuseqty'];
tqty = Math.min(max, t);
}
}
});
if(val > tqty) {
if(!busy)
showError("本次填写的数量不得超过" + tqty);
val = tqty;
} else if(val < 0){
if(!busy)
showError("本次填写的数量不能是负数");
val = tqty;
} else if(val == 0 && tqty != 0){
val = tqty;
}
if(record.get('mm_thisqty') != val)
record.set('mm_thisqty', val);
return val;
},
/**
* @PM.Make 万利达,UAS 先用本次退料数
* 制造单本次退料数mm_thisqty<=mm_onlineqty(在制数)
*/
pm_make_rqtyf: function(val, meta, record, x, y, store){
meta.style = "background:#C6E2FF;";
if(record.data['mm_onlineqty'] < 0) {// 返修工单退料
return val;
}
var mrec = record;
if(record.data.isrep) {
//替代料 本次数量 按主料本次数量计算
store.each(function(d){
if(d.data.mm_id == record.data.mm_id && !d.data.isrep) {
mrec = d;return;
}
});
}
var t = Math.floor(((mrec.data['mm_onlineqty'] || val) - (mrec.data['mm_backqty'] || 0))),
busy = Ext.getCmp('editorColumnGridPanel').busy;
var max = t;
max = max < 0 ? 0 : max;
var tqty = max;
var items = Ext.getCmp('grid').store.data.items;
Ext.each(items, function(item){
if(item.data['ma_code'] != null && item.data['ma_code'].toString().trim() != ''
&& item.data['ma_code'] == mrec.data['mm_code']){
mItem = item;
if(item.data['ma_thisqty'] > 0 && mrec.data['mm_oneuseqty'] > 0){
max = item.data['ma_thisqty'] * mrec.data['mm_oneuseqty'];
tqty = Math.min(max, t);
}
}
});
if(val > tqty) {
if(!busy)
showError("本次退料的数量不得超过" + tqty);
val = tqty;
} else if(val < 0){
if(!busy)
showError("本次退料的数量不能是负数");
val = tqty;
} else if(val == 0 && tqty != 0){
val = tqty;
}
if(record.get('mm_thisqty') != val)
record.set('mm_thisqty', val);
return val;
},
/**
* @PM.Make
* 成套补料,本次补料套数
*/
pm_make_add_thisqty: function(val, meta, record, x, y){
var code = record.data['ma_code'], busy = Ext.getCmp('grid').busy;
if(!Ext.isEmpty(record.data['ma_id']) && !Ext.isEmpty(code)) {
var nQty = record.data['ma_qty'] - record.data['ma_haveqty'];
record.maxQty = record.maxQty || nQty;
var maxQty = Math.min(record.maxQty, nQty);
if(val > maxQty) {
if(!busy)
showError('本次补料套数不能超过<' + maxQty + '>,单号:' + code);
val = maxQty;
if(record.data['ma_thisqty'] != val) {
record.set('ma_thisqty', val);
}
} else if(val < 0) {
val = 0;
if(record.data['ma_thisqty'] != val) {
record.set('ma_thisqty', val);
}
}
var grid = Ext.getCmp('editorColumnGridPanel'),items = grid.store.data.items;
if(!grid.lockrender) {
Ext.each(items, function(item){
if(item.data['mm_code'] == code){
var max = item.data['mm_oneuseqty'] * val;
var t = 0;
if(item.data.isrep) {
t = 0;
} else {
if(record.data['mm_qty'] == Math.floor(record.data['mm_qty'])){
t = record.data['mm_scrapqty'] + record.data['mm_returnmqty'] - Math.floor(record.data['mm_balance'])
- record.data['mm_addqty'];// - record.data['mm_totaluseqty']
}else{
t = record.data['mm_scrapqty'] + record.data['mm_returnmqty'] - record.data['mm_balance']
- record.data['mm_addqty'];// - record.data['mm_totaluseqty']
}
}
max = Math.min(t, max);
if(item.data['mm_thisqty'] != max){
item.set('mm_thisqty', max);
}
}
});
}
}
return val;
},
/**
* @PM.Make
* 本次补料数: mm_scrapqty(报废) + mm_returnmqty(制程不良退料数) - mm_balance(备损数) - mm_addqty(补料数)// - mm_totaluseqty(已转领料数量)
*
*/
pm_make_thisadd: function(val, meta, record, x, y) {
meta.tdCls = "x-grid-cell-renderer-bl";
var t = 0,busy = Ext.getCmp('editorColumnGridPanel').busy;
if(record.data.isrep) {
return val;
} else {
if(record.data['mm_qty'] == Math.floor(record.data['mm_qty'])){
t = record.data['mm_scrapqty'] + record.data['mm_returnmqty'] - Math.floor(record.data['mm_balance'])
- record.data['mm_addqty'];// - record.data['mm_totaluseqty']
}else{
t = record.data['mm_scrapqty'] + record.data['mm_returnmqty'] - record.data['mm_balance']
- record.data['mm_addqty'];// - record.data['mm_totaluseqty']
}
}
var max = t;
max = max < 0 ? 0 : max;
var tqty = max;
var items = Ext.getCmp('grid').store.data.items;
Ext.each(items, function(item){
if(item.data['ma_code'] != null && item.data['ma_code'].toString().trim() != ''
&& item.data['ma_code'] == record.data['mm_code']){
mItem = item;
if(item.data['ma_thisqty'] > 0 && record.data['mm_oneuseqty'] > 0){
max = item.data['ma_thisqty'] * record.data['mm_oneuseqty'];
tqty = Math.min(max, t);
}
}
});
if(val > tqty) {
if(!busy)
showError("本次补料数不得超过" + tqty);
val = tqty;
record.set('mm_thisqty', val);
} else if(val < 0){
if(!busy)
showError("本次补料数不能是负数");
val = tqty;
record.set('mm_thisqty', val);
} else if(val == 0 && tqty != 0){
val = tqty;
record.set('mm_thisqty', val);
}
return val;
},
/**
* @PM.Make
* ProductAll!Query MRP仓剩余可用=pr_mrponhand-pr_commited
*/
pm_ProductAll_onhandlack: function(val, meta, record, x, y){
var t = 0 ;
t = record.data['v_po_mrponhand'] - record.data['v_mrpsaqty'] - record.data['v_forecastqty'] - record.data['v_mrpmmqty'] ;
var field = this.columns[y].dataIndex;
return t;
//record.set(field, t);
},
/**
* @PM.Make
* ProductAll!Query 收料仓剩余可用=pr_mrponhand+pr_reconhand-pr_commited
*/
pm_ProductAll_reconhandlack: function(val, meta, record, x, y){
var t = 0 ;
t = record.data['v_po_mrponhand'] + record.data['v_reconhand'] - record.data['v_mrpsaqty'] - record.data['v_forecastqty'] - record.data['v_mrpmmqty'] ;
var field = this.columns[y].dataIndex;
return t;
},
/**
* @PM.Make
* ProductAll!Query MRP在途剩余可用=pr_mrponhand+pr_onorder-pr_commited
*/
pm_ProductAll_onorderlack: function(val, meta, record, x, y){
var t = 0 ;
t = record.data['v_po_mrponhand'] + record.data['v_mrppoqty'] + record.data['v_mrpmaqty'] - record.data['v_forecastqty'] - record.data['v_mrpsaqty']- record.data['v_mrpmmqty'] ;
var field = this.columns[y].dataIndex;
return t;
},
/**
* @PM.Make
* ProductAll!Query MRP请购剩余可用=pr_mrponhand+pr_onorder+pr_arkqty-pr_commited
*/
pm_ProductAll_arklack: function(val, meta, record, x, y){
var t = 0;
t = record.data['v_po_mrponhand'] + record.data['v_mrppoqty'] + record.data['v_mrpmaqty'] + record.data['v_arkqty'] - record.data['v_mrpsaqty'] - record.data['v_forecastqty'] - record.data['v_mrpmmqty'] ;
var field = this.columns[y].dataIndex;
return t;
},
/**
*@PM.MakePlan 生产计划维护
* */
pm_make_presMakePlan:function(val,meta,record,rol){
if(val)
return '' + val + '';
else return null;
},
/**
* 颜色列
* @expression bgcolor
*/
bgcolor: function(val, meta, record, x, y){
return "" + val + "
";
},
/**
* 颜色列
* @expression bgcolor2
*/
bgcolor2: function(val, meta, record, x, y){
return '
';
},
/**
* 超链接列
*/
href: function(val, meta, record, x, y){
return '' + val + '';
},
/**
* 年和月
*/
yearmonth: function(val, meta, record, x, y){
meta.style = "background:#C6E2FF;";
if(val == null || val == ''){
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
month = month < 10 ? '0' + month : month;
val = '' + year + month;
}
var field = this.columns[y].dataIndex;
if(record.data[field] != val){
record.set(field, val);
}
return val;
},
/**
* ??
*/
date: function(val, meta, record){
meta.style = "background:#C6E2FF;";
if(val){
return '' + Ext.Date.toString(val); + '';
} else
return '';
},
/**
* 网络寻呼-状态prd_status
* -1未读 1已读 0保留
*/
pagingReleaseStatus: function(val, meta, record){
var d = Number(val);
var str = '';
switch (d){
case 0:
str = '保留';
break;
case 1:
str = '' +
'已阅';
break;
case -1:
str = '' +
'未阅';
break;
}
return str;
},
/**
* @OA
* 不通过监听itemmousedown来查看明细,
* 而是点击button
*/
detailbutton: function(msg, meta, record){
/**
* 寻呼内容列表显示时
* 将表情代码转化成图片。
* 插入的图片和附件代码不转化
*/
if(msg){
msg = msg.toString();
var faces = msg.match(/&f\d+;/g);
Ext.each(faces, function(f){//表情
msg = msg.replace(f, '');
});
}
return (msg || ' ') + "";
},
opendetail: function(val, meta, record) {
if(!Ext.isEmpty(val)){
var sd_id = record.get('sd_id');
return val + "";
}
},
/**
* 不直接显示附件的ID字符串,转化显示附件数
*/
attachcolumn: function(val, meta, record){
if(val != null && val != ''){
return val.split(',').length + ' 个';
} else {
return '无';
}
},
/**
* 对任务完成率不同阶段进行图片标识
*/
percentdone: function(val, meta, record){
val == null || 0;
if(val < 30)
return ''+'' + val + '';
else if(val > 30 && val < 50)
return ''+'' + val + '';
else if(val == 100){
return ''+'' + val + '';
}else if(val > 80){
return ''+'' + val + '';
}
else
return val;
},
/**
* SCM 请购转采购替代料
* */
ap_isrep: function(val, meta, record, x, y){
if(record.data.ad_ifrep==-1) {
meta.tdCls = "x-grid-cell-renderer-cl";
return '' + val;
}
return val;
},
isDateModel_type: function(val){
if(val =='zhou'){
return '周';
} else if(val == 'yue'){
return '月';
} else {
return '未知';
}
},
string_substring: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
return val;
} else {
var i=me.args['string_substring'][field];
return val.substring(Number(i[0]),Number(i[1]));
}
},
/**
* @MA
*/
logicDesc_type: function(val){
if (val == 1) {
return '主算法';
} else if(val == 0){
return '一般算法';
} else {
return '系统算法';
}
},
/**
* 通用方法
* 获取本地常用属性
* em_name,em_code,em_uu,en_uu...
* 以及获取本地时间
* @expression getLocal(em_code),getLocal(Y-m-d),getLocal(time)
*/
getLocal: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,me = grid.RenderUtil,column = grid.columns[y],field = column.dataIndex;
if(!me || !me.args){
grid = grid.ownerCt, me = grid.RenderUtil;
if(!me || !me.args){
return val;
}
}
var arg = me.args.getLocal[field][0],v = val;
if(contains('Y-m-d H:i:s', arg)) {
v = Ext.Date.format(new Date(), arg);
} else if('time' == arg){
v = Ext.Date.format(new Date(), 'Y-m-d H:i:s');
} else if('date' == arg){
v = Ext.Date.format(new Date(), 'Y-m-d');
} else {
v = window[arg];
}
if(v && Ext.isEmpty(val)) {
val = v;
record.set(field, v);
}
return val;
},
/**
* @MA
* 逻辑顺序 0-before,1-after
*/
logicturn: function(val){
switch (Number(val)){
case 0 :
val = 'before';break;
case 1 :
val = 'after';break;
}
return val;
},
/**
* @MA
* form配置界面,将从datadictonary得到的ddd_fieldtype转化为form能识别的fd_type
*/
form_type: function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,column = grid.columns[y],e,f, _v = val ? val.toLowerCase() : '', len = 20;
if(/^(varchar2)/.test(_v)) {
val = 'S';
len = Number(_v.substring(_v.indexOf('(') + 1, _v.indexOf(')')));
} else if (/^(int)/.test(_v)) {
val = 'N';
} else if (/^(number)/.test(_v)) {
val = 'N';
} else if (/^(float)/.test(_v)) {
val = 'N';
} else if (/^(smallint)/.test(_v)) {
val = 'N';
} else if ('date' == _v) {
val = 'D';
} else if ('timestamp' == _v) {
val = 'DT';
}
if (record.get('fd_type') != val) {
record.set('fd_type', val);
record.set('fd_fieldlength', len);
}
if ((e = (column.editor || column.filter)) != null && e.store) {
var s = null,dd = e.store.data;
s = Ext.Array.filter(dd, function(d, index){
return d.value == val;
});
if(s && s.length > 0) {
return s[0].display;
}
} else if ((f = column.field) != null) {
return f.rawValue;
}
return val;
},
/**
* @FA.VoucherStyle
*/
fa_vdclass: function(val, meta, record, x, y, store, view) {
if(!Ext.isEmpty(val)) {
var count = 0;
store.each(function(d){
if(d.get('vd_class') == val) {
count++;
}
});
var v = record.get('vd_detno');
if(v <= 0 || v > count) {
record.set('vd_detno', count);
}
}
return val;
} ,
/**
* @FA.VoucherStyle
*/
fa_custmonthcys_batch: function(val, meta, record, x, y, store, view) {
var cm_endamount = record.data['cm_endamount']; //应收金额
var cm_prepayend = record.data['cm_prepayend']; //预收金额
if(Ext.isNumber(Number(cm_endamount))&&Ext.isNumber(Number(cm_prepayend))){
if(cm_endamount == '' && cm_prepayend == ''){
return '';
}
return Number(cm_endamount) > Number(cm_prepayend) ? Ext.util.Format.number(cm_endamount, '0,000.00') :Ext.util.Format.number(cm_prepayend,'0,000.00') ;
} else {
return '';
}
} ,
/**
* @流程等待时间
*/
WaitTime:function(val, meta, record){
if(record){
var launchTime=record.data.jp_launchTime;
return parseInt((new Date().getTime()-new Date(launchTime).getTime())/60000);
}
else return null;
},
/**
* @FA.Voucher
* VoucherCreate
* 打开凭证
*/
openvoucher: function(val, meta, record) {
if(!Ext.isEmpty(val)) {
if(!window.__fn) {
var fn = function(vo_code) {
Ext.Ajax.request({
url: basePath + 'common/getFieldData.action',
params: {
caller: 'Voucher',
field: 'vo_id',
condition: 'vo_code=\'' + vo_code + '\''
},
callback: function(opt, s, r) {
if(s) {
var rs = Ext.decode(r.responseText);
if(rs.data != null && rs.data > 0) {
openUrl('jsps/fa/ars/voucher.jsp?formCondition=vo_idIS' + rs.data +
'&gridCondition=vd_voidIS' + rs.data);
}
}
}
});
};
window.__fn = fn;
}
val = '' + val + '';
}
return val;
},
prod_disable : function(v, m, r) {
var s = r.get('pr_status');
m.style = '';
if('已删除' == s || '已禁用' == s) {
m.style = 'color:red;';
}
return v;
},
/**
* @PM
* 制造单批量转FQC前,判断根据物料大类,批号需要手工录入(国扬)
**/
turnfqc_requirebatch : function(v, m, r, x, y, store, view) {
var kinds = ['CWDM模块','PCBA板','PCB板','光开关','结构件','模拟光模块','模拟光器件','数字光模块','数字光器件','数字器件材料','无源半成品','无源器件材料'];
if(kinds.indexOf(v) > -1 && view.ownerCt.selModel.isSelected(r) && Ext.isEmpty(r.get('ma_contractcode'))) {
showError('需要填写批号,工单:' + r.get('ma_code'));
}
return v;
},
/**
* @Scm.Application
* 请购单差异天数计算(国扬)
**/
application_differdays : function(val, meta, record){
var v = record.get('ad_delivery');
if(v != null) {
return Math.round((v-Ext.getCmp('ap_date').getValue())/86400000)-(record.get('ad_leadtime'));
}
return 0;
},
/**
* @Pm.MakeScrap
* 报废单是否超备损数报废
**/
ifoverqtyScrap : function(val, meta, record){
var v1 = record.get('md_allscrapqty');
var v2 = record.get('mm_balanceqty');
var v;
if(v1>0 && v1>v2) {
v='是';
}else
v= '否';
return v;
},
/**
* @Scm。ProdInOut
* 生产退料单,是否超损耗退料
**/
ifoverqtyReturn : function(val, meta, record){
var v1 = record.get('pd_orderqty');
var v2 = record.get('mm_balanceqty');
var v;
if(v1>0 && v1>v2 && record.get('pd_description')=="制程不良") {
v='是';
}else
v= '否';
return v;
},
/**
* @Pm。
* 增加物料的关联信息查看render(鼠标停在某个物料上时,显示一个tip提示信息,
* 包含物料的MRP库存,不良品库存,采购待检数,PO在途数,请购在途数,工单未发料数,工单为完工数)
**/
ProductHref : function(val, meta, record,x,y,store, view){
var field = this.columns[y].dataIndex;
var me = this.RenderUtil;
var grid = view.ownerCt;
document.getElementById(view.el.id).addEventListener("mouseover", function(e){
callValue = e.target.innerHTML;
if(typeof(me.args.ProductHref) != undefined && me.args.ProductHref != null){//带有参数,分别指参数列
var rfield = me.args.ProductHref[field];
for(var i=0;i 库存数量为0');
}
}
}
});
}
},
items : [{
xtype : 'grid',
width : 300,
columns : [ {
text : '仓库编号',
cls : 'x-grid-header-1',
dataIndex : 'PW_WHCODE',
width : 80
}, {
text : '仓库名称',
cls : 'x-grid-header-1',
dataIndex : 'WH_DESCRIPTION',
width : 120
}, {
text : '库存',
cls : 'x-grid-header-1',
xtype : 'numbercolumn',
align : 'right',
dataIndex : 'PW_ONHAND',
width : 90
} ],
columnLines : true,
title : '物料分仓库存',
store : new Ext.data.Store({
fields : [ 'PW_WHCODE', 'WH_DESCRIPTION', 'PW_ONHAND' ],
data : [ {} ]
})
} ]
});
}
}
return record.data[field];
},
/**
* @SCM.Purchase.VerifyApplyChange
* 收料变更单新数量
*/
scm_verify_change_qty: function(val, meta, record){
meta.style = "background:#C6E2FF;";
var pdq = record.data['pd_qty'], oldqty = record.data['vcd_oldqty'],
yqty = record.data['pd_yqty'];
if(pdq != null && pdq > 0) {
if(yqty + (val-oldqty) > pdq) {
val = pdq-yqty+oldqty;
showError('请不要超过采购数<' + pdq + '>!');
}
}
if(record.get('vcd_newqty') != val) {
record.set('vcd_newqty', val);
}
return val;
},
/**
* @PM ProdInOut!Partition!Deal
* 拆件批量入库 (入库数)
*/
pm_io_thisqty: function(val, meta, record, x, y, store, view){
meta.tdCls = "x-grid-cell-renderer-bl";
var grid = view.ownerCt, me = grid.RenderUtil,column = grid.columns[y] ;
var gqty = record.data['mm_gqty'];
var yqty = record.data['mm_yqty'];
if(gqty != null && gqty > 0 ) {
var maxValue = gqty-yqty;
if(record.dirty){
var thisqty = val ;
if(column.editor || (column.getEditor && column.getEditor())) {//在允许编辑的情况下,修改值不能大于maxValue
if (thisqty > maxValue){
val = maxValue;
showError('请不要输入超过最大数量<' + maxValue + '>的值!');
}
}
}else{
val = maxValue;
}
if(record.data['mm_thisqty'] != val){
record.set('mm_thisqty', val);
}
return val;
}
},
/**
* @Fa
* 应付批量开票
* */
FA_THISVOQTY: function(val, meta, record, x, y, store, view){
var maxValue=record.get('pd_showqty')-record.get('pd_showinvoqty');
var grid = view.ownerCt,column = grid.columns[y],field = column.dataIndex;
if(maxValue>0 && val<0){
val=maxValue;
showError('开票数量不能小于0!');
record.set(field,val);
}
else if(maxValue<0 && val>0){
val=maxValue;
showError('开票数量不能大于0!');
record.set(field,val);
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
else
val = val.toFixed(4);
return val;
},
FA_BILLOUTTHISVOQTY: function(val, meta, record, x, y, store, view){
var maxValue=record.get('abd_qty')-record.get('abd_yqty');
var grid = view.ownerCt,column = grid.columns[y],field = column.dataIndex;
if(maxValue>0 && val<0){
val=maxValue;
showError('开票数量不能小于0!');
record.set(field,val);
}
else if(maxValue<0 && val>0){
val=maxValue;
showError('开票数量不能大于0!');
record.set(field,val);
} else if(!val) {
val = maxValue;
record.set(field,val);
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
else
val = val.toFixed(4);
return val;
},
/**
* @Fa
* 对账单转发票
* */
FA_CHECK_THISVOQTY: function(val, meta, record, x, y, store, view){
var maxValue=record.get('ad_qty')-record.get('ad_yqty');
var grid = view.ownerCt,column = grid.columns[y],field = column.dataIndex;
if(maxValue>0 && val<0){
val=maxValue;
showError('开票数量不能小于0!');
record.set(field,val);
} else if(maxValue<0 && val>0){
val=maxValue;
showError('开票数量不能大于0!');
record.set(field,val);
} else if(!val) {
val = maxValue;
record.set(field,val);
}
if(column.format)
val = Ext.util.Format.number(val, column.format);
else
val = val.toFixed(4);
return val;
},
BatchRemind: function(val, meta, record){
if(record.get('ba_validtime') && Number(record.get('ba_remain'))>0 && new Date()>record.get('ba_validtime'))
return '' + val + '';
else return val;
},
SMTMonitor :function(val, meta, record, x, y, store, view){
var me = this;
if(Ext.isDefined(me.unitTime)){
if(Number(me.unitTime)*Number(record.get('msl_remainqty')) < Number(me.warningTime)*60){
me.getView().getRowClass = function(record, rowIndex, rowParams, store) {
return 'renderColor';
};
var el = Ext.get('audio-error').dom;
el.play();
}
}
return val;
},
/**
* 明细行附件上传下载
* */
detailAttach:function(val, meta, record, x, y, store, view){
if(record&&record.data["1detailAttach"]!=null&&record.data["1detailAttach"]!=""){
var attach=record.data["1detailAttach"];
var grid = view.ownerCt,column = grid.columns[y],field = column.dataIndex;
if(record.data[field] != attach){
record.set(field,attach);
}
return ''+'' + attach.split(";")[0] + ''+'';
}else if(record&&val!=null&&val!=""){
return ''+'' + val.split(";")[0] + ''+'';
}else return val;
},
/**
* 明细行报表上传下载
* */
detailAttach1:function(val, meta, record, x, y, store, view){
var file_path = record.data["file_path"];
if(record&&record.data["1detailAttach"]){
var attach=record.data["1detailAttach"];
var grid = view.ownerCt,column = grid.columns[y],field = column.dataIndex;
if(record.data[field] != attach){
record.set(field,attach);
}
return ''+'' + attach.split(";")[0] + ''+'';
}else if(record &&en_admin=="pdf"){
if(val!=null&&val!="" ){
return ''+'' + val.split(";")[0] + ''+'';
}else if(!record.dirty && record.data["file_name"] !="" && record.data["file_name"]!=null){
return ''+'' + record.data["file_name"]+'.rpt'+ ''+'';
}else if(record.data["id"] !="" && record.data["id"]!=null&&en_admin=="pdf"){//解决更新条件等字段时附件字段为空无法更新
var arr=file_path.split('/');var length=arr.length;
record.set('attach',arr[length-1]+";0");
return ''+'' + arr[length-1]+ ''+'';
}
}else return val;
},
/**
*kpi考核结果 查看分数来源
* */
score_from:function(val,meta,record){
if(record.data.ktd_kiid!=0){
var ktd_kiid=record.data.ktd_kiid;
return "";
}
return '';
},
/**
* 培训资源链接
*/
resource_link:function(val){
return ''+val+'';
},
/**
* 培训计划—考试-特殊颜色
*/
trainingPlan_exam:function(val,meta,record){
if(record&&record.data['ti_exam']==true){
meta.tdCls = "x-grid-cell-renderer-cl";
}
return val;
},
/**
* 明细行texttrigger
*/
texttrigger:function(val, meta, record, x, y, store, view){
var grid = view.ownerCt,column = grid.columns[y];
meta.style="padding-right:0px!important";
if(val){
return ''+val+''+
'';
}
return '';
},
/**
* CommonUse 列表链接
*/
openCommonUse:function(val, m, record, x, y, store, view) {
var grid = view.ownerCt, me = grid.RenderUtil,column = grid.columns[y], url = record.get('cu_url');
if(url) {
var val = "" + val + "";
return val;
}
return val;
},
/**
* @PM.MRP
* MRP 需求中的订单号根据不同来源[销售订单,销售预测]打开链接
*/
openorder: function(val, meta, record) {
if(!Ext.isEmpty(val)) {
if(!window.__fn) {
var fn = function(code) {
Ext.Ajax.request({
url: basePath + 'common/getFieldData.action',
params: {
caller: 'SaleForecast',
field: 'sf_id',
condition: 'sf_code=\'' + code + '\''
},
callback: function(opt, s, r) {
if(s) {
var rs = Ext.decode(r.responseText);
if(rs.data != null && rs.data > 0) {
openUrl('jsps/scm/sale/saleForecast.jsp?whoami=SaleForecast&formCondition=sf_idIS' + rs.data +
'&gridCondition=sd_sfidIS' + rs.data);
}else{
openUrl('jsps/scm/sale/sale.jsp?whoami=Sale&formCondition=sa_codeIS' + code +
'&gridCondition=sd_codeIS'+code);
}
}
}
});
};
window.__fn = fn;
}
val = '' + val + '';
}
return val;
},
/**
* @PM.GoodsUpDeal 批量上架
* 本次上架数量不允许超过建议上架数量,不允许小于0
*/
pm_goodsup_thisqty: function(val, meta, record, x, y){
meta.tdCls = "x-grid-cell-renderer-bl";
var r=0;
//r为该序号总剩余未发料数
r = record.data['mdd_qty'];
if(record.dirty){//未被修改过,并且mdd_qty与计算值不等
if(val > r) {
showError("本次上架数不得超过" + r);
val = r;
record.set('mdd_upqty', val);
} else if(val < 0 || val == 0){
showError("本次上架数必须大于0");
if(val!=r){
val = r;
record.set('mdd_upqty', val);
}
}
}else if(val == 0 ){
if(val!=r){
val = r;
record.set('mdd_upqty', val);
}
}
return val;
}
});