📄 common_006.js
字号:
Ext.onReady(function(){
Ext.QuickTips.init();
/* create the Data Store */
var store = new Ext.data.Store({
id: 'store',
proxy: new Ext.data.MemoryProxy(getAddInfo()),
reader: new Ext.data.JsonReader({
totalProperty: "totalProperty",
root: "dataList"
}, new Ext.data.Record.create([{
name: 'addressID',
mapping: 'addressID'
}, {
name: 'description',
mapping: 'description'
}, {
name: 'addressInfo',
mapping: 'addressInfo'
}, {
name: 'postcode',
mapping: 'postcode'
}, {
name: 'phone',
mapping: 'phone'
}]))
});
var checkboxSelection = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer({// 自动行号
header: '序号',
width: 32
}), checkboxSelection, {
id: 'addressID',
header: "地址编号",
hidden: true,
dataIndex: 'addressID',
width: 50
}, {
id: 'description',
header: "地址信息描述",
dataIndex: 'description',
width: 110,
editor: new Ext.form.TextField({
allowBlank: false
})
}, {
id: 'addressInfo',
header: "详细地址信息",
dataIndex: 'addressInfo',
width: 200,
editor: new Ext.form.TextField({
allowBlank: false
})
}, {
id: 'postcode',
header: "邮编",
dataIndex: 'postcode',
width: 80,
editor: new Ext.form.TextField({
allowBlank: false
})
}, {
id: 'phone',
header: "联系电话",
dataIndex: 'phone',
width: 110,
editor: new Ext.form.TextField({
allowBlank: false
})
}]);
cm.defaultSortable = true;
var grid = new Ext.grid.EditorGridPanel({
id: 'addInfoGrid',
el: 'empAddList',
width: 670,
height: 150,
title: '地址信息列表',
store: store,
cm: cm,
sm: checkboxSelection,
stripeRows: true,
tbar: [{
text: '添加地址信息',
tooltip: '添加一个新的地址信息列',
iconCls: 'add-Btn-Image',
handler: addAddressInfo
}, '-', {
text: '删除地址信息',
tooltip: '删除选中的地址信息列',
iconCls: 'remove-Btn-Image',
handler: removeAddressInfo
}]
});
grid.render();
store.load();
refreshEnd();
});
strTitle = '员工详细信息';
AddressPlant = Ext.data.Record.create([{
name: 'addressID',
mapping: 'addressID',
type: 'string'
}, {
name: 'description',
mapping: 'description',
type: 'string'
}, {
name: 'addressInfo',
mapping: 'addressInfo',
type: 'string'
}, {
name: 'postcode',
mapping: 'postcode',
type: 'string'
}, {
name: 'phone',
mapping: 'phone',
type: 'string'
}]);
/* 删除地址列表信息 */
function removeAddressInfo(){
var grid = Ext.getCmp('addInfoGrid');
var gridSelects = grid.getSelections();
if (gridSelects.length == 0) {
showInfoMessageBox_2(strTitle, '请选择要删除地址信息');
} else {
showInfoMessageBox_3(strTitle, '确定要删除选中的地址信息吗?',
removeAddressInfo_Action);
}
}
function removeAddressInfo_Action(btn){
if (btn == 'ok') {
var grid = Ext.getCmp('addInfoGrid');
var store = Ext.getCmp('addInfoGrid').store;
var gridSelects = grid.getSelections();
for (var i = 0; i < gridSelects.length; i++) {
store.remove(gridSelects[i]);
}
grid.view.refresh();
}
}
/* 添加地址列表信息 */
function addAddressInfo(){
var address = new AddressPlant({
addressID: '',
description: '',
addressInfo: '',
postcode: '',
phone: ''
});
var grid = Ext.getCmp('addInfoGrid');
var store = Ext.getCmp('addInfoGrid').store;
grid.stopEditing();
store.insert(0, address);
grid.view.refresh();
grid.startEditing(0, 0);
}
/* 取得地址列表信息 */
function getAddInfo(){
var addInfoListDate = document.forms['empDetailForm'].elements['empDetailForm:addInfoList'].value;
if (addInfoListDate == null || addInfoListDate == "") {
return {};
}
return JSON.parse(addInfoListDate);
}
/* 重置地址列表信息 */
function resetAddInfoGrid(){
showInfoMessageBox_3(strTitle, '要放弃所有已修改的的数据吗?', resetAddInfoGrid_Action);
}
function resetAddInfoGrid_Action(btn){
if (btn == 'ok') {
document.forms['empDetailForm'].reset();
var ds = Ext.getCmp('addInfoGrid').store;
ds.reload();
}
}
function saveDataCheck(){
/* 地址列表信息Check */
var store = Ext.getCmp('addInfoGrid').store;
for (var i = 0; i < store.getCount(); i++) {
var addressInfo = store.getAt(i).data;
if (addressInfo.description == null || addressInfo.description == '' ||
addressInfo.addressInfo == null ||
addressInfo.addressInfo == '' ||
addressInfo.postcode == null ||
addressInfo.postcode == '' ||
addressInfo.phone == null ||
addressInfo.phone == '') {
showInfoMessageBox_2(strTitle, '输入的地址信息不能为空!');
return false;
}
}
if (store.data.length > 0) {
var addInfoListData = new Array();
for (var i = 0; i < store.getCount(); i++) {
var addressInfo = store.getAt(i).data;
addInfoListData.push(addressInfo);
}
document.forms['empDetailForm'].elements['empDetailForm:addInfoList'].value = JSON
.stringify(addInfoListData);
} else {
document.forms['empDetailForm'].elements['empDetailForm:addInfoList'].value = "";
}
return true;
}
/* 界面初始化开始 */
function refresh(){
parent.workDivInit();
}
/* 界面初始化结束 */
function refreshEnd(){
parent.workDivInitFinish();
}
/* 打开上传照片窗口 */
function openPhotoFileWindow(){
document.forms['photoView:uploadPhotoForm'].elements['photoView:uploadPhotoForm:photoTxt'].value = '';
Richfaces.showModalPanel('uploadPhotoFile');
return false;
}
/* 关闭上传照片窗口 */
function closePhotoFileWindow(){
Richfaces.hideModalPanel('uploadPhotoFile');
return false;
}
/* 检查上传文件类型 */
function checkUploadFileType(){
filePath = document.forms['photoView:uploadPhotoForm'].elements['photoView:uploadPhotoForm:photoTxt'].value;
if (filePath != null && filePath != "") {
var strFileFormat = filePath.match(/^(.*)(\.)(.{1,8})$/)[3];// 检查上传文件格式
strFileFormat = strFileFormat.toUpperCase();
if (strFileFormat == "JPG") {
//TODO fileName empID
return true;
}
showInfoMessageBox_2(strTitle, '输入的上传文件类型不是标准的JPG格式!');
} else {
showInfoMessageBox_2(strTitle, '输入的上传文件路径信息不能为空!');
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -