Browse Source

企业编辑修改

jack 8 years ago
parent
commit
21fb7c07fb
2 changed files with 62 additions and 47 deletions
  1. 2 2
      cmp-portal/cmp-updateinfo.html
  2. 60 45
      cmp-portal/js/cmp-updateinfo.js

+ 2 - 2
cmp-portal/cmp-updateinfo.html

@ -84,7 +84,7 @@
84 84
													<div class="col-w-6 citybox">
85 85
														<span class="frmtype frmtypeW" id="City" >
86 86
				                                       		<em class="mr_sj"></em>
87
				                                            <i class="mr_show" id="oCity">请选择企业总部所在城市</i>
87
				                                            <i class="mr_show" id="ocity">请选择企业总部所在城市</i>
88 88
				                                            <ul>
89 89
				                                                <li><a href="javascript:void(0)" alt="请选择企业总部所在城市">请选择企业总部所在城市</a></li>
90 90
				                                            </ul>
@ -170,7 +170,7 @@
170 170
										</li>
171 171
										<li>
172 172
											<div class="col-w-6 paddingSpace" style="text-align: right;"><button type="button" class="frmtype btnModel headRadius save-block">保存</button></div>
173
											<div class="col-w-6 paddingSpace"><button type="button" class="frmtype btnModel btnCancel headRadius save-block">取消</button></div>
173
											<div class="col-w-6 paddingSpace"><button type="button" class="frmtype btnModel btnCancel headRadius save-block" id="Ocancel">取消</button></div>
174 174
										</li>
175 175
									</ul>
176 176
			            		</div>

+ 60 - 45
cmp-portal/js/cmp-updateinfo.js

@ -1,5 +1,7 @@
1 1
$(document).ready(function() {
2 2
	var id = "05FBD2E6F568461CA7EC378E66C47ABE";
3
	var fileId = null;
4
	var cacheImageKey = null;
3 5
	/*企业信息*/
4 6
	function companyInformation() {
5 7
		$.ajax({
@ -10,33 +12,43 @@ $(document).ready(function() {
10 12
			beforeSend: function() {},
11 13
			success: function(data, textState) {
12 14
				if(data.success) {
13
					console.log(data);
15
					//console.log(data);
14 16
					var $data = data.data;
15 17
					$(".h1Font").text($data.name);
16
					if($data.orgUrl) {
17
						$("#inteAddress").val($data.orgUrl);
18
					if($data.hasOrgLogo) {
19
						$("#oimg").attr("src", "/images/org/" + $data.id + ".jpg");
18 20
					}
19 21
					if($data.orgUrl) {
20 22
						$("#inteAddress").val($data.orgUrl);
23
					} else {
24
						$("#inteAddress").val("");
21 25
					}
22 26
					if($data.forShort) {
23 27
						$("#businessAbbreviation").val($data.forShort);
28
					} else {
29
						$("#businessAbbreviation").val("");
24 30
					}
25 31
					if($data.foundTime) {
26 32
						var oTime = timeGeshi($data.foundTime);
27 33
						$("#createTime").val(oTime);
34
					} else {
35
						$("#createTime").val("");
28 36
					}
29 37
					if($data.province) {
30 38
						$("#oprovince").text($data.province);
39
					} else {
40
						$("#oprovince").text("请选择企业总部所在省或直辖市");
31 41
					}
32 42
					if($data.city) {
33
						$("#oCity").text($data.city);
43
						$("#ocity").text($data.city);
44
					} else {
45
						$("#ocity").text("请选择企业总部所在城市");
34 46
					}
35 47
					if($data.descp) {
36 48
						$("textarea").val($data.descp);
37 49
					}
38 50
					if($data.orgSize) {
39

51
						$("#qualificationList").find("li").removeClass("cmpBg listactive");
40 52
						switch($data.orgSize) {
41 53
							case '1':
42 54
								$("#qualificationList").find("li").eq(0).addClass("cmpBg listactive");
@ -59,6 +71,7 @@ $(document).ready(function() {
59 71
						}
60 72
					}
61 73
					if($data.orgType) {
74
						$("#orgType").find("li").removeClass("cmpBg listactive");
62 75
						switch($data.orgType) {
63 76
							case '2':
64 77
								$("#orgType").find("li").eq(0).addClass("cmpBg listactive");
@ -147,7 +160,6 @@ $(document).ready(function() {
147 160
		for(i in arr) {
148 161
			oArr.push('<li>' + arr[i] + '<img src="images/con_icon_delete.png" /></li>');
149 162
		}
150
		console.log(oArr.join(","));
151 163
		$(oSelector).html(oArr.join(""));
152 164
	}
153 165
	/*删除*/
@ -226,6 +238,9 @@ $(document).ready(function() {
226 238
			var oTextGui = $("#qualificationList").find("li.cmpBg.listactive").text();
227 239
			var $info = {};
228 240
			$info.id = id;
241
			if(cacheImageKey != null) {
242
				$info.fn = cacheImageKey;
243
			}
229 244
			$info.forShort = $("#businessAbbreviation").val();
230 245
			switch(tex) {
231 246
				case '上市企业':
@ -273,8 +288,8 @@ $(document).ready(function() {
273 288
			if($("#oprovince").text() != "请选择企业总部所在省或直辖市") {
274 289
				$info.province = $("#oprovince").text();
275 290
			}
276
			if($("#oCity").text() != "请选择企业总部所在城市") {
277
				$info.city = $("#oCity").text();
291
			if($("#ocity").text() != "请选择企业总部所在城市") {
292
				$info.city = $("#ocity").text();
278 293
			}
279 294
			if($("#createTime").val()) {
280 295
				$info.foundTime = st6($("#createTime").val());
@ -292,8 +307,7 @@ $(document).ready(function() {
292 307
				beforeSend: function() {},
293 308
				success: function(data, textState) {
294 309
					if(data.success) {
295
						alert(11)
296
						companyInformation();
310

297 311
					}
298 312
				},
299 313
				error: function(XMLHttpRequest, textStats, errorThrown) {
@ -316,20 +330,19 @@ $(document).ready(function() {
316 330
		return tim;
317 331
	}
318 332
	/*企业图片上传*/
319
	var fileId = null;
320
	var cacheImageKey=null;
321 333
	var uploader = WebUploader.create({
322 334
		auto: true,
323 335
		fileNumLimit: 1,
324 336
		swf: '../js/webuploader/Uploader.swf',
325 337
		server: '../ajax/cachedFileUpload',
338
		fileSingleSizeLimit: 50 * 1024 * 1024,
326 339
		pick: {
327 340
			id: "#filePicker",
328 341
			multiple: false
329 342
		},
330 343
		accept: {
331 344
			title: 'Images',
332
			extensions: 'gif,jpg,jpeg,bmp',
345
			extensions: 'jpg,jpeg,png',
333 346
			mimeTypes: 'image/*'
334 347
		}
335 348

@ -338,49 +351,51 @@ $(document).ready(function() {
338 351
	// 当有文件添加进来的时候
339 352
	uploader.on('fileQueued', function(file) {
340 353
		fileId = file.id;
341
		var $li = $('<div id="' + file.id + '" class="file-item thumbnail">' +'<img>' +'</div>')
354
		var $li = $('<div id="' + file.id + '" class="file-item thumbnail">' + '<img>' + '</div>')
342 355
		$img = $li.find('img');
343 356
		var $list = $('#fileList');
344
		// 创建缩略图
345
		// 如果为非图片文件,可以不用调用此方法。
346
		// thumbnailWidth x thumbnailHeight 为 100 x 100
347
		uploader.makeThumb(file, function(error, src) {
348
			if(error) {
349
				$img.replaceWith('<span>不能预览</span>');
350
				return;
351
			}
352

353
		}, 240, 240);
354

355 357
		//判断上传文件格式
356
		 var fileNameAll = file.name;
357
		    var AllImgExt=".jpg|.jpeg|.gif|.bmp|.png|";
358
		    var extName = fileNameAll.substring(fileNameAll.lastIndexOf(".")).toLowerCase();//(把路径中的所有字母全部转换为小写)
359
	        if(AllImgExt.indexOf(extName+"|")==-1){
360
	            var ErrMsg="该文件类型不允许上传。请上传 "+AllImgExt+" 类型的文件,当前文件类型为"+extName;
361
	            $.MsgBox.Alert('提示',ErrMsg);
362
	            return false;
363
	        }
358
		var fileNameAll = file.name;
359
		console.log(fileNameAll)
360
		var AllImgExt = ".jpg|.jpeg|.png|";
361
		var extName = fileNameAll.substring(fileNameAll.lastIndexOf(".")).toLowerCase(); //(把路径中的所有字母全部转换为小写)
362
		console.log(extName)
363
		if(AllImgExt.indexOf(extName + "|") == -1) {
364
			var ErrMsg = "该文件类型不允许上传。请上传 " + AllImgExt + " 类型的文件,当前文件类型为" + extName;
365
			$.MsgBox.Alert('提示', ErrMsg);
366
			return false;
367
		}
364 368

365 369
	});
366 370

367
	uploader.on( 'uploadError', function( file ) {
368
		alert(file);
369
    var $li = $( '#'+file.id ),
370
        $error = $li.find('div.error');
371
	uploader.on('uploadError', function(file) {
372
		var $li = $('#' + file.id),
373
			$error = $li.find('div.error');
374

375
		// 避免重复创建
376
		if(!$error.length) {
377
			$error = $('<div class="error"></div>').appendTo($li);
378
		}
371 379

372
    // 避免重复创建
373
    if ( !$error.length ) {
374
        $error = $('<div class="error"></div>').appendTo( $li );
375
    }
380
		$error.text('上传失败');
376 381

377
    $error.text('上传失败');
378
    
379
});
382
	});
380 383
	uploader.on('uploadSuccess', function(file, data) {
381 384
		uploader.removeFile(fileId);
382 385
		cacheImageKey = data.data[0].cacheKey;
383 386
		$("#oimg").attr("src", "/images/tmp/" + cacheImageKey);
384 387
	});
385

388
	/*取消*/
389
	$("#Ocancel").click(function() {
390
			fileId = null;
391
			cacheImageKey = null;
392
			companyInformation();
393
		})
394
		/*选择城市*/
395
		/*选择城市填充js	*/
396
	$(document).on("click", "#City li a", function() {
397
		var aVal = $(this).text();
398
		$(this).parent().parent().parent().find('.mr_show').text(aVal);
399
		$(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
400
	});
386 401
})