141 lines
5.9 KiB
PHP
141 lines
5.9 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, specIndex) in spec_group.length">
|
|
<div class="form-group row form-field" initialized="1" >
|
|
<label class="text-capitalize control-label" style="font-weight: bold;">@{{spec_group[specIndex].name}}</label>
|
|
<table class="table table-hover">
|
|
<tbody class="kv-table">
|
|
<tr v-for="(spec, itemIndex) in spec_group[specIndex].specs">
|
|
<td>
|
|
<div class="form-group " style="margin-bottom: 0 !important;">
|
|
<div class="col-sm-12">
|
|
<select v-model="spec.name" class="form-control">
|
|
<option value="NONE">未选择</option>
|
|
<option v-for="(options,id) in spec_items[specIndex]" :key="id" :value="options">@{{options}}</option>
|
|
</select>
|
|
<!-- <input name="" class="form-control" v-model="spec.name" disabled> -->
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div class="form-group " style="margin-bottom: 0 !important;">
|
|
<div class="col-sm-12">
|
|
<div class="input-group">
|
|
<span class="input-group-prepend"><span class="input-group-text bg-white">¥</span></span>
|
|
<input name="" class="form-control" placeholder="输入 属性价格" v-model="spec.value">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td style="width: 85px;">
|
|
<div class="list-remove btn btn-white btn-sm pull-right" v-on:click="delSpecs(specIndex, itemIndex)">
|
|
<i class="feather icon-trash"> </i>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
<tfoot>
|
|
<tr>
|
|
<td colspan="4">
|
|
<div class="list-add btn btn-primary btn-outline btn-sm pull-left" v-on:click="addSpecs(specIndex)">
|
|
<i class="feather icon-plus"></i> 新增
|
|
</div>
|
|
<div class="text-center"></div>
|
|
</td>
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
</div>
|
|
</template>
|
|
<input type="hidden" name="{{ $name }}" :value="getSpecs">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@include('admin::form.help-block')
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script init="{!! $selector !!}">
|
|
|
|
var vm = new Vue({
|
|
el: '#' + id,
|
|
data: {
|
|
spec_group:[],
|
|
spec_items:[],
|
|
},
|
|
computed: {
|
|
getSpecs() {
|
|
return JSON.stringify(this.spec_group);
|
|
}
|
|
},
|
|
methods: {
|
|
addSpecs(specIndex){
|
|
this.spec_group[specIndex].specs.push(
|
|
{
|
|
name:"NONE",
|
|
value:"0"
|
|
}
|
|
);
|
|
},
|
|
delSpecs(specIndex, itemIndex){
|
|
if(this.spec_group[specIndex].specs[itemIndex]){
|
|
if(itemIndex >= 0){
|
|
let arr = this.spec_group[specIndex].specs;
|
|
this.spec_group[specIndex].specs = (arr.slice(0, itemIndex).concat(arr.slice(itemIndex+1,arr.length)));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
function getTypeSpecs(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.spec_group = [];
|
|
if(result.specs.length > 0){
|
|
for(j = 0, len=result.specs.length; j < len; j++){
|
|
vm.spec_group.push({
|
|
name:result.specs[j].name,
|
|
specs:[]
|
|
});
|
|
let items = [];
|
|
if(result.specs[j] && result.specs[j].specs.length > 0){
|
|
for(i = 0, llen = result.specs[j].specs.length; i <llen; i++){
|
|
items.push(result.specs[j].specs[i].name);
|
|
}
|
|
}
|
|
vm.spec_items[j] = items;
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
$("[name='{{ $listen }}']").on('change', function(){
|
|
var group_id = this.options[this.options.selectedIndex].value;
|
|
// alert(group_id);
|
|
getTypeSpecs(group_id);
|
|
})
|
|
|
|
</script>
|