123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- $(document).ready(function() {
- $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
- var id = $.cookie('orgId');
- if(id == "" || id == null || id == "null") {
- location.href = "cmp-settled-log.html";
- }
- 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").val($data.orgSize)
- }
- if($data.orgType) {
- $("#orgType").val($data.orgType)
- }
- if($data.industry) {
- indu($data.industry, '#industryList')
- }
- if($data.subject) {
- indu($data.subject, '#subjectList')
- }
- if($data.qualification) {
- indu($data.qualification, '.editUlistC')
- }
- if($data.fieldOfSupplier) {
- indu($data.fieldOfSupplier, '#subjectListOut')
- }
- if($data.fieldOfCustomer) {
- indu($data.fieldOfCustomer, '#subjectListIn')
- }
- if($data.addr) {
- $("#cmpAddress").val($data.addr);
- }
- if($data.contactNum) {
- $("#phone").val($data.contactNum);
- }
- if($data.email) {
- $("#mail").val($data.email);
- }
-
- if($("#oprovince").text() == "请选择企业总部所在省或直辖市") {
- $("#oprovince").removeClass("mr_select");
- } else {
- $("#oprovince").addClass("mr_select");
- }
- if($("#ocity").text() == "请选择企业总部所在城市") {
- $("#ocity").removeClass("mr_select");
- } else {
- $("#ocity").addClass("mr_select");
- }
- }
- },
- 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, 500));
- }
- $("textarea").bind({
- paste: function(e) {
- limitFont(e);
- setTimeout(function() {
- $(".limitNum").text($("textarea").val().length);
- }, 1);
- e.preventDefault();
- },
- cut: function(e) {
- setTimeout(function() {
- $(".limitNum").text($("textarea").val().length);
- }, 1);
- },
- keyup: function(e) {
- if($("textarea").val().length > 500) {
- $("textarea").val($("textarea").val().substring(0, 500));
- e.preventDefault();
- }
- setTimeout(function() {
- $(".limitNum").text($("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] + '<div class="closeThis"></div></li>');
- }
- $(oSelector).html(oArr.join(""));
- }
-
- $("body").on("click", ".closeThis", function() {
- if($(this).parent().length < 5) {
- $(this).parents(".keyResult").siblings("div").show();
- }
- $(this).parent().remove();
- })
-
- $("button:contains('添加')").click(function() {
- var oValue = $(this).siblings("input").val().trim();
- var oJudge = $(this).parent().siblings().find("ul.ulspace 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().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
- $(this).hide();
- $(this).siblings("input").val("");
- if(oJudge.length == 4) {
- $(this).val("").parents(".col-w-12").hide();
- }
- $(this).siblings(".keydrop").find("ul").html("");
- })
-
- $("button:contains('保存')").click(function() {
- var oBusinessAbbreviation = $("#businessAbbreviation").val().trim();
- if(!oBusinessAbbreviation) {
- $.MsgBox.Alert('提示', '企业简称不能为空');
- return;
- }
- if(oBusinessAbbreviation.length > 10) {
- $.MsgBox.Alert('提示', '企业简称不能超过10个字');
- return;
- }
-
- var oTextArea = $("textarea").val().trim();
- var oBusinessType = $("#orgType").find("option").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(!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;
- }*/
- var $info = {};
- $info.id = id;
- if(cacheImageKey != null) {
- $info.fn = cacheImageKey;
- }
- $info.forShort = $("#businessAbbreviation").val();
- if($("#orgType").find("option:selected").text() != "请选择最符合的一项") {
- $info.orgType = $("#orgType").find("option:selected").text()
- }
- if($("#qualificationList").find("option:selected").text() != "请选择员工数量范围") {
- $info.orgSize = $("#qualificationList").find("option:selected").text();
- }
- if($("#inteAddress").val().trim()) {
- if($("#inteAddress").val().trim().length > 20) {
- $.MsgBox.Alert('提示', '企业官网 20个字之内!');
- return;
- }
- $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());
- }
- if($("#cmpAddress").val().trim()) {
- if($("#cmpAddress").val().trim().length > 20) {
- $.MsgBox.Alert('提示', '企业地址 20个字之内!');
- return;
- } else {
- $info.addr = $("#cmpAddress").val();
- }
- }
- if($("#phone").val().trim()) {
- if($("#phone").val().trim().length > 50) {
- $.MsgBox.Alert('提示', '办公电话50个字之内!');
- return;
- } else {
- $info.contactNum = $("#cmpAddress").val();
- }
- }
- if($("#mail").val().trim()) {
- if($("#mail").val().trim().indexOf("@")) {
- $info.email = $("#mail").val();
- } else {
- $.MsgBox.Alert('提示', '邮箱格式不正确');
- return;
- }
- }
- $info.descp = $("textarea").val();
- $info.industry = oString("#industryList");
- $info.subject = oString("#subjectList");
- $info.qualification = oString(".editUlistC");
- $info.fieldOfCustomer=oString(subjectListIn);
- $info.fieldOfSupplier==oString(subjectListOut);
- $.ajax({
- url: "/ajax/org/update",
- type: "POST",
- data: $info,
- timeout: 10000,
- dataType: "json",
- beforeSend: function() {},
- success: function(data, textState) {
- if(data.success) {
- $.MsgBox.Alert('提示', '修改成功');
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
- setTimeout(function() {
- location.reload(false)
- }, 500);
- }
- },
- 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/gif,image/jpg,image/jpeg,image/bmp,image/png'
- }
- });
-
- 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() {
- location.href = "cmp-workspaces.html"
- })
-
- $(document).on("click", "#Province li a", function() {
- var aVal = $(this).text();
- $(this).parent().parent().parent().find('.mr_show').text(aVal);
- $(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
- if($("#oprovince").text() == "请选择企业总部所在省或直辖市") {
- $("#oprovince").removeClass("mr_select");
- $("#ocity").removeClass("mr_select");
- } else {
- $("#oprovince").addClass("mr_select");
- $("#ocity").removeClass("mr_select");
- }
- });
-
- $(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);
- if($("#ocity").text() == "请选择企业总部所在城市") {
- $("#ocity").removeClass("mr_select");
- } else {
- $("#ocity").addClass("mr_select");
- }
- });
- })
|