6
0
Fork 0
jiqu-library-server/resources/views/admin/form/product-select-attr.blade.php

104 lines
3.6 KiB
PHP

<div class="{{$viewClass['form-group']}}">
<label class="{{$viewClass['label']}} control-label">{!! $label !!}</label>
<div class="{{$viewClass['field']}}">
@include('admin::form.error')
<div class="{{ $class }}" style="width: 100%; height: 100%;">
<div class="card">
<div class="card-body">
<template v-for="(n, attrIndex) in attr_group.length">
<div class="form-group row form-field" initialized="1" >
<label class="text-capitalize control-label" style="font-weight: bold;">@{{attr_group[attrIndex].name}}</label>
<table class="table table-hover">
<tbody class="kv-table">
<tr v-for="(attr) in attr_group[attrIndex].attrs">
<td>
<div class="form-group ">
<div class="col-sm-12">
<div class="help-block with-errors"></div>
<input name="" class="form-control" v-model="attr.name" disabled>
</div>
</div>
</td>
<td>
<div class="form-group ">
<div class="col-sm-12">
<div class="help-block with-errors"></div>
<input name="" class="form-control" v-model="attr.value">
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<input type="hidden" name="{{ $name }}" :value="getAttrs">
</div>
</div>
</div>
@include('admin::form.help-block')
</div>
</div>
<script init="{!! $selector !!}">
var vm = new Vue({
el: '#' + id,
data: {
attr_group:[],
},
created() {
this.createStart();
},
computed: {
getAttrs() {
return JSON.stringify(this.attr_group);
}
},
methods:{
createStart(){//初始化数据
var selectAttrValue = (new Function("return " + '{!! $value !!}'))();
if(selectAttrValue && selectAttrValue.length > 0){
for(j = 0, len=selectAttrValue.length; j < len; j++){
this.attr_group.push(selectAttrValue[j]);
}
}
},
}
});
function getTypeAttrs(group_id){
var url_path = "{{ admin_route('api.product_group_details') }}";
var goods_id = 0;
$.ajax({
type: 'get',
dataType: 'json',
url: url_path,
data: {
'group_id':group_id,
},
success: function (result) {
vm.attr_group = [];
if(result.attrs.length > 0){
for(j = 0, len=result.attrs.length; j < len; j++){
vm.attr_group.push(result.attrs[j]);
}
}
}
})
}
$("[name='{{ $listen }}']").on('change', function(){
var group_id = this.options[this.options.selectedIndex].value;
// alert(group_id);
getTypeAttrs(group_id);
})
</script>