From 0152b864f47e5e1bfe0414663cc03208d7e6f5cb Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期二, 05 十一月 2024 21:05:35 +0800
Subject: [PATCH] 单据可编辑

---
 WebTM/views/销售管理/应收单/Xs_ReceivableBill.html               |   80 +++++++++++++++++++++++++++++++++------
 WebTM/views/领料发货/销售出库/Kf_SellOutBill.html                 |    2 
 WebTM/views/采购管理/付款单/YF_PayMentBill.html                  |    6 +-
 WebTM/views/销售管理/销售订单/Add_Edit_Xs_SeOrderBillList.html    |    2 
 WebTM/views/工资管理/考勤汇报单/Pay_WorkTimesSumQueryBillList.html |   26 ++++++++++++
 5 files changed, 97 insertions(+), 19 deletions(-)

diff --git "a/WebTM/views/\345\267\245\350\265\204\347\256\241\347\220\206/\350\200\203\345\213\244\346\261\207\346\212\245\345\215\225/Pay_WorkTimesSumQueryBillList.html" "b/WebTM/views/\345\267\245\350\265\204\347\256\241\347\220\206/\350\200\203\345\213\244\346\261\207\346\212\245\345\215\225/Pay_WorkTimesSumQueryBillList.html"
index 29f3260..f2aa510 100644
--- "a/WebTM/views/\345\267\245\350\265\204\347\256\241\347\220\206/\350\200\203\345\213\244\346\261\207\346\212\245\345\215\225/Pay_WorkTimesSumQueryBillList.html"
+++ "b/WebTM/views/\345\267\245\350\265\204\347\256\241\347\220\206/\350\200\203\345\213\244\346\261\207\346\212\245\345\215\225/Pay_WorkTimesSumQueryBillList.html"
@@ -65,6 +65,7 @@
                         <script type="text/html" id="toolbarDemo">
                             <div class="layui-btn-container">
                                 <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Exit"><i class="layui-icon layui-icon-logout"></i>閫�鍑�</button>
+                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn_Export" id="btn_Export"><i class="layui-icon layui-icon-export"></i>瀵煎嚭</button>
                                 <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>鍒楄缃�</button>
                             </div>
                         </script>
@@ -91,7 +92,7 @@
             var option = [];
             var sWhere = "";
             var HModName = "Pay_WorkTimesReportBill";
-
+            var ins;
             //涓嶉渶瑕佹樉绀虹殑瀛楁 鍙墿灞�
             var titleData = ["hmainid", "HDeptID", "HGroupID","HMangerID","HLeaveID","hsubid","HMaterID","HProcID","hEmpid"];
             //#endregion
@@ -115,6 +116,9 @@
                         break;
                     //鍒楄缃�
                     case 'set_HideColumn': get_HideColumn();
+                        break;
+                    //瀵煎嚭鎸夐挳
+                    case 'btn_Export': btn_Export();
                         break;
                 };
             });
@@ -304,6 +308,24 @@
             }
             //#endregion
 
+            //#region 瀵煎嚭Execel
+            function btn_Export() {
+                var data = option.data
+                data.forEach((item) => {
+                    for (let itemobj in item) {
+                        if (item[itemobj] == null) {
+                            item[itemobj] = "";
+                        }
+                        if (item[itemobj].length > 0) {  // 鍋囪瀛楁鍚嶄负field
+                            item[itemobj] = item[itemobj].toString().replaceAll(/[\r\n]+/g, '');  // 灏嗘崲琛岀鏇挎崲涓虹┖瀛楃涓�
+                        }
+                    }
+                });
+
+                table.exportFile(ins.config.id, option.data, "xls");
+            }
+            //#endregion
+
             //#region 鍒锋柊
             function get_Refresh() {
                 set_ClearQuery();
@@ -419,8 +441,10 @@
                                 }
                             }
                             table.render(option);
+                            ins = table.render(option);
                         } else {
                             table.render(option);
+                            ins = table.render(option);
                         }
                     }, error: function () {
                         layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
diff --git "a/WebTM/views/\351\207\207\350\264\255\347\256\241\347\220\206/\344\273\230\346\254\276\345\215\225/YF_PayMentBill.html" "b/WebTM/views/\351\207\207\350\264\255\347\256\241\347\220\206/\344\273\230\346\254\276\345\215\225/YF_PayMentBill.html"
index d09066d..d1f0a73 100644
--- "a/WebTM/views/\351\207\207\350\264\255\347\256\241\347\220\206/\344\273\230\346\254\276\345\215\225/YF_PayMentBill.html"
+++ "b/WebTM/views/\351\207\207\350\264\255\347\256\241\347\220\206/\344\273\230\346\254\276\345\215\225/YF_PayMentBill.html"
@@ -1070,7 +1070,7 @@
                             , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 1)
                             , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)                                                   //
                             , "HMoney": dealDoubleToFixed(dataArray[i].閲戦, 2)
-                            , "HInvoiceBillNo_Sub": dataArray[i].鍙戠エ缂栧彿
+                            , "HInvoiceBillNo_Sub": dataArray[i].鍙戠エ缂栧彿 ? "" : dataArray[i].鍙戠エ缂栧彿
                             , "HReceiveBillInterID": dataArray[i].hmainid
                             , "HReceiveBillEntryID": dataArray[i].hsubid
                             , "HReceiveBillNo": dataArray[i].鍗曟嵁鍙�
@@ -1355,7 +1355,7 @@
                                 , "HRelSumMoney": data.鎶樻墸鍚庨噾棰�
                                 , "HAccDate": formatDate(data.璐㈠姟鏃ユ湡)
                                 , "HCreditRating_Now": data.HCreditRating_Now
-                                , "HInvoiceBillNo": data.鍙戠エ缂栧彿
+                                , "HInvoiceBillNo": data.鍙戠エ缂栧彿 ? "" : data.鍙戠エ缂栧彿
                                 , "HBigMoney": data.澶у啓閲戦
                                 , "HReason": data.浠樻浜嬬敱
                                 , "HMaker": data.鍒跺崟浜�
@@ -1387,7 +1387,7 @@
                                             , "HQty": dealDoubleToFixed(result.data[i].鏁伴噺, 1)
                                             , "HPrice": dealDoubleToFixed(result.data[i].鍗曚环, 3)                                                   //
                                             , "HMoney": dealDoubleToFixed(result.data[i].缁撶畻閲戦, 2)
-                                            , "HInvoiceBillNo_Sub": result.data[i].鍙戠エ鍙风爜
+                                            , "HInvoiceBillNo_Sub": result.data[i].鍙戠エ鍙风爜 ? "" : result.data[i].鍙戠エ鍙风爜
                                             , "HReceiveBillInterID": result.data[i].婧愬崟涓诲唴鐮�
                                             , "HReceiveBillEntryID": result.data[i].婧愬崟瀛愬唴鐮�
                                             , "HReceiveBillNo": result.data[i].婧愬崟鍗曞彿
diff --git "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\345\272\224\346\224\266\345\215\225/Xs_ReceivableBill.html" "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\345\272\224\346\224\266\345\215\225/Xs_ReceivableBill.html"
index c9e5421..e3be052 100644
--- "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\345\272\224\346\224\266\345\215\225/Xs_ReceivableBill.html"
+++ "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\345\272\224\346\224\266\345\215\225/Xs_ReceivableBill.html"
@@ -136,8 +136,9 @@
                                             <label class="layui-form-label">鍗曚环绫诲瀷</label>
                                             <div class="layui-input-inline">
                                                 <select name="HPriceType" id="HPriceType" lay-filter="HPriceType" style="width: 190px; ">
-                                                    <option value="鎴愭湰浠�" selected="selected">鎴愭湰浠�</option>
+                                                    <option value="鍘荤◣浠�" selected="selected">鍘荤◣浠�</option>
                                                     <option value="缁撶畻浠�">缁撶畻浠�</option>
+                                                    <option value="鍚◣浠�">鍚◣浠�</option>
                                                 </select>
                                             </div>
                                         </div>
@@ -1286,6 +1287,69 @@
                 }
             });
             //#endregion
+
+            //#region 涓嬫媺妗嗕簨浠�
+            // 鐩戝惉涓嬫媺妗嗛�夋嫨  
+            form.on('select(HPriceType)', function (data) {
+                console.log(data.value); // 寰楀埌琚�変腑鐨勫��  
+                // 鎵ц鐩稿叧鎿嶄綔  
+                //#region 瀛愯〃 鏁版嵁妫�楠�
+                for (var i = 0; i < option.data.length; i++) {
+                    if (option.data[i]["HMaterID"] == "0") {
+                        layer.msg("绗�" + (i + 1) + "琛岋細鐗╂枡鏈�夋嫨锛�");
+                        return false;
+                    } else {
+                        var HPrice = option.data[i]["HPrice"];
+                        var HMaterID = option.data[i]["HMaterID"];
+                        var HType = data.value.toString();
+                        //鑾峰彇鐗╂枡瀵瑰簲鍗曚环绫诲瀷鐨勫崟浠�
+                        $.ajax({
+                            url: GetWEBURL() + "/Xs_ReceivableBill/getPriceByType",
+                            type: "GET",
+                            async: false,
+                            data: { "HMaterID": HMaterID, HType: HType },
+                            success: function (d) {
+                                HPrice = Number(d.data);
+                            }, error: function () {
+                                layer.alert("鍙戠敓閿欒!" + d.Message, { icon: 5 });
+                            }
+                        });
+                        var Dec = getDecByMaterID(option.data[i]["HMaterID"]) //鑾峰彇绮惧害
+                        var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //鏁伴噺绮惧害
+                        var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //鍗曚环绮惧害
+                        var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //閲戦绮惧害
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HTaxRate = option.data[i]["HTaxRate"] * 0.01;
+                        var HExRate = $("#HExRate").val();                      //姹囩巼
+                        var HQty = option.data[i]["HQty"] * 1;                           //鏁伴噺
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                        var HDiscountRate = option.data[i]["HDiscountRate"] * 1;   //鎶樻墸鐜�
+                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
+                        var HExRate = $("#HExRate").val();                      //姹囩巼
+                        var HMoneyBB = HMoney * HExRate;
+                        ///鏁板瓧绮惧害
+                        option.data[i]["HQty"] = Number(HQty.toFixed(HQtyDec));
+                        option.data[i]["HPrice"] = Number(HPrice.toFixed(HPriceDec));
+                        option.data[i]["HMoney"] = Number(HMoney.toFixed(HMoneyDec));
+                        option.data[i]["HTaxMoney"] = Number(HTaxMoney.toFixed(HMoneyDec));
+                        option.data[i]["HMoneyBB"] = Number(HMoneyBB.toFixed(HMoneyDec));
+                        option.data[i]["HlineTotal"] = Number(HlineTotal.toFixed(HMoneyDec));
+                        option.data[i]["HTaxPrice"] = Number(HTaxPrice.toFixed(HPriceDec));
+                        option.data[i]["HRelTaxPrice"] = Number(HRelTaxPrice.toFixed(HPriceDec));
+                        option.data[i]["HlineTotalBB"] = Number(HlineTotalBB.toFixed(HMoneyDec));
+                    }
+                    
+                }
+                table.render(option);
+                //#endregion
+            });
+
+            //#endregion
+
             //#endregion
 
             //#endregion
@@ -2372,12 +2436,7 @@
                                         var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //鏁伴噺绮惧害
                                         var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //鍗曚环绮惧害
                                         var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //閲戦绮惧害
-                                        var HPrice = 0;
-                                        if ($("#HPriceType").val() == "鎴愭湰浠�") {
-                                            HPrice = OptionData.鍚◣鎴愭湰浠� * 1;//鍗曚环
-                                        } else {
-                                            HPrice = OptionData.缁撶畻浠� * 1;//鍗曚环
-                                        }
+                                        var HPrice = obj.data.HPrice * 1;
                                         var HTaxRate = obj.data.HTaxRate*0.01;
                                         if (HSupID != 0) {
                                             $.ajax({
@@ -2511,12 +2570,7 @@
                                 var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //鏁伴噺绮惧害
                                 var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //鍗曚环绮惧害
                                 var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //閲戦绮惧害
-                                var HPrice = 0;
-                                if ($("#HPriceType").val() == "鎴愭湰浠�") {
-                                    HPrice = OptionData.鍚◣鎴愭湰浠� * 1;//鍗曚环
-                                } else {
-                                    HPrice = OptionData.缁撶畻浠� * 1;//鍗曚环
-                                }
+                                var HPrice = obj.data.HPrice * 1;
                                 var HTaxRate = obj.data.HTaxRate*0.01;
                                 if (HSupID != 0) {
                                     $.ajax({
diff --git "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\350\256\242\345\215\225/Add_Edit_Xs_SeOrderBillList.html" "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\350\256\242\345\215\225/Add_Edit_Xs_SeOrderBillList.html"
index daf6b1e..dea00d6 100644
--- "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\350\256\242\345\215\225/Add_Edit_Xs_SeOrderBillList.html"
+++ "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\350\256\242\345\215\225/Add_Edit_Xs_SeOrderBillList.html"
@@ -1555,7 +1555,7 @@
                                         "浠撳簱": result.data[i]["瀛愪粨搴�"],
                                         "HQty": dealDoubleToFixed(result.data[i]["鏁伴噺"], 1),
                                         "HPrice": dealDoubleToFixed(result.data[i]["鍗曚环"], 3),
-                                        "HTaxPrice": dealDoubleToFixed(result.data[i]["鍚◣鍗曚环"], 3),
+                                        "HTaxPrice": dealDoubleToFixed(result.data[i]["HTaxPrice"], 3),
                                         "HMoney": dealDoubleToFixed(result.data[i]["閲戦"],2),
                                         "HDiscountRate": result.data[i]["鎶樻墸鐜�"],
                                         "HRelTaxPrice": result.data[i]["瀹為檯鍚◣鍗曚环"],
diff --git "a/WebTM/views/\351\242\206\346\226\231\345\217\221\350\264\247/\351\224\200\345\224\256\345\207\272\345\272\223/Kf_SellOutBill.html" "b/WebTM/views/\351\242\206\346\226\231\345\217\221\350\264\247/\351\224\200\345\224\256\345\207\272\345\272\223/Kf_SellOutBill.html"
index 91cfe59..2e6ae0f 100644
--- "a/WebTM/views/\351\242\206\346\226\231\345\217\221\350\264\247/\351\224\200\345\224\256\345\207\272\345\272\223/Kf_SellOutBill.html"
+++ "b/WebTM/views/\351\242\206\346\226\231\345\217\221\350\264\247/\351\224\200\345\224\256\345\207\272\345\272\223/Kf_SellOutBill.html"
@@ -66,7 +66,7 @@
                                         <div class="layui-inline">
                                             <label class="layui-form-label">鍗曟嵁缂栧彿</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
+                                                <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;">
                                                 <input type="hidden" name="HInterID" id="HInterID" value="0">
                                             </div>
                                         </div>

--
Gitblit v1.9.1