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/MsSoftUpDateEdit.js

432 lines
13 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');
Shipping.MsSoftUpDateEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsSoftUpDateEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsSoftUpDateEdit, 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)
// 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: '100%'
// },
// items: [{
// xtype: 'container',
// layout: 'hbox',
// defaultType: 'textfield',
// items: [ {
// xtype: 'button',
// width: 120,
// text: "确认更新",
// iconCls: "btnrefresh",
// handler: function (button, event) {
// },
// scope: this
// },'-' , {
// xtype: 'button',
// width: 120,
// text: "退出更新",
// handler: function (button, event) {
// },
// scope: this
// }]
// }
// ]//end items(fieldset 1)
// }]//end root items
// });
//编辑form
this.formEdit = Ext.widget('form', {
region: 'east',
width: 460,
frame: true,
bodyPadding: 5,
autoScroll: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 30,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'textareafield',
grow: true,
height: 380,
id: 'ERRSTR',
fieldLabel: '错误日志',
name: 'ERRSTR',
anchor: '100%'
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsSysUpdateSql',
pageSize: this.PageSize,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/SoftMng/MsSoftUpGrade/GetUpDateData',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
this.initgirdcolums = [{
sortable: true,
id: '',
dataIndex: '',
header: '',
width: 0
}, {
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'SQLVER',
header: '脚本版本号',
width: 100
}, {
sortable: true,
dataIndex: 'SORT',
header: '序号',
width: 40
}, {
sortable: true,
dataIndex: 'REMARKS',
header: '更新内容',
width: 160
}, {
sortable: true,
dataIndex: 'UPSTATUS',
header: '已更新',
width: 100,
renderer: function (value, meta, record) {
if (value == true || value == '1')
return '✔';
else if (value == false || value == '0')
return '✘';
else if (value == '3')
return '→';
else
return '';
}
}
];
this.girdcolums = this.initgirdcolums;
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
_this = this;
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
columns: this.girdcolums
,
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
xtype: 'button',
width: 120,
text: "确认更新",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onExecSQLClick();
},
scope: this
},
'-',
{
xtype: 'button',
width: 120,
text: "退出更新",
handler: function (button, event) {
window.close();
},
scope: this
}
]
});
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 45,
items: [this.panelBtn]
});
this.panelDetail = new Ext.Panel({
layout: "border",
region: "center",
items: [this.gridList, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.panelDetail]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
}, //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];
}
var sqlver = this.editRecord.get('SQLVER');
var sort = this.editRecord.get('SORT');
this.storeList.load({ params: { sqlver: sqlver, sort: sort} });
}, //end InitData
onExecSQLClick: function () {
Ext.MessageBox.confirm('提示', '确定要更新到最新版吗?', function (btn) {
if (btn == 'yes') {
for (i = 0; i < this.storeList.getCount(); i += 1) {
var memberyf = this.storeList.getAt(i);
var bodyAddDatas = [];
bodyAddDatas.push(memberyf);
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/SoftMng/MsSoftUpGrade/ExecUpSql',
async: false,
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
var Rvalue = Ext.getCmp('ERRSTR').getValue();
Ext.getCmp('ERRSTR').setRawValue(Rvalue + '执行脚本版本号:' + memberyf.data.SQLVER + ',出现错误. \n' + "错误内容:" + result.Message + '\n');
memberyf.set("UPSTATUS", '0');
memberyf.commit();
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
memberyf.set("UPSTATUS", '1');
memberyf.commit();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
};
}
}, this);
},
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 '';
} //
});