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

Commit cb9caae8 authored by qinshuangshuang's avatar qinshuangshuang

演出远程搜索框

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