|
|
@@ -17,7 +17,7 @@
|
|
|
<td>@{{ template.name }}</td>
|
|
|
<td></td>
|
|
|
<td>
|
|
|
- <button type="button" class="btn-outline-primary" @click="edit(template,i)">编辑</button>
|
|
|
+ <button type="button" class="btn btn-outline-primary" @click="edit(template,i)">编辑关联</button>
|
|
|
</td>
|
|
|
<td>
|
|
|
<button type="button" class="btn btn-danger" @click="destroy(template.id,i)">删除</button>
|
|
|
@@ -26,6 +26,7 @@
|
|
|
</tr>
|
|
|
@include('maintenance.expressPrinting.template._edit')
|
|
|
</table>
|
|
|
+ {{ $templates->links() }}
|
|
|
</div>
|
|
|
@endsection
|
|
|
|
|
|
@@ -34,13 +35,14 @@
|
|
|
let vue = new Vue({
|
|
|
el:'#part-template',
|
|
|
data:{
|
|
|
- templates:{!! $templates !!},
|
|
|
- logistics:{!! $logistics !!},
|
|
|
- owners:{!! $owners !!},
|
|
|
- deliveryInterfaces:{!! $delivery_interfaces !!},
|
|
|
+ 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,
|
|
|
+ editTemplateLogistic:null,
|
|
|
},
|
|
|
mounted() {
|
|
|
this.init();
|
|
|
@@ -55,16 +57,15 @@
|
|
|
this.owners.forEach(function(owner){
|
|
|
// isActivation 是否激活
|
|
|
// selected 是否选中
|
|
|
- data[owner.id] = {isActivation:false,logistics:{},name:owner.name,selected:false};
|
|
|
+ data[owner.id] = {isActivation:false,logistics:{},name:owner.name,selected:false,id:owner.id};
|
|
|
self.logistics.forEach(function(logistic){
|
|
|
let interfaces = {}
|
|
|
- self['deliveryInterfaces'].forEach(function(i){
|
|
|
+ self['deliveryInterfaces'].forEach(function(i,index){
|
|
|
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){
|
|
|
@@ -87,17 +88,21 @@
|
|
|
template['owner_logistic_print_template'].forEach(function(item){
|
|
|
data[item.owner_id].isActivation = true;
|
|
|
data[item.owner_id].logistics[item.logistic_id].isActivation = true;
|
|
|
+ data[item.owner_id].logistics[item.logistic_id].interfaces[item.delivery_interface].isActivation = true;
|
|
|
});
|
|
|
|
|
|
this.editTemplate = JSON.parse(JSON.stringify(template));
|
|
|
this.editTemplate.index = index
|
|
|
this.editTemplate.data = data;
|
|
|
+
|
|
|
$("#edit-template").modal('show');
|
|
|
+ console.log(123);
|
|
|
},
|
|
|
selectOwner(data,owners){
|
|
|
if(data.selected === true){
|
|
|
data.selected = false;
|
|
|
this.editTemplateOwner = null
|
|
|
+ this.editTemplateLogistic = null;
|
|
|
return ;
|
|
|
}
|
|
|
for (const dataKey in owners) {
|
|
|
@@ -113,13 +118,73 @@
|
|
|
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
|
|
|
+ if (!confirm("是否取消模板和货主的关联")){return ;}
|
|
|
+ let url = "{{url("apiLocal/maintenance/expressPrinting/template/saveRelation")}}";
|
|
|
+ let data = {
|
|
|
+ 'owner_id' : model.id,
|
|
|
+ 'print_template_id' : this.editTemplate.id,
|
|
|
+ };
|
|
|
+ window.tempTip.setIndex(1999)
|
|
|
+ window.axios.post(url,data).then(res=>{
|
|
|
+ if (res.data.success){
|
|
|
+ window.tempTip.showSuccess("保存成功");
|
|
|
+ model.isActivation = false;
|
|
|
+ for (const key in model.logistics) {
|
|
|
+ if(model.logistics[key].isActivation) model.logistics[key].isActivation = false
|
|
|
+ }
|
|
|
+ this.$set(this.templates,this.editTemplate.index,res.data);
|
|
|
+ this.$forceUpdate();
|
|
|
+ return
|
|
|
+ }
|
|
|
+ window.tempTip.show("保存异常")
|
|
|
+ }).catch(err=>{
|
|
|
+ window.tempTip.show(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 取消 货主和承运商的关联
|
|
|
+ cancelOwnerLogisticRelation(logistic,model){
|
|
|
+ if (!confirm("是否取消模板,货主和承运商的关联")){return ;}
|
|
|
+ let url = "{{url("apiLocal/maintenance/expressPrinting/template/saveRelation")}}";
|
|
|
+ let data = {
|
|
|
+ 'owner_id' : this.editTemplateOwner.id,
|
|
|
+ 'logistic_id' : logistic.id,
|
|
|
+ 'print_template_id' : this.editTemplate.id,
|
|
|
+ };
|
|
|
+ window.tempTip.setIndex(1999)
|
|
|
+ window.axios.post(url,data).then(res=>{
|
|
|
+ if (res.data.success){
|
|
|
+ logistic.isActivation = false
|
|
|
+ this.editTemplateLogistic = null;
|
|
|
+ for (const dataKey in logistic.interfaces) {
|
|
|
+ logistic.interfaces[dataKey].selected = false;
|
|
|
+ logistic.interfaces[dataKey].isActivation = false
|
|
|
+ }
|
|
|
+ this.$set(this.templates,this.editTemplate.index,res.data);
|
|
|
+ this.$forceUpdate()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ window.tempTip.show("保存异常")
|
|
|
+ }).catch(err=>{
|
|
|
+ window.tempTip.show(err)
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ selectOwnerLogistic(logistic,model){
|
|
|
+ if (logistic.selected === true){
|
|
|
+ logistic.selected = false;
|
|
|
+ this.editTemplateLogistic = null;
|
|
|
+ return ;
|
|
|
}
|
|
|
- this.$forceUpdate();
|
|
|
+ for (const dataKey in model.logistics) {
|
|
|
+ if (dataKey!==logistic.id){
|
|
|
+ model.logistics[dataKey].selected = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logistic.selected = true;
|
|
|
+ this.editTemplateLogistic = logistic;
|
|
|
},
|
|
|
isChecking(){
|
|
|
if(this.editTemplate === null)return false;
|
|
|
@@ -131,24 +196,31 @@
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
- save(){
|
|
|
- let url = "{{url('apiLocal/maintenance/expressPrinting/template/saveRelation')}}"
|
|
|
- let data = this.editTemplate;
|
|
|
- window.tempTip.setIndex(1999);
|
|
|
+ saveOwnerLogisticPrinterTempRelation(item,islink){
|
|
|
+ if (!islink && !confirm("是否取消当前关联关系")){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ let url = "{{url("apiLocal/maintenance/expressPrinting/template/saveRelation")}}";
|
|
|
+ let data = {
|
|
|
+ 'owner_id' : this.editTemplateOwner.id,
|
|
|
+ 'logistic_id' : this.editTemplateLogistic.id,
|
|
|
+ 'print_template_id' : this.editTemplate.id,
|
|
|
+ 'delivery_interface' : item.interface,
|
|
|
+ 'is_save':islink
|
|
|
+ }
|
|
|
+ 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 ;
|
|
|
+ this.$set(this.templates,this.editTemplate.index,res.data.data);
|
|
|
+ window.tempTip.showSuccess("保存成功");
|
|
|
+ item.isActivation = islink;
|
|
|
+ return
|
|
|
}
|
|
|
- window.tempTip.show('修改失败,刷新后重试');
|
|
|
+ window.tempTip.show("保存异常")
|
|
|
}).catch(err=>{
|
|
|
window.tempTip.show(err)
|
|
|
})
|
|
|
- },
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
</script>
|