From 2b9052db0dfe13b6150c3f50c4d3898bc3982b4b Mon Sep 17 00:00:00 2001
From: lisy <linlangsur163@163.com>
Date: 星期四, 27 七月 2023 16:18:56 +0800
Subject: [PATCH] 开始上课的课时详情优化

---
 cloud-server-course/src/main/java/com/dsh/course/feignclient/model/StuCourseResp.java                    |    3 
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponController.java |    6 
 cloud-server-account/src/main/java/com/dsh/account/model/vo/classDetails/RegisteredCourse.java           |    3 
 cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html                      |  206 +++++++++++++++++
 cloud-server-account/src/main/java/com/dsh/account/feignclient/course/model/StuCourseResp.java           |    3 
 cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java                 |    1 
 cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java          |    2 
 cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCoupon.html                         |    4 
 cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCoupon.js                         |   24 +
 cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js                     |  438 ++++++++++++++++++++++++++++++++++++
 10 files changed, 673 insertions(+), 17 deletions(-)

diff --git a/cloud-server-account/src/main/java/com/dsh/account/feignclient/course/model/StuCourseResp.java b/cloud-server-account/src/main/java/com/dsh/account/feignclient/course/model/StuCourseResp.java
index b6094b5..3a7fe9a 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/feignclient/course/model/StuCourseResp.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/feignclient/course/model/StuCourseResp.java
@@ -22,4 +22,7 @@
 
     @ApiModelProperty(value = "剩余课时数")
     private int residueNums;
+
+    @ApiModelProperty(value = "课时有效期")
+    private String periodOfValidity;
 }
diff --git a/cloud-server-account/src/main/java/com/dsh/account/model/vo/classDetails/RegisteredCourse.java b/cloud-server-account/src/main/java/com/dsh/account/model/vo/classDetails/RegisteredCourse.java
index 21fc2c4..7f05d00 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/model/vo/classDetails/RegisteredCourse.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/model/vo/classDetails/RegisteredCourse.java
@@ -21,4 +21,7 @@
     @ApiModelProperty(value = "剩余学时数")
     private Integer remainingNums;
 
+    @ApiModelProperty(value = "课时有效期")
+    private String periodOfValidity;
+
 }
diff --git a/cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java b/cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
index ea5d476..8cb1126 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
@@ -162,6 +162,7 @@
                         course.setTotalNums(ToolUtil.isEmpty(tCoursePackagePayment.getTotalCourseNums()) ? 0 : tCoursePackagePayment.getTotalCourseNums());
                         course.setDeductedNums(ToolUtil.isEmpty(tCoursePackagePayment.getDeductionNums()) ? 0 : tCoursePackagePayment.getDeductionNums());
                         course.setRemainingNums(ToolUtil.isEmpty(tCoursePackagePayment.getResidueNums())? 0 : tCoursePackagePayment.getResidueNums());
+                        course.setPeriodOfValidity(tCoursePackagePayment.getPeriodOfValidity());
                         courseList.add(course);
                     }
                 }
diff --git a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
index 85230c2..9f0ee68 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -119,6 +119,8 @@
                 resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours());
                 resp.setResidueNums(tCoursePackagePayment.getLaveClassHours());
                 resp.setDeductionNums(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours());
+                String afterDayDate = DateUtil.getAfterDayDate2(tCoursePackage.getInsertTime(),tCoursePackage.getValidDays() + "");
+                resp.setPeriodOfValidity(afterDayDate);
                 resps.add(resp);
             }
         }
diff --git a/cloud-server-course/src/main/java/com/dsh/course/feignclient/model/StuCourseResp.java b/cloud-server-course/src/main/java/com/dsh/course/feignclient/model/StuCourseResp.java
index 6af2ebc..440631b 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/feignclient/model/StuCourseResp.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/feignclient/model/StuCourseResp.java
@@ -22,4 +22,7 @@
 
     @ApiModelProperty(value = "剩余课时数")
     private int residueNums;
+
+    @ApiModelProperty(value = "课时有效期")
+    private String periodOfValidity;
 }
diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponController.java
index 8c343e3..202b658 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponController.java
@@ -47,7 +47,7 @@
      */
     @RequestMapping("/coupon_add")
     public String memberCouponAdd() {
-        return PREFIX + "coupon_add.html";
+        return PREFIX + "TCouponAdd.html";
     }
 
     /**
@@ -65,9 +65,7 @@
         ofSearch.setUserPopulation(userPopulation);
         ofSearch.setStatus(status);
         ofSearch.setState(state);
-        List<Map<String, Object>> mapList = client.getCouponListOfSearch(ofSearch);
-        page.setRecords(mapList);
-        return page.getRecords();
+        return client.getCouponListOfSearch(ofSearch);
     }
 
 
diff --git a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCoupon.html b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCoupon.html
index fbb6b32..84e028e 100644
--- a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCoupon.html
+++ b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCoupon.html
@@ -52,8 +52,8 @@
                 </#SelectCon>
                         </div>
         <div class="col-sm-3">
-            <#button name="搜索" icon="fa-search" clickFun="MemberCoupon.search()"/>
-            <#button name="搜索" icon="fa-search" clickFun="MemberCoupon.search()"/>
+            <#button name="搜索" icon="fa-search" clickFun="TCoupon.search()"/>
+            <#button name="重置" icon="fa-trash" clickFun="TCoupon.resetSearch()"/>
         </div>
                         </div>
                         <div class="hidden-xs" id="TCouponTableToolbar" role="group">
diff --git a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html
new file mode 100644
index 0000000..b0a6d05
--- /dev/null
+++ b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tCoupon/TCouponAdd.html
@@ -0,0 +1,206 @@
+@layout("/common/_container.html"){
+<div class="ibox float-e-margins">
+    <div class="ibox-content">
+        <div class="form-horizontal">
+            <div class="row">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <label class="col-sm-3 control-label"><font  style="color:red">*</font>优惠券名称: </label>
+                        <div class="col-sm-9">
+                            <input class="form-control" id="name" name="name" autocomplete="off" placeholder="请输入优惠券名称">
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="row">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <div class="initialLevel col-sm-12 control-label form-group">
+                            <label class="col-sm-3 control-label"><font style="color:red">*</font>优惠券类型: </label>
+                            <input class="col-sm-1" style="margin-left: 1.7%;width: 13px;height: 13px;"
+                                   name="prescription" onclick="radio1()"
+                                   value="1" type="radio">
+                            <label class="col-sm-1" style="margin-left: 18px;width: 17%">满减券: 满</label>
+                            <input type="text" class="col-sm-1" id="conditionalAmount"
+                                   onkeyup="value=value.replace(/\D/g,'')"/>
+                            <label class="col-sm-1" style="margin-left: -1.5%;width: 14%"> 元 , 减 </label>
+                            <input type="text" class="col-sm-1" id="deductionAmount"
+                                   onkeyup="value=value.replace(/\D/g,'')"/>
+                            <label class="col-sm-1" style="margin-left: -1.5%"> 元</label>
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <div class="initialLevel col-sm-12 control-label form-group">
+                            <input class="col-sm-1" name="prescription" type="radio" value="2"
+                                   onclick="radio2()"
+                                   style="margin-left: 24.7%;">
+                            <label class="col-sm-1" style="margin-left: -17px;width: 20%;">代金券: 可抵</label>
+                            <input class="col-sm-1" id="discountAmount" onkeyup="value=value.replace(/\D/g,'')"/>
+                            <label class="col-sm-1">元</label>
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <div class="initialLevel col-sm-12 control-label form-group">
+                            <input class="col-sm-1" name="prescription" type="radio" value="3"
+                                   onclick="radio3()"
+                                   style="margin-left: 24.7%;">
+                            <label class="col-sm-3 control-label" style="margin-left: -1%;width: 14%;margin-top: -5px">体验券: </label>
+                            <input class="form-control" style="width: 35%" id="experienceName" name="name"
+                                   autocomplete="off" placeholder="请输入体验券名称">
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="row">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <label class="col-sm-3 control-label"><font  style="color:red">*</font>优惠券说明: </label>
+                        <div class="col-sm-9">
+                            <textarea type="checkbox" id="illustrate" style="margin-left: 1%;width: 75%;height: 120px"
+                                      placeholder="请输入优惠券名称"></textarea>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="row">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <div class="initialLevel col-sm-12 control-label form-group">
+                            <label class="col-sm-3 control-label"><font  style="color:red">*</font>发放方式: </label>
+                            <input class="col-sm-1 control-label" onclick="checkCompany()" name="company" type="radio"
+                                   value="0" style="margin-top: 10px"/>
+                            <label class="col-sm-1" style="margin-left: -15px;width: 16%;margin-top: 7px">积分购买</label>
+                            <input class="col-sm-1 control-label" name="company" onclick="checkCompany2()" type="radio"
+                                   value="1" checked style="margin-left: 5%;margin-top: 10px;width: 13px;height: 13px"/>
+                            <label class="col-sm-1" style="width: 16%;margin-top: 7px">注册赠送</label>
+                            <input class="col-sm-1 control-label" name="company" onclick="checkCompany2()" type="radio"
+                                   value="1" checked style="margin-left: 4%;margin-top: 10px;width: 13px;height: 13px"/>
+                            <label class="col-sm-1" style="width: 16%;margin-top: 7px">自动发券</label>
+                        </div>
+                    </div>
+                </div>
+            </div>
+
+            <div class="row">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <div class="initialLevel col-sm-12 control-label form-group">
+                            <label class="col-sm-3 control-label"><font  style="color:red">*</font>兑换方式: </label>
+                            <input class="col-sm-1 control-label" onclick="checkCompany()" name="company" type="radio"
+                                   value="0" style="margin-top: 10px"/>
+                            <label class="col-sm-1" style="margin-left: -15px;width: 16%;margin-top: 7px">积分</label>
+                            <input class="col-sm-1 control-label" name="company" onclick="checkCompany2()" type="radio"
+                                   value="1" checked style="margin-left: 5%;margin-top: 10px;width: 13px;height: 13px"/>
+                            <label class="col-sm-1" style="width: 20%;margin-top: 7px">现金+积分</label>
+                        </div>
+                    </div>
+                </div>
+            </div>
+
+            <div class="row" id="needAmount">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <label class="col-sm-3 control-label"><font  style="color:red">*</font>所需现金: </label>
+                        <input type="text" class="col-sm-1" id="requiredCash"
+                               onkeyup="value=value.replace(/\D/g,'')"/>
+                    </div>
+                </div>
+            </div>
+            <div class="row" id="needIntegral">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <label class="col-sm-3 control-label"><font  style="color:red">*</font>所需积分: </label>
+                        <input type="text" class="col-sm-1" id="requiredPoints"/>
+                    </div>
+                </div>
+            </div>
+
+            <div class="row">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <div class="initialLevel col-sm-12 control-label form-group">
+                            <label class="col-sm-3 control-label"><font  style="color:red">*</font>用户人群: </label>
+                            <input class="col-sm-1 control-label" onclick="userGroup1()" name="company" type="radio"
+                                   value="0" style="margin-top: 10px"/>
+                            <label class="col-sm-1" style="margin-left: -15px;width: 16%;margin-top: 7px">全部用户</label>
+                            <input class="col-sm-1 control-label" name="company" onclick="userGroup2()" type="radio"
+                                   value="1" checked style="margin-left: 5%;margin-top: 10px;width: 13px;height: 13px"/>
+                            <label class="col-sm-1" style="width: 16%;margin-top: 7px">年度会员</label>
+                            <input class="col-sm-1 control-label" name="company" onclick="userGroup3()" type="radio"
+                                   value="1" checked style="margin-left: 4%;margin-top: 10px;width: 13px;height: 13px"/>
+                            <label class="col-sm-1" style="width: 25%;margin-top: -16px">已有学员用户</label>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="row" >
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <label class="col-sm-3 control-label"><font  style="color:red">*</font>发放数量: </label>
+                        <input type="text" class="col-sm-1" id="issued"/>
+                    </div>
+                </div>
+            </div>
+
+            <div class="row" >
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <label class="col-sm-3 control-label"><font  style="color:red">*</font>限领数量: </label>
+                        <input type="text" class="col-sm-1" id="restrictedQty"/>
+                    </div>
+                </div>
+            </div>
+            <div class="row" >
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <label class="col-sm-3 control-label"><font  style="color:red">*</font>有效期: </label>
+                        <input type="text" style="width: 30%" class="form-control" id="periodOfValidity" placeholder="请选择"/>
+                    </div>
+                </div>
+            </div>
+
+
+
+            <div class="row">
+                <div class="col-sm-5">
+                    <div class="form-group">
+                        <div class="initialLevel col-sm-12 control-label form-group">
+                            <label class="col-sm-3 control-label"><font  style="color:red">*</font>适用范围: </label>
+                            <input class="col-sm-1 control-label" onclick="scopeOfApplication1()" name="company" type="radio"
+                                   value="0" style="margin-top: 10px"/>
+                            <label class="col-sm-1" style="margin-left: -15px;width: 16%;margin-top: 7px">全国通用</label>
+                            <input class="col-sm-1 control-label" name="company" onclick="scopeOfApplication2()" type="radio"
+                                   value="1" checked style="margin-left: 5%;margin-top: 10px;width: 13px;height: 13px"/>
+                            <label class="col-sm-1" style="width: 16%;margin-top: 7px">指定城市</label>
+                            <input class="col-sm-1 control-label" name="company" onclick="scopeOfApplication3()" type="radio"
+                                   value="1" checked style="margin-left: 4%;margin-top: 10px;width: 13px;height: 13px"/>
+                            <label class="col-sm-1" style="width: 25%;margin-top: -16px">指定门店</label>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="row">
+                <div class="row btn-group-m-t">
+                    <div class="col-sm-10" style="margin-left: 20%;">
+                        <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser"
+                        clickFun="couponInfoDlg.close()"/>
+                    </div>
+                    <div class="col-sm-10" style="margin-left: 35%;margin-top: -2.5%">
+                        <#button btnCss="info" name="保存" id="ensure" icon="fa-check"
+                        clickFun="couponInfoDlg.addSubmit()"/>
+                    </div>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>
+<script src="${ctxPath}/modular/system/tCoupon/TCouponInfo.js"></script>
+<script type="text/javascript">
+    laydate.render({
+        elem: '#periodOfValidity',
+        type: 'date',
+        range: true
+    });
+</script>
+@}
diff --git a/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCoupon.js b/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCoupon.js
index 6c7f68b..7904f52 100644
--- a/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCoupon.js
+++ b/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCoupon.js
@@ -69,10 +69,10 @@
     var index = layer.open({
         type: 2,
         title: '添加',
-        area: ['800px', '420px'], //宽高
+        area: ['100%', '100%'], //宽高
         fix: false, //不固定
         maxmin: true,
-        content: Feng.ctxPath + '/tCouponManage/tCouponManage_add'
+        content: Feng.ctxPath + '/tCouponManage/coupon_add'
     });
     this.layerIndex = index;
 };
@@ -82,15 +82,17 @@
  * 点击编辑
  */
 TCoupon.openChange = function () {
-    var index = layer.open({
-        type: 2,
-        title: '添加',
-        area: ['800px', '420px'], //宽高
-        fix: false, //不固定
-        maxmin: true,
-        content: Feng.ctxPath + '/tCouponManage/tCouponManage_add'
-    });
-    this.layerIndex = index;
+    if (this.check()){
+        var index = layer.open({
+            type: 2,
+            title: '编辑',
+            area: ['800px', '420px'], //宽高
+            fix: false, //不固定
+            maxmin: true,
+            content: Feng.ctxPath + '/tCouponManage/tCouponManage_add'
+        });
+        this.layerIndex = index;
+    }
 };
 
 
diff --git a/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js b/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js
new file mode 100644
index 0000000..7cfe71e
--- /dev/null
+++ b/cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js
@@ -0,0 +1,438 @@
+/**
+ * 初始化详情对话框
+ */
+var couponInfoDlg = {
+    couponInfoData: {}
+};
+
+/**
+ * 清除数据
+ */
+couponInfoDlg.clearData = function () {
+    this.couponInfoData = {};
+}
+
+/**
+ * 设置对话框中的数据
+ *
+ * @param key 数据的名称
+ * @param val 数据的具体值
+ */
+couponInfoDlg.set = function (key, val) {
+    this.couponInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
+    return this;
+}
+
+/**
+ * 设置对话框中的数据
+ *
+ * @param key 数据的名称
+ * @param val 数据的具体值
+ */
+couponInfoDlg.get = function (key) {
+    return $("#" + key).val();
+}
+
+/**
+ * 关闭此对话框
+ */
+couponInfoDlg.close = function () {
+    parent.layer.close(window.parent.CouponServer.layerIndex);
+}
+
+function ajax(serverCouponId, value, remark) {
+    var ajax = new $ax(Feng.ctxPath + "/couponServer/examine", function (data) {
+        Feng.success("审核成功!");
+        window.parent.CouponServer.table.refresh();
+        couponInfoDlg.close();
+    }, function (data) {
+        Feng.error("审核失败!" + data.responseJSON.message + "!");
+    });
+    ajax.setData({
+        couponServerId: serverCouponId,
+        state: value,
+        remark: remark
+    });
+    ajax.start();
+}
+
+function refush() {
+    $("#detailBox").show()
+}
+
+function agree() {
+    $("#detailBox").hide()
+}
+
+function checkCompany() {
+    $("#demo2").hide()
+}
+
+function checkCompany2() {
+    $("#demo2").show()
+}
+
+function radio1() {
+    $("#time").val('')
+    // document.getElementById("time").readOnly = true;
+    $("#time").attr('disabled', 'disabled');
+    $("#createTime").removeAttr("disabled");
+}
+
+function radio2() {
+    $("#createTime").val('')
+    // document.getElementById("time").readOnly = false;
+    $("#time").removeAttr("disabled");
+    $("#createTime").attr('disabled', 'disabled');
+}
+
+function radio3() {
+    $("#time").val('')
+    $("#createTime").val('')
+    //document.getElementById("createTime").readOnly = true;
+    // document.getElementById("time").readOnly = true;
+    $("#createTime").attr('disabled', 'disbled');
+    $("#time").attr('disabled', 'disabled');
+}
+
+/**
+ * 关闭此对话框
+ */
+couponInfoDlg.addSubmitCoupon = function () {
+    var value = $('input:radio:checked').val();
+    let couponServerId = $("#serverCouponId").val();
+    let remark = $('#detail').val()
+    if (value == 1) {
+        //提交信息
+        ajax(couponServerId, value, remark)
+    } else {
+        if (!remark) {
+            Feng.error("请输入拒绝理由!");
+            return;
+        }
+        ajax(couponServerId, value, remark)
+    }
+}
+
+/**
+ * 收集数据
+ */
+couponInfoDlg.collectData = function () {
+    this
+        .set('couponId')
+        .set('name')
+        .set('type')
+        .set('typeName')
+        .set('times')
+        .set('sheetsNum')
+        .set('auditStatus')
+        .set('reason')
+        .set('remark')
+        .set('startTime')
+        .set('endTime')
+        .set('activityId')
+        .set('createId')
+        .set('createTime')
+        .set('timeType')
+        .set('expDay')
+        .set('couponCode')
+        .set('instructions')
+        .set('belongs')
+        .set('useTimes');
+}
+
+function couponCheck() {
+    if ($("#couponType").val() == 6) {
+        $("#couponName1").show()
+    } else {
+        $("#couponName1").hide()
+    }
+}
+
+function checkCouponTimes() {
+    if ($("#inlineCheckbox").prop('checked')) {
+        $("#couponTimes").prop("disabled", true)
+        $("#couponTimes").val('')
+    } else {
+        $("#couponTimes").prop("disabled", false)
+    }
+}
+
+/**
+ * 提交添加
+ */
+couponInfoDlg.addSubmit = function () {
+    this.clearData();
+    this.collectData();
+
+    let times = 1;
+    if ($("#inlineCheckbox").get(0).checked) {
+        times = 0
+    } else {
+        let times1 = $("#couponTimes").val();
+        times = times1 != '' ? times1 : 1;
+        if (times > 100) {
+            Feng.error("服务次数最多为100次!")
+            return;
+        }
+        if (times < 1) {
+            Feng.error("服务次数至少为1次!")
+            return;
+        }
+    }
+    console.log(times);
+    var val2 = $("#number").val();
+    if (!val2) {
+        Feng.error("请输入服务券张数!")
+        return;
+    }
+    if (val2 <= 0) {
+        Feng.error("请输入正确的服务券张数!")
+        return;
+    }
+    let timeType = $(':radio[name="prescription"]:checked').val()
+    let expDay = 0
+    if (timeType == 2) {
+        expDay = $("#time").val()
+        if (expDay == null || expDay == '') {
+            Feng.info("请输入领取后有效天数")
+            return
+        }
+        if (expDay <= 0) {
+            Feng.info("请输入正确的天数")
+            return
+        }
+    }
+    var split = $('#createTime').val().split(" - ");
+    if (timeType == 1) {
+        if (split == null || split == '' || split == "-") {
+            Feng.info("请输入有效期")
+            return
+        }
+    }
+    if ($("#couponType").val() == 6) {
+        var val2 = $("#couponName1").val();
+        if (!val2) {
+            Feng.info("请输入服务卷名称")
+            return
+        }
+        if (val2.length > 4) {
+            Feng.info("请输入4个字以内券名称")
+            return
+        }
+    }
+
+    //分公司直接就默认自己
+    var val1 = $("#type_").val();
+    var val = xmSelect.get('#demo2', true).getValue('valueStr')
+    if (val1 == 1) {
+        if ($(':radio[name="company"]:checked').val() == 1) {
+            if (val == "") {
+                Feng.error("指定公司未选择!")
+                return;
+            }
+        }
+        if (val == "" || $(':radio[name="company"]:checked').val() == 0) {
+            val = 0;
+        }
+    } else {
+        val = $("#companyId_").val();
+    }
+    if (!$("#detail").val()) {
+        Feng.error("请输入服务描述")
+        return;
+    }
+    if (!$("#couponName").val()) {
+        Feng.error("请输入服务券名称!")
+        return;
+    }
+    //提交信息
+    var ajax = new $ax(Feng.ctxPath + "/couponServer/add", function (data) {
+        Feng.success("添加成功!");
+        window.parent.CouponServer.table.refresh();
+        couponInfoDlg.close();
+    }, function (data) {
+        Feng.error("添加失败!" + data.responseJSON.message + "!");
+    });
+    ajax.setData({
+        name: $("#couponName").val(),
+        type: $("#couponType").val(),
+        typeName: $("#couponName1").val(),
+        times: times,
+        sheetsNum: $("#number").val(),
+        remark: $("#detail").val(),
+        startTime: split[0],
+        endTime: split[1],
+        timeType: $(':radio[name="prescription"]:checked').val(),
+        expDay: $("#time").val(),
+        belongs: val,
+    });
+    ajax.start();
+}
+
+/**
+ * 提交修改
+ */
+couponInfoDlg.editSubmit = function () {
+
+    this.clearData();
+    this.collectData();
+
+    if (!$("#couponName").val()) {
+        Feng.error("请输入服务券名称!")
+        return;
+    }
+    let times = 1;
+    if ($("#inlineCheckbox").get(0).checked) {
+        times = 0
+    } else {
+        times = $("#couponTimes").val()
+        if (times > 100) {
+            Feng.error("服务次数最多为100次!")
+            return;
+        }
+        if (times < 1) {
+            Feng.error("服务次数至少为1次!")
+            return;
+        }
+    }
+    var val3 = $("#number").val();
+    if (!val3) {
+        Feng.error("请输入服务券张数!")
+        return;
+    }
+    if (val3 <= 0) {
+        Feng.error("请输入正确的服务券张数!")
+        return;
+    }
+    if ($("#couponType").val() == 6) {
+        var val2 = $("#couponName1").val();
+        if (!val2) {
+            Feng.info("请输入服务卷名称")
+            return
+        }
+        if (val2.length > 4) {
+            Feng.info("请输入4个字以内券名称")
+            return
+        }
+    }
+    let timeType = $(':radio[name="prescription"]:checked').val()
+    let expDay = 0
+    if (timeType == 2) {
+        expDay = $("#time").val()
+        if (expDay == null || expDay == '') {
+            Feng.info("请输入领取后有效天数")
+            return
+        }
+        if (expDay <= 0) {
+            Feng.info("请输入正确的天数")
+            return
+        }
+    }
+    var split = $('#createTime').val().split(" - ");
+    if (timeType == 1) {
+        if (split == null || split == '' || split == "-") {
+            Feng.info("请输入有效期")
+            return
+        }
+    }
+
+    //分公司直接就默认自己
+    var val1 = $("#type_").val();
+    var val = xmSelect.get('#demo2', true).getValue('valueStr')
+    if (val1 == 1) {
+        if ($(':radio[name="company"]:checked').val() == 1) {
+            if (val == "") {
+                Feng.error("指定公司未选择!")
+                return;
+            }
+        }
+        if (val == "" || $(':radio[name="company"]:checked').val() == 0) {
+            val = 0;
+        }
+    } else {
+        val = $("#companyId_").val();
+    }
+    if (!$("#detail").val()) {
+        Feng.error("请输入服务描述")
+        return;
+    }
+
+    //提交信息
+    var ajax = new $ax(Feng.ctxPath + "/couponServer/update", function (data) {
+        Feng.success("修改成功!");
+        window.parent.CouponServer.table.refresh();
+        couponInfoDlg.close();
+    }, function (data) {
+        Feng.error("修改失败!" + data.responseJSON.message + "!");
+    });
+    ajax.setData({
+        couponId: $("#couponId_").val(),
+        name: $("#couponName").val(),
+        type: $("#couponType").val(),
+        typeName: $("#couponName1").val(),
+        times: times,
+        sheetsNum: $("#number").val(),
+        remark: $("#detail").val(),
+        timeType: $(':radio[name="prescription"]:checked').val(),
+        expDay: $("#time").val(),
+        belongs: val,
+    });
+    ajax.set("startTimeStr", split[0]);
+    ajax.set("endTimeStr", split[1]);
+    ajax.start();
+}
+
+$(function () {
+
+    var val3 = $("#couponType_").val();
+    document.getElementById("couponType").selectedIndex = val3 - 1;
+    if ($("#couponType").val() == 6) {
+        $("#couponName1").show()
+    }
+
+    var val1 = $('#remark_').val();
+    if (val1 != '' && val1 != null) {
+        const detailTextarea = document.querySelector('#detail');
+        detailTextarea.value = val1;
+    }
+
+    if ($('#times_').val() == 0) {
+        $('#couponTimes').val('')
+        $("#couponTimes").prop("disabled", true)
+        $("#inlineCheckbox").prop('checked', true)
+    } else {
+        $('#couponTimes').val($('#times_').val())
+    }
+    // $(':radio[name="prescription"]:checked').val($("#timeType_").val())
+    var val2 = $("#timeType_").val();
+    $(":radio[name='prescription'][value=" + val2 + "]").prop("checked", "checked");
+    if (val2 == 1) {
+        $("#time").val('');
+        // document.getElementById("time").readOnly = true;
+        $("#time").attr('disabled', 'disabled');
+        $("#createTime").removeAttr("disabled");
+    } else if (val2 == 2) {
+        $("#createTime").val('')
+        // document.getElementById("time").readOnly = false;
+        $("#time").removeAttr("disabled");
+        $("#createTime").attr('disabled', 'disabled');
+    } else {
+        $("#time").val('')
+        $("#createTime").val('')
+        //document.getElementById("time").readOnly = true;
+        $("#time").attr('disabled', 'disabled');
+        $("#createTime").attr('disabled', 'disabled');
+    }
+
+    if ($("#belongs_").val() == '0') {
+        $("#demo2").hide()
+        $("input:radio[value='0']").attr('checked', 'true');
+    } else {
+        $("input:radio[value='4']").attr('checked', 'true');
+    }
+
+    // document.getElementById("time").readOnly = true;
+    // $("#createTime").attr('disabled', 'disabled');couponTimes
+    $("#couponTimes").val(1)
+});

--
Gitblit v1.7.1