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.

253 lines
8.9 KiB

define(function (require, exports, module) {
let BaseBiz = require('apps/rht/base/rhtBiz');
let Service = require('./dst200101service');
let MdYhInf = require('./mdyhinf');
let YhErrInf = require('./yherrinf');
/**
* 控制按钮的可用
* @param opCode 按钮编码
* @return [description]
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
vm.remark =''
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
let dataList = null;
//根据登录组织等拼装查询条件
Biz.prototype.beforeDataSrcSearch = function (dataSrc, params) {
let self = this;
self.setServerBiz('cn.qdhezheng.rht.app.dst.dst200101.SavePlugin');
};
//校验小数精度
Biz.prototype.getPrecision = function (dataSrc, dr, dc, defaultPrecision) {
if (dataSrc.uiObjCode == this.dsDetail.uiObjCode) {
//把这里改成需要控制的字段
if (dc.fieldName == 'QrCount') {
return TypeUtil.toInt(dr['R_DotDecimal']);
}
}
return this.super('getPrecision', dataSrc, dr, dc, defaultPrecision);
};
//字段变化触发事件
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
switch (dc.fieldName) {
case 'Remark':
this.fieldChangedRemark(dataSrc, dr, dc);
break;
}
}
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
switch (dc.fieldName) {
case 'QrCount':
this.fieldChangedQrCount(dataSrc, dr, dc);
break;
}
}
this.super('fieldChanged');
};
//Remark 字段变化执行事件
Biz.prototype.fieldChangedRemark = function (dataSrc, dr, dc) {
let sRemarkBillNo = dr ? TypeUtil.toString(dr['RemarkBillNo']) : '';
if (sRemarkBillNo.length > 0){
dr.setColumnError(dc.fieldName, "备注信息已写入配送单,不能修改!");
return false;
}
return true;
};
//QrCount 字段变化执行事件
Biz.prototype.fieldChangedQrCount = function (dataSrc, dr, dc) {
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
if (sPluCode === '') return false;
let curHRow = this.dsMaster.currentRow;
let sBillNo = curHRow ? TypeUtil.toString(curHRow['BillNo']) : '';
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","QrCount", sBillNo,"","","","");
if (ret.result !== 1) {
Store.messager.err(ret.message);
return false;
}
return true;
};
//按钮事件控制
Biz.prototype.doOp = function (opCode) {
if (opCode == 'myedit') {
this.opRouter('edit');
}
if (opCode == 'pass') {
this.onpass("1");
}
if (opCode == 'nopass') {
this.onpass("2");
}
if (opCode == 'showinf') {
this.onshowinf();
}
if (opCode == 'mdyhinf') {
this.onmdyhinf();
}
if (opCode == 'yherrinf') {
this.onyherrinf();
}
};
//控制主界面按钮状态
Biz.prototype.getOpEnabled = function (opCode) {
let isOk = this.super('getOpEnabled', opCode);
if (!isOk) {
return false;
}
let curRow = this.dsMaster.currentRow;
if (opCode == 'myedit'){
if (!curRow)
return false;
if (this.isEdit())
return false;
}
if ((opCode == 'pass') || (opCode == 'nopass')) {
if (!curRow)
return false;
if (this.isEdit())
return false;
}
return true;
};
//确认/作废公共事件处理
Biz.prototype.onpass = function (sType) {
let sTypeName ="确认";
if (sType == "2"){
sTypeName ="作废";
}
//弹出是否确认提交对话框
if (!Store.confirm("确认要对选中数据进行"+sTypeName+"处理吗?")) {
return false;
}
let curHRow = this.dsMaster.currentRow;
let sBillNo = curHRow ? TypeUtil.toString(curHRow['BillNo']) : '';
let arrBillNo = new Array();
let iPass = 0;
if (this.dsMaster.getSelectedRows().length <= 0){
if (sBillNo.length > 0){
let sZbOrgCode = curHRow ? TypeUtil.toString(curHRow['ZbOrgCode']) : '';
if (sZbOrgCode != Store.logOn.orgCode){
Store.messager.err("所选单据("+sBillNo+")不是向本组织要货的要货数据,本组织不能确认或作废,请检查!");
return false;
}
arrBillNo[0] = sBillNo;
iPass = iPass +1;
}
}
else{
//只处理符合条件的单据
for (let i=0;i<this.dsMaster.getSelectedRows().length;i++){
let row = this.dsMaster.getSelectedRows()[i];
if (TypeUtil.toString(row['ZbOrgCode']) != Store.logOn.orgCode){
Store.messager.err("所选单据("+row['BillNo']+")不是向本组织要货的要货数据,本组织不能确认或作废,请检查!");
return false;
}
if (sType == "2"){
let sQrRemark = row ? TypeUtil.toString(row['QrRemark']) : '';
if (sQrRemark.length <= 0){
Store.messager.err("作废要货数据("+row['BillNo']+")前必须录入要货单据头的总部确认说明。");
return false;
}
}
arrBillNo[iPass] = TypeUtil.toString(row['BillNo']);
iPass = iPass +1;
}
}
if (iPass <= 0){
Store.messager.err("处理失败,未找到符合条件的单据!");
return false;
}
let ret= Service.getSlideMenuData("actExecute","onpass", arrBillNo,sType,"","","");
if ((ret.result !== 1) && (ret.result !== 2)) {
Store.messager.err(ret.message);
return false;
}
dataList = ret.data;
this.opRouter('refresh');
if (ret.result == 2) {
Store.messager.tip(sTypeName+"处理成功!"+ret.message);
}
else{
Store.messager.tip(sTypeName+"处理成功!");
}
return true;
};
//信息展示事件处理
Biz.prototype.onshowinf = function (sType) {
if (dataList === null){
return false;
}
if (dataList.length == 0){
return false;
}
let mainGrid = {
opts: {},
data: {
columns: [
{field: 'BillNo',name: '要货单号'},
{field: 'PluCode',name: '商品编码'},
{field: 'PluName',name: '商品名称'},
{field: 'YhCount',name: '要货数量'},
{field: 'QrCount',name: '确认数量'},
{field: 'Remark',name: '备注信息'}
],
rows:dataList
/*rows: [
{PluCode: '111111'},
{PluCode: '22222'}
],*/
},
actions: {}
};
this.view.register('grid','grid_main',mainGrid);
return true;
};
//门店要货信息事件处理
Biz.prototype.onmdyhinf = function () {
let self = this;
//定义多选窗口界面
let param = {
uiObjCode: '20515',
serverBiz: 'cn.qdhezheng.rht.app.dst.dst200101.SavePlugin',
biz: self,
pk: "OrgCode",
showCheckColumn: true,
enablePager: false,
funcCode: self.FuncCode,
ds: self.dsMaster
};
//new多选窗体 并打开
let myWindow = new MdYhInf(param);
myWindow.open();
};
//要货异常信息事件处理
Biz.prototype.onyherrinf = function () {
let self = this;
//定义多选窗口界面
let param = {
uiObjCode: '20516',
serverBiz: 'cn.qdhezheng.rht.app.dst.dst200101.SavePlugin',
biz: self,
//pk: "OrgCode",
showCheckColumn: true,
enablePager: false,
funcCode: self.FuncCode,
ds: self.dsMaster
};
//new多选窗体 并打开
let myWindow = new YhErrInf(param);
myWindow.open();
};
return Biz;
});