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.
DS7/DSWeb/Areas/SoftMng/Viewsjs/MsSoftUpGrade/MsSoftUpGradeEdit.js

952 lines
30 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsSoftUpGradeEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsSoftUpGradeEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsSoftUpGradeEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
editFactryRecord: null,
FactryStatus: 'add',
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.Loading = true;
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
autoScroll: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '版本号',
allowBlank: true,
flex: 1,
name: 'SQLVER'
}, {
fieldLabel: '序号',
allowBlank: true,
flex: 1,
name: 'SORT'
}, {
fieldLabel: '当前状态',
allowBlank: true,
flex: 1,
name: 'UPSTATUS'
}, {
fieldLabel: '录入人',
readOnly: true,
disabled: true,
name: 'INPUTBYREF'
}, {
fieldLabel: '录入日期',
readOnly: true,
disabled: true,
name: 'INPUTTIME'
}]
}, { xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'textareafield',
grow: true,
height: 240,
fieldLabel: '更新语句',
name: 'SQLTEXT',
anchor: '100%'
}]
}, { xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'textareafield',
grow: true,
height: 40,
fieldLabel: '说明',
name: 'REMARKS',
anchor: '100%'
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
id: 'btnEPrev',
text: "上一条",
// iconCls: "btnsave",
handler: function (button, event) {
this.PrevRecord();
},
scope: this
}, {
id: 'btnENext',
text: "下一条",
// iconCls: "btnsave",
handler: function (button, event) {
this.NextRecord();
},
scope: this
}, {
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
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');
field.setValue(NewGuid());
basicForm.findField('GID').setDisabled(true);
field = basicForm.findField('INPUTBYREF');
field.setValue(SHOWNAME);
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("VERGID", '*');
memberbody.commit();
};
},
scope: this
}, '-', {
id: 'btnSubmitAudit',
text: '提交审核',
tooltip: '提交审核',
handler: function (button, event) {
this.onSubmitAuditClick();
},
scope: this
}, '-', {
id: 'btnSubmitAuditBack',
text: '撤销审核',
tooltip: '撤销审核',
handler: function (button, event) {
this.onSubmitAuditBackClick();
},
scope: this
}, '-', {
text: "审核通过",
id: 'btnAudit',
iconCls: "btnadd",
handler: function (button, event) {
this.onAuditClick();
},
scope: this
},
'-',
{
text: "驳回提交",
id: 'btnAuditBack',
iconCls: "btndelete",
handler: function (button, event) {
this.onAuditBackClick();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 相关表及VIEW
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsSysUpdateSqlTbl',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/SoftMng/MsSoftUpGrade/GetSqlTableList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeTBLNAME = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsSysTbl',
proxy: { url: '/CommMng/BasicDataRef/GetCodeLaneList' }
});
this.storeTBLNAME.load();
this.comboTBLNAME = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeTBLNAME,
// forceSelection: true,
name: 'TBLNAME',
valueField: 'GID',
displayField: 'TBLNAME'
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListTableItems = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
id: "btnadddetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.addDetail();
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
id: "btndeldetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelTableClick();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'VERGID',
header: '业务编号',
hidden: true,
width: 0
}, {
dataIndex: 'TBLGID',
header: '相关表',
width: 220,
editor: this.storeTBLNAME,
renderer: function (value, p, record) {
return record.data.TBLNAME;
}
}]
});
this.gridListTableItems.on('edit', function (editor, e, eOpts) {
this.gridListAfterEdit(editor, e, eOpts);
}, this);
this.panelTableItems = new Ext.Panel({
title: '相关表及VIEW',
layout: "border",
region: 'center',
animate: true,
frame: false,
items: [this.gridListTableItems]
});
//#endregion
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 410,
items: [this.panelBtn, this.formEdit]
});
this.tabWTpanel = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
frame: false,
region: 'center',
enableTabScroll: true,
items:
[
this.panelTableItems
]
});
Ext.apply(this, {
items: [this.panelTop, this.tabWTpanel]
});
//#endregion
//绑定查询窗体
this.storeBodyList.on('beforeload', function (store) {
var acondition = " VERGID='" + this.editRecord.get('GID') + "'";
Ext.apply(store.proxy.extraParams, { condition: acondition });
}, this);
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
var btnAudit = Ext.getCmp('btnAudit');
var btnAuditBack = Ext.getCmp('btnAuditBack');
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsBaseInfo/GetUserModuleEnable',
params: {
modulename: "AUDITSQL"
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
btnAudit.disable();
btnAuditBack.disable();
} else {
btnAudit.enable();
btnAuditBack.enable();
}
} else {
}
},
scope: this
});
//绑定事件
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
this.FactryStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/SoftMng/MsSoftUpGrade/GetData',
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;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
if (this.opStatus == 'edit') {
var acondition = " VERGID='" + this.editRecord.get('GID') + "'";
this.storeBodyList.load({ params: { condition: acondition} });
}
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
if (this.opStatus == 'add') {
data.GID = NewGuid();
}
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/SoftMng/MsSoftUpGrade/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.insert(0, returnData);
this.editRecord = this.StoreList.getAt(0);
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsSysUpdateSql', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm.findField('GID').setDisabled(true);
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("VERGID", this.editRecord.get('GID'));
memberbody.commit();
};
} else if (type == '1') {
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("VERGID", this.editRecord.get('GID'));
memberbody.commit();
};
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('GID').setDisabled(false);
}
} 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
});
}
}
});
}, //end save
gridListAfterEdit: function (editor, e, eOpts) {
if (e.value == e.originalValue) return;
if (e.field == 'TBLGID') {
var selectrecords = DsStoreQueryBy(this.storeTBLNAME, 'GID', e.value);
if (selectrecords.getCount() > 0) {
var selectdata = selectrecords.getAt(0).data;
e.record.set('TBLNAME', selectdata.TBLNAME);
} else {
e.record.set('TBLNAME', '');
}
}
},
addDetail: function () {
var MSDSID = this.formEdit.getForm().findField('GID').getValue();
//var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo);
var record = Ext.create('MsSysUpdateSqlTbl', {
GID: NewGuid(),
VERGID: '*',
TBLGID: '',
TBLNAME: '',
REMARKS: ''
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
onDelTableClick: function () {
var selections = this.gridListTableItems.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
var bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/SoftMng/MsSoftUpGrade/DeleteSqlTable',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var acondition = " VERGID='" + this.editRecord.get('GID') + "'";
this.storeBodyList.load({ params: { condition: acondition} });
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);
},
onSubmitAuditClick: function () {
var Duino = this.formEdit.getForm().findField('GID').getValue();
var billstatus = this.formEdit.getForm().findField('UPSTATUS').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存语句,然后才能提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if ((billstatus != '新增') && (billstatus != '驳回提交')) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/SoftMng/MsSoftUpGrade/SubmitAudit',
params: {
bill: Duino,
type: 2
},
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;
} else {
var returnData = result.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'edit') {
var editp = Ext.create('MsSysUpdateSql', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
this.GetEditStatus();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onSubmitAuditBackClick: function () {
var Duino = this.formEdit.getForm().findField('GID').getValue();
var billstatus = this.formEdit.getForm().findField('UPSTATUS').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存语句,然后才能撤销提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if (billstatus != '提交审核') {
Ext.Msg.show({ title: '提示', msg: '当前状态无法撤销提交!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/SoftMng/MsSoftUpGrade/SubmitAudit',
params: {
bill: Duino,
type: 1
},
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;
} else {
var returnData = result.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'edit') {
var editp = Ext.create('MsSysUpdateSql', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
this.GetEditStatus();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
// #region 根据权限和状态判断是否允许修改
GetEditStatus: function () {
var canedit = false;
var btnESubmitAudit = Ext.getCmp('btnSubmitAudit');
var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack');
var bsStatus = this.formEdit.getForm().findField('UPSTATUS').getValue();
var op = this.formEdit.getForm().findField('INPUTBYREF').getValue();
_this = this;
if (SHOWNAME == op) {
if (bsStatus == '提交审核') {
btnESubmitAuditBack.enable();
btnESubmitAudit.disable();
_this.setSaveBtnStatus(false);
} else if (bsStatus == '新增' || bsStatus == '新建' || bsStatus == '驳回提交') {
btnESubmitAuditBack.disable();
btnESubmitAudit.enable();
_this.setSaveBtnStatus(true);
} else {
btnESubmitAuditBack.disable();
btnESubmitAudit.disable();
_this.setSaveBtnStatus(false);
}
} else {
btnESubmitAudit.disable();
btnESubmitAuditBack.disable();
_this.setSaveBtnStatus(false);
}
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEAddDetail = Ext.getCmp('btnadddetail');
var btnEDeleteDetail = Ext.getCmp('btndeldetail');
this.canedit = enable;
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
}
},
// #endregion
PrevRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == 0) {
Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
if (j == this.StoreList.count) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var condition = '';
j = j - 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "GID='" + this.editRecord.get('GID') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
NextRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == (this.StoreList.data.length - 1)) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var condition = '';
j = j + 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "GID='" + this.editRecord.get('GID') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
getIsModify: function () {
if (panelEdit.formEdit.getForm().isDirty() == true) {
return '升级信息';
}
else return '';
} //
});