作者 Karson

新增普通搜索的onCommonSearch事件和onPostCommonSearch事件

优化普通搜索显示
优化菜单双击事件
优化后台插件安装提示
优化普通搜索操作符,Between支持单边搜索
@@ -259,7 +259,7 @@ class Addon extends Backend @@ -259,7 +259,7 @@ class Addon extends Backend
259 Service::importsql($name); 259 Service::importsql($name);
260 260
261 $info['config'] = get_addon_config($name) ? 1 : 0; 261 $info['config'] = get_addon_config($name) ? 1 : 0;
262 - $this->success(__('Installed tips'), null, ['addon' => $info]); 262 + $this->success(__('Offline installed tips'), null, ['addon' => $info]);
263 } 263 }
264 catch (Exception $e) 264 catch (Exception $e)
265 { 265 {
@@ -7,6 +7,7 @@ return [ @@ -7,6 +7,7 @@ return [
7 'Array key' => '键', 7 'Array key' => '键',
8 'Array value' => '值', 8 'Array value' => '值',
9 'File' => '文件', 9 'File' => '文件',
  10 + 'Donate' => '打赏作者',
10 'Warmtips' => '温馨提示', 11 'Warmtips' => '温馨提示',
11 'Offline install' => '离线安装', 12 'Offline install' => '离线安装',
12 'Refresh addon cache' => '刷新插件缓存', 13 'Refresh addon cache' => '刷新插件缓存',
@@ -21,7 +22,11 @@ return [ @@ -21,7 +22,11 @@ return [
21 'Pay click tips' => '请点击这里在新窗口中进行支付!', 22 'Pay click tips' => '请点击这里在新窗口中进行支付!',
22 'Pay new window tips' => '请在新弹出的窗口中进行支付,支付完成后再重新点击安装按钮进行安装!', 23 'Pay new window tips' => '请在新弹出的窗口中进行支付,支付完成后再重新点击安装按钮进行安装!',
23 'Uninstall tips' => '确认卸载插件?<p class="text-danger">卸载将会删除所有插件文件且不可找回!!! 插件如果有创建数据库表请手动删除!!!</p>如有重要数据请备份后再操作!', 24 'Uninstall tips' => '确认卸载插件?<p class="text-danger">卸载将会删除所有插件文件且不可找回!!! 插件如果有创建数据库表请手动删除!!!</p>如有重要数据请备份后再操作!',
24 - 'Installed tips' => '插件安装成功,你需要手动启用该插件,使之生效', 25 + 'Offline installed tips' => '插件安装成功!你需要手动启用该插件,并清除缓存使之生效',
  26 + 'Online installed tips' => '插件安装成功!清除插件缓存和框架缓存后生效!',
  27 + 'Not login tips' => '你当前未登录FastAdmin,登录后将同步已购买的记录,下载时无需二次付费!',
  28 + 'Login now' => '立即登录',
  29 + 'Continue install' => '不登录,继续安装',
25 'Recommend' => '推荐', 30 'Recommend' => '推荐',
26 'Hot' => '热门', 31 'Hot' => '热门',
27 'New' => '新', 32 'New' => '新',
@@ -2,16 +2,13 @@ @@ -2,16 +2,13 @@
2 .item-addon{margin-left:15px;margin-bottom:15px;} 2 .item-addon{margin-left:15px;margin-bottom:15px;}
3 .item-addon img.img-responsive,.item-addon .noimage{width: 300px;height:200px;} 3 .item-addon img.img-responsive,.item-addon .noimage{width: 300px;height:200px;}
4 .noimage {line-height: 200px;text-align: center;background:#18bc9c;color:#fff;} 4 .noimage {line-height: 200px;text-align: center;background:#18bc9c;color:#fff;}
5 - .addon {  
6 - position: relative;  
7 - }  
8 - .addon > span {  
9 - position:absolute;left:15px;top:15px;  
10 - }  
11 - .layui-layer-pay .layui-layer-content {  
12 - padding:0;height:600px!important;  
13 - } 5 + .addon {position: relative;}
  6 + .addon > span {position:absolute;left:15px;top:15px;}
  7 + .layui-layer-pay .layui-layer-content {padding:0;height:600px!important;}
14 .layui-layer-pay {border:none;} 8 .layui-layer-pay {border:none;}
  9 + .payimg{position:relative;width:800px;height:600px;}
  10 + .payimg .alipaycode {position:absolute;left:265px;top:442px;}
  11 + .payimg .wechatcode {position:absolute;left:660px;top:442px;}
15 </style> 12 </style>
16 <div id="warmtips" class="alert alert-dismissable alert-danger hide"> 13 <div id="warmtips" class="alert alert-dismissable alert-danger hide">
17 <button type="button" class="close" data-dismiss="alert">×</button> 14 <button type="button" class="close" data-dismiss="alert">×</button>
@@ -79,13 +76,15 @@ @@ -79,13 +76,15 @@
79 </div> 76 </div>
80 </script> 77 </script>
81 <script id="paytpl" type="text/html"> 78 <script id="paytpl" type="text/html">
82 - <div style="position:relative;width:800px;height:600px;background:url('<%=payimg%>') 0 0 no-repeat;">  
83 - <div style="position:absolute;left:265px;top:442px;"> 79 + <div class="payimg" style="background:url('<%=payimg%>') 0 0 no-repeat;background-size:cover;">
  80 + <%if(paycode){%>
  81 + <div class="alipaycode">
84 <%=paycode%> 82 <%=paycode%>
85 </div> 83 </div>
86 - <div style="position:absolute;left:660px;top:442px;"> 84 + <div class="wechatcode">
87 <%=paycode%> 85 <%=paycode%>
88 </div> 86 </div>
  87 + <%}%>
89 </div> 88 </div>
90 </script> 89 </script>
91 <script id="conflicttpl" type="text/html"> 90 <script id="conflicttpl" type="text/html">
@@ -146,7 +145,7 @@ @@ -146,7 +145,7 @@
146 <p class="text-muted">{:__('Createtime')}: <%=Moment(item.createtime*1000).format("YYYY-MM-DD HH:mm:ss")%></p> 145 <p class="text-muted">{:__('Createtime')}: <%=Moment(item.createtime*1000).format("YYYY-MM-DD HH:mm:ss")%></p>
147 <p class="operate" data-id="<%=item.id%>" data-name="<%=item.name%>"> 146 <p class="operate" data-id="<%=item.id%>" data-name="<%=item.name%>">
148 <% if(!addon){ %> 147 <% if(!addon){ %>
149 - <a href="javascript:;" class="btn btn-primary btn-success btn-install" data-type="<%=item.price<=0?'free':'price';%>"><i class="fa fa-cloud-download"></i> {:__('Install')}</a> 148 + <a href="javascript:;" class="btn btn-primary btn-success btn-install" data-type="<%=item.price<=0?'free':'price';%>" data-donateimage="<%=item.donateimage%>"><i class="fa fa-cloud-download"></i> {:__('Install')}</a>
150 <% if(item.demourl){ %> 149 <% if(item.demourl){ %>
151 <a href="<%=item.demourl%>" class="btn btn-primary btn-info btn-demo" target="_blank"><i class="fa fa-flash"></i> {:__('Demo')}</a> 150 <a href="<%=item.demourl%>" class="btn btn-primary btn-info btn-demo" target="_blank"><i class="fa fa-flash"></i> {:__('Demo')}</a>
152 <% } %> 151 <% } %>
@@ -262,7 +262,21 @@ class Backend extends Controller @@ -262,7 +262,21 @@ class Backend extends Controller
262 break; 262 break;
263 case 'BETWEEN': 263 case 'BETWEEN':
264 case 'NOT BETWEEN': 264 case 'NOT BETWEEN':
265 - $where[] = [$k, $sym, array_slice(explode(',', $v), 0, 2)]; 265 + $arr = array_slice(explode(',', $v), 0, 2);
  266 + if (stripos($v, ',') === false || !array_filter($arr))
  267 + continue;
  268 + //当出现一边为空时改变操作符
  269 + if ($arr[0] === '')
  270 + {
  271 + $sym = $sym == 'BETWEEN' ? '<=' : '>';
  272 + $arr = $arr[1];
  273 + }
  274 + else if ($arr[1] === '')
  275 + {
  276 + $sym = $sym == 'BETWEEN' ? '>=' : '<';
  277 + $arr = $arr[0];
  278 + }
  279 + $where[] = [$k, $sym, $arr];
266 break; 280 break;
267 case 'LIKE': 281 case 'LIKE':
268 case 'LIKE %...%': 282 case 'LIKE %...%':
@@ -120,6 +120,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function @@ -120,6 +120,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
120 120
121 // 点击安装 121 // 点击安装
122 $(document).on("click", ".btn-install", function () { 122 $(document).on("click", ".btn-install", function () {
  123 + var that = this;
123 var name = $(this).closest(".operate").data("name"); 124 var name = $(this).closest(".operate").data("name");
124 var userinfo = Controller.api.userinfo.get(); 125 var userinfo = Controller.api.userinfo.get();
125 var uid = userinfo ? userinfo.id : 0; 126 var uid = userinfo ? userinfo.id : 0;
@@ -131,6 +132,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function @@ -131,6 +132,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
131 }, function (data, ret) { 132 }, function (data, ret) {
132 Layer.closeAll(); 133 Layer.closeAll();
133 Config['addons'][data.addon.name] = ret.data.addon; 134 Config['addons'][data.addon.name] = ret.data.addon;
  135 + Layer.alert(__('Online installed tips'), {
  136 + btn: [__('OK'), __('Donate')],
  137 + title: __('Warning'),
  138 + icon: 1,
  139 + btn2: function () {
  140 + //打赏
  141 + Layer.open({
  142 + content: Template("paytpl", {payimg: $(that).data("donateimage")}),
  143 + shade: 0.8,
  144 + area: ['800px', '600px'],
  145 + skin: 'layui-layer-msg layui-layer-pay',
  146 + title: false,
  147 + closeBtn: true,
  148 + btn: false,
  149 + resize: false,
  150 + });
  151 + }
  152 + });
134 $('.btn-refresh').trigger('click'); 153 $('.btn-refresh').trigger('click');
135 }, function (data, ret) { 154 }, function (data, ret) {
136 //如果是需要购买的插件则弹出二维码提示 155 //如果是需要购买的插件则弹出二维码提示
@@ -183,6 +202,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function @@ -183,6 +202,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
183 return false; 202 return false;
184 }); 203 });
185 }; 204 };
  205 + if ($(that).data("type") !== 'free') {
  206 + if (parseInt(uid) === 0) {
  207 + return Layer.alert(__('Not login tips'), {
  208 + title: __('Warning'),
  209 + btn: [__('Login now'), __('Continue install')],
  210 + yes: function (index, layero) {
  211 + $(".btn-userinfo").trigger("click");
  212 + },
  213 + btn2: function () {
  214 + install(name, false);
  215 + }
  216 + });
  217 + }
  218 + }
186 install(name, false); 219 install(name, false);
187 }); 220 });
188 221
@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi @@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi
8 8
9 //双击重新加载页面 9 //双击重新加载页面
10 $(document).on("dblclick", ".sidebar-menu li > a", function (e) { 10 $(document).on("dblclick", ".sidebar-menu li > a", function (e) {
11 - $("#tab_" + $(this).attr("addtabs") + " iframe").attr('src', function (i, val) { 11 + $("#con_" + $(this).attr("addtabs") + " iframe").attr('src', function (i, val) {
12 return val; 12 return val;
13 }); 13 });
14 e.stopPropagation(); 14 e.stopPropagation();
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 * @version: v0.0.1 3 * @version: v0.0.1
4 * 4 *
5 * @update 2017-05-07 <http://git.oschina.net/pp/fastadmin> 5 * @update 2017-05-07 <http://git.oschina.net/pp/fastadmin>
  6 + * @update 2017-09-03 <http://git.oschina.net/karson/fastadmin>
6 */ 7 */
7 8
8 !function ($) { 9 !function ($) {
@@ -19,8 +20,8 @@ @@ -19,8 +20,8 @@
19 vModal += vFormCommon.join(''); 20 vModal += vFormCommon.join('');
20 vModal += "</div>"; 21 vModal += "</div>";
21 that.$container.prepend($(vModal)); 22 that.$container.prepend($(vModal));
22 -  
23 - var form = $("form.form-commonsearch", that.$container); 23 + that.$commonsearch = $(".commonsearch-table", that.$container);
  24 + var form = $("form.form-commonsearch", that.$commonsearch);
24 25
25 //绑定日期时间元素事件 26 //绑定日期时间元素事件
26 if ($(".datetimepicker", form).size() > 0) { 27 if ($(".datetimepicker", form).size() > 0) {
@@ -49,25 +50,26 @@ @@ -49,25 +50,26 @@
49 // 表单提交 50 // 表单提交
50 form.on("submit", function (event) { 51 form.on("submit", function (event) {
51 event.preventDefault(); 52 event.preventDefault();
52 - that.onColumnCommonSearch(); 53 + that.onCommonSearch();
53 return false; 54 return false;
54 }); 55 });
55 56
56 // 重置搜索 57 // 重置搜索
57 form.on("click", "button[type=reset]", function (event) { 58 form.on("click", "button[type=reset]", function (event) {
58 form[0].reset(); 59 form[0].reset();
59 - that.onColumnCommonSearch(); 60 + that.onCommonSearch();
60 }); 61 });
61 62
62 }; 63 };
63 64
64 var createFormCommon = function (pColumns, that) { 65 var createFormCommon = function (pColumns, that) {
65 var htmlForm = []; 66 var htmlForm = [];
66 - var opList = ['=', '>', '>=', '<', '<=', '!=', 'LIKE', 'LIKE %...%', 'NOT LIKE', 'IN(...)', 'NOT IN(...)', 'BETWEEN', 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL'];  
67 - htmlForm.push(sprintf('<form class="form-inline form-commonsearch" action="%s" >', that.options.actionForm)); 67 + var opList = ['=', '>', '>=', '<', '<=', '!=', 'LIKE', 'LIKE %...%', 'NOT LIKE', 'IN', 'NOT IN', 'IN(...)', 'NOT IN(...)', 'BETWEEN', 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL'];
  68 + htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" action="%s" >', that.options.actionForm));
68 htmlForm.push('<fieldset>'); 69 htmlForm.push('<fieldset>');
69 if (that.options.titleForm.length > 0) 70 if (that.options.titleForm.length > 0)
70 htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm)); 71 htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
  72 + htmlForm.push('<div class="row">');
71 for (var i in pColumns) { 73 for (var i in pColumns) {
72 var vObjCol = pColumns[i]; 74 var vObjCol = pColumns[i];
73 if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) { 75 if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) {
@@ -75,8 +77,11 @@ @@ -75,8 +77,11 @@
75 query = query ? query : ''; 77 query = query ? query : '';
76 vObjCol.defaultValue = that.options.renderDefault && query != '' ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue); 78 vObjCol.defaultValue = that.options.renderDefault && query != '' ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue);
77 ColumnsForSearch.push(vObjCol); 79 ColumnsForSearch.push(vObjCol);
78 - htmlForm.push('<div class="form-group" style="margin:5px">');  
79 - htmlForm.push(sprintf('<label for="%s" class="control-label" style="padding:0 10px">%s</label>', vObjCol.field, vObjCol.title)); 80 +
  81 + htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  82 + htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
  83 + htmlForm.push('<div class="col-xs-8">');
  84 +
80 vObjCol.operate = (typeof vObjCol.operate === 'undefined' || $.inArray(vObjCol.operate, opList) === -1) ? '=' : vObjCol.operate; 85 vObjCol.operate = (typeof vObjCol.operate === 'undefined' || $.inArray(vObjCol.operate, opList) === -1) ? '=' : vObjCol.operate;
81 htmlForm.push(sprintf('<input type="hidden" class="form-control operate" name="field-%s" data-name="%s" value="%s" readonly>', vObjCol.field, vObjCol.field, vObjCol.operate)); 86 htmlForm.push(sprintf('<input type="hidden" class="form-control operate" name="field-%s" data-name="%s" value="%s" readonly>', vObjCol.field, vObjCol.field, vObjCol.operate));
82 87
@@ -86,7 +91,7 @@ @@ -86,7 +91,7 @@
86 htmlForm.push(sprintf('<select class="form-control" name="%s" %s>%s</select>', vObjCol.field, style, sprintf('<option value="">%s</option>', that.options.formatCommonChoose()))); 91 htmlForm.push(sprintf('<select class="form-control" name="%s" %s>%s</select>', vObjCol.field, style, sprintf('<option value="">%s</option>', that.options.formatCommonChoose())));
87 (function (vObjCol, that) { 92 (function (vObjCol, that) {
88 $.when(vObjCol.searchList).done(function (ret) { 93 $.when(vObjCol.searchList).done(function (ret) {
89 - 94 +
90 var isArray = false; 95 var isArray = false;
91 if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) { 96 if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
92 var resultlist = {}; 97 var resultlist = {};
@@ -126,17 +131,26 @@ @@ -126,17 +131,26 @@
126 if (/BETWEEN$/.test(vObjCol.operate)) { 131 if (/BETWEEN$/.test(vObjCol.operate)) {
127 var defaultValueArr = /^.+|.+$/.test(defaultValue) ? defaultValue.split('|') : ['', '']; 132 var defaultValueArr = /^.+|.+$/.test(defaultValue) ? defaultValue.split('|') : ['', ''];
128 htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValueArr[0], placeholder, vObjCol.field, style, data)); 133 htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValueArr[0], placeholder, vObjCol.field, style, data));
129 - htmlForm.push(sprintf('&nbsp;-&nbsp;<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValueArr[1], placeholder, vObjCol.field, style, data)); 134 +
  135 + htmlForm.push('</div>');
  136 + htmlForm.push('</div>');
  137 + htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  138 + htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, "-"));
  139 + htmlForm.push('<div class="col-xs-8">');
  140 + htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValueArr[1], placeholder, vObjCol.field, style, data));
130 } else { 141 } else {
131 htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValue, placeholder, vObjCol.field, style, data)); 142 htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValue, placeholder, vObjCol.field, style, data));
132 } 143 }
133 } 144 }
134 145
135 htmlForm.push('</div>'); 146 htmlForm.push('</div>');
  147 + htmlForm.push('</div>');
136 } 148 }
137 } 149 }
138 - 150 + htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
139 htmlForm.push(createFormBtn(that).join('')); 151 htmlForm.push(createFormBtn(that).join(''));
  152 + htmlForm.push('</div>');
  153 + htmlForm.push('</div>');
140 htmlForm.push('</fieldset>'); 154 htmlForm.push('</fieldset>');
141 htmlForm.push('</form>'); 155 htmlForm.push('</form>');
142 156
@@ -147,12 +161,10 @@ @@ -147,12 +161,10 @@
147 var htmlBtn = []; 161 var htmlBtn = [];
148 var searchSubmit = that.options.formatCommonSubmitButton(); 162 var searchSubmit = that.options.formatCommonSubmitButton();
149 var searchReset = that.options.formatCommonResetButton(); 163 var searchReset = that.options.formatCommonResetButton();
150 - htmlBtn.push('<div class="form-group" style="margin:5px">');  
151 - htmlBtn.push('<div class="col-sm-12 text-center">'); 164 + htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
152 htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" >%s</button> ', searchSubmit)); 165 htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" >%s</button> ', searchSubmit));
153 htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset)); 166 htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
154 htmlBtn.push('</div>'); 167 htmlBtn.push('</div>');
155 - htmlBtn.push('</div>');  
156 return htmlBtn; 168 return htmlBtn;
157 }; 169 };
158 170
@@ -179,7 +191,7 @@ @@ -179,7 +191,7 @@
179 if (obj.size() > 1) { 191 if (obj.size() > 1) {
180 if (/BETWEEN$/.test(sym)) { 192 if (/BETWEEN$/.test(sym)) {
181 var value_begin = $.trim($("[name='" + name + "']:first").val()), value_end = $.trim($("[name='" + name + "']:last").val()); 193 var value_begin = $.trim($("[name='" + name + "']:first").val()), value_end = $.trim($("[name='" + name + "']:last").val());
182 - if (!value_begin.length || !value_end.length) { 194 + if (!value_begin.length && !value_end.length) {
183 return true; 195 return true;
184 } 196 }
185 if (typeof vObjCol.process === 'function') { 197 if (typeof vObjCol.process === 'function') {
@@ -187,8 +199,8 @@ @@ -187,8 +199,8 @@
187 value_end = vObjCol.process(value_end, 'end'); 199 value_end = vObjCol.process(value_end, 'end');
188 } else if ($("[name='" + name + "']:first").attr('type') === 'datetime') { //datetime类型字段转换成时间戳 200 } else if ($("[name='" + name + "']:first").attr('type') === 'datetime') { //datetime类型字段转换成时间戳
189 var Hms = Moment(value_begin).format("HH:mm:ss"); 201 var Hms = Moment(value_begin).format("HH:mm:ss");
190 - value_begin = parseInt(Moment(value_begin) / 1000);  
191 - value_end = parseInt(Moment(value_end) / 1000); 202 + value_begin = value_begin ? parseInt(Moment(value_begin) / 1000) : '';
  203 + value_end = value_end ? parseInt(Moment(value_end) / 1000) : '';
192 if (value_begin === value_end && '00:00:00' === Hms) { 204 if (value_begin === value_end && '00:00:00' === Hms) {
193 value_end += 86399; 205 value_end += 86399;
194 } 206 }
@@ -217,7 +229,10 @@ @@ -217,7 +229,10 @@
217 searchFormVisible: true, 229 searchFormVisible: true,
218 searchClass: 'searchit', 230 searchClass: 'searchit',
219 renderDefault: true, 231 renderDefault: true,
220 - onColumnCommonSearch: function (field, text) { 232 + onCommonSearch: function (field, text) {
  233 + return false;
  234 + },
  235 + onPostCommonSearch: function (table) {
221 return false; 236 return false;
222 } 237 }
223 }); 238 });
@@ -227,7 +242,8 @@ @@ -227,7 +242,8 @@
227 }); 242 });
228 243
229 $.extend($.fn.bootstrapTable.Constructor.EVENTS, { 244 $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
230 - 'column-common-search.bs.table': 'onColumnCommonSearch' 245 + 'common-search.bs.table': 'onCommonSearch',
  246 + 'post-common-search.bs.table': 'onPostCommonSearch'
231 }); 247 });
232 248
233 $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], { 249 $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], {
@@ -297,6 +313,7 @@ @@ -297,6 +313,7 @@
297 params.op = JSON.stringify($.extend(params.op || {}, searchQuery.op)); 313 params.op = JSON.stringify($.extend(params.op || {}, searchQuery.op));
298 return params; 314 return params;
299 }; 315 };
  316 + this.trigger('post-common-search', that);
300 317
301 }; 318 };
302 319
@@ -335,40 +352,23 @@ @@ -335,40 +352,23 @@
335 }) : this.data; 352 }) : this.data;
336 }; 353 };
337 354
338 - BootstrapTable.prototype.onColumnCommonSearch = function (event) {  
339 - if (typeof event === 'undefined') {  
340 - var searchquery = getSearchQuery(this);  
341 - // 追加查询关键字  
342 - this.options.pageNumber = 1;  
343 - this.options.queryParams = function (params) {  
344 - return {  
345 - search: params.search,  
346 - sort: params.sort,  
347 - order: params.order,  
348 - filter: JSON.stringify(searchquery.filter),  
349 - op: JSON.stringify(searchquery.op),  
350 - offset: params.offset,  
351 - limit: params.limit,  
352 - }; 355 + BootstrapTable.prototype.onCommonSearch = function () {
  356 + var searchquery = getSearchQuery(this);
  357 + this.trigger('common-search', this, searchquery);
  358 +
  359 + // 追加查询关键字
  360 + this.options.pageNumber = 1;
  361 + this.options.queryParams = function (params) {
  362 + return {
  363 + search: params.search,
  364 + sort: params.sort,
  365 + order: params.order,
  366 + filter: JSON.stringify(searchquery.filter),
  367 + op: JSON.stringify(searchquery.op),
  368 + offset: params.offset,
  369 + limit: params.limit,
353 }; 370 };
354 - this.refresh({query: {filter: JSON.stringify(searchquery.filter), op: JSON.stringify(searchquery.op)}});  
355 -  
356 - } else {  
357 - var text = $.trim($(event.currentTarget).val());  
358 - var $field = $(event.currentTarget)[0].id;  
359 -  
360 - if ($.isEmptyObject(this.filterColumnsPartial)) {  
361 - this.filterColumnsPartial = {};  
362 - }  
363 - if (text) {  
364 - this.filterColumnsPartial[$field] = text;  
365 - } else {  
366 - delete this.filterColumnsPartial[$field];  
367 - }  
368 - this.options.pageNumber = 1;  
369 - this.onSearch(event);  
370 -// this.updatePagination();  
371 - this.trigger('column-common-search', $field, text);  
372 - } 371 + };
  372 + this.refresh({query: {filter: JSON.stringify(searchquery.filter), op: JSON.stringify(searchquery.op)}});
373 }; 373 };
374 }(jQuery); 374 }(jQuery);
@@ -7283,6 +7283,7 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7283,6 +7283,7 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7283 * @version: v0.0.1 7283 * @version: v0.0.1
7284 * 7284 *
7285 * @update 2017-05-07 <http://git.oschina.net/pp/fastadmin> 7285 * @update 2017-05-07 <http://git.oschina.net/pp/fastadmin>
  7286 + * @update 2017-09-03 <http://git.oschina.net/karson/fastadmin>
7286 */ 7287 */
7287 7288
7288 !function ($) { 7289 !function ($) {
@@ -7299,8 +7300,8 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7299,8 +7300,8 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7299 vModal += vFormCommon.join(''); 7300 vModal += vFormCommon.join('');
7300 vModal += "</div>"; 7301 vModal += "</div>";
7301 that.$container.prepend($(vModal)); 7302 that.$container.prepend($(vModal));
7302 -  
7303 - var form = $("form.form-commonsearch", that.$container); 7303 + that.$commonsearch = $(".commonsearch-table", that.$container);
  7304 + var form = $("form.form-commonsearch", that.$commonsearch);
7304 7305
7305 //绑定日期时间元素事件 7306 //绑定日期时间元素事件
7306 if ($(".datetimepicker", form).size() > 0) { 7307 if ($(".datetimepicker", form).size() > 0) {
@@ -7329,25 +7330,26 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7329,25 +7330,26 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7329 // 表单提交 7330 // 表单提交
7330 form.on("submit", function (event) { 7331 form.on("submit", function (event) {
7331 event.preventDefault(); 7332 event.preventDefault();
7332 - that.onColumnCommonSearch(); 7333 + that.onCommonSearch();
7333 return false; 7334 return false;
7334 }); 7335 });
7335 7336
7336 // 重置搜索 7337 // 重置搜索
7337 form.on("click", "button[type=reset]", function (event) { 7338 form.on("click", "button[type=reset]", function (event) {
7338 form[0].reset(); 7339 form[0].reset();
7339 - that.onColumnCommonSearch(); 7340 + that.onCommonSearch();
7340 }); 7341 });
7341 7342
7342 }; 7343 };
7343 7344
7344 var createFormCommon = function (pColumns, that) { 7345 var createFormCommon = function (pColumns, that) {
7345 var htmlForm = []; 7346 var htmlForm = [];
7346 - var opList = ['=', '>', '>=', '<', '<=', '!=', 'LIKE', 'LIKE %...%', 'NOT LIKE', 'IN(...)', 'NOT IN(...)', 'BETWEEN', 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL'];  
7347 - htmlForm.push(sprintf('<form class="form-inline form-commonsearch" action="%s" >', that.options.actionForm)); 7347 + var opList = ['=', '>', '>=', '<', '<=', '!=', 'LIKE', 'LIKE %...%', 'NOT LIKE', 'IN', 'NOT IN', 'IN(...)', 'NOT IN(...)', 'BETWEEN', 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL'];
  7348 + htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" action="%s" >', that.options.actionForm));
7348 htmlForm.push('<fieldset>'); 7349 htmlForm.push('<fieldset>');
7349 if (that.options.titleForm.length > 0) 7350 if (that.options.titleForm.length > 0)
7350 htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm)); 7351 htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
  7352 + htmlForm.push('<div class="row">');
7351 for (var i in pColumns) { 7353 for (var i in pColumns) {
7352 var vObjCol = pColumns[i]; 7354 var vObjCol = pColumns[i];
7353 if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) { 7355 if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) {
@@ -7355,8 +7357,11 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7355,8 +7357,11 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7355 query = query ? query : ''; 7357 query = query ? query : '';
7356 vObjCol.defaultValue = that.options.renderDefault && query != '' ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue); 7358 vObjCol.defaultValue = that.options.renderDefault && query != '' ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue);
7357 ColumnsForSearch.push(vObjCol); 7359 ColumnsForSearch.push(vObjCol);
7358 - htmlForm.push('<div class="form-group" style="margin:5px">');  
7359 - htmlForm.push(sprintf('<label for="%s" class="control-label" style="padding:0 10px">%s</label>', vObjCol.field, vObjCol.title)); 7360 +
  7361 + htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  7362 + htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
  7363 + htmlForm.push('<div class="col-xs-8">');
  7364 +
7360 vObjCol.operate = (typeof vObjCol.operate === 'undefined' || $.inArray(vObjCol.operate, opList) === -1) ? '=' : vObjCol.operate; 7365 vObjCol.operate = (typeof vObjCol.operate === 'undefined' || $.inArray(vObjCol.operate, opList) === -1) ? '=' : vObjCol.operate;
7361 htmlForm.push(sprintf('<input type="hidden" class="form-control operate" name="field-%s" data-name="%s" value="%s" readonly>', vObjCol.field, vObjCol.field, vObjCol.operate)); 7366 htmlForm.push(sprintf('<input type="hidden" class="form-control operate" name="field-%s" data-name="%s" value="%s" readonly>', vObjCol.field, vObjCol.field, vObjCol.operate));
7362 7367
@@ -7366,7 +7371,7 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7366,7 +7371,7 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7366 htmlForm.push(sprintf('<select class="form-control" name="%s" %s>%s</select>', vObjCol.field, style, sprintf('<option value="">%s</option>', that.options.formatCommonChoose()))); 7371 htmlForm.push(sprintf('<select class="form-control" name="%s" %s>%s</select>', vObjCol.field, style, sprintf('<option value="">%s</option>', that.options.formatCommonChoose())));
7367 (function (vObjCol, that) { 7372 (function (vObjCol, that) {
7368 $.when(vObjCol.searchList).done(function (ret) { 7373 $.when(vObjCol.searchList).done(function (ret) {
7369 - 7374 +
7370 var isArray = false; 7375 var isArray = false;
7371 if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) { 7376 if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
7372 var resultlist = {}; 7377 var resultlist = {};
@@ -7406,17 +7411,26 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7406,17 +7411,26 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7406 if (/BETWEEN$/.test(vObjCol.operate)) { 7411 if (/BETWEEN$/.test(vObjCol.operate)) {
7407 var defaultValueArr = /^.+|.+$/.test(defaultValue) ? defaultValue.split('|') : ['', '']; 7412 var defaultValueArr = /^.+|.+$/.test(defaultValue) ? defaultValue.split('|') : ['', ''];
7408 htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValueArr[0], placeholder, vObjCol.field, style, data)); 7413 htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValueArr[0], placeholder, vObjCol.field, style, data));
7409 - htmlForm.push(sprintf('&nbsp;-&nbsp;<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValueArr[1], placeholder, vObjCol.field, style, data)); 7414 +
  7415 + htmlForm.push('</div>');
  7416 + htmlForm.push('</div>');
  7417 + htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  7418 + htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, "-"));
  7419 + htmlForm.push('<div class="col-xs-8">');
  7420 + htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValueArr[1], placeholder, vObjCol.field, style, data));
7410 } else { 7421 } else {
7411 htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValue, placeholder, vObjCol.field, style, data)); 7422 htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" %s %s>', type, addclass, vObjCol.field, defaultValue, placeholder, vObjCol.field, style, data));
7412 } 7423 }
7413 } 7424 }
7414 7425
7415 htmlForm.push('</div>'); 7426 htmlForm.push('</div>');
  7427 + htmlForm.push('</div>');
7416 } 7428 }
7417 } 7429 }
7418 - 7430 + htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
7419 htmlForm.push(createFormBtn(that).join('')); 7431 htmlForm.push(createFormBtn(that).join(''));
  7432 + htmlForm.push('</div>');
  7433 + htmlForm.push('</div>');
7420 htmlForm.push('</fieldset>'); 7434 htmlForm.push('</fieldset>');
7421 htmlForm.push('</form>'); 7435 htmlForm.push('</form>');
7422 7436
@@ -7427,12 +7441,10 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7427,12 +7441,10 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7427 var htmlBtn = []; 7441 var htmlBtn = [];
7428 var searchSubmit = that.options.formatCommonSubmitButton(); 7442 var searchSubmit = that.options.formatCommonSubmitButton();
7429 var searchReset = that.options.formatCommonResetButton(); 7443 var searchReset = that.options.formatCommonResetButton();
7430 - htmlBtn.push('<div class="form-group" style="margin:5px">');  
7431 - htmlBtn.push('<div class="col-sm-12 text-center">'); 7444 + htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
7432 htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" >%s</button> ', searchSubmit)); 7445 htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" >%s</button> ', searchSubmit));
7433 htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset)); 7446 htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
7434 htmlBtn.push('</div>'); 7447 htmlBtn.push('</div>');
7435 - htmlBtn.push('</div>');  
7436 return htmlBtn; 7448 return htmlBtn;
7437 }; 7449 };
7438 7450
@@ -7459,7 +7471,7 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7459,7 +7471,7 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7459 if (obj.size() > 1) { 7471 if (obj.size() > 1) {
7460 if (/BETWEEN$/.test(sym)) { 7472 if (/BETWEEN$/.test(sym)) {
7461 var value_begin = $.trim($("[name='" + name + "']:first").val()), value_end = $.trim($("[name='" + name + "']:last").val()); 7473 var value_begin = $.trim($("[name='" + name + "']:first").val()), value_end = $.trim($("[name='" + name + "']:last").val());
7462 - if (!value_begin.length || !value_end.length) { 7474 + if (!value_begin.length && !value_end.length) {
7463 return true; 7475 return true;
7464 } 7476 }
7465 if (typeof vObjCol.process === 'function') { 7477 if (typeof vObjCol.process === 'function') {
@@ -7467,8 +7479,8 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7467,8 +7479,8 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7467 value_end = vObjCol.process(value_end, 'end'); 7479 value_end = vObjCol.process(value_end, 'end');
7468 } else if ($("[name='" + name + "']:first").attr('type') === 'datetime') { //datetime类型字段转换成时间戳 7480 } else if ($("[name='" + name + "']:first").attr('type') === 'datetime') { //datetime类型字段转换成时间戳
7469 var Hms = Moment(value_begin).format("HH:mm:ss"); 7481 var Hms = Moment(value_begin).format("HH:mm:ss");
7470 - value_begin = parseInt(Moment(value_begin) / 1000);  
7471 - value_end = parseInt(Moment(value_end) / 1000); 7482 + value_begin = value_begin ? parseInt(Moment(value_begin) / 1000) : '';
  7483 + value_end = value_end ? parseInt(Moment(value_end) / 1000) : '';
7472 if (value_begin === value_end && '00:00:00' === Hms) { 7484 if (value_begin === value_end && '00:00:00' === Hms) {
7473 value_end += 86399; 7485 value_end += 86399;
7474 } 7486 }
@@ -7497,7 +7509,10 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7497,7 +7509,10 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7497 searchFormVisible: true, 7509 searchFormVisible: true,
7498 searchClass: 'searchit', 7510 searchClass: 'searchit',
7499 renderDefault: true, 7511 renderDefault: true,
7500 - onColumnCommonSearch: function (field, text) { 7512 + onCommonSearch: function (field, text) {
  7513 + return false;
  7514 + },
  7515 + onPostCommonSearch: function (table) {
7501 return false; 7516 return false;
7502 } 7517 }
7503 }); 7518 });
@@ -7507,7 +7522,8 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7507,7 +7522,8 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7507 }); 7522 });
7508 7523
7509 $.extend($.fn.bootstrapTable.Constructor.EVENTS, { 7524 $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
7510 - 'column-common-search.bs.table': 'onColumnCommonSearch' 7525 + 'common-search.bs.table': 'onCommonSearch',
  7526 + 'post-common-search.bs.table': 'onPostCommonSearch'
7511 }); 7527 });
7512 7528
7513 $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], { 7529 $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], {
@@ -7577,6 +7593,7 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7577,6 +7593,7 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7577 params.op = JSON.stringify($.extend(params.op || {}, searchQuery.op)); 7593 params.op = JSON.stringify($.extend(params.op || {}, searchQuery.op));
7578 return params; 7594 return params;
7579 }; 7595 };
  7596 + this.trigger('post-common-search', that);
7580 7597
7581 }; 7598 };
7582 7599
@@ -7615,41 +7632,24 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length) @@ -7615,41 +7632,24 @@ return d.keepInvalid=a,l},l.datepickerInput=function(a){if(0===arguments.length)
7615 }) : this.data; 7632 }) : this.data;
7616 }; 7633 };
7617 7634
7618 - BootstrapTable.prototype.onColumnCommonSearch = function (event) {  
7619 - if (typeof event === 'undefined') {  
7620 - var searchquery = getSearchQuery(this);  
7621 - // 追加查询关键字  
7622 - this.options.pageNumber = 1;  
7623 - this.options.queryParams = function (params) {  
7624 - return {  
7625 - search: params.search,  
7626 - sort: params.sort,  
7627 - order: params.order,  
7628 - filter: JSON.stringify(searchquery.filter),  
7629 - op: JSON.stringify(searchquery.op),  
7630 - offset: params.offset,  
7631 - limit: params.limit,  
7632 - }; 7635 + BootstrapTable.prototype.onCommonSearch = function () {
  7636 + var searchquery = getSearchQuery(this);
  7637 + this.trigger('common-search', this, searchquery);
  7638 +
  7639 + // 追加查询关键字
  7640 + this.options.pageNumber = 1;
  7641 + this.options.queryParams = function (params) {
  7642 + return {
  7643 + search: params.search,
  7644 + sort: params.sort,
  7645 + order: params.order,
  7646 + filter: JSON.stringify(searchquery.filter),
  7647 + op: JSON.stringify(searchquery.op),
  7648 + offset: params.offset,
  7649 + limit: params.limit,
7633 }; 7650 };
7634 - this.refresh({query: {filter: JSON.stringify(searchquery.filter), op: JSON.stringify(searchquery.op)}});  
7635 -  
7636 - } else {  
7637 - var text = $.trim($(event.currentTarget).val());  
7638 - var $field = $(event.currentTarget)[0].id;  
7639 -  
7640 - if ($.isEmptyObject(this.filterColumnsPartial)) {  
7641 - this.filterColumnsPartial = {};  
7642 - }  
7643 - if (text) {  
7644 - this.filterColumnsPartial[$field] = text;  
7645 - } else {  
7646 - delete this.filterColumnsPartial[$field];  
7647 - }  
7648 - this.options.pageNumber = 1;  
7649 - this.onSearch(event);  
7650 -// this.updatePagination();  
7651 - this.trigger('column-common-search', $field, text);  
7652 - } 7651 + };
  7652 + this.refresh({query: {filter: JSON.stringify(searchquery.filter), op: JSON.stringify(searchquery.op)}});
7653 }; 7653 };
7654 }(jQuery); 7654 }(jQuery);
7655 7655