瀏覽代碼

问题件快递单号复制功能修复

ajun 5 年之前
父節點
當前提交
3bb38d2447
共有 1 個文件被更改,包括 31 次插入29 次删除
  1. 31 29
      resources/views/order/issue/index.blade.php

+ 31 - 29
resources/views/order/issue/index.blade.php

@@ -623,6 +623,7 @@
                 </div>
             </div>
         </div>
+        <textarea  id="clipboardDiv" style="opacity:0"></textarea>
     </div>
 
 @endsection
@@ -1009,38 +1010,39 @@
                     }
                 },
                 copyOrderNo() {
-                    try{
-                        let _this = this;
-                        if (this.checkData.length === 0) {
-                            tempTip.show('没有勾选订单');
-                            return;
-                        }
-                        let orderNos = [];
-                        $.each(this.orderIssues,function(index,orderIssue){
-                            if (_this.checkData.includes(orderIssue.id)) {
-                                if(orderIssue.order.packages){
-                                    $.each(orderIssue.order.packages,function(i,package){
-                                        orderNos.push(package.logistic_number);
-                                    });
-                                }
+                    let _this = this;
+                    if (this.checkData.length === 0) {
+                        tempTip.show('没有勾选订单');
+                        return;
+                    }
+                    let orderNos = [];
+                    $.each(this.orderIssues,function(index,orderIssue){
+                        if (_this.checkData.includes(orderIssue.id)) {
+                            if(orderIssue.order.packages){
+                                $.each(orderIssue.order.packages,function(i,package){
+                                    orderNos.push(package.logistic_number);
+                                });
                             }
-                        });
-                        if (orderNos.length === 0) {
-                            tempTip.setDuration(2200);
-                            tempTip.show('勾选的问题件没有对应的快递单号');
-                            return;
                         }
-                        let p = $('<textarea class="d-none" id="copy" />'+orderNos.join('\n')+'</textarea>');
-                        $('body').append(p);
-                        let p_ele = document.getElementById('copy');
-                        p_ele.select();
+                    });
+                    if (orderNos.length === 0) {
+                        tempTip.setDuration(2200);
+                        tempTip.show('勾选的问题件没有对应的快递单号');
+                        return;
+                    }
+                    this.copyText(orderNos.join('\n'));
+                },
+                copyText(text){
+                    try {
+                        $('#clipboardDiv').text(text).select().focus();
                         document.execCommand("Copy");
-                        p.remove();
-                        tempTip.setDuration(1200);
-                        tempTip.showSuccess('复制快递单号成功');
-                    }catch(err){
-                        tempTip.setDuration(2000);
-                        tempTip.show('复制快递单号失败'+err);
+                        tempTip.setIndex(1052)
+                        tempTip.setDuration(2000)
+                        tempTip.showSuccess('复制成功')
+                    } catch (e) {
+                        tempTip.setIndex(1052)
+                        tempTip.setDuration(2000)
+                        tempTip.showSuccess('复制失败:'+e)
                     }
                 },
                 checkAll(e) {