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.
151 lines
5.7 KiB
151 lines
5.7 KiB
|
|
define(function (require, exports, module) {
|
|
//引入业务类基类
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
let rhtComm = require('apps/rht/comm/rhtComm');
|
|
|
|
//引入业务服务
|
|
let Service = require('./pri10020105service');
|
|
|
|
/**
|
|
* 定义业务类对象
|
|
* @param vm 界面相关ViewModule
|
|
*/
|
|
function Biz(vm) {
|
|
//继承第一步,构造继承
|
|
BaseBiz.call(this, vm);
|
|
}
|
|
|
|
//继承第二步,方法继承
|
|
inherits(Biz, BaseBiz);
|
|
|
|
Biz.prototype.afterRefresh = function() {
|
|
let curRow = this.dsMaster.currentRow;
|
|
if(curRow){
|
|
for(let i=0;i<this.dsMaster.rows.length;i++){
|
|
let row = this.dsMaster.rows[i];
|
|
let rowSqPrice = TypeUtil.toFloat(row['SqPrice']);
|
|
let rowPrice = TypeUtil.toFloat(row['Price']);
|
|
if ((rowSqPrice == 0) || (rowPrice == 0)){
|
|
row.setColumnValue('TzRate',"0");
|
|
}
|
|
else{
|
|
let fTzRate = (100*(rowSqPrice-rowPrice)/rowPrice).round(2);
|
|
row.setColumnValue('TzRate',fTzRate);
|
|
}
|
|
}
|
|
}
|
|
return this.super('afterRefresh');
|
|
};
|
|
//保存前校验
|
|
Biz.prototype.beforeSave = function () {
|
|
let curRow = this.dsMaster.currentRow;
|
|
if(curRow){
|
|
let SqPrice = TypeUtil.toFloat(curRow['SqPrice']);
|
|
let SqHyPrice = TypeUtil.toFloat(curRow['SqHyPrice']);
|
|
if (SqPrice < 0) {
|
|
curRow.setColumnError('SqPrice', '申请售价必须大于等于零!');
|
|
return false;
|
|
}
|
|
if (SqHyPrice < 0) {
|
|
curRow.setColumnError('SqHyPrice', '申请会员价必须大于等于零!');
|
|
return false;
|
|
}
|
|
}
|
|
return this.super('beforeSave');
|
|
};
|
|
//保存后
|
|
Biz.prototype.afterSave = function() {
|
|
this.super('afterSave');
|
|
let curRow = this.dsMaster.currentRow;
|
|
if(curRow){
|
|
for(let i=0;i<this.dsMaster.rows.length;i++){
|
|
let row = this.dsMaster.rows[i];
|
|
let rowSqPrice = TypeUtil.toFloat(row['SqPrice']);
|
|
let rowPrice = TypeUtil.toFloat(row['Price']);
|
|
if ((rowSqPrice == 0) || (rowPrice == 0)){
|
|
row.setColumnValue('TzRate',"0");
|
|
}
|
|
else{
|
|
let fTzRate = (100*(rowSqPrice-rowPrice)/rowPrice).round(2);
|
|
row.setColumnValue('TzRate',fTzRate);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
//按钮事件控制
|
|
Biz.prototype.doOp = function (opCode) {
|
|
let self = this;
|
|
if (opCode == 'placc') {
|
|
let ds = self.dsMaster;
|
|
this.onplacc(self, ds);
|
|
}
|
|
};
|
|
//按钮事件处理
|
|
Biz.prototype.onplacc = function (biz, ds) {
|
|
Store.messager.confirm("确认要记账选中的数据吗?",function(isOK){
|
|
if(!isOK){
|
|
return false;
|
|
}
|
|
else{
|
|
let isel=0;
|
|
let guid = rhtComm.GetGUID();
|
|
let GenDate = rhtComm.GetServerDateTime(0);
|
|
for (let i = 0; i < ds.rows.length; i++) {
|
|
let row = ds.rows[i];
|
|
if (row['$is_sel'] !== undefined) {
|
|
if (row['$is_sel'] == true) {
|
|
let OrgCode = row ? TypeUtil.toString(row['OrgCode']) : '';
|
|
let BillNo = row ? TypeUtil.toString(row['BillNo']) : '';
|
|
let SerialNo = row ? TypeUtil.toString(row['SerialNo']) : '';
|
|
let retSelec= rhtComm.InToBatchSelectData(guid,GenDate,OrgCode,BillNo,SerialNo,"","","","","","");
|
|
if (retSelec.result !== 1) {
|
|
Store.messager.err(retSelec.message);
|
|
return false;
|
|
}
|
|
isel=isel+1;
|
|
}
|
|
}
|
|
}
|
|
if (isel==0){
|
|
Store.messager.err('请先选择需要记账的数据。');
|
|
return false;
|
|
}
|
|
let ret= Service.getSlideMenuData("actExecute","onplacc",guid,Store.logOn.userId,Store.logOn.userCode,Store.logOn.userName,"");
|
|
if (ret.result !== 1) {
|
|
Store.messager.err(ret.message);
|
|
return false;
|
|
}
|
|
//最后都提示成功
|
|
Store.messager.tip("记账完成!");
|
|
return true;
|
|
}
|
|
})
|
|
// return true;
|
|
};
|
|
//控制主界面按钮状态
|
|
Biz.prototype.getOpEnabled = function (opCode) {
|
|
let isOk = this.super('getOpEnabled', opCode);
|
|
if (!isOk) return false;
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
|
if (opCode == 'edit') {
|
|
let DataState = curRow ? TypeUtil.toString(curRow['DataState']) : '';
|
|
if (!curRow)
|
|
return false;
|
|
|
|
if ((DataState == '5') || (DataState == '6'))
|
|
return false;
|
|
}
|
|
if (opCode == 'delete') {
|
|
let DataState = curRow ? TypeUtil.toString(curRow['DataState']) : '';
|
|
if (!curRow)
|
|
return false;
|
|
|
|
if ((DataState == '5') || (DataState == '6'))
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
return Biz;
|
|
}); |