<div class="form-group row">
<label class="control-label col-xs-12 col-sm-2">{:__('选择房屋')}:</label>
<div class="col-xs-12 col-sm-10">
<dl class="fieldlist" data-template="housetpl" data-name="row[house]">
<dd>
<ins>{:__('房号')}</ins>
<ins>{:__('层数')}</ins>
<ins>{:__('单元')}</ins>
<ins>{:__('楼号')}</ins>
<ins>{:__('操作')}</ins>
</dd>
<dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
<textarea name="row[house]" class="form-control" cols="30" rows="5">{:json_encode($houses)}</textarea>
</dl>
<script id="housetpl" type="text/html">
<dd class="form-inline">
<div class="form-inline" data-toggle="cxselect" data-selects="build<%=index%>,unit<%=index%>,floor<%=index%>,house<%=index%>">
<ins>
<select class="house house<%=index%> form-control" data-url="ajax/house?type=1" data-query-name="pid" name="<%=name%>[<%=index%>][house]" data-value="<%=row.house%>"></select>
</ins>
<ins>
<select class="floor floor<%=index%> form-control" name="<%=name%>[<%=index%>][floor]" data-url="ajax/houseCate" data-query-name="pid" data-value="<%=row.floor%>"></select>
</ins>
<ins>
<select class="unit unit<%=index%> form-control" name="<%=name%>[<%=index%>][unit]" data-url="ajax/houseCate" data-query-name="pid" data-value="<%=row.unit%>"></select>
</ins>
<ins>
<select class="build build<%=index%> form-control" name="<%=name%>[<%=index%>][build]" data-url="ajax/houseCate?type=1&pid=0" data-value="<%=row.build%>"></select>
</ins>
<!--下面的两个按钮务必保留-->
<span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
<span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
</div>
</dd>
</script>
</div>
</div>
add: function () {
$(document).on("fa.event.appendfieldlist", "#add-form .btn-append", function (e, obj) {
Form.events.cxselect(obj);
Form.events.fieldlist(obj);
});
Controller.api.bindevent();
},
edit: function () {
$(document).on("fa.event.appendfieldlist", "#edit-form .btn-append", function (e, obj) {
Form.events.cxselect(obj);
Form.events.fieldlist(obj);
});
$(document).on("dp.change", "#edit-form .cxselect", function () {
});
Controller.api.bindevent();
},
api: {
bindevent: function () {
$(document).on("dp.change", "#add-form .cxselect", function () {
// $(this).parent().prev().find("input").trigger("change");
// Form.events.cxselect(obj);
// Form.events.fieldlist(obj);
});
Form.api.bindevent($("form[role=form]"));
}
}
// 房屋
$row->houses = \app\admin\model\house\Good::where('id', 'in', $row->house_good_id)->select();
$houses = [];
foreach ($row->houses as $key => $value) {
$houses[] = [
'house' => $value->id*1,
'floor' => $value->ceng_id*1,
'unit' => $value->danyuan_id*1,
'build' => $value->lou_id*1,
];
}
$this->view->assign("houses", $houses);
// 车位
$row->cars = \app\admin\model\house\Good::where('id', 'in', $row->car_space)->select();
$cars = [];
foreach ($row->cars as $key => $value) {
$cars[] = [
'house' => $value->id,
'build' => $value->lou_id,
];
}
$this->view->assign("cars", $cars);