devfab 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +290 -290
- package/dist/common/models.esm.js +3 -1
- package/dist/common/models.js +3 -1
- package/dist/index.esm.js +3 -1
- package/dist/index.js +3 -1
- package/dist/index.umd.js +3 -1
- package/lib/devfab.js +486 -452
- package/lib/devfab.min.js +3 -1
- package/package.json +78 -78
package/lib/devfab.js
CHANGED
|
@@ -19,6 +19,31 @@
|
|
|
19
19
|
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
20
20
|
return e;
|
|
21
21
|
}
|
|
22
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
23
|
+
try {
|
|
24
|
+
var i = n[a](c),
|
|
25
|
+
u = i.value;
|
|
26
|
+
} catch (n) {
|
|
27
|
+
return void e(n);
|
|
28
|
+
}
|
|
29
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
30
|
+
}
|
|
31
|
+
function _asyncToGenerator(n) {
|
|
32
|
+
return function () {
|
|
33
|
+
var t = this,
|
|
34
|
+
e = arguments;
|
|
35
|
+
return new Promise(function (r, o) {
|
|
36
|
+
var a = n.apply(t, e);
|
|
37
|
+
function _next(n) {
|
|
38
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
39
|
+
}
|
|
40
|
+
function _throw(n) {
|
|
41
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
42
|
+
}
|
|
43
|
+
_next(void 0);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
22
47
|
function _callSuper(t, o, e) {
|
|
23
48
|
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
24
49
|
}
|
|
@@ -151,6 +176,114 @@
|
|
|
151
176
|
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
152
177
|
return _assertThisInitialized(t);
|
|
153
178
|
}
|
|
179
|
+
function _regenerator() {
|
|
180
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
181
|
+
var e,
|
|
182
|
+
t,
|
|
183
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
184
|
+
n = r.iterator || "@@iterator",
|
|
185
|
+
o = r.toStringTag || "@@toStringTag";
|
|
186
|
+
function i(r, n, o, i) {
|
|
187
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
188
|
+
u = Object.create(c.prototype);
|
|
189
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
190
|
+
var i,
|
|
191
|
+
c,
|
|
192
|
+
u,
|
|
193
|
+
f = 0,
|
|
194
|
+
p = o || [],
|
|
195
|
+
y = !1,
|
|
196
|
+
G = {
|
|
197
|
+
p: 0,
|
|
198
|
+
n: 0,
|
|
199
|
+
v: e,
|
|
200
|
+
a: d,
|
|
201
|
+
f: d.bind(e, 4),
|
|
202
|
+
d: function (t, r) {
|
|
203
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
function d(r, n) {
|
|
207
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
208
|
+
var o,
|
|
209
|
+
i = p[t],
|
|
210
|
+
d = G.p,
|
|
211
|
+
l = i[2];
|
|
212
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
213
|
+
}
|
|
214
|
+
if (o || r > 1) return a;
|
|
215
|
+
throw y = !0, n;
|
|
216
|
+
}
|
|
217
|
+
return function (o, p, l) {
|
|
218
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
219
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
220
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
221
|
+
try {
|
|
222
|
+
if (f = 2, i) {
|
|
223
|
+
if (c || (o = "next"), t = i[o]) {
|
|
224
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
225
|
+
if (!t.done) return t;
|
|
226
|
+
u = t.value, c < 2 && (c = 0);
|
|
227
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
228
|
+
i = e;
|
|
229
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
230
|
+
} catch (t) {
|
|
231
|
+
i = e, c = 1, u = t;
|
|
232
|
+
} finally {
|
|
233
|
+
f = 1;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
value: t,
|
|
238
|
+
done: y
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
}(r, o, i), !0), u;
|
|
242
|
+
}
|
|
243
|
+
var a = {};
|
|
244
|
+
function Generator() {}
|
|
245
|
+
function GeneratorFunction() {}
|
|
246
|
+
function GeneratorFunctionPrototype() {}
|
|
247
|
+
t = Object.getPrototypeOf;
|
|
248
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
249
|
+
return this;
|
|
250
|
+
}), t),
|
|
251
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
252
|
+
function f(e) {
|
|
253
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
254
|
+
}
|
|
255
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
256
|
+
return this;
|
|
257
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
258
|
+
return "[object Generator]";
|
|
259
|
+
}), (_regenerator = function () {
|
|
260
|
+
return {
|
|
261
|
+
w: i,
|
|
262
|
+
m: f
|
|
263
|
+
};
|
|
264
|
+
})();
|
|
265
|
+
}
|
|
266
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
267
|
+
var i = Object.defineProperty;
|
|
268
|
+
try {
|
|
269
|
+
i({}, "", {});
|
|
270
|
+
} catch (e) {
|
|
271
|
+
i = 0;
|
|
272
|
+
}
|
|
273
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
274
|
+
function o(r, n) {
|
|
275
|
+
_regeneratorDefine(e, r, function (e) {
|
|
276
|
+
return this._invoke(r, n, e);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
r ? i ? i(e, r, {
|
|
280
|
+
value: n,
|
|
281
|
+
enumerable: !t,
|
|
282
|
+
configurable: !t,
|
|
283
|
+
writable: !t
|
|
284
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
285
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
286
|
+
}
|
|
154
287
|
function _setPrototypeOf(t, e) {
|
|
155
288
|
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
156
289
|
return t.__proto__ = e, t;
|
|
@@ -1609,27 +1742,6 @@
|
|
|
1609
1742
|
}]);
|
|
1610
1743
|
}(BaseModel);
|
|
1611
1744
|
|
|
1612
|
-
/**
|
|
1613
|
-
* models - GridModel
|
|
1614
|
-
*
|
|
1615
|
-
* 参照中台 `mdf-cube/src/models/GridModel.js`(`cb.models.register('GridModel')`)重写,
|
|
1616
|
-
* 把它的约定搬进我们这套 devfab 的 ui-model 体系:
|
|
1617
|
-
*
|
|
1618
|
-
* 1. 两层数据:`dataSource`(全量原始数据)+ `rows`(当前展示行,本地模式下是 dataSource 的分页切片);
|
|
1619
|
-
* 2. 行状态与数据同序:`rowsDataState[i]` 对应 `dataSource[i]`,取值见 DataStates;
|
|
1620
|
-
* 3. 内部字段由 `innerUsedAttrs` 统一定义:`_id` / `_selected` / `_status`;
|
|
1621
|
-
* 4. 列是 **object map**(key = field),不是数组 —— 给 vxe-grid 渲染时用 `getColumnList()` 转数组;
|
|
1622
|
-
* 5. 分页状态叫 `pageInfo`(pageIndex/pageSize/pageCount/recordCount),不叫 pager;
|
|
1623
|
-
* 6. 行、单元格、列都可以挂状态:`rowState` / `cellState`;
|
|
1624
|
-
* 7. 选中分「当前页 `_selected` 标记」与「跨页选中缓存(selectedKeysSet + selectedRowsMap)」两层。
|
|
1625
|
-
*
|
|
1626
|
-
* 与中台实现不同的地方(有意为之,都有注释说明):
|
|
1627
|
-
* - 中台的取数配置走 `proxyConfig` + `setProxy`,我们直接保留 `proxyConfig.load`(函数或 url),
|
|
1628
|
-
* 并兼容旧的 `dataSource: fn` / `cUrl` 写法;
|
|
1629
|
-
* - 中台的 `setRows` 会把 `getShowRows()`(展示文案副本)推给组件,我们推**原始行对象**,
|
|
1630
|
-
* 否则选中回灌、单元格编辑会落到副本上;
|
|
1631
|
-
* - 中台的行模型(editRowModel / ReferModel / 特征 / 孙表)没有移植,这里只做行级与单元格级能力。
|
|
1632
|
-
*/
|
|
1633
1745
|
var DataStates = {
|
|
1634
1746
|
Unchanged: '',
|
|
1635
1747
|
Insert: 'Insert',
|
|
@@ -1657,9 +1769,9 @@
|
|
|
1657
1769
|
|
|
1658
1770
|
// ---------------- 列:数组 ↔ object map 归一 ----------------
|
|
1659
1771
|
|
|
1660
|
-
/**
|
|
1661
|
-
* 列统一收敛成 object map(key = field),与中台一致。
|
|
1662
|
-
* 入参既接受数组(我们自己写 meta 的习惯),也接受后端下发的 map。
|
|
1772
|
+
/**
|
|
1773
|
+
* 列统一收敛成 object map(key = field),与中台一致。
|
|
1774
|
+
* 入参既接受数组(我们自己写 meta 的习惯),也接受后端下发的 map。
|
|
1663
1775
|
*/
|
|
1664
1776
|
function normalizeColumns(columns) {
|
|
1665
1777
|
var map = {};
|
|
@@ -1683,6 +1795,21 @@
|
|
|
1683
1795
|
return map;
|
|
1684
1796
|
}
|
|
1685
1797
|
|
|
1798
|
+
// ---------------- 响应体:从各种后端结构里取行与总数 ----------------
|
|
1799
|
+
|
|
1800
|
+
function resolveRowsData(res) {
|
|
1801
|
+
if (!res) return [];
|
|
1802
|
+
if (isArray(res)) return res;
|
|
1803
|
+
if (isArray(res.data)) return res.data;
|
|
1804
|
+
if (isArray(res.records)) return res.records;
|
|
1805
|
+
if (isArray(res.list)) return res.list;
|
|
1806
|
+
if (isArray(res.rows)) return res.rows;
|
|
1807
|
+
var nested = res.data && _typeof(res.data) === 'object' ? res.data : res.result;
|
|
1808
|
+
if (isArray(nested)) return nested;
|
|
1809
|
+
if (nested && _typeof(nested) === 'object') return nested.records || nested.list || nested.rows || nested.data || [];
|
|
1810
|
+
return [];
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1686
1813
|
/** 给行补内部 id(没有主键时用 rowId_ 前缀,与中台一致) */
|
|
1687
1814
|
function setIds() {
|
|
1688
1815
|
var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -1743,11 +1870,11 @@
|
|
|
1743
1870
|
};
|
|
1744
1871
|
}
|
|
1745
1872
|
|
|
1746
|
-
/**
|
|
1747
|
-
* 取数配置:中台叫 proxyConfig({ load: fn|url }),这里兼容三种写法
|
|
1748
|
-
* - `proxyConfig: { load }`
|
|
1749
|
-
* - `dataSource: fn`(旧写法)
|
|
1750
|
-
* - `cUrl: '/xxx'`
|
|
1873
|
+
/**
|
|
1874
|
+
* 取数配置:中台叫 proxyConfig({ load: fn|url }),这里兼容三种写法
|
|
1875
|
+
* - `proxyConfig: { load }`
|
|
1876
|
+
* - `dataSource: fn`(旧写法)
|
|
1877
|
+
* - `cUrl: '/xxx'`
|
|
1751
1878
|
*/
|
|
1752
1879
|
function resolveProxyConfig() {
|
|
1753
1880
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1757,12 +1884,13 @@
|
|
|
1757
1884
|
if (!proxy.load && typeof props.url === 'string') proxy.load = props.url;
|
|
1758
1885
|
return proxy;
|
|
1759
1886
|
}
|
|
1760
|
-
|
|
1761
|
-
/* code-link-enable */
|
|
1762
|
-
var showPageInner = function showPageInner(proxyConfig, queryParams, callback, refresh, needLoadPageination, backQueryPageCount, extraProps) {
|
|
1887
|
+
function _getData(proxyConfig, queryParams, callback) {
|
|
1763
1888
|
var _this = this;
|
|
1764
|
-
this.promiseExecute('
|
|
1765
|
-
|
|
1889
|
+
this.promiseExecute('beforeQuery', {
|
|
1890
|
+
proxyConfig: proxyConfig,
|
|
1891
|
+
queryParams: queryParams
|
|
1892
|
+
}, function () {
|
|
1893
|
+
var self = _this;
|
|
1766
1894
|
var proxy = _this.setProxy({
|
|
1767
1895
|
queryData: proxyConfig
|
|
1768
1896
|
});
|
|
@@ -1772,174 +1900,37 @@
|
|
|
1772
1900
|
pageIndex: _this.getPageIndex()
|
|
1773
1901
|
}
|
|
1774
1902
|
};
|
|
1775
|
-
if (!defaultParams.page.pageSize) {
|
|
1776
|
-
_this.setPageSize(10);
|
|
1777
|
-
defaultParams.page.pageSize = 10;
|
|
1778
|
-
}
|
|
1779
|
-
var bLoadPagination = _this._get_data('bLoadPagination');
|
|
1780
|
-
if (!bLoadPagination && !needLoadPageination) defaultParams.page.totalCount = 1;
|
|
1781
|
-
var delayLoadPageInfo = _this._get_data('delayLoadPageInfo');
|
|
1782
|
-
if (bLoadPagination && delayLoadPageInfo) {
|
|
1783
|
-
if (refresh) {
|
|
1784
|
-
_this.setState('showDelayPagination', true);
|
|
1785
|
-
}
|
|
1786
|
-
defaultParams.page.totalCount = 1;
|
|
1787
|
-
}
|
|
1788
1903
|
var params = Object.assign(defaultParams, queryParams);
|
|
1789
1904
|
_this.setCache('proxyCache', {
|
|
1790
1905
|
proxyConfig: proxyConfig,
|
|
1791
1906
|
params: params
|
|
1792
1907
|
});
|
|
1793
|
-
|
|
1794
|
-
var responseData = {};
|
|
1795
|
-
var viewModel = _this.getRootParent();
|
|
1796
|
-
var self = _this;
|
|
1797
|
-
|
|
1798
|
-
// 增加queryId解决 报表临时表锁问题
|
|
1799
|
-
var queryId = new Date().valueOf();
|
|
1800
|
-
params.queryId = queryId;
|
|
1908
|
+
_this.getRootParent();
|
|
1801
1909
|
var queryDataCallback = function queryDataCallback(err, result, callBackMsg, errorDetail) {
|
|
1802
|
-
var _this$getParent, _this$getParent$getPa;
|
|
1803
|
-
setTimeout(function () {
|
|
1804
|
-
self.clearCache('isGridInLoading');
|
|
1805
|
-
}, 0);
|
|
1806
|
-
viewModel === null || viewModel === void 0 || viewModel.clearCache('lazySearch');
|
|
1807
1910
|
if (err) {
|
|
1808
|
-
this.setState('showDelayPagination', false);
|
|
1809
|
-
this.clearCache('setPageIndexFromBack');
|
|
1810
1911
|
return;
|
|
1811
1912
|
}
|
|
1812
|
-
result = result || {}; // 容错处理null或者undefined情况
|
|
1813
1913
|
this._set_data('dataSourceMode', 'remote'); // 处理请求过程中被修改
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
}
|
|
1818
|
-
var data = Array.isArray(result.recordList) ? result.recordList : [];
|
|
1819
|
-
if ((!(bLoadPagination && delayLoadPageInfo) || queryCount === 2) && callback) {
|
|
1820
|
-
callback.call(this, result, callBackMsg, errorDetail);
|
|
1821
|
-
}
|
|
1822
|
-
this.getCache('setPageIndexFromBack'); // 是否是从卡片页返回的
|
|
1823
|
-
this.clearCache('setPageIndexFromBack');
|
|
1824
|
-
if (!this.execute('beforeSetDataSource', data)) return;
|
|
1825
|
-
var rowKeyField = this._get_data('rowKeyField');
|
|
1826
|
-
var keyMap = {};
|
|
1827
|
-
data.forEach(function (item) {
|
|
1828
|
-
keyMap[item[rowKeyField]] = item;
|
|
1829
|
-
});
|
|
1830
|
-
this._set_data('keyMap', keyMap);
|
|
1831
|
-
if (!refresh && this._get_data('override') === false) {
|
|
1832
|
-
this._set_data('dataSource', this._get_data('dataSource').concat(data), true);
|
|
1833
|
-
} else {
|
|
1834
|
-
this._set_data('dataSource', data, true);
|
|
1835
|
-
this.doPropertyChange('resetCellStatus');
|
|
1836
|
-
this._set_data('cellState', {}, true);
|
|
1837
|
-
this._set_data('rowState', {}, true);
|
|
1838
|
-
}
|
|
1839
|
-
// 存入当前model缓存便于client端搜索
|
|
1840
|
-
this.setCache('currentGridData', data);
|
|
1841
|
-
if (data.length) {
|
|
1842
|
-
setIds.call(this, data);
|
|
1843
|
-
}
|
|
1844
|
-
this.initRowState();
|
|
1845
|
-
// 修改缓存数据
|
|
1846
|
-
setCachePaginationRowData.call(this, data);
|
|
1847
|
-
this._get_data('sortParams');
|
|
1848
|
-
var colFilterParams = this._get_data('colFilterParams');
|
|
1849
|
-
this.showRows(null, !cb.utils.isEmptyObject(colFilterParams));
|
|
1850
|
-
var pageInfo = this._get_data('pageInfo');
|
|
1851
|
-
// bLoadPagination 优先级比 delayLoadPageInfo 高,bLoadPagination开启时值是false,所以第一项条件需要用 bLoadPagination = false 约束 delayLoadPageInfo = true 的情况
|
|
1852
|
-
if (bLoadPagination && !delayLoadPageInfo && (this._get_data('bLoadPagination') || needLoadPageination)) {
|
|
1853
|
-
pageInfo = {
|
|
1854
|
-
pageSize: result.pageSize,
|
|
1855
|
-
pageIndex: result.pageIndex,
|
|
1856
|
-
pageCount: result.pageCount,
|
|
1857
|
-
recordCount: result.recordCount
|
|
1858
|
-
};
|
|
1859
|
-
this.setPageInfo(pageInfo);
|
|
1860
|
-
} else {
|
|
1861
|
-
pageInfo.pageIndex = result.pageIndex;
|
|
1862
|
-
pageInfo.from = 'showPageInner';
|
|
1863
|
-
this.setPageInfo(pageInfo);
|
|
1864
|
-
}
|
|
1865
|
-
resetSelected.call(this);
|
|
1866
|
-
if (!(((_this$getParent = this.getParent) === null || _this$getParent === void 0 || (_this$getParent = _this$getParent.call(this)) === null || _this$getParent === void 0 || (_this$getParent$getPa = _this$getParent.getParams) === null || _this$getParent$getPa === void 0 || (_this$getParent$getPa = _this$getParent$getPa.call(_this$getParent)) === null || _this$getParent$getPa === void 0 ? void 0 : _this$getParent$getPa.templateType) === 'splitview')) {
|
|
1867
|
-
this._set_data('focusedRowIndex', -1); // 重置选中行
|
|
1868
|
-
}
|
|
1869
|
-
for (var _len = arguments.length, args = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
|
|
1870
|
-
args[_key - 4] = arguments[_key];
|
|
1871
|
-
}
|
|
1872
|
-
this.execute('afterSetDataSource', data, result.viewmodel, args === null || args === void 0 ? void 0 : args[1]); // 社保缴交节点翻页的时候需要改columns
|
|
1914
|
+
result = Object.assign({}, result);
|
|
1915
|
+
var data = resolveRowsData(result);
|
|
1916
|
+
callback === null || callback === void 0 || callback.call(this, data);
|
|
1873
1917
|
};
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
var queryDataParams = _.cloneDeep(params);
|
|
1878
|
-
proxy.queryData(queryDataParams, queryDataCallback, _this);
|
|
1879
|
-
}
|
|
1880
|
-
if (refresh && bLoadPagination && delayLoadPageInfo) {
|
|
1881
|
-
var queryPageProxyConfig = JSON.parse(JSON.stringify(proxyConfig));
|
|
1882
|
-
if (!queryPageProxyConfig.options) {
|
|
1883
|
-
queryPageProxyConfig.options = {};
|
|
1884
|
-
}
|
|
1885
|
-
queryPageProxyConfig.options.mask = false;
|
|
1886
|
-
var _callback = function _callback(pageInfo) {
|
|
1887
|
-
queryCount++;
|
|
1888
|
-
Object.assign(responseData, pageInfo);
|
|
1889
|
-
if (queryCount === 2 && callback) {
|
|
1890
|
-
callback.call(_this, responseData);
|
|
1891
|
-
}
|
|
1892
|
-
};
|
|
1893
|
-
queryPageCount.call(_this, queryPageProxyConfig, params, function (pageInfo) {
|
|
1894
|
-
_callback(pageInfo);
|
|
1895
|
-
});
|
|
1896
|
-
}
|
|
1918
|
+
if (_this.execute('beforeQueryData', params) === false) return;
|
|
1919
|
+
var queryDataParams = _.cloneDeep(params);
|
|
1920
|
+
proxy.queryData(queryDataParams, queryDataCallback, self);
|
|
1897
1921
|
});
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
queryPageCount: _objectSpread2({}, proxyConfig)
|
|
1922
|
+
}
|
|
1923
|
+
function _setData(data) {
|
|
1924
|
+
if (!this.execute('beforeSetDataSource', data)) return;
|
|
1925
|
+
var rowKeyField = this._get_data('rowKeyField');
|
|
1926
|
+
var keyMap = {};
|
|
1927
|
+
data.forEach(function (item) {
|
|
1928
|
+
keyMap[item[rowKeyField]] = item;
|
|
1906
1929
|
});
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
};
|
|
1912
|
-
var params = Object.assign(true, queryParams, defaultParams);
|
|
1913
|
-
if (!this.__queryPageCountRequestId) this.__queryPageCountRequestId = 0;
|
|
1914
|
-
this.__queryPageCountRequestId++;
|
|
1915
|
-
var queryPageCountCallback = function queryPageCountCallback(requestId, err, result) {
|
|
1916
|
-
if (this.__queryPageCountRequestId !== requestId) return;
|
|
1917
|
-
this.setCache('queryPageCountLoading', false);
|
|
1918
|
-
this.setState('showDelayPagination', false);
|
|
1919
|
-
if (err) {
|
|
1920
|
-
var currentpageinfo = this._get_data('pageInfo');
|
|
1921
|
-
if (currentpageinfo) {
|
|
1922
|
-
// 接口报错时,分页组件信息保持原来的值
|
|
1923
|
-
this.setPageInfo(currentpageinfo);
|
|
1924
|
-
}
|
|
1925
|
-
return;
|
|
1926
|
-
}
|
|
1927
|
-
result = result || {}; // 容错处理null或者undefined情况
|
|
1928
|
-
var pageInfo = {
|
|
1929
|
-
beginPageIndex: result.beginPageIndex,
|
|
1930
|
-
endPageIndex: result.endPageIndex,
|
|
1931
|
-
pageSize: result.pageSize,
|
|
1932
|
-
pageIndex: result.pageIndex,
|
|
1933
|
-
pageCount: result.pageCount,
|
|
1934
|
-
recordCount: result.recordCount
|
|
1935
|
-
};
|
|
1936
|
-
if (callback) {
|
|
1937
|
-
callback.call(this, pageInfo);
|
|
1938
|
-
}
|
|
1939
|
-
this.setPageInfo(pageInfo);
|
|
1940
|
-
this.execute('afterQueryPageInfo', result);
|
|
1941
|
-
};
|
|
1942
|
-
proxy.queryPageCount(params, queryPageCountCallback.bind(this, this.__queryPageCountRequestId), this);
|
|
1930
|
+
this._set_data('keyMap', keyMap);
|
|
1931
|
+
this._set_data('dataSource', data, true);
|
|
1932
|
+
this.doPropertyChange('setDataSource');
|
|
1933
|
+
this.execute('afterSetDataSource', data);
|
|
1943
1934
|
}
|
|
1944
1935
|
|
|
1945
1936
|
// ============================================================
|
|
@@ -1960,6 +1951,7 @@
|
|
|
1960
1951
|
// 静态数据:cData / data 数组
|
|
1961
1952
|
var seed = props.cData || (isArray(props.data) ? props.data : null);
|
|
1962
1953
|
_this2 = _callSuper(this, GridModel, [data]);
|
|
1954
|
+
_defineProperty(_this2, "modelType", 'GridModel');
|
|
1963
1955
|
_this2.initPageInfo(props.cPage || props.page);
|
|
1964
1956
|
_this2.initColumns(data.columns);
|
|
1965
1957
|
_this2.initRowState();
|
|
@@ -2174,105 +2166,57 @@
|
|
|
2174
2166
|
|
|
2175
2167
|
/* ============================ 取数 ============================ */
|
|
2176
2168
|
|
|
2177
|
-
|
|
2169
|
+
/* ======================= 数据写入 ======================= */
|
|
2178
2170
|
}, {
|
|
2179
|
-
key: "
|
|
2180
|
-
value: function
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
this.setDataSource(result.data);
|
|
2200
|
-
if (callback) {
|
|
2201
|
-
callback.call(this);
|
|
2202
|
-
}
|
|
2203
|
-
}, this);
|
|
2171
|
+
key: "setDataSource",
|
|
2172
|
+
value: function setDataSource(proxyConfig) {
|
|
2173
|
+
var _this4 = this;
|
|
2174
|
+
var queryParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2175
|
+
var callback = arguments.length > 2 ? arguments[2] : undefined;
|
|
2176
|
+
if (this._get_data('dataSourceMode') === 'local') {
|
|
2177
|
+
var data = cb.utils.isArray(proxyConfig) ? proxyConfig : [];
|
|
2178
|
+
_setData(data);
|
|
2179
|
+
} else {
|
|
2180
|
+
if (!this.execute('beforeProxyLoad', queryParams)) return;
|
|
2181
|
+
var pageInfo = this._get_data('pageInfo');
|
|
2182
|
+
pageInfo.pageIndex = 1;
|
|
2183
|
+
this._set_data('proxyConfig', proxyConfig);
|
|
2184
|
+
this._set_data('queryParams', queryParams);
|
|
2185
|
+
this._set_data('loadDataCallback', callback);
|
|
2186
|
+
_getData.call(this, proxyConfig, queryParams, function (data) {
|
|
2187
|
+
_setData.call(_this4, data);
|
|
2188
|
+
callback === null || callback === void 0 || callback.call(_this4);
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2204
2191
|
}
|
|
2205
|
-
|
|
2206
|
-
// 重新取数:优先驱动已挂载的表格(走表格自带的分页状态),没有视图时直接取数
|
|
2207
2192
|
}, {
|
|
2208
|
-
key: "
|
|
2209
|
-
value: function
|
|
2210
|
-
var
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2193
|
+
key: "reload",
|
|
2194
|
+
value: function reload() {
|
|
2195
|
+
var _this5 = this;
|
|
2196
|
+
this.getProxy();
|
|
2197
|
+
var proxyConfig = this._get_data('proxyConfig');
|
|
2198
|
+
var queryParams = this._get_data('queryParams');
|
|
2199
|
+
var callback = this._get_data('loadDataCallback');
|
|
2200
|
+
_getData.call(this, proxyConfig, queryParams, function (data) {
|
|
2201
|
+
_setData.call(_this5, data);
|
|
2202
|
+
callback === null || callback === void 0 || callback.call(_this5);
|
|
2214
2203
|
});
|
|
2215
2204
|
}
|
|
2216
|
-
}, {
|
|
2217
|
-
key: "loadData",
|
|
2218
|
-
value: function loadData() {
|
|
2219
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2220
|
-
return this.refresh(params);
|
|
2221
|
-
}
|
|
2222
|
-
}, {
|
|
2223
|
-
key: "queryData",
|
|
2224
|
-
value: function queryData() {
|
|
2225
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2226
|
-
return this.refresh(params);
|
|
2227
|
-
}
|
|
2228
2205
|
|
|
2229
2206
|
/* ======================== 数据(两层) ======================== */
|
|
2230
|
-
|
|
2231
|
-
/** 全量数据源(中台 getRealData 的语义:不拷贝,剔除已删除行) */
|
|
2232
2207
|
}, {
|
|
2233
2208
|
key: "getDataSource",
|
|
2234
2209
|
value: function getDataSource() {
|
|
2235
2210
|
var source = this._get_data('dataSource') || [];
|
|
2236
|
-
|
|
2237
|
-
var rowsDataState = this._get_data('rowsDataState') || [];
|
|
2238
|
-
return source.filter(function (row, index) {
|
|
2239
|
-
return rowsDataState[index] !== DataStates.Delete;
|
|
2240
|
-
});
|
|
2241
|
-
}
|
|
2242
|
-
}, {
|
|
2243
|
-
key: "getRealData",
|
|
2244
|
-
value: function getRealData() {
|
|
2245
|
-
return this.getDataSource();
|
|
2246
|
-
}
|
|
2247
|
-
}, {
|
|
2248
|
-
key: "getRealRows",
|
|
2249
|
-
value: function getRealRows() {
|
|
2250
|
-
return this._get_data('rows') || [];
|
|
2251
|
-
}
|
|
2252
|
-
}, {
|
|
2253
|
-
key: "getRowsCount",
|
|
2254
|
-
value: function getRowsCount() {
|
|
2255
|
-
return (this._get_data('rows') || []).length;
|
|
2256
|
-
}
|
|
2257
|
-
}, {
|
|
2258
|
-
key: "getDataSourceCount",
|
|
2259
|
-
value: function getDataSourceCount() {
|
|
2260
|
-
return (this._get_data('dataSource') || []).length;
|
|
2261
|
-
}
|
|
2262
|
-
}, {
|
|
2263
|
-
key: "hasDeletedRow",
|
|
2264
|
-
value: function hasDeletedRow() {
|
|
2265
|
-
return (this._get_data('rowsDataState') || []).some(function (state) {
|
|
2266
|
-
return state === DataStates.Delete;
|
|
2267
|
-
});
|
|
2211
|
+
return source;
|
|
2268
2212
|
}
|
|
2269
2213
|
|
|
2270
|
-
/**
|
|
2271
|
-
* 数据出口,签名与中台一致,但语义容易踩坑,这里写清楚:
|
|
2272
|
-
* - `getData()` → 全量 dataSource(提交/保存用,保留 _status,剔除 _selected)
|
|
2273
|
-
* - `getData(true)` → 当前页 rows(视图用,剔除 _status / _selected)
|
|
2274
|
-
* - `getAllData()` → 等于 getData(true),仅为对齐中台签名而保留
|
|
2275
|
-
* - `getPageData()` → 等于 getData(true),语义更直白的别名
|
|
2214
|
+
/**
|
|
2215
|
+
* 数据出口,签名与中台一致,但语义容易踩坑,这里写清楚:
|
|
2216
|
+
* - `getData()` → 全量 dataSource(提交/保存用,保留 _status,剔除 _selected)
|
|
2217
|
+
* - `getData(true)` → 当前页 rows(视图用,剔除 _status / _selected)
|
|
2218
|
+
* - `getAllData()` → 等于 getData(true),仅为对齐中台签名而保留
|
|
2219
|
+
* - `getPageData()` → 等于 getData(true),语义更直白的别名
|
|
2276
2220
|
*/
|
|
2277
2221
|
}, {
|
|
2278
2222
|
key: "getData",
|
|
@@ -2363,18 +2307,18 @@
|
|
|
2363
2307
|
}, {
|
|
2364
2308
|
key: "getRowIndexByRowId",
|
|
2365
2309
|
value: function getRowIndexByRowId(rowId) {
|
|
2366
|
-
var
|
|
2310
|
+
var _this6 = this;
|
|
2367
2311
|
var rows = this._get_data('rows') || [];
|
|
2368
2312
|
return rows.findIndex(function (row) {
|
|
2369
|
-
return (row === null || row === void 0 ? void 0 : row[
|
|
2313
|
+
return (row === null || row === void 0 ? void 0 : row[_this6.getIdFlag()]) === rowId;
|
|
2370
2314
|
});
|
|
2371
2315
|
}
|
|
2372
2316
|
}, {
|
|
2373
2317
|
key: "getDataSourceIndexByRowId",
|
|
2374
2318
|
value: function getDataSourceIndexByRowId(rowId) {
|
|
2375
|
-
var
|
|
2319
|
+
var _this7 = this;
|
|
2376
2320
|
return (this._get_data('dataSource') || []).findIndex(function (row) {
|
|
2377
|
-
return (row === null || row === void 0 ? void 0 : row[
|
|
2321
|
+
return (row === null || row === void 0 ? void 0 : row[_this7.getIdFlag()]) === rowId;
|
|
2378
2322
|
});
|
|
2379
2323
|
}
|
|
2380
2324
|
}, {
|
|
@@ -2436,11 +2380,11 @@
|
|
|
2436
2380
|
}, {
|
|
2437
2381
|
key: "setCellValues",
|
|
2438
2382
|
value: function setCellValues() {
|
|
2439
|
-
var
|
|
2383
|
+
var _this8 = this;
|
|
2440
2384
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2441
2385
|
if (!isArray(values)) return;
|
|
2442
2386
|
values.forEach(function (item) {
|
|
2443
|
-
return
|
|
2387
|
+
return _this8.setCellValue(item.rowIndex, item.cellName || item.field, item.value);
|
|
2444
2388
|
});
|
|
2445
2389
|
}
|
|
2446
2390
|
}, {
|
|
@@ -2479,11 +2423,11 @@
|
|
|
2479
2423
|
}, {
|
|
2480
2424
|
key: "setCellStates",
|
|
2481
2425
|
value: function setCellStates() {
|
|
2482
|
-
var
|
|
2426
|
+
var _this9 = this;
|
|
2483
2427
|
var states = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2484
2428
|
if (!isArray(states)) return;
|
|
2485
2429
|
states.forEach(function (item) {
|
|
2486
|
-
return
|
|
2430
|
+
return _this9.setCellState(item.rowIndex, item.cellName, item.propertyName || item.name, item.value);
|
|
2487
2431
|
});
|
|
2488
2432
|
}
|
|
2489
2433
|
|
|
@@ -2500,7 +2444,7 @@
|
|
|
2500
2444
|
}, {
|
|
2501
2445
|
key: "getDataSourceIndexByRow",
|
|
2502
2446
|
value: function getDataSourceIndexByRow(rowIndex) {
|
|
2503
|
-
var
|
|
2447
|
+
var _this0 = this;
|
|
2504
2448
|
var rows = this._get_data('rows') || [];
|
|
2505
2449
|
var row = rows[rowIndex];
|
|
2506
2450
|
if (!row) return -1;
|
|
@@ -2509,7 +2453,7 @@
|
|
|
2509
2453
|
if (index > -1) return index;
|
|
2510
2454
|
// 本地分页时 rows 是切片,引用一致;远程模式下 rows 与 dataSource 同源
|
|
2511
2455
|
return source.findIndex(function (item) {
|
|
2512
|
-
return (item === null || item === void 0 ? void 0 : item[
|
|
2456
|
+
return (item === null || item === void 0 ? void 0 : item[_this0.getIdFlag()]) === (row === null || row === void 0 ? void 0 : row[_this0.getIdFlag()]);
|
|
2513
2457
|
});
|
|
2514
2458
|
}
|
|
2515
2459
|
}, {
|
|
@@ -2573,11 +2517,11 @@
|
|
|
2573
2517
|
}, {
|
|
2574
2518
|
key: "setRowStates",
|
|
2575
2519
|
value: function setRowStates() {
|
|
2576
|
-
var
|
|
2520
|
+
var _this1 = this;
|
|
2577
2521
|
var states = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2578
2522
|
if (!isArray(states)) return;
|
|
2579
2523
|
states.forEach(function (item) {
|
|
2580
|
-
return
|
|
2524
|
+
return _this1.setRowState(item.rowIndex, item.propertyName || item.name, item.value);
|
|
2581
2525
|
});
|
|
2582
2526
|
}
|
|
2583
2527
|
|
|
@@ -2585,7 +2529,7 @@
|
|
|
2585
2529
|
}, {
|
|
2586
2530
|
key: "getDirtyData",
|
|
2587
2531
|
value: function getDirtyData(necessary) {
|
|
2588
|
-
var
|
|
2532
|
+
var _this10 = this;
|
|
2589
2533
|
var source = this._get_data('dataSource') || [];
|
|
2590
2534
|
var rowsDataState = this._get_data('rowsDataState') || [];
|
|
2591
2535
|
var data = [];
|
|
@@ -2593,7 +2537,7 @@
|
|
|
2593
2537
|
var dataState = rowsDataState[index];
|
|
2594
2538
|
if (!dataState) return;
|
|
2595
2539
|
var item = cloneDeep(row);
|
|
2596
|
-
item[
|
|
2540
|
+
item[_this10.getStatusFlag()] = dataState;
|
|
2597
2541
|
data.push(item);
|
|
2598
2542
|
});
|
|
2599
2543
|
return data.length ? data : undefined;
|
|
@@ -2601,12 +2545,12 @@
|
|
|
2601
2545
|
}, {
|
|
2602
2546
|
key: "getDirtyRowIndexes",
|
|
2603
2547
|
value: function getDirtyRowIndexes() {
|
|
2604
|
-
var
|
|
2548
|
+
var _this11 = this;
|
|
2605
2549
|
var rows = this._get_data('rows') || [];
|
|
2606
2550
|
return rows.map(function (row, index) {
|
|
2607
2551
|
return index;
|
|
2608
2552
|
}).filter(function (index) {
|
|
2609
|
-
return !!
|
|
2553
|
+
return !!_this11.getRowDataState(index);
|
|
2610
2554
|
});
|
|
2611
2555
|
}
|
|
2612
2556
|
}, {
|
|
@@ -2669,11 +2613,11 @@
|
|
|
2669
2613
|
}, {
|
|
2670
2614
|
key: "insertRows",
|
|
2671
2615
|
value: function insertRows(rowIndex) {
|
|
2672
|
-
var
|
|
2616
|
+
var _this12 = this;
|
|
2673
2617
|
var rowsData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
2674
2618
|
var result = [];
|
|
2675
2619
|
(isArray(rowsData) ? rowsData : [rowsData]).forEach(function (rowData, offset) {
|
|
2676
|
-
result.push(
|
|
2620
|
+
result.push(_this12.insertRow(rowIndex + offset, rowData));
|
|
2677
2621
|
});
|
|
2678
2622
|
return result;
|
|
2679
2623
|
}
|
|
@@ -2705,11 +2649,11 @@
|
|
|
2705
2649
|
}, {
|
|
2706
2650
|
key: "updateRows",
|
|
2707
2651
|
value: function updateRows() {
|
|
2708
|
-
var
|
|
2652
|
+
var _this13 = this;
|
|
2709
2653
|
var rowsData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2710
2654
|
rowsData.forEach(function (item) {
|
|
2711
2655
|
var _item$rowIndex;
|
|
2712
|
-
return
|
|
2656
|
+
return _this13.updateRow((_item$rowIndex = item.rowIndex) !== null && _item$rowIndex !== void 0 ? _item$rowIndex : item.index, item.rowData || item.row);
|
|
2713
2657
|
});
|
|
2714
2658
|
}
|
|
2715
2659
|
|
|
@@ -2717,9 +2661,9 @@
|
|
|
2717
2661
|
}, {
|
|
2718
2662
|
key: "deleteRows",
|
|
2719
2663
|
value: function deleteRows(rowIndexes) {
|
|
2720
|
-
var
|
|
2664
|
+
var _this14 = this;
|
|
2721
2665
|
var indexes = (isArray(rowIndexes) ? rowIndexes : [rowIndexes]).filter(function (index) {
|
|
2722
|
-
return index >= 0 && index <
|
|
2666
|
+
return index >= 0 && index < _this14.getRowsCount();
|
|
2723
2667
|
}).sort(function (a, b) {
|
|
2724
2668
|
return a - b;
|
|
2725
2669
|
});
|
|
@@ -2734,14 +2678,14 @@
|
|
|
2734
2678
|
rowsToDelete.forEach(function (row) {
|
|
2735
2679
|
var index = source.indexOf(row);
|
|
2736
2680
|
if (index < 0) return;
|
|
2737
|
-
var key = row[
|
|
2681
|
+
var key = row[_this14.getIdFlag()];
|
|
2738
2682
|
deletedIds.add(key);
|
|
2739
2683
|
if (rowsDataState[index] === DataStates.Insert) discardIds.add(key);
|
|
2740
2684
|
});
|
|
2741
2685
|
var keptSource = [];
|
|
2742
2686
|
var keptState = [];
|
|
2743
2687
|
source.forEach(function (row, index) {
|
|
2744
|
-
var key = row[
|
|
2688
|
+
var key = row[_this14.getIdFlag()];
|
|
2745
2689
|
if (!deletedIds.has(key)) {
|
|
2746
2690
|
keptSource.push(row);
|
|
2747
2691
|
keptState.push(rowsDataState[index]);
|
|
@@ -2783,15 +2727,15 @@
|
|
|
2783
2727
|
|
|
2784
2728
|
/* ======================= 选中 ======================= */
|
|
2785
2729
|
|
|
2786
|
-
/**
|
|
2787
|
-
* 选中行
|
|
2788
|
-
* @param {Number|Array} rowIndexes rows 下标
|
|
2789
|
-
* @param {Boolean} all true = 替换选择(先清掉其他选中),默认 false = 追加
|
|
2730
|
+
/**
|
|
2731
|
+
* 选中行
|
|
2732
|
+
* @param {Number|Array} rowIndexes rows 下标
|
|
2733
|
+
* @param {Boolean} all true = 替换选择(先清掉其他选中),默认 false = 追加
|
|
2790
2734
|
*/
|
|
2791
2735
|
}, {
|
|
2792
2736
|
key: "select",
|
|
2793
2737
|
value: function select(rowIndexes, all) {
|
|
2794
|
-
var
|
|
2738
|
+
var _this15 = this;
|
|
2795
2739
|
if (rowIndexes == null && all !== true) return;
|
|
2796
2740
|
if (all === true) this.unselectAll({
|
|
2797
2741
|
silent: true
|
|
@@ -2800,7 +2744,7 @@
|
|
|
2800
2744
|
return index;
|
|
2801
2745
|
}) : isArray(rowIndexes) ? rowIndexes : [rowIndexes];
|
|
2802
2746
|
indexes = indexes.filter(function (index) {
|
|
2803
|
-
return index >= 0 && index <
|
|
2747
|
+
return index >= 0 && index < _this15.getRowsCount();
|
|
2804
2748
|
});
|
|
2805
2749
|
var rows = this._get_data('rows') || [];
|
|
2806
2750
|
var selectedFlag = this.getSelectedFlag();
|
|
@@ -2820,14 +2764,14 @@
|
|
|
2820
2764
|
if (!this.execute('beforeSelect', data)) return;
|
|
2821
2765
|
changed.forEach(function (index) {
|
|
2822
2766
|
rows[index][selectedFlag] = true;
|
|
2823
|
-
|
|
2767
|
+
_this15.cacheSelectedRow(rows[index], true);
|
|
2824
2768
|
});
|
|
2825
2769
|
this.flushSelection();
|
|
2826
2770
|
}
|
|
2827
2771
|
}, {
|
|
2828
2772
|
key: "unselect",
|
|
2829
2773
|
value: function unselect(rowIndexes) {
|
|
2830
|
-
var
|
|
2774
|
+
var _this16 = this;
|
|
2831
2775
|
if (rowIndexes == null) return;
|
|
2832
2776
|
var indexes = isArray(rowIndexes) ? rowIndexes : [rowIndexes];
|
|
2833
2777
|
var rows = this._get_data('rows') || [];
|
|
@@ -2840,34 +2784,34 @@
|
|
|
2840
2784
|
if (!this.execute('beforeUnselect', changed)) return;
|
|
2841
2785
|
changed.forEach(function (index) {
|
|
2842
2786
|
rows[index][selectedFlag] = false;
|
|
2843
|
-
|
|
2787
|
+
_this16.cacheSelectedRow(rows[index], false);
|
|
2844
2788
|
});
|
|
2845
2789
|
this.flushSelection();
|
|
2846
2790
|
}
|
|
2847
2791
|
}, {
|
|
2848
2792
|
key: "selectAll",
|
|
2849
2793
|
value: function selectAll() {
|
|
2850
|
-
var
|
|
2794
|
+
var _this17 = this;
|
|
2851
2795
|
var rows = this._get_data('rows') || [];
|
|
2852
2796
|
var selectedFlag = this.getSelectedFlag();
|
|
2853
2797
|
rows.forEach(function (row) {
|
|
2854
2798
|
row[selectedFlag] = true;
|
|
2855
|
-
|
|
2799
|
+
_this17.cacheSelectedRow(row, true);
|
|
2856
2800
|
});
|
|
2857
2801
|
this.flushSelection();
|
|
2858
2802
|
}
|
|
2859
2803
|
|
|
2860
|
-
/**
|
|
2861
|
-
* 清空选中
|
|
2862
|
-
* @param {Object} options onlyPage=true 只清当前页(其他页的跨页缓存保留);silent=true 不下发视图
|
|
2863
|
-
*
|
|
2864
|
-
* 注意要清 **dataSource** 上的行:`_selected` 记在行对象上,
|
|
2865
|
-
* 而本地分页时当前页的 rows 只是 dataSource 的切片,只清 rows 会让翻页回来的行「带着选中复活」。
|
|
2804
|
+
/**
|
|
2805
|
+
* 清空选中
|
|
2806
|
+
* @param {Object} options onlyPage=true 只清当前页(其他页的跨页缓存保留);silent=true 不下发视图
|
|
2807
|
+
*
|
|
2808
|
+
* 注意要清 **dataSource** 上的行:`_selected` 记在行对象上,
|
|
2809
|
+
* 而本地分页时当前页的 rows 只是 dataSource 的切片,只清 rows 会让翻页回来的行「带着选中复活」。
|
|
2866
2810
|
*/
|
|
2867
2811
|
}, {
|
|
2868
2812
|
key: "unselectAll",
|
|
2869
2813
|
value: function unselectAll() {
|
|
2870
|
-
var
|
|
2814
|
+
var _this18 = this;
|
|
2871
2815
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2872
2816
|
var selectedFlag = this.getSelectedFlag();
|
|
2873
2817
|
var targets = options.onlyPage ? this._get_data('rows') : this._get_data('dataSource');
|
|
@@ -2876,7 +2820,7 @@
|
|
|
2876
2820
|
});
|
|
2877
2821
|
if (options.onlyPage) {
|
|
2878
2822
|
(this._get_data('rows') || []).forEach(function (row) {
|
|
2879
|
-
return
|
|
2823
|
+
return _this18.cacheSelectedRow(row, false);
|
|
2880
2824
|
});
|
|
2881
2825
|
} else {
|
|
2882
2826
|
this._set_data('selectedKeys', [], true);
|
|
@@ -2891,15 +2835,15 @@
|
|
|
2891
2835
|
this.unselectAll();
|
|
2892
2836
|
}
|
|
2893
2837
|
|
|
2894
|
-
/**
|
|
2895
|
-
* 以传入的行集合作为**当前页**的选中结果(表格选中变化回灌的入口)。
|
|
2896
|
-
* 其他页的跨页选中缓存不受影响 —— 表格的勾选状态只覆盖当前页,
|
|
2897
|
-
* 若在这里清空缓存,翻页就会把之前选的行丢掉。
|
|
2838
|
+
/**
|
|
2839
|
+
* 以传入的行集合作为**当前页**的选中结果(表格选中变化回灌的入口)。
|
|
2840
|
+
* 其他页的跨页选中缓存不受影响 —— 表格的勾选状态只覆盖当前页,
|
|
2841
|
+
* 若在这里清空缓存,翻页就会把之前选的行丢掉。
|
|
2898
2842
|
*/
|
|
2899
2843
|
}, {
|
|
2900
2844
|
key: "setSelectedRows",
|
|
2901
2845
|
value: function setSelectedRows() {
|
|
2902
|
-
var
|
|
2846
|
+
var _this19 = this;
|
|
2903
2847
|
var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2904
2848
|
var list = isArray(rows) ? rows : [];
|
|
2905
2849
|
var keyField = this.getRowKeyField();
|
|
@@ -2913,7 +2857,7 @@
|
|
|
2913
2857
|
var selected = keys.has(String(row[keyField]));
|
|
2914
2858
|
if (selected !== !!row[selectedFlag]) {
|
|
2915
2859
|
row[selectedFlag] = selected;
|
|
2916
|
-
|
|
2860
|
+
_this19.cacheSelectedRow(row, selected);
|
|
2917
2861
|
}
|
|
2918
2862
|
});
|
|
2919
2863
|
this.flushSelection();
|
|
@@ -3095,9 +3039,9 @@
|
|
|
3095
3039
|
}));
|
|
3096
3040
|
}
|
|
3097
3041
|
|
|
3098
|
-
/**
|
|
3099
|
-
* 统一的分页写入:算 pageCount / 记录 begin~end、切片、下发视图
|
|
3100
|
-
* @param {Object} options silent=true 时不通知视图(组件自己的翻页动作走这里)
|
|
3042
|
+
/**
|
|
3043
|
+
* 统一的分页写入:算 pageCount / 记录 begin~end、切片、下发视图
|
|
3044
|
+
* @param {Object} options silent=true 时不通知视图(组件自己的翻页动作走这里)
|
|
3101
3045
|
*/
|
|
3102
3046
|
}, {
|
|
3103
3047
|
key: "applyPageInfo",
|
|
@@ -3138,54 +3082,6 @@
|
|
|
3138
3082
|
this.setRows(source.slice(start, start + pageSize));
|
|
3139
3083
|
}
|
|
3140
3084
|
|
|
3141
|
-
/* ======================= 数据写入 ======================= */
|
|
3142
|
-
|
|
3143
|
-
/** 全量赋值(中台 setDataSource):本地模式重新切片,远程模式等于当前页 */
|
|
3144
|
-
}, {
|
|
3145
|
-
key: "setDataSource",
|
|
3146
|
-
value: function setDataSource(proxyConfig) {
|
|
3147
|
-
var queryParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3148
|
-
var callback = arguments.length > 2 ? arguments[2] : undefined;
|
|
3149
|
-
if (this._get_data('dataSourceMode') === 'local') {
|
|
3150
|
-
var data = cb.utils.isArray(proxyConfig) ? proxyConfig : [];
|
|
3151
|
-
if (!this.execute('beforeSetDataSource', data)) return;
|
|
3152
|
-
var rowKeyField = this._get_data('rowKeyField');
|
|
3153
|
-
var keyMap = {};
|
|
3154
|
-
data.forEach(function (item) {
|
|
3155
|
-
keyMap[item[rowKeyField]] = item;
|
|
3156
|
-
});
|
|
3157
|
-
this._set_data('keyMap', keyMap);
|
|
3158
|
-
this._set_data('dataSource', data, true);
|
|
3159
|
-
this.getCache('grandson');
|
|
3160
|
-
if (data.length) {
|
|
3161
|
-
setIds.call(this, data);
|
|
3162
|
-
}
|
|
3163
|
-
this.initRowState();
|
|
3164
|
-
// 修改缓存数据
|
|
3165
|
-
setCachePaginationRowData.call(this, data);
|
|
3166
|
-
// 修改行号
|
|
3167
|
-
this.doPropertyChange('resetCellStatus');
|
|
3168
|
-
this._set_data('rowState', {}, true);
|
|
3169
|
-
// this.showRows(null, true)
|
|
3170
|
-
this.doPropertyChange('setDataSource', this.getShowRows());
|
|
3171
|
-
this._set_data('delayInsertRows', []); // setDataSource方法会同步模型和组件数据,把延迟存的数据清掉
|
|
3172
|
-
if (this._get_data('isSorting')) {
|
|
3173
|
-
this._set_data('isSorting', false);
|
|
3174
|
-
}
|
|
3175
|
-
this.execute('afterSetDataSource', data);
|
|
3176
|
-
} else {
|
|
3177
|
-
if (!this.execute('beforeProxyLoad', queryParams)) return;
|
|
3178
|
-
var pageInfo = this._get_data('pageInfo');
|
|
3179
|
-
pageInfo.pageIndex = 1;
|
|
3180
|
-
var needLoadPageination = true;
|
|
3181
|
-
// this.rebuildProxyConfig(proxyConfig)
|
|
3182
|
-
this._set_data('proxyConfig', proxyConfig);
|
|
3183
|
-
this._set_data('queryParams', queryParams);
|
|
3184
|
-
this._set_data('callback', callback);
|
|
3185
|
-
showPageInner.call(this, proxyConfig, queryParams, callback, true, needLoadPageination);
|
|
3186
|
-
}
|
|
3187
|
-
}
|
|
3188
|
-
|
|
3189
3085
|
/** 只换当前页 rows(中台 setRows) */
|
|
3190
3086
|
}, {
|
|
3191
3087
|
key: "setRows",
|
|
@@ -3205,10 +3101,10 @@
|
|
|
3205
3101
|
}, {
|
|
3206
3102
|
key: "setRowsIdMap",
|
|
3207
3103
|
value: function setRowsIdMap() {
|
|
3208
|
-
var
|
|
3104
|
+
var _this20 = this;
|
|
3209
3105
|
var map = {};
|
|
3210
3106
|
(this._get_data('rows') || []).forEach(function (row) {
|
|
3211
|
-
if ((row === null || row === void 0 ? void 0 : row[
|
|
3107
|
+
if ((row === null || row === void 0 ? void 0 : row[_this20.getIdFlag()]) !== undefined) map[row[_this20.getIdFlag()]] = row;
|
|
3212
3108
|
});
|
|
3213
3109
|
this._set_data('rowsIdMap', map);
|
|
3214
3110
|
}
|
|
@@ -3220,14 +3116,14 @@
|
|
|
3220
3116
|
|
|
3221
3117
|
/* ======================= 校验 ======================= */
|
|
3222
3118
|
|
|
3223
|
-
/**
|
|
3224
|
-
* 必输校验(中台会把校验委托给 editRowModel,我们这层没有行模型,只做列级必输)
|
|
3225
|
-
* @returns {Boolean} 通过返回 true,不通过返回 false,并把消息推给视图(validate 事件)
|
|
3119
|
+
/**
|
|
3120
|
+
* 必输校验(中台会把校验委托给 editRowModel,我们这层没有行模型,只做列级必输)
|
|
3121
|
+
* @returns {Boolean} 通过返回 true,不通过返回 false,并把消息推给视图(validate 事件)
|
|
3226
3122
|
*/
|
|
3227
3123
|
}, {
|
|
3228
3124
|
key: "validate",
|
|
3229
3125
|
value: function validate(cancel, paramsRowsIndex) {
|
|
3230
|
-
var
|
|
3126
|
+
var _this21 = this;
|
|
3231
3127
|
if (cancel) {
|
|
3232
3128
|
this.doPropertyChange('validate', {
|
|
3233
3129
|
type: '',
|
|
@@ -3244,18 +3140,18 @@
|
|
|
3244
3140
|
rows.forEach(function (row, index) {
|
|
3245
3141
|
for (var field in columns) {
|
|
3246
3142
|
var column = columns[field];
|
|
3247
|
-
if (!
|
|
3143
|
+
if (!_this21.isRequiredColumn(column)) continue;
|
|
3248
3144
|
var value = row[field];
|
|
3249
3145
|
var empty = isEmpty(value) || isArray(value) && !value.length || isEmptyObject(value);
|
|
3250
3146
|
if (!empty) continue;
|
|
3251
3147
|
var caption = column.cShowCaption || column.cCaption || column.cCaption || column.title || field;
|
|
3252
3148
|
errors.push({
|
|
3253
3149
|
rowIndex: index,
|
|
3254
|
-
rowId: row[
|
|
3150
|
+
rowId: row[_this21.getIdFlag()],
|
|
3255
3151
|
cellName: field,
|
|
3256
3152
|
message: "".concat(caption, "\u4E0D\u80FD\u4E3A\u7A7A")
|
|
3257
3153
|
});
|
|
3258
|
-
|
|
3154
|
+
_this21.setCellState(index, field, 'msg', '不能为空');
|
|
3259
3155
|
}
|
|
3260
3156
|
});
|
|
3261
3157
|
this._set_data('validateErrors', errors);
|
|
@@ -3332,9 +3228,9 @@
|
|
|
3332
3228
|
return data;
|
|
3333
3229
|
}
|
|
3334
3230
|
|
|
3335
|
-
/**
|
|
3336
|
-
* 收集全部属性数据
|
|
3337
|
-
* @param withOutGrid 为 true 时跳过标记了 isGrid 的子模型(子表格)
|
|
3231
|
+
/**
|
|
3232
|
+
* 收集全部属性数据
|
|
3233
|
+
* @param withOutGrid 为 true 时跳过标记了 isGrid 的子模型(子表格)
|
|
3338
3234
|
*/
|
|
3339
3235
|
}, {
|
|
3340
3236
|
key: "getAllData",
|
|
@@ -3418,7 +3314,7 @@
|
|
|
3418
3314
|
var propertyNames = this._get_data('propertyNames');
|
|
3419
3315
|
for (var i = 0, len = propertyNames.length; i < len; i++) {
|
|
3420
3316
|
gridModel = this.get(propertyNames[i]);
|
|
3421
|
-
var isGridModel = gridModel instanceof GridModel;
|
|
3317
|
+
var isGridModel = gridModel instanceof GridModel || gridModel.modelType == 'GridModel';
|
|
3422
3318
|
if (isGridModel) {
|
|
3423
3319
|
this._set_data('gridModel', gridModel);
|
|
3424
3320
|
return gridModel;
|
|
@@ -3432,7 +3328,8 @@
|
|
|
3432
3328
|
var gridModels = [];
|
|
3433
3329
|
for (var i = 0, len = propertyNames.length; i < len; i++) {
|
|
3434
3330
|
var gridModel = this.get(propertyNames[i]);
|
|
3435
|
-
|
|
3331
|
+
var isGridModel = gridModel instanceof GridModel || gridModel.modelType == 'GridModel';
|
|
3332
|
+
if (isGridModel) {
|
|
3436
3333
|
gridModels.push(gridModel);
|
|
3437
3334
|
}
|
|
3438
3335
|
}
|
|
@@ -3451,23 +3348,168 @@
|
|
|
3451
3348
|
}
|
|
3452
3349
|
return model;
|
|
3453
3350
|
}
|
|
3454
|
-
function
|
|
3455
|
-
var
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
domainKeyField = _ref$domainKeyField === void 0 ? 'domainKey' : _ref$domainKeyField,
|
|
3460
|
-
_ref$billNoField = _ref.billNoField,
|
|
3461
|
-
billNoField = _ref$billNoField === void 0 ? 'billNo' : _ref$billNoField,
|
|
3462
|
-
_ref$modelNameField = _ref.modelNameField,
|
|
3463
|
-
modelNameField = _ref$modelNameField === void 0 ? 'modelName' : _ref$modelNameField,
|
|
3464
|
-
_ref$enableExtendjs = _ref.enableExtendjs,
|
|
3465
|
-
enableExtendjs = _ref$enableExtendjs === void 0 ? true : _ref$enableExtendjs;
|
|
3466
|
-
if (params !== null && params !== void 0 && params.require) {
|
|
3467
|
-
_require = params === null || params === void 0 ? void 0 : params.require;
|
|
3351
|
+
function _initExtendJs(params) {
|
|
3352
|
+
var self = this;
|
|
3353
|
+
if (window && window.__debugger_initExtendJs) {
|
|
3354
|
+
// eslint-disable-next-line no-debugger
|
|
3355
|
+
debugger;
|
|
3468
3356
|
}
|
|
3469
|
-
var
|
|
3470
|
-
|
|
3357
|
+
var requirejs = params.requirejs,
|
|
3358
|
+
extendFilePath = params.extendFilePath,
|
|
3359
|
+
pageKey = params.pageKey,
|
|
3360
|
+
_params$enableExtendJ = params.enableExtendJs,
|
|
3361
|
+
enableExtendJs = _params$enableExtendJ === void 0 ? true : _params$enableExtendJ,
|
|
3362
|
+
_params$extendJsPath = params.extendJsPath,
|
|
3363
|
+
extendJsPath = _params$extendJsPath === void 0 ? '_VM.Extend.js' : _params$extendJsPath;
|
|
3364
|
+
if (!enableExtendJs) {
|
|
3365
|
+
self.execute('extendReady', self);
|
|
3366
|
+
return;
|
|
3367
|
+
}
|
|
3368
|
+
var extendFile = "".concat(pageKey).concat(extendJsPath);
|
|
3369
|
+
var extendFiles = [extendFile];
|
|
3370
|
+
// if (self.getEnv && self.getEnv('everyCommonExtend')) {
|
|
3371
|
+
// extendFiles.push(self.getEnv('everyCommonExtend'))
|
|
3372
|
+
// }
|
|
3373
|
+
if (typeof requirejs.require !== 'function') {
|
|
3374
|
+
console.warn("requirejs.js \u672A\u52A0\u8F7D\uFF0C\u8DF3\u8FC7\u6269\u5C55\u811A\u672C\uFF1A".concat(extendFile));
|
|
3375
|
+
self.execute('extendReady', self);
|
|
3376
|
+
return;
|
|
3377
|
+
}
|
|
3378
|
+
requirejs.require(extendFilePath, extendFiles, function (extend, everyCommonExtend) {
|
|
3379
|
+
if (extend && extend.doAction) {
|
|
3380
|
+
// 处理扩展脚本异常导致渲染失败
|
|
3381
|
+
try {
|
|
3382
|
+
extend.doAction('init', self);
|
|
3383
|
+
if (everyCommonExtend) {
|
|
3384
|
+
everyCommonExtend.doAction('init', self);
|
|
3385
|
+
}
|
|
3386
|
+
} catch (err) {
|
|
3387
|
+
console.error('扩展脚本异常:', err);
|
|
3388
|
+
}
|
|
3389
|
+
} else {
|
|
3390
|
+
console.error("".concat(extendFile, "\u6269\u5C55\u6587\u4EF6extend.*.min.js\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25 \u6216 \u672A\u6CE8\u518C\u6269\u5C55\u811A\u672C"));
|
|
3391
|
+
}
|
|
3392
|
+
self.execute('extendReady', self);
|
|
3393
|
+
}, function (err) {
|
|
3394
|
+
console.warn("\u672A\u627E\u5230\u6269\u5C55\u811A\u672C\uFF1A".concat(extendFile, "\u9519\u8BEF\u4FE1\u606F\uFF1A"), err);
|
|
3395
|
+
self.execute('extendReady', self);
|
|
3396
|
+
});
|
|
3397
|
+
}
|
|
3398
|
+
var _extscripturls = /*#__PURE__*/function () {
|
|
3399
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(result, vm, params) {
|
|
3400
|
+
var _vm$getParams, _exturls;
|
|
3401
|
+
var _result$extscripturls, exturls;
|
|
3402
|
+
return _regenerator().w(function (_context2) {
|
|
3403
|
+
while (1) switch (_context2.n) {
|
|
3404
|
+
case 0:
|
|
3405
|
+
_result$extscripturls = result.extscripturls, exturls = _result$extscripturls === void 0 ? [] : _result$extscripturls; // 支持注入单据级本地化扩展脚本
|
|
3406
|
+
exturls = (vm.getCache('localDynamicScripts') || []).concat(exturls);
|
|
3407
|
+
|
|
3408
|
+
// 支持给全单据注入扩展脚本
|
|
3409
|
+
exturls = exturls.concat(window.__devfab__EXT_BILL_SCRIPTS__ || []);
|
|
3410
|
+
|
|
3411
|
+
// 支持参数注入扩展脚本
|
|
3412
|
+
if ((_vm$getParams = vm.getParams()) !== null && _vm$getParams !== void 0 && _vm$getParams.initVMExtUrls) {
|
|
3413
|
+
exturls = exturls.concat([vm.getParams().initVMExtUrls]);
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
// 预处理扩展脚本
|
|
3417
|
+
if (!((_exturls = exturls) !== null && _exturls !== void 0 && _exturls.length)) {
|
|
3418
|
+
_context2.n = 2;
|
|
3419
|
+
break;
|
|
3420
|
+
}
|
|
3421
|
+
exturls = _toConsumableArray(new Set(exturls));
|
|
3422
|
+
_context2.n = 1;
|
|
3423
|
+
return Promise.all(exturls.map(/*#__PURE__*/function () {
|
|
3424
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url) {
|
|
3425
|
+
return _regenerator().w(function (_context) {
|
|
3426
|
+
while (1) switch (_context.n) {
|
|
3427
|
+
case 0:
|
|
3428
|
+
return _context.a(2, url);
|
|
3429
|
+
}
|
|
3430
|
+
}, _callee);
|
|
3431
|
+
}));
|
|
3432
|
+
return function (_x4) {
|
|
3433
|
+
return _ref2.apply(this, arguments);
|
|
3434
|
+
};
|
|
3435
|
+
}()));
|
|
3436
|
+
case 1:
|
|
3437
|
+
exturls = _context2.v;
|
|
3438
|
+
case 2:
|
|
3439
|
+
// 加载扩展脚本
|
|
3440
|
+
result.extscripturls = exturls;
|
|
3441
|
+
return _context2.a(2, new Promise(function (resolve, reject) {
|
|
3442
|
+
_requireExtscripturls(result, vm, params, function () {
|
|
3443
|
+
resolve(true);
|
|
3444
|
+
});
|
|
3445
|
+
}));
|
|
3446
|
+
}
|
|
3447
|
+
}, _callee2);
|
|
3448
|
+
}));
|
|
3449
|
+
return function _extscripturls(_x, _x2, _x3) {
|
|
3450
|
+
return _ref.apply(this, arguments);
|
|
3451
|
+
};
|
|
3452
|
+
}();
|
|
3453
|
+
function _requireExtscripturls(result, vm, params, callback) {
|
|
3454
|
+
// 二开、客开的扩展脚本
|
|
3455
|
+
var _result$extscripturls2 = result.extscripturls,
|
|
3456
|
+
exturls = _result$extscripturls2 === void 0 ? [] : _result$extscripturls2;
|
|
3457
|
+
if (exturls !== null && exturls !== void 0 && exturls.length) {
|
|
3458
|
+
try {
|
|
3459
|
+
var _params$requirejs;
|
|
3460
|
+
var requireInner = params === null || params === void 0 || (_params$requirejs = params.requirejs) === null || _params$requirejs === void 0 ? void 0 : _params$requirejs.requireInner;
|
|
3461
|
+
if (typeof requireInner !== 'function') {
|
|
3462
|
+
console.warn("requirejs.js \u672A\u52A0\u8F7D\uFF0C\u8DF3\u8FC7\u5BA2\u5F00\u6269\u5C55\u811A\u672C");
|
|
3463
|
+
callback === null || callback === void 0 || callback(result, vm);
|
|
3464
|
+
return;
|
|
3465
|
+
}
|
|
3466
|
+
requireInner(exturls,
|
|
3467
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
3468
|
+
function () {
|
|
3469
|
+
// cb.console.info('[exturls]: %c [extscript js] cb.requireInner success and doAction[init]', 'color:green')
|
|
3470
|
+
var correct = true;
|
|
3471
|
+
if (arguments.length) {
|
|
3472
|
+
for (var i = 0, len = arguments.length; i < len; i++) {
|
|
3473
|
+
var external = i < 0 || arguments.length <= i ? undefined : arguments[i];
|
|
3474
|
+
if (external) {
|
|
3475
|
+
external.doAction('init', vm);
|
|
3476
|
+
} else {
|
|
3477
|
+
correct = false;
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
if (correct) {
|
|
3481
|
+
callback === null || callback === void 0 || callback(result, vm);
|
|
3482
|
+
}
|
|
3483
|
+
} else {
|
|
3484
|
+
correct = false;
|
|
3485
|
+
}
|
|
3486
|
+
if (!correct) {
|
|
3487
|
+
console.log('[error] [extendjs] 租户级扩展脚本有语法错误,请修改正确后刷新浏览器重试!');
|
|
3488
|
+
}
|
|
3489
|
+
},
|
|
3490
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
3491
|
+
function (_error) {
|
|
3492
|
+
// cb.console.info('[exturls]: %c [extscript js] cb.requireInner, but notFound', 'font-size:12pt;color:#860786')
|
|
3493
|
+
callback === null || callback === void 0 || callback(result, vm);
|
|
3494
|
+
});
|
|
3495
|
+
} catch (e) {
|
|
3496
|
+
// cb.console.log('[exturls]: %c [extscript js] cb.requireInner exception', 'font-size:12pt;color:#860786', e)
|
|
3497
|
+
callback === null || callback === void 0 || callback(result, vm);
|
|
3498
|
+
}
|
|
3499
|
+
} else {
|
|
3500
|
+
callback === null || callback === void 0 || callback(result, vm);
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
function _createViewModel(meta) {
|
|
3504
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3505
|
+
var _params$extendFilePat = params.extendFilePathField,
|
|
3506
|
+
extendFilePathField = _params$extendFilePat === void 0 ? 'domainKey' : _params$extendFilePat,
|
|
3507
|
+
_params$pageKeyField = params.pageKeyField,
|
|
3508
|
+
pageKeyField = _params$pageKeyField === void 0 ? 'billNo' : _params$pageKeyField,
|
|
3509
|
+
_params$modelNameFiel = params.modelNameField,
|
|
3510
|
+
modelNameField = _params$modelNameFiel === void 0 ? 'cName' : _params$modelNameFiel;
|
|
3511
|
+
var extendFilePath = meta[extendFilePathField] || '';
|
|
3512
|
+
var pageKey = meta[pageKeyField] || '';
|
|
3471
3513
|
var VM = /*#__PURE__*/function (_ViewModel) {
|
|
3472
3514
|
function VM() {
|
|
3473
3515
|
_classCallCheck(this, VM);
|
|
@@ -3505,68 +3547,60 @@
|
|
|
3505
3547
|
}, {
|
|
3506
3548
|
key: "initData",
|
|
3507
3549
|
value: function initData() {
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
value: function initExtendJs() {
|
|
3513
|
-
if (window && window.__debugger_initExtendJs) {
|
|
3514
|
-
// eslint-disable-next-line no-debugger
|
|
3515
|
-
debugger;
|
|
3516
|
-
}
|
|
3517
|
-
var self = this;
|
|
3518
|
-
if (!enableExtendjs) {
|
|
3519
|
-
self.execute('extendReady', self);
|
|
3520
|
-
return;
|
|
3521
|
-
}
|
|
3522
|
-
var extendFile = "".concat(billno, "_VM.Extend.js");
|
|
3523
|
-
var extendFiles = [extendFile];
|
|
3524
|
-
// if (self.getEnv && self.getEnv('everyCommonExtend')) {
|
|
3525
|
-
// extendFiles.push(self.getEnv('everyCommonExtend'))
|
|
3526
|
-
// }
|
|
3527
|
-
if (typeof _require !== 'function') {
|
|
3528
|
-
console.warn("requirejs.js \u672A\u52A0\u8F7D\uFF0C\u8DF3\u8FC7\u6269\u5C55\u811A\u672C\uFF1A".concat(extendFile));
|
|
3529
|
-
self.execute('extendReady', self);
|
|
3530
|
-
return;
|
|
3531
|
-
}
|
|
3532
|
-
_require(domainKey, extendFiles, function (extend, everyCommonExtend) {
|
|
3533
|
-
if (extend && extend.doAction) {
|
|
3534
|
-
// 处理扩展脚本异常导致渲染失败
|
|
3535
|
-
try {
|
|
3536
|
-
extend.doAction('init', self);
|
|
3537
|
-
if (everyCommonExtend) {
|
|
3538
|
-
everyCommonExtend.doAction('init', self);
|
|
3539
|
-
}
|
|
3540
|
-
} catch (err) {
|
|
3541
|
-
console.error('扩展脚本异常:', err);
|
|
3542
|
-
}
|
|
3543
|
-
} else {
|
|
3544
|
-
console.error("".concat(extendFile, "\u6269\u5C55\u6587\u4EF6extend.*.min.js\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25 \u6216 \u672A\u6CE8\u518C\u6269\u5C55\u811A\u672C"));
|
|
3545
|
-
}
|
|
3546
|
-
self.execute('extendReady', self);
|
|
3547
|
-
}, function (err) {
|
|
3548
|
-
console.warn("\u672A\u627E\u5230\u6269\u5C55\u811A\u672C\uFF1A".concat(extendFile, "\u9519\u8BEF\u4FE1\u606F\uFF1A"), err);
|
|
3549
|
-
self.execute('extendReady', self);
|
|
3550
|
-
});
|
|
3550
|
+
_initExtendJs.call(this, _objectSpread2(_objectSpread2({}, params), {}, {
|
|
3551
|
+
extendFilePath: extendFilePath,
|
|
3552
|
+
pageKey: pageKey
|
|
3553
|
+
}));
|
|
3551
3554
|
}
|
|
3552
3555
|
}]);
|
|
3553
3556
|
}(ViewModel);
|
|
3554
3557
|
VM.prototype.modelType = 'ViewModel';
|
|
3555
3558
|
return VM;
|
|
3556
3559
|
}
|
|
3557
|
-
function
|
|
3558
|
-
var
|
|
3559
|
-
var vm = new
|
|
3560
|
+
function _initViewModel(meta, params) {
|
|
3561
|
+
var VM = _createViewModel(meta, params);
|
|
3562
|
+
var vm = new VM();
|
|
3560
3563
|
vm.init(meta.models, meta);
|
|
3561
3564
|
return vm;
|
|
3562
3565
|
}
|
|
3566
|
+
function initViewModel(meta) {
|
|
3567
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3568
|
+
var callback = arguments.length > 2 ? arguments[2] : undefined;
|
|
3569
|
+
if (!(params !== null && params !== void 0 && params.requirejs)) {
|
|
3570
|
+
params.requirejs = window.__devfab;
|
|
3571
|
+
}
|
|
3572
|
+
var vm = _initViewModel(meta, params);
|
|
3573
|
+
vm.on('destroyVM', function () {
|
|
3574
|
+
var _vm, _vm$destroyVM;
|
|
3575
|
+
(_vm = vm) === null || _vm === void 0 || (_vm$destroyVM = _vm.destroyVM) === null || _vm$destroyVM === void 0 || _vm$destroyVM.call(_vm);
|
|
3576
|
+
vm = null;
|
|
3577
|
+
});
|
|
3578
|
+
vm.on('extendReady', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
3579
|
+
var promises;
|
|
3580
|
+
return _regenerator().w(function (_context3) {
|
|
3581
|
+
while (1) switch (_context3.n) {
|
|
3582
|
+
case 0:
|
|
3583
|
+
promises = []; // 加载二开脚本
|
|
3584
|
+
promises.push(_extscripturls(meta, vm, params));
|
|
3585
|
+
_context3.n = 1;
|
|
3586
|
+
return Promise.all(promises);
|
|
3587
|
+
case 1:
|
|
3588
|
+
// console.info(`[initVM]: after vm init ${ moment().format('YYYY-MM-DD HH:mm:ss.SSS')}`)
|
|
3589
|
+
callback === null || callback === void 0 || callback(vm, meta);
|
|
3590
|
+
case 2:
|
|
3591
|
+
return _context3.a(2);
|
|
3592
|
+
}
|
|
3593
|
+
}, _callee3);
|
|
3594
|
+
})));
|
|
3595
|
+
vm.initData();
|
|
3596
|
+
return vm;
|
|
3597
|
+
}
|
|
3563
3598
|
var models = {
|
|
3564
3599
|
BaseModel: BaseModel,
|
|
3565
3600
|
FilterModel: FilterModel,
|
|
3566
3601
|
SimpleModel: SimpleModel,
|
|
3567
3602
|
GridModel: GridModel,
|
|
3568
3603
|
ViewModel: ViewModel,
|
|
3569
|
-
createViewModel: createViewModel,
|
|
3570
3604
|
initViewModel: initViewModel
|
|
3571
3605
|
};
|
|
3572
3606
|
|