@nokecy/qc-ui 1.1.78 → 1.1.80
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/dist/cjs/ag-grid-plus/ag-gridPlus.js +2 -12
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +13 -2
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +26 -15
- package/dist/cjs/attachment/AttachmentFileButton.d.ts +4 -0
- package/dist/cjs/attachment/AttachmentFileButton.js +86 -0
- package/dist/cjs/attachment/AttachmentImageUpload.d.ts +16 -0
- package/dist/cjs/attachment/AttachmentImageUpload.js +206 -0
- package/dist/cjs/attachment/AttachmentPanel.d.ts +8 -0
- package/dist/cjs/attachment/AttachmentPanel.js +63 -0
- package/dist/cjs/attachment/AttachmentVideoUpload.d.ts +13 -0
- package/dist/cjs/attachment/AttachmentVideoUpload.js +88 -0
- package/dist/cjs/attachment/ChunkedDragger.d.ts +14 -0
- package/dist/cjs/attachment/ChunkedDragger.js +160 -0
- package/dist/cjs/attachment/attachmentList.d.ts +91 -0
- package/dist/cjs/attachment/attachmentList.js +214 -0
- package/dist/cjs/attachment/chunkUpload.d.ts +26 -0
- package/dist/cjs/attachment/chunkUpload.js +276 -0
- package/dist/cjs/attachment/env.d.ts +41 -0
- package/dist/cjs/attachment/env.js +41 -0
- package/dist/cjs/attachment/index.d.ts +20 -0
- package/dist/cjs/attachment/index.js +92 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +12 -0
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +3 -13
- package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +13 -2
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +25 -15
- package/dist/esm/attachment/AttachmentFileButton.d.ts +4 -0
- package/dist/esm/attachment/AttachmentFileButton.js +77 -0
- package/dist/esm/attachment/AttachmentImageUpload.d.ts +16 -0
- package/dist/esm/attachment/AttachmentImageUpload.js +199 -0
- package/dist/esm/attachment/AttachmentPanel.d.ts +8 -0
- package/dist/esm/attachment/AttachmentPanel.js +52 -0
- package/dist/esm/attachment/AttachmentVideoUpload.d.ts +13 -0
- package/dist/esm/attachment/AttachmentVideoUpload.js +82 -0
- package/dist/esm/attachment/ChunkedDragger.d.ts +14 -0
- package/dist/esm/attachment/ChunkedDragger.js +153 -0
- package/dist/esm/attachment/attachmentList.d.ts +91 -0
- package/dist/esm/attachment/attachmentList.js +207 -0
- package/dist/esm/attachment/chunkUpload.d.ts +26 -0
- package/dist/esm/attachment/chunkUpload.js +272 -0
- package/dist/esm/attachment/env.d.ts +41 -0
- package/dist/esm/attachment/env.js +35 -0
- package/dist/esm/attachment/index.d.ts +20 -0
- package/dist/esm/attachment/index.js +14 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.splitFile = exports.createVideoProtocol = exports.createFileProtocol = exports.CHUNK_SIZE = void 0;
|
|
8
|
+
var _env = require("./env");
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /**
|
|
12
|
+
* 附件上传协议:普通文件(带断点续传与合并校验)与视频(分块后确认)。
|
|
13
|
+
* 两套协议的端点、参数大小写、进度算法与收尾都不同,各自照原样实现,不合并成带开关的一套。
|
|
14
|
+
*
|
|
15
|
+
* @author nokecy
|
|
16
|
+
*/
|
|
17
|
+
/** 分块大小,同时也是切块上传的阈值。 */
|
|
18
|
+
var CHUNK_SIZE = exports.CHUNK_SIZE = 5 * 1024 * 1024;
|
|
19
|
+
/** 把文件切成 `chunks` 块。 */
|
|
20
|
+
var splitFile = exports.splitFile = function splitFile(file, eachSize, chunks) {
|
|
21
|
+
return new Promise(function (resolve, reject) {
|
|
22
|
+
try {
|
|
23
|
+
setTimeout(function () {
|
|
24
|
+
var fileChunk = [];
|
|
25
|
+
for (var chunk = 0; chunks > 0; chunks--) {
|
|
26
|
+
fileChunk.push(file.slice(chunk, chunk + eachSize));
|
|
27
|
+
chunk += eachSize;
|
|
28
|
+
}
|
|
29
|
+
resolve(fileChunk);
|
|
30
|
+
}, 0);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error(e);
|
|
33
|
+
reject(new Error('文件切块发生错误'));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var toFormData = function toFormData(param) {
|
|
38
|
+
var formData = new FormData();
|
|
39
|
+
for (var p in param) formData.append(p, param[p]);
|
|
40
|
+
return formData;
|
|
41
|
+
};
|
|
42
|
+
var headersOf = function headersOf(env) {
|
|
43
|
+
var _env$getHeaders, _env$getHeaders2;
|
|
44
|
+
return (_env$getHeaders = (_env$getHeaders2 = env.getHeaders) === null || _env$getHeaders2 === void 0 ? void 0 : _env$getHeaders2.call(env)) !== null && _env$getHeaders !== void 0 ? _env$getHeaders : {};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** 普通文件协议。 */
|
|
48
|
+
var createFileProtocol = exports.createFileProtocol = function createFileProtocol(env) {
|
|
49
|
+
var endpoints = (0, _env.resolveEndpoints)(env);
|
|
50
|
+
var postFile = function postFile(param, onProgress) {
|
|
51
|
+
return env.post("".concat(env.serverUrl()).concat(endpoints.upload), toFormData(param), {
|
|
52
|
+
headers: headersOf(env),
|
|
53
|
+
onUploadProgress: function onUploadProgress(e) {
|
|
54
|
+
if (param.chunked) {
|
|
55
|
+
e.percent = Number(((param.chunk * (param.eachSize - 1) + e.loaded) / param.fullSize * 100).toFixed(2));
|
|
56
|
+
} else {
|
|
57
|
+
e.percent = Number((e.loaded / e.total * 100).toFixed(2));
|
|
58
|
+
}
|
|
59
|
+
onProgress(e);
|
|
60
|
+
}
|
|
61
|
+
}).then(function (rs) {
|
|
62
|
+
return {
|
|
63
|
+
nextchunk: rs.data.nextchunk,
|
|
64
|
+
filename: rs.data.filename
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
var validateFile = function validateFile(body) {
|
|
69
|
+
return env.post("".concat(env.serverUrl()).concat(endpoints.validate), body, {
|
|
70
|
+
headers: headersOf(env)
|
|
71
|
+
}).then(function (rs) {
|
|
72
|
+
return rs.data;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** 单文件上传,返回 `{ nextchunk, filename }`。 */
|
|
77
|
+
var uploadSingle = function uploadSingle(file, onProgress) {
|
|
78
|
+
return postFile({
|
|
79
|
+
file: file,
|
|
80
|
+
uid: file.uid,
|
|
81
|
+
fileName: file.fileName
|
|
82
|
+
}, onProgress);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** 分块上传:服务端返回的 `nextchunk` 决定下一块(断点续传),最后合并校验,校验不通过则抛错。 */
|
|
86
|
+
var uploadChunked = /*#__PURE__*/function () {
|
|
87
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file, onProgress) {
|
|
88
|
+
var chunks, fileChunks, currentChunk, i, _yield$postFile, nextchunk, data;
|
|
89
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
90
|
+
while (1) switch (_context.prev = _context.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
chunks = Math.ceil(file.size / CHUNK_SIZE);
|
|
93
|
+
_context.next = 3;
|
|
94
|
+
return splitFile(file, CHUNK_SIZE, chunks);
|
|
95
|
+
case 3:
|
|
96
|
+
fileChunks = _context.sent;
|
|
97
|
+
currentChunk = 0;
|
|
98
|
+
i = 0;
|
|
99
|
+
case 6:
|
|
100
|
+
if (!(i < fileChunks.length)) {
|
|
101
|
+
_context.next = 16;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (!(Number(currentChunk) === i)) {
|
|
105
|
+
_context.next = 13;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
_context.next = 10;
|
|
109
|
+
return postFile({
|
|
110
|
+
chunked: true,
|
|
111
|
+
chunk: i,
|
|
112
|
+
chunks: chunks,
|
|
113
|
+
eachSize: CHUNK_SIZE,
|
|
114
|
+
fileName: file.name,
|
|
115
|
+
fullSize: file.size,
|
|
116
|
+
uid: file.uid,
|
|
117
|
+
file: fileChunks[i]
|
|
118
|
+
}, onProgress);
|
|
119
|
+
case 10:
|
|
120
|
+
_yield$postFile = _context.sent;
|
|
121
|
+
nextchunk = _yield$postFile.nextchunk;
|
|
122
|
+
currentChunk = nextchunk;
|
|
123
|
+
case 13:
|
|
124
|
+
i++;
|
|
125
|
+
_context.next = 6;
|
|
126
|
+
break;
|
|
127
|
+
case 16:
|
|
128
|
+
_context.next = 18;
|
|
129
|
+
return validateFile({
|
|
130
|
+
chunks: fileChunks.length,
|
|
131
|
+
fileName: file.name,
|
|
132
|
+
fullSize: file.size,
|
|
133
|
+
uid: file.uid
|
|
134
|
+
});
|
|
135
|
+
case 18:
|
|
136
|
+
data = _context.sent;
|
|
137
|
+
if (data.isValid) {
|
|
138
|
+
_context.next = 21;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
throw new Error('文件校验异常');
|
|
142
|
+
case 21:
|
|
143
|
+
return _context.abrupt("return", data);
|
|
144
|
+
case 22:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context.stop();
|
|
147
|
+
}
|
|
148
|
+
}, _callee);
|
|
149
|
+
}));
|
|
150
|
+
return function uploadChunked(_x, _x2) {
|
|
151
|
+
return _ref.apply(this, arguments);
|
|
152
|
+
};
|
|
153
|
+
}();
|
|
154
|
+
return {
|
|
155
|
+
uploadSingle: uploadSingle,
|
|
156
|
+
uploadChunked: uploadChunked
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/** 视频协议。 */
|
|
161
|
+
var createVideoProtocol = exports.createVideoProtocol = function createVideoProtocol(env) {
|
|
162
|
+
var endpoints = (0, _env.resolveEndpoints)(env);
|
|
163
|
+
var postFile = function postFile(param, onProgress) {
|
|
164
|
+
return env.post("".concat(env.serverUrl()).concat(endpoints.uploadVideoChunk), toFormData(param), {
|
|
165
|
+
headers: headersOf(env),
|
|
166
|
+
// 视频接口的参数是大写开头,下面的 `chunked` 恒为 undefined,进度始终按单次请求计算——沿用原行为。
|
|
167
|
+
onUploadProgress: function onUploadProgress(e) {
|
|
168
|
+
if (param.chunked) {
|
|
169
|
+
e.percent = Number(((param.chunk * (param.eachSize - 1) + e.loaded) / param.fullSize * 100).toFixed(2));
|
|
170
|
+
} else {
|
|
171
|
+
e.percent = Number((e.loaded / e.total * 100).toFixed(2));
|
|
172
|
+
}
|
|
173
|
+
onProgress(e);
|
|
174
|
+
}
|
|
175
|
+
}).then(function (rs) {
|
|
176
|
+
return {
|
|
177
|
+
nextchunk: rs.data.nextchunk,
|
|
178
|
+
filename: rs.data.filename
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
var confirm = function confirm(body) {
|
|
183
|
+
return env.post("".concat(env.serverUrl()).concat(endpoints.confirmVideo), body, {
|
|
184
|
+
headers: headersOf(env)
|
|
185
|
+
}).then(function (rs) {
|
|
186
|
+
return rs.data;
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/** 单文件上传后确认;确认失败时返回 undefined 而不抛错——沿用原行为。 */
|
|
191
|
+
var uploadSingle = function uploadSingle(file, onProgress) {
|
|
192
|
+
return postFile({
|
|
193
|
+
File: file,
|
|
194
|
+
Uid: file.uid,
|
|
195
|
+
FileName: file.fileName
|
|
196
|
+
}, onProgress).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
197
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
198
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
199
|
+
case 0:
|
|
200
|
+
_context2.prev = 0;
|
|
201
|
+
_context2.next = 3;
|
|
202
|
+
return confirm({
|
|
203
|
+
Chunks: 1,
|
|
204
|
+
FileName: file.name,
|
|
205
|
+
FullSize: file.size,
|
|
206
|
+
Uid: file.uid
|
|
207
|
+
});
|
|
208
|
+
case 3:
|
|
209
|
+
return _context2.abrupt("return", _context2.sent);
|
|
210
|
+
case 6:
|
|
211
|
+
_context2.prev = 6;
|
|
212
|
+
_context2.t0 = _context2["catch"](0);
|
|
213
|
+
return _context2.abrupt("return", undefined);
|
|
214
|
+
case 9:
|
|
215
|
+
case "end":
|
|
216
|
+
return _context2.stop();
|
|
217
|
+
}
|
|
218
|
+
}, _callee2, null, [[0, 6]]);
|
|
219
|
+
})));
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/** 分块上传:每一块都按顺序上传(不按 nextchunk 跳块、不检查 isValid),最后确认。 */
|
|
223
|
+
var uploadChunked = /*#__PURE__*/function () {
|
|
224
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(file, onProgress) {
|
|
225
|
+
var Chunks, fileChunks, i;
|
|
226
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
227
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
228
|
+
case 0:
|
|
229
|
+
Chunks = Math.ceil(file.size / CHUNK_SIZE);
|
|
230
|
+
_context3.next = 3;
|
|
231
|
+
return splitFile(file, CHUNK_SIZE, Chunks);
|
|
232
|
+
case 3:
|
|
233
|
+
fileChunks = _context3.sent;
|
|
234
|
+
i = 0;
|
|
235
|
+
case 5:
|
|
236
|
+
if (!(i < fileChunks.length)) {
|
|
237
|
+
_context3.next = 11;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
_context3.next = 8;
|
|
241
|
+
return postFile({
|
|
242
|
+
Chunked: true,
|
|
243
|
+
Chunk: i,
|
|
244
|
+
Chunks: Chunks,
|
|
245
|
+
EachSize: CHUNK_SIZE,
|
|
246
|
+
FileName: file.name,
|
|
247
|
+
FullSize: file.size,
|
|
248
|
+
Uid: file.uid,
|
|
249
|
+
File: fileChunks[i]
|
|
250
|
+
}, onProgress);
|
|
251
|
+
case 8:
|
|
252
|
+
i++;
|
|
253
|
+
_context3.next = 5;
|
|
254
|
+
break;
|
|
255
|
+
case 11:
|
|
256
|
+
return _context3.abrupt("return", confirm({
|
|
257
|
+
Chunks: fileChunks.length,
|
|
258
|
+
FileName: file.name,
|
|
259
|
+
FullSize: file.size,
|
|
260
|
+
Uid: file.uid
|
|
261
|
+
}));
|
|
262
|
+
case 12:
|
|
263
|
+
case "end":
|
|
264
|
+
return _context3.stop();
|
|
265
|
+
}
|
|
266
|
+
}, _callee3);
|
|
267
|
+
}));
|
|
268
|
+
return function uploadChunked(_x3, _x4) {
|
|
269
|
+
return _ref3.apply(this, arguments);
|
|
270
|
+
};
|
|
271
|
+
}();
|
|
272
|
+
return {
|
|
273
|
+
uploadSingle: uploadSingle,
|
|
274
|
+
uploadChunked: uploadChunked
|
|
275
|
+
};
|
|
276
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 附件上传的宿主环境:后端地址、传输层与接口路径。
|
|
3
|
+
* qc-ui 不依赖具体的 HTTP 库,宿主把自己的 POST 实现与地址前缀注入进来。
|
|
4
|
+
*
|
|
5
|
+
* @author nokecy
|
|
6
|
+
*/
|
|
7
|
+
/** 附件服务的接口路径(相对于 `serverUrl()`)。`validate` 沿用后端的拼写 `valiate`。 */
|
|
8
|
+
export interface AttachmentEndpoints {
|
|
9
|
+
/** 普通文件上传(单文件与分块共用) */
|
|
10
|
+
upload: string;
|
|
11
|
+
/** 普通文件分块合并后的校验 */
|
|
12
|
+
validate: string;
|
|
13
|
+
/** 视频分块上传 */
|
|
14
|
+
uploadVideoChunk: string;
|
|
15
|
+
/** 视频上传完成后的确认 */
|
|
16
|
+
confirmVideo: string;
|
|
17
|
+
/** 按 blobName 下载,blobName 直接拼在末尾 */
|
|
18
|
+
downloadByBlobName: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const defaultAttachmentEndpoints: AttachmentEndpoints;
|
|
21
|
+
/** `post` 的第三个参数,约定与 axios 一致。 */
|
|
22
|
+
export interface AttachmentPostConfig {
|
|
23
|
+
headers?: Record<string, string | undefined>;
|
|
24
|
+
onUploadProgress?: (event: any) => void;
|
|
25
|
+
}
|
|
26
|
+
/** 宿主注入的环境。 */
|
|
27
|
+
export interface AttachmentEnv {
|
|
28
|
+
/** 后端地址前缀,如 `() => window.serverUrl.apiServerUrl`;与路径直接拼接,不加斜杠 */
|
|
29
|
+
serverUrl: () => string;
|
|
30
|
+
/** 发 POST 请求(multipart 或 JSON),约定与 `axios.post` 一致,返回含 `data` 的响应 */
|
|
31
|
+
post: (url: string, data: any, config?: AttachmentPostConfig) => Promise<{
|
|
32
|
+
data: any;
|
|
33
|
+
}>;
|
|
34
|
+
/** 每次请求附带的请求头(例如防伪令牌),请求时才读取 */
|
|
35
|
+
getHeaders?: () => Record<string, string | undefined>;
|
|
36
|
+
/** 覆盖默认的接口路径 */
|
|
37
|
+
endpoints?: Partial<AttachmentEndpoints>;
|
|
38
|
+
}
|
|
39
|
+
export declare const resolveEndpoints: (env: AttachmentEnv) => AttachmentEndpoints;
|
|
40
|
+
/** 按 blobName 拼出下载地址。 */
|
|
41
|
+
export declare const getBlobDownloadUrl: (env: AttachmentEnv, blobName: string) => string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveEndpoints = exports.getBlobDownloadUrl = exports.defaultAttachmentEndpoints = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
/**
|
|
14
|
+
* 附件上传的宿主环境:后端地址、传输层与接口路径。
|
|
15
|
+
* qc-ui 不依赖具体的 HTTP 库,宿主把自己的 POST 实现与地址前缀注入进来。
|
|
16
|
+
*
|
|
17
|
+
* @author nokecy
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** 附件服务的接口路径(相对于 `serverUrl()`)。`validate` 沿用后端的拼写 `valiate`。 */
|
|
21
|
+
|
|
22
|
+
var defaultAttachmentEndpoints = exports.defaultAttachmentEndpoints = {
|
|
23
|
+
upload: '/api/attachmentManage/temp-blob/upload',
|
|
24
|
+
validate: '/api/attachmentManage/temp-blob/valiate',
|
|
25
|
+
uploadVideoChunk: '/api/attachmentManage/temp-blob/upload-video-chunk',
|
|
26
|
+
confirmVideo: '/api/attachmentManage/temp-blob/confirm-video',
|
|
27
|
+
downloadByBlobName: '/api/attachmentManage/blob/by-blob-name/'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** `post` 的第三个参数,约定与 axios 一致。 */
|
|
31
|
+
|
|
32
|
+
/** 宿主注入的环境。 */
|
|
33
|
+
|
|
34
|
+
var resolveEndpoints = exports.resolveEndpoints = function resolveEndpoints(env) {
|
|
35
|
+
return _objectSpread(_objectSpread({}, defaultAttachmentEndpoints), env.endpoints);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** 按 blobName 拼出下载地址。 */
|
|
39
|
+
var getBlobDownloadUrl = exports.getBlobDownloadUrl = function getBlobDownloadUrl(env, blobName) {
|
|
40
|
+
return "".concat(env.serverUrl()).concat(resolveEndpoints(env).downloadByBlobName).concat(blobName);
|
|
41
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 附件上传:拖拽上传(普通文件断点续传 / 视频分块)、附件列表、图片墙。
|
|
3
|
+
* 传输层与接口路径由宿主通过 `env` 注入。
|
|
4
|
+
*
|
|
5
|
+
* @author nokecy
|
|
6
|
+
*/
|
|
7
|
+
export { default as AttachmentPanel } from './AttachmentPanel';
|
|
8
|
+
export type { AttachmentPanelProps } from './AttachmentPanel';
|
|
9
|
+
export { default as AttachmentFileButton } from './AttachmentFileButton';
|
|
10
|
+
export { default as AttachmentImageUpload } from './AttachmentImageUpload';
|
|
11
|
+
export type { AttachmentImageUploadProps } from './AttachmentImageUpload';
|
|
12
|
+
export { default as AttachmentVideoUpload } from './AttachmentVideoUpload';
|
|
13
|
+
export type { AttachmentVideoUploadProps } from './AttachmentVideoUpload';
|
|
14
|
+
export { default as ChunkedDragger } from './ChunkedDragger';
|
|
15
|
+
export type { ChunkedDraggerProps } from './ChunkedDragger';
|
|
16
|
+
export { formatAttachmentDate } from './attachmentList';
|
|
17
|
+
export type { AttachmentListProps } from './attachmentList';
|
|
18
|
+
export { defaultAttachmentEndpoints, getBlobDownloadUrl, resolveEndpoints } from './env';
|
|
19
|
+
export type { AttachmentEndpoints, AttachmentEnv, AttachmentPostConfig } from './env';
|
|
20
|
+
export { CHUNK_SIZE, createFileProtocol, createVideoProtocol, splitFile } from './chunkUpload';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AttachmentFileButton", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _AttachmentFileButton.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "AttachmentImageUpload", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _AttachmentImageUpload.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "AttachmentPanel", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _AttachmentPanel.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "AttachmentVideoUpload", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _AttachmentVideoUpload.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "CHUNK_SIZE", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _chunkUpload.CHUNK_SIZE;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "ChunkedDragger", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _ChunkedDragger.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "createFileProtocol", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _chunkUpload.createFileProtocol;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "createVideoProtocol", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _chunkUpload.createVideoProtocol;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "defaultAttachmentEndpoints", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _env.defaultAttachmentEndpoints;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "formatAttachmentDate", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _attachmentList.formatAttachmentDate;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "getBlobDownloadUrl", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _env.getBlobDownloadUrl;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "resolveEndpoints", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _env.resolveEndpoints;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "splitFile", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _chunkUpload.splitFile;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var _AttachmentPanel = _interopRequireDefault(require("./AttachmentPanel"));
|
|
85
|
+
var _AttachmentFileButton = _interopRequireDefault(require("./AttachmentFileButton"));
|
|
86
|
+
var _AttachmentImageUpload = _interopRequireDefault(require("./AttachmentImageUpload"));
|
|
87
|
+
var _AttachmentVideoUpload = _interopRequireDefault(require("./AttachmentVideoUpload"));
|
|
88
|
+
var _ChunkedDragger = _interopRequireDefault(require("./ChunkedDragger"));
|
|
89
|
+
var _attachmentList = require("./attachmentList");
|
|
90
|
+
var _env = require("./env");
|
|
91
|
+
var _chunkUpload = require("./chunkUpload");
|
|
92
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export type { CentralizedColumnScheme, QueryScheme, SchemeStorageAdapter, Scheme
|
|
|
33
33
|
export * from './adapters';
|
|
34
34
|
export * from "./readPretty";
|
|
35
35
|
export * from "./standardList";
|
|
36
|
+
export * from "./attachment";
|
|
36
37
|
export { createEntitySelect } from "./entitySelect";
|
|
37
38
|
export { default as ExportButton, buildExportUrl, DEFAULT_EXPORT_TEMPLATE_API, resolveExportAction, resolveExportError, resolveFileName } from "./exportButton";
|
|
38
39
|
export type { ExportButtonProps, ExportTemplateApi, ExportTemplateOption } from "./exportButton";
|
package/dist/cjs/index.js
CHANGED
|
@@ -541,6 +541,18 @@ Object.keys(_standardList).forEach(function (key) {
|
|
|
541
541
|
}
|
|
542
542
|
});
|
|
543
543
|
});
|
|
544
|
+
var _attachment = require("./attachment");
|
|
545
|
+
Object.keys(_attachment).forEach(function (key) {
|
|
546
|
+
if (key === "default" || key === "__esModule") return;
|
|
547
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
548
|
+
if (key in exports && exports[key] === _attachment[key]) return;
|
|
549
|
+
Object.defineProperty(exports, key, {
|
|
550
|
+
enumerable: true,
|
|
551
|
+
get: function get() {
|
|
552
|
+
return _attachment[key];
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
});
|
|
544
556
|
var _entitySelect = require("./entitySelect");
|
|
545
557
|
var _exportButton = _interopRequireWildcard(require("./exportButton"));
|
|
546
558
|
var _download = require("./utils/download");
|
|
@@ -36,7 +36,7 @@ import ToolBar from "./toolBar";
|
|
|
36
36
|
import SettingItem from "./settingItem";
|
|
37
37
|
import { RedoOutlined, FilterOutlined } from '@ant-design/icons';
|
|
38
38
|
import { convertFilterModel, dateTimeValueFormatter, dateValueFormatter, flatten, toTree } from "./utils";
|
|
39
|
-
import { mergeInferredColumnType, processEllipsisColumn, processEnumColumn } from "./utils/columnProcessors";
|
|
39
|
+
import { mergeInferredColumnType, processEllipsisColumn, processEnumColumn, renderDefaultCell } from "./utils/columnProcessors";
|
|
40
40
|
import AdvancedQueryBuilder from "./queryForm/AdvancedQueryBuilder";
|
|
41
41
|
import { v4 as uuidv4 } from 'uuid';
|
|
42
42
|
import Setting from "./setting";
|
|
@@ -445,18 +445,8 @@ function AgGridPlus(props) {
|
|
|
445
445
|
return undefined;
|
|
446
446
|
};
|
|
447
447
|
|
|
448
|
-
// 辅助函数:
|
|
449
|
-
var cellRenderer =
|
|
450
|
-
var value = params.value,
|
|
451
|
-
node = params.node,
|
|
452
|
-
colDef = params.colDef;
|
|
453
|
-
//@ts-ignore
|
|
454
|
-
if (node.isRowPinned() || !colDef.customCellRenderer) {
|
|
455
|
-
return value;
|
|
456
|
-
}
|
|
457
|
-
//@ts-ignore
|
|
458
|
-
return colDef.customCellRenderer(params);
|
|
459
|
-
};
|
|
448
|
+
// 辅助函数: 自定义单元格渲染器(无自定义渲染器时显示 valueFormatter 的结果,见 renderDefaultCell)
|
|
449
|
+
var cellRenderer = renderDefaultCell;
|
|
460
450
|
|
|
461
451
|
// 辅助函数: 处理单个列配置
|
|
462
452
|
var processColumnConfig = function processColumnConfig(col, data) {
|
|
@@ -95,13 +95,24 @@ export declare function processEnumColumn(col: any, dataType?: DataTypeInference
|
|
|
95
95
|
* @returns 处理后的列定义
|
|
96
96
|
*/
|
|
97
97
|
export declare function processEllipsisColumn(col: any): ColDef;
|
|
98
|
+
/**
|
|
99
|
+
* 默认单元格渲染:固定行(合计等)显示原值;数据行有自定义渲染器(`customCellRenderer`)时交给它;
|
|
100
|
+
* 否则显示 `valueFormatted`(列上配了 `valueFormatter` 时由 AG Grid 算好),没配则显示原值。
|
|
101
|
+
*
|
|
102
|
+
* 以前这里直接返回 `params.value`,普通列(没有 `type`、没有自定义渲染器)上写的 `valueFormatter`
|
|
103
|
+
* 被绕过:状态码列显示原码、「0/1」列显示 0/1,而不是格式化后的文字。
|
|
104
|
+
* 固定行保持原行为:格式化函数多按数据行写,空值常被格式化成「—」,不能让合计行冒出占位符。
|
|
105
|
+
*
|
|
106
|
+
* @author nokecy
|
|
107
|
+
*/
|
|
108
|
+
export declare function renderDefaultCell(params: ICellRendererParams): any;
|
|
98
109
|
/**
|
|
99
110
|
* 创建自定义单元格渲染器包装
|
|
100
111
|
*
|
|
101
|
-
* @param
|
|
112
|
+
* @param _customRenderer 保留参数,实际取列上的 `customCellRenderer`
|
|
102
113
|
* @returns 包装后的渲染器
|
|
103
114
|
*/
|
|
104
|
-
export declare function createCellRenderer(
|
|
115
|
+
export declare function createCellRenderer(_customRenderer?: any): typeof renderDefaultCell;
|
|
105
116
|
/**
|
|
106
117
|
* 构建查询表单项
|
|
107
118
|
*
|
|
@@ -229,26 +229,36 @@ export function processEllipsisColumn(col) {
|
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* 默认单元格渲染:固定行(合计等)显示原值;数据行有自定义渲染器(`customCellRenderer`)时交给它;
|
|
234
|
+
* 否则显示 `valueFormatted`(列上配了 `valueFormatter` 时由 AG Grid 算好),没配则显示原值。
|
|
235
|
+
*
|
|
236
|
+
* 以前这里直接返回 `params.value`,普通列(没有 `type`、没有自定义渲染器)上写的 `valueFormatter`
|
|
237
|
+
* 被绕过:状态码列显示原码、「0/1」列显示 0/1,而不是格式化后的文字。
|
|
238
|
+
* 固定行保持原行为:格式化函数多按数据行写,空值常被格式化成「—」,不能让合计行冒出占位符。
|
|
239
|
+
*
|
|
240
|
+
* @author nokecy
|
|
241
|
+
*/
|
|
242
|
+
export function renderDefaultCell(params) {
|
|
243
|
+
var _node$isRowPinned;
|
|
244
|
+
var value = params.value,
|
|
245
|
+
valueFormatted = params.valueFormatted,
|
|
246
|
+
node = params.node,
|
|
247
|
+
colDef = params.colDef;
|
|
248
|
+
if (node !== null && node !== void 0 && (_node$isRowPinned = node.isRowPinned) !== null && _node$isRowPinned !== void 0 && _node$isRowPinned.call(node)) return value;
|
|
249
|
+
var customRenderer = colDef === null || colDef === void 0 ? void 0 : colDef.customCellRenderer;
|
|
250
|
+
if (!customRenderer) return valueFormatted !== null && valueFormatted !== void 0 ? valueFormatted : value;
|
|
251
|
+
return customRenderer(params);
|
|
252
|
+
}
|
|
253
|
+
|
|
232
254
|
/**
|
|
233
255
|
* 创建自定义单元格渲染器包装
|
|
234
256
|
*
|
|
235
|
-
* @param
|
|
257
|
+
* @param _customRenderer 保留参数,实际取列上的 `customCellRenderer`
|
|
236
258
|
* @returns 包装后的渲染器
|
|
237
259
|
*/
|
|
238
|
-
export function createCellRenderer(
|
|
239
|
-
return
|
|
240
|
-
var value = params.value,
|
|
241
|
-
node = params.node,
|
|
242
|
-
colDef = params.colDef;
|
|
243
|
-
|
|
244
|
-
// 固定行或没有自定义渲染器时,直接返回值
|
|
245
|
-
if (node.isRowPinned() || !colDef.customCellRenderer) {
|
|
246
|
-
return value;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// 使用自定义渲染器
|
|
250
|
-
return colDef.customCellRenderer(params);
|
|
251
|
-
};
|
|
260
|
+
export function createCellRenderer(_customRenderer) {
|
|
261
|
+
return renderDefaultCell;
|
|
252
262
|
}
|
|
253
263
|
|
|
254
264
|
/**
|