123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- $(document).ready(function() {
- var id = $.cookie('orgId');
- var fileId = null;
- var cacheImageKey = null;
-
- function companyInformation() {
- $.ajax({
- url: "/ajax/org/" + id,
- type: "GET",
- timeout: 10000,
- dataType: "json",
- beforeSend: function() {},
- success: function(data, textState) {
- if(data.success) {
- console.log(data);
- var $data = data.data;
- $(".h1Font").text($data.name);
- if($data.hasOrgLogo) {
- $("#oimg").attr("src", "/images/org/" + $data.id + ".jpg");
- }
- if($data.orgUrl) {
- $("#inteAddress").val($data.orgUrl);
- } else {
- $("#inteAddress").val("");
- }
- if($data.forShort) {
- $("#businessAbbreviation").val($data.forShort);
- } else {
- $("#businessAbbreviation").val("");
- }
- if($data.foundTime) {
- var oTime = timeGeshi($data.foundTime);
- $("#createTime").val(oTime);
- } else {
- $("#createTime").val("");
- }
- if($data.province) {
- $("#oprovince").text($data.province);
- } else {
- $("#oprovince").text("请选择企业总部所在省或直辖市");
- }
- if($data.city) {
- $("#ocity").text($data.city);
- } else {
- $("#ocity").text("请选择企业总部所在城市");
- }
- if($data.descp) {
- $("textarea").val($data.descp);
- }
- if($data.orgSize) {
- $("#qualificationList").find("li").removeClass("cmpBg listactive");
- switch($data.orgSize) {
- case '1':
- $("#qualificationList").find("li").eq(0).addClass("cmpBg listactive");
- break;
- case '2':
- $("#qualificationList").find("li").eq(1).addClass("cmpBg listactive")
- break;
- case '3':
- $("#qualificationList").find("li").eq(2).addClass("cmpBg listactive")
- break;
- case '4':
- $("#qualificationList").find("li").eq(3).addClass("cmpBg listactive")
- break;
- case '5':
- $("#qualificationList").find("li").eq(4).addClass("cmpBg listactive")
- break;
- default:
- $("#qualificationList").find("li").eq(5).addClass("cmpBg listactive")
- break;
- }
- }
- if($data.orgType) {
- $("#orgType").find("li").removeClass("cmpBg listactive");
- switch($data.orgType) {
- case '2':
- $("#orgType").find("li").eq(0).addClass("cmpBg listactive");
- break;
- case '3':
- $("#orgType").find("li").eq(1).addClass("cmpBg listactive")
- break;
- case '4':
- $("#orgType").find("li").eq(2).addClass("cmpBg listactive")
- break;
- case '5':
- $("#orgType").find("li").eq(3).addClass("cmpBg listactive")
- break;
- case '6':
- $("#orgType").find("li").eq(4).addClass("cmpBg listactive")
- break;
- default:
- $("#orgType").find("li").eq(5).addClass("cmpBg listactive")
- break;
- }
- }
- if($data.industry) {
- indu($data.industry, '#industryList')
- }
- if($data.subject) {
- indu($data.subject, '#subjectList')
- }
- if($data.qualification) {
- indu($data.qualification, '.editUlistC ')
- }
- }
- },
- error: function(XMLHttpRequest, textStats, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- })
- }
- companyInformation()
-
- function timeGeshi(otm) {
- var otme = otm.substring(0, 4) + "-" + otm.substring(4, 6) + "-" + otm.substring(6, 8);
- return otme;
- }
-
- function limitFont(e) {
- var pastedText;
- if (window.clipboardData && window.clipboardData.getData) {
-
- pastedText = $("textarea").val() + window.clipboardData.getData('Text');
- }
- else {
- pastedText = $("textarea").val() + e.originalEvent.clipboardData.getData('Text');
-
- }
- $("textarea").val(pastedText.substring(0, 300));
- }
- $("textarea").bind({
- paste: function(e) {
- limitFont(e);
- setTimeout(function() {
- $(".limitNum").find("span").text(300 - $("textarea").val().length);
- }, 1);
- e.preventDefault();
- },
- cut: function(e) {
- setTimeout(function() {
- $(".limitNum").find("span").text(300 - $("textarea").val().length);
- }, 1);
- },
- keyup: function(e) {
- if($("textarea").val().length > 300) {
- $("textarea").val($("textarea").val().substring(0, 300));
- e.preventDefault();
- }
- setTimeout(function() {
- $(".limitNum").find("span").text(300 - $("textarea").val().length);
- }, 1);
- }
- });
-
- function indu(oString, oSelector) {
- var arr = oString.split(",");
- var oArr = new Array();
- var i;
- for(i in arr) {
- oArr.push('<li>' + arr[i] + '<img src="images/con_icon_delete.png" /></li>');
- }
- $(oSelector).html(oArr.join(""));
- }
-
- $("body").on("click", "li img", function() {
- $(this).parent().remove();
- })
-
- $("button:contains('添加')").click(function() {
- var oValue = $(this).parent().siblings(".col-w-10").children("input").val().trim();
- var oJudge = $(this).parent().siblings("ul").find("li");
- if(!oValue) {
- $.MsgBox.Alert('提示', '请先填写内容');
- return;
- }
- if(oValue.length > 10) {
- $.MsgBox.Alert('提示', '添加内容不能超过10个字');
- return;
- }
- for(var i = 0; i < oJudge.length; i++) {
- if(oValue == oJudge[i].innerText) {
- $.MsgBox.Alert('提示', '添加内容不能重复');
- return;
- }
- }
- $(this).parent().siblings("ul").append('<li>' + oValue + '<img src="images/con_icon_delete.png" /></li>');
- $(this).parent().siblings(".col-w-10").children("input").val("");
- })
-
- $("#orgType,#qualificationList").on("click", "li", function() {
- var oClassName = $(this).addClass("cmpBg listactive").siblings().removeClass("cmpBg listactive");
- })
-
- $("button:contains('保存')").click(function() {
- var oBusinessAbbreviation = $("#businessAbbreviation").val().trim();
- var oTextArea = $("textarea").val().trim();
- var oBusinessType = $("#orgType").find("li.cmpBg.listactive").length;
- var oBusinessDimensions = $("#qualificationList").find("li.cmpBg.listactive").length;
- var oIndustryNumber = $("#industryList").find("li").length;
- var oSubjectNumber = $("#subjectList").find("li").length;
- var oEditUlistCNumber = $(".editUlistC ").find("li").length;
- if(!oBusinessAbbreviation) {
- $.MsgBox.Alert('提示', '企业简称不能为空');
- return;
- }
- if(oBusinessAbbreviation.length > 10) {
- $.MsgBox.Alert('提示', '企业简称不能超过10个字');
- return;
- }
- if(!oTextArea) {
- $.MsgBox.Alert('提示', '企业简介不能为空');
- return;
- }
- if(oBusinessType == 0) {
- $.MsgBox.Alert('提示', '请选择企业类型');
- return;
- }
- if(oIndustryNumber == 0) {
- $.MsgBox.Alert('提示', '企业所属行业必填一项');
- return;
- }
- if(oSubjectNumber == 0) {
- $.MsgBox.Alert('提示', '企业所属领域必填一项');
- return;
- }
- if(oBusinessDimensions == 0) {
- $.MsgBox.Alert('提示', '请选择企业规模');
- return;
- }
- if(oEditUlistCNumber == 0) {
- $.MsgBox.Alert('提示', '企业资质必填一项');
- return;
- }
-
- fn: 企业logo上传临时文件名 NULL 字符串*/
- var tex = $("#orgType").find("li.cmpBg.listactive").text();
- var oTextGui = $("#qualificationList").find("li.cmpBg.listactive").text();
- var $info = {};
- $info.id = id;
- if(cacheImageKey != null) {
- $info.fn = cacheImageKey;
- }
- $info.forShort = $("#businessAbbreviation").val();
- switch(tex) {
- case '上市企业':
- $info.orgType = 2;
- break;
- case '国有企业':
- $info.orgType = 3;
- break;
- case '合资企业':
- $info.orgType = 4;
- break;
- case '私人企业':
- $info.orgType = 5;
- break;
- case '外资企业':
- $info.orgType = 6;
- break;
- default:
- $info.orgType = 7;
- break;
- }
- switch(oTextGui) {
- case '50人以内':
- $info.orgSize = 1;
- break;
- case '50-100人':
- $info.orgSize = 2;
- break;
- case '100-200人':
- $info.orgSize = 3;
- break;
- case '200-500人':
- $info.orgSize = 4;
- break;
- case '500-1000人':
- $info.orgSize = 5;
- break;
- default:
- $info.orgSize = 6;
- break;
- }
- if($("#inteAddress").val().trim()) {
- $info.orgUrl = $("#inteAddress").val();
- }
- if($("#oprovince").text() != "请选择企业总部所在省或直辖市") {
- $info.province = $("#oprovince").text();
- }
- if($("#ocity").text() != "请选择企业总部所在城市") {
- $info.city = $("#ocity").text();
- }
- if($("#createTime").val()) {
- $info.foundTime = st6($("#createTime").val());
- }
- $info.descp = $("textarea").val();
- $info.industry = oString("#industryList");
- $info.subject = oString("#subjectList");
- $info.qualification = oString(".editUlistC");
- $.ajax({
- url: "/ajax/org/update",
- type: "POST",
- data: $info,
- timeout: 10000,
- dataType: "json",
- beforeSend: function() {},
- success: function(data, textState) {
- if(data.success) {
- $.MsgBox.Alert('提示', '修改成功');
- }
- },
- error: function(XMLHttpRequest, textStats, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败')
- }
- })
- })
-
- function oString(sele) {
- var len = $(sele).find("li");
- var arry = new Array();
- for(var i = 0; i < len.length; i++) {
- arry.push(len[i].innerText);
- }
- return arry.join(",");
- }
-
- function st6(osr) {
- var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10);
- return tim;
- }
-
- var uploader = WebUploader.create({
- auto: true,
- fileNumLimit: 1,
- swf: '../js/webuploader/Uploader.swf',
- server: '../ajax/cachedFileUpload',
- fileSingleSizeLimit: 5 * 1024 * 1024,
- pick: {
- id: "#filePicker",
- multiple: false
- },
- accept: {
- title: 'Images',
- extensions: 'jpg,jpeg,png',
- mimeTypes: 'image/*'
- }
- });
-
- uploader.on('fileQueued', function(file) {
- fileId = file.id;
- var $li = $('<div id="' + file.id + '" class="file-item thumbnail">' + '<img>' + '</div>')
- $img = $li.find('img');
- var $list = $('#fileList');
-
- var fileNameAll = file.name;
- var AllImgExt = ".jpg|.jpeg|.png|";
- var extName = fileNameAll.substring(fileNameAll.lastIndexOf(".")).toLowerCase();
- if(AllImgExt.indexOf(extName + "|") == -1) {
- var ErrMsg = "该文件类型不允许上传。请上传 " + AllImgExt + " 类型的文件,当前文件类型为" + extName;
- $.MsgBox.Alert('提示', ErrMsg);
- return false;
- }
- });
- uploader.onError = function( code ) {
- $.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过5M')
- };
- uploader.on('uploadSuccess', function(file, data) {
- uploader.removeFile(fileId);
- cacheImageKey = data.data[0].cacheKey;
- $("#oimg").attr("src", "/images/tmp/" + cacheImageKey);
- });
-
- $("#Ocancel").click(function() {
- fileId = null;
- cacheImageKey = null;
- companyInformation();
- })
-
-
- $(document).on("click", "#City li a", function() {
- var aVal = $(this).text();
- $(this).parent().parent().parent().find('.mr_show').text(aVal);
- $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
- });
- })
|