From 640ff18d2d7f4be02ddb7f8f75e899f05545eb98 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 05 二月 2024 11:56:52 +0800
Subject: [PATCH] 更新bug修改

---
 cloud-server-management/src/main/webapp/static/modular/system/tCoupon/TCouponInfo.js |  195 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 165 insertions(+), 30 deletions(-)

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
index f42e2e2..5cb9b52 100644
--- 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
@@ -42,6 +42,9 @@
 couponInfoDlg.close = function () {
     parent.layer.close(window.parent.TCoupon.layerIndex);
 }
+couponInfoDlg.close1 = function () {
+    parent.layer.close(window.parent.TCouponExamine.layerIndex);
+}
 
 
 /**
@@ -316,7 +319,49 @@
 couponInfoDlg.delete = function (o) {
     $(o).parent("div").remove()
 }
+couponInfoDlg.audit = function () {
+    var id = $("#id").val();
+    var state = $("#state").val();
+    console.log("让我看看state")
+    console.log(state)
+    if (state == "未通过"){
+        Feng.error("当前优惠券不可再次审核!");
+        return ;
+    }
+    let audit = document.querySelector('input[name="r1"]:checked').value;
+    let text = $("#text").val()
+    if(audit==3){
+        if(text==''){
+            Feng.info("请输入拒绝理由")
+            return false;
+        }
+    }
+    var ajax = new $ax(Feng.ctxPath + "/tCouponExamine/examine", function (data) {
+        if (data.code == 200) {
+            Feng.success("操作成功!");
 
+            window.parent.TCouponExamine.table.refresh();
+            couponInfoDlg.close1();
+        } else if(data=="repeat"){
+            window.location.reload();
+            window.parent.layer.closeAll();
+            Feng.error("请勿重复操作");
+        }else {
+            return  Feng.error(data.msg);
+        }
+    }, function (data) {
+        Feng.error("操作失败!")
+        window.location.reload();
+        window.parent.layer.closeAll();
+        return   Feng.error("操作失败!");
+    });
+
+    ajax.set("id", id);
+    ajax.set("state", audit);
+    ajax.set("remark", text);
+    ajax.start();
+    layer.closeAll();
+}
 /**
  * 提交
  */
@@ -358,10 +403,12 @@
     }
 
 
-    // 说明
-    var illustrate = $('#illustrate').val();
-    if (illustrate === undefined || illustrate === '' || illustrate === null){
-        return Feng.error('优惠券说明不能为空');
+    if ($('#userType').val()==1) {
+        // 说明
+        var illustrate = $('#illustrate').val();
+        if (illustrate === undefined || illustrate === '' || illustrate === null) {
+            return Feng.error('优惠券说明不能为空');
+        }
     }
     // 发放方式
     let distributionMethod = $(":radio[name='distributionMethod']:checked").val();
@@ -390,17 +437,22 @@
     if (periodOfValidity === undefined || periodOfValidity === '' || periodOfValidity === null){
         return Feng.error('有效期不能为空');
     }
+    if ($('#userType').val()==1){
     // 兑换方式
     let exchangeMethod = $(':radio[name="exchangeMethod"]:checked').val();
-    if (exchangeMethod === '' || exchangeMethod === undefined || exchangeMethod === null){
-        return Feng.error('兑换方式不能为空');
+        console.log("看看exchangeMethod")
+        console.log(exchangeMethod)
+    if (distributionMethod === '1') {
+        if (exchangeMethod === '' || exchangeMethod === undefined || exchangeMethod === null) {
+            return Feng.error('兑换方式不能为空');
+        }
     }
-    if (exchangeMethod === '1'){
+    if (exchangeMethod === '1' ){
         if (requiredPoints === undefined || requiredPoints === '' || requiredPoints === null){
             return Feng.error('所需积分不能为空');
         }
     }
-    if (exchangeMethod === '2'){
+    if (exchangeMethod === '2' && distributionMethod === '1'){
         if (requiredPoints === undefined || requiredPoints === '' || requiredPoints === null){
             return Feng.error('所需积分不能为空');
         }
@@ -408,35 +460,37 @@
             return Feng.error('所需现金不能为空');
         }
     }
-    if (exchangeMethod === '3'){
+    if (exchangeMethod === '3' && distributionMethod === '1'){
         if (requiredCash === undefined || requiredCash === '' || requiredCash === null){
             return Feng.error('所需现金不能为空');
         }
     }
-
+    }
     let company = $(':radio[name="company"]:checked').val();
     var cts = "";
-    if (company === '2'){
-        var myselect=document.getElementById('cityData');
-        var seCity = myselect.options[myselect.selectedIndex].value;
-        if (seCity === null || seCity === undefined || seCity === ''){
-            return Feng.error('请选中一个省市');
-        }
-        cityIds.push(seCity);
-        if (num > 0){
-            for (let i = 1; i <= num; i++) {
-                var insSelect=document.getElementById('cityData'+i);
-                var inData = insSelect.options[insSelect.selectedIndex].value;
-                if (inData !== undefined || inData !== null ||  inData !== ''){
-                    cityIds.push(inData);
+    if ($('#userType').val()==1) {
+        if (company === '2') {
+            var myselect = document.getElementById('cityData');
+            var seCity = myselect.options[myselect.selectedIndex].value;
+            if (seCity === null || seCity === undefined || seCity === '') {
+                return Feng.error('请选中一个省市');
+            }
+            cityIds.push(seCity);
+            if (num > 0) {
+                for (let i = 1; i <= num; i++) {
+                    var insSelect = document.getElementById('cityData' + i);
+                    var inData = insSelect.options[insSelect.selectedIndex].value;
+                    if (inData !== undefined || inData !== null || inData !== '') {
+                        cityIds.push(inData);
+                    }
                 }
             }
             cts = cityIds.join(',');
-        }else {
-            cts = cityIds;
-        }
-    }
+            console.log("============到达城市"+cts)
 
+        }
+
+    }
     const commaSeparatedString = this.goodsPicArray.join(',');
 
     var stores = "";
@@ -448,22 +502,28 @@
         stores = this.storeIds.join(',');
         console.log('stores--===--',stores)
     }
+
+    var ensure = document.getElementById("ensure");
+    ensure.disabled = true;
     //提交信息
     var ajax = new $ax(Feng.ctxPath + "/tCouponManage/commitData", function (data) {
+        ensure.disabled = false;
         Feng.success("添加成功!");
         window.parent.TCoupon.table.refresh();
         couponInfoDlg.close();
     }, function (data) {
+        ensure.disabled = false;
         Feng.error("添加失败!" + data.responseJSON.message + "!");
     });
-    ajax.set("userType",1);
-    ajax.set("cityManagerId",1);
+    ajax.set("userType",$('#userType').val());
+    ajax.set("cityManagerId",0);
     ajax.set("couponName",couponName);
     ajax.set("prescription",prescription);
     ajax.set("condition",conditionalAmount);
     ajax.set("subtraction",deductionAmount);
     ajax.set("discount",voucherAmount);
     ajax.set("experience",experienceName);
+    var illustrate = $('#illustrate').val();
     ajax.set("illustrate",illustrate);
     ajax.set("distributionMethod",distributionMethod);
     ajax.set("requiredPoints",requiredPoints);
@@ -472,7 +532,13 @@
     ajax.set("quantityIssued",quantityIssued);
     ajax.set("pickUpQuantity",pickUpQuantity);
     ajax.set("periodOfValidity",periodOfValidity);
-    ajax.set("exchangeMethod",exchangeMethod);
+
+    if ($('#userType').val()==2) {
+        ajax.set("exchangeMethod",1);
+    }else{
+        let exchangeMethod = $(':radio[name="exchangeMethod"]:checked').val();
+        ajax.set("exchangeMethod",exchangeMethod);
+    }
     ajax.set("goodImg",this.goodsCover);
     ajax.set("goodImgs",commaSeparatedString);
     ajax.set("company",company);
@@ -511,6 +577,7 @@
 
 
 $(function () {
+
     getProvince(null);
     radio1();
     var OBJradio = document.getElementsByName("prescription")
@@ -585,4 +652,72 @@
         $('#belongsStore').show();
         $('#storeSelect').show();
     }
+    if (userType === '3'){
+        // 兑换方式
+        $('#exchangeType').show();
+        $('#needAmount').show();
+        $('#needIntegral').show();
+        // 图片
+        $('#app').show();
+        $('#app1').show();
+        // 适用范围
+    }
+
+
+
+
+    const distributionMethodOptions = document.getElementsByName('distributionMethod');
+
+// 监听distributionMethod选项的变化
+    for (let i = 0; i < distributionMethodOptions.length; i++) {
+        distributionMethodOptions[i].addEventListener('change', function() {
+            // 获取选中的distributionMethod值
+            const selectedDistributionMethod = document.querySelector('input[name="distributionMethod"]:checked').value;
+            console.log("看看选择")
+            console.log(selectedDistributionMethod);
+            // 判断选中的值是否不等于1
+            if (selectedDistributionMethod !== '1') {
+                console.log("已经选择1")
+                // 隐藏exchangeType
+                document.getElementById('exchangeType').style.display = 'none';
+                document.getElementById('needAmount').style.display = 'none';
+                document.getElementById('needIntegral').style.display = 'none';
+            } else {
+                // 显示exchangeType
+                document.getElementById('exchangeType').style.display = 'block';
+                document.getElementById('needAmount').style.display = 'block';
+                document.getElementById('needIntegral').style.display = 'block';
+            }
+            // 如果选择发放方式为注册赠送
+            if (selectedDistributionMethod == "2"){
+                const userGroupRadios = document.querySelectorAll('input[name="userGroup"][value="1"], input[name="userGroup"][value="3"]');
+                console.log("看看要隐藏的")
+                console.log(userGroupRadios)
+                // 隐藏值为 1 或 2 的 radio 按钮,并显示值为 2 的 radio 按钮
+                userGroupRadios.forEach(userRadio => {
+                    console.log("隐藏啊")
+                    userRadio.style.display = 'none';
+                });
+                $('#u1').hide();
+                $('#u3').hide();
+                const userGroupTwo = document.querySelector('input[name="userGroup"][value="2"]');
+                userGroupTwo.style.display = 'inline-block';
+                userGroupTwo.checked = true;
+            }else{
+                // 如果选择的不是值为 2 的 radio 按钮,则显示所有的 userGroup radio 按钮
+                const userGroupRadios = document.querySelectorAll('input[name="userGroup"]');
+                userGroupRadios.forEach(userRadio => {
+                    userRadio.style.display = 'inline-block';
+                });
+                const userGroupTwo = document.querySelector('input[name="userGroup"][value="1"]');
+                userGroupTwo.style.display = 'inline-block';
+                userGroupTwo.checked = true;
+                $('#u1').show();
+                $('#u3').show();
+            }
+        });
+    }
+
+
+
 });

--
Gitblit v1.7.1