| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- $(function () {
- $("#allBuilds").click(function () {
- if (this.checked) {
- $("#pushBuildsList :checkbox").prop("checked", true);
- } else {
- $("#pushBuildsList :checkbox").prop("checked", false);
- }
- });
- $("#form-notify-edit").validate({
- rules: {
- title: {
- required: true,
- maxlength: 255
- },
- content: {
- required: true
- },
- type: {
- required: true
- }
- },
- onkeyup: false,
- focusCleanup: true,
- success: "valid",
- submitHandler: function (form) {
- // $(form).find(":submit").attr("disabled", true);
- if ($("#isPush").val() == "true") {
- if ($("#pushStreetIds").val() == "" && $("#pushBuildIds").val() == "" && $("#pushCompanyIds").val() == "") {
- sadMessage("请选择推送单位!");
- return false;
- }
- }
- //如果摘要没填写,取正文前50个字
- if($.trim($("#notify_abstract").val())==""){
- var content = $("#content").val();
- if($.trim(content)!=""){
- var defaultAbstract = "";
- //去除标签
- var cleanContent = content.replace(/<\/?.+?>/g,""); //去标签
- cleanContent = cleanContent.replace(/(^\s+)|(\s+$)/g,""); //去空格
- cleanContent = cleanContent.replace(/(\r)|(\n)/g,""); //去回车
- cleanContent = cleanContent.replace(/ /ig,''); //去掉
- if(cleanContent.length>50){
- defaultAbstract = cleanContent.substring(0,50);
- defaultAbstract += "...";
-
- }else{
- defaultAbstract = cleanContent;
- }
- $("#notify_abstract").val(defaultAbstract);
- }
- }
- $(form).ajaxSubmit({
- type: 'post',
- url: pagePath + "/government/notify/update",
- dataType: "json",
- data: {
- isPush: $("#isPush").val()
- },
- success: function (result) {
- if (result.success) {
- succeedMessage(result.message);
- setTimeClose();
- } else {
- // $(form).find(":submit").attr("disabled", false);
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- },
- errorPlacement: function (error, element) {
- if (element.attr('id') == 'content') {
- error.addClass(' label_error')
- }
- error.appendTo(element.parent());
- }
- });
- });
- function getPushBuildsIds() {
- var chlength = $('#pushBuildsList').find('input[type="checkbox"]:checked').length;
- var build_ids = '';
- $('#pushBuildsList').find('input[type="checkbox"]:checked').each(function (i, item) {
- build_ids = build_ids + $(this).attr("value") + ",";
- });
- build_ids = build_ids.substring(0, build_ids.length - 1);
- return build_ids;
- }
- function sendNotify() {
- $("#isPush").val(true);
- if ($("#pushStreetIds").val() == "" && $("#pushBuildIds").val() == "" && $("#pushCompanyIds").val() == "") {
- sadMessage("请选择推送单位!");
- return false;
- }
- }
- /*
- 参数解释:
- title 标题
- url 请求的url
- id 需要操作的数据id
- w 弹出层宽度(缺省调默认值)
- h 弹出层高度(缺省调默认值)
- */
- /*管理员-*/
- function notify_addPush(title, url, w, h) {
- layer_show(title, pagePath + url, w, h);
- }
|