uploadfileTab.js 16.5 KB
Newer Older
罗绍泽 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
/**
 * 序号:1
 * 功能:定义分页(EasyUI)
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:无需更改
 **/
var ls_width = $(window).width();
var ls_height = $(window).height();

var local_page=1;
var rows=20;
var listPageSize = [10,20,50,100,500,1000];
var queryData = eval("({'page':'"+local_page+"','rows':'"+rows+"'})");
var tab_n = 0;

//重置分页参数
function resetQueryData(){
	queryData = "";
	queryData = eval("({'page':'"+local_page+"','rows':'"+rows+"'})");
}

//定义附件关联模块ID(1:一般业务,2:测试信息,3:审批业务,999:其它数据 )
var ls_module_id='999';
//定义当前模块业务类型(YBYW:一般业务,SPGL:审批业务) 
var ls_ywlx = 'YBYW';
/****/

/**
 * 序号:2
 * 功能:构建下拉框内容
 * 参数:
 * 说明:方便新增、修改页面里的下拉选项加载数据
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
//加载是否数据
var v_yesnoquery = {};
v_yesnoquery.FIELD_tableName = "DM_ST_YES_NO";
var v_yesnoquery_data = standardModel.dataAction.listAllCache(v_yesnoquery);
//加载文件所在模块数据
var v_modulequery = {};
v_modulequery.FIELD_tableName = "DM_ST_FILE_MODULE";
var v_modulequery_data = standardModel.dataAction.listAllCache(v_modulequery);
/****/

/**
 * 序号:3
 * 功能:构建主页面列表
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
//定义grid列表
var ls_title="附件管理&nbsp;&nbsp;<font color='#993300'>(注:1、蓝色表示数据库里存有文件;2、灰色表示数据被删除。)</font>";
var is_column = [ [
					{field : 'FILE_NAME',title : '附件真实名',width : 200,align : 'center'},
					{field : 'FILE_SVAE_NAME',title : '附件保存名',width : 300,align : 'center'},
					{field : 'MODULE_ID',title : '所在模块',width : 120,align : 'center',
						formatter : function(value) {
							return getCodeName(v_modulequery_data.rowSet, value);
						}
					},
					{field : 'MAINDATA_ID',title : '对应主表ID',width : 250,align : 'center'},
					{field : 'FILE_SAVE_PATH',title : '磁盘保存路径',width : 500,align : 'left'},
					{field : 'EXIST_FILE',title : '文件已存库',width : 80,align : 'center',
						formatter : function(value) {
							return getCodeName(v_yesnoquery_data.rowSet, value);
					    }
					},
					{field : 'DELETE_FLAG',title : '数据已删除',width : 80,align : 'center',
						formatter : function(value) {
							return getCodeName(v_yesnoquery_data.rowSet, value);
					    }
					},
					{field : 'CREATE_NAME',title : '创建人员',width : 100,align : 'center'},
					{field : 'CREATE_TIME',title : '创建时间',width : 100,align : 'center'},
					{field : 'UPDATE_NAME',title : '修改人员',width : 100,align : 'center'},
					{field : 'UPDATE_TIME',title : '修改时间',width : 100,align : 'center'}
				] ];
//列表加载完成回调
function dataOnLoadSuccess(){
	$('#FIELD_MODULE_ID').combobox({
		data : v_modulequery_data.rowSet,
		valueField : 'CODE_ID',
		textField : 'CODE_NAME',
		editable:false,  
		panelHeight:'auto'
	});
}
//设置颜色和每行高度
function rowstyler(index,row){
	if(row.DELETE_FLAG!='1'){
		if (row.EXIST_FILE=='1') {
			return 'color:blue;height:30px;';
		}
	}
	else{
		return 'color:#c0c0c0;height:30px;';
	}
}
//展示列表
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/uploadFileData_list_nofile",queryData,is_column,60,80);
/****/

/**
 * 序号:4
 * 功能:设置主页面操作列菜单
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
//操用列显示更多(一般情况下无需更改)
function formatMenu(value, data,index) {
	var returnData="";
	return  returnData
	      + "<span class=\"icon-ext-moremenu\" style=\"padding-left:20px;*width:20px;\"></span>"
	      + "<span data-p1="+index+" class=\"easyui-tooltip\" style=\"color:blue;cursor:pointer;\">更多</span>";
}

//上浮横向菜单集里的具体菜单项(需更改)
function getOptionMenu(data,index){
	var returnData= "<span class=\"icon-edit\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"editRow('"
		+ index + "')\">编辑</a>  |  <span class=\"icon-clear\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"deleteRow('"
		+ index + "')\">删除</a>  |  <span class=\"icon-undo\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"resumeRow('"
		+ index + "')\">恢复</a>  |  <span class=\"icon-remove\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"removeRow('"
		+ index + "')\">清除</a>  |  <span class=\"icon-download\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"downloadjw('"
		+ index + "')\">下载</a>";
	return returnData;
}

//返回菜单集的菜单个数(需更改)
function getOptionMenuCount(){
	var is_menu_count = 5;
	return is_menu_count;
}

/****/

/**
 * 序号:5
 * 功能:新增修改弹出
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
//加载增加子页面
function addRow(){
	var is_row={OPETYPE:'insert'};
	openEditRow("uploadFileView_uploadfileTabDetail",is_row,"新增",true,0.65,0.95,0,0);

}
//加载增加子页面成功后的回调
function addUrlOnloadCallback(is_row){
	$('#MODULE_ID').combobox({
		data : v_modulequery_data.rowSet,
		valueField : 'CODE_ID',
		textField : 'CODE_NAME',
		editable:false,  
		panelHeight:'auto'
	});
}
//保存
function insertData(is_entity){
//	is_entity.FIELD_SEND_DATE = strToDateObj(is_entity.FIELD_SEND_DATE);
//	is_entity.FIELD_RECEIVE_DATE = strToDateObj(is_entity.FIELD_RECEIVE_DATE);
	var v_result = uploadfileModule.uploadfileActAction.insertUploadfile(is_entity);
	$('#list').datagrid('reload');
	return v_result;
}

//加载修改子页面
function editRow(index) {
	$('#list').datagrid('selectRow',index);
	var is_row = $('#list').datagrid('getSelections');
	$('#list').datagrid('clearSelections');
	is_row[0].OPETYPE = 'update';
	openEditRow("uploadFileView_uploadfileTabDetail",is_row[0],"编辑",true,0.65,0.95,0,0);	
}

//加载修改子页面成功后的回调
function updateUrlOnloadCallback(is_row){
	$('#MODULE_ID').combobox({
		data : v_modulequery_data.rowSet,
		valueField : 'CODE_ID',
		textField : 'CODE_NAME',
		editable:false,  
		panelHeight:'auto'
	});
}
//保存
function updateData(is_entity){
//	is_entity.FIELD_SEND_DATE = strToDateObj(is_entity.FIELD_SEND_DATE);
//	is_entity.FIELD_RECEIVE_DATE = strToDateObj(is_entity.FIELD_RECEIVE_DATE);
	v_result = uploadfileModule.uploadfileActAction.updateUploadfile(is_entity);
	$('#list').datagrid('reload');
	return v_result;
}

/****/

/**
 * 序号:6
 * 功能:单个删除
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function deleteRow(index){
	$('#list').datagrid('selectRow',index);
	
	var is_row = $('#list').datagrid('getSelections');
	$('#list').datagrid('clearSelections');
	
	var code = is_row[0].UUID;
	$.messager.confirm('提示', '确定删除?', function(r) {
		if (r) {
			var v_query = {};
		    v_query.FIELD_CODE = code;
		    var v_result = uploadfileModule.uploadfileActAction.deleteUploadfile(v_query);
			$.messager.alert('提示',v_result.VALUE);
			$('#list').datagrid('reload');
		}
	});
}
/****/

/**
 * 序号:7
 * 功能:批量删除
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function deleteBatchRow(){
	var code="";
	var rows = $('#list').datagrid('getSelections');
	for(var i=0; i<rows.length; i++){
		code = code + rows[i].UUID+",";
	}
	if(rows == null || rows == ""){
		$.messager.alert('提示',"请选择需删除的记录!",'info');
		return;
	}
	if(code.length>0){
		code = code.substring(0,code.length - 1);
	}
	$.messager.confirm('提示', '确定删除?', function(r) {
		if (r) {
			var v_query = {};
		    v_query.FIELD_CODE = code;
		    var v_result = uploadfileModule.uploadfileActAction.deleteUploadfile(v_query);
			$.messager.alert('提示',v_result.VALUE);
			$('#list').datagrid('reload');
		}
	});
}
/****/

/**
 * 序号:8
 * 功能:刷新
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function refreshRow(){
	$('#list').datagrid('load',{});
	$("#uploadfileTab_searchForm")[0].reset();
}
/****/

/**
 * 序号:9
 * 功能:查询
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function searchRow(){
	var v_query = $("#uploadfileTab_searchForm").getFormVal();
	$('#list').datagrid('load',v_query);
	renderDATAFORM(v_query,$("#uploadfileTab_searchForm"));
}
/****/

/**
 * 序号:10
 * 功能:单个恢复
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function resumeRow(index){
	$('#list').datagrid('selectRow',index);
	
	var is_row = $('#list').datagrid('getSelections');
	$('#list').datagrid('clearSelections');
	
	var code = is_row[0].UUID;
	$.messager.confirm('提示', '确定恢复?', function(r) {
		if (r) {
			var v_query = {};
		    v_query.FIELD_CODE = code;
		    var v_result = uploadfileModule.uploadfileActAction.resumeUploadfile(v_query);
			$.messager.alert('提示',v_result.VALUE);
			$('#list').datagrid('reload');
		}
	});
}
/****/

/**
 * 序号:11
 * 功能:批量恢复
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function resumeBatchRow(){
	var code="";
	var rows = $('#list').datagrid('getSelections');
	for(var i=0; i<rows.length; i++){
		code = code + rows[i].UUID+",";
	}
	if(rows == null || rows == ""){
		$.messager.alert('提示',"请选择需恢复的记录!",'info');
		return;
	}
	if(code.length>0){
		code = code.substring(0,code.length - 1);
	}
	$.messager.confirm('提示', '确定恢复删除的记录?', function(r) {
		if (r) {
			var v_query = {};
		    v_query.FIELD_CODE = code;
		    var v_result = uploadfileModule.uploadfileActAction.resumeUploadfile(v_query);
			$.messager.alert('提示',v_result.VALUE);
			$('#list').datagrid('reload');
		}
	});
}
/****/

/**
 * 序号:12
 * 功能:单个清除
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function removeRow(index){
	$('#list').datagrid('selectRow',index);
	
	var is_row = $('#list').datagrid('getSelections');
	$('#list').datagrid('clearSelections');
	
	if(is_row[0].DELETE_FLAG!=null && is_row[0].DELETE_FLAG == '0'){
		$.messager.alert('提示',"存在没有删除标记的记录,无法清除!",'info');
		return;
	}
	
	var code = is_row[0].UUID;
	$.messager.confirm('提示', '确定清除记录?', function(r) {
		if (r) {
			var v_query = {};
		    v_query.FIELD_CODE = code;
		    var v_result = uploadfileModule.uploadfileActAction.deleteTrueUploadfile(v_query);
			$.messager.alert('提示',v_result.VALUE);
			$('#list').datagrid('reload');
		}
	});
}
/****/

/**
 * 序号:13
 * 功能:批量清除
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function removeBatchRow(){
	var code="";
	var rows = $('#list').datagrid('getSelections');
	for(var i=0; i<rows.length; i++){
		code = code + rows[i].UUID+",";
		if(rows[i].DELETE_FLAG!=null && rows[i].DELETE_FLAG == '0'){
			$.messager.alert('提示',"存在没有删除标记的记录,无法清除!",'info');
			return;
		}
	}
	if(rows == null || rows == ""){
		$.messager.alert('提示',"请选择需清除的记录!",'info');
		return;
	}
	if(code.length>0){
		code = code.substring(0,code.length - 1);
	}
	$.messager.confirm('提示', '确定清除记录?', function(r) {
		if (r) {
			var v_query = {};
		    v_query.FIELD_CODE = code;
		    var v_result = uploadfileModule.uploadfileActAction.deleteTrueUploadfile(v_query);
			$.messager.alert('提示',v_result.VALUE);
			$('#list').datagrid('reload');
		}
	});
}
/****/

/**
 * 序号:14
 * 功能:高级查询弹出
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
//加载高级查询子页面
function advsearchRow(){
	var is_row={OPETYPE:'ww'};
	openAdvsearchRow("uploadFileView_uploadfileAdvsearch",is_row,"高级查询",true,0.65,0.95,0,0);

}
//加载高级查询子页面成功后的回调
function addAdvsearchCallback(is_row){
	$('#adv_MODULE_ID').combobox({
		data : v_modulequery_data.rowSet,
		valueField : 'CODE_ID',
		textField : 'CODE_NAME',
		editable:false,  
		panelHeight:'auto'
	});
}
//高级查询
function advsearchData(is_entity){
	is_entity.FIELD_START_TIME = strToDateObj(is_entity.FIELD_START_TIME);
	is_entity.FIELD_END_TIME = strToDateObj(is_entity.FIELD_END_TIME);
	is_entity.FIELD_USTART_TIME = strToDateObj(is_entity.FIELD_USTART_TIME);
	is_entity.FIELD_UEND_TIME = strToDateObj(is_entity.FIELD_UEND_TIME);
	$('#list').datagrid('load',is_entity);
}
/****/

/**
 * 序号:15
 * 功能:上传
 * 参数:填写限制上传类型,上传地址
 * 说明:openUpload_image(uuid),打开图片上传;
 *      openUpload_doc(uuid),打开常用公文上传;
 *      openUpload_imagedoc(uuid),打开常图片+用公文上传;
 *      openUpload_page2(up_act,uuid),自定义URL,打开常图片+用公文上传;
 *      如有特殊限制时用以下这段:
 *      var up_type = "gif,jpg,jpeg,bmp,png";//限制上传类型
 *      var up_act = "reportact_upload";//上传地址
 *      openUpload_page1(up_type,up_act,uuid);
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
//打开上传页面
function uploadjw(uuid){
	openUpload_page2('uploadFileAct_upload',uuid);
}
//上传成功后的回调,主要返回三个参数:
//fname上传时的真实文件名如:文件.txt,
//fpath上传后的真实文件名如:c:\temp\145597044184082388.txt
//uuid主要用于记录跟文件绑定用,如果uuid的值是'uuid',可多传文件,手工关闭上传界面
function uploadCallback(fname,fpath,uuid){
	var fileOld = fname;
	var filePath = fpath.substring(0,fpath.lastIndexOf("/")+1);
	var filenew = fpath.substring(fpath.lastIndexOf("/")+1);
	var is_entity = {};
	is_entity.FIELD_FILE_NAME = fileOld;
	is_entity.FIELD_FILE_SVAE_NAME = filenew;
	is_entity.FIELD_FILE_SAVE_PATH = filePath;
	var v_result = uploadfileModule.uploadfileActAction.insertUploadfile(is_entity);
	$('#list').datagrid('reload'); 
	$.messager.alert('提示',"上传成功!",'info');
}
/****/

/**
 * 序号:16
 * 功能:下载
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function downloadjw(index){
   $('#list').datagrid('selectRow',index);
	
   var is_row = $('#list').datagrid('getSelections');
   $('#list').datagrid('clearSelections');
	
//   if(is_row[0].EXIST_FILE!=null && is_row[0].EXIST_FILE == '0'){
//	  $.messager.alert('提示',"没有文件可以下载!",'info');
//	  return;
//   }
   var uploadnew = is_row[0].FILE_SVAE_NAME;
   var uploadpath = is_row[0].FILE_SAVE_PATH;
   var uploadold = is_row[0].FILE_NAME;
   var uuid = is_row[0].UUID;
   if(uploadpath == null || uploadpath == ""){
      $.messager.alert('提示',"没有文件可以下载!",'info');
      return;
   }
//   var url = gaowj.WEB_APP_NAME + "/reportact_download?uploadnew="+uploadnew+"&uploadpath="+uploadpath+"&uploadold="+uploadold;
//   window.location = url;
   fileDownload(uploadnew,uploadpath,uploadold,uuid,'uploadFileAct_download');
}
/****/

/**
 * 序号:17
 * 功能:批量处理附件大字段数据(0清空大字段数据,1存储大字段数据)
 * 参数:
 * 说明:
 * 作者:高伟杰
 * 时间:2016-01-22
 * 单位:宁波金网
 * 备注:需更改
 **/
function setUploadFileBatchRow(lsKey){
	var code="";
	var rows = $('#list').datagrid('getSelections');
	for(var i=0; i<rows.length; i++){
		code = code + rows[i].UUID+",";
	}
	if(rows == null || rows == ""){
		$.messager.alert('提示',"请选择需处理的记录!",'info');
		return;
	}
	if(code.length>0){
		code = code.substring(0,code.length - 1);
	}
	$.messager.confirm('提示', '确定处理记录?', function(r) {
		if (r) {
			var v_query = {};
		    v_query.FIELD_CODE = code;
		    v_query.FIELD_SETKEY = lsKey;
		    var v_result = uploadfileModule.uploadfileActAction.setUploadfile(v_query);
			$.messager.alert('提示',v_result.VALUE);
			$('#list').datagrid('reload');
		}
	});
}
/****/