/** * Created by TT on 2017/7/7. */ ; spa_define(function () { return $.use(["spa", "util", "form", "code"], function (spa, util, fb, code) { return { modal: function (data) { var root = spa.findInModal(".sys_userinfo_details"); var ca = {ready: true, items: []}; var dp = code.parseCode(root.find(".dt-project")); var dh = code.parseCode(root.find(".dt-honor")); var dj = code.parseCode(root.find(".dt-job")); var de = code.parseCode(root.find(".dt-edu")); var form = fb.build(root.find(".newForm"), { industryList: ca, subjectList: ca, researchAreaList: ca }); var oValue; var oJudge; var trim = function (str) { //删除左右两端的空格    return str.replace(/(^\s*)|(\s*$)/g, ""); }; var saveBtn = root.find(".opt-save"), save = function () { form.val({ industry: oString(form.val().industryList), subject: oString(form.val().subjectList), researchArea: form.val().researchAreaList, subjectList: "", industryList: "", researchAreaList: "" }); if (form.val().title) { var title = form.val().title; if (title.length > 20) { util.alert("职称不得超过20个字"); return; } } if (form.val().office) { var office = form.val().office; if (office.length > 20) { util.alert("职位不得超过20个字"); return; } } if (form.val().orgName) { var orgName = form.val().orgName; if (orgName.length > 50) { util.alert("所在机构不得超过50个字"); return; } } if (form.val().department) { var department = form.val().department; if (department.length > 20) { util.alert("所在部门不得超过20个字"); return; } } if (form.val().descp) { var descp = trim(form.val().descp); if (descp.length > 500) { util.alert("个人简介不得超过500个字"); } } if (form.val().mobile) { var mobile = form.val().mobile; if (mobile) { if (mobile.length > 50) { util.alert('提示', '联系电话不得超过50个字'); return; } } } if (form.val().email) { var email = form.val().email; var gunf = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; if (!gunf.test(email)) { util.alert("联系邮箱格式有误,请检查后重新填写"); return; } } if (form.val().name) { var name = form.val().name; if (name.length > 10) { util.alert("姓名最长为10个字"); return; } } if (form.val().name == null) { util.alert("请输入专家姓名"); } else if (form.val().mobile || form.val().email) { form.doPut("../ajax/userinfo/update", function () { spa.closeModal(); if (data.hand) { data.hand(); } }, function (data) { util.alert(data.msg); }); } else { util.alert("手机或邮箱至少输入一项"); } }; var part = function (one, list) { oValue = one; oJudge = list || []; var repeat, b; if (!oValue) { util.alert('提示', '请先填写内容'); return; } if (oValue.length > 15) { util.alert('提示', '添加内容不能超过15个字'); return; } else { var oValueList = oValue.split(","), length = oValueList.length; for (var m = 0;m 30) { util.alert('提示', '添加内容不能超过30个字'); return; } else { var oValueList = oValue.split(","), length = oValueList.length; for (var m = 0;m