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.

382 lines
16 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) {
let BaseBiz = require('apps/rht/base/rhtBiz');
let Service = require('./dst200103service');
let rhtComm = require('apps/rht/comm/rhtComm');
let MdYhInf = require('./mdyhinf');
let queryTpl = require('text!./custom-built-query.tpl')
let showTypeChg = require('./dsttypechg');
let queryWindow = require("system/views/pages/querywindow/querywindow");
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
let sGuid = '';
let DST_ZSIsChangEtp = rhtComm.getRhtOptionValue('*','DST','DST_ZSIsChangEtp','0');
let DST_YKIsChangEtp = rhtComm.getRhtOptionValue('*','DST','DST_YKIsChangEtp','0');
let Dst_QrCountEditType = rhtComm.getRhtOptionValue('*','DST','Dst_QrCountEditType','0');
let IsMngPsCyc = rhtComm.getRhtOptionValue('*','DST','IsMngPsCyc','0');
Biz.prototype.getCustomBuiltQuery = function() {
let t =$(queryTpl);
//let $psCyc = self.getElement('.ps-cyc');
if (IsMngPsCyc == '1'){
t.append('<input class="easyui-checkbox ps-cyc" data-options="label: \'考虑配送周期:\'" checked=true labelWidth=100px labelAlign=\'right\' editable=false style="width:20px">')
}
return t[0].outerHTML
};
Biz.prototype.initCompleted = function () {
this.super('initCompleted');
this.dsMaster.onlySaveCurrent = false;
initDataListCheck(this);
};
function initDataListCheck(self) {
let DST_CLYH_DefCkSet = rhtComm.getRhtOptionValue('*','DST','DST_CLYH_DefCkSet','系统默认');
let IsAllCk = rhtComm.getRhtOptionValue('*','DST','IsAllCk','0');
let LsCkIsMngPsArea = rhtComm.getRhtOptionValue('*','SUPP','LsCkIsMngPsArea','0');
let DST_Set_PsJobCkCode = rhtComm.getRhtOptionValue('*','DST','DST_Set_PsJobCkCode','*');
let ret= Service.getSlideMenuData("actExecute","GetCkInf", "","","","","");
if (ret.result !== 1) {
Store.messager.err(ret.message);
return false;
}
self.getElement('.qh-cl').combobox();
self.getElement('.ps-type').combobox();
self.getElement('.ps-cyc').combobox();
if (ret.data !== null){
let $ckcode = self.getElement('.ck-code');
if ((IsAllCk == '1') && (LsCkIsMngPsArea == '0') && (DST_Set_PsJobCkCode == '*') && (ret.message == '1')){
ret.data.unshift({'ckname': '<全部>', 'ckcode': '<全部>'});
$ckcode.combobox({
valueField:'ckcode',
textField:'ckname',
data: ret.data,
onChange: function(){
if (LsCkIsMngPsArea == '1'){
self.opRouter('refresh')
}
}
});
$ckcode.combobox('setValue', '<全部>');
}
else{
$ckcode.combobox({
valueField:'ckcode',
textField:'ckname',
data: ret.data
});
if (ret.data !== null){
$ckcode.combobox('setValue', ret.data[0].ckcode);
}
if (DST_CLYH_DefCkSet != '系统默认'){
if (DST_CLYH_DefCkSet == '空'){
$ckcode.combobox('setValue', '');
}
else{
//$ckcode.combobox('setValue', '');
for(let i=0;i<ret.data.length;i++){
if (DST_CLYH_DefCkSet == ret.data[i].ckcode){
$ckcode.combobox('setValue', ret.data[i].ckcode);
}
}
}
}
}
}
}
Biz.prototype.beforeRefresh = function () {
let isOk = this.super('beforeRefresh');
if (IsMngPsCyc == '1'){
this.dsMaster.state = {
isCreate: '0',
psType: this.getElement('.ps-type').combobox('getValue'),
qhCl: this.getElement('.qh-cl').combobox('getValue'),
ckCode: this.getElement('.ck-code').combobox('getValue'),
psCyc: this.getElement('.ps-cyc').checkbox('options').checked ? 1 : 0,
}
}
else{
this.dsMaster.state = {
isCreate: '0',
psType: this.getElement('.ps-type').combobox('getValue'),
qhCl: this.getElement('.qh-cl').combobox('getValue'),
ckCode: this.getElement('.ck-code').combobox('getValue'),
psCyc: 0,
}
}
return isOk;
};
Biz.prototype.afterRefresh = function () {
let curRow = this.dsMaster.currentRow;
if(curRow){
this.dsMaster.setEditable(true);
}
return this.super('afterRefresh');
};
//根据登录组织等拼装查询条件
Biz.prototype.beforeDataSrcSearch = function (dataSrc, params) {
let self = this;
self.setServerBiz('cn.qdhezheng.rht.app.dst.dst200103.SavePlugin');
};
//字段变化触发事件
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
switch (dc.fieldName) {
case 'SupCode':
this.fieldChangedSupCode(dataSrc, dr, dc);
break;
case 'ZbSupCode':
this.fieldChangedZbSupCode(dataSrc, dr, dc);
break;
case 'DstType':
this.fieldChangedDstType(dataSrc, dr, dc);
break;
case 'QrCount':
this.fieldChangedQrCount(dataSrc, dr, dc);
break;
}
}
this.super('fieldChanged');
};
//SupCode 字段变化执行事件
Biz.prototype.fieldChangedSupCode = function (dataSrc, dr, dc) {
let sDstType = dr ? TypeUtil.toString(dr['DstType']) : '';
if ((sDstType != '1') && (DST_ZSIsChangEtp == '1')){
dr.setColumnError(dc.fieldName, "只有配送类型为直送时才可以手动设置供应商!");
return false;
}
let sPluID = dr ? TypeUtil.toString(dr['PluID']) : '';
let sOrgCode = dr ? TypeUtil.toString(dr['ShOrgCode']) : '';
let sSupCode = dr ? TypeUtil.toString(dr['SupCode']) : '';
let ret= Service.getSlideMenuData("DoOnMasterCalcRule","CheckEtpCode", sSupCode,sOrgCode,sPluID,"","");
if (ret.result !== 1) {
Store.messager.err(ret.message);
return false;
}
else{
dr.setColumnValue('SupName', ret.message);
}
return true;
};
//ZbSupCode 字段变化执行事件
Biz.prototype.fieldChangedZbSupCode = function (dataSrc, dr, dc) {
let sDstType = dr ? TypeUtil.toString(dr['DstType']) : '';
if ((sDstType != '2') && (DST_YKIsChangEtp == '1')){
dr.setColumnError(dc.fieldName, "只有配送类型为越库时才可以手动设置总部供应商!");
return false;
}
let sPluID = dr ? TypeUtil.toString(dr['PluID']) : '';
let sOrgCode = dr ? TypeUtil.toString(dr['OrgCode']) : '';
let sSupCode = dr ? TypeUtil.toString(dr['ZbSupCode']) : '';
let ret= Service.getSlideMenuData("DoOnMasterCalcRule","CheckEtpCode", sSupCode,sOrgCode,sPluID,"","");
if (ret.result !== 1) {
Store.messager.err(ret.message);
return false;
}
else{
dr.setColumnValue('ZbSupName', ret.message);
}
return true;
};
//DstType 字段变化执行事件
Biz.prototype.fieldChangedDstType = function (dataSrc, dr, dc) {
let sDstType = dr ? TypeUtil.toString(dr['DstType']) : '';
if ((sDstType != '0') && (sDstType != '1') && (sDstType != '2')){
dr.setColumnError(dc.fieldName, "请正确输入配送属性!");
return false;
}
let sOldDstType = TypeUtil.toFloat(dr.transData['DstType']);
let ushow = new showTypeChg(sOldDstType,sDstType);
ushow.callback=function(sRtnType){
if (sRtnType != "-1") {
let ret= Service.getSlideMenuData("DoOnMasterCalcRule","DstTypeChg", sRtnType,dr.getData(),"","","");
if (ret.result !== 1) {
Store.messager.err(ret.message);
return false;
}
Store.messager.tip('请重新选择创建配送任务数据!');
}
else{
//self.opRouter('refresh');
dr.setColumnValue('DstType', sOldDstType);
}
};
ushow.open();
return true;
};
//QrCount 字段变化执行事件
Biz.prototype.fieldChangedQrCount = function (dataSrc, dr, dc) {
let fQrCount = TypeUtil.toFloat(dr['QrCount']);
let fAskCount = TypeUtil.toFloat(dr['AskCount']);
let sBillType = dr ? TypeUtil.toString(dr['BillType']) : '';
if (sBillType == '1'){
if ((fAskCount != fQrCount) && (Dst_QrCountEditType == '1')){
dr.setColumnError(dc.fieldName, "选项控制对于主动配送单生成的待配送数据不允许修改确认数量!");
return false;
}
else if ((fAskCount < fQrCount) && (Dst_QrCountEditType == '2')){
dr.setColumnError(dc.fieldName, "选项控制对于主动配送单生成的待配送数据的确认数量不允许改大!");
return false;
}
}
return true;
};
//按钮事件控制
Biz.prototype.doOp = function (opCode) {
let self = this;
if (opCode == 'create') {
self.oncreate();
}
if (opCode == 'mdyhinf') {
this.onmdyhinf();
}
if (opCode == 'jobinf') {
this.onshowinf();
}
if (opCode == 'mysave') {
this.onmysave();
}
if (opCode == 'selall') {
this.onselall();
}
if (opCode == 'selno') {
this.onselno();
}
};
//增加右键菜单按钮并控制按钮状态
Biz.prototype.getContextMenus = function (ds, source) {
let menus = this.super("getContextMenus", ds, source)
menus.push({
text: '门店要货情况查询',
opCode: 'mdyhinf'
});
return menus;
};
//门店要货信息事件处理
Biz.prototype.onmdyhinf = function () {
let self = this;
//定义多选窗口界面
let param = {
uiObjCode: '20515',
serverBiz: 'cn.qdhezheng.rht.app.dst.dst200103.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.onshowinf = function () {
let self = this;
//定义多选窗口界面
let param = {
uiObjCode: '20008',
biz: self,
pk: 'PsJobNo,RefBillType,RefBillNo',
fixQuery: { 'PsJobNo': sGuid },
funcCode: self.FuncCode,
ds: self.dsMaster
};
//new多选窗体 并打开
let myWindow = new queryWindow(param);
myWindow.open();
return true;
};
//保存处理
Biz.prototype.onmysave = function () {
// isCreate 改为1后台刷新时不会调用刷新过程
this.dsMaster.state = {
isCreate: '1',
psType: this.getElement('.ps-type').combobox('getValue'),
qhCl: this.getElement('.qh-cl').combobox('getValue'),
ckCode: this.getElement('.ck-code').combobox('getValue'),
psCyc: 0,
}
this.dsMaster.save();
return true;
};
//创建事件处理
Biz.prototype.oncreate = function () {
//弹出是否确认提交对话框
if (!Store.confirm("是否执行创建操作? ")) {
return false;
}
// isCreate 改为1后台刷新时不会调用刷新过程
this.dsMaster.state = {
isCreate: '1',
psType: this.getElement('.ps-type').combobox('getValue'),
qhCl: this.getElement('.qh-cl').combobox('getValue'),
ckCode: this.getElement('.ck-code').combobox('getValue'),
psCyc: 0,
}
let sPsType = this.getElement('.ps-type').combobox('getValue');
let sCkCode = this.getElement('.ck-code').combobox('getValue');
let sQhCl = this.getElement('.qh-cl').combobox('getValue');
if ((sPsType != '2') && (sCkCode == '')){
Store.messager.err('请选择仓库!');
return false;
}
if (sCkCode == ''){
sCkCode = '<全部>';
}
//sGuid = Store.bizDao.getNewId('2005');
for (let i=0;i<this.dsMaster.rows.length;i++){
let masterRow = this.dsMaster.rows[i];
let sIsSelected = masterRow ? TypeUtil.toString(masterRow['IsSelected']) : '';
let sDstType = masterRow ? TypeUtil.toString(masterRow['DstType']) : '';
let sShOrgCode = masterRow ? TypeUtil.toString(masterRow['ShOrgCode']) : '';
let sZpSource = masterRow ? TypeUtil.toString(masterRow['ZpSource']) : '';
sGuid = masterRow ? TypeUtil.toString(masterRow['PsJobNo']) : '';
if (sIsSelected == "1"){
if ((rhtComm.GetOrgCode(sShOrgCode) != "1") && (sDstType == '1')){
Store.messager.err('不能对客户'+sShOrgCode+'进行直送操作!');
return false;
}
if ((sZpSource == "1") && (sDstType != '0')){
Store.messager.err('不能对人工录入的赠品进行直送或越库操作!');
return false;
}
//masterRow.setColumnValue('PsJobNo', sGuid);
}
}
self = this;
this.dsMaster.save(async function (isOk) {
if (isOk){
let ret = await Service.getSlideMenuData("actExecute","CreateJob", sGuid,sCkCode,sQhCl,"","");
if (ret.result !== 1) {
Store.messager.err(ret.message);
return false;
}
Store.messager.tip('任务已经开始执行,请到[处理要货结果查询]页面查看处理结果!');
}
self.opRouter('refresh');
});
return true;
};
//全选事件处理
Biz.prototype.onselall = function () {
for (let i=0;i<this.dsMaster.rows.length;i++){
let masterRow = this.dsMaster.rows[i];
masterRow.setColumnValue('IsSelected', '1');
}
return true;
};
//全清事件处理
Biz.prototype.onselno = function () {
for (let i=0;i<this.dsMaster.rows.length;i++){
let masterRow = this.dsMaster.rows[i];
masterRow.setColumnValue('IsSelected', '0');
}
return true;
};
return Biz;
});