Browse Source

首页弹窗修改

yanym 1 year ago
parent
commit
22b558221c

+ 67 - 61
suishenbang-admin/src/main/resources/templates/system/alertConfiguration/add.html

@@ -37,25 +37,27 @@
         <div class="form-group">
             <label class="col-sm-3 control-label">弹框开始时间:</label>
             <div class="col-sm-8">
-                <div class="input-group date">
-                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
-                    <input id="alertStartTime" name="alertStartTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
-                </div>
+                <input id="alertStartTime" name="alertStartTime" class="form-control" type="datetime-local">
+                <!--<div class="input-group date">-->
+                    <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
+                    <!--<input id="alertStartTime" name="alertStartTime" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
+                <!--</div>-->
             </div>
         </div>
         <div class="form-group">
             <label class="col-sm-3 control-label">弹框结束时间:</label>
             <div class="col-sm-8">
-                <div class="input-group date">
-                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
-                    <input id="alertEndTime" name="alertEndTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
-                </div>
+                <input id="alertEndTime" name="alertEndTime" class="form-control" type="datetime-local">
+                <!--<div class="input-group date">-->
+                    <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
+                    <!--<input id="alertEndTime" name="alertEndTime" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
+                <!--</div>-->
             </div>
         </div>
         <div class="form-group">
             <label class="col-sm-3 control-label">弹框每日可弹次数:</label>
             <div class="col-sm-8">
-                <input id="alertNum" name="alertNum" class="form-control" type="text">
+                <input id="alertNum" name="alertNum" class="form-control" type="number">
             </div>
         </div>
         <div class="form-group">
@@ -239,66 +241,70 @@
         if ($.validate.form()) {
             var alertType = $('#alertType').val();
             var contentVal = $('#alertContent').val();
-            var startTime = $('#alertStartTime').val();
-            var endTime = $('#alertEndTime').val();
+            var startTime = $('#alertStartTime').val().replace('T',' ');
+            var endTime = $('#alertEndTime').val().replace('T',' ');
             var alertNum = $('#alertNum').val();
             var userType = $('#userType').val();
-            var objSubmit = {
-                alertType:alertType,
-                photoUrl:photoUrl,
-                alertContent:contentVal,
-                alertStartTime:startTime,
-                alertEndTime:endTime,
-                alertNum:alertNum,
-                userType:userType,
-                alertStatus:'0'
-            }
-            if ($('#deptType3').val() != "") {
-                objSubmit.salesLevel = 'suboffice_level';
-                objSubmit.orgCode = $('#deptType3').val();
-                objSubmit.orgName = $('#deptType3').find("option:selected")[0].label
-            }
-            if ($('#deptType2').val() != "" && $('#deptType3').val() == "") {
-                objSubmit.salesLevel = 'office_level';
-                objSubmit.orgCode = $('#deptType2').val();
-                objSubmit.orgName = $('#deptType2').find("option:selected")[0].label
-            }
-            if ($('#deptType1').val() != "" && $('#deptType2').val() == "" && $('#deptType3').val() == "") {
-                objSubmit.salesLevel = 'company_level';
-                objSubmit.orgCode = $('#deptType1').val();
-                objSubmit.orgName = $('#deptType1').find("option:selected")[0].label
-            }
-            if ($('#deptType1').val() == "" && $('#deptType2').val() == "" && $('#deptType3').val() == "") {
-                objSubmit.salesLevel = 'diy_level';
-            }
-            console.log('objSubmit', objSubmit);
-            var configSubmit = {
-                url: prefix + "/add",
-                type: "post",
-                dataType: "json",
-                data: objSubmit,
-                beforeSend: function () {
-                    $.modal.loading("正在处理中,请稍后...");
-                },
-                success:function (result) {
-                    $.modal.closeLoading();
-                    $.operate.successCallback(result);
+            if (new Date(startTime).getTime() - new Date(endTime).getTime() >= 0){
+                $.modal.alertWarning("弹框结束时间不能小于开始时间");
+            }else {
+                var objSubmit = {
+                    alertType:alertType,
+                    photoUrl:photoUrl,
+                    alertContent:contentVal,
+                    alertStartTime:startTime,
+                    alertEndTime:endTime,
+                    alertNum:alertNum,
+                    userType:userType,
+                    alertStatus:'0'
+                }
+                if ($('#deptType3').val() != "") {
+                    objSubmit.salesLevel = 'suboffice_level';
+                    objSubmit.orgCode = $('#deptType3').val();
+                    objSubmit.orgName = $('#deptType3').find("option:selected")[0].label
                 }
+                if ($('#deptType2').val() != "" && $('#deptType3').val() == "") {
+                    objSubmit.salesLevel = 'office_level';
+                    objSubmit.orgCode = $('#deptType2').val();
+                    objSubmit.orgName = $('#deptType2').find("option:selected")[0].label
+                }
+                if ($('#deptType1').val() != "" && $('#deptType2').val() == "" && $('#deptType3').val() == "") {
+                    objSubmit.salesLevel = 'company_level';
+                    objSubmit.orgCode = $('#deptType1').val();
+                    objSubmit.orgName = $('#deptType1').find("option:selected")[0].label
+                }
+                if ($('#deptType1').val() == "" && $('#deptType2').val() == "" && $('#deptType3').val() == "") {
+                    objSubmit.salesLevel = 'diy_level';
+                }
+                console.log('objSubmit', objSubmit);
+                var configSubmit = {
+                    url: prefix + "/add",
+                    type: "post",
+                    dataType: "json",
+                    data: objSubmit,
+                    beforeSend: function () {
+                        $.modal.loading("正在处理中,请稍后...");
+                    },
+                    success:function (result) {
+                        $.modal.closeLoading();
+                        $.operate.successCallback(result);
+                    }
+                }
+                $.ajax(configSubmit)
             }
-            $.ajax(configSubmit)
             // $.operate.save(prefix + "/add", $('#form-configuration-add').serialize());
         }
     }
 
-    $("input[name='alertStartTime']").datetimepicker({
-        format: "yyyy-mm-dd hh:ii",
-        autoclose: true
-    });
-
-    $("input[name='alertEndTime']").datetimepicker({
-        format: "yyyy-mm-dd hh:ii",
-        autoclose: true
-    });
+    // $("input[name='alertStartTime']").datetimepicker({
+    //     format: "yyyy-mm-dd hh:ii",
+    //     autoclose: true
+    // });
+    //
+    // $("input[name='alertEndTime']").datetimepicker({
+    //     format: "yyyy-mm-dd hh:ii",
+    //     autoclose: true
+    // });
 
     /* 获取公司列表 */
     function getCompanyList(obj) {

+ 68 - 62
suishenbang-admin/src/main/resources/templates/system/alertConfiguration/edit.html

@@ -39,25 +39,27 @@
             <div class="form-group">    
                 <label class="col-sm-3 control-label">弹框开始时间:</label>
                 <div class="col-sm-8">
-                    <div class="input-group date">
-                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
-                        <input id="alertStartTime" name="alertStartTime" th:value="${#dates.format(alertConfiguration.alertStartTime, 'yyyy-MM-dd hh:mm')}" class="form-control" placeholder="yyyy-MM-dd hh:mm" type="text">
-                    </div>
+                    <input id="alertStartTime" name="alertStartTime" th:value="${#dates.format(alertConfiguration.alertStartTime, 'yyyy-MM-dd hh:mm')}" class="form-control" type="datetime-local">
+                    <!--<div class="input-group date">-->
+                        <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
+                        <!--<input id="alertStartTime" name="alertStartTime" th:value="${#dates.format(alertConfiguration.alertStartTime, 'yyyy-MM-dd hh:mm')}" class="form-control" placeholder="yyyy-MM-dd hh:mm" type="text">-->
+                    <!--</div>-->
                 </div>
             </div>
             <div class="form-group">    
                 <label class="col-sm-3 control-label">弹框结束时间:</label>
                 <div class="col-sm-8">
-                    <div class="input-group date">
-                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
-                        <input id="alertEndTime" name="alertEndTime" th:value="${#dates.format(alertConfiguration.alertEndTime, 'yyyy-MM-dd hh:mm')}" class="form-control" placeholder="yyyy-MM-dd hh:mm" type="text">
-                    </div>
+                    <input id="alertEndTime" name="alertEndTime" th:value="${#dates.format(alertConfiguration.alertEndTime, 'yyyy-MM-dd hh:mm')}" class="form-control" type="datetime-local">
+                    <!--<div class="input-group date">-->
+                        <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
+                        <!--<input id="alertEndTime" name="alertEndTime" th:value="${#dates.format(alertConfiguration.alertEndTime, 'yyyy-MM-dd hh:mm')}" class="form-control" placeholder="yyyy-MM-dd hh:mm" type="text">-->
+                    <!--</div>-->
                 </div>
             </div>
             <div class="form-group">    
                 <label class="col-sm-3 control-label">弹框每日可弹次数:</label>
                 <div class="col-sm-8">
-                    <input name="alertNum" th:field="*{alertNum}" class="form-control" type="text">
+                    <input name="alertNum" th:field="*{alertNum}" class="form-control" type="number">
                 </div>
             </div>
             <div class="form-group">
@@ -267,67 +269,71 @@
                 var alertId = $('#alertId').val();
                 var alertType = $('#alertType').val();
                 var contentVal = $('#alertContent').val();
-                var startTime = $('#alertStartTime').val();
-                var endTime = $('#alertEndTime').val();
+                var startTime = $('#alertStartTime').val().replace('T',' ');
+                var endTime = $('#alertEndTime').val().replace('T',' ');
                 var alertNum = $('#alertNum').val();
                 var userType = $('#userType').val();
-                var objSubmit = {
-                    alertId:alertId,
-                    alertType:alertType,
-                    photoUrl:photoUrl,
-                    alertContent:contentVal,
-                    alertStartTime:startTime,
-                    alertEndTime:endTime,
-                    alertNum:alertNum,
-                    userType:userType,
-                    alertStatus:'0'
-                }
-                if ($('#deptType3').val() != "") {
-                    objSubmit.salesLevel = 'suboffice_level';
-                    objSubmit.orgCode = $('#deptType3').val();
-                    objSubmit.orgName = $('#deptType3').find("option:selected")[0].label
-                }
-                if ($('#deptType2').val() != "" && $('#deptType3').val() == "") {
-                    objSubmit.salesLevel = 'office_level';
-                    objSubmit.orgCode = $('#deptType2').val();
-                    objSubmit.orgName = $('#deptType2').find("option:selected")[0].label
-                }
-                if ($('#deptType1').val() != "" && $('#deptType2').val() == "" && $('#deptType3').val() == "") {
-                    objSubmit.salesLevel = 'company_level';
-                    objSubmit.orgCode = $('#deptType1').val();
-                    objSubmit.orgName = $('#deptType1').find("option:selected")[0].label
-                }
-                if ($('#deptType1').val() == "" && $('#deptType2').val() == "" && $('#deptType3').val() == "") {
-                    objSubmit.salesLevel = 'diy_level';
-                }
-                console.log('objSubmit', objSubmit);
-                var configSubmit = {
-                    url: prefix + "/edit",
-                    type: "post",
-                    dataType: "json",
-                    data: objSubmit,
-                    beforeSend: function () {
-                        $.modal.loading("正在处理中,请稍后...");
-                    },
-                    success:function (result) {
-                        $.modal.closeLoading();
-                        $.operate.successCallback(result);
+                if (new Date(startTime).getTime() - new Date(endTime).getTime() >= 0){
+                    $.modal.alertWarning("弹框结束时间不能小于开始时间");
+                }else {
+                    var objSubmit = {
+                        alertId:alertId,
+                        alertType:alertType,
+                        photoUrl:photoUrl,
+                        alertContent:contentVal,
+                        alertStartTime:startTime,
+                        alertEndTime:endTime,
+                        alertNum:alertNum,
+                        userType:userType,
+                        alertStatus:'0'
+                    }
+                    if ($('#deptType3').val() != "") {
+                        objSubmit.salesLevel = 'suboffice_level';
+                        objSubmit.orgCode = $('#deptType3').val();
+                        objSubmit.orgName = $('#deptType3').find("option:selected")[0].label
+                    }
+                    if ($('#deptType2').val() != "" && $('#deptType3').val() == "") {
+                        objSubmit.salesLevel = 'office_level';
+                        objSubmit.orgCode = $('#deptType2').val();
+                        objSubmit.orgName = $('#deptType2').find("option:selected")[0].label
+                    }
+                    if ($('#deptType1').val() != "" && $('#deptType2').val() == "" && $('#deptType3').val() == "") {
+                        objSubmit.salesLevel = 'company_level';
+                        objSubmit.orgCode = $('#deptType1').val();
+                        objSubmit.orgName = $('#deptType1').find("option:selected")[0].label
+                    }
+                    if ($('#deptType1').val() == "" && $('#deptType2').val() == "" && $('#deptType3').val() == "") {
+                        objSubmit.salesLevel = 'diy_level';
                     }
+                    console.log('objSubmit', objSubmit);
+                    var configSubmit = {
+                        url: prefix + "/edit",
+                        type: "post",
+                        dataType: "json",
+                        data: objSubmit,
+                        beforeSend: function () {
+                            $.modal.loading("正在处理中,请稍后...");
+                        },
+                        success:function (result) {
+                            $.modal.closeLoading();
+                            $.operate.successCallback(result);
+                        }
+                    }
+                    $.ajax(configSubmit)
                 }
-                $.ajax(configSubmit)
             }
             // $.operate.save(prefix + "/edit", $('#form-configuration-edit').serialize());
         }
 
-        $("input[name='alertStartTime']").datetimepicker({
-            format: "yyyy-mm-dd hh:ii",
-            autoclose: true
-        });
-
-        $("input[name='alertEndTime']").datetimepicker({
-            format: "yyyy-mm-dd hh:ii",
-            autoclose: true
-        });
+        // $("input[name='alertStartTime']").datetimepicker({
+        //     format: "yyyy-mm-dd hh:ii",
+        //     autoclose: true
+        // });
+        //
+        // $("input[name='alertEndTime']").datetimepicker({
+        //     format: "yyyy-mm-dd hh:ii",
+        //     autoclose: true
+        // });
 
         $('#avatar').on('change', function () {
             var reader = new FileReader();