From 1a0c0fc8b02415e919e17c0b6ffbf99d08dec8f5 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 07 四月 2023 17:40:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 management/guns-admin/src/main/webapp/static/modular/system/tBroadcast/tBroadcast_info.js |   68 ++++++++++++++++++++++++++++++----
 1 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/management/guns-admin/src/main/webapp/static/modular/system/tBroadcast/tBroadcast_info.js b/management/guns-admin/src/main/webapp/static/modular/system/tBroadcast/tBroadcast_info.js
index 54f4bdf..af3a5f2 100644
--- a/management/guns-admin/src/main/webapp/static/modular/system/tBroadcast/tBroadcast_info.js
+++ b/management/guns-admin/src/main/webapp/static/modular/system/tBroadcast/tBroadcast_info.js
@@ -2,7 +2,39 @@
  * 初始化详情对话框
  */
 var TBroadcastInfoDlg = {
-    tBroadcastInfoData : {}
+    tBroadcastInfoData : {},
+    validateFields: {
+        content: {
+            validators: {
+                notEmpty: {
+                    message: '消息内容不能为空'
+                }
+            }
+        },
+        sort: {
+            validators: {
+                notEmpty: {
+                    message: '排序不能为空'
+                }
+            }
+        },
+        show: {
+            validators: {
+                notEmpty: {
+                    message: '请选择是否显示'
+                }
+            }
+        },
+    }
+};
+
+/**
+ * 验证数据是否为空
+ */
+TBroadcastInfoDlg.validate = function () {
+    $('#broadcastInfoForm').data("bootstrapValidator").resetForm();
+    $('#broadcastInfoForm').bootstrapValidator('validate');
+    return $("#broadcastInfoForm").data('bootstrapValidator').isValid();
 };
 
 /**
@@ -49,6 +81,8 @@
     .set('content')
     .set('sort')
     .set('status')
+    .set('show')
+    .set('upDown')
     .set('createTime');
 }
 
@@ -60,11 +94,20 @@
     this.clearData();
     this.collectData();
 
+    if(!this.validate()){
+        return ;
+    }
+
     //提交信息
     var ajax = new $ax(Feng.ctxPath + "/tBroadcast/add", function(data){
-        Feng.success("添加成功!");
-        window.parent.TBroadcast.table.refresh();
-        TBroadcastInfoDlg.close();
+        if(500 == data.code){
+            Feng.error(data.message);
+            return;
+        }else {
+            Feng.success("添加成功!");
+            window.parent.TBroadcast.table.refresh();
+            TBroadcastInfoDlg.close();
+        }
     },function(data){
         Feng.error("添加失败!" + data.responseJSON.message + "!");
     });
@@ -80,11 +123,20 @@
     this.clearData();
     this.collectData();
 
+    if(!this.validate()){
+        return ;
+    }
+
     //提交信息
     var ajax = new $ax(Feng.ctxPath + "/tBroadcast/update", function(data){
-        Feng.success("修改成功!");
-        window.parent.TBroadcast.table.refresh();
-        TBroadcastInfoDlg.close();
+        if(500 == data.code){
+            Feng.error(data.message);
+            return;
+        }else {
+            Feng.success("修改成功!");
+            window.parent.TBroadcast.table.refresh();
+            TBroadcastInfoDlg.close();
+        }
     },function(data){
         Feng.error("修改失败!" + data.responseJSON.message + "!");
     });
@@ -93,5 +145,5 @@
 }
 
 $(function() {
-
+    Feng.initValidator("broadcastInfoForm", TBroadcastInfoDlg.validateFields);
 });

--
Gitblit v1.7.1