liuhairui 2 weeks ago
parent
commit
0797d01783
1 changed files with 88 additions and 37 deletions
  1. 88 37
      public/assets/js/backend/procuremen.js

+ 88 - 37
public/assets/js/backend/procuremen.js

@@ -473,7 +473,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         if (tab === 'pick') {
                         if (tab === 'pick') {
                             return '';
                             return '';
                         } else if (tab === 'audit') {
                         } else if (tab === 'audit') {
-                            parts.push('<a class="btn btn-xs btn-primary procuremen-op-open procuremen-btn-audit-issue"' + areaAudit + ' href="procuremen/auditissue" data-row-index="' + index + '" title="确认供应商"><i class="fa fa-check"></i> 确认供应商</a>');
+                            parts.push('<a class="btn btn-xs btn-primary procuremen-op-open procuremen-btn-audit-issue"' + areaAudit + ' href="procuremen/auditissue" data-row-index="' + index + '" title=""><i class="fa fa-check"></i> 选择供应商</a>');
                             parts.push('<a class="btn btn-xs btn-info procuremen-op-open procuremen-btn-details"' + areaDetails + ' href="procuremen/details" data-row-index="' + index + '" title="详情"><i class="fa fa-file-text-o"></i> 详情</a>');
                             parts.push('<a class="btn btn-xs btn-info procuremen-op-open procuremen-btn-details"' + areaDetails + ' href="procuremen/details" data-row-index="' + index + '" title="详情"><i class="fa fa-file-text-o"></i> 详情</a>');
                         } else if (tab === 'confirm') {
                         } else if (tab === 'confirm') {
                             parts.push('<a class="btn btn-xs btn-success procuremen-op-open procuremen-btn-outward"' + areaConfirmOutward + ' href="procuremen/outward_detail?wff_tab=confirm" data-row-index="' + index + '" title="审批"><i class="fa fa-gavel"></i> 审批</a>');
                             parts.push('<a class="btn btn-xs btn-success procuremen-op-open procuremen-btn-outward"' + areaConfirmOutward + ' href="procuremen/outward_detail?wff_tab=confirm" data-row-index="' + index + '" title="审批"><i class="fa fa-gavel"></i> 审批</a>');
@@ -1169,7 +1169,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         }
                         }
                         var winA = window;
                         var winA = window;
                         if (winA.Backend && winA.Backend.api) {
                         if (winA.Backend && winA.Backend.api) {
-                            winA.Backend.api.open(auditUrl, '确认供应商', {area: ['92%', '88%']});
+                            winA.Backend.api.open(auditUrl, '供应商报价明细', {area: ['92%', '88%']});
                         }
                         }
                         return;
                         return;
                     }
                     }
@@ -1505,23 +1505,54 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 }
                 }
             });
             });
 
 
-            $wrap.on('click.procuremenPurchaseConfirm', '#btn-pod-purchase-confirm', function () {
-                var FastRef = (typeof Fast !== 'undefined' && Fast.api) ? Fast
-                    : (typeof parent !== 'undefined' && parent.Fast && parent.Fast.api ? parent.Fast : null);
-                if (!FastRef || !FastRef.api) {
+            function procuremenOutwardFastRef() {
+                if (typeof Fast !== 'undefined' && Fast.api) {
+                    return Fast;
+                }
+                if (typeof parent !== 'undefined' && parent.Fast && parent.Fast.api) {
+                    return parent.Fast;
+                }
+                return null;
+            }
+
+            function procuremenOutwardToast(msg, type) {
+                type = type || 'warning';
+                var T = null;
+                try {
                     if (typeof parent !== 'undefined' && parent.Toastr) {
                     if (typeof parent !== 'undefined' && parent.Toastr) {
-                        parent.Toastr.error('页面未就绪,请刷新后重试');
+                        T = parent.Toastr;
                     }
                     }
+                } catch (eP) {
+                }
+                if (!T && typeof Toastr !== 'undefined') {
+                    T = Toastr;
+                }
+                if (T) {
+                    if (type === 'error' && typeof T.error === 'function') {
+                        T.error(msg);
+                    } else if (typeof T.warning === 'function') {
+                        T.warning(msg);
+                    }
+                    return;
+                }
+                var Lm = procuremenLayerTop();
+                if (Lm && typeof Lm.msg === 'function') {
+                    Lm.msg(msg);
+                }
+            }
+
+            function onPurchaseConfirmClick(e) {
+                if (e && typeof e.preventDefault === 'function') {
+                    e.preventDefault();
+                }
+                var FastRef = procuremenOutwardFastRef();
+                if (!FastRef || !FastRef.api) {
+                    procuremenOutwardToast('页面未就绪,请刷新后重试', 'error');
                     return;
                     return;
                 }
                 }
                 var $checked = $wrap.find('.pod-company-pick-cb:checked');
                 var $checked = $wrap.find('.pod-company-pick-cb:checked');
                 if (!$checked.length) {
                 if (!$checked.length) {
-                    var Lm = (typeof parent !== 'undefined' && parent.Layer) ? parent.Layer : (typeof Layer !== 'undefined' ? Layer : null);
-                    if (Lm && typeof Lm.msg === 'function') {
-                        Lm.msg('请至少勾选一家供应商');
-                    } else if (typeof Toastr !== 'undefined') {
-                        Toastr.warning('请至少勾选一家供应商');
-                    }
+                    procuremenOutwardToast('请至少勾选一家供应商');
                     return;
                     return;
                 }
                 }
 
 
@@ -1584,15 +1615,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
 
                 var orderPicks = collectOrderPicks();
                 var orderPicks = collectOrderPicks();
                 if (!orderPicks || orderPicks.length === 0) {
                 if (!orderPicks || orderPicks.length === 0) {
-                    var L0 = (typeof parent !== 'undefined' && parent.Layer) ? parent.Layer : (typeof Layer !== 'undefined' ? Layer : null);
-                    var missMsg = requiredSids.length > 1
+                    procuremenOutwardToast(requiredSids.length > 1
                         ? '所选供应商须覆盖本单全部工序,且同一工序不可重复选择'
                         ? '所选供应商须覆盖本单全部工序,且同一工序不可重复选择'
-                        : '请勾选一家供应商';
-                    if (L0 && typeof L0.msg === 'function') {
-                        L0.msg(missMsg);
-                    } else if (typeof Toastr !== 'undefined') {
-                        Toastr.warning(missMsg);
-                    }
+                        : '请勾选一家供应商');
                     return;
                     return;
                 }
                 }
 
 
@@ -1616,7 +1641,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 var nUn = unNames.length;
                 var nUn = unNames.length;
                 var okListText = nOk ? (nOk <= 4 ? okNames.join('、') : (okNames.slice(0, 3).join('、') + ' 等共' + nOk + '家')) : '—';
                 var okListText = nOk ? (nOk <= 4 ? okNames.join('、') : (okNames.slice(0, 3).join('、') + ' 等共' + nOk + '家')) : '—';
                 var unListText = nUn ? (nUn <= 4 ? unNames.join('、') : (unNames.slice(0, 3).join('、') + ' 等共' + nUn + '家')) : '—';
                 var unListText = nUn ? (nUn <= 4 ? unNames.join('、') : (unNames.slice(0, 3).join('、') + ' 等共' + nUn + '家')) : '—';
-                var tk = $('input[name=\'__token__\']').val() || '';
+                var tk = $('input[name=\'__token__\']').val() || $wrap.find('input[name=\'__token__\']').val() || '';
 
 
                 var confirmHtml = ''
                 var confirmHtml = ''
                     + '<div style="text-align:left;line-height:1.75;font-size:13px;">'
                     + '<div style="text-align:left;line-height:1.75;font-size:13px;">'
@@ -1630,9 +1655,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
 
                 var Lr = procuremenLayerTop();
                 var Lr = procuremenLayerTop();
                 if (!Lr || typeof Lr.confirm !== 'function') {
                 if (!Lr || typeof Lr.confirm !== 'function') {
-                    if (typeof Toastr !== 'undefined') {
-                        Toastr.error('弹层组件未就绪,请刷新后重试');
-                    }
+                    procuremenOutwardToast('弹层组件未就绪,请刷新后重试', 'error');
                     return;
                     return;
                 }
                 }
 
 
@@ -1654,14 +1677,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     }
                     }
                 }, function (idx) {
                 }, function (idx) {
                     Lr.close(idx);
                     Lr.close(idx);
-                    var postData = {
-                        __token__: tk,
-                        order_picks_json: JSON.stringify(orderPicks)
-                    };
                     FastRef.api.ajax({
                     FastRef.api.ajax({
                         url: FastRef.api.fixurl('procuremen/purchaseConfirmPick'),
                         url: FastRef.api.fixurl('procuremen/purchaseConfirmPick'),
                         type: 'POST',
                         type: 'POST',
-                        data: postData
+                        data: {
+                            __token__: tk,
+                            order_picks_json: JSON.stringify(orderPicks)
+                        }
                     }, function () {
                     }, function () {
                         if (typeof parent !== 'undefined' && parent.Layer) {
                         if (typeof parent !== 'undefined' && parent.Layer) {
                             var ix = parent.Layer.getFrameIndex(window.name);
                             var ix = parent.Layer.getFrameIndex(window.name);
@@ -1680,8 +1702,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         }
                         }
                     });
                     });
                 });
                 });
-            });
-            $wrap.on('click.procuremenPurchaseConfirm', '#btn-pod-purchase-reject', function () {
+            }
+
+            function onPurchaseRejectClick(e) {
+                if (e && typeof e.preventDefault === 'function') {
+                    e.preventDefault();
+                }
+                var FastRef = procuremenOutwardFastRef();
+                if (!FastRef || !FastRef.api) {
+                    procuremenOutwardToast('页面未就绪,请刷新后重试', 'error');
+                    return;
+                }
                 var rejectPicks = requiredSids.map(function (sid) {
                 var rejectPicks = requiredSids.map(function (sid) {
                     return {scydgy_id: String(sid)};
                     return {scydgy_id: String(sid)};
                 });
                 });
@@ -1690,7 +1721,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 }
                 }
                 var Lr = procuremenLayerTop();
                 var Lr = procuremenLayerTop();
                 if (!Lr || typeof Lr.confirm !== 'function') {
                 if (!Lr || typeof Lr.confirm !== 'function') {
-                    Toastr.error('弹层组件未就绪,请刷新后重试');
+                    procuremenOutwardToast('弹层组件未就绪,请刷新后重试', 'error');
                     return;
                     return;
                 }
                 }
                 Lr.confirm(
                 Lr.confirm(
@@ -1708,7 +1739,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                             url: FastRef.api.fixurl('procuremen/purchaseApprovalReject'),
                             url: FastRef.api.fixurl('procuremen/purchaseApprovalReject'),
                             type: 'POST',
                             type: 'POST',
                             data: {
                             data: {
-                                __token__: $('input[name=\'__token__\']').val() || $wrap.find('input[name=\'__token__\']').val(),
+                                __token__: $('input[name=\'__token__\']').val() || $wrap.find('input[name=\'__token__\']').val() || '',
                                 order_picks_json: JSON.stringify(rejectPicks)
                                 order_picks_json: JSON.stringify(rejectPicks)
                             }
                             }
                         }, function () {
                         }, function () {
@@ -1725,8 +1756,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         });
                         });
                     }
                     }
                 );
                 );
-            });
-            $wrap.on('click.procuremenPurchaseConfirm', '#btn-pod-purchase-close', function () {
+            }
+
+            function onPurchaseCloseClick(e) {
+                if (e && typeof e.preventDefault === 'function') {
+                    e.preventDefault();
+                }
                 if (typeof parent !== 'undefined' && parent.Layer) {
                 if (typeof parent !== 'undefined' && parent.Layer) {
                     var ixClose = parent.Layer.getFrameIndex(window.name);
                     var ixClose = parent.Layer.getFrameIndex(window.name);
                     if (typeof ixClose !== 'undefined' && ixClose !== null) {
                     if (typeof ixClose !== 'undefined' && ixClose !== null) {
@@ -1737,7 +1772,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 if (typeof Layer !== 'undefined' && typeof Layer.closeAll === 'function') {
                 if (typeof Layer !== 'undefined' && typeof Layer.closeAll === 'function') {
                     Layer.closeAll();
                     Layer.closeAll();
                 }
                 }
-            });
+            }
+
+            function bindOutwardPurchaseFooterButtons() {
+                $(document)
+                    .off('click.procuremenPurchaseConfirm', '#btn-pod-purchase-confirm')
+                    .on('click.procuremenPurchaseConfirm', '#btn-pod-purchase-confirm', onPurchaseConfirmClick)
+                    .off('click.procuremenPurchaseConfirm', '#btn-pod-purchase-reject')
+                    .on('click.procuremenPurchaseConfirm', '#btn-pod-purchase-reject', onPurchaseRejectClick)
+                    .off('click.procuremenPurchaseConfirm', '#btn-pod-purchase-close')
+                    .on('click.procuremenPurchaseConfirm', '#btn-pod-purchase-close', onPurchaseCloseClick);
+                $('#btn-pod-purchase-confirm').off('click.procuremenPurchaseConfirmDirect').on('click.procuremenPurchaseConfirmDirect', onPurchaseConfirmClick);
+                $('#btn-pod-purchase-reject').off('click.procuremenPurchaseConfirmDirect').on('click.procuremenPurchaseConfirmDirect', onPurchaseRejectClick);
+                $('#btn-pod-purchase-close').off('click.procuremenPurchaseConfirmDirect').on('click.procuremenPurchaseConfirmDirect', onPurchaseCloseClick);
+            }
+
+            bindOutwardPurchaseFooterButtons();
+            setTimeout(bindOutwardPurchaseFooterButtons, 350);
         },
         },
 
 
         details: function () {
         details: function () {