/********************************************
* 后台管理 - 申请批复 *
*******************************************/
//控制器:ResApplyRecommendController
//------------------------------------------
//F1.定义Ext列表实体字段
//F2.获取Ext列表数据
//F3.Ext加载后创建建列表
//F4.获取查询条件
//F5.页面初始化
//F6.查询
//F7.清除
//F8.显示批复对话框
//F9.关闭批复对话框
//F10.保存批复
//F11 查看申请理由
//------------------------------------------
//F1.定义Ext列表实体字段
Ext.define('ResModel', {
extend: 'Ext.data.Model',
fields:[
'resourceid', 'title', 'appid', 'appuserid', 'applycount', 'auditresult', 'audituserid', 'replycount', 'appdate', 'apptype', 'insteadaudit', 'isDangQianYongHu','appDays','appSys'
],
idProperty: 'appid'
});
//F2.获取Ext列表数据
var ResStore = new Ext.data.Store({
autoDestroy: true,
pageSize: 10,
model: 'ResModel',
proxy: {
type: 'ajax',
url: '/res/manage/applyrecommend/getlist',
reader: {
root: 'topics',
totalProperty: 'totalCount'
},
simpleSortMode: true
},
// remoteSort: true
});
//F3.Ext加载后创建建列表
var formdata = {};
Ext.onReady(function () {
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
Ext.tip.QuickTipManager.init();
Ext.Ajax.timeout = 900000;
Ext.require([
'Ext.ux.PagingToolbar'
]);
Ext.create('Ext.grid.Panel', {
id: 'gridexample',
renderTo: 'grid',
// width: 2400,
// height: 420,
layout: 'fit',
autoScroll: false,
//bodyStyle: 'width:100%',
store: ResStore,
stateful: false,
stateId: 'ZYMLZiYuan-Grid',
viewConfig: {
forceFit: true,
enableTextSelection: true //列表数据可复制
},
columns: [
{ xtype: 'rownumberer', text: "序号", width: '5%', align: 'center' },
{ text: "资源名称", dataIndex: 'title', width: '15%', sortable: true, align: 'center', filter: { type: 'string' },
renderer: function (value, p, record) {
var ziYuanId = record.getData()["resourceid"];
var tit = htmlEncodeByRegExp(value);
return Ext.String.format(
'{2}',
ziYuanId, value, tit
);
}
},
{ text: "申请人", dataIndex: 'appuserid', width: '10%', sortable: false, align: 'center', filter: { type: 'string' } },
{ text: "申请类型", dataIndex: 'apptype', width: '10%', sortable: true, align: 'center', filter: { type: 'string' } },
{ text: "申请系统", dataIndex: 'appSys', width: '12%', sortable: false, align: 'center', filter: { type: 'string' } },
{ text: "申请时间(天)", dataIndex: 'appDays', width: '8%', sortable: false, align: 'center', filter: { type: 'string' } },
{ text: "申请/批复", dataIndex: 'applycount', width: '10%', sortable: true, align: 'center',
renderer: function (value, p, record) {
var replycount = record.getData()["replycount"];
return Ext.String.format(
'{1} / {0}',
replycount,value
);
}
},
// { text: "批复次数", dataIndex: 'replycount', width: '10%', sortable: true, align: 'center' },
{ text: "申请日期", dataIndex: 'appdate', width: '10%', sortable: false, align: 'center', filter: { type: 'string' } },
{ text: "申请理由", width: '10%', sortable: false, align: 'center' ,
renderer: function (value, p, record) {
var appid = record.getData()["appid"];
return Ext.String.format(
'查看',
appid
);
}
},
{ text: "批复操作", dataIndex: 'auditresult', width: '10%', sortable: true, align: 'center', filter: { type: 'string' },
renderer: function (value, p, record) {
var insteadauditId = record.getData()["insteadaudit"];
//资源发布人 与 当前用户是否一致 一致 为1
var isDangQianYongHu=record.getData()["isDangQianYongHu"];
//有委托批复的记录,批复列显示按钮
// if(insteadauditId==1){
// if(value == null || value == 'null' || value == '' || value == 0 ){
// var appid = record.getData()["appid"];
// return Ext.String.format(
// '通过 不通过',
// appid
// );
// } else {
// if( value == 1 ){
// return '通过
';
// }
// else if( value == 2 ){
// return '不通过
';
// }
// else{
// return '' + value + '
';
// }
// }
// }else {
// if(isDangQianYongHu==1){
// if(value == null || value == 'null' || value == '' || value == 0 ){
// var appid = record.getData()["appid"];
// return Ext.String.format(
// '通过 不通过',
// appid
// );
// } else {
// if( value == 1 ){
// return '通过
';
// }
// else if( value == 2 ){
// return '不通过
';
// }
// else{
// return '' + value + '
';
// }
// }
// }else{
// return Ext.String.format(
// '通知 '
// );
// }
// }
if(value == null || value == 'null' || value == '' || value == 0) {
if(isDangQianYongHu==1 || insteadauditId==1) {
var appid = record.getData()["appid"];
return Ext.String.format(
'通过 不通过',
appid
);
}
else {
return Ext.String.format(
''
// '通知 '
);
}
}
else {
if( value == 1 ){
return '通过
';
}
else if( value == 2 ){
return '不通过
';
}
else{
return '' + value + '
';
}
}
}
}
],
bbar: Ext.create('Ext.ux.PagingToolbar', {
id: "Page",
name: "Page",
store: ResStore,
displayInfo: true,
firstText: "首页",
prevText: "上一页",
nextText: "下一页",
lastText: "尾页",
refreshText: '刷新',
beforePageText: '第',
afterPageText: '页,共 {0} 页',
displayMsg: '显示 {0} - {1} 条,共 {2} 条',
emptyMsg: "没有数据显示",
items: [
{
xtype: 'label',
text: ''
}
]
})
});
ResStore.on('beforeload', function () {
GetSearchWhere("SearchForm");
ResStore.proxy.extraParams = [];
Ext.apply(ResStore.proxy.extraParams, formdata);
});
ResStore.on('load', function (store, records, successful, eOpts) {
var totalCount = store.totalCount;
if (totalCount == "") totalCount = "0";
});
ResStore.load();
//添加resize监听防止切换tab或者收起左栏导致grid不自适应宽度
$(window).resize(function () {
Ext.getCmp('gridexample').doLayout();//panel重新布局
});
});
//F4.获取查询条件
function GetSearchWhere(formId) {
var form = document.forms[formId];
for (var i = 0; i < form.elements.length; i++) {
var strID = form.elements[i].id;
var value = form.elements[i].value;
if (form.elements[i].type == "checkbox") {
if (form.elements[i].checked == true)
value = "on";
else
value = "";
}
if (form.elements[i].type == "radio") {
if (form.elements[i].checked == true) {
strID = form.elements[i].name;
value = form.elements[i].value;
}
}
formdata[strID] = (value == "全部" || value == "None" ? "" : value + "");
}
}
//F5.页面初始化
$(function () {
$(".date-picker").datepicker({
language: 'zh-CN',
format: 'yyyy-mm-dd'
});
});
//F6.查询
function Search() {
if(!checkDate2()) {
$("#appdateEnd").focus();
$("#appdateEnd").focus();
return false;
}
Ext.getCmp('gridexample').dockedItems.items[1].store.currentPage = 1;
ResStore.load();
}
//F7.清除
function Clear() {
document.getElementById("SearchForm").reset();
}
//F8.显示批复对话框
function ShowModal(appid, status) {
$("#myModal").modal("show");
$("#APPID").val(appid);
$("#Status").val(status);
if (status == 1) {
$("#sStatus").text(" - 通过");
} else {
$("#sStatus").text(" - 不通过");
}
}
//F9.关闭批复对话框
function CloseModal() {
$("#myModal").modal("hide");
}
//F10.保存批复
function Save() {
var appid = $("#APPID").val();
var status = $("#Status").val();
var opinion = $("#opinion").val();
console.log({'appid': appid, 'auditresult': status, 'auditopinion': opinion})
//return false ;
if (opinion == null || opinion == "") {
alert("请输入批复意见!")
} else {
$.ajax({
url: '/res/manage/applyrecommend/save',
type: 'post',
dataType: "text",
data: {'appid': appid, 'auditresult': status, 'auditopinion': opinion},
success: function (data) {
if (data !=0) {
alert("审核成功!");
CloseModal();
Search();
} else {
alert("审核失败!");
CloseModal();
}
},
error: function (e) {
alert(e);
}
});
}
}
//F11 查看申请理由
function showAppreason (id) {
layer.open({
type: 2,
title: "申请理由",
shadeClose: true,
area: ["600px", "250px"],
content: 'content?appid='+id
});
}
//判断发布时间选择框,后一个时间是否小于前一个时间
function checkDate2() {
var pubdateBegin = $("#appdateBeg").val();
var pubdatefinish = $("#appdateEnd").val();
if(pubdateBegin != "" && pubdatefinish != ""){
var pubdatestart = new Date(pubdateBegin.replace(/-/g,"/"));
var pubdateend = new Date(pubdatefinish.replace(/-/g,"/"));
if(pubdatestart > pubdateend){
alert("结束时间不能小于开始时间!");
return false;
}
else {
return true;
}
}
else {
return true;
}
}