@model SelectNodeModel
@using NewLife;
@using NewLife.Web;
@using XCode;
@using System.Linq;
@using Stardust.Data.Nodes;
@using Stardust.Web.Models;
@{
var id = Model.Id;
var page = ViewBag.Page as Pager;
if (id.IsNullOrEmpty()) { id = "nodeId"; }
var nodeId = Model.NodeId;
if (nodeId <= 0) nodeId = page[id].ToInt();
var showValue = Node.FindByID(nodeId)?.Name;
}
<div class="form-group" style="position:relative">
<div class="col-lg-12">
<div class="input-group">
<input type="hidden" name="@id" id="@id" value="@nodeId" />
<input type="text" class="form-control" id="@(id)_select" placeholder="搜索节点" value="@showValue">
<div class="input-group-btn">
<ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
</div>
</div>
</div>
<script src="~/Content/bootstrap-suggest.js"></script>
<script type="text/javascript">
$(function () {
$("#@(id)_select").bsSuggest({
url: "/Nodes/Node/NodeSearch?category=@Model.Category&product=@Model.Product&key=",
getDataMethod:"url",
effectiveFieldsAlias: { id: "编号", code: "代码", name: "名称", ip: "地址" },
ignorecase: true,
showHeader: true,
delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时,延迟到有输入/获取到焦点时才请求数据
hideOnSelect: true,
idField: "id",
showBtn: false,
keyField: "name",
clearable: true,
searchingTip: '搜索中...',
allowNoKeyword: true,
delay: 500,
emptyTip: '无数据',
containerValueId: '@id',
fnProcessData: function (result) {
dt = {};
dt.value = result.data;
return dt;
}
}).on('onSetSelectValue', function (e, keyword, data) {
$('#@id').val(keyword.id);
}).on('onUnsetSelectValue', function () {
$('#@id').val('');
});
});
</script>
|