element-ui-pro-components-test 1.5.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/CHANGELOG.md +0 -0
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/lib/dialog-form.js +1175 -0
- package/lib/editable-pro-table.js +2080 -0
- package/lib/element-ui-pro-components.common.js +193 -0
- package/lib/index.js +1 -0
- package/lib/locale/index.js +44 -0
- package/lib/locale/lang/en.js +46 -0
- package/lib/locale/lang/zh-CN.js +46 -0
- package/lib/pro-form.js +1036 -0
- package/lib/pro-table.js +2779 -0
- package/lib/theme-chalk/editable-pro-table.css +1 -0
- package/lib/theme-chalk/index.css +1 -0
- package/lib/theme-chalk/pro-table.css +1 -0
- package/lib/umd/locale/en.js +67 -0
- package/lib/umd/locale/zh-CN.js +67 -0
- package/lib/utils/breakpoints.js +68 -0
- package/lib/utils/debounce.js +20 -0
- package/lib/utils/form.js +108 -0
- package/package.json +78 -0
- package/packages/dialog-form/index.js +9 -0
- package/packages/dialog-form/src/components/Submitter.vue +47 -0
- package/packages/dialog-form/src/index.vue +404 -0
- package/packages/editable-pro-table/index.js +9 -0
- package/packages/editable-pro-table/src/components/Editable.vue +203 -0
- package/packages/editable-pro-table/src/components/FormItem.vue +193 -0
- package/packages/editable-pro-table/src/components/RecordCreator.vue +43 -0
- package/packages/editable-pro-table/src/components/RenderCell.vue +181 -0
- package/packages/editable-pro-table/src/index.vue +805 -0
- package/packages/pro-form/index.js +9 -0
- package/packages/pro-form/src/components/Submitter.vue +47 -0
- package/packages/pro-form/src/index.vue +309 -0
- package/packages/pro-table/index.js +9 -0
- package/packages/pro-table/src/components/ColumnAlignSettings.vue +77 -0
- package/packages/pro-table/src/components/ColumnSettings.vue +172 -0
- package/packages/pro-table/src/components/ColumnSettingsItem.vue +401 -0
- package/packages/pro-table/src/components/svg/ArrowIcon.vue +16 -0
- package/packages/pro-table/src/components/svg/HolderIcon.vue +17 -0
- package/packages/pro-table/src/components/svg/SettingIcon.vue +20 -0
- package/packages/pro-table/src/components/svg/VerticalAlginBottomIcon.vue +17 -0
- package/packages/pro-table/src/components/svg/VerticalAlginMiddleIcon.vue +17 -0
- package/packages/pro-table/src/components/svg/VerticalAlignTopIcon.vue +17 -0
- package/packages/pro-table/src/index.vue +934 -0
- package/src/components/custom-render/index.vue +16 -0
- package/src/components/pro-form-item/index.vue +129 -0
- package/src/index.js +57 -0
- package/src/locale/index.js +47 -0
- package/src/locale/lang/en.js +46 -0
- package/src/locale/lang/zh-CN.js +46 -0
- package/src/utils/breakpoints.js +61 -0
- package/src/utils/debounce.js +22 -0
- package/src/utils/form.js +94 -0
|
@@ -0,0 +1,2080 @@
|
|
|
1
|
+
module.exports =
|
|
2
|
+
/******/ (function(modules) { // webpackBootstrap
|
|
3
|
+
/******/ // The module cache
|
|
4
|
+
/******/ var installedModules = {};
|
|
5
|
+
/******/
|
|
6
|
+
/******/ // The require function
|
|
7
|
+
/******/ function __webpack_require__(moduleId) {
|
|
8
|
+
/******/
|
|
9
|
+
/******/ // Check if module is in cache
|
|
10
|
+
/******/ if(installedModules[moduleId]) {
|
|
11
|
+
/******/ return installedModules[moduleId].exports;
|
|
12
|
+
/******/ }
|
|
13
|
+
/******/ // Create a new module (and put it into the cache)
|
|
14
|
+
/******/ var module = installedModules[moduleId] = {
|
|
15
|
+
/******/ i: moduleId,
|
|
16
|
+
/******/ l: false,
|
|
17
|
+
/******/ exports: {}
|
|
18
|
+
/******/ };
|
|
19
|
+
/******/
|
|
20
|
+
/******/ // Execute the module function
|
|
21
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22
|
+
/******/
|
|
23
|
+
/******/ // Flag the module as loaded
|
|
24
|
+
/******/ module.l = true;
|
|
25
|
+
/******/
|
|
26
|
+
/******/ // Return the exports of the module
|
|
27
|
+
/******/ return module.exports;
|
|
28
|
+
/******/ }
|
|
29
|
+
/******/
|
|
30
|
+
/******/
|
|
31
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
32
|
+
/******/ __webpack_require__.m = modules;
|
|
33
|
+
/******/
|
|
34
|
+
/******/ // expose the module cache
|
|
35
|
+
/******/ __webpack_require__.c = installedModules;
|
|
36
|
+
/******/
|
|
37
|
+
/******/ // define getter function for harmony exports
|
|
38
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ };
|
|
43
|
+
/******/
|
|
44
|
+
/******/ // define __esModule on exports
|
|
45
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
46
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
/******/ };
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // create a fake namespace object
|
|
53
|
+
/******/ // mode & 1: value is a module id, require it
|
|
54
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
55
|
+
/******/ // mode & 4: return value when already ns object
|
|
56
|
+
/******/ // mode & 8|1: behave like require
|
|
57
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
58
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59
|
+
/******/ if(mode & 8) return value;
|
|
60
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61
|
+
/******/ var ns = Object.create(null);
|
|
62
|
+
/******/ __webpack_require__.r(ns);
|
|
63
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65
|
+
/******/ return ns;
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/
|
|
68
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69
|
+
/******/ __webpack_require__.n = function(module) {
|
|
70
|
+
/******/ var getter = module && module.__esModule ?
|
|
71
|
+
/******/ function getDefault() { return module['default']; } :
|
|
72
|
+
/******/ function getModuleExports() { return module; };
|
|
73
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74
|
+
/******/ return getter;
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/
|
|
77
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
78
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79
|
+
/******/
|
|
80
|
+
/******/ // __webpack_public_path__
|
|
81
|
+
/******/ __webpack_require__.p = "";
|
|
82
|
+
/******/
|
|
83
|
+
/******/
|
|
84
|
+
/******/ // Load entry module and return exports
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 10);
|
|
86
|
+
/******/ })
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ ([
|
|
89
|
+
/* 0 */
|
|
90
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
91
|
+
|
|
92
|
+
"use strict";
|
|
93
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
|
|
94
|
+
/* globals __VUE_SSR_CONTEXT__ */
|
|
95
|
+
|
|
96
|
+
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
|
|
97
|
+
// This module is a runtime utility for cleaner component module output and will
|
|
98
|
+
// be included in the final webpack user bundle.
|
|
99
|
+
|
|
100
|
+
function normalizeComponent(
|
|
101
|
+
scriptExports,
|
|
102
|
+
render,
|
|
103
|
+
staticRenderFns,
|
|
104
|
+
functionalTemplate,
|
|
105
|
+
injectStyles,
|
|
106
|
+
scopeId,
|
|
107
|
+
moduleIdentifier /* server only */,
|
|
108
|
+
shadowMode /* vue-cli only */
|
|
109
|
+
) {
|
|
110
|
+
// Vue.extend constructor export interop
|
|
111
|
+
var options =
|
|
112
|
+
typeof scriptExports === 'function' ? scriptExports.options : scriptExports
|
|
113
|
+
|
|
114
|
+
// render functions
|
|
115
|
+
if (render) {
|
|
116
|
+
options.render = render
|
|
117
|
+
options.staticRenderFns = staticRenderFns
|
|
118
|
+
options._compiled = true
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// functional template
|
|
122
|
+
if (functionalTemplate) {
|
|
123
|
+
options.functional = true
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// scopedId
|
|
127
|
+
if (scopeId) {
|
|
128
|
+
options._scopeId = 'data-v-' + scopeId
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var hook
|
|
132
|
+
if (moduleIdentifier) {
|
|
133
|
+
// server build
|
|
134
|
+
hook = function (context) {
|
|
135
|
+
// 2.3 injection
|
|
136
|
+
context =
|
|
137
|
+
context || // cached call
|
|
138
|
+
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
139
|
+
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
|
|
140
|
+
// 2.2 with runInNewContext: true
|
|
141
|
+
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
142
|
+
context = __VUE_SSR_CONTEXT__
|
|
143
|
+
}
|
|
144
|
+
// inject component styles
|
|
145
|
+
if (injectStyles) {
|
|
146
|
+
injectStyles.call(this, context)
|
|
147
|
+
}
|
|
148
|
+
// register component module identifier for async chunk inferrence
|
|
149
|
+
if (context && context._registeredComponents) {
|
|
150
|
+
context._registeredComponents.add(moduleIdentifier)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// used by ssr in case component is cached and beforeCreate
|
|
154
|
+
// never gets called
|
|
155
|
+
options._ssrRegister = hook
|
|
156
|
+
} else if (injectStyles) {
|
|
157
|
+
hook = shadowMode
|
|
158
|
+
? function () {
|
|
159
|
+
injectStyles.call(
|
|
160
|
+
this,
|
|
161
|
+
(options.functional ? this.parent : this).$root.$options.shadowRoot
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
: injectStyles
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (hook) {
|
|
168
|
+
if (options.functional) {
|
|
169
|
+
// for template-only hot-reload because in that case the render fn doesn't
|
|
170
|
+
// go through the normalizer
|
|
171
|
+
options._injectStyles = hook
|
|
172
|
+
// register for functional component in vue file
|
|
173
|
+
var originalRender = options.render
|
|
174
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
175
|
+
hook.call(context)
|
|
176
|
+
return originalRender(h, context)
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
// inject component registration as beforeCreate hook
|
|
180
|
+
var existing = options.beforeCreate
|
|
181
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
exports: scriptExports,
|
|
187
|
+
options: options
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
/***/ }),
|
|
193
|
+
/* 1 */
|
|
194
|
+
/***/ (function(module, exports) {
|
|
195
|
+
|
|
196
|
+
module.exports = require("element-ui-pro-components/lib/locale");
|
|
197
|
+
|
|
198
|
+
/***/ }),
|
|
199
|
+
/* 2 */
|
|
200
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
201
|
+
|
|
202
|
+
"use strict";
|
|
203
|
+
|
|
204
|
+
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/custom-render/index.vue?vue&type=script&lang=js
|
|
205
|
+
/* harmony default export */ var custom_rendervue_type_script_lang_js = ({
|
|
206
|
+
name: 'CustomRender',
|
|
207
|
+
props: {
|
|
208
|
+
render: {
|
|
209
|
+
type: Function,
|
|
210
|
+
required: true
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
render: function (h) {
|
|
214
|
+
return h("Fragment", [this.render()]);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
// CONCATENATED MODULE: ./src/components/custom-render/index.vue?vue&type=script&lang=js
|
|
218
|
+
/* harmony default export */ var components_custom_rendervue_type_script_lang_js = (custom_rendervue_type_script_lang_js);
|
|
219
|
+
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
220
|
+
var componentNormalizer = __webpack_require__(0);
|
|
221
|
+
|
|
222
|
+
// CONCATENATED MODULE: ./src/components/custom-render/index.vue
|
|
223
|
+
var render, staticRenderFns
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
/* normalize component */
|
|
229
|
+
|
|
230
|
+
var component = Object(componentNormalizer["a" /* default */])(
|
|
231
|
+
components_custom_rendervue_type_script_lang_js,
|
|
232
|
+
render,
|
|
233
|
+
staticRenderFns,
|
|
234
|
+
false,
|
|
235
|
+
null,
|
|
236
|
+
null,
|
|
237
|
+
null
|
|
238
|
+
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
/* harmony default export */ var custom_render = __webpack_exports__["a"] = (component.exports);
|
|
242
|
+
|
|
243
|
+
/***/ }),
|
|
244
|
+
/* 3 */
|
|
245
|
+
/***/ (function(module, exports) {
|
|
246
|
+
|
|
247
|
+
module.exports = require("element-ui-pro-components/lib/utils/form");
|
|
248
|
+
|
|
249
|
+
/***/ }),
|
|
250
|
+
/* 4 */,
|
|
251
|
+
/* 5 */,
|
|
252
|
+
/* 6 */,
|
|
253
|
+
/* 7 */,
|
|
254
|
+
/* 8 */
|
|
255
|
+
/***/ (function(module, exports) {
|
|
256
|
+
|
|
257
|
+
module.exports = require("el-table-prepend");
|
|
258
|
+
|
|
259
|
+
/***/ }),
|
|
260
|
+
/* 9 */,
|
|
261
|
+
/* 10 */
|
|
262
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
263
|
+
|
|
264
|
+
"use strict";
|
|
265
|
+
// ESM COMPAT FLAG
|
|
266
|
+
__webpack_require__.r(__webpack_exports__);
|
|
267
|
+
|
|
268
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/index.vue?vue&type=template&id=b4388ac0&scoped=true
|
|
269
|
+
var render = function render() {
|
|
270
|
+
var _vm = this,
|
|
271
|
+
_c = _vm._self._c
|
|
272
|
+
return _c(
|
|
273
|
+
_vm.formRef ? "fragment" : "el-form",
|
|
274
|
+
_vm._b({ tag: "component" }, "component", _vm.getDynamicProps, false),
|
|
275
|
+
[
|
|
276
|
+
_c(
|
|
277
|
+
"el-table-prepend",
|
|
278
|
+
_vm._g(
|
|
279
|
+
_vm._b(
|
|
280
|
+
{
|
|
281
|
+
directives: [
|
|
282
|
+
{
|
|
283
|
+
name: "loading",
|
|
284
|
+
rawName: "v-loading",
|
|
285
|
+
value: _vm.loading,
|
|
286
|
+
expression: "loading",
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
ref: "editableProTableRef",
|
|
290
|
+
staticClass: "editable-pro-table",
|
|
291
|
+
class: _vm.className,
|
|
292
|
+
attrs: { data: _vm.form[_vm.name] },
|
|
293
|
+
scopedSlots: _vm._u(
|
|
294
|
+
[
|
|
295
|
+
_vm.initializedCreatorProps.position === "top" &&
|
|
296
|
+
!_vm.exceedsMax
|
|
297
|
+
? {
|
|
298
|
+
key: "prepend",
|
|
299
|
+
fn: function () {
|
|
300
|
+
return [
|
|
301
|
+
_c(
|
|
302
|
+
"div",
|
|
303
|
+
{ staticClass: "btn-add-box" },
|
|
304
|
+
[
|
|
305
|
+
_c("RecordCreator", {
|
|
306
|
+
attrs: {
|
|
307
|
+
recordCreatorProps:
|
|
308
|
+
_vm.initializedCreatorProps,
|
|
309
|
+
size: _vm.defaultSize,
|
|
310
|
+
},
|
|
311
|
+
nativeOn: {
|
|
312
|
+
click: function ($event) {
|
|
313
|
+
return _vm.addEditRecord(null)
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
}),
|
|
317
|
+
],
|
|
318
|
+
1
|
|
319
|
+
),
|
|
320
|
+
]
|
|
321
|
+
},
|
|
322
|
+
proxy: true,
|
|
323
|
+
}
|
|
324
|
+
: null,
|
|
325
|
+
],
|
|
326
|
+
null,
|
|
327
|
+
true
|
|
328
|
+
),
|
|
329
|
+
},
|
|
330
|
+
"el-table-prepend",
|
|
331
|
+
_vm.initializedTableProps,
|
|
332
|
+
false
|
|
333
|
+
),
|
|
334
|
+
_vm.tableEvents
|
|
335
|
+
),
|
|
336
|
+
_vm._l(_vm.initializedColumns, function (column, index) {
|
|
337
|
+
return _c(
|
|
338
|
+
"el-table-column",
|
|
339
|
+
_vm._b(
|
|
340
|
+
{
|
|
341
|
+
key: column.prop || column.key || `${column.type}-col`,
|
|
342
|
+
scopedSlots: _vm._u(
|
|
343
|
+
[
|
|
344
|
+
column.renderCellHeader
|
|
345
|
+
? {
|
|
346
|
+
key: "header",
|
|
347
|
+
fn: function (scope) {
|
|
348
|
+
return [
|
|
349
|
+
_c("CustomRender", {
|
|
350
|
+
attrs: {
|
|
351
|
+
render: () => column.renderCellHeader(scope),
|
|
352
|
+
},
|
|
353
|
+
}),
|
|
354
|
+
]
|
|
355
|
+
},
|
|
356
|
+
}
|
|
357
|
+
: null,
|
|
358
|
+
column.valueType || column.renderField
|
|
359
|
+
? {
|
|
360
|
+
key: "default",
|
|
361
|
+
fn: function (scope) {
|
|
362
|
+
return [
|
|
363
|
+
column.valueType === "option"
|
|
364
|
+
? [
|
|
365
|
+
_c("Editable", {
|
|
366
|
+
attrs: {
|
|
367
|
+
editable: _vm.initializedEditable,
|
|
368
|
+
actions: {
|
|
369
|
+
cancelEditable: _vm.cancelEditable,
|
|
370
|
+
startEditable: _vm.startEditable,
|
|
371
|
+
addEditRecord: _vm.addEditRecord,
|
|
372
|
+
},
|
|
373
|
+
validateRow: _vm.validateRow,
|
|
374
|
+
recordKey: scope.row[_vm.rowKey],
|
|
375
|
+
scope: scope,
|
|
376
|
+
name: _vm.name,
|
|
377
|
+
render: (actions) =>
|
|
378
|
+
column.renderCell(scope, actions),
|
|
379
|
+
newLineRecordCache:
|
|
380
|
+
_vm.newLineRecordCache,
|
|
381
|
+
preEditRows: _vm.preEditRows,
|
|
382
|
+
defaultSize: _vm.defaultSize,
|
|
383
|
+
},
|
|
384
|
+
on: {
|
|
385
|
+
delete: _vm.filterByRecordKey,
|
|
386
|
+
cancel: _vm.deleteOrResetRow,
|
|
387
|
+
},
|
|
388
|
+
}),
|
|
389
|
+
]
|
|
390
|
+
: [
|
|
391
|
+
_c("RenderCell", {
|
|
392
|
+
attrs: {
|
|
393
|
+
editable: _vm.initializedEditable,
|
|
394
|
+
column: column,
|
|
395
|
+
name: _vm.name,
|
|
396
|
+
recordKey: scope.row[_vm.rowKey],
|
|
397
|
+
scope: scope,
|
|
398
|
+
cachedOptions: _vm.cachedOptions,
|
|
399
|
+
preEditRows: _vm.preEditRows,
|
|
400
|
+
},
|
|
401
|
+
scopedSlots: _vm._u(
|
|
402
|
+
[
|
|
403
|
+
{
|
|
404
|
+
key: column.prop,
|
|
405
|
+
fn: function (scope) {
|
|
406
|
+
return [
|
|
407
|
+
_vm._t(
|
|
408
|
+
column.prop,
|
|
409
|
+
null,
|
|
410
|
+
null,
|
|
411
|
+
scope
|
|
412
|
+
),
|
|
413
|
+
]
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
],
|
|
417
|
+
null,
|
|
418
|
+
true
|
|
419
|
+
),
|
|
420
|
+
}),
|
|
421
|
+
],
|
|
422
|
+
]
|
|
423
|
+
},
|
|
424
|
+
}
|
|
425
|
+
: null,
|
|
426
|
+
],
|
|
427
|
+
null,
|
|
428
|
+
true
|
|
429
|
+
),
|
|
430
|
+
},
|
|
431
|
+
"el-table-column",
|
|
432
|
+
_vm.getColumnProps(column, index),
|
|
433
|
+
false
|
|
434
|
+
)
|
|
435
|
+
)
|
|
436
|
+
}),
|
|
437
|
+
1
|
|
438
|
+
),
|
|
439
|
+
_vm.initializedCreatorProps.position === "bottom" && !_vm.exceedsMax
|
|
440
|
+
? _c("RecordCreator", {
|
|
441
|
+
attrs: {
|
|
442
|
+
recordCreatorProps: _vm.initializedCreatorProps,
|
|
443
|
+
size: _vm.defaultSize,
|
|
444
|
+
},
|
|
445
|
+
nativeOn: {
|
|
446
|
+
click: function ($event) {
|
|
447
|
+
return _vm.addEditRecord(null)
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
})
|
|
451
|
+
: _vm._e(),
|
|
452
|
+
],
|
|
453
|
+
1
|
|
454
|
+
)
|
|
455
|
+
}
|
|
456
|
+
var staticRenderFns = []
|
|
457
|
+
render._withStripped = true
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/index.vue?vue&type=template&id=b4388ac0&scoped=true
|
|
461
|
+
|
|
462
|
+
// EXTERNAL MODULE: external "el-table-prepend"
|
|
463
|
+
var external_el_table_prepend_ = __webpack_require__(8);
|
|
464
|
+
var external_el_table_prepend_default = /*#__PURE__*/__webpack_require__.n(external_el_table_prepend_);
|
|
465
|
+
|
|
466
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/RecordCreator.vue?vue&type=template&id=162f12bc&scoped=true
|
|
467
|
+
var RecordCreatorvue_type_template_id_162f12bc_scoped_true_render = function render() {
|
|
468
|
+
var _vm = this,
|
|
469
|
+
_c = _vm._self._c
|
|
470
|
+
return _c(
|
|
471
|
+
"el-button",
|
|
472
|
+
_vm._b(
|
|
473
|
+
{
|
|
474
|
+
staticClass: "btn-add",
|
|
475
|
+
style: _vm.recordCreatorProps.style,
|
|
476
|
+
attrs: { icon: "el-icon-plus" },
|
|
477
|
+
},
|
|
478
|
+
"el-button",
|
|
479
|
+
_vm.initializedButtonProps,
|
|
480
|
+
false
|
|
481
|
+
),
|
|
482
|
+
[_vm._v("\n " + _vm._s(_vm.recordCreatorProps.creatorButtonText) + "\n")]
|
|
483
|
+
)
|
|
484
|
+
}
|
|
485
|
+
var RecordCreatorvue_type_template_id_162f12bc_scoped_true_staticRenderFns = []
|
|
486
|
+
RecordCreatorvue_type_template_id_162f12bc_scoped_true_render._withStripped = true
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/RecordCreator.vue?vue&type=template&id=162f12bc&scoped=true
|
|
490
|
+
|
|
491
|
+
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/RecordCreator.vue?vue&type=script&lang=js
|
|
492
|
+
/* harmony default export */ var RecordCreatorvue_type_script_lang_js = ({
|
|
493
|
+
name: 'RecordCreator',
|
|
494
|
+
props: {
|
|
495
|
+
recordCreatorProps: {
|
|
496
|
+
type: [Boolean, Object],
|
|
497
|
+
required: true
|
|
498
|
+
},
|
|
499
|
+
size: {
|
|
500
|
+
type: String
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
computed: {
|
|
504
|
+
initializedButtonProps() {
|
|
505
|
+
const {
|
|
506
|
+
size,
|
|
507
|
+
recordCreatorProps: {
|
|
508
|
+
buttonProps = {}
|
|
509
|
+
}
|
|
510
|
+
} = this;
|
|
511
|
+
return {
|
|
512
|
+
plain: true,
|
|
513
|
+
...buttonProps,
|
|
514
|
+
size
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/RecordCreator.vue?vue&type=script&lang=js
|
|
520
|
+
/* harmony default export */ var components_RecordCreatorvue_type_script_lang_js = (RecordCreatorvue_type_script_lang_js);
|
|
521
|
+
// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/less-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/RecordCreator.vue?vue&type=style&index=0&id=162f12bc&prod&scoped=true&lang=css
|
|
522
|
+
// extracted by mini-css-extract-plugin
|
|
523
|
+
|
|
524
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/RecordCreator.vue?vue&type=style&index=0&id=162f12bc&prod&scoped=true&lang=css
|
|
525
|
+
|
|
526
|
+
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
527
|
+
var componentNormalizer = __webpack_require__(0);
|
|
528
|
+
|
|
529
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/RecordCreator.vue
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
/* normalize component */
|
|
537
|
+
|
|
538
|
+
var component = Object(componentNormalizer["a" /* default */])(
|
|
539
|
+
components_RecordCreatorvue_type_script_lang_js,
|
|
540
|
+
RecordCreatorvue_type_template_id_162f12bc_scoped_true_render,
|
|
541
|
+
RecordCreatorvue_type_template_id_162f12bc_scoped_true_staticRenderFns,
|
|
542
|
+
false,
|
|
543
|
+
null,
|
|
544
|
+
"162f12bc",
|
|
545
|
+
null
|
|
546
|
+
|
|
547
|
+
)
|
|
548
|
+
|
|
549
|
+
/* harmony default export */ var RecordCreator = (component.exports);
|
|
550
|
+
// EXTERNAL MODULE: ./src/components/custom-render/index.vue + 2 modules
|
|
551
|
+
var custom_render = __webpack_require__(2);
|
|
552
|
+
|
|
553
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/RenderCell.vue?vue&type=template&id=934d518a&scoped=true
|
|
554
|
+
var RenderCellvue_type_template_id_934d518a_scoped_true_render = function render() {
|
|
555
|
+
var _vm = this,
|
|
556
|
+
_c = _vm._self._c
|
|
557
|
+
return _c(
|
|
558
|
+
"Fragment",
|
|
559
|
+
[
|
|
560
|
+
_vm.isEditable
|
|
561
|
+
? _c("FormItem", {
|
|
562
|
+
attrs: {
|
|
563
|
+
formItem: _vm.formItem,
|
|
564
|
+
formItemProp: _vm.formItemProp,
|
|
565
|
+
form: _vm.row,
|
|
566
|
+
name: _vm.name,
|
|
567
|
+
recordKey: _vm.recordKey,
|
|
568
|
+
index: _vm.index,
|
|
569
|
+
},
|
|
570
|
+
scopedSlots: _vm._u(
|
|
571
|
+
[
|
|
572
|
+
{
|
|
573
|
+
key: _vm.formItem.prop,
|
|
574
|
+
fn: function () {
|
|
575
|
+
return [
|
|
576
|
+
_vm._t(_vm.formItem.prop, null, null, {
|
|
577
|
+
form: _vm.row,
|
|
578
|
+
formItem: _vm.formItem,
|
|
579
|
+
recordKey: _vm.recordKey,
|
|
580
|
+
index: _vm.index,
|
|
581
|
+
}),
|
|
582
|
+
]
|
|
583
|
+
},
|
|
584
|
+
proxy: true,
|
|
585
|
+
},
|
|
586
|
+
],
|
|
587
|
+
null,
|
|
588
|
+
true
|
|
589
|
+
),
|
|
590
|
+
})
|
|
591
|
+
: [
|
|
592
|
+
_c(
|
|
593
|
+
"el-form-item",
|
|
594
|
+
{
|
|
595
|
+
staticClass: "editable-form-item",
|
|
596
|
+
attrs: { prop: _vm.formItemProp },
|
|
597
|
+
},
|
|
598
|
+
[
|
|
599
|
+
_vm.column.renderCell
|
|
600
|
+
? _c("CustomRender", {
|
|
601
|
+
attrs: { render: () => _vm.column.renderCell(_vm.scope) },
|
|
602
|
+
})
|
|
603
|
+
: _c(
|
|
604
|
+
"span",
|
|
605
|
+
{
|
|
606
|
+
class: {
|
|
607
|
+
"text-ellipsis": _vm.column["show-overflow-tooltip"],
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
[_vm._v(_vm._s(_vm.value))]
|
|
611
|
+
),
|
|
612
|
+
],
|
|
613
|
+
1
|
|
614
|
+
),
|
|
615
|
+
],
|
|
616
|
+
],
|
|
617
|
+
2
|
|
618
|
+
)
|
|
619
|
+
}
|
|
620
|
+
var RenderCellvue_type_template_id_934d518a_scoped_true_staticRenderFns = []
|
|
621
|
+
RenderCellvue_type_template_id_934d518a_scoped_true_render._withStripped = true
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/RenderCell.vue?vue&type=template&id=934d518a&scoped=true
|
|
625
|
+
|
|
626
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/FormItem.vue?vue&type=template&id=6714ad42&scoped=true
|
|
627
|
+
var FormItemvue_type_template_id_6714ad42_scoped_true_render = function render() {
|
|
628
|
+
var _vm = this,
|
|
629
|
+
_c = _vm._self._c
|
|
630
|
+
return _c(
|
|
631
|
+
"el-form-item",
|
|
632
|
+
_vm._b(
|
|
633
|
+
{
|
|
634
|
+
staticClass: "editable-form-item is-editable",
|
|
635
|
+
attrs: { prop: _vm.formItemProp, label: "" },
|
|
636
|
+
},
|
|
637
|
+
"el-form-item",
|
|
638
|
+
_vm.normalizedFormItem,
|
|
639
|
+
false
|
|
640
|
+
),
|
|
641
|
+
[
|
|
642
|
+
_vm.formItem.renderField
|
|
643
|
+
? _c("CustomRender", {
|
|
644
|
+
attrs: {
|
|
645
|
+
render: () =>
|
|
646
|
+
_vm.formItem.renderField({
|
|
647
|
+
form: _vm.form,
|
|
648
|
+
formItem: _vm.formItem,
|
|
649
|
+
recordKey: _vm.recordKey,
|
|
650
|
+
index: _vm.index,
|
|
651
|
+
}),
|
|
652
|
+
},
|
|
653
|
+
})
|
|
654
|
+
: _vm.formItem.valueType === "slot"
|
|
655
|
+
? _vm._t(_vm.formItem.prop)
|
|
656
|
+
: _c(
|
|
657
|
+
`el-${_vm.formItem.valueType}`,
|
|
658
|
+
_vm._g(
|
|
659
|
+
_vm._b(
|
|
660
|
+
{
|
|
661
|
+
tag: "component",
|
|
662
|
+
model: {
|
|
663
|
+
value: _vm.form[_vm.formItem.prop],
|
|
664
|
+
callback: function ($$v) {
|
|
665
|
+
_vm.$set(_vm.form, _vm.formItem.prop, $$v)
|
|
666
|
+
},
|
|
667
|
+
expression: "form[formItem.prop]",
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
"component",
|
|
671
|
+
_vm.formItem.fieldProps,
|
|
672
|
+
false
|
|
673
|
+
),
|
|
674
|
+
_vm.normalizedFieldEvents
|
|
675
|
+
),
|
|
676
|
+
[
|
|
677
|
+
_vm.formItem.valueType === "select"
|
|
678
|
+
? [
|
|
679
|
+
_vm.isOptionGroup
|
|
680
|
+
? _vm._l(_vm.formItem.options, function (group) {
|
|
681
|
+
return _c(
|
|
682
|
+
"el-option-group",
|
|
683
|
+
_vm._b(
|
|
684
|
+
{ key: group.label },
|
|
685
|
+
"el-option-group",
|
|
686
|
+
group,
|
|
687
|
+
false
|
|
688
|
+
),
|
|
689
|
+
_vm._l(group.options, function (option) {
|
|
690
|
+
return _c(
|
|
691
|
+
"el-option",
|
|
692
|
+
_vm._b(
|
|
693
|
+
{ key: option.value },
|
|
694
|
+
"el-option",
|
|
695
|
+
option,
|
|
696
|
+
false
|
|
697
|
+
)
|
|
698
|
+
)
|
|
699
|
+
}),
|
|
700
|
+
1
|
|
701
|
+
)
|
|
702
|
+
})
|
|
703
|
+
: _vm._l(_vm.formItem.options, function (option) {
|
|
704
|
+
return _c(
|
|
705
|
+
"el-option",
|
|
706
|
+
_vm._b(
|
|
707
|
+
{ key: option.value },
|
|
708
|
+
"el-option",
|
|
709
|
+
option,
|
|
710
|
+
false
|
|
711
|
+
)
|
|
712
|
+
)
|
|
713
|
+
}),
|
|
714
|
+
]
|
|
715
|
+
: _vm.groups.includes(_vm.formItem.valueType)
|
|
716
|
+
? _vm._l(_vm.formItem.options, function (option) {
|
|
717
|
+
return _c(
|
|
718
|
+
_vm.selection[_vm.formItem.valueType],
|
|
719
|
+
{
|
|
720
|
+
key: option.value,
|
|
721
|
+
tag: "component",
|
|
722
|
+
attrs: { label: option.value },
|
|
723
|
+
},
|
|
724
|
+
[_vm._v("\n " + _vm._s(option.label) + "\n ")]
|
|
725
|
+
)
|
|
726
|
+
})
|
|
727
|
+
: _vm._e(),
|
|
728
|
+
],
|
|
729
|
+
2
|
|
730
|
+
),
|
|
731
|
+
],
|
|
732
|
+
2
|
|
733
|
+
)
|
|
734
|
+
}
|
|
735
|
+
var FormItemvue_type_template_id_6714ad42_scoped_true_staticRenderFns = []
|
|
736
|
+
FormItemvue_type_template_id_6714ad42_scoped_true_render._withStripped = true
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/FormItem.vue?vue&type=template&id=6714ad42&scoped=true
|
|
740
|
+
|
|
741
|
+
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/FormItem.vue?vue&type=script&lang=js
|
|
742
|
+
|
|
743
|
+
/* harmony default export */ var FormItemvue_type_script_lang_js = ({
|
|
744
|
+
name: 'FormItem',
|
|
745
|
+
components: {
|
|
746
|
+
CustomRender: custom_render["a" /* default */]
|
|
747
|
+
},
|
|
748
|
+
props: {
|
|
749
|
+
// formItem 项
|
|
750
|
+
formItem: {
|
|
751
|
+
type: Object,
|
|
752
|
+
required: true
|
|
753
|
+
},
|
|
754
|
+
// 表单数据
|
|
755
|
+
form: {
|
|
756
|
+
type: Object,
|
|
757
|
+
required: true
|
|
758
|
+
},
|
|
759
|
+
// 可编辑表格名称
|
|
760
|
+
name: {
|
|
761
|
+
type: String
|
|
762
|
+
},
|
|
763
|
+
recordKey: {
|
|
764
|
+
type: [Number, String]
|
|
765
|
+
},
|
|
766
|
+
// 下标
|
|
767
|
+
index: {
|
|
768
|
+
type: Number
|
|
769
|
+
},
|
|
770
|
+
// el-form-item prop
|
|
771
|
+
formItemProp: {
|
|
772
|
+
type: String
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
computed: {
|
|
776
|
+
// 过滤 el-form-item 的属性
|
|
777
|
+
normalizedFormItem() {
|
|
778
|
+
const {
|
|
779
|
+
valueType,
|
|
780
|
+
renderField,
|
|
781
|
+
fieldProps,
|
|
782
|
+
fieldEvents,
|
|
783
|
+
options,
|
|
784
|
+
valueEnum,
|
|
785
|
+
optionLoader,
|
|
786
|
+
initialValue,
|
|
787
|
+
colProps,
|
|
788
|
+
...keys
|
|
789
|
+
} = this.formItem;
|
|
790
|
+
return keys;
|
|
791
|
+
},
|
|
792
|
+
// 表单事件
|
|
793
|
+
normalizedFieldEvents() {
|
|
794
|
+
const {
|
|
795
|
+
formItem: {
|
|
796
|
+
fieldEvents
|
|
797
|
+
}
|
|
798
|
+
} = this;
|
|
799
|
+
if (!fieldEvents) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const newEvents = {};
|
|
803
|
+
const {
|
|
804
|
+
recordKey,
|
|
805
|
+
form: row,
|
|
806
|
+
index
|
|
807
|
+
} = this;
|
|
808
|
+
for (const eventName in fieldEvents) {
|
|
809
|
+
const handler = (...args) => {
|
|
810
|
+
var _fieldEvents$eventNam;
|
|
811
|
+
return (_fieldEvents$eventNam = fieldEvents[eventName]) === null || _fieldEvents$eventNam === void 0 ? void 0 : _fieldEvents$eventNam.call(fieldEvents, ...args, {
|
|
812
|
+
recordKey,
|
|
813
|
+
row,
|
|
814
|
+
index
|
|
815
|
+
});
|
|
816
|
+
};
|
|
817
|
+
newEvents[eventName] = handler;
|
|
818
|
+
}
|
|
819
|
+
return newEvents;
|
|
820
|
+
},
|
|
821
|
+
isOptionGroup() {
|
|
822
|
+
var _this$formItem$option, _this$formItem$option2;
|
|
823
|
+
return (_this$formItem$option = this.formItem.options) === null || _this$formItem$option === void 0 ? void 0 : (_this$formItem$option2 = _this$formItem$option[0]) === null || _this$formItem$option2 === void 0 ? void 0 : _this$formItem$option2.options;
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
data() {
|
|
827
|
+
return {
|
|
828
|
+
groups: ['radio-group', 'checkbox-group'],
|
|
829
|
+
// valueType
|
|
830
|
+
selection: {
|
|
831
|
+
// 选项组对应的组件
|
|
832
|
+
'radio-group': 'el-radio',
|
|
833
|
+
'checkbox-group': 'el-checkbox'
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/FormItem.vue?vue&type=script&lang=js
|
|
839
|
+
/* harmony default export */ var components_FormItemvue_type_script_lang_js = (FormItemvue_type_script_lang_js);
|
|
840
|
+
// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/less-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/FormItem.vue?vue&type=style&index=0&id=6714ad42&prod&lang=less&scoped=true
|
|
841
|
+
// extracted by mini-css-extract-plugin
|
|
842
|
+
|
|
843
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/FormItem.vue?vue&type=style&index=0&id=6714ad42&prod&lang=less&scoped=true
|
|
844
|
+
|
|
845
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/FormItem.vue
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
/* normalize component */
|
|
853
|
+
|
|
854
|
+
var FormItem_component = Object(componentNormalizer["a" /* default */])(
|
|
855
|
+
components_FormItemvue_type_script_lang_js,
|
|
856
|
+
FormItemvue_type_template_id_6714ad42_scoped_true_render,
|
|
857
|
+
FormItemvue_type_template_id_6714ad42_scoped_true_staticRenderFns,
|
|
858
|
+
false,
|
|
859
|
+
null,
|
|
860
|
+
"6714ad42",
|
|
861
|
+
null
|
|
862
|
+
|
|
863
|
+
)
|
|
864
|
+
|
|
865
|
+
/* harmony default export */ var FormItem = (FormItem_component.exports);
|
|
866
|
+
// EXTERNAL MODULE: external "element-ui-pro-components/lib/utils/form"
|
|
867
|
+
var form_ = __webpack_require__(3);
|
|
868
|
+
|
|
869
|
+
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/RenderCell.vue?vue&type=script&lang=js
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
/* harmony default export */ var RenderCellvue_type_script_lang_js = ({
|
|
874
|
+
name: 'RenderCell',
|
|
875
|
+
components: {
|
|
876
|
+
FormItem: FormItem,
|
|
877
|
+
CustomRender: custom_render["a" /* default */]
|
|
878
|
+
},
|
|
879
|
+
props: {
|
|
880
|
+
editable: {
|
|
881
|
+
type: Object,
|
|
882
|
+
required: true
|
|
883
|
+
},
|
|
884
|
+
// 列
|
|
885
|
+
column: {
|
|
886
|
+
type: Object,
|
|
887
|
+
required: true
|
|
888
|
+
},
|
|
889
|
+
// 数据
|
|
890
|
+
scope: {
|
|
891
|
+
type: Object
|
|
892
|
+
},
|
|
893
|
+
name: {
|
|
894
|
+
type: String,
|
|
895
|
+
required: true
|
|
896
|
+
},
|
|
897
|
+
recordKey: {
|
|
898
|
+
type: [String, Number]
|
|
899
|
+
},
|
|
900
|
+
cachedOptions: {
|
|
901
|
+
type: Object
|
|
902
|
+
},
|
|
903
|
+
preEditRows: {
|
|
904
|
+
type: Map
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
computed: {
|
|
908
|
+
// 表单项
|
|
909
|
+
formItem() {
|
|
910
|
+
const {
|
|
911
|
+
column,
|
|
912
|
+
column: {
|
|
913
|
+
prop,
|
|
914
|
+
formItemProps = {},
|
|
915
|
+
valueType,
|
|
916
|
+
renderField,
|
|
917
|
+
fieldProps = {},
|
|
918
|
+
fieldEvents
|
|
919
|
+
}
|
|
920
|
+
} = this;
|
|
921
|
+
// 设置 placeholder
|
|
922
|
+
Object(form_["setPlaceholder"])(fieldProps, valueType);
|
|
923
|
+
|
|
924
|
+
// 设置 select options
|
|
925
|
+
Object(form_["setSelectOptions"])(column, this.cachedOptions);
|
|
926
|
+
|
|
927
|
+
// 设置 cascader options
|
|
928
|
+
Object(form_["setCascaderOptions"])(fieldProps, column, this.cachedOptions);
|
|
929
|
+
return {
|
|
930
|
+
...formItemProps,
|
|
931
|
+
prop,
|
|
932
|
+
valueType,
|
|
933
|
+
renderField,
|
|
934
|
+
fieldProps,
|
|
935
|
+
fieldEvents,
|
|
936
|
+
options: column.options
|
|
937
|
+
};
|
|
938
|
+
},
|
|
939
|
+
// 行数据
|
|
940
|
+
row() {
|
|
941
|
+
return this.scope.row;
|
|
942
|
+
},
|
|
943
|
+
// 下标
|
|
944
|
+
index() {
|
|
945
|
+
return this.scope.$index;
|
|
946
|
+
},
|
|
947
|
+
// 可编辑表格 el-form-item prop
|
|
948
|
+
formItemProp() {
|
|
949
|
+
const {
|
|
950
|
+
formItem: {
|
|
951
|
+
prop
|
|
952
|
+
},
|
|
953
|
+
name,
|
|
954
|
+
index
|
|
955
|
+
} = this;
|
|
956
|
+
return `${name}.${index}.${prop}`;
|
|
957
|
+
},
|
|
958
|
+
isEditable() {
|
|
959
|
+
var _this$preEditRows$get;
|
|
960
|
+
const {
|
|
961
|
+
editable: {
|
|
962
|
+
editableKeys
|
|
963
|
+
},
|
|
964
|
+
recordKey,
|
|
965
|
+
formItem: {
|
|
966
|
+
prop
|
|
967
|
+
},
|
|
968
|
+
column: {
|
|
969
|
+
readonly,
|
|
970
|
+
editable
|
|
971
|
+
}
|
|
972
|
+
} = this;
|
|
973
|
+
const preEditCellValue = (_this$preEditRows$get = this.preEditRows.get(this.recordKey)) === null || _this$preEditRows$get === void 0 ? void 0 : _this$preEditRows$get[prop];
|
|
974
|
+
return (editableKeys === null || editableKeys === void 0 ? void 0 : editableKeys.some(key => recordKey === key)) && readonly !== true && (editable ? editable === null || editable === void 0 ? void 0 : editable(preEditCellValue, this.row, this.index) : true);
|
|
975
|
+
},
|
|
976
|
+
// 文本
|
|
977
|
+
value() {
|
|
978
|
+
const {
|
|
979
|
+
column: {
|
|
980
|
+
formatter
|
|
981
|
+
},
|
|
982
|
+
formItem,
|
|
983
|
+
scope,
|
|
984
|
+
row,
|
|
985
|
+
index
|
|
986
|
+
} = this;
|
|
987
|
+
const {
|
|
988
|
+
prop,
|
|
989
|
+
valueType,
|
|
990
|
+
options,
|
|
991
|
+
valueEnum
|
|
992
|
+
} = formItem;
|
|
993
|
+
const cellValue = row[prop];
|
|
994
|
+
if (formatter) {
|
|
995
|
+
// formatter
|
|
996
|
+
return formatter(row, scope.column, cellValue, index);
|
|
997
|
+
} else if (valueType === 'select') {
|
|
998
|
+
// 选择器
|
|
999
|
+
if (valueEnum) {
|
|
1000
|
+
// 枚举
|
|
1001
|
+
if (valueEnum instanceof Map) {
|
|
1002
|
+
return valueEnum.get(cellValue);
|
|
1003
|
+
} else {
|
|
1004
|
+
return valueEnum[cellValue];
|
|
1005
|
+
}
|
|
1006
|
+
} else {
|
|
1007
|
+
// options
|
|
1008
|
+
const map = (options || []).reduce((accu, cur) => ({
|
|
1009
|
+
...accu,
|
|
1010
|
+
[cur.value]: cur.label
|
|
1011
|
+
}), {});
|
|
1012
|
+
return map[cellValue];
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return cellValue !== null && cellValue !== void 0 ? cellValue : '-';
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/RenderCell.vue?vue&type=script&lang=js
|
|
1020
|
+
/* harmony default export */ var components_RenderCellvue_type_script_lang_js = (RenderCellvue_type_script_lang_js);
|
|
1021
|
+
// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/less-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/RenderCell.vue?vue&type=style&index=0&id=934d518a&prod&lang=less&scoped=true
|
|
1022
|
+
// extracted by mini-css-extract-plugin
|
|
1023
|
+
|
|
1024
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/RenderCell.vue?vue&type=style&index=0&id=934d518a&prod&lang=less&scoped=true
|
|
1025
|
+
|
|
1026
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/RenderCell.vue
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
/* normalize component */
|
|
1034
|
+
|
|
1035
|
+
var RenderCell_component = Object(componentNormalizer["a" /* default */])(
|
|
1036
|
+
components_RenderCellvue_type_script_lang_js,
|
|
1037
|
+
RenderCellvue_type_template_id_934d518a_scoped_true_render,
|
|
1038
|
+
RenderCellvue_type_template_id_934d518a_scoped_true_staticRenderFns,
|
|
1039
|
+
false,
|
|
1040
|
+
null,
|
|
1041
|
+
"934d518a",
|
|
1042
|
+
null
|
|
1043
|
+
|
|
1044
|
+
)
|
|
1045
|
+
|
|
1046
|
+
/* harmony default export */ var RenderCell = (RenderCell_component.exports);
|
|
1047
|
+
// EXTERNAL MODULE: external "element-ui-pro-components/lib/locale"
|
|
1048
|
+
var locale_ = __webpack_require__(1);
|
|
1049
|
+
|
|
1050
|
+
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/Editable.vue?vue&type=script&lang=js
|
|
1051
|
+
|
|
1052
|
+
/* harmony default export */ var Editablevue_type_script_lang_js = ({
|
|
1053
|
+
name: 'Editable',
|
|
1054
|
+
props: {
|
|
1055
|
+
// 可编辑配置
|
|
1056
|
+
editable: {
|
|
1057
|
+
type: Object,
|
|
1058
|
+
required: true
|
|
1059
|
+
},
|
|
1060
|
+
actions: {
|
|
1061
|
+
type: Object,
|
|
1062
|
+
required: true
|
|
1063
|
+
},
|
|
1064
|
+
validateRow: {
|
|
1065
|
+
type: Function
|
|
1066
|
+
},
|
|
1067
|
+
recordKey: {
|
|
1068
|
+
type: [String, Number]
|
|
1069
|
+
},
|
|
1070
|
+
render: {
|
|
1071
|
+
type: Function,
|
|
1072
|
+
required: true
|
|
1073
|
+
},
|
|
1074
|
+
scope: {
|
|
1075
|
+
type: Object
|
|
1076
|
+
},
|
|
1077
|
+
newLineRecordCache: {
|
|
1078
|
+
type: Object
|
|
1079
|
+
},
|
|
1080
|
+
name: {
|
|
1081
|
+
type: String
|
|
1082
|
+
},
|
|
1083
|
+
preEditRows: {
|
|
1084
|
+
type: Map
|
|
1085
|
+
},
|
|
1086
|
+
defaultSize: {
|
|
1087
|
+
type: String
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
computed: {
|
|
1091
|
+
isEditable() {
|
|
1092
|
+
const {
|
|
1093
|
+
editable: {
|
|
1094
|
+
editableKeys
|
|
1095
|
+
},
|
|
1096
|
+
recordKey
|
|
1097
|
+
} = this;
|
|
1098
|
+
return editableKeys === null || editableKeys === void 0 ? void 0 : editableKeys.some(key => recordKey === key);
|
|
1099
|
+
},
|
|
1100
|
+
isNewLineRecordCache() {
|
|
1101
|
+
var _this$newLineRecordCa;
|
|
1102
|
+
return ((_this$newLineRecordCa = this.newLineRecordCache) === null || _this$newLineRecordCa === void 0 ? void 0 : _this$newLineRecordCa.options.recordKey) === this.recordKey;
|
|
1103
|
+
}
|
|
1104
|
+
},
|
|
1105
|
+
data() {
|
|
1106
|
+
return {
|
|
1107
|
+
saveLoading: false,
|
|
1108
|
+
deleteLoading: false,
|
|
1109
|
+
visible: false
|
|
1110
|
+
};
|
|
1111
|
+
},
|
|
1112
|
+
methods: {
|
|
1113
|
+
/**
|
|
1114
|
+
* @desc 保存
|
|
1115
|
+
*/
|
|
1116
|
+
async save() {
|
|
1117
|
+
// 手动销毁
|
|
1118
|
+
this.visible = false;
|
|
1119
|
+
const {
|
|
1120
|
+
validateRow,
|
|
1121
|
+
scope: {
|
|
1122
|
+
row,
|
|
1123
|
+
$index
|
|
1124
|
+
},
|
|
1125
|
+
recordKey
|
|
1126
|
+
} = this;
|
|
1127
|
+
const res = await validateRow($index);
|
|
1128
|
+
if (!res) {
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
try {
|
|
1132
|
+
var _this$editable$onSave, _this$editable;
|
|
1133
|
+
this.saveLoading = true;
|
|
1134
|
+
const res = await ((_this$editable$onSave = (_this$editable = this.editable).onSave) === null || _this$editable$onSave === void 0 ? void 0 : _this$editable$onSave.call(_this$editable, recordKey, row, this.preEditRows.get(recordKey)));
|
|
1135
|
+
this.saveLoading = false;
|
|
1136
|
+
if (res === false) {
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
this.actions.cancelEditable(recordKey, row);
|
|
1140
|
+
} catch (err) {
|
|
1141
|
+
this.saveLoading = false;
|
|
1142
|
+
console.error('err', err);
|
|
1143
|
+
}
|
|
1144
|
+
},
|
|
1145
|
+
/**
|
|
1146
|
+
* @desc 删除
|
|
1147
|
+
*/
|
|
1148
|
+
async delete() {
|
|
1149
|
+
try {
|
|
1150
|
+
var _this$editable$onDele, _this$editable2;
|
|
1151
|
+
this.deleteLoading = true;
|
|
1152
|
+
const {
|
|
1153
|
+
scope: {
|
|
1154
|
+
row
|
|
1155
|
+
},
|
|
1156
|
+
recordKey
|
|
1157
|
+
} = this;
|
|
1158
|
+
const res = await ((_this$editable$onDele = (_this$editable2 = this.editable).onDelete) === null || _this$editable$onDele === void 0 ? void 0 : _this$editable$onDele.call(_this$editable2, recordKey, row));
|
|
1159
|
+
this.deleteLoading = false;
|
|
1160
|
+
if (res === false) {
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
this.visible = false;
|
|
1164
|
+
await this.actions.cancelEditable(recordKey, row);
|
|
1165
|
+
this.$emit('delete', recordKey);
|
|
1166
|
+
} catch (err) {
|
|
1167
|
+
this.deleteLoading = false;
|
|
1168
|
+
console.error('err', err);
|
|
1169
|
+
}
|
|
1170
|
+
},
|
|
1171
|
+
/**
|
|
1172
|
+
* @desc 取消
|
|
1173
|
+
*/
|
|
1174
|
+
async cancel() {
|
|
1175
|
+
try {
|
|
1176
|
+
// 手动销毁
|
|
1177
|
+
this.visible = false;
|
|
1178
|
+
const {
|
|
1179
|
+
recordKey,
|
|
1180
|
+
scope: {
|
|
1181
|
+
row,
|
|
1182
|
+
$index
|
|
1183
|
+
}
|
|
1184
|
+
} = this;
|
|
1185
|
+
await this.actions.cancelEditable(recordKey, row);
|
|
1186
|
+
this.$emit('cancel', recordKey, $index);
|
|
1187
|
+
} catch (err) {
|
|
1188
|
+
console.error('err', err);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1192
|
+
render: function (h) {
|
|
1193
|
+
const {
|
|
1194
|
+
saveText,
|
|
1195
|
+
deleteText,
|
|
1196
|
+
cancelText,
|
|
1197
|
+
deletePopconfirmMessage
|
|
1198
|
+
} = this.editable;
|
|
1199
|
+
const {
|
|
1200
|
+
defaultSize
|
|
1201
|
+
} = this;
|
|
1202
|
+
const doms = {
|
|
1203
|
+
save: h("el-button", {
|
|
1204
|
+
"class": "btn-save",
|
|
1205
|
+
"attrs": {
|
|
1206
|
+
"type": "text",
|
|
1207
|
+
"size": defaultSize,
|
|
1208
|
+
"loading": this.saveLoading
|
|
1209
|
+
},
|
|
1210
|
+
"on": {
|
|
1211
|
+
"click": this.save
|
|
1212
|
+
},
|
|
1213
|
+
"key": "save"
|
|
1214
|
+
}, [saveText]),
|
|
1215
|
+
delete: h("el-popover", {
|
|
1216
|
+
"attrs": {
|
|
1217
|
+
"placement": "top",
|
|
1218
|
+
"popper-class": "editable-pro-table__popover--delete",
|
|
1219
|
+
"trigger": "click",
|
|
1220
|
+
"value": this.visible
|
|
1221
|
+
},
|
|
1222
|
+
"on": {
|
|
1223
|
+
"input": val => this.visible = val
|
|
1224
|
+
},
|
|
1225
|
+
"key": "delete"
|
|
1226
|
+
}, [h("i", {
|
|
1227
|
+
"class": "el-icon-info"
|
|
1228
|
+
}), h("span", [deletePopconfirmMessage]), h("div", [h("el-button", {
|
|
1229
|
+
"attrs": {
|
|
1230
|
+
"size": "mini",
|
|
1231
|
+
"type": "text"
|
|
1232
|
+
},
|
|
1233
|
+
"on": {
|
|
1234
|
+
"click": () => this.visible = false
|
|
1235
|
+
}
|
|
1236
|
+
}, [Object(locale_["t"])('elProComponents.editableProTable.cancelButtonText')]), h("el-button", {
|
|
1237
|
+
"attrs": {
|
|
1238
|
+
"type": "primary",
|
|
1239
|
+
"size": "mini",
|
|
1240
|
+
"loading": this.deleteLoading
|
|
1241
|
+
},
|
|
1242
|
+
"on": {
|
|
1243
|
+
"click": this.delete
|
|
1244
|
+
}
|
|
1245
|
+
}, [Object(locale_["t"])('elProComponents.editableProTable.confirmButtonText')])]), h("el-button", {
|
|
1246
|
+
"slot": "reference",
|
|
1247
|
+
"attrs": {
|
|
1248
|
+
"type": "text",
|
|
1249
|
+
"size": defaultSize
|
|
1250
|
+
}
|
|
1251
|
+
}, [deleteText])]),
|
|
1252
|
+
cancel: h("el-button", {
|
|
1253
|
+
"class": "btn-cancel",
|
|
1254
|
+
"attrs": {
|
|
1255
|
+
"type": "text",
|
|
1256
|
+
"size": defaultSize
|
|
1257
|
+
},
|
|
1258
|
+
"on": {
|
|
1259
|
+
"click": this.cancel
|
|
1260
|
+
},
|
|
1261
|
+
"key": "cancel"
|
|
1262
|
+
}, [cancelText])
|
|
1263
|
+
};
|
|
1264
|
+
const {
|
|
1265
|
+
editable: {
|
|
1266
|
+
editableKeys,
|
|
1267
|
+
onChange,
|
|
1268
|
+
onSave,
|
|
1269
|
+
onDelete,
|
|
1270
|
+
onCancel,
|
|
1271
|
+
actionRender
|
|
1272
|
+
},
|
|
1273
|
+
scope: {
|
|
1274
|
+
row
|
|
1275
|
+
},
|
|
1276
|
+
isNewLineRecordCache
|
|
1277
|
+
} = this;
|
|
1278
|
+
const {
|
|
1279
|
+
recordKey,
|
|
1280
|
+
scope: {
|
|
1281
|
+
$index
|
|
1282
|
+
},
|
|
1283
|
+
actions: {
|
|
1284
|
+
cancelEditable,
|
|
1285
|
+
addEditRecord
|
|
1286
|
+
},
|
|
1287
|
+
name,
|
|
1288
|
+
newLineRecordCache
|
|
1289
|
+
} = this;
|
|
1290
|
+
const config = {
|
|
1291
|
+
editableKeys,
|
|
1292
|
+
setEditableRowKeys: keys => onChange === null || onChange === void 0 ? void 0 : onChange(keys),
|
|
1293
|
+
recordKey,
|
|
1294
|
+
preEditRow: this.preEditRows.get(recordKey),
|
|
1295
|
+
index: $index,
|
|
1296
|
+
onSave,
|
|
1297
|
+
onDelete,
|
|
1298
|
+
onCancel,
|
|
1299
|
+
cancelEditable,
|
|
1300
|
+
newLineConfig: newLineRecordCache,
|
|
1301
|
+
saveText,
|
|
1302
|
+
deleteText,
|
|
1303
|
+
cancelText,
|
|
1304
|
+
deletePopconfirmMessage,
|
|
1305
|
+
addEditRecord,
|
|
1306
|
+
tableName: name
|
|
1307
|
+
};
|
|
1308
|
+
const defaultDoms = [doms.save, !isNewLineRecordCache && doms.delete, doms.cancel].filter(Boolean);
|
|
1309
|
+
const actionDoms = typeof actionRender === 'function' ? actionRender(row, config, doms) : defaultDoms;
|
|
1310
|
+
return h("Fragment", [this.isEditable ? actionDoms : this.render(this.actions)]);
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/Editable.vue?vue&type=script&lang=js
|
|
1314
|
+
/* harmony default export */ var components_Editablevue_type_script_lang_js = (Editablevue_type_script_lang_js);
|
|
1315
|
+
// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/less-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/Editable.vue?vue&type=style&index=0&id=7488f54c&prod&scoped=true&lang=css
|
|
1316
|
+
// extracted by mini-css-extract-plugin
|
|
1317
|
+
|
|
1318
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/Editable.vue?vue&type=style&index=0&id=7488f54c&prod&scoped=true&lang=css
|
|
1319
|
+
|
|
1320
|
+
// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/less-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/components/Editable.vue?vue&type=style&index=1&id=7488f54c&prod&lang=less
|
|
1321
|
+
// extracted by mini-css-extract-plugin
|
|
1322
|
+
|
|
1323
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/Editable.vue?vue&type=style&index=1&id=7488f54c&prod&lang=less
|
|
1324
|
+
|
|
1325
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/components/Editable.vue
|
|
1326
|
+
var Editable_render, Editable_staticRenderFns
|
|
1327
|
+
|
|
1328
|
+
|
|
1329
|
+
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
/* normalize component */
|
|
1334
|
+
|
|
1335
|
+
var Editable_component = Object(componentNormalizer["a" /* default */])(
|
|
1336
|
+
components_Editablevue_type_script_lang_js,
|
|
1337
|
+
Editable_render,
|
|
1338
|
+
Editable_staticRenderFns,
|
|
1339
|
+
false,
|
|
1340
|
+
null,
|
|
1341
|
+
"7488f54c",
|
|
1342
|
+
null
|
|
1343
|
+
|
|
1344
|
+
)
|
|
1345
|
+
|
|
1346
|
+
/* harmony default export */ var Editable = (Editable_component.exports);
|
|
1347
|
+
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/index.vue?vue&type=script&lang=js
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
/* harmony default export */ var srcvue_type_script_lang_js = ({
|
|
1355
|
+
name: 'EditableProTable',
|
|
1356
|
+
components: {
|
|
1357
|
+
ElTablePrepend: external_el_table_prepend_default.a,
|
|
1358
|
+
RecordCreator: RecordCreator,
|
|
1359
|
+
CustomRender: custom_render["a" /* default */],
|
|
1360
|
+
RenderCell: RenderCell,
|
|
1361
|
+
Editable: Editable
|
|
1362
|
+
},
|
|
1363
|
+
// 组件外 el-form 的引用
|
|
1364
|
+
inject: {
|
|
1365
|
+
formRef: {
|
|
1366
|
+
from: 'elForm',
|
|
1367
|
+
default: null
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
props: {
|
|
1371
|
+
// el-table 的数据
|
|
1372
|
+
dataSource: {
|
|
1373
|
+
type: Array,
|
|
1374
|
+
required: true,
|
|
1375
|
+
default: () => []
|
|
1376
|
+
},
|
|
1377
|
+
// 新建一行数据的相关配置
|
|
1378
|
+
recordCreatorProps: {
|
|
1379
|
+
type: [Boolean, Object],
|
|
1380
|
+
default: true
|
|
1381
|
+
},
|
|
1382
|
+
// 最大的行数
|
|
1383
|
+
maxLength: {
|
|
1384
|
+
type: Number
|
|
1385
|
+
},
|
|
1386
|
+
// 可编辑表格的相关配置
|
|
1387
|
+
editable: {
|
|
1388
|
+
type: Object
|
|
1389
|
+
},
|
|
1390
|
+
// 行数据的 Key
|
|
1391
|
+
rowKey: {
|
|
1392
|
+
type: String
|
|
1393
|
+
},
|
|
1394
|
+
// 表格名称
|
|
1395
|
+
name: {
|
|
1396
|
+
type: String,
|
|
1397
|
+
default: 'dataSource'
|
|
1398
|
+
},
|
|
1399
|
+
// el-table 的类名
|
|
1400
|
+
className: {
|
|
1401
|
+
type: String
|
|
1402
|
+
},
|
|
1403
|
+
// 加载中
|
|
1404
|
+
loading: {
|
|
1405
|
+
type: Boolean
|
|
1406
|
+
},
|
|
1407
|
+
// el-table attributes 的配置
|
|
1408
|
+
tableProps: {
|
|
1409
|
+
type: Object
|
|
1410
|
+
},
|
|
1411
|
+
// el-table events 的配置
|
|
1412
|
+
tableEvents: {
|
|
1413
|
+
type: Object
|
|
1414
|
+
},
|
|
1415
|
+
// 列定义
|
|
1416
|
+
columns: {
|
|
1417
|
+
type: Array,
|
|
1418
|
+
required: true,
|
|
1419
|
+
default: () => []
|
|
1420
|
+
},
|
|
1421
|
+
// 默认的 size
|
|
1422
|
+
defaultSize: {
|
|
1423
|
+
type: String,
|
|
1424
|
+
validator: function (value) {
|
|
1425
|
+
return ['medium', 'small', 'mini'].includes(value);
|
|
1426
|
+
}
|
|
1427
|
+
},
|
|
1428
|
+
// 固定列是否使用 position: sticky 实现
|
|
1429
|
+
sticky: {
|
|
1430
|
+
type: Boolean,
|
|
1431
|
+
default: true
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
computed: {
|
|
1435
|
+
getDynamicProps() {
|
|
1436
|
+
const {
|
|
1437
|
+
formRef,
|
|
1438
|
+
form,
|
|
1439
|
+
defaultSize
|
|
1440
|
+
} = this;
|
|
1441
|
+
if (!formRef) {
|
|
1442
|
+
return {
|
|
1443
|
+
ref: 'formRef',
|
|
1444
|
+
model: form,
|
|
1445
|
+
size: defaultSize
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
return;
|
|
1449
|
+
},
|
|
1450
|
+
// recordCreatorProps 初始化
|
|
1451
|
+
initializedCreatorProps() {
|
|
1452
|
+
const {
|
|
1453
|
+
recordCreatorProps
|
|
1454
|
+
} = this;
|
|
1455
|
+
if (recordCreatorProps) {
|
|
1456
|
+
const defaultRecordCreatorProps = {
|
|
1457
|
+
position: 'bottom',
|
|
1458
|
+
newRecordType: 'cache',
|
|
1459
|
+
creatorButtonText: Object(locale_["t"])('elProComponents.editableProTable.add'),
|
|
1460
|
+
onlyAddOneLineAlertMessage: Object(locale_["t"])('elProComponents.editableProTable.onlyAddOneLine')
|
|
1461
|
+
};
|
|
1462
|
+
if (typeof recordCreatorProps === 'object') {
|
|
1463
|
+
return {
|
|
1464
|
+
...defaultRecordCreatorProps,
|
|
1465
|
+
...recordCreatorProps
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
return defaultRecordCreatorProps;
|
|
1469
|
+
}
|
|
1470
|
+
return false;
|
|
1471
|
+
},
|
|
1472
|
+
// 是否超过了最大的行数
|
|
1473
|
+
exceedsMax() {
|
|
1474
|
+
const {
|
|
1475
|
+
maxLength
|
|
1476
|
+
} = this;
|
|
1477
|
+
if (typeof maxLength === 'number') {
|
|
1478
|
+
return this.form[this.name].length >= maxLength;
|
|
1479
|
+
}
|
|
1480
|
+
return false;
|
|
1481
|
+
},
|
|
1482
|
+
// editable 初始化
|
|
1483
|
+
initializedEditable() {
|
|
1484
|
+
const defaultEditable = {
|
|
1485
|
+
type: 'single',
|
|
1486
|
+
saveText: Object(locale_["t"])('elProComponents.editableProTable.save'),
|
|
1487
|
+
deleteText: Object(locale_["t"])('elProComponents.editableProTable.delete'),
|
|
1488
|
+
cancelText: Object(locale_["t"])('elProComponents.editableProTable.cancel'),
|
|
1489
|
+
deletePopconfirmMessage: Object(locale_["t"])('elProComponents.editableProTable.deleteThisLine'),
|
|
1490
|
+
onlyOneLineEditorAlertMessage: Object(locale_["t"])('elProComponents.editableProTable.onlyOneLineEditor')
|
|
1491
|
+
};
|
|
1492
|
+
return {
|
|
1493
|
+
...defaultEditable,
|
|
1494
|
+
...this.editable
|
|
1495
|
+
};
|
|
1496
|
+
},
|
|
1497
|
+
// tableProps 初始化
|
|
1498
|
+
initializedTableProps() {
|
|
1499
|
+
const {
|
|
1500
|
+
rowKey,
|
|
1501
|
+
tableProps = {},
|
|
1502
|
+
defaultSize: size
|
|
1503
|
+
} = this;
|
|
1504
|
+
return {
|
|
1505
|
+
...tableProps,
|
|
1506
|
+
rowKey,
|
|
1507
|
+
size,
|
|
1508
|
+
'cell-style': data => this.getCellStyle(data, tableProps['cell-style']),
|
|
1509
|
+
'header-cell-style': data => this.getCellStyle(data, tableProps['header-cell-style'])
|
|
1510
|
+
};
|
|
1511
|
+
},
|
|
1512
|
+
// columns 初始化
|
|
1513
|
+
initializedColumns() {
|
|
1514
|
+
return this.columns.filter(item => !item.hideInTable);
|
|
1515
|
+
},
|
|
1516
|
+
// 计算定位的偏移
|
|
1517
|
+
calculateOffset() {
|
|
1518
|
+
const offset = {};
|
|
1519
|
+
const {
|
|
1520
|
+
initializedColumns,
|
|
1521
|
+
sticky
|
|
1522
|
+
} = this;
|
|
1523
|
+
let totalLeftOffset = 0;
|
|
1524
|
+
let leftIndex = -1;
|
|
1525
|
+
for (let i = 0; i < initializedColumns.length; i++) {
|
|
1526
|
+
const col = initializedColumns[i];
|
|
1527
|
+
const isSticky = sticky !== false && col.fixed === 'left';
|
|
1528
|
+
if (isSticky) {
|
|
1529
|
+
leftIndex = i;
|
|
1530
|
+
offset[i] = totalLeftOffset;
|
|
1531
|
+
totalLeftOffset += col.width || col.minWidth;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
let totalRightOffset = 0;
|
|
1535
|
+
let rightIndex = -1;
|
|
1536
|
+
for (let i = initializedColumns.length - 1; i >= 0; i--) {
|
|
1537
|
+
const col = initializedColumns[i];
|
|
1538
|
+
const isSticky = sticky !== false && col.fixed === 'right';
|
|
1539
|
+
if (isSticky) {
|
|
1540
|
+
rightIndex = i;
|
|
1541
|
+
offset[i] = totalRightOffset;
|
|
1542
|
+
totalRightOffset += col.width || col.minWidth;
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
return {
|
|
1546
|
+
offset,
|
|
1547
|
+
leftIndex,
|
|
1548
|
+
rightIndex
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
},
|
|
1552
|
+
data() {
|
|
1553
|
+
return {
|
|
1554
|
+
cachedOptions: {},
|
|
1555
|
+
// 下拉数据 { [prop]: data }
|
|
1556
|
+
form: {
|
|
1557
|
+
[this.name]: this.dataSource
|
|
1558
|
+
},
|
|
1559
|
+
newLineRecordCache: undefined,
|
|
1560
|
+
// 新增一行草稿数据
|
|
1561
|
+
preEditRows: new Map() // 编辑前行数据
|
|
1562
|
+
};
|
|
1563
|
+
},
|
|
1564
|
+
created() {
|
|
1565
|
+
// 获取异步数据
|
|
1566
|
+
this.getOptions();
|
|
1567
|
+
},
|
|
1568
|
+
watch: {
|
|
1569
|
+
// 监听元数据变化
|
|
1570
|
+
dataSource(newValue) {
|
|
1571
|
+
this.form[this.name] = newValue;
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
methods: {
|
|
1575
|
+
/**
|
|
1576
|
+
* @desc 获取异步下拉数据
|
|
1577
|
+
*/
|
|
1578
|
+
getOptions() {
|
|
1579
|
+
for (const item of this.columns) {
|
|
1580
|
+
const {
|
|
1581
|
+
prop,
|
|
1582
|
+
optionLoader
|
|
1583
|
+
} = item;
|
|
1584
|
+
if (typeof optionLoader === 'function') {
|
|
1585
|
+
optionLoader().then(res => {
|
|
1586
|
+
this.cachedOptions = {
|
|
1587
|
+
...this.cachedOptions,
|
|
1588
|
+
[prop]: res
|
|
1589
|
+
};
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
},
|
|
1594
|
+
/**
|
|
1595
|
+
* @desc 初始化表单字段
|
|
1596
|
+
*/
|
|
1597
|
+
getInitialValues() {
|
|
1598
|
+
return this.initializedColumns.reduce((accu, cur) => {
|
|
1599
|
+
const {
|
|
1600
|
+
prop
|
|
1601
|
+
} = cur;
|
|
1602
|
+
if (!prop) {
|
|
1603
|
+
return accu;
|
|
1604
|
+
}
|
|
1605
|
+
return {
|
|
1606
|
+
...accu,
|
|
1607
|
+
[prop]: undefined
|
|
1608
|
+
};
|
|
1609
|
+
}, {});
|
|
1610
|
+
},
|
|
1611
|
+
/**
|
|
1612
|
+
* 新增一行的方法
|
|
1613
|
+
* @param record 数据
|
|
1614
|
+
* @param newLine 新增一行的配置
|
|
1615
|
+
*/
|
|
1616
|
+
addEditRecord(record, newLine) {
|
|
1617
|
+
var _record;
|
|
1618
|
+
const {
|
|
1619
|
+
initializedCreatorProps: {
|
|
1620
|
+
onlyAddOneLineAlertMessage
|
|
1621
|
+
}
|
|
1622
|
+
} = this;
|
|
1623
|
+
// 只能新增一行校验
|
|
1624
|
+
if (this.newLineRecordCache) {
|
|
1625
|
+
this.$message.warning(onlyAddOneLineAlertMessage);
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
// 只能同时编辑一行校验
|
|
1630
|
+
if (!this.validateCanStartEdit()) {
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
const {
|
|
1634
|
+
form,
|
|
1635
|
+
name,
|
|
1636
|
+
rowKey
|
|
1637
|
+
} = this;
|
|
1638
|
+
const {
|
|
1639
|
+
initializedCreatorProps: {
|
|
1640
|
+
position,
|
|
1641
|
+
newRecordType,
|
|
1642
|
+
record: defaultRecord
|
|
1643
|
+
}
|
|
1644
|
+
} = this;
|
|
1645
|
+
const dataSource = form[name];
|
|
1646
|
+
const newLineConfig = {
|
|
1647
|
+
position,
|
|
1648
|
+
newRecordType,
|
|
1649
|
+
...(newLine || {})
|
|
1650
|
+
};
|
|
1651
|
+
const index = newLineConfig.position === 'top' ? dataSource.length : 0;
|
|
1652
|
+
record = (_record = record) !== null && _record !== void 0 ? _record : defaultRecord;
|
|
1653
|
+
const newRecord = {
|
|
1654
|
+
...this.getInitialValues(),
|
|
1655
|
+
...(typeof record === 'function' ? record(index, dataSource) : record)
|
|
1656
|
+
};
|
|
1657
|
+
if (!newRecord[rowKey]) {
|
|
1658
|
+
console.error('Error: 请设置 recordCreatorProps.record 并返回一个唯一的key');
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
// 记录缓存数据
|
|
1663
|
+
if (newLineConfig.newRecordType !== 'dataSource') {
|
|
1664
|
+
this.newLineRecordCache = {
|
|
1665
|
+
// 深拷贝防止引用
|
|
1666
|
+
defaultValue: JSON.parse(JSON.stringify(newRecord)),
|
|
1667
|
+
options: {
|
|
1668
|
+
...newLineConfig,
|
|
1669
|
+
recordKey: newRecord[rowKey]
|
|
1670
|
+
}
|
|
1671
|
+
};
|
|
1672
|
+
} else {
|
|
1673
|
+
this.newLineRecordCache = undefined;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
// 插入数据
|
|
1677
|
+
if (newLineConfig.position === 'top') {
|
|
1678
|
+
dataSource.unshift(newRecord);
|
|
1679
|
+
} else {
|
|
1680
|
+
dataSource.push(newRecord);
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
// 更新 editableKeys
|
|
1684
|
+
const {
|
|
1685
|
+
initializedEditable: {
|
|
1686
|
+
editableKeys,
|
|
1687
|
+
onChange
|
|
1688
|
+
}
|
|
1689
|
+
} = this;
|
|
1690
|
+
const newKeys = [...editableKeys, newRecord[rowKey]];
|
|
1691
|
+
const editableRows = dataSource.filter(item => editableKeys.includes(item[rowKey]));
|
|
1692
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newKeys, editableRows);
|
|
1693
|
+
},
|
|
1694
|
+
/**
|
|
1695
|
+
* @desc 获取 column 配置
|
|
1696
|
+
* @param col 列
|
|
1697
|
+
*/
|
|
1698
|
+
getColumnProps(col, index) {
|
|
1699
|
+
// 筛选 el-column 属性
|
|
1700
|
+
const {
|
|
1701
|
+
formItemProps,
|
|
1702
|
+
renderLabel,
|
|
1703
|
+
valueType,
|
|
1704
|
+
renderField,
|
|
1705
|
+
fieldProps,
|
|
1706
|
+
fieldEvents,
|
|
1707
|
+
options,
|
|
1708
|
+
valueEnum,
|
|
1709
|
+
optionLoader,
|
|
1710
|
+
renderCellHeader,
|
|
1711
|
+
renderCell,
|
|
1712
|
+
editable,
|
|
1713
|
+
readonly,
|
|
1714
|
+
key,
|
|
1715
|
+
...keys
|
|
1716
|
+
} = col;
|
|
1717
|
+
const {
|
|
1718
|
+
sticky
|
|
1719
|
+
} = this;
|
|
1720
|
+
const getStickyClassName = (fixed, sticky) => {
|
|
1721
|
+
if (!sticky) return '';
|
|
1722
|
+
if (fixed === 'left') return 'editable-pro-table__fixed-left';
|
|
1723
|
+
if (fixed === 'right') return 'editable-pro-table__fixed-right';
|
|
1724
|
+
return '';
|
|
1725
|
+
};
|
|
1726
|
+
let className = col['class-name'] || '';
|
|
1727
|
+
if (col.fixed && sticky) {
|
|
1728
|
+
className += ' ' + getStickyClassName(col.fixed, sticky);
|
|
1729
|
+
}
|
|
1730
|
+
if (this.calculateOffset.leftIndex === index) {
|
|
1731
|
+
className += ' ' + 'editable-pro-table__fixed-start-shadow';
|
|
1732
|
+
} else if (this.calculateOffset.rightIndex === index) {
|
|
1733
|
+
className += ' ' + 'editable-pro-table__fixed-end-shadow';
|
|
1734
|
+
}
|
|
1735
|
+
return {
|
|
1736
|
+
...keys,
|
|
1737
|
+
fixed: col.fixed && sticky ? undefined : col.fixed,
|
|
1738
|
+
'class-name': className
|
|
1739
|
+
};
|
|
1740
|
+
},
|
|
1741
|
+
/**
|
|
1742
|
+
* @desc 获取待校验的字段
|
|
1743
|
+
* @param index 下标
|
|
1744
|
+
* @returns {Array}
|
|
1745
|
+
*/
|
|
1746
|
+
getValidateFields(index) {
|
|
1747
|
+
return this.columns.filter(item => item.valueType && item.valueType !== 'option' || item.renderField).map(item => `${this.name}.${index}.${item.prop}`);
|
|
1748
|
+
},
|
|
1749
|
+
/**
|
|
1750
|
+
* @desc 校验行
|
|
1751
|
+
* @param index 下标
|
|
1752
|
+
*/
|
|
1753
|
+
validateRow(index) {
|
|
1754
|
+
return new Promise(async resolve => {
|
|
1755
|
+
const fields = this.getValidateFields(index);
|
|
1756
|
+
const promises = fields.map(field => new Promise(resolve => {
|
|
1757
|
+
var _this$getFormRef;
|
|
1758
|
+
(_this$getFormRef = this.getFormRef()) === null || _this$getFormRef === void 0 ? void 0 : _this$getFormRef.validateField(field, error => {
|
|
1759
|
+
resolve(!error);
|
|
1760
|
+
});
|
|
1761
|
+
}));
|
|
1762
|
+
const res = await Promise.all(promises);
|
|
1763
|
+
resolve(!res.some(item => !item));
|
|
1764
|
+
});
|
|
1765
|
+
},
|
|
1766
|
+
/**
|
|
1767
|
+
* @desc 验证是否可以开始编辑
|
|
1768
|
+
* @returns {Boolean}
|
|
1769
|
+
*/
|
|
1770
|
+
validateCanStartEdit() {
|
|
1771
|
+
const {
|
|
1772
|
+
initializedEditable: {
|
|
1773
|
+
type,
|
|
1774
|
+
editableKeys,
|
|
1775
|
+
onlyOneLineEditorAlertMessage
|
|
1776
|
+
}
|
|
1777
|
+
} = this;
|
|
1778
|
+
if (editableKeys.length && type === 'single') {
|
|
1779
|
+
this.$message.warning(onlyOneLineEditorAlertMessage);
|
|
1780
|
+
return false;
|
|
1781
|
+
}
|
|
1782
|
+
return true;
|
|
1783
|
+
},
|
|
1784
|
+
/**
|
|
1785
|
+
* @desc 退出编辑
|
|
1786
|
+
* @param recordKey
|
|
1787
|
+
*/
|
|
1788
|
+
clearEditableState(recordKey) {
|
|
1789
|
+
const {
|
|
1790
|
+
initializedEditable: {
|
|
1791
|
+
editableKeys,
|
|
1792
|
+
onChange
|
|
1793
|
+
}
|
|
1794
|
+
} = this;
|
|
1795
|
+
if (!editableKeys.includes(recordKey)) {
|
|
1796
|
+
return true;
|
|
1797
|
+
}
|
|
1798
|
+
const newKeys = editableKeys.filter(item => item !== recordKey);
|
|
1799
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newKeys);
|
|
1800
|
+
},
|
|
1801
|
+
/**
|
|
1802
|
+
* @desc 清除新增行缓存
|
|
1803
|
+
* @param recordKey
|
|
1804
|
+
*/
|
|
1805
|
+
clearNewLineCache(recordKey) {
|
|
1806
|
+
var _this$newLineRecordCa;
|
|
1807
|
+
if (((_this$newLineRecordCa = this.newLineRecordCache) === null || _this$newLineRecordCa === void 0 ? void 0 : _this$newLineRecordCa.options.recordKey) === recordKey) {
|
|
1808
|
+
this.newLineRecordCache = null;
|
|
1809
|
+
}
|
|
1810
|
+
},
|
|
1811
|
+
/**
|
|
1812
|
+
* @desc 取消编辑
|
|
1813
|
+
* @param {String | Number} recordKey 值
|
|
1814
|
+
* @param {Object} editRow 行数据
|
|
1815
|
+
* @param {Object} originRow 初始行数据
|
|
1816
|
+
*/
|
|
1817
|
+
async cancelEditable(recordKey, editRow) {
|
|
1818
|
+
try {
|
|
1819
|
+
var _this$editable$onCanc, _this$editable;
|
|
1820
|
+
const originRow = this.preEditRows.get(recordKey);
|
|
1821
|
+
await ((_this$editable$onCanc = (_this$editable = this.editable).onCancel) === null || _this$editable$onCanc === void 0 ? void 0 : _this$editable$onCanc.call(_this$editable, recordKey, editRow, originRow));
|
|
1822
|
+
|
|
1823
|
+
// 退出编辑
|
|
1824
|
+
this.clearEditableState(recordKey);
|
|
1825
|
+
|
|
1826
|
+
// 清除新增行缓存
|
|
1827
|
+
this.clearNewLineCache(recordKey);
|
|
1828
|
+
} catch (err) {
|
|
1829
|
+
console.error('err', err);
|
|
1830
|
+
}
|
|
1831
|
+
return true;
|
|
1832
|
+
},
|
|
1833
|
+
/**
|
|
1834
|
+
* @desc 查找行数据
|
|
1835
|
+
* @param recordKey
|
|
1836
|
+
*/
|
|
1837
|
+
findRecordByKey(recordKey) {
|
|
1838
|
+
const dataSource = this.form[this.name];
|
|
1839
|
+
const record = dataSource.find(item => item[this.rowKey] === recordKey);
|
|
1840
|
+
return JSON.parse(JSON.stringify(record));
|
|
1841
|
+
},
|
|
1842
|
+
/**
|
|
1843
|
+
* @desc 开始编辑指定字段
|
|
1844
|
+
* @param {String | Number} recordKey 值
|
|
1845
|
+
* @returns {Boolean}
|
|
1846
|
+
*/
|
|
1847
|
+
startEditable(recordKey) {
|
|
1848
|
+
if (!this.validateCanStartEdit()) {
|
|
1849
|
+
return false;
|
|
1850
|
+
}
|
|
1851
|
+
const {
|
|
1852
|
+
initializedEditable: {
|
|
1853
|
+
editableKeys,
|
|
1854
|
+
onChange
|
|
1855
|
+
}
|
|
1856
|
+
} = this;
|
|
1857
|
+
const isAlreadyEditable = editableKeys === null || editableKeys === void 0 ? void 0 : editableKeys.some(key => key === recordKey);
|
|
1858
|
+
if (!isAlreadyEditable) {
|
|
1859
|
+
onChange === null || onChange === void 0 ? void 0 : onChange([...editableKeys, recordKey]);
|
|
1860
|
+
// 更新 preEditRows
|
|
1861
|
+
this.preEditRows.set(recordKey, this.findRecordByKey(recordKey));
|
|
1862
|
+
}
|
|
1863
|
+
return true;
|
|
1864
|
+
},
|
|
1865
|
+
/**
|
|
1866
|
+
* @desc 删除
|
|
1867
|
+
* @param recordKey
|
|
1868
|
+
*/
|
|
1869
|
+
filterByRecordKey(recordKey) {
|
|
1870
|
+
const {
|
|
1871
|
+
form,
|
|
1872
|
+
name,
|
|
1873
|
+
rowKey
|
|
1874
|
+
} = this;
|
|
1875
|
+
const dataSource = form[name];
|
|
1876
|
+
const index = dataSource.findIndex(item => item[rowKey] === recordKey);
|
|
1877
|
+
if (index !== -1) {
|
|
1878
|
+
dataSource.splice(index, 1);
|
|
1879
|
+
}
|
|
1880
|
+
},
|
|
1881
|
+
/**
|
|
1882
|
+
* @desc 取消
|
|
1883
|
+
* @param recordKey
|
|
1884
|
+
* @param index
|
|
1885
|
+
*/
|
|
1886
|
+
deleteOrResetRow(recordKey, index) {
|
|
1887
|
+
const {
|
|
1888
|
+
initializedCreatorProps: {
|
|
1889
|
+
newRecordType
|
|
1890
|
+
}
|
|
1891
|
+
} = this;
|
|
1892
|
+
const preEditRow = this.preEditRows.get(recordKey);
|
|
1893
|
+
if (preEditRow) {
|
|
1894
|
+
// 重置为默认值
|
|
1895
|
+
const {
|
|
1896
|
+
form,
|
|
1897
|
+
name,
|
|
1898
|
+
rowKey
|
|
1899
|
+
} = this;
|
|
1900
|
+
const dataSource = form[name];
|
|
1901
|
+
const index = dataSource.findIndex(item => item[rowKey] === recordKey);
|
|
1902
|
+
if (index !== -1) {
|
|
1903
|
+
dataSource.splice(index, 1, preEditRow);
|
|
1904
|
+
}
|
|
1905
|
+
} else {
|
|
1906
|
+
if (newRecordType !== 'dataSource') {
|
|
1907
|
+
// 没有历史值 则删除
|
|
1908
|
+
this.filterByRecordKey(recordKey);
|
|
1909
|
+
} else {
|
|
1910
|
+
// 重置为新增的初始值
|
|
1911
|
+
const {
|
|
1912
|
+
initializedCreatorProps: {
|
|
1913
|
+
record
|
|
1914
|
+
},
|
|
1915
|
+
form,
|
|
1916
|
+
name,
|
|
1917
|
+
rowKey
|
|
1918
|
+
} = this;
|
|
1919
|
+
const dataSource = form[name];
|
|
1920
|
+
const newRecord = {
|
|
1921
|
+
...this.getInitialValues(),
|
|
1922
|
+
...(typeof record === 'function' ? record(index, dataSource) : record)
|
|
1923
|
+
};
|
|
1924
|
+
// 防止 rowKey 覆盖
|
|
1925
|
+
delete newRecord[rowKey];
|
|
1926
|
+
this.setRowData(index, newRecord);
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
},
|
|
1930
|
+
/**
|
|
1931
|
+
* @desc 获取 form ref
|
|
1932
|
+
*/
|
|
1933
|
+
getFormRef() {
|
|
1934
|
+
return this.formRef || this.$refs.formRef;
|
|
1935
|
+
},
|
|
1936
|
+
/**
|
|
1937
|
+
* @desc 获取 table ref
|
|
1938
|
+
*/
|
|
1939
|
+
getTableRef() {
|
|
1940
|
+
return this.$refs.editableProTableRef;
|
|
1941
|
+
},
|
|
1942
|
+
/**
|
|
1943
|
+
* @desc 获取行数据
|
|
1944
|
+
*/
|
|
1945
|
+
getRowData(rowIndex) {
|
|
1946
|
+
const dataSource = this.form[this.name];
|
|
1947
|
+
if (typeof rowIndex === 'number' && rowIndex < dataSource.length) {
|
|
1948
|
+
return dataSource[rowIndex];
|
|
1949
|
+
} else {
|
|
1950
|
+
return dataSource.find(item => item[this.rowKey] === rowIndex);
|
|
1951
|
+
}
|
|
1952
|
+
},
|
|
1953
|
+
/**
|
|
1954
|
+
* @desc 获取整个 table 的数据
|
|
1955
|
+
*/
|
|
1956
|
+
getRowsData() {
|
|
1957
|
+
return this.form[this.name];
|
|
1958
|
+
},
|
|
1959
|
+
/**
|
|
1960
|
+
* @desc 设置一行的数据
|
|
1961
|
+
*/
|
|
1962
|
+
setRowData(rowIndex, data) {
|
|
1963
|
+
const dataSource = this.form[this.name];
|
|
1964
|
+
if (typeof rowIndex === 'number' && rowIndex < dataSource.length) {
|
|
1965
|
+
console.log({
|
|
1966
|
+
...dataSource[rowIndex],
|
|
1967
|
+
...data
|
|
1968
|
+
});
|
|
1969
|
+
dataSource.splice(rowIndex, 1, {
|
|
1970
|
+
...dataSource[rowIndex],
|
|
1971
|
+
...data
|
|
1972
|
+
});
|
|
1973
|
+
} else {
|
|
1974
|
+
const index = dataSource.findIndex(item => item[this.rowKey] === rowIndex);
|
|
1975
|
+
if (index !== -1) {
|
|
1976
|
+
dataSource.splice(index, 1, {
|
|
1977
|
+
...dataSource[index],
|
|
1978
|
+
...data
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
},
|
|
1983
|
+
/**
|
|
1984
|
+
* @desc cellStyle
|
|
1985
|
+
*/
|
|
1986
|
+
getCellStyle({
|
|
1987
|
+
row,
|
|
1988
|
+
column,
|
|
1989
|
+
rowIndex,
|
|
1990
|
+
columnIndex
|
|
1991
|
+
}, parentCellStyle) {
|
|
1992
|
+
const parentStyle = parentCellStyle === null || parentCellStyle === void 0 ? void 0 : parentCellStyle({
|
|
1993
|
+
row,
|
|
1994
|
+
column,
|
|
1995
|
+
rowIndex,
|
|
1996
|
+
columnIndex
|
|
1997
|
+
});
|
|
1998
|
+
const childStyle = this.getStickyStyle(columnIndex, this.initializedColumns[columnIndex].fixed);
|
|
1999
|
+
if (typeof parentStyle === 'string') {
|
|
2000
|
+
let cellStyleString = '';
|
|
2001
|
+
cellStyleString += parentStyle + ';';
|
|
2002
|
+
if (childStyle) {
|
|
2003
|
+
const childStyleString = Object.entries(childStyle).map(([key, value]) => {
|
|
2004
|
+
return `${key}: ${value};`;
|
|
2005
|
+
});
|
|
2006
|
+
cellStyleString += childStyleString;
|
|
2007
|
+
}
|
|
2008
|
+
return cellStyleString;
|
|
2009
|
+
}
|
|
2010
|
+
if (parentStyle instanceof Object) {
|
|
2011
|
+
return {
|
|
2012
|
+
...parentStyle,
|
|
2013
|
+
...(childStyle || {})
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
return childStyle;
|
|
2017
|
+
},
|
|
2018
|
+
/**
|
|
2019
|
+
* @desc 获取 sticky 的样式
|
|
2020
|
+
* @param {Number} index 下标
|
|
2021
|
+
* @param {String} fixed 固定位置
|
|
2022
|
+
*/
|
|
2023
|
+
getStickyStyle(index, fixed) {
|
|
2024
|
+
const offset = this.calculateOffset.offset[index];
|
|
2025
|
+
if (offset !== undefined) {
|
|
2026
|
+
return {
|
|
2027
|
+
[fixed]: `${offset}px`
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
return;
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/index.vue?vue&type=script&lang=js
|
|
2035
|
+
/* harmony default export */ var editable_pro_table_srcvue_type_script_lang_js = (srcvue_type_script_lang_js);
|
|
2036
|
+
// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/less-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/index.vue?vue&type=style&index=0&id=b4388ac0&prod&lang=less&scoped=true
|
|
2037
|
+
// extracted by mini-css-extract-plugin
|
|
2038
|
+
|
|
2039
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/index.vue?vue&type=style&index=0&id=b4388ac0&prod&lang=less&scoped=true
|
|
2040
|
+
|
|
2041
|
+
// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/less-loader/dist/cjs.js!./node_modules/vue-loader/lib??vue-loader-options!./packages/editable-pro-table/src/index.vue?vue&type=style&index=1&id=b4388ac0&prod&lang=less
|
|
2042
|
+
// extracted by mini-css-extract-plugin
|
|
2043
|
+
|
|
2044
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/index.vue?vue&type=style&index=1&id=b4388ac0&prod&lang=less
|
|
2045
|
+
|
|
2046
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/src/index.vue
|
|
2047
|
+
|
|
2048
|
+
|
|
2049
|
+
|
|
2050
|
+
|
|
2051
|
+
|
|
2052
|
+
|
|
2053
|
+
|
|
2054
|
+
/* normalize component */
|
|
2055
|
+
|
|
2056
|
+
var src_component = Object(componentNormalizer["a" /* default */])(
|
|
2057
|
+
editable_pro_table_srcvue_type_script_lang_js,
|
|
2058
|
+
render,
|
|
2059
|
+
staticRenderFns,
|
|
2060
|
+
false,
|
|
2061
|
+
null,
|
|
2062
|
+
"b4388ac0",
|
|
2063
|
+
null
|
|
2064
|
+
|
|
2065
|
+
)
|
|
2066
|
+
|
|
2067
|
+
/* harmony default export */ var src = (src_component.exports);
|
|
2068
|
+
// CONCATENATED MODULE: ./packages/editable-pro-table/index.js
|
|
2069
|
+
|
|
2070
|
+
|
|
2071
|
+
// 为组件提供 install 方法
|
|
2072
|
+
src.install = function (Vue) {
|
|
2073
|
+
Vue.component(src.name, src);
|
|
2074
|
+
};
|
|
2075
|
+
|
|
2076
|
+
// 默认导出组件
|
|
2077
|
+
/* harmony default export */ var editable_pro_table = __webpack_exports__["default"] = (src);
|
|
2078
|
+
|
|
2079
|
+
/***/ })
|
|
2080
|
+
/******/ ]);
|