@ -456,91 +456,61 @@
}
}
})
})
},
},
deepCompare(x, y) {
floatAdd(a,b){
var i, l, leftChain, rightChain;
return Math.round(a*100+b*100)/100;
function compare2Objects(x, y) {
},
var p;
floatCut(a,b){
if (isNaN(x) & & isNaN(y) & & typeof x === 'number' & & typeof y === 'number') {
return Math.round(a*100-b*100)/100;
return true;
},
}
CompanyKeyName:{
if (x === y) {
id:"公司表id",
return true;
partner:"公司名称",
}
link_man:'联系人',
if ((typeof x === 'function' & & typeof y === 'function') ||
link_phone:"联系电话",
(x instanceof Date & & y instanceof Date) ||
address:'邮寄地址',
(x instanceof RegExp & & y instanceof RegExp) ||
company_tax_no:'公司税号',
(x instanceof String & & y instanceof String) ||
payee_name:'名称',
(x instanceof Number & & y instanceof Number)) {
bank_account:"银行账号",
return x.toString() === y.toString();
opening_bank:"开户行"
}
},
if (!(x instanceof Object & & y instanceof Object)) {
checkCompanyKey(type,key){
return false;
//获取公司名
}
var company = '';
if (x.isPrototypeOf(y) || y.isPrototypeOf(x)) {
if(key == "payee_name" || key == "bank_account" || key == "opening_bank"){
return false;
if((DATAOBJ.statement_type == 0 & & type == "first_party_info") || (DATAOBJ.statement_type == 1 & & type == "second_party_info")){
}
company = "收款方";
if (x.constructor !== y.constructor) {
return false;
}
}
if (x.prototype !== y.prototype) {
if((DATAOBJ.statement_type == 0 & & type == "second_party_info")|| (DATAOBJ.statement_type == 1 & & type == "first_party_info")){
return false ;
company = "付款方" ;
}
}
if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1) {
}else{
return false;
if(type == "first_party_info"){
company = "甲方";
}else{
company = "乙方";
}
}
for (p in y) {
if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
return false;
} else if (typeof y[p] !== typeof x[p]) {
return false;
}
}
for (p in x) {
if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
return false;
} else if (typeof y[p] !== typeof x[p]) {
return false;
}
switch (typeof (x[p])) {
case 'object':
case 'function':
leftChain.push(x);
rightChain.push(y);
if (!compare2Objects(x[p], y[p])) {
return false;
}
leftChain.pop();
rightChain.pop();
break;
default:
if (x[p] !== y[p]) {
return false;
}
break;
}
}
return true;
}
}
//获取键名
if (arguments.length < 1 ) {
try {
return true;
var keyname = company+PUBLIC.CompanyKeyName[key];
} catch (error) {
var keyname = false;
}
}
for (i = 1, l = arguments.length; i < l ; i + + ) {
//验证
if(DATAOBJ[type][key] ===''){
leftChain = []; //Todo: this can be cached
layer.msg(keyname+"不能为空");
rightChain = [];
return false;
}
if (!compare2Objects(arguments[0], arguments[i])) {
if(key == "link_phone" & & !CHECK.mobile.test(DATAOBJ[type][key])){
return false;
layer.msg(keyname+"格式错误");
}
return false;
}
if(key == "bank_account" & & !CHECK.BankNo.test(DATAOBJ[type][key])){
layer.msg(keyname+"格式错误");
return false;
}
}
return true;
return true;
}
},
}
}
//数据类
//数据类
@ -570,37 +540,20 @@
}
}
//验证甲方信息
//验证甲方信息
for (const key in DATAOBJ.first_party_info) {
for (const key in DATAOBJ.first_party_info) {
var t = DATAOBJ.first_party_info;
var t = DATAOBJ.first_party_info;
if (t[key] === '') {
var flag = PUBLIC.checkCompanyKey("first_party_info",key);
layer.msg('甲方信息不全,请先补全 code:' + key);
if(!flag){
return false;
return flag;
}
if (key == "link_phone" & & !CHECK.mobile.test(t[key])) {
layer.msg('甲方联系人手机号格式错误');
return false;
}
if (key == "bank_account" & & !CHECK.BankNo.test(t[key])) {
layer.msg('甲方银行卡号格式错误');
return false;
}
}
}
}
//乙方
//乙方
for (const key in DATAOBJ.second_party_info) {
for (const key in DATAOBJ.second_party_info) {
var t = DATAOBJ.second_party_info;
var t = DATAOBJ.second_party_info;
if (!t[key] || t[key] == '') {
var flag = PUBLIC.checkCompanyKey("second_party_info",key);
layer.msg('乙方信息不全,请先补全 code:' + key);
if(!flag){
return false;
return flag;
}
if (key == "link_phone" & & !CHECK.mobile.test(t[key])) {
layer.msg('乙方联系人手机号格式错误');
return false;
}
if (key == "bank_account" & & !CHECK.BankNo.test(t[key])) {
layer.msg('乙方银行卡号格式错误');
return false;
}
}
}
}
console.log(DATAOBJ);
layer.load(2);
layer.load(2);
$("#createStatement").off("click");//自我解绑
$("#createStatement").off("click");//自我解绑
@ -633,56 +586,67 @@
},
},
statementchange() {
statementchange() {
$(".statementchange").off("blur");
$(".statementchange").off("blur");
$(".statementchange").on("blur", function () {
$(".statementchange").on("blur",function(){
var sort = $(this).data("change");
var sort = $(this).data("change");
var val = $(this).val();
var val = $(this).val();
if (!CHECK.number.test(val)) {
var vdata = eval("DATAOBJ."+sort);//原先值
var dom = $(this);
if(!CHECK.number.test(val)){
layer.msg('结算单中的罚款和税率必须是数字');
layer.msg('结算单中的罚款和税率必须是数字');
$(this).val(0);
dom.val(vdata );
return false;
return false;
}
}
var str = "DATAOBJ." + sort + "='" + val + "';";
if (sort != 'fine') {
var str = "DATAOBJ."+sort+"='"+val+"';";
if(sort != 'fine'){
if(val > 100 || val < 0 ) {
layer.msg('结算单中的税率不允许大于100和小于0');
dom.val(vdata);
return false;
}
eval(str);
eval(str);
var index = $(this).data("index");
var index = $(this).data("index");
var td = DATAOBJ.statement_info[index];
var td = DATAOBJ.statement_info[index];
if ($(this).attr("name") == "first_ratio") {
if( $(this).attr("name") == "first_ratio"){
td['second_ratio'] = 100 - val;
td['second_ratio'] = 100-val;
}
}
if ($(this).attr("name") == "second_ratio") {
if( $(this).attr("name") == "second_ratio"){
td['first_ratio'] = 100 - val;
td['first_ratio'] = 100-val;
}
}
if (DATAOBJ.statement_type == 0) {
if(DATAOBJ.statement_type == 0){
var ratio = td['first_ratio'] / 100;
var ratio = td['first_ratio']/100;
} else {
}else{
var ratio = td['second_ratio'] / 100;
var ratio = td['second_ratio']/100;
}
}
DATAOBJ.statement_count['sum_money'] - = td['sum_money'];
DATAOBJ.statement_count['sum_money'] = PUBLIC.floatCut(DATAOBJ.statement_count['sum_money'], td['sum_money']) ;
td['sum_money'] = Math.floor((td['pay_amount'] * (100 - td['promote_ratio']) / 100 * ratio * (100 - td['fax_ratio']) / 100) * 100) / 100;
td['sum_money'] = Math.round((td['pay_amount']*(100-td['promote_ratio'])/100*ratio*(100-td['fax_ratio'])/100)* 100) / 100 ;
DATAOBJ.statement_count['sum_money'] += (td['sum_money'] - 0);
} else {
DATAOBJ.statement_count['sum_money']=PUBLIC.floatAdd(DATAOBJ.statement_count['sum_money'],td['sum_money']);
DATAOBJ.fine = Math.floor(DATAOBJ.fine * 100) / 100;
if (val > DATAOBJ.statement_count['sum_money']) {
}else{
DATAOBJ.fine = Math.round(DATAOBJ.fine * 100) / 100 ;
if(!CHECK.money.test(val)){
layer.msg('罚款金额格式错误');
$(this).val(DATAOBJ.fine);
return false;
}
if(val > DATAOBJ.statement_count['sum_money']){
layer.msg('罚款金额过大,总计不允许为负数');
layer.msg('罚款金额过大,总计不允许为负数');
$(this).val(DATAOBJ.fine);
$(this).val(DATAOBJ.fine);
return false;
return false;
}
}
console.log(str);
DATAOBJ.statement_count['sum_money'] = (DATAOBJ.statement_count['sum_money'] - 0 + DATAOBJ.fine);
DATAOBJ.statement_count['sum_money'] =PUBLIC.floatAdd(DATAOBJ.statement_count['sum_money'], DATAOBJ.fine);
DATAOBJ.statement_count['pay_amount'] = (DATAOBJ.statement_count['pay_amount'] - 0 + DATAOBJ.fine);
DATAOBJ.statement_count['pay_amount'] = PUBLIC.floatAdd(DATAOBJ.statement_count['pay_amount'], DATAOBJ.fine);
eval(str);
eval(str);
DATAOBJ.statement_count['sum_money'] = DATAOBJ.statement_count['sum_money'] - DATAOBJ.fine;
DATAOBJ.statement_count['sum_money'] =PUBLIC.floatCut(DATAOBJ.statement_count['sum_money'],DATAOBJ.fine);
DATAOBJ.statement_count['pay_amount'] = DATAOBJ.statement_count['pay_amount'] - DATAOBJ.fine;
DATAOBJ.statement_count['pay_amount'] = PUBLIC.floatCut(DATAOBJ.statement_count['pay_amount'],DATAOBJ.fine);
}
}
DATAOBJ.statement_count['pay_amount'] = Math.floor(DATAOBJ.statement_count['pay_amount'] * 100) / 100;
DATAOBJ.statement_count['sum_money'] = Math.floor(DATAOBJ.statement_count['sum_money'] * 100) / 100;
TPLSHOW.showStatementList(true);
TPLSHOW.showStatementList(true);
})
})
}
}