You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

599 lines
21 KiB
JavaScript

12 months ago

Ext.namespace('DsTruck');
DsTruck.WorkFlowIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.WorkFlowIndex.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.WorkFlowIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.bodyDel = [];
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
idProperty: 'GID',
model: 'WorkFlowmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/OA/WorkFlow/GetWorkFlowList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "WorkFlow";
this.column = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'NAME',
header: '工作流名称',
width: 80
},
{
sortable: true,
dataIndex: 'DESCRIPTION',
header: '工作流显示名',
width: 80
},
{
sortable: true,
dataIndex: 'TYPE',
header: '类型序列号',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CREATEUSER',
header: 'CREATEUSER',
width: 80
},
{
sortable: true,
dataIndex: 'CREATEUSER_REF',
header: '建立人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '建立时间',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDUSER',
header: 'MODIFIEDUSER',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDUSER_REF',
header: '修改人',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: '修改时间',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'COMPANYID',
header: 'COMPANYID',
width: 80
},
{
sortable: true,
dataIndex: 'COMPANY_REF',
header: '分公司',
width: 80
}
];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.ProjectCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 50
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
trackResetOnLoad: true,
//height: 160,
title: '工作流类型明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing],
stateful: false,
selModel: this.ProjectCBModel,
selType: 'cellmodel',
columns: [new Ext.grid.RowNumberer()],
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column, 1);
//使用者id表名 中间column数组跳过一开始的几列
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
//#region formSearch
_this = this;
Ext.define('MsCompanysEntity', {
extend: 'Ext.data.Model',
idProperty: 'GID',
fields: [
{ name: 'GID', type: 'string' }, //GID
{name: 'CODENAME', type: 'string' }, //CODENAME
{name: 'NAME', type: 'string' }, //NAME
{name: 'FULLNAME', type: 'string' }, //FULLNAME
{name: 'ENNAME', type: 'string' }, //公司英文名称
{name: 'ADDRESS', type: 'string' }, //ADDRESS
{name: 'ENADDRESS', type: 'string' }, //公司英文地址
{name: 'POSTCODE', type: 'string' }, //POSTCODE
{name: 'OFFICEPHONE', type: 'string' }, //OFFICEPHONE
{name: 'FAX', type: 'string' }, //FAX
{name: 'EMAIL', type: 'string' }, //EMAIL
{name: 'WEBSITEURL', type: 'string' }, //WEBSITEURL
{name: 'LICENSECODE', type: 'string' }, //LICENSECODE
{name: 'TAXCODE', type: 'string' }, //TAXCODE
//{name: 'LOGO', type: 'byte[]' }, //徽标
{name: 'CREATEUSER', type: 'string' }, //CREATEUSER
{name: 'CREATETIME', type: 'DateTime' }, //CREATETIME
{name: 'MODIFIEDUSER', type: 'string' }, //更新人gid
{name: 'MODIFIEDTIME', type: 'DateTime' }, //更新时间
{name: 'ISDELETED', type: 'bool' }, //ISDELETED
{name: 'ISDISABLE', type: 'bool' }, //ISDISABLE
{name: 'PARENTID', type: 'string' }, //PARENTID
{name: 'BILLRISES', type: 'string' }, //发票抬头
{name: 'CHEQUEPAYABLE', type: 'string' }, //支票抬头
{name: 'PRTHEADXML1', type: 'string' }, //打印抬头1
{name: 'PRTHEADXML2', type: 'string' }, //打印抬头2
{name: 'PRTHEADXML3', type: 'string' }, //打印抬头3
{name: 'PRTHEADXML4', type: 'string' }, //打印抬头4
{name: 'PRTHEADXML5', type: 'string' }, //打印抬头5
{name: 'BANKSHEAD', type: 'string' }, //BANKSHEAD
{name: 'LOCALCURR', type: 'string' }, //本地货币
{name: 'WORKFLOWMSG', type: 'string' }, //是否启用消息提示
{name: 'GPSUSER', type: 'string' }, //GPSUser
{name: 'GPSPASSWORD', type: 'string' }, //GPSPassWord
{name: 'ORGANIZATIONCODE', type: 'string' },
{ name: 'MODIFIEDUSERNAME', type: 'string' },
{ name: 'DBNAME', type: 'string' },
{ name: 'LOGOURL', type: 'string' }
]
});
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCompanysEntity',
proxy: { url: '/MvcShipping/MsCompanys/GetNoPicDataList' }
});
this.storeCompany.load({ params: { condition: ""} });
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel:'分公司', //'委托分公司',
store: this.storeCompany,
width: 80,
name: 'COMPANYID',
valueField: 'GID',
displayField: 'NAME',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
//this.storeUser.load({ params: { condition: "CORPID='" + combo.value + "'", dbname: records[0].data.DBNAME} });
}
},
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeWorkFlowType = Ext.create('DsExt.ux.RefTableStore', {
model: 'WorkFlowTypemb',
proxy: { url: '/CommMng/BasicDataRef/GetTYPENO' }
});
this.storeWorkFlowType.load({
callback: function (options, success, response) {
_this.storeWorkFlowType.add({
"TYPENO": "",
"NAME": ""
});
}
});
this.comboxWorkFlowType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '工作流类型',
forceSelection: true,
store: this.storeWorkFlowType,
valueField: 'TYPENO',
displayField: 'NAME',
name: 'TYPE',
flex: 2,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '80%'
},
items: [ {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel:'工作流名称', //'费用代码',
name: 'WORKFLOWNAME',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxWorkFlowType, this.comboxCompany
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd", id: "NEW",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin("/OA/WorkFlow/Edit", "", "620", "1000");
},
scope: this
}, {
text: "删除",
iconCls: "btndelete", id: "DEL",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-', {
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
},
{
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1,true);
//alert(this.column[0].id);
},
scope: this
}, '-'
]
});
//#endregion
//布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 75,
items: [this.formSearch,this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
this.WorkFlowTypeAfterEdit(editor, e, eOpts);
}, this);
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin("/OA/WorkFlow/Edit", "", "620", "1000");
}, this);
this.onRefreshClick();
}, //end initUIComponents
WorkFlowTypeAfterEdit: function (editor, e, eOpts) {
e.record.set('MODIFIEDUSER', USERID);
e.record.set('MODIFIEDTIME', currdate.format('yyyy-MM-dd hh:mm:ss'));
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
this.bodyDel = [];
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var COMPANYID = form.findField('COMPANYID').getValue();
sql = sql + getAndConSql(sql, COMPANYID, "COMPANYID = '" + COMPANYID + "'");
var TYPE = form.findField('TYPE').getValue();
sql = sql + getAndConSql(sql, TYPE, "TYPE = '" + TYPE + "'");
var WORKFLOWNAME = form.findField('WORKFLOWNAME').getValue();
sql = sql + getAndConSql(sql, WORKFLOWNAME, "(NAME like '%" + WORKFLOWNAME + "%' or DESCRIPTION like '%" + WORKFLOWNAME + "%')");
/*
var PROTYPE = form.findField('PROTYPE').getValue();
sql = sql + getAndConSql(sql, PROTYPE, "PROTYPE like '%" + PROTYPE + "%'");
var BLNOTYPE = form.findField('BLNOTYPE').getValue();
sql = sql + getAndConSql(sql, BLNOTYPE, "BLNOTYPE like '%" + BLNOTYPE + "'%");
*/
return sql;
},
checkSearchCondition: function () {
/*var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}*/
return true;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
getStrValue: function (list) {
var _list = [];
for (var _i = 0; _i < list.length; _i++) {
_list.push("'" + list[_i] + "'");
}
return _list;
},
Save: function (type) {
//费用
var bodyList = [];
for (i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodyList.push(member);
/*
var BLNO = member.data.BLNO;
var PROJECTNO = member.data.PROJECTNO;
if (BLNO == ''||PROJECTNO == '') {
Ext.Msg.show({ title: '警告',
msg: '项目单号和项目编码均不允许为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}*/
};
var jsonBody = ConvertRecordsToJson(bodyList);
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
if (jsonBody == '' && jsonDelBody == '') {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/OA/WorkFlow/Save_Type',
scope: this,
params: {
ProjectBody: jsonBody,
ProjectDelBody: jsonDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//alert("保存成功");
var returnData = jsonresult.Data;
this.storeList.commitChanges();
} 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');
}
});
},
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
/*
var candelete = DsTruck.CheckBaoxiaoDelete(selectedRecords);
if (candelete == false) {
return;
}*/
var record = selections[0];
Ext.MessageBox.confirm('提示', '注意!目前审核未通过的业务将可能变得无法处理。确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/OA/WorkFlow/DeleteWorkFlow',
params: {
data: Ext.JSON.encode(record.data),
USERID: USERID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}, //onDeleteClick
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
});