/// Ext.namespace('DsTruck'); var C_cargoinfo_id = ""; var HTHCount = 0; DsTruck.WorkFlowEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.WorkFlowEdit.superclass.constructor.call(this); }; Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //second "q+": Math.floor((this.getMonth() + 3) / 3), //quarter "S": this.getMilliseconds() //millisecond } if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); return format; } var xhr = new XMLHttpRequest(); var currdate = new Date(); if (!xhr) { //...其他生成xmlhttprequest方法 } xhr.open("HEAD", location.href, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var datestr = xhr.getResponseHeader("Date"); currdate = new Date(datestr); // alert(currdate.format('yyyy-MM-dd')); } } xhr.send(null); Ext.extend(DsTruck.WorkFlowEdit, Ext.Panel, { parentWin: null, OpStatus: 'add', StoreList: null, editRecord: null, // parentfunction: null, _First: true, initUIComponents: function () { this.StepDel = []; //#region 枚举参照相关(编辑form) this.storeWorkFlowType = Ext.create('DsExt.ux.RefTableStore', { model: 'WorkFlowTypemb', proxy: { url: '/CommMng/BasicDataRef/GetTYPENO' } }); this.storeWorkFlowType.load({}); this.comboxWorkFlowType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '工作流类型', forceSelection: true, store: this.storeWorkFlowType, valueField: 'TYPENO', displayField: 'NAME', name: 'TYPE', flex: 2 }); this.storeCompany = Ext.create('DsExt.ux.RefTableStore', { model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' } }); this.storeCompany.load({ params: { condition: ""} }); this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '分公司', store: this.storeCompany, name: 'COMPANYID', valueField: 'gid', displayField: 'name' }); /* this.storeDEPT = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.DEPTRefModel', proxy: { url: '/CommMng/BasicDataRef/GetDeptList' } }); this.storeDEPT.load({ params: { condition: ""} }); this.comboxDEPT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '部门', store: this.storeDEPT, name: 'DEPTGID', id: "DEPTGID", valueField: 'GID', displayField: 'DeptName' });*/ //数据集 Ext.define('DeductibleMd', { extend: 'Ext.data.Model', fields: [ { name: 'ISLAST', type: 'string' }, { name: 'ISLAST_REF', type: 'string' } ] }); var IsOpenData = [{ "ISLAST": "False", "ISLAST_REF": "否" }, { "ISLAST": "True", "ISLAST_REF": "是" }]; this.storeIsOpenType = Ext.create('Ext.data.Store', { model: 'DeductibleMd', data: IsOpenData }); this.comboxIsLast = Ext.create('DsExt.ux.RefEnumCombox', { //fieldLabel: '是否最终审核', forceSelection: true, store: this.storeIsOpenType, name: 'ISLAST', valueField: 'ISLAST', displayField: 'ISLAST_REF' }); this.storeUser = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeUser.load({ params: { condition: " 1=1 " } }); this.comboxCreator = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '审核人', forceSelection: true, store: this.storeUser, name: 'AUDITOR', id: "AUDITOR", matchFieldWidth: false, valueField: 'GID', displayField: 'CodeAndName', allowBlank: false }); //#endregion //#region 编辑form:formEdit this.formEdit = Ext.widget('form', { // layout: "border", region: 'center', frame: true, bodyPadding: 5, trackResetOnLoad: true, //不加的话load之后isdirty即变为true fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' //,split:true }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{//container_1 xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'GID', name: 'GID', flex: 0, hidden: true, margins: '0' },{ fieldLabel: '步骤代码', // allowBlank: false, //readOnly: true, name: 'NAME' }, { fieldLabel: '步骤名称', // allowBlank: false, name: 'DESCRIPTION' }, this.comboxWorkFlowType /**//*, { fieldLabel: '时间戳', name: 'TimeMark', flex: 0, hidden: true, margins: '0' }*/ ] }, //container_1 end { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: '建立人', readOnly: true, id: "CREATEUSER_REF", name: 'CREATEUSER_REF' }, { fieldLabel: 'CREATEUSER', hidden: true, id: "CREATEUSER", name: 'CREATEUSER' }, { fieldLabel: '建立时间', readOnly: true, id: "CREATETIME", name: 'CREATETIME' }, { fieldLabel: '修改人', readOnly: true, id: "MODIFIEDUSER_REF", name: 'MODIFIEDUSER_REF' }, { fieldLabel: 'MODIFIEDUSER', hidden: true, id: "MODIFIEDUSER", name: 'MODIFIEDUSER' }, { fieldLabel: '修改时间', readOnly: true, id: "MODIFIEDTIME", name: 'MODIFIEDTIME' } //this.comboxCountry, //this.comboxport ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ this.comboxCompany, //this.comboxDEPT, { xtype: 'checkbox', flex: 1, fieldLabel: '默认工作流', name: 'ISDEFAULT' }, //this.comboxDEPT, ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'checkbox', flex: 1, inputValue: true, fieldLabel: '是否条件审核', name: 'ISCONDITION' }, { fieldLabel: '顺序号', //'免箱期', name: 'SORTNO', value: 0, regex: /^(0|[1-9][0-9]*)$/, regexText: '请输入正确的数值!' }, { fieldLabel: '条件判断SQL语句', labelWidth: 100, flex: 4, name: 'CONDITIONSQL', height: 40, xtype: "textarea" }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [/*this.comboxTransactionMethod, this.comboxPaymentMethods, this.comboxFStatus*/] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [/*this.comboxRCVMode,this.comboxOP,{ fieldLabel: '备注1', name: 'remark' }*/] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [] } ] } ] }); //#endregion //#region 工作流程表格 formWorkFlowStep this.storeStep = Ext.create('Ext.data.Store', { model: 'WorkFlowStepmb', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/OA/WorkFlow/GetStepList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.cellEditingStep = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.StepCB = Ext.create('Ext.selection.CheckboxModel'); this.formWorkFlowStep = new Ext.grid.GridPanel({ store: this.storeStep, enableHdMenu: false, region: 'center', trackResetOnLoad: true, title: '步骤信息', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingStep], selModel: this.StepCB, selType: 'cellmodel', tbar: [{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddStepClick(button, event); }, scope: this }, { text: '复制增加明细', tooltip: '复制增加选中的一条明细', iconCls: "btncopy", handler: function (button, event) { this.onCopyStepClick(button, event); }, scope: this }, '-', { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelStepClick(button, event); }, scope: this }, '-'], columns: [ { dataIndex: 'GID', header: 'GID', hidden: true, width: 80 }, { dataIndex: 'NAME', header: '步骤名称', width: 150, editor: { xtype: 'textfield', selectOnFocus: true } }, { dataIndex: 'DESCRIPTION', hidden: true, header: '步骤名称', width: 80, editor: { xtype: 'textfield', selectOnFocus: true } }, { dataIndex: 'WORKFLOWID', header: '工作流代码', width: 80, hidden: true }, { dataIndex: 'GROUPID', header: '步骤组ID', width: 80, editor: { xtype: 'numberfield', allowDecimals: false, minValue: 0, selectOnFocus: true } }, { dataIndex: 'STEPNO', header: '步骤组内步骤', width: 80, editor: { xtype: 'numberfield', allowDecimals: false, minValue: 1, selectOnFocus: true } }, { dataIndex: 'NEXTGROUP', header: '下一步骤组', width: 80, editor: { xtype: 'numberfield', allowDecimals: false, minValue: 0, selectOnFocus: true } }, { dataIndex: 'AUDITOR', header: '审核人', width: 80, renderer: function (value, p, record) { if (value == null || value == '') return ''; else return record.data.AUDITOR_REF; }, editor: this.comboxCreator }, { dataIndex: 'ISLAST', header: '最终审核', width: 80, renderer: function (value, p, record) { if (value == null || value == '') return ''; else return record.data.ISLAST_REF; }, editor: this.comboxIsLast }, { dataIndex: 'CREATEUSER_REF', header: '建立人', width: 80 }, { dataIndex: 'CREATEUSER', header: 'CREATEUSER', hidden: true, width: 80 }, { dataIndex: 'CREATETIME', header: '建立时间', width: 80 }, { dataIndex: 'MODIFIEDUSER_REF', header: '修改人', width: 80 }, { dataIndex: 'MODIFIEDUSER', header: 'MODIFIEDUSER', hidden: true, width: 80 }, { dataIndex: 'MODIFIEDTIME', header: '修改时间', width: 80 }, { dataIndex: 'REMARK', header: '备注', width: 80, editor: { xtype: 'textfield', selectOnFocus: true } } ] }); //#endregion //#region 管理范围表格 (待选择人员) this.storeUserState = Ext.create('Ext.data.Store', { model: 'WorkFlowUserPathmb', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/OA/WorkFlow/GetUserStateList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.cellEditingUserState = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.USCB = Ext.create('Ext.selection.CheckboxModel'); this.GridUserState = new Ext.grid.GridPanel({ store: this.storeUserState, enableHdMenu: false, region: 'center', trackResetOnLoad: true, //title: '步骤信息', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingUserState], selModel: this.USCB, selType: 'cellmodel', tbar: [{ text: '加入受管辖范围', tooltip: '将选中的人员加入右边的受管辖范围', iconCls: "btnadddetail", handler: function (button, event) { this.onAddUserPathClick(button, event); }, scope: this }], columns: [ { sortable: true, hidden: true, dataIndex: 'USERID', header: 'USERID', width: 80 }, { sortable: true, dataIndex: 'DEPTNAME', header: '部门', width: 80 }, { sortable: true, dataIndex: 'USERNAME', header: '用户名', width: 80 }, { sortable: true, dataIndex: 'WORKFLOWNAME', header: '目前工作流程', width: 80 } ] }); //#endregion //#region 管理范围 现状 表格 this.storeUserPath = Ext.create('Ext.data.Store', { model: 'WorkFlowUserPathmb', remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/OA/WorkFlow/GetUserPathList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.cellEditingUserPath = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.UPCB = Ext.create('Ext.selection.CheckboxModel'); this.GridUserPath = new Ext.grid.GridPanel({ store: this.storeUserPath, enableHdMenu: false, region: 'center', trackResetOnLoad: true, //title: '步骤信息', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingUserPath], selModel: this.UPCB, selType: 'cellmodel', tbar: [{ text: '排除出管辖范围', tooltip: '将选中的人员排除出管辖范围', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelUserPathClick(button, event); }, scope: this }], columns: [ { sortable: true, hidden: true, dataIndex: 'USERID', header: 'USERID', width: 80 }, { sortable: true, dataIndex: 'USERNAME', header: '用户名', width: 80 }, { sortable: true, dataIndex: 'STATE', header: '受管理状态', width: 80 } ] }); //#endregion //#region 公共按钮Toolbar:panelBtn this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { // id: "saveandclose", text: "保存", handler: function (button, event) { this.Save('0'); }, scope: this }, { // id: "saveandclose", text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, { id: 'btnECopyNew', text: "复制新建", handler: function (button, event) { var basicForm = this.formEdit.getForm(); this.opStatus = 'add'; // basicForm.findField('GID').setDisabled(false); var field = basicForm.findField('GID'); var GID = NewGuid(); field.setValue(GID); var field = basicForm.findField('NAME'); field.setValue(''); // basicForm.findField('GID').setDisabled(true); for (var j = 0; j < this.storeStep.getCount() ; j += 1) { var memberbody = this.storeStep.getAt(j); memberbody.set("WORKFLOWID",''); memberbody.set("GID", NewGuid()); // memberbody.commit(); }; }, scope: this }, '-', { // id: "saveandclose", text: "关闭", handler: function (button, event) { window.close(); }, scope: this }, '-', { // id: "saveandclose", //text: "打印", //handler: function (button, event) { // this.Print(); //}, //scope: this } ] }); //end 按钮Toolbar //#endregion //#region 布局 /* 3 */ this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 180, items: [this.panelBtn, this.formEdit] }); Ext.apply(this, { items: [this.panelTop, this.MainTab] }); Ext.apply(this, { items: [this.panelTop, this.panelFee, this.panelPayBody] }); this.PanelUP1 = new Ext.Panel({ title: "待选人员", layout: "border", region: 'west', margin: '0 0', width: 330, split: true, items: [this.GridUserState] }); this.PanelUP2 = new Ext.Panel({ title: "目前管辖的人员", layout: "border", region: 'center', margin: '0 0', width: 330, split: true, items: [this.GridUserPath] }); this.page_1 = new Ext.Panel({ title: "工作流信息", layout: "border", region: "center", height: 500, items: [this.formWorkFlowStep] }); this.page_2 = new Ext.Panel({ title: "管理范围(提交至此流程的人员列表)", layout: "border", region: "center", height: 500, items: [this.PanelUP1, this.PanelUP2] }); this.MainTab = new Ext.tab.Panel({ layout: "border", region: "center", items: [ this.page_1 , this.page_2 //, this.page_3 //, this.page_4 ] }) Ext.apply(this, { items: [this.panelTop, this.MainTab] }); //#endregion parentWin = window.parent.opener; this.InitData(); //集中绑定编辑后事件 this.cellEditingStep.on('beforeedit', function (editor, e) { return this.StepBeforeEdit(editor, e); }, this); this.cellEditingStep.on('edit', function (editor, e, eOpts) { this.StepAfterEdit(editor, e, eOpts); }, this); }, //end initUIComponents //#region 增加/复制增加 workflow_step onAddStepClick: function (button, event) { var record = Ext.create('WorkFlowStepmb', { 'GID': NewGuid(), 'WORKFLOWID': '', 'NAME': '', 'DESCRIPTION': '', 'AUDITOR': '', 'CREATEUSER': USERID, 'CREATEUSER_REF': SHOWNAME, 'CREATETIME': currdate.format('yyyy-MM-dd hh:mm:ss'), 'MODIFIEDUSER': USERID, 'MODIFIEDUSER_REF': SHOWNAME, 'MODIFIEDTIME': currdate.format('yyyy-MM-dd hh:mm:ss'), 'STEPNO': '', 'ISLAST': '', 'GROUPID': '', 'NEXTGROUP': '' }); this.storeStep.add(record); var n = this.storeStep.getCount(); this.cellEditingStep.startEditByPosition({ row: n - 1, column: 2 }); //aftereditform(); }, onCopyStepClick: function (button, event) { var selectedRecords = this.formWorkFlowStep.selModel.getSelection(); if (selectedRecords.length > 0) { record = selectedRecords[0]; //storeStep var new_record = Ext.create('WorkFlowStepmb', { 'GID': NewGuid(), 'WORKFLOWID': '', 'NAME': record.get("NAME"), 'DESCRIPTION': record.get("DESCRIPTION"), 'AUDITOR': '', 'CREATEUSER': USERID, 'CREATEUSER_REF': SHOWNAME, 'CREATETIME': currdate.format('yyyy-MM-dd hh:mm:ss'), 'MODIFIEDUSER': USERID, 'MODIFIEDUSER_REF': SHOWNAME, 'MODIFIEDTIME': currdate.format('yyyy-MM-dd hh:mm:ss'), 'STEPNO': record.get("STEPNO"), 'ISLAST': record.get("ISLAST"), 'ISLAST_REF': record.get("ISLAST_REF"), 'GROUPID': record.get("GROUPID"), 'NEXTGROUP': record.get("NEXTGROUP") }); this.storeStep.add(new_record); var n = this.storeStep.getCount(); this.cellEditingStep.startEditByPosition({ row: n - 1, column: 8 }); } }, //#endregion onDelStepClick: function (button, event) { var selectedRecords = this.formWorkFlowStep.selModel.getSelection(); Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) { if (btn == 'yes') { for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.GID != "" || rec.GID != "*") //如果是新增但没有保存的数据,没有必要提交到后台 { var canedit = true; Ext.Ajax.request({// waitMsg: '正在查询待审核的业务...', url: '/CommMng/WorkFLow/GetCanChange', async: false, params: { GID: rec.GID }, callback: function (options, success, response) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { canedit = true; //return true; } else { canedit = false; //return false; } }, scope: this }); //request over if (canedit == false) { var IsOpenrecords = DsStoreQueryBy(this.storeUser, 'GID', rec.GID); if (IsOpenrecords.getCount() > 0) { var IsOpendata = IsOpenrecords.getAt(0).data; var Auditor = IsOpendata.UserName; } else { var Auditor = ""; } alert("工作流步骤:" + rec.NAME + " 审核人:" + Auditor + " 的工作流步骤仍包含即将审完的流程,请将其完成"); } else { this.StepDel.push(rec); this.storeStep.remove(selectedRecords[i]); } } } } }, this); //aftereditform(); }, onAddUserPathClick: function (button, event) { var selectedRecords = this.GridUserState.selModel.getSelection(); Ext.MessageBox.confirm('提示', '确定将这些人员纳入管辖范围吗?已被同类型的其他工作流程管辖的选定人员将改为受此流程管辖', function (btn) { if (btn == 'yes') { var UserList = ""; var CanEdit = true; var WORKFLOWTYPENO = this.editRecord.get('TYPE'); var WORKFLOWID = this.editRecord.get('GID'); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i].data; if (UserList == "") { UserList = "'" + rec.USERID + "'"; } else { UserList = UserList + ",'" + rec.USERID + "'"; } // //Ext.Ajax.request({// // waitMsg: '正在查询待审核的业务...', // url: '/CommMng/WorkFLow/GetCanChange_UserPath', // async: false, // params: { USERID: rec.USERID, // TYPENO: WORKFLOWTYPENO, // NewWorkFlowID: WORKFLOWID // }, // callback: function (options, success, response) { // var jsonresult = Ext.JSON.decode(response.responseText); // if (jsonresult.Success) { // if (UserList == "") { // UserList = "'" + rec.USERID + "'"; // } else { // UserList = UserList + ",'" + rec.USERID + "'"; // } // } else { // alert(jsonresult.Message); // CanEdit = false; // } // }, // scope: this //}); //request over // } if (CanEdit == true) { Ext.Ajax.request({// waitMsg: '正在查询待审核的业务...', url: '/OA/WorkFLow/SaveUserPath', async: false, params: { WORKFLOWTYPENO: WORKFLOWTYPENO, WORKFLOWID: WORKFLOWID, USERIDList: UserList }, callback: function (options, success, response) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { alert("添加成功"); } else { alert("添加失败" + jsonresult.Message); } }, scope: this }); //request over this.storeUserState.load({ params: { WorkFlowID: WORKFLOWID} }); this.storeUserPath.load({ params: { WorkFlowID: WORKFLOWID} }); } } }, this); //aftereditform(); }, onDelUserPathClick: function (button, event) { var selectedRecords = this.GridUserPath.selModel.getSelection(); Ext.MessageBox.confirm('提示', '确定将这些人员排除出管辖范围吗?他们将无法提交这类业务,请及时为他们设定新的工作流', function (btn) { if (btn == 'yes') { var UserList = ""; var CanEdit = true; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i].data; var WORKFLOWTYPENO = this.editRecord.get('TYPE'); var WORKFLOWID = this.editRecord.get('GID'); Ext.Ajax.request({// waitMsg: '正在查询待审核的业务...', url: '/CommMng/WorkFLow/GetCanChange_UserPath', async: false, params: { USERID: rec.USERID, TYPENO: WORKFLOWTYPENO, NewWorkFlowID: "" }, callback: function (options, success, response) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { if (UserList == "") { UserList = "'" + rec.USERID + "'"; } else { UserList = UserList + ",'" + rec.USERID + "'"; } } else { alert(jsonresult.Message); CanEdit = false; } }, scope: this }); //request over /* if (UserList == "") { UserList = "'" + rec.USERID + "'"; } else { UserList = UserList + ",'" + rec.USERID + "'"; }*/ } //var WORKFLOWTYPENO = this.editRecord.get('TYPE'); //var WORKFLOWID = this.editRecord.get('GID'); if (CanEdit == true) { Ext.Ajax.request({// waitMsg: '正在查询待审核的业务...', url: '/OA/WorkFLow/DelUserPath', async: false, params: { WORKFLOWTYPENO: WORKFLOWTYPENO, WORKFLOWID: WORKFLOWID, USERIDList: UserList }, callback: function (options, success, response) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { alert("删除成功"); } else { alert("删除失败" + jsonresult.Message); } }, scope: this }); //request over this.storeUserState.load({ params: { WorkFlowID: WORKFLOWID} }); this.storeUserPath.load({ params: { WorkFlowID: WORKFLOWID} }); } } }, this); //aftereditform(); }, StepBeforeEdit: function (editor, e, eOpts) { //return false; var GID = e.record.get('GID'); var canedit = true; if (e.record.get('WORKFLOWID') == "") { return true; //新增还未保存的可以随便修改 } this.WorkFlow_Using_Count = 0; if (e.field == 'STEPNO' || e.field == 'ISLAST' || e.field == 'GROUPID' || e.field == 'NEXTGROUP') { Ext.Ajax.request({// waitMsg: '正在查询待审核的业务...', url: '/CommMng/WorkFLow/GetCanChange', async: false, params: { GID: GID }, callback: function (options, success, response) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { canedit = true; //return true; } else { canedit = false; alert("目前还存在必须审核此步骤的业务,或者修改此步骤会导致业务审核通过,不能修改"); } }, scope: this }); //request over } return canedit; }, StepAfterEdit: function (editor, e, eOpts) { if (e.field == 'ISLAST') { var IsOpenrecords = DsStoreQueryBy(this.storeIsOpenType, 'ISLAST', e.value); if (IsOpenrecords.getCount() > 0) { var IsOpendata = IsOpenrecords.getAt(0).data; e.record.set('ISLAST_REF', IsOpendata.ISLAST_REF); } else { e.record.set('ISLAST_REF', ''); } } if (e.field == 'AUDITOR') { var IsOpenrecords = DsStoreQueryBy(this.storeUser, 'GID', e.value); if (IsOpenrecords.getCount() > 0) { var IsOpendata = IsOpenrecords.getAt(0).data; e.record.set('AUDITOR_REF', IsOpendata.UserName); } else { e.record.set('AUDITOR_REF', ''); } } e.record.set('MODIFIEDUSER', USERID); e.record.set('MODIFIEDTIME', currdate.format('yyyy-MM-dd hh:mm:ss')); }, /////////////明细表<<<>>>的相关方法 parentfunction: function (button, event) { var ret1 = window.parent.opener.OprationSwap(); // alert(this.First); ret1[3](); }, InitData: function () { this.opStatus = 'add'; var condition = ''; if (parentWin) { var ret = parentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; // this.parentfunction = ret[3]; } if (this.opStatus == 'edit') condition = " GID='" + this.editRecord.get('GID') + "'"; else { } this.LoadData(this.opStatus, condition); }, //end InitData //载入数据 LoadData: function (opstatus, condition) { this.opStatus = opstatus; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/OA/WorkFlow/GetWorkFlowData', params: { handle: opstatus, condition: condition }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; /* Ext.getCmp("CREATEUSER").setValue(USERID); Ext.getCmp("CREATEUSER_REF").setValue(usercode); Ext.getCmp("CREATETIME").setValue(currdate.format('yyyy-MM-dd hh:mm:ss')); Ext.getCmp("MODIFIEDUSER").setValue(USERID); Ext.getCmp("MODIFIEDUSER_REF").setValue(usercode); Ext.getCmp("MODIFIEDTIME").setValue(currdate.format('yyyy-MM-dd hh:mm:ss')) */ if (this.opStatus == 'add') { if (data.GID == "") { data.GID = NewGuid() }; if (data.CREATEUSER == "") { data.CREATEUSER = USERID }; if (data.CREATEUSER_REF == "") { data.CREATEUSER_REF = usercode }; if (data.CREATETIME == "") { data.CREATETIME = currdate.format('yyyy-MM-dd hh:mm:ss') }; if (data.MODIFIEDUSER == "") { data.CREATEUSER = USERID }; if (data.MODIFIEDUSER_REF == "") { data.CREATEUSER_REF = usercode }; if (data.MODIFIEDTIME == "") { data.CREATETIME = currdate.format('yyyy-MM-dd hh:mm:ss') }; if (data.COMPANYID == "") { data.COMPANYID = COMPANYID }; } if (data.ISDEFAULT == '1') { data.ISDEFAULT = '1'; } else { data.ISDEFAULT = '0' }; this.formEdit.getForm().setValues(data); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); //request over if (this.opStatus == 'edit') { this.storeStep.load({ params: { WorkFlowID: this.editRecord.get('GID')} }); this.storeUserState.load({ params: { WorkFlowID: this.editRecord.get('GID')} }); this.storeUserPath.load({ params: { WorkFlowID: this.editRecord.get('GID')} }); } else { } }, // end LoadDate checkedit: function () { }, Save: function (type) { /* var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } if (!validateEditorGridPanel(this.gridListReceipt)) { return; }*/ var data = this.formEdit.getForm().getValues(); var GID = data.GID; data.MODIFIEDUSER = USERID; data.MODIFIEDTIME = currdate.format('yyyy-MM-dd hh:mm:ss'); var Stepdatas = []; for (var i = 0; i < this.storeStep.getCount(); i += 1) { var member = this.storeStep.getAt(i); Stepdatas.push(member); } //商品明细 var StepBody = ConvertRecordsToJson(Stepdatas); var StepDelBody = ConvertRecordsToJsonAll(this.StepDel); //ConvertRecordsToJsonAll(this.AppstateDel); data.ISDEFAULT = this.formEdit.getForm().findField('ISDEFAULT').getValue() ? 1 : 0; var _this = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/OA/WorkFlow/SaveStep', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), StepBody: StepBody, StepDel: StepDelBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeStep.commitChanges(); var returnData = jsonresult.Data; if (returnData.ISDEFALUT == 'True') { returnData.ISDEFALUT = '1'; } else { returnData.ISDEFALUT = '0' }; this.formEdit.getForm().setValues(returnData); if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.add(returnData); this.editRecord = arrNewRecords[0]; // alert(editRecord.get('ContractNo')); } else if (this.opStatus == 'edit') { var editp = Ext.create('WorkFlowmb', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; //alert(name + ' -- ' + editp.get(name)); if (name != 'GID') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } if (type == '0') { this.opStatus = 'edit'; this.storeStep.load({ params: { WorkFlowID: this.editRecord.get('GID')} }); } else if (type == '1') {//保存并关闭 window.close(); } } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } //alert('03'); } }); } , //end save Print: function () { var basicForm = this.formEdit.getForm(); var ContractNo = this.editRecord.get('ContractNo') if (ContractNo == '*' || ContractNo == '') { Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var printType = 'XXH_CW_YS'; // var sql1 = "SET LANGUAGE 'us_english' SELECT price,weight,6.1667 as exchange FROM import_cargo WHERE contractno = '" + ContractNo + "' "; var sql2 = ""; ; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } });