记得上下班打卡 | git大法好,push需谨慎

Commit cb9caae8 authored by qinshuangshuang's avatar qinshuangshuang

演出远程搜索框

parent 5eb8a51c
;(function ($) {
//这里放入插件代码
var RemoteSearch = function (element, options) {
var RemoteSearchPerformance = function (element, options) {
this.$element = $(element);
this.options = $.extend(true, {}, $.fn.remoteSearch.defaults, options);
this.options = $.extend(true, {}, $.fn.remoteSearchPerformance.defaults, options);
this.id = $(element).attr('id');
this.ulID = '#' + this.id + '_ul';
this.ulFoucus = false;
......@@ -11,12 +11,12 @@
this.render = this.options.render || this.render;
this.select = this.options.select || this.select;
this.ajax = $.extend({}, $.fn.remoteSearch.defaults.ajax, this.options.ajax);
this.ajax = $.extend({}, $.fn.remoteSearchPerformance.defaults.ajax, this.options.ajax);
this.listen();
}
RemoteSearch.prototype = {
RemoteSearchPerformance.prototype = {
listen: function () {
this.$element.on('blur', $.proxy(this.blur, this))
.on('keyup', $.proxy(this.keyup, this));
......@@ -47,7 +47,7 @@
// tab
case 13:
// enter
break;
this.ajaxer();
case 27:
// escape
break;
......@@ -61,10 +61,10 @@
},
ajaxer: function () {
var that = this,
query = that.$element.val();
title = that.$element.val();
// Query changed
that.query = query;
that.title = title;
// Cancel last timer if set
if (that.ajax.timerId) {
clearTimeout(that.ajax.timerId);
......@@ -73,10 +73,9 @@
// Query is good to send, set a timer
that.ajax.timerId = setTimeout(function() {
var params = { query : query };
var params = { title : title };
var jAjax = (that.ajax.method === "post") ? $.post : $.get;
jAjax(that.ajax.url, params, function(data){
console.log(data);
return that.render(data.value);
});
that.ajax.timerId = null;
......@@ -85,7 +84,6 @@
return that;
},
render: function (data) {
console.log(data);
this.ulFoucus = false;
var liList = data || [];
var num = this._getNum();
......@@ -136,14 +134,14 @@
}
$.fn.remoteSearch = function (option) {
$.fn.remoteSearchPerformance = function (option) {
return this.each(function () {
var $this = $(this),
data = $this.data('remoteSearch'),
data = $this.data('remoteSearchPerformance'),
options = typeof option === 'object' && option;
if (!data) {
$this.data('remoteSearch', (data = new RemoteSearch(this, options)));
$this.data('remoteSearchPerformance', (data = new RemoteSearchPerformance(this, options)));
}
if (typeof option === 'string') {
......@@ -152,9 +150,10 @@
});
}
$.fn.remoteSearch.defaults = {
$.fn.remoteSearchPerformance.defaults = {
hiddenVal: '',
chose: function () { },
ajax: {
url: null,
timeout: 300,
......@@ -162,11 +161,9 @@
timerId: null
},
success: function(res){
console.log('==parent==success==');
console.log(res);
}
}
$.fn.remoteSearch.Constructor = RemoteSearch;
$.fn.remoteSearchPerformance.Constructor = RemoteSearchPerformance;
})(jQuery);
\ No newline at end of file
......@@ -42,7 +42,7 @@
<script th:src="@{/ruoyi/js/common.js?v=4.6.1}"></script>
<script th:src="@{/ruoyi/js/ry-ui.js?v=4.6.1}"></script>
<!--远程搜索下拉框-->
<script th:src="@{/js/remote-search.js}"></script>
<script th:src="@{/js/remote-search-performance.js}"></script>
</div>
<!-- ztree树插件 -->
......
......@@ -24,7 +24,7 @@
-->
<div class="remote_wrapper" style="position: relative;">
<input name="ids" type="hidden">
<input type="text" id="remoteSearch11">
<input type="text" id="remoteSearch">
</div>
</br>
<p>推荐排序:</p>
......@@ -65,19 +65,15 @@
// });
// }
$('#remoteSearch11').remoteSearch({
$('#remoteSearch').remoteSearchPerformance({
ajax:{
url: prefix + "/performance/status?status=(3,6,7,9,10)&title=" + document.getElementById("remoteSearch11").value,
url: prefix + "/performance/status?status=(3,6,7,9,10)&",
type: "get"
},
chose: function(text,val){
document.getElementsByName("ids")[0].value = val;
console.log('remoteSearch===========chose=');
console.log(text)
console.log(val)
},
success: function(){
console.log('==success====');
}
})
</script>
......
......@@ -9,19 +9,26 @@
<div class="form-group">
<p>演出名称</p>
<div class="row">
<!--
<input name="roadShowId" th:value="*{roadShowId}" type="hidden">
<input name="ids" type="hidden">
<div class="col-lg-6">
<div class="input-group">
<input type="text" class="form-control" id="suggest-demo-2" onkeyup="getPerformanceTitle()">
<div class="input-group-btn">
<button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
</ul>
</div>
</div>
<input name="ids" type="hidden">
<div class="col-lg-6">
<div class="input-group">
<input type="text" class="form-control" id="suggest-demo-2" onkeyup="getPerformanceTitle()">
<div class="input-group-btn">
<button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
</ul>
</div>
</div>
</div>
-->
<input name="roadShowId" th:value="*{roadShowId}" type="hidden">
<div class="remote_wrapper" style="position: relative;">
<input name="ids" type="hidden">
<input type="text" id="remoteSearch">
</div>
</div>
</div>
......@@ -43,18 +50,29 @@
}
}
function getPerformanceTitle() {
var testBsSuggest = $("#suggest-demo-2").bsSuggest({
url: prefix + "/performance/status?status=(3,6,7,9,10)&title=" + document.getElementById("suggest-demo-2").value,
showBtn: false,
idField: "performancesId",
keyField: "title"
}).on('onDataRequestSuccess', function (e, result) {
}).on('onSetSelectValue', function (e, keyword) {
document.getElementsByName("ids")[0].value = keyword.id;
}).on('onUnsetSelectValue', function (e) {
});
}
// function getPerformanceTitle() {
// var testBsSuggest = $("#suggest-demo-2").bsSuggest({
// url: prefix + "/performance/status?status=(3,6,7,9,10)&title=" + document.getElementById("suggest-demo-2").value,
// showBtn: false,
// idField: "performancesId",
// keyField: "title"
// }).on('onDataRequestSuccess', function (e, result) {
// }).on('onSetSelectValue', function (e, keyword) {
// document.getElementsByName("ids")[0].value = keyword.id;
// }).on('onUnsetSelectValue', function (e) {
// });
// }
$('#remoteSearch').remoteSearchPerformance({
ajax:{
url: prefix + "/performance/status?status=(3,6,7,9,10)&",
type: "get"
},
chose: function(text,val){
document.getElementsByName("ids")[0].value = val;
},
success: function(){
}
})
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment