|
|
@@ -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)
|
|
|
+ })
|
|
|
},
|
|
|
}
|
|
|
});
|