define(function (require, exports, module) { let BaseBiz = require('apps/rht/base/rhtBiz'); let rhtComm = require('apps/rht/comm/rhtComm'); let Service = require('./sys0223service'); let multiWindow = require("system/views/pages/multiwindowdiv/multiwindowdiv"); /** * 控制按钮的可用 * @param opCode 按钮编码 * @return [description] */ function Biz(vm) { //继承第一步,构造继承 BaseBiz.call(this, vm); } //继承第二步,方法继承 inherits(Biz, BaseBiz); //增加右键菜单按钮并控制状态 Biz.prototype.getContextMenus = function (ds, source) { let menus = this.super("getContextMenus", ds, source) let edit = ds.getEditable(); let curRow = this.dsMaster.currentRow; //仅在明细表点击右键时 本按钮可用 menus.push({ text: '批量增加明细', opCode: 'plAdd', disabled: (!(ds.name == "dsDetail")) || (curRow == 0) || (edit) }); menus.push({ text: '批量删除明细', opCode: 'plDel', disabled: (!(ds.name == "dsDetail")) || (curRow == 0) || (edit) }); return menus; }; //定义按钮事件 Biz.prototype.doOp = function (opCode) { let self = this; let curRow = this.dsMaster.currentRow; let UserID = curRow ? TypeUtil.toString(curRow['UserID']) : ''; if (UserID == '') return false; if (opCode == 'plDel') { let ds = self.dsDetail; this.onedtplDel(self, ds, UserID); }; if (opCode == 'plAdd') { let ret = Service.getSlideMenuData("USaveOrg", "GetRoleCode", UserID, "", "", "", ""); let RoleCode=''; if (ret.result == 1) { if (ret.data != null) { RoleCode=ret.data.RoleCode; } } //从待选择窗口剔除当前明细表已有的数据 let exists = new Array(); for (let j = 0; j < self.dsDetail.rows.length; j++) { exists.push({ 'OrgCode': self.dsDetail.rows[j].OrgCode, 'DepCode': self.dsDetail.rows[j].DepCode }); } //定义多选窗口界面 let param={ exists: exists, uiObjCode: '5522', biz: self, enablePager: true, pk: "OrgCode,DepCode", fixQuery: { 'IsActive': '1', 'IsYw': '1' }, showCheckColumn: true, funcCode: self.FuncCode, ds: self.dsDetail, itreator: function (row) { let isOK = self.addrows(row,UserID,RoleCode); if (isOK != true) { //加上这个代码 就能将商品触发的校验报错展示,但本次的提示不展示(不知道这啥情况,暂时这样用吧) dbody.currentRow.setColumnError("OrgCode","批量导入数据失败,校验失败!"); return false; } return true; } }; //new多选窗体 并打开 let myWindow = new multiWindow(param); myWindow.open(); }; }; //批量增加每行后触发操作 Biz.prototype.addrows = function (row,UserID,RoleCode) { let ds = this.dsDetail; if (row != null) { let ret = Service.getSlideMenuData("USaveOrg", "Adddata", UserID, row.OrgCode, row.OrgClass, row.DepCode, RoleCode); if (ret.result != 1) { Store.messager.tip(row.OrgCode+"门店"+row.DepCode+"部门,增加组织部门权限数据失败!"+ret.messager); return false; }; /* let dr = ds.addRow(); if ((!dr.setColumnText('UserID', UserID)) || (!dr.setColumnText('OrgCode', row.OrgCode)) || (!dr.setColumnText('OrgStyle', row.OrgClass)) || (!dr.setColumnText('DepCode', row.DepCode)) || (!dr.setColumnText('RoleCode', RoleCode))){ return false; } ds.save(); */ }; return true; }; //按钮事件处理 Biz.prototype.onedtplDel = function (biz, ds, UserID) { Store.messager.confirm("确认要删除选中的组织部门权限数据吗?",function(isOK){ if(!isOK){ return false; } else{ let isel=0; //定义JSON,将选中数据打包传后台处理 let data = []; for (let i = ds.rows.length - 1; i > -1; i--) { let row = ds.rows[i]; if (row['$is_sel'] !== undefined) { if (row['$is_sel'] == true) { data.push( { OrgCode:row.OrgCode, DepCode:row.DepCode } ); //row.delete(); isel=isel+1; }; }; }; if (isel==0){ Store.messager.err('请选择需要删除的明细表数据。'); return false; }; let ret = Service.getSlideMenuData("USaveOrg", "Deldata", UserID, data, "", "", ""); if (ret.result == 1) { Store.messager.tip("删除选中的组织部门权限数据成功!"); rhtComm.MWriteOprLog(Store.logOn.orgCode,Store.logOn.userId,Store.logOn.userCode,Store.logOn.userName,'','','用户组织部门权限设置','批量删除选中的组织部门权限数据'); return true; } else { Store.messager.tip("删除选中的组织部门权限数据失败!"+ret.messager); return false; }; }; }); // return true; }; return Biz; });