Jelajahi Sumber

临时提交

ajun 4 tahun lalu
induk
melakukan
60b7b65277

+ 7 - 3
app/Http/Controllers/PrintTemplateController.php

@@ -3,6 +3,8 @@
 namespace App\Http\Controllers;
 
 use App\Components\AsyncResponse;
+use App\Logistic;
+use App\Owner;
 use App\PrintPartImage;
 use App\PrintTemplate;
 use App\Services\PrintTemplateService;
@@ -17,7 +19,9 @@ class PrintTemplateController extends Controller
         $templates = PrintTemplate::query()->with(['ownerLogisticPrintTemplate' => function ($query) {
             $query->with(['owner', 'logistic']);
         }])->get();
-        return view('/maintenance/expressPrinting/template/index', compact('templates'));
+        $owners = Owner::query()->get();
+        $logistics = Logistic::query()->get();
+        return view('/maintenance/expressPrinting/template/index', compact('templates','owners','logistics'));
     }
 
     public function create(PrintTemplateService $service)
@@ -54,9 +58,9 @@ class PrintTemplateController extends Controller
         return ['success' => true, 'data' => $print_template];
     }
 
-    public function destroyApi(Request $request)
+    public function destroyApi($id)
     {
-        $printTemplate = PrintTemplate::query()->find($request['id']);
+        $printTemplate = PrintTemplate::query()->find($id);
         $printTemplate->delete();
         $this->success('删除成功');
     }

+ 7 - 0
app/Http/Controllers/TestController.php

@@ -63,6 +63,7 @@ use App\Services\common\BatchUpdateService;
 use App\Services\common\DataHandlerService;
 use App\Services\common\QueryService;
 use App\Services\DeliveryAppointmentService;
+use App\Services\DeliveryService;
 use App\Services\DocWaveHeaderService;
 use App\Services\FeatureService;
 use App\Services\InventoryCompareService;
@@ -1739,4 +1740,10 @@ TEXT;
         $iname = str_replace(PHP_EOL, '', $name);
         var_dump($iname);
     }
+
+    public function testDelete()
+    {
+        $service = new DeliveryService();
+        $service->destroyFile();
+    }
 }

+ 24 - 0
resources/views/maintenance/expressPrinting/template/_create.blade.php

@@ -0,0 +1,24 @@
+<div class="modal" tabindex="-1">
+    <div class="modal-dialog">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">模板关联</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <template v-for="owner in owners">
+                    <tempalate v-for="logistic in logistics">
+                        
+                    </tempalate>
+                </template>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-primary">保存</button>
+            </div>
+        </div>
+    </div>
+
+</div>

+ 64 - 10
resources/views/maintenance/expressPrinting/template/edit.blade.php

@@ -82,8 +82,40 @@
                 this.productionParts.printParts.forEach(function(item,index,array){
                     if (self.z_index < item['z_index'])self.z_index = item['z_index']+1;
                 });
+                this.initCode();
             },
             methods: {
+                initCode(){
+                    let self = this;
+                    console.log(this.productionParts.printParts);
+                    this.productionParts.printParts.forEach(function(item){
+                        if (item.type==="stripeCode"){
+                            setTimeout(function () {
+                                window.setBarcode("0123456789", "#svg" + item.id, 2, 50, true)
+                            }, 1000);
+                        }else if(item.type === 'qRCode'){
+                            setTimeout(function () {
+                                new QRCode(document.getElementById(item.id), {
+                                    text: "占位二维码",
+                                    width: item.height,
+                                    height: item.height,
+                                    colorDark : "#000000",
+                                    colorLight : "#ffffff",
+                                    correctLevel : QRCode.CorrectLevel.H
+                                });
+                            }, 1000)
+                        } else if(item.type === "image"){
+                            let images = self.images.filter(function(img){
+                                return img.name === item.value;
+                            })
+                            let img = images.shift();
+                            console.log(img);
+                            let element = document.getElementById(item.id);
+                            // element.setAttribute('src',)
+                        }
+                    });
+                },
+                // 添加组件至面板上
                 // 添加组件至面板上
                 _addPartToProductionPanel(printPart) {
                     let _clone = JSON.parse(JSON.stringify(printPart));
@@ -107,13 +139,12 @@
                     this.productionParts.printParts.push(print_part);  // 添加入组件列表中
                     if (print_part.type === "stripeCode") {
                         setTimeout(function () {
-                            console.log(123);
-                            window.setBarcode("0123456789", "#" + print_part.id, 2, 50, true)
+                            window.setBarcode("0123456789", "#svg" + print_part.id, 2, 50, true)
                         }, 100);
                     } else if (print_part.type === "qRCode") {
                         setTimeout(function () {
                             new QRCode(document.getElementById(print_part.id), {
-                                text: "占位二维码",
+                                text: "0123456789",
                                 width: print_part.width,
                                 height: print_part.height,
                                 colorDark : "#000000",
@@ -122,7 +153,7 @@
                             });
                         }, 1000)
                     } else if (print_part.type === "image") {
-                        // TODO 修改为图片
+
                     }
                 },
                 // 从面板删除组件
@@ -136,7 +167,6 @@
                     this.productionParts.printParts.splice(this.productionParts.editIndex, 1);
                     this.$forceUpdate();
                 },
-
                 // 打开保存modal
                 showSaveModal() {
                     $('#saveModal').modal('show');
@@ -148,10 +178,11 @@
                     let printTemplate = JSON.parse(JSON.stringify(this.productionParts.printParts));
                     printTemplate.push(this.productionParts.bg);
                     let data = {
+                        id: this.printTemplate.id,
                         name: this.productionParts.addPart.name,
                         value: printTemplate
                     };
-                    window.axios.post("{{url('apiLocal/maintenance/expressPrinting/template/create')}}", data).then(res => {
+                    window.axios.post("{{url('apiLocal/maintenance/expressPrinting/template/update')}}", data).then(res => {
                         if (res.data.success) {
                             tempTip.showSuccess('保存成功!');
                             $('#saveModal').modal('hide');
@@ -187,15 +218,28 @@
                         height: item.height + 'px',
                         left: item.left + 'px',
                         top: item.top + 'px',
-                        'white-space': 'pre',
                         'z-index' : item['z_index'],
                     };
-                    if (item['border-width']) {
+                    if (item.type === 'textBox'){
+                        style['font-size'] = item['font-size'];
                         style['border-width'] = item['border-width']+'px';
                         style['border-color'] = '#000';
                         style['border-style'] = 'solid';
+                        style['display'] = 'flex'
+                        style['justify-content'] = item['justify-content']
+                        style['align-items'] = item['align-items']
+                        style['text-align'] = 'center'
+                    } else if (item.type === 'qRCode'){
+                        style.width = 100+'px';
+                        style.height = 100+'px';
+                        let scale = item.scale;
+                        if(scale){
+                            style.transform =  `scale(${scale},${scale})`;
+                        }
+                    } else if (item.type === 'stripeCode'){
+                        let scale = item.scale;
+                        style.transform =  `scale(${scale},${scale})`;
                     }
-                    if (item['font-size']) style['font-size'] = item['font-size'];
                     return style;
                 },
                 getImageSrc(image){
@@ -203,8 +247,18 @@
                 },
                 setImageBg(image){
                     let src =  this.getImageSrc(image);
-                    this.productionParts.editPart.value = image.name;
+                    this.productionParts.editPart.text = image.name;
                     document.getElementById(this.productionParts.editPart.id).setAttribute('src',src) ;
+                },
+                changeStripeCodeWidth(){
+                    let default_width = 404;
+                    if (this.productionParts.editPart.type === 'qRCode')default_width = 100;
+                    this.productionParts.editPart.scale = this.productionParts.editPart.width / default_width;
+                },
+                changeStripeCodeScale(){
+                    let default_width = 404;
+                    if (this.productionParts.editPart.type === 'qRCode')default_width = 100;
+                    this.productionParts.editPart.width = default_width * this.productionParts.editPart.scale;
                 }
             }
         });

+ 16 - 5
resources/views/maintenance/expressPrinting/template/index.blade.php

@@ -15,7 +15,6 @@
                 <td>@{{ i+1 }}</td>
                 <td>@{{ template.name }}</td>
                 <td></td>
-{{--                <td>@{{ template.value }}</td>--}}
                 <td>
                     <button type="button" class="btn btn-danger" @click="destroy(template.id,i)">删除</button>
                     <a class="btn btn-primary" :href="'{{url('maintenance/expressPrinting/template/edit')}}'+'/'+template.id" :target="'maintenance/expressPrinting/template/edit'+template.id">编辑模板</a>
@@ -31,14 +30,26 @@
             el:'#part-template',
             data:{
                 templates:{!! $templates !!},
+                logistics:{!! $logistics !!},
+                owners:{!! $owners !!},
             },
             methods:{
                 destroy(id,i){
                     if (!confirm('是否删除当前模板')) return;
-                    tempTip.setDuration(3000);
-                    window.tempTip.postBasicRequest("{{url('apiLocal/maintenance/expressPrinting/template/destroy')}}",{id:id},res=>{
-                        tempTip.showSuccess('删除成功');
-                        this.$delete(this.templates,i);
+                    let url = "{{url('apiLocal/maintenance/expressPrinting/template')}}"+"/"+id;
+                    window.axios.delete(url).then(res=>{
+                        if(res.data.success){
+                            window.tempTip.showSuccess('删除成功');
+                            this.$delete(this.templates,i);
+                        }
+                    }).catch(err=>{
+                        window.tempTip.show('删除异常:'+err);
+                    })
+                },
+                edit(template){
+                    let data = [];
+                    template.owner_logistic_print_template.forEach(function(item){
+
                     });
                 },
             }

+ 2 - 1
routes/apiLocal.php

@@ -142,7 +142,8 @@ Route::group(['prefix'=>'maintenance'],function (){
 
         Route::group(['prefix'=>'template'],function(){
             Route::post('create','PrintTemplateController@storeApi');
-            Route::post('destroy','PrintTemplateController@destroyApi');
+            Route::delete('{id}','PrintTemplateController@destroyApi');
+            Route::post('update','PrintTemplateController@updateApi');
         });
         Route::group(['prefix' => 'setting'],function () {
             Route::group(['prefix' => 'terminal'],function () {