ajun 4 лет назад
Родитель
Сommit
042f013b0e

+ 1 - 1
app/Http/Controllers/PrintTemplateController.php

@@ -22,7 +22,7 @@ class PrintTemplateController extends Controller
         }])->paginate($request['paginate'] ?? 50);
         $owners = Owner::query()->get();
         $logistics = Logistic::query()->get();
-        return view('maintenance.expressPrinting.template.index', compact('templates','owners','logistics','delivery_interfaces'));
+        return view('maintenance.expressPrinting.template.index', compact('templates','owners','logistics'));
     }
 
     public function create(PrintTemplateService $service)

+ 1 - 2
app/Http/Controllers/TestController.php

@@ -1755,8 +1755,7 @@ TEXT;
 
 
     public function showOrderInfo(){
-        
+        dump("admin");
     }
 
-
 }

+ 53 - 22
resources/views/maintenance/expressPrinting/print/template.blade.php

@@ -19,6 +19,9 @@
                 <button class="btn btn-success" @click="wsPrintImage">GoWebSocket 打印</button>
                 <button class="btn btn-outline-warning" @click="initGoWebSocket">GoWebSocket 重置</button>
                 <button class="btn btn-outline-warning" @click="getPrinters">获取打印机</button>
+
+                <button class="btn btn-dark" @click="getImage">获取图片</button>
+                <button class="btn btn-dark" @click="printImage">打印图片</button>
             </div>
 
             <div class="container">
@@ -37,6 +40,7 @@
             <div class="alert alert-primary" v-if="goWebSocketStatus === 3" @click="initGoWebSocket">
                 链接错误
             </div>
+
         </div>
         <div class="card">
             <ul class="list-group">
@@ -51,6 +55,8 @@
                     </li>
                 </template>
             </ul>
+
+            <img src="" alt="" id="cImage">
         </div>
     </div>
 
@@ -69,7 +75,8 @@
             el: '#list',
             data: {
                 printItems: [],
-                goWebSocketPath: "ws://127.0.0.1:11101/print",
+                // goWebSocketPath: "ws://127.0.0.1:11101/print",
+                goWebSocketPath: "ws://127.0.0.1:11011/printer",
                 goWebSocket: null,
                 goWebSocketStatus: 0,
 
@@ -79,20 +86,19 @@
                 pddWebSocket: null,
                 pddWebSocketPath: "ws://127.0.0.1:5000",
                 pddWebSocketStatus: null,
-
                 clientPrinters: {
                     defaultPrinter: "",
                     printers: [],
                 },
-            },
+                base64String:null,            },
             created() {
 
             },
             mounted() {
                 // 初始化 go 链接
-                // this.initGoWebSocket();
-                this.initPddWebSocket();
-                this.initCnWebSocket();
+                this.initGoWebSocket();
+                // this.initPddWebSocket();
+                // this.initCnWebSocket();
 
             },
             methods: {
@@ -147,23 +153,33 @@
                 },
                 // TODO GoWs 返回信息
                 receiveGoWebSocketMessage(meg) {
-                    this.goWebSocketStatus = 1;
-                    let res = JSON.parse(meg.data)
-                    if (res.operation === 'print') {
-                        if (res.status === true) {
-                        }
-                    } else if (res.operation === 'preview') {
-                        if (res.status === "success") {
-                            this.printItems.forEach(function (item) {
-                                if (item['task_id'] === res['task_id']) {
-                                    item['base64'] = res.data.shift();
-                                }
-                            })
-                            this.$forceUpdate();
-                        }
-                    } else if (res.operation === 'line') {
-                        if (res.status === '') this.goWebSocketStatus = 1;
+                    let data  = meg.data;
+                    data = JSON.parse(data)
+                    console.log(data)
+                    if (data.Status === true){
+                        let image = document.getElementById("cImage");
+                        console.log(image)
+                        console.log(data.Base64)
+                        this.base64String = data.Base64;
+                        image.setAttribute("src","data:image/jpeg;base64,"+data.Base64)
                     }
+                    // this.goWebSocketStatus = 1;
+                    // let res = JSON.parse(meg.data)
+                    // if (res.operation === 'print') {
+                    //     if (res.status === true) {
+                    //     }
+                    // } else if (res.operation === 'preview') {
+                    //     if (res.status === "success") {
+                    //         this.printItems.forEach(function (item) {
+                    //             if (item['task_id'] === res['task_id']) {
+                    //                 item['base64'] = res.data.shift();
+                    //             }
+                    //         })
+                    //         this.$forceUpdate();
+                    //     }
+                    // } else if (res.operation === 'line') {
+                    //     if (res.status === '') this.goWebSocketStatus = 1;
+                    // }
                 },
                 // TODO 发送到后台进行加工
                 {{--uploadPrintData() {--}}
@@ -212,6 +228,7 @@
                     };
                     this.goWebSocket.onclose = function () {
                         self.goWebSocketStatus = 2
+                        alert("onclose")
                     };
 
                     this.goWebSocket.onerror = function () {
@@ -410,6 +427,20 @@
                         self.previewLogisticFace(item)
                     })
                 },
+                getImage(){
+                    let data = {
+                        processType:"getBase64Image",
+                        url:"https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/exp/w=480/sign=2c1fdf63d909b3deebbfe560fcbe6cd3/fd039245d688d43ffdc5e9f9751ed21b0ef43b48.jpg"
+                    }
+                    this.goWebSocket.send(JSON.stringify(data))
+                },
+                printImage(){
+                    let data = {
+                        processType:"printImage",
+                        base64:this.base64String
+                    };
+                    this.goWebSocket.send(JSON.stringify(data));
+                }
             }
         });
 

+ 0 - 1
resources/views/maintenance/expressPrinting/template/index.blade.php

@@ -38,7 +38,6 @@
                 templates:{!! $templates->toJson() !!}['data'],
                 logistics:[@foreach($logistics as $logistic ){!! $logistic !!},@endforeach],
                 owners:[@foreach($owners as $owner ){!! $owner !!},@endforeach],
-                deliveryInterfaces:[@foreach($delivery_interfaces as $key=>$delivery_interface)'{!! $delivery_interface !!}',@endforeach],
                 editTemplate:null,
                 templateMode:null,
                 editTemplateOwner:null,