⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 book.js

📁 图书管理系统
💻 JS
📖 第 1 页 / 共 3 页
字号:
			}
		}
	},{
		text : '重置',
		handler : function() {
			var record = grid_book.getSelectionModel().getSelected();
			if(record){
				bookEditForm.getForm().loadRecord(record);
				bookEditForm.getForm().findField('_companyName').setValue('');
				bookEditForm.getForm().findField('_deptNo').setValue('');
				bookEditForm.getForm().findField('upload').setValue('');
			}
		}
	}, {
		text : '取消',
		handler : function() {this.ownerCt.ownerCt.hide();}
	}]
});

var ds_user_select = new Ext.data.Store({
	url : 'findUserByExample.action',
	reader : new Ext.data.JsonReader({
		root : 'root'
	}, [{name : 'userId',type : 'int'}, 
		{name : 'emplName',type : 'string'}
	])
})
		 
var loanLogForm = new Ext.FormPanel({
	url : 'saveLoanLog.action',
	labelAlign : 'right',
	labelWidth : 80,
	bodyStyle : 'padding:5px',
	border : false,
	baseCls : 'x-plain',
	defaultType : 'combo',
	defaults : {anchor:'95%'},
	items : [
	   {xtype : 'hidden',name : 'loanLog.bookId'},
	   {xtype : 'hidden',name : 'loanLog.bookName',id:'bookName'},
	   {xtype : 'textfield',fieldLabel : '图书名称',name : '_bookName',disabled:true},
	   {fieldLabel : '借出天数',
		valueField : 'loanDays',
		displayField : 'loanDays',
		hiddenName : 'loanLog.loanDays', 
		mode : 'local',
		triggerAction : 'all',
		editable : false,
		allowBlank : false,
		store : new Ext.data.SimpleStore({
	        fields: ['loanDays', 'loanDays'],
	        data : [['1','1'],['2','2'],['3','3'],['4','4'],['5','5'],['6','6'],['7','7'],['8','8'],['9','9'],['10','10'],['11','11'],['12','12'],['13','13'],['14','14'],['15','15'],['16','16'],['17','17'],['18','18'],['19','19'],['20','20'],['21','21'],['22','22'],['23','23'],['24','24'],['25','25'],['26','26'],['27','27'],['28','28'],['29','29'],['30','30']]}),
	    listeners : {
	    	'select': function(combo, record){
				var dt = new Date().add(Date.DAY,new Number(record.data.loanDays));
	    		loanLogForm.getForm().findField('_preReturnTime').setValue(dt.format('Y-m-d'));
	    		loanLogForm.getForm().findField('loanLog.preReturnTime').setValue(dt.format('Y-m-d'));
	    	}
	    }},
	    {xtype : 'hidden',name : 'loanLog.preReturnTime'},
	    {xtype : 'textfield',fieldLabel : '预计还书日期',name:'_preReturnTime',disabled : true},
	    {fieldLabel : '所属分公司',
		 name : 'companyName',
		 editable : false,
		 valueField : 'companyId',
		 displayField : 'companyName',
		 mode : 'remote',
		 store : ds_company_select,
		 triggerAction : 'all',
		 loadingText : '加载中...',
		 listeners : {
		 	'select': function(combo,record){
		 		loanLogForm.getForm().findField('deptNo').reset();
		 		loanLogForm.getForm().findField('loanLog.reader').reset();
		 		ds_dept_select.baseParams.companyId = record.data.companyId;
				ds_dept_select.reload();
				ds_user_select.removeAll();
		 	}
		 }},
		{fieldLabel : '所属部门',
		 name : 'deptNo',
		 editable : false,
		 valueField : 'deptId',
		 displayField : 'deptName',
		 mode : 'remote',
		 store : ds_dept_select,
		 triggerAction : 'all',
		 loadingText : '加载中...',
		 listeners : {
			 'beforequery' : function(queryEvent) {
				if (!this.ownerCt.form.findField('companyName').getValue()) {
					queryEvent.cancel = true;
				}
			 },
			 'select' : function(combo, record) {
			 	loanLogForm.getForm().findField('loanLog.reader').reset();
			 	ds_user_select.baseParams['user.deptId'] = record.data.deptId;
			 	ds_user_select.reload();
			 }
		 }
		},{xtype:'hidden',name:'loanLog.readerId'},
		{fieldLabel : '借书人',
		 hiddenName : 'loanLog.reader',
		 editable : false,
		 allowBlank : false,
		 displayField : 'emplName',
		 mode : 'local',
		 triggerAction : 'all',
		 loadingText : '加载中...',
		 store : ds_user_select,
		 listeners : {
		 	'select' : function(combo,record){
		 		loanLogForm.getForm().findField('loanLog.readerId').setValue(record.data.userId);
		 	}
		 }
		}
	  ],
	buttonAlign : 'right',
	minButtonWidth : 60,
	buttons : [{
		text:'借出',
		handler : function(){
			if(this.ownerCt.getForm().isValid()){
				Ext.Msg.confirm('操作提示','确认借出?',function(btn){
					if('yes' == btn){
						loanLogForm.getForm().submit({
							success: function(form){
								Ext.Msg.show({
									title : '成功提示',
									msg : '[' + form.findField('loanLog.bookName').getValue() + '] 成功借出!',
									icon : Ext.Msg.INFO,
									buttons : Ext.Msg.OK,
									fn:function(){
										window_loan_book.hide();
										var record = grid_book.getSelectionModel().getSelected();
										record.set('state',0);
										grid_book.fireEvent('rowclick',grid_book,grid_book.getStore().indexOf(record));
									}
								});
							},
							failure : function(form,action){
								Ext.Msg.show({
									title : '错误提示',
									msg : '[' + form.findField('loanLog.bookName').getValue() + '] 借出失败!',
									icon : Ext.Msg.ERROR,
									buttons : Ext.Msg.OK
								});
							}
						});
					}
				});
			}
		}
	},{
		text : '取消',
		handler:function(){
			this.ownerCt.ownerCt.hide();
		}
	}]
});

var bookForm = new Ext.FormPanel({
	url : 'saveBook.action',
	labelAlign : 'right',
	labelWidth : 70,
	bodyStyle : 'padding:5px',
	border : false,
	fileUpload : true,
	baseCls : 'x-plain',
	items : [{
		layout : 'column',
		border : false,
		baseCls : 'x-plain',
		items : [{
			columnWidth : .5,
			layout : 'form',
			baseCls : 'x-plain',
			border : false,
			defaultType : 'textfield',
			defaults : {anchor : '93%'},
			items : [{
				fieldLabel : '图书名称',
				id : 'book.bookName',
				name : 'book.bookName',
				allowBlank : false,
				maxLength : 50
			}, {
				xtype : 'combo',
				fieldLabel : '所属分类',
				id : 'category',
				hiddenName : 'book.categoryId',
				valueField : 'categoryId',
				displayField : 'categoryName',
				mode : 'remote',
				store : ds_category_select,
				selectOnFocus : true,
				editable : false,
				triggerAction : 'all',
				loadingText : '加载中...',
				listeners : {
					'select' : function(combo, record, index) {
						this.ownerCt.ownerCt.ownerCt.form.findField('book.categoryName').setValue(record.data.categoryName);
					}
				}
			},  {xtype : 'hidden',name : 'book.categoryName'}, 
				{fieldLabel : '作者',name : 'book.author',maxLength : 50}, 
				{fieldLabel : 'ISBN',name : 'book.isbn',	maxLength : 50}, 
				{fieldLabel : '字数',	name : 'book.wordCount',maxLength : 25}, 
				{fieldLabel : '页数',name : 'book.pageCount',maxLength : 25}, 
				{fieldLabel : '开本',name : 'book.bookSize',	maxLength : 25}, 
				{fieldLabel : '封面图片',	name : 'upload',inputType : 'file'}]
		}, {
			columnWidth : .5,
			layout : 'form',
			border : false,
			baseCls : 'x-plain',
			defaultType : 'textfield',
			defaults : {anchor : '93%'},
			items : [
				{fieldLabel : '出版社',name : 'book.press',maxLength : 50}, 
				{fieldLabel : '定价(元)',xtype : 'numberfield',name : 'book.price',maxValue : 1000}, 
				{fieldLabel : '版次',name : 'book.editionNo',maxLength : 25}, 
				{fieldLabel : '纸张',name : 'book.paper',maxLength : 25}, 
				{fieldLabel : '包装',name : 'book.pack',maxLength : 25}, 
				{xtype : 'hidden',name : 'book.address',maxLength : 50}, 
				{xtype : 'hidden',value : '1',name : 'book.state'}, 
				cbb_company_for_book, cbb_dept_for_book]
		}]
	}, {
		xtype : 'tabpanel',
		plain : true,
		bodyBorder : false,
		activeTab : 0,
		height : 200,
		defaults : {bodyStyle : 'padding:2px'},
		items : [
			{title : '内容简介',layout : 'fit',items : {xtype : 'textarea',name : 'book.description',maxLength : 500}}, 
			{title : '编辑推荐',layout : 'fit',items : {xtype : 'textarea',name : 'book.editorRecommend',maxLength : 500}}, 
			{title : '作者简介',layout : 'fit',items : {xtype : 'textarea',name : 'book.authorDesc',maxLength : 500}
		}]
	}],
	buttonAlign : 'center',
	minButtonWidth : 60,
	buttons : [{
		text : '添加',
		handler : function(btn) {
			if (bookForm.getForm().isValid()) {
				btn.disable();
				var bnfield = bookForm.getForm().findField('book.bookName');
				bookForm.getForm().submit({
					waitTitle : '请稍候',
					waitMsg : '正在提交表单数据,请稍候...',
					success : function(form, action) {
						var store = grid_book.getStore();
						if (store.data.length <= 20) {
							var description = '', editorRecommend = '', authorDesc = '';
							if (form.findField('book.description')) {
								description = form.findField('book.description').getValue();
							}
							if (form.findField('book.editorRecommend')) {
								editorRecommend = form.findField('book.editorRecommend').getValue();
							}
							if (form.findField('book.authorDesc')) {
								authorDesc = form.findField('book.authorDesc').getValue();
							}
							var book = new Book({
								bookId : action.result.bookId,
								bookName : bnfield.getValue(),
								categoryId : form.findField('book.categoryId').getValue(),
								categoryName : Ext.get('category').dom.value,
								author : form.findField('book.author').getValue(),
								press : form.findField('book.press').getValue(),
								price : form.findField('book.price').getValue(),
								editionNo : form.findField('book.editionNo').getValue(),
								isbn : form.findField('book.isbn').getValue(),
								wordCount : form.findField('book.wordCount').getValue(),
								pageCount : form.findField('book.pageCount').getValue(),
								bookSize : form.findField('book.bookSize').getValue(),
								paper : form.findField('book.paper').getValue(),
								pack : form.findField('book.pack').getValue(),
								imageUrl : action.result.imageUrl,
								address : form.findField('book.address').getValue(),
								description : description,
								editorRecommend : editorRecommend,
								authorDesc : authorDesc,
								state : form.findField('book.state').getValue()
							});
							store.insert(0, [book]);
							if (store.data.length > 20) {
								store.remove(store.getAt(store.data.length- 1));
							}
						}
						Ext.Msg.show({
							title : '提示',
							msg : '[ ' + bnfield.getValue() + ' ]   添加成功!!',
							buttons : Ext.MessageBox.OK,
							icon : Ext.Msg.INFO
						});
						bnfield.reset();
						btn.enable();
					},
					failure : function(form, action) {
						Ext.Msg.show({
							title : '错误提示',
							msg : action.result.contentTypeIsValid ? '操作失败' : '操作失败,文件类型不正确!',
							buttons : Ext.Msg.OK,
							fn : function() {bnfield.focus(true);btn.enable();},
							icon : Ext.Msg.ERROR
						});
					}
				});
			}
		}
	}, {
		text : '重置',
		handler : function() {this.ownerCt.form.reset();}
	}, {
		text : '取消',

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -