- 根因:页面(_MainLayout 等)加载的是 bundle.js 等由 bundleconfig.json 打包的生成产物,
但 csproj 未接入 BundlerMinifier,dotnet build 不会重生它们,Jenkins 只是把 git 里
陈旧的 bundle.js 原样发布 -> 改了 fastVue.base.js 后回车不生效(部署的 bundle 仍是无
enter 的旧版)。且源文件带 UTF-8 BOM,拼接后每个 BOM 落入文件中间成为 ZWNBSP,提交
diff 充满不可见字符(历史上曾多次在产物上手工清 BOM 打补丁)。
- 修复:
1. YLErpWeb.csproj 新增 BuildBundlerMinifier(3.2.449);其 BundleMinify 目标在
BeforeCompile 自动按 bundleconfig.json 重建全部 bundle,Jenkins 构建即自动产出正确版本,
不再需要手工重建并提交 bundle.js。
2. .gitignore 忽略 8 个生成产物(jquery.js/bundle.js/vue.js/bundle.css/bundleV2.css/
bundleV2.js/bundle.min.css/bundleV2.min.css) 并 git rm --cached 取消跟踪;这些产物
永不再入版本库、永不陈旧。
3. 剥离 15 个喂给 bundle 的源文件(及 css)开头的 UTF-8 BOM,使重建产物不再含 ZWNBSP。
- 验证:本地 dotnet build -t:BundleMinify 重建后 8 个 bundle 全部 BOM=0,bundle.js 含完整
enter 链路(_enterFired/isEnter/$emit('enter'));删除 bundle.min.css 后构建可自动重建。
113 lines
3.7 KiB
JavaScript
113 lines
3.7 KiB
JavaScript
var main = main || {};
|
|
|
|
(function ($) {
|
|
|
|
(function extendJqgrid(ajaxOptions) {
|
|
|
|
var completeOrigin = $.jgrid.ajaxOptions.complete;
|
|
|
|
$.extend(ajaxOptions, {
|
|
complete(XMLHttpRequest, textStatus) {
|
|
let resp = XMLHttpRequest.responseJSON;
|
|
if (typeof resp !== 'object' || resp.success || !resp.msg && !resp.message) {
|
|
return typeof completeOrigin === 'function' ? completeOrigin(XMLHttpRequest, textStatus) : null;
|
|
}
|
|
main.alert("数据查询失败: " + (resp.msg || resp.message));
|
|
}
|
|
});
|
|
}($.jgrid.ajaxOptions));
|
|
|
|
function jqGridCtrl() {
|
|
|
|
this.initGrid = function (options) {
|
|
|
|
options = $.extend({
|
|
url: '#',
|
|
datatype: 'json',
|
|
multiselect: false,
|
|
height: 'auto',
|
|
width: '90%',
|
|
autowidth: false,
|
|
shrinkToFit: false,
|
|
viewrecords: true,
|
|
jsonReader: { repeatitems: false },
|
|
cmTemplate: { align: 'center', width: 120 },
|
|
mtype: 'POST',
|
|
postData: null,
|
|
afterInsertRow: null,
|
|
onSelectRow: null,
|
|
ondblClickRow: null,
|
|
colModel: null,
|
|
pager: jQuery('#pagerGrid'),
|
|
pagerpos: 'left',
|
|
rowNum: 20,
|
|
rowList: [20, 30, 50, 200, 10000],
|
|
loadComplete: null,
|
|
onPaging: null,
|
|
footerrow: false
|
|
}, options);
|
|
|
|
//为了兼容以前的配置
|
|
!options.colModel && options.colModelGrid && (options.colModel = options.colModelGrid);
|
|
if (!options.postData) {
|
|
options.postData = options.PostData || {};
|
|
}
|
|
!options.afterInsertRow && options.AfterInsertRow && (options.afterInsertRow = options.AfterInsertRow);
|
|
!options.onSelectRow && options.rowclick && (options.onSelectRow = options.rowclick);
|
|
!options.ondblClickRow && options.rowdblclick && (options.ondblClickRow = options.rowdblclick);
|
|
!options.loadComplete && options.gridComplete && (options.loadComplete = options.gridComplete);
|
|
!options.onPaging && options.onJqgridPaging && (options.onPaging = options.onJqgridPaging);
|
|
|
|
return (options.el ? $(options.el) : $('#listGrid')).jqGrid(options);
|
|
}
|
|
|
|
function SearchClick($jqGrid, $form, firstPage) {
|
|
|
|
$jqGrid.appendPostData($form.serializeObject());
|
|
|
|
if (firstPage === true) {
|
|
$jqGrid.jqGrid('setGridParam', { page: 1 });
|
|
}
|
|
|
|
$jqGrid.trigger('reloadGrid');
|
|
}
|
|
|
|
this.initSearch = function ($jqGrid, searchForm) {
|
|
|
|
let $form = $(searchForm || '#searchForm');
|
|
|
|
if ($form.length && $form.is('form')) {
|
|
|
|
let search = SearchClick.bind(null, $jqGrid, $form);
|
|
|
|
$form.on('keydown', function (event) {
|
|
(event.keyCode === 13) && search();
|
|
});
|
|
|
|
$form.on('submit', function () {
|
|
search();
|
|
return false;
|
|
});
|
|
|
|
return search;
|
|
}
|
|
}
|
|
}
|
|
|
|
main.jqGrid = function (options) {
|
|
let ctrl = new jqGridCtrl();
|
|
let $grid = ctrl.initGrid(options);
|
|
let search = ctrl.initSearch($grid, options.searchForm);
|
|
return {
|
|
SearchClick: search || $.noop
|
|
};
|
|
};
|
|
|
|
main.enterSearch = function (searchFn) {
|
|
if (!searchFn) return;
|
|
document.onkeydown = function (event) {
|
|
(event.keyCode === 13) && searchFn();
|
|
};
|
|
};
|
|
|
|
})(jQuery); |