You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

define(function(require, exports, module) {
var Biz = require('system/base/biz');
function BillTypeBiz(vm) {
Biz.call(this, vm);
};
inherits(BillTypeBiz, Biz);
BillTypeBiz.prototype.initCompleted = function() {
this.super('initCompleted');
};
BillTypeBiz.prototype.beforeSave = function() {
var currentRow = this.dsMaster.currentRow;
if (currentRow === null) return false;
var useDBPrefix = currentRow["UseDBPrefix"];
var prefixNo = currentRow["PrefixNo"];
var noLength = Number(currentRow["NoLength"]);
var dateFmt = currentRow["DateFmt"];
var length = 0;
if (useDBPrefix === '1') {
length = 100 - (2 + dateFmt.length + prefixNo.length);
} else {
length = 100 - (dateFmt.length + prefixNo.length);
}
if (length < 0) {
Store.messager.warn(Store.format(Store.MSG.FRS003_01,prefixNo.Length)); //单号前缀长度为{0},过于冗长请检查是否录入错误。
return false;
}
if (noLength >= length || noLength < 0) {
Store.messager.warn(Store.format(Store.MSG.FRS003_02,length)); //输入的序号长度应该大于0并且应该小于{0}
return false;
}
return this.super('beforeSave');
}
BillTypeBiz.prototype.dataColumnValidate = function(dataSrc, dr, dc, value) {
if (dataSrc.currentRow !== null && dc.fieldName === 'DateFmt' && value !== null) {
// 获取服务器端时间
var nowDateTime = Store.bizDao.getSysDate();
var nowDate = nowDateTime.split(' ')[0].replace(/-/g,"/");
var date = new Date(nowDate);
var FormatDate = Format(date, value);
dataSrc.currentRow.setColumnValue('NowDate', FormatDate);
}
return this.super('dataColumnValidate');
}
function Format(x, y) {
var z = {
M : x.getMonth() + 1,
D : x.getDate()
};
y = y.replace(/(M+|D+)/g, function(v) {
return ((v.length > 1 ? "0" : "") + eval('z.' + v.slice(-1))).slice(-2);
});
return y.replace(/(Y+)/g, function(v) {
return x.getFullYear().toString().slice(-v.length);
});
}
return BillTypeBiz;
})