| | |
| | | } |
| | | |
| | | layui.link('/module/complete/autocomplete.css'); |
| | | layui.define(['jquery', 'laytpl', 'layer'], function (e) { |
| | | layui.define(['jquery', 'laytpl', 'layer','config'], function (e) { |
| | | "use strict"; |
| | | var hint = layui.hint(), |
| | | $ = layui.jquery, |
| | |
| | | filter = 'layui-autocomplete', |
| | | container = 'layui-form-autocomplete', |
| | | container_focus = 'layui-form-autocomplete-focus', |
| | | sysconfig=layui.config, |
| | | system = { |
| | | config: { |
| | | template: ['<div class="layui-form-autocomplete">', '<dl class="layui-anim layui-anim-upbit">', '</dl>', '</div>'].join(''), |
| | | layout: ['<dd data-index="{{d.index}}">{{d.text}}</dd>'].join(''), |
| | | template_txt: '{{d.text}}', |
| | | template_val: '{{d.value}}', |
| | | cache: false |
| | | cache: false, |
| | | keywordsName:'' |
| | | }, |
| | | data: {} |
| | | }, |
| | |
| | | msg: 'msg' |
| | | }, |
| | | request: { |
| | | keywords: 'keywords' |
| | | keywords: system.config.keywordsName |
| | | }, |
| | | statusCode: 0, |
| | | time_limit: 300, |
| | |
| | | } |
| | | job.prototype.render = function () { |
| | | var _self = this, _config = _self.config; |
| | | _config.request.keywords=_config.keywordsName; |
| | | if (_config.elem = $(_config.elem), _config.where = _config.where || {}, !_config.elem[0]) return _self; |
| | | var _elem = _config.elem, |
| | | _container = _elem.next('.' + container), |
| | |
| | | if ((_config.cache || !_config.url) && _config.data instanceof Object && Object.keys(_config.data).length > 0) return _self.renderData(_config.data); |
| | | var keywords = _config.request.keywords |
| | | var params = { |
| | | t: new Date().getTime() |
| | | //t: new Date().getTime() |
| | | } |
| | | params[keywords] = _config.filter; |
| | | params[keywords] = _config.filter.replace("'",""); |
| | | |
| | | var $loading = $('<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>'); |
| | | $.ajax($.extend({ |
| | |
| | | data: $.extend(params, _config.params instanceof Function ? _config.params() :_config.params), |
| | | contentType: 'text/json,charset=utf-8', |
| | | dataType: "json", |
| | | beforeSend: function () { |
| | | beforeSend: function (xhr) { |
| | | xhr.setRequestHeader("Authorization", "Bearer " + sysconfig.getToken().access_token); |
| | | xhr.setRequestHeader("Content-Type", "application/json"); |
| | | $loading.attr('style', [ |
| | | 'position:absolute', |
| | | 'left:' + (_elem.offset().left + _elem.outerWidth() - 20) + 'px', |