Browse Source

修改前端页面

ajun 4 years ago
parent
commit
bc8deff848

+ 16 - 12
resources/views/maintenance/expressPrinting/print/template.blade.php

@@ -77,7 +77,6 @@
                     window.axios.post(url, data).then(res => {
                         this.printItems = res.data.data
                         this.$forceUpdate();
-                        console.log(this.printItems);
                     }).catch(err => {
                         console.log(err);
                     });
@@ -85,23 +84,18 @@
                 // TODO GoWs 返回信息
                 receiveGoWebSocketMessage(meg) {
                     this.goWebSocketStatus = 1;
-                    console.log("receiveGoWebSocketMessage");
                     let res = JSON.parse(meg.data)
-                    console.log(meg)
                     if (res.operation === 'print') {
                         if (res.status === true) {
-                            console.log('receiveGoWebSocketMessage->print');
-                            console.log(res)
                         }
-                    } else if (res.operation === 'preview') {
+                    } else if (res.operation === 'preview' ) {
                         if (res.status === "success") {
-                            console.log('receiveGoWebSocketMessage->preview');
-                            console.log(res)
                             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;
@@ -115,7 +109,6 @@
                     window.axios.post(url, data).then(res => {
                         console.log(res)
                         if (res.data.success) {
-
                             res.data.data.forEach(function (item) {
                                 self.printItems.forEach(function (data, index, array) {
                                     if (data['logistic_number'] === item['logistic_number']) {
@@ -149,15 +142,15 @@
                 },
                 // TODO GoWebSocket 链接成功
                 GoWebSocketOpen() {
-
+                    this.goWebSocketStatus = 0;
                 },
                 // TODO GoWebSocket 链接关闭
                 GoWebSocketClose() {
-                    this.goWebSocketStatus = 1
+                    this.goWebSocketStatus = 1;
                 },
                 // TODO  GoWebSocket 关闭
                 closeGoWebSocket() {
-                    this.goWebSocketStatus = 2
+                    this.goWebSocketStatus = 2;
                     this.goWebSocket.close();
                 },
                 // TODO 推动到GoWs 获取打印图片
@@ -177,11 +170,22 @@
                     this.initGoWebSocket();
                     let self = this;
                     this.printItems.forEach(function (item) {
+
                         item['operation'] = 'print';
+
                         item['printer_name'] = 'Microsoft XPS Document Writer';
+
                         self.goWebSocket.send(JSON.stringify(item));
                     });
                 },
+                getPrinters(){
+                    let url ="";
+                    window.axios.get(url).then(res=>{
+
+                    }).catch(err=>{
+
+                    })
+                }
             }
         });
 

+ 100 - 3
resources/views/maintenance/expressPrinting/template/index.blade.php

@@ -9,17 +9,22 @@
                 <th>序号</th>
                 <th>名称</th>
                 <th>内容</th>
+                <th>绑定</th>
                 <th>操作</th>
             </tr>
             <tr v-for="(template,i) in templates">
                 <td>@{{ i+1 }}</td>
                 <td>@{{ template.name }}</td>
                 <td></td>
+                <td>
+                    <button type="button" class="btn-outline-primary" @click="edit(template,i)">编辑</button>
+                </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>
                 </td>
             </tr>
+            @include('maintenance.expressPrinting.template._edit')
         </table>
     </div>
 @endsection
@@ -32,8 +37,36 @@
                 templates:{!! $templates !!},
                 logistics:{!! $logistics !!},
                 owners:{!! $owners !!},
+                deliveryInterfaces:{!! $delivery_interfaces !!},
+                editTemplate:null,
+                templateMode:null,
+                editTemplateOwner:null,
+            },
+            mounted() {
+                this.init();
+            },
+            computed:{
+
             },
             methods:{
+                init(){
+                    let self = this;
+                    let data = {};
+                    this.owners.forEach(function(owner){
+                        // isActivation 是否激活
+                        // selected 是否选中
+                        data[owner.id] = {isActivation:false,logistics:{},name:owner.name,selected:false};
+                        self.logistics.forEach(function(logistic){
+                            let interfaces = {}
+                            self['deliveryInterfaces'].forEach(function(i){
+                                interfaces[i] ={isActivation:false,interface:i}
+                            })
+                            data[owner.id].logistics[logistic.id] = {isActivation:false,id:logistic.id,name:logistic.name,selected:false,interfaces:interfaces}
+                        })
+                    });
+                    console.log(data);
+                    this.templateMode = data;
+                },
                 destroy(id,i){
                     if (!confirm('是否删除当前模板')) return;
                     let url = "{{url('apiLocal/maintenance/expressPrinting/template')}}"+"/"+id;
@@ -46,11 +79,75 @@
                         window.tempTip.show('删除异常:'+err);
                     })
                 },
-                edit(template){
-                    let data = [];
-                    template.owner_logistic_print_template.forEach(function(item){
+                edit(template,index){
+                    let data = JSON.parse(JSON.stringify(this.templateMode));
+
+                    if (!template['owner_logistic_print_template']) return
 
+                    template['owner_logistic_print_template'].forEach(function(item){
+                        data[item.owner_id].isActivation = true;
+                        data[item.owner_id].logistics[item.logistic_id].isActivation = true;
                     });
+
+                    this.editTemplate = JSON.parse(JSON.stringify(template));
+                    this.editTemplate.index = index
+                    this.editTemplate.data = data;
+                    $("#edit-template").modal('show');
+                },
+                selectOwner(data,owners){
+                    if(data.selected === true){
+                        data.selected = false;
+                        this.editTemplateOwner = null
+                        return ;
+                    }
+                    for (const dataKey in owners) {
+                        if (dataKey!==data.id){
+                            owners[dataKey]['selected'] = false;
+                        }
+                    }
+                    data.selected = true;
+                    this.editTemplateOwner = data;
+                },
+                // 添加货主关联
+                linkOwnerRelation(model){
+                    model.isActivation = true;
+                    this.$forceUpdate();
+                },
+                // 取消货主关联
+                cancelOwnerRelation(model){
+                    model.isActivation = false;
+                    for (const key in model.logistics) {
+                        if(model.logistics[key].isActivation) model.logistics[key].isActivation = false
+                    }
+                    this.$forceUpdate();
+                },
+                isChecking(){
+                    if(this.editTemplate === null)return false;
+                    if (this.editTemplate.data === null )return false;
+                    for (const argumentsKey in this.editTemplate.data) {
+                        if (this.editTemplate.data[argumentsKey].isActivation === true){
+                            return true;
+                        }
+                    }
+                    return false;
+                },
+                save(){
+                    let url = "{{url('apiLocal/maintenance/expressPrinting/template/saveRelation')}}"
+                    let data = this.editTemplate;
+                    window.tempTip.setIndex(1999);
+                    window.axios.post(url,data).then(res=>{
+                        if (res.data.success){
+                            this.$set(this.templates,this.editTemplate.index,res.data);
+                            window.tempTip.showSuccess('修改成功');
+                            $("#edit-template").modal('hide');
+                            this.editTemplate = null;
+                            this.editTemplateOwner = null;
+                            return ;
+                        }
+                        window.tempTip.show('修改失败,刷新后重试');
+                    }).catch(err=>{
+                        window.tempTip.show(err)
+                    })
                 },
             }
         });