106 lines
3.8 KiB
PHP
106 lines
3.8 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">
|
|
<div class="form-group row form-field" initialized="1" >
|
|
<table class="table table-hover">
|
|
<tbody class="kv-table">
|
|
<tr v-for="i in extend_data">
|
|
<td>
|
|
<div class="form-group " style="margin-bottom: 0 !important;">
|
|
<div class="col-sm-12 input-group">
|
|
<div class="help-block with-errors"></div>
|
|
<span class="input-group-prepend"><span class="input-group-text bg-white">@{{i.unit}}</span></span>
|
|
<input name="" class="form-control" v-model="i.name" disabled>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div class="form-group " style="margin-bottom: 0 !important;">
|
|
<div class="col-sm-12 input-group">
|
|
<div class="help-block with-errors"></div>
|
|
<input name="" class="form-control" v-model="i.value" onInput="value=value.replace(/[^\d^\.]+/g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.')" :placeholder="i.unit">
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<input type="hidden" name="{{ $name }}" :value="getExtends">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@include('admin::form.help-block')
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script init="{!! $selector !!}">
|
|
|
|
var vm = new Vue({
|
|
el: '#' + id,
|
|
data: {
|
|
extend_data:[]
|
|
},
|
|
created() {
|
|
this.createStart();
|
|
},
|
|
computed: {
|
|
getExtends() {
|
|
return JSON.stringify(this.extend_data);
|
|
}
|
|
},
|
|
methods:{
|
|
createStart(){//初始化数据
|
|
var selectExtendValue = (new Function("return " + '{!! $value !!}'))();
|
|
if(selectExtendValue && selectExtendValue.length > 0){
|
|
for(j = 0, len=selectExtendValue.length; j < len; j++){
|
|
this.extend_data.push(selectExtendValue[j]);
|
|
}
|
|
}
|
|
},
|
|
}
|
|
});
|
|
|
|
|
|
function getCropExtends(cropId){
|
|
$.ajax({
|
|
type: 'get',
|
|
dataType: 'json',
|
|
url: '/admin/api/crops/' + cropId,
|
|
success: function (result) {
|
|
vm.extend_data = [];
|
|
let crop = result.data;
|
|
let crop_extends;
|
|
if(crop && crop.extends){
|
|
crop_extends = JSON.parse(crop.extends);
|
|
}
|
|
|
|
if(crop_extends && crop_extends.length > 0){
|
|
for(j = 0, len=crop_extends.length; j < len; j++){
|
|
vm.extend_data.push({
|
|
"name": crop_extends[j].name,
|
|
"unit": crop_extends[j].unit,
|
|
"value": null,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
$("[name='{{ $listen }}']").on('change', function(){
|
|
var crop_id = this.options[this.options.selectedIndex].value;
|
|
getCropExtends(crop_id);
|
|
})
|
|
|
|
</script>
|