Compare commits

...

3 Commits

Author SHA1 Message Date
Karson 31088b0758 更新package.json依赖 2026-01-20 11:23:27 +08:00
Karson cac61decce 优化日期显示
加强表单元素生成转义
2026-01-20 11:23:02 +08:00
Karson 24be463fae 通用搜索新增自定义列样式
优化通用搜索searchList
选择文件change事件新增回传数据
修复不存在编辑按钮时双击编辑功能
2026-01-20 10:53:34 +08:00
7 changed files with 84 additions and 242 deletions

View File

@ -124,7 +124,7 @@ class Date
*/
public static function human($remote, $local = null)
{
$time_diff = (is_null($local) ? time() : $local) - $remote;
$time_diff = (is_null($local) ? time() : $local) - (int)$remote;
$tense = $time_diff < 0 ? 'after' : 'ago';
$time_diff = abs($time_diff);
$chunks = [
@ -196,11 +196,11 @@ class Date
case 'quarter':
$quarter = ceil(date('n', $baseTime) / 3) + $offset;
$month = $quarter * 3;
$offset_year = ceil($month/12) - 1;
$offset_year = ceil($month / 12) - 1;
$year = $year + $offset_year;
$month = $month - ($offset_year * 12);
$time = $position ?
mktime(0, 0, 0, $month-2, 1, $year) :
mktime(0, 0, 0, $month - 2, 1, $year) :
mktime(23, 59, 59, $month, self::days_in_month($month, $year), $year);
break;
case 'year':

View File

@ -205,6 +205,7 @@ class FormBuilder
$value = $this->getValueAttribute($name, $value);
$options['class'] = isset($options['class']) ? $options['class'] . (stripos($options['class'], 'form-control') !== false ? '' : ' form-control') : 'form-control';
}
$value = $this->escape($value);
$merge = compact('type', 'value', 'id');
$options = array_merge($options, $merge);
@ -586,9 +587,9 @@ EOD;
public function datetimepicker($name, $value, $options = [])
{
$defaults = [
'data-date-format' => "YYYY-MM-DD HH:mm:ss",
'data-date-format' => "YYYY-MM-DD HH:mm:ss",
// 兼容旧的用法
'data-use-current' => "true",
'data-use-current' => "true",
'data-date-use-current' => "true",
];
$value = is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
@ -680,6 +681,7 @@ EOD;
return "<ins>{$value}</ins>";
}, $title));
$value = is_array($value) ? json_encode($value) : $value;
$value = $this->escape($value);
$html = <<<EOD
<dl class="fieldlist" data-name="{$name}" {$template} {$attributes}>
<dd>
@ -710,7 +712,8 @@ EOD;
$level = $index + 1;
$class = "cxselect-{$level}";
$classes[] = $class;
$selectValue = isset($values[$value]) ? $values[$value] : (isset($values[$index]) ? $values[$index] : '');
$selectValue = $values[$value] ?? ($values[$index] ?? '');
$selectValue = $this->escape($selectValue);
$cxselect[] = <<<EOD
<select class="{$class} form-control" name="{$value}" data-value="{$selectValue}" data-url="{$url}?level={$level}&name={$value}" {$attributes}></select>

199
package-lock.json generated
View File

@ -18,7 +18,7 @@
"eonasdan-bootstrap-datetimepicker": "^4.17.49",
"fastadmin-addtabs": "^1.0.8",
"fastadmin-arttemplate": "^3.1.4",
"fastadmin-bootstraptable": "^1.11.12",
"fastadmin-bootstraptable": "^1.11.13",
"fastadmin-citypicker": "^1.3.6",
"fastadmin-cxselect": "^1.4.0",
"fastadmin-dragsort": "^1.0.5",
@ -46,18 +46,6 @@
"parse-config-file": "^1.0.4"
}
},
"node_modules/@babel/runtime": {
"version": "7.27.0",
"resolved": "http://mirrors.tencent.com/npm/@babel/runtime/-/runtime-7.27.0.tgz",
"integrity": "sha512-VtPOkrdPHZsKc/clNqyi9WUA8TINkZ4cGk63UUE3u4pmB2k+ZMQRDuIOagv8UVd6j7k0T3+RRIb7beKTebNbcw==",
"license": "MIT",
"dependencies": {
"regenerator-runtime": "^0.14.0"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@swc/helpers": {
"version": "0.3.17",
"resolved": "http://mirrors.tencent.com/npm/@swc/helpers/-/helpers-0.3.17.tgz",
@ -67,20 +55,6 @@
"tslib": "^2.4.0"
}
},
"node_modules/@types/raf": {
"version": "3.4.3",
"resolved": "http://mirrors.tencent.com/npm/@types/raf/-/raf-3.4.3.tgz",
"integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==",
"license": "MIT",
"optional": true
},
"node_modules/@types/trusted-types": {
"version": "2.0.7",
"resolved": "http://mirrors.tencent.com/npm/@types/trusted-types/-/trusted-types-2.0.7.tgz",
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
"license": "MIT",
"optional": true
},
"node_modules/abbrev": {
"version": "1.1.1",
"resolved": "http://mirrors.tencent.com/npm/abbrev/-/abbrev-1.1.1.tgz",
@ -194,18 +168,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/atob": {
"version": "2.1.2",
"resolved": "http://mirrors.tencent.com/npm/atob/-/atob-2.1.2.tgz",
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==",
"license": "(MIT OR Apache-2.0)",
"bin": {
"atob": "bin/atob.js"
},
"engines": {
"node": ">= 4.5.0"
}
},
"node_modules/available-typed-arrays": {
"version": "1.0.7",
"resolved": "http://mirrors.tencent.com/npm/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
@ -281,18 +243,18 @@
},
"node_modules/bootstrap-table": {
"name": "fastadmin-bootstraptable",
"version": "1.11.12",
"resolved": "http://mirrors.tencent.com/npm/fastadmin-bootstraptable/-/fastadmin-bootstraptable-1.11.12.tgz",
"integrity": "sha512-WQXtzfsQ2c/SxCpltEASE2V6jXztj3cKzg1leg2iDtDr1lkPiUcv6SJERrAI/pfuf5z9YFfMy40TltEEWG68jg==",
"version": "1.11.13",
"resolved": "http://mirrors.tencent.com/npm/fastadmin-bootstraptable/-/fastadmin-bootstraptable-1.11.13.tgz",
"integrity": "sha512-Qf9rc7jZjlaozLkKBMDmI03/0EUYP1AyK7j5OzM8VORm6zRHIlDyQMhlyqvqDitiAacxW16epNTKZVMsJisMog==",
"license": "MIT",
"dependencies": {
"uglify-js": "^2.8.29"
}
},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "http://mirrors.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"version": "1.1.12",
"resolved": "http://mirrors.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.12.tgz",
"integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -342,18 +304,6 @@
],
"license": "MIT"
},
"node_modules/btoa": {
"version": "1.2.1",
"resolved": "http://mirrors.tencent.com/npm/btoa/-/btoa-1.2.1.tgz",
"integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==",
"license": "(MIT OR Apache-2.0)",
"bin": {
"btoa": "bin/btoa.js"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/call-bind": {
"version": "1.0.8",
"resolved": "http://mirrors.tencent.com/npm/call-bind/-/call-bind-1.0.8.tgz",
@ -410,33 +360,6 @@
"node": ">=0.10.0"
}
},
"node_modules/canvg": {
"version": "3.0.11",
"resolved": "http://mirrors.tencent.com/npm/canvg/-/canvg-3.0.11.tgz",
"integrity": "sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==",
"license": "MIT",
"optional": true,
"dependencies": {
"@babel/runtime": "^7.12.5",
"@types/raf": "^3.4.0",
"core-js": "^3.8.3",
"raf": "^3.4.1",
"regenerator-runtime": "^0.13.7",
"rgbcolor": "^1.0.1",
"stackblur-canvas": "^2.0.0",
"svg-pathdata": "^6.0.3"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/canvg/node_modules/regenerator-runtime": {
"version": "0.13.11",
"resolved": "http://mirrors.tencent.com/npm/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
"license": "MIT",
"optional": true
},
"node_modules/center-align": {
"version": "0.1.3",
"resolved": "http://mirrors.tencent.com/npm/center-align/-/center-align-0.1.3.tgz",
@ -538,18 +461,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/core-js": {
"version": "3.42.0",
"resolved": "http://mirrors.tencent.com/npm/core-js/-/core-js-3.42.0.tgz",
"integrity": "sha512-Sz4PP4ZA+Rq4II21qkNqOEDTDrCvcANId3xpIgB34NDkWc3UduWj2dqEtN9yZIq8Dk3HyPI33x9sqqU5C8sr0g==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"node_modules/crypto-js": {
"version": "4.2.0",
"resolved": "http://mirrors.tencent.com/npm/crypto-js/-/crypto-js-4.2.0.tgz",
@ -679,16 +590,6 @@
"integrity": "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==",
"license": "MIT"
},
"node_modules/dompurify": {
"version": "3.2.5",
"resolved": "http://mirrors.tencent.com/npm/dompurify/-/dompurify-3.2.5.tgz",
"integrity": "sha512-mLPd29uoRe9HpvwP2TxClGQBzGXeEC/we/q+bFlmPPmj2p2Ugl3r6ATu/UU1v77DXNcehiBg9zsr1dREyA/dJQ==",
"license": "(MPL-2.0 OR Apache-2.0)",
"optional": true,
"optionalDependencies": {
"@types/trusted-types": "^2.0.7"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "http://mirrors.tencent.com/npm/dunder-proto/-/dunder-proto-1.0.1.tgz",
@ -844,9 +745,9 @@
"license": "BSD"
},
"node_modules/fastadmin-bootstraptable": {
"version": "1.11.12",
"resolved": "http://mirrors.tencent.com/npm/fastadmin-bootstraptable/-/fastadmin-bootstraptable-1.11.12.tgz",
"integrity": "sha512-WQXtzfsQ2c/SxCpltEASE2V6jXztj3cKzg1leg2iDtDr1lkPiUcv6SJERrAI/pfuf5z9YFfMy40TltEEWG68jg==",
"version": "1.11.13",
"resolved": "http://mirrors.tencent.com/npm/fastadmin-bootstraptable/-/fastadmin-bootstraptable-1.11.13.tgz",
"integrity": "sha512-Qf9rc7jZjlaozLkKBMDmI03/0EUYP1AyK7j5OzM8VORm6zRHIlDyQMhlyqvqDitiAacxW16epNTKZVMsJisMog==",
"license": "MIT",
"dependencies": {
"uglify-js": "^2.8.29"
@ -903,12 +804,6 @@
"integrity": "sha512-RGPwHQkYQRCNf0ksR11iJlT9D2xXo8Wt2S6+q8fYs3HIvkM6dJp2AIAG6x9w8VKc2esblpzIOyGKD64ZAZTqbg==",
"license": "MIT"
},
"node_modules/fflate": {
"version": "0.8.2",
"resolved": "http://mirrors.tencent.com/npm/fflate/-/fflate-0.8.2.tgz",
"integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==",
"license": "MIT"
},
"node_modules/file-saver": {
"version": "2.0.5",
"resolved": "http://mirrors.tencent.com/npm/file-saver/-/file-saver-2.0.5.tgz",
@ -1983,22 +1878,11 @@
}
},
"node_modules/jspdf": {
"version": "3.0.1",
"resolved": "http://mirrors.tencent.com/npm/jspdf/-/jspdf-3.0.1.tgz",
"integrity": "sha512-qaGIxqxetdoNnFQQXxTKUD9/Z7AloLaw94fFsOiJMxbfYdBbrBuhWmbzI8TVjrw7s3jBY1PFHofBKMV/wZPapg==",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.26.7",
"atob": "^2.1.2",
"btoa": "^1.2.1",
"fflate": "^0.8.1"
},
"optionalDependencies": {
"canvg": "^3.0.11",
"core-js": "^3.6.0",
"dompurify": "^3.2.4",
"html2canvas": "^1.0.0-rc.5"
}
"name": "noop",
"version": "1.0.0",
"resolved": "http://mirrors.tencent.com/npm/noop/-/noop-1.0.0.tgz",
"integrity": "sha512-Hv02hO5vzZNX2Gn1BcD+ATfkFGF3g0B7JDpAKcv+dvhiG8ZAv0k61+CpnQeMDBRXJJ1umGnMb1NgA4c4w6SvhQ==",
"license": "MIT OR CC0-1.0"
},
"node_modules/jstree": {
"version": "3.3.17",
@ -2448,13 +2332,6 @@
"node": ">=8"
}
},
"node_modules/performance-now": {
"version": "2.1.0",
"resolved": "http://mirrors.tencent.com/npm/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==",
"license": "MIT",
"optional": true
},
"node_modules/picomatch": {
"version": "2.3.1",
"resolved": "http://mirrors.tencent.com/npm/picomatch/-/picomatch-2.3.1.tgz",
@ -2482,16 +2359,6 @@
"node": ">= 0.4"
}
},
"node_modules/raf": {
"version": "3.4.1",
"resolved": "http://mirrors.tencent.com/npm/raf/-/raf-3.4.1.tgz",
"integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==",
"license": "MIT",
"optional": true,
"dependencies": {
"performance-now": "^2.1.0"
}
},
"node_modules/rechoir": {
"version": "0.7.1",
"resolved": "http://mirrors.tencent.com/npm/rechoir/-/rechoir-0.7.1.tgz",
@ -2505,12 +2372,6 @@
"node": ">= 0.10"
}
},
"node_modules/regenerator-runtime": {
"version": "0.14.1",
"resolved": "http://mirrors.tencent.com/npm/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
"integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==",
"license": "MIT"
},
"node_modules/regexp.prototype.flags": {
"version": "1.5.4",
"resolved": "http://mirrors.tencent.com/npm/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz",
@ -2586,16 +2447,6 @@
"integrity": "sha512-e0dOpjm5DseomnXx2M5lpdZ5zoHqF1+bqdMJUohoYVVQa7cBdnk7fdmeI6byNWP/kiME72EeTiSypTCVnpLiDg==",
"license": "MIT"
},
"node_modules/rgbcolor": {
"version": "1.0.1",
"resolved": "http://mirrors.tencent.com/npm/rgbcolor/-/rgbcolor-1.0.1.tgz",
"integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==",
"license": "MIT OR SEE LICENSE IN FEEL-FREE.md",
"optional": true,
"engines": {
"node": ">= 0.8.15"
}
},
"node_modules/right-align": {
"version": "0.1.3",
"resolved": "http://mirrors.tencent.com/npm/right-align/-/right-align-0.1.3.tgz",
@ -2777,16 +2628,6 @@
"dev": true,
"license": "BSD-3-Clause"
},
"node_modules/stackblur-canvas": {
"version": "2.7.0",
"resolved": "http://mirrors.tencent.com/npm/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz",
"integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=0.1.14"
}
},
"node_modules/stop-iteration-iterator": {
"version": "1.1.0",
"resolved": "http://mirrors.tencent.com/npm/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz",
@ -2836,16 +2677,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/svg-pathdata": {
"version": "6.0.3",
"resolved": "http://mirrors.tencent.com/npm/svg-pathdata/-/svg-pathdata-6.0.3.tgz",
"integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/svg-to-pdfkit": {
"version": "0.1.8",
"resolved": "http://mirrors.tencent.com/npm/svg-to-pdfkit/-/svg-to-pdfkit-0.1.8.tgz",

View File

@ -17,7 +17,7 @@
"eonasdan-bootstrap-datetimepicker": "^4.17.49",
"fastadmin-addtabs": "^1.0.8",
"fastadmin-arttemplate": "^3.1.4",
"fastadmin-bootstraptable": "^1.11.12",
"fastadmin-bootstraptable": "^1.11.13",
"fastadmin-citypicker": "^1.3.6",
"fastadmin-cxselect": "^1.4.0",
"fastadmin-dragsort": "^1.0.5",
@ -53,7 +53,8 @@
"xmldom": "^0.7.0"
},
"tableexport.jquery.plugin": {
"xlsx": "npm:@e965/xlsx@^0.20.3"
"xlsx": "npm:@e965/xlsx@^0.20.3",
"jspdf": "npm:noop@1.0.0"
},
"eonasdan-bootstrap-datetimepicker": {
"moment-timezone": "^0.5.35"

View File

@ -53,6 +53,7 @@
if (that.options.searchFormTemplate) {
return Template(that.options.searchFormTemplate, {columns: pColumns, table: that});
}
var columnClass = typeof that.options.commonSearchColumnClass === 'undefined' ? 'col-xs-12 col-sm-6 col-md-4 col-lg-3' : that.options.commonSearchColumnClass;
var htmlForm = [];
htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" novalidate method="post" action="%s" >', that.options.actionForm));
htmlForm.push('<fieldset>');
@ -70,7 +71,7 @@
vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate);
ColumnsForSearch.push(vObjCol);
htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
htmlForm.push(sprintf('<div class="form-group %s %s">', columnClass, (typeof vObjCol.searchVisible === 'undefined' || vObjCol.searchVisible) ? '' : 'hidden'));
htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
htmlForm.push('<div class="col-xs-8">');
@ -86,23 +87,7 @@
if (typeof vObjCol.searchList === 'function') {
htmlForm.push(vObjCol.searchList.call(this, vObjCol));
} else {
var optionList = [sprintf('<option value="">%s</option>', that.options.formatCommonChoose())];
if (typeof vObjCol.searchList === 'object' && typeof vObjCol.searchList.then === 'function') {
(function (vObjCol, that) {
$.when(vObjCol.searchList).done(function (ret) {
var searchList = [];
if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
searchList = ret.data.searchlist;
} else if (ret.constructor === Array || ret.constructor === Object) {
searchList = ret;
}
var optionList = createOptionList(searchList, vObjCol, that);
$("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).html(optionList.join('')).trigger("change");
});
})(vObjCol, that);
} else {
optionList = createOptionList(vObjCol.searchList, vObjCol, that);
}
var optionList = createOptionList(vObjCol.searchList, vObjCol, that);
htmlForm.push(sprintf('<select class="%s" name="%s" %s %s>%s</select>', addClass, vObjCol.field, style, extend, optionList.join('')));
}
} else {
@ -125,7 +110,7 @@
htmlForm.push('</div>');
}
}
htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
htmlForm.push('<div class="form-group ' + columnClass + '">');
htmlForm.push(createFormBtn(that).join(''));
htmlForm.push('</div>');
htmlForm.push('</div>');
@ -147,16 +132,10 @@
};
var createOptionList = function (searchList, vObjCol, that) {
var isArray = searchList.constructor === Array;
var optionList = [];
optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
searchList = $.fn.bootstrapTable.utils.combineSearchList(searchList);
$.each(searchList, function (key, value) {
if (value.constructor === Object) {
key = value.id;
value = value.name;
} else {
key = isArray ? value : key;
}
optionList.push(sprintf("<option value='" + Fast.api.escape(key) + "' %s>" + Fast.api.escape(value) + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
});
return optionList;
@ -306,6 +285,43 @@
_load = BootstrapTable.prototype.load,
_initSearch = BootstrapTable.prototype.initSearch;
// 定义通用searchList处理方法
$.fn.bootstrapTable.utils.combineSearchList = function (list) {
var searchList = {};
if (typeof list !== 'undefined') {
var isFunction = list.constructor === Function;
var isAjax = typeof list === 'object' && typeof list.then === 'function';
if (isFunction) {
list = list();
} else if (isAjax) {
$.when(list).done(function (ret) {
// 兼容旧版本在data中返回searchlist
if (typeof ret.data.searchlist !== 'undefined') {
list = ret.data.searchlist;
} else {
list = ret;
}
});
}
// 兼容旧版本searchList返回字符串直接渲染自定义搜索栏
if (typeof list === 'string') {
return searchList;
}
var isArray = list.constructor === Array;
var i = 0;
$.each(list, function (key, val) {
if (typeof val !== 'undefined' && val.constructor === Object) {
key = val.id;
val = val.name;
} else {
key = isArray ? val : key;
}
searchList[key] = val;
});
}
return searchList;
};
BootstrapTable.prototype.initHeader = function () {
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
this.$header.find('th[data-field]').each(function (i) {

View File

@ -295,7 +295,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
}
}
var result = urlArr.join(",");
inputObj.val(result).trigger("change").trigger("validate");
inputObj.val(result).trigger("change", [data]).trigger("validate");
} else if (input_id) {
var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url, true) : data.url;
$("#" + input_id).val(url).trigger("change").trigger("validate");

View File

@ -244,7 +244,13 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
if (options.dblClickToEdit) {
//当双击单元格时
table.on('dbl-click-row.bs.table', function (e, row, element, field) {
$(Table.config.editonebtn, element).trigger("click");
var editone = $(Table.config.editonebtn, element);
if (editone.length > 0) {
editone.trigger("click");
} else if (options.extend.edit_url) {
// 判断是否允许双击编辑
Table.api.events.operate['click .btn-editone'].call(element, e, undefined, row, element.index());
}
});
}
//渲染内容前
@ -855,13 +861,14 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
}
value = row[this.field] || value;
value = value == null || value.length === 0 ? '' : value.toString();
this.searchList = $.fn.bootstrapTable.utils.combineSearchList(this.searchList);
var keys = typeof this.searchList === 'object' ? Object.keys(this.searchList) : [];
var index = keys.indexOf(value);
var keyIndex = keys.indexOf(value);
var color = value && typeof custom[value] !== 'undefined' ? custom[value] : null;
var display = index > -1 ? this.searchList[value] : null;
var icon = typeof this.icon !== 'undefined' ? this.icon : null;
if (!color) {
color = index > -1 && typeof colorArr[index] !== 'undefined' ? colorArr[index] : 'primary';
color = keyIndex > -1 && typeof colorArr[keyIndex] !== 'undefined' ? colorArr[keyIndex] : 'primary';
}
if (!display) {
display = __(value.charAt(0).toUpperCase() + value.slice(1));
@ -938,25 +945,9 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
value = Fast.api.escape(customValue);
field = this.customField;
}
if (typeof that.searchList === 'object' && typeof that.searchList.then === 'function') {
$.when(that.searchList).done(function (ret) {
if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
that.searchList = ret.data.searchlist;
} else if (ret.constructor === Array || ret.constructor === Object) {
that.searchList = ret;
}
})
}
if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') {
var i = 0;
var searchValues = Object.values(colorArr);
$.each(that.searchList, function (key, val) {
if (typeof colorArr[key] == 'undefined') {
colorArr[key] = searchValues[i];
i = typeof searchValues[i + 1] === 'undefined' ? 0 : i + 1;
}
});
}
//优化searchList
that.searchList = $.fn.bootstrapTable.utils.combineSearchList(that.searchList);
//渲染Flag
var html = [];
@ -967,7 +958,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
if (value === '')
return true;
color = value && typeof colorArr[value] !== 'undefined' ? colorArr[value] : 'primary';
display = typeof that.searchList !== 'undefined' && typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
display = typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
value = Fast.api.escape(value);
display = Fast.api.escape(display);
label = '<span class="label label-' + color + '">' + display + '</span>';