瀏覽代碼

修复变更bug

ellisran 5 月之前
父節點
當前提交
8000e168f3
共有 1 個文件被更改,包括 109 次插入1 次删除
  1. 109 1
      app/public/js/change_information.js

+ 109 - 1
app/public/js/change_information.js

@@ -3596,6 +3596,7 @@ $(document).ready(() => {
                 };
                 const refreshData = ledgerTree.loadPostData(loadResult);
                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
+                ledgerTreeSpreadObj.loadExprToInput();
             }, function () {
                 select[col.field] = orgValue;
                 if (col.field === 'b_code') {
@@ -4128,6 +4129,7 @@ $(document).ready(() => {
                 };
                 const refreshData = ledgerTree.loadPostData(loadResult);
                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
+                posSpreadObj.loadExprToInput();
             }, function () {
                 select[col.field] = orgValue;
                 cInfo[col.field] = orgValue;
@@ -5499,7 +5501,7 @@ $(document).ready(() => {
             showMode(type);
         });
     });
-
+    let firstLoad = true;
     function showMode(type) {
         if (type === 0) {
             $('.judge-hide').show();
@@ -5518,6 +5520,14 @@ $(document).ready(() => {
         } else {
             $('.judge-hide').attr("style","display:none !important");
             $('.judge-show').show();
+            if (firstLoad) {
+                const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
+                if (updateOrderList.length > 0) {
+                    postData(window.location.pathname + '/save', { type:'changeOrder', postData: updateOrderList }, function (result) {
+                    });
+                }
+                firstLoad = false;
+            }
             const {changeLedgers, changePoss} = makeLedgerAndPosData();
             ledgerTree.loadDatas(changeLedgers);
             pos.loadDatas(changePoss);
@@ -6061,7 +6071,105 @@ $(document).ready(() => {
             });
         };
     }
+    // 重新审批获取手机验证码
+    // 获取验证码
+    let isPosting = false;
+    $(".get-code").on('click', function() {
+        if (isPosting) {
+            return false;
+        }
+        const btn = $(this);
+
+        $.ajax({
+            url: '/profile/code?_csrf_j=' + csrf,
+            type: 'post',
+            data: { mobile: authMobile, type: 'shenpi' },
+            dataTye: 'json',
+            error: function() {
+                isPosting = false;
+            },
+            beforeSend: function() {
+                isPosting = true;
+            },
+            success: function(response) {
+                isPosting = false;
+                if (response.err === 0) {
+                    codeSuccess(btn);
+                    $("input[name='code']").removeAttr('readonly');
+                    $("#re-shenpi-btn").removeAttr('disabled');
+                    $("#re-shenpi-btn2").removeAttr('disabled');
+                } else {
+                    toast(response.msg, 'error');
+                }
+            }
+        });
+    });
+
+    if (readOnly && !shenpiPower) {
+        // 记录变更信息操作
+        $('body').on('valuechange', '#w_code', function (e, previous) {
+            const new_w_code = $(this).val();
+            if (new_w_code !== w_code) {
+                $('#show-save-btn').show();
+                $('#sp-btn').hide();
+                $('.title-main').addClass('bg-warning');
+            } else {
+                $('#show-save-btn').hide();
+                $('#sp-btn').show();
+                $('.title-main').removeClass('bg-warning');
+            }
+        });
+
+        // 保存修改ajax提交(不刷新页面)
+        $('.save_change_btn').on('click', function () {
+            const new_w_code = $('#w_code').val();
+            // 后改为br
+            // 更新至服务器
+            postData(window.location.pathname + '/save', { type:'info', updateData: { w_code: new_w_code } }, function (result) {
+                toastr.success(result ? result.msg : '');
+                $('#show-save-btn').hide();
+                $('#sp-btn').show();
+                $('.title-main').removeClass('bg-warning');
+                w_code = new_w_code;
+            });
+            return false;
+        });
+
+        $('#cancel_change').on('click', function () {
+            $('#show-save-btn').hide();
+            $('#sp-btn').show();
+            $('.title-main').removeClass('bg-warning');
+            $('#w_code').val(w_code);
+            // toastr.success('已还原到上次保存状态');
+        });
+    }
 });
+/**
+ * 获取成功后的操作
+ *
+ * @param {Object} btn - 点击的按钮
+ * @return {void}
+ */
+function codeSuccess(btn) {
+    let counter = 60;
+    btn.addClass('disabled').text('重新获取 ' + counter + 'S');
+    btn.parent().siblings('input').removeAttr('readonly').attr('placeholder', '输入短信中的6位验证码');
+    const bindBtn = $("#bind-btn");
+    bindBtn.removeClass('btn-secondary disabled').addClass('btn-primary');
+
+    const countDown = setInterval(function() {
+        const countString = counter - 1 <= 0 ? '' : ' ' + (counter - 1) + 'S';
+        // 倒数结束后
+        if (countString === '') {
+            clearInterval(countDown);
+            btn.removeClass('disabled');
+        }
+        const text = '重新获取' + countString;
+        btn.text(text);
+        counter -= 1;
+    }, 1000);
+}
+
 
 function calcChangePrice() {
     let positive_tp = 0;