define(function (require, exports, module) { //引入业务类基类 let BaseBiz = require('apps/rht/base/rhtBiz'); let rhtComm = require('apps/rht/comm/rhtComm'); let service = require('./sku080206service'); let multiWindow = require("system/views/pages/singlewindow/singlewindow"); let Revert = require('./Revert'); let PreAbandon = require('./PreAbandon'); require('css!./pagePluAbandon.css'); let selectedTreeNode; let self; /** * 定义业务类对象 * @param vm 界面相关ViewModule */ function Biz(vm) { //继承第一步,构造继承 BaseBiz.call(this, vm); } //继承第二步,方法继承 inherits(Biz, BaseBiz); function btnPluClick() { //定义多选窗口界面 let param = { uiObjCode: '8001', pk: "PluCode", biz: self, funcCode: self.FuncCode, showCheckColumn: false, enablePager: true, callback: function (row) { $('#pluCode').textbox("setText", row.PluCode); } }; //new多选窗体 并打开 let myWindow = new multiWindow(param); myWindow.open(); }; /** * @description 点击组织选择按钮 */ function btnOrgClick() { //定义多选窗口界面 let param = { uiObjCode: '6209', pk: "EtpCode", biz: self, funcCode: self.FuncCode, showCheckColumn: false, enablePager: true, callback: function (row) { $('#supCode').textbox("setText", row.EtpCode); } }; //new多选窗体 并打开 let myWindow = new multiWindow(param); myWindow.open(); }; /** * @description 点击【刷新】按钮 */ function btnRefreshClick() { let pluCode = $('#pluCode').textbox("getText"); let supCode = $('#supCode').textbox("getText"); if(pluCode === '' && supCode === '') { if (!Store.confirm("不设置商品编码或供应商可能数据量过大,继续吗?")) { return false; } } $('#masterArea').datagrid('getPager').pagination('select', 1); }; function refresh(pageNumber, pageSize) { let pluCode = $('#pluCode').textbox("getText"); let supCode = $('#supCode').textbox("getText"); let pluStatus = $('#pluStatus').combobox("getValue"); let seasonStatus = $('#seasonStatus').combobox("getValue"); let qzts = $('#qzts').textbox("getText"); let where = 'IsActive=\'1\''; if(pluCode !== '') { where += ' and (PluCode=\'' + pluCode + '\' or PluName like \'%' + pluCode + '%\')'; } if(pluStatus == '') { where += ' and YwStatus<>\'0\''; }else { where += ' and YwStatus=\'' + pluStatus + '\''; } if(seasonStatus != '') { where += ' and IsSeason=\'1\' and IsNewPlu=\'' + seasonStatus + '\''; } //where += ' and rownum >' + (pageSize*(pageNumber-1)) + 'rownum<' + (pageSize*pageNumber+1); let ret = service.SkuGetDisUsePluData('', supCode, qzts, where, '', pageNumber, pageSize); if(ret.result != 1) { Store.messager.err('获取商品失败!' + ret.message); return false; } $('#masterArea').datagrid('loadData', ret.data); $('#detailArea').datagrid('loadData', []); }; /** * @description 主表单击事件 */ function masterRowClick(index, row) { let ywStatus = row.ywstatus; let ret = service.GetSkuPluEx(row.pluid); if(ret.result == 1) { $('#detailArea').datagrid('loadData', ret.data); } }; /** * @description 点击【预淘汰】按钮 */ function btnPreAbandonClick() { let selRows = $('#masterArea').datagrid('getChecked'); if(selRows.length < 1) { Store.messager.err('请勾选商品!'); return false; } for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; if(row.ywstatus != '1') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '不是正常状态,不能预淘汰!'); return false; } } let preAbandon = new PreAbandon('并预淘汰'); preAbandon.callback = function (status, disuseReason) { let ret; for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; ret = service.DisUseDeal(row.pluid, '2', status); if(ret.result != 1) { Store.messager.err('预淘汰' + row.plucode + '-' + row.pluname + '失败!' + ret.message); return false; } } btnRefreshClick(); } preAbandon.open(); }; /** * @description 点击【淘汰】按钮 */ function btnAbandonClick() { let selRows = $('#masterArea').datagrid('getChecked'); if(selRows.length < 1) { Store.messager.err('请勾选商品!'); return false; } for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; if(row.ywstatus != '2') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '不是预淘汰状态,不能淘汰!'); return false; } } if (!Store.confirm("您确定要淘汰吗?")) { return false; } let delDisUsePlu = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'SKU','Sku_DelDisUsePlu_Cnt','1'); let ret; for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; ret = service.DisUseDeal(row.pluid, '3', '000000'); if(ret.result != 1) { Store.messager.err('淘汰' + row.plucode + '-' + row.pluname + '失败!' + ret.message); return false; } if(delDisUsePlu == '1') { ret = service.DelDisUsePluCntAcc(row.pluid, 1); if(ret.result != 1) { Store.messager.err('自动删除该商品所在合同中商品明细出错!' + ret.message); return false; } } } btnRefreshClick(); }; /** * @description 点击【休眠】按钮 */ function btnSleepClick() { let selRows = $('#masterArea').datagrid('getChecked'); if(selRows.length < 1) { Store.messager.err('请勾选商品!'); return false; } for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; if(row.ywstatus == '3') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '已经淘汰,无法休眠!'); return false; } if(row.isseason != '1') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '不是季节性商品,无法休眠!'); return false; } if(row.isnewplu != '1') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '已经休眠!'); return false; } } if (!Store.confirm("您确定要休眠所选商品吗?")) { return false; } let ret; for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; ret = service.SkuSetPluStatus(row.pluid, row.plucode, '10', '11'); if(ret.result != 1) { Store.messager.err('休眠' + row.plucode + '-' + row.pluname + '失败!' + ret.message); return false; } } btnRefreshClick(); }; /** * @description 点击【恢复】按钮 */ function btnRevertClick() { let selRows = $('#masterArea').datagrid('getChecked'); if(selRows.length < 1) { Store.messager.err('请勾选商品!'); return false; } let revert = new Revert(); revert.callback = function (czType) { if(czType == '0') { // 淘汰商品恢复为正常 for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; if(row.ywstatus != '2' && row.ywstatus != '3') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '不是预淘汰或淘汰状态,不能恢复!'); return false; } } if (!Store.confirm("您确定要恢复为正常吗?")) { return false; } let ret; for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; ret = service.DisUseDeal(row.pluid, '1', '111111'); if(ret.result != 1) { Store.messager.err('恢复' + row.plucode + '-' + row.pluname + '失败!' + ret.message); return false; } ret = service.UDisReason(row.pluid, ''); if(ret.result != 1) { Store.messager.err('恢复' + row.plucode + '-' + row.pluname + '失败!' + ret.message); return false; } } btnRefreshClick(); }else { // 休眠商品恢复为在季 for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; if(row.ywstatus == '3') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '已经淘汰,无法设置为在季!'); return false; } if(row.isseason != '1') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '不是季节性商品,无法设置为在季!'); return false; } if(row.isnewplu != '0') { Store.messager.err('商品' + row.plucode + '-' + row.pluname + '已经在季!'); return false; } } if (!Store.confirm("您确定要唤醒所选商品吗?")) { return false; } let ret; for(let i = 0; i < selRows.length; i++) { let row = selRows[i]; ret = service.SkuSetPluStatus(row.pluid, row.plucode, '11', '10'); if(ret.result != 1) { Store.messager.err('唤醒' + row.plucode + '-' + row.pluname + '失败!' + ret.message); return false; } } btnRefreshClick(); } }; revert.open(); }; /** * @description 初始化完毕 */ Biz.prototype.initCompleted = function () { $('#btnRefresh').linkbutton(); $('#btnPreAbandon').linkbutton(); $('#btnAbandon').linkbutton(); $('#btnSleep').linkbutton(); $('#btnRevert').linkbutton(); $('#pluCode').textbox(); $('#btnPlu').linkbutton(); $('#supCode').textbox(); $('#btnOrg').linkbutton(); $('#pluStatus').combobox(); $('#seasonStatus').combobox(); $('#qzts').numberbox(); $('#masterArea').datagrid({ columns:[[ {field:'sel',checkbox: true,width:100}, {field:'pluid',title:'商品ID',hidden:true, width:100}, {field:'plucode',title:'商品编码',width:100}, {field:'pluname',title:'商品名称',width:100}, {field:'unit',title:'单位',width:100}, {field:'spec',title:'规格',width:100}, {field:'hjprice',title:'含税进价',width:100}, {field:'wjprice',title:'无税进价',width:100}, {field:'price',title:'建议零售价',width:100}, {field:'hyprice',title:'建议会员价',width:100}, {field:'xscount',title:'销售数量',width:100}, {field:'hxtotal',title:'销售金额',width:100}, {field:'jthcount',title:'进退货数量',width:100}, {field:'jthcost',title:'进退货金额',width:100}, {field:'kccount',title:'库存数量',width:100}, {field:'kccost',title:'库存金额',width:100}, {field:'qzdays',title:'前置天数',width:100}, {field:'ywstatus',title:'商品状态',width:100, formatter: function(value,row,index){ if(row.ywstatus == '1') { return '正常'; }else if(row.ywstatus == '2') { return '预淘汰'; }else if(row.ywstatus == '3') { return '淘汰'; }else { return ''; } } }, {field:'disusereason',title:'淘汰原因',width:100}, {field:'isnewplu',title:'是否在季',width:100, formatter: function(value,row,index){ if(row.isnewplu == '0') { return '否'; }else if(row.isnewplu == '1') { return '是'; }else { return ''; } } }, {field:'barcode',title:'条形码',width:100} ]], pagination:true, pagePosition:'bottom', pageSize:50, checkOnSelect:false, selectOnCheck:false, striped:true, ctrlSelect:true, onSelect:masterRowClick }); $('#detailArea').datagrid({ columns:[[ {field:'orgcode',title:'组织',width:100, formatter: function(value,row,index){ return row.orgcode + '-' + row.orgname; } }, {field:'depcode',title:'主业务部门',width:100, formatter: function(value,row,index){ return row.depcode + '-' + row.depname; } }, {field:'jhcycle',title:'进货周期',width:100}, {field:'pscycle',title:'配送周期',width:100}, {field:'aqdays',title:'安全天数',width:100}, {field:'mincount',title:'最低库存',width:100}, {field:'maxcount',title:'最高库存',width:100}, {field:'pfprice',title:'批发价',width:100}, {field:'hyprice',title:'会员价',width:100}, {field:'price',title:'售价',width:100}, {field:'isjh',title:'允许进货',width:100}, {field:'isth',title:'允许退货',width:100}, {field:'isps',title:'允许配送',width:100}, {field:'isjs',title:'允许结算',width:100}, {field:'issale',title:'允许销售',width:100}, {field:'issaleth',title:'允许销售退货',width:100} ]], // pagination:true, // pagePosition:'bottom', // pageSize:50, // showRefresh: false, striped:true, ctrlSelect:true }); self = this; // 对页面中的元素进行事件绑定 let btnPlu = document.getElementById('btnPlu'); btnPlu.addEventListener('click', btnPluClick, false); let btnOrg = document.getElementById('btnOrg'); btnOrg.addEventListener('click', btnOrgClick, false); let btnRefresh = document.getElementById('btnRefresh'); btnRefresh.addEventListener('click', btnRefreshClick, false); let btnPreAbandon = document.getElementById('btnPreAbandon'); btnPreAbandon.addEventListener('click', btnPreAbandonClick, false); let btnAbandon = document.getElementById('btnAbandon'); btnAbandon.addEventListener('click', btnAbandonClick, false); let btnSleep = document.getElementById('btnSleep'); btnSleep.addEventListener('click', btnSleepClick, false); let btnRevert = document.getElementById('btnRevert'); btnRevert.addEventListener('click', btnRevertClick, false); $('#btnAdd').linkbutton('disable'); var pg = $("#masterArea").datagrid("getPager"); if(pg) { $(pg).pagination({ showRefresh: false, onSelectPage:function(pageNumber,pageSize){ refresh(pageNumber===0 ? 1 : pageNumber,pageSize); } }); } }; return Biz; });