@panpanzhao/component-ui 0.0.1
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/lib/component-ui.common.js +5689 -0
- package/lib/components/crud.js +2276 -0
- package/lib/components/form-dialog.js +1198 -0
- package/lib/components/form-group.js +883 -0
- package/lib/components/form-input.js +1571 -0
- package/lib/components/form-item.js +284 -0
- package/lib/components/form-view-dialog.js +963 -0
- package/lib/components/form-view-group.js +687 -0
- package/lib/components/form-view.js +409 -0
- package/lib/components/form.js +495 -0
- package/lib/components/table-column.js +1053 -0
- package/lib/components/table-editable.js +954 -0
- package/lib/components/table-search.js +407 -0
- package/lib/components/table.js +659 -0
- package/lib/index.js +1 -0
- package/lib/styles/component-ui.css +1 -0
- package/lib/styles/fonts/element-icons.ttf +0 -0
- package/lib/styles/fonts/element-icons.woff +0 -0
- package/lib/styles/form.css +1 -0
- package/lib/styles/index.css +1 -0
- package/lib/styles/table-editable.css +1 -0
- package/lib/styles/table.css +1 -0
- package/lib/utils/formula/evalutor.js +1883 -0
- package/lib/utils/formula/filter.js +48 -0
- package/lib/utils/formula/function.js +12 -0
- package/lib/utils/formula/index.js +25 -0
- package/lib/utils/formula/lexer.js +590 -0
- package/lib/utils/formula/parser.js +734 -0
- package/package.json +67 -0
|
@@ -0,0 +1,954 @@
|
|
|
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 = "/dist/";
|
|
82
|
+
/******/
|
|
83
|
+
/******/
|
|
84
|
+
/******/ // Load entry module and return exports
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 59);
|
|
86
|
+
/******/ })
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ ({
|
|
89
|
+
|
|
90
|
+
/***/ 0:
|
|
91
|
+
/***/ (function(module, exports) {
|
|
92
|
+
|
|
93
|
+
module.exports = require("@vue/babel-helper-vue-jsx-merge-props");
|
|
94
|
+
|
|
95
|
+
/***/ }),
|
|
96
|
+
|
|
97
|
+
/***/ 1:
|
|
98
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
99
|
+
|
|
100
|
+
"use strict";
|
|
101
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
|
|
102
|
+
/* globals __VUE_SSR_CONTEXT__ */
|
|
103
|
+
|
|
104
|
+
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
|
|
105
|
+
// This module is a runtime utility for cleaner component module output and will
|
|
106
|
+
// be included in the final webpack user bundle.
|
|
107
|
+
|
|
108
|
+
function normalizeComponent(
|
|
109
|
+
scriptExports,
|
|
110
|
+
render,
|
|
111
|
+
staticRenderFns,
|
|
112
|
+
functionalTemplate,
|
|
113
|
+
injectStyles,
|
|
114
|
+
scopeId,
|
|
115
|
+
moduleIdentifier /* server only */,
|
|
116
|
+
shadowMode /* vue-cli only */
|
|
117
|
+
) {
|
|
118
|
+
// Vue.extend constructor export interop
|
|
119
|
+
var options =
|
|
120
|
+
typeof scriptExports === 'function' ? scriptExports.options : scriptExports
|
|
121
|
+
|
|
122
|
+
// render functions
|
|
123
|
+
if (render) {
|
|
124
|
+
options.render = render
|
|
125
|
+
options.staticRenderFns = staticRenderFns
|
|
126
|
+
options._compiled = true
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// functional template
|
|
130
|
+
if (functionalTemplate) {
|
|
131
|
+
options.functional = true
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// scopedId
|
|
135
|
+
if (scopeId) {
|
|
136
|
+
options._scopeId = 'data-v-' + scopeId
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
var hook
|
|
140
|
+
if (moduleIdentifier) {
|
|
141
|
+
// server build
|
|
142
|
+
hook = function (context) {
|
|
143
|
+
// 2.3 injection
|
|
144
|
+
context =
|
|
145
|
+
context || // cached call
|
|
146
|
+
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
147
|
+
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
|
|
148
|
+
// 2.2 with runInNewContext: true
|
|
149
|
+
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
150
|
+
context = __VUE_SSR_CONTEXT__
|
|
151
|
+
}
|
|
152
|
+
// inject component styles
|
|
153
|
+
if (injectStyles) {
|
|
154
|
+
injectStyles.call(this, context)
|
|
155
|
+
}
|
|
156
|
+
// register component module identifier for async chunk inferrence
|
|
157
|
+
if (context && context._registeredComponents) {
|
|
158
|
+
context._registeredComponents.add(moduleIdentifier)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// used by ssr in case component is cached and beforeCreate
|
|
162
|
+
// never gets called
|
|
163
|
+
options._ssrRegister = hook
|
|
164
|
+
} else if (injectStyles) {
|
|
165
|
+
hook = shadowMode
|
|
166
|
+
? function () {
|
|
167
|
+
injectStyles.call(
|
|
168
|
+
this,
|
|
169
|
+
(options.functional ? this.parent : this).$root.$options.shadowRoot
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
: injectStyles
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (hook) {
|
|
176
|
+
if (options.functional) {
|
|
177
|
+
// for template-only hot-reload because in that case the render fn doesn't
|
|
178
|
+
// go through the normalizer
|
|
179
|
+
options._injectStyles = hook
|
|
180
|
+
// register for functional component in vue file
|
|
181
|
+
var originalRender = options.render
|
|
182
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
183
|
+
hook.call(context)
|
|
184
|
+
return originalRender(h, context)
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
// inject component registration as beforeCreate hook
|
|
188
|
+
var existing = options.beforeCreate
|
|
189
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
exports: scriptExports,
|
|
195
|
+
options: options
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
/***/ }),
|
|
201
|
+
|
|
202
|
+
/***/ 21:
|
|
203
|
+
/***/ (function(module, exports) {
|
|
204
|
+
|
|
205
|
+
module.exports = require("component-ui/lib/components/form-input");
|
|
206
|
+
|
|
207
|
+
/***/ }),
|
|
208
|
+
|
|
209
|
+
/***/ 22:
|
|
210
|
+
/***/ (function(module, exports) {
|
|
211
|
+
|
|
212
|
+
module.exports = require("component-ui/lib/components/table-column");
|
|
213
|
+
|
|
214
|
+
/***/ }),
|
|
215
|
+
|
|
216
|
+
/***/ 24:
|
|
217
|
+
/***/ (function(module, exports) {
|
|
218
|
+
|
|
219
|
+
module.exports = require("element-ui/lib/table");
|
|
220
|
+
|
|
221
|
+
/***/ }),
|
|
222
|
+
|
|
223
|
+
/***/ 53:
|
|
224
|
+
/***/ (function(module, exports) {
|
|
225
|
+
|
|
226
|
+
module.exports = require("element-ui/lib/popover");
|
|
227
|
+
|
|
228
|
+
/***/ }),
|
|
229
|
+
|
|
230
|
+
/***/ 54:
|
|
231
|
+
/***/ (function(module, exports) {
|
|
232
|
+
|
|
233
|
+
module.exports = require("async-validator");
|
|
234
|
+
|
|
235
|
+
/***/ }),
|
|
236
|
+
|
|
237
|
+
/***/ 59:
|
|
238
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
239
|
+
|
|
240
|
+
"use strict";
|
|
241
|
+
// ESM COMPAT FLAG
|
|
242
|
+
__webpack_require__.r(__webpack_exports__);
|
|
243
|
+
|
|
244
|
+
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/vue-loader/lib??vue-loader-options!./src/components/table-editable/src/index.vue?vue&type=template&id=1701e242&
|
|
245
|
+
var srcvue_type_template_id_1701e242_render = function render() {
|
|
246
|
+
var _vm = this,
|
|
247
|
+
_c = _vm._self._c
|
|
248
|
+
return _c(
|
|
249
|
+
"div",
|
|
250
|
+
{ staticClass: "table-editable" },
|
|
251
|
+
[
|
|
252
|
+
_c(
|
|
253
|
+
"el-table",
|
|
254
|
+
_vm._g(
|
|
255
|
+
_vm._b({ ref: "table" }, "el-table", _vm.tableProps, false),
|
|
256
|
+
_vm.tableListeners
|
|
257
|
+
),
|
|
258
|
+
[
|
|
259
|
+
_vm._l(_vm.columns, function (column) {
|
|
260
|
+
return [
|
|
261
|
+
_c(
|
|
262
|
+
"ColumnItem",
|
|
263
|
+
_vm._g(
|
|
264
|
+
_vm._b(
|
|
265
|
+
{
|
|
266
|
+
key: `${column.control}_${column.prop}`,
|
|
267
|
+
attrs: { actions: _vm.actionItem[column.prop] },
|
|
268
|
+
},
|
|
269
|
+
"ColumnItem",
|
|
270
|
+
column,
|
|
271
|
+
false
|
|
272
|
+
),
|
|
273
|
+
column.on
|
|
274
|
+
)
|
|
275
|
+
),
|
|
276
|
+
]
|
|
277
|
+
}),
|
|
278
|
+
],
|
|
279
|
+
2
|
|
280
|
+
),
|
|
281
|
+
],
|
|
282
|
+
1
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
var staticRenderFns = []
|
|
286
|
+
srcvue_type_template_id_1701e242_render._withStripped = true
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
// CONCATENATED MODULE: ./src/components/table-editable/src/index.vue?vue&type=template&id=1701e242&
|
|
290
|
+
|
|
291
|
+
// EXTERNAL MODULE: external "element-ui/lib/table"
|
|
292
|
+
var table_ = __webpack_require__(24);
|
|
293
|
+
var table_default = /*#__PURE__*/__webpack_require__.n(table_);
|
|
294
|
+
|
|
295
|
+
// EXTERNAL MODULE: external "@vue/babel-helper-vue-jsx-merge-props"
|
|
296
|
+
var babel_helper_vue_jsx_merge_props_ = __webpack_require__(0);
|
|
297
|
+
var babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(babel_helper_vue_jsx_merge_props_);
|
|
298
|
+
|
|
299
|
+
// EXTERNAL MODULE: external "component-ui/lib/components/table-column"
|
|
300
|
+
var table_column_ = __webpack_require__(22);
|
|
301
|
+
var table_column_default = /*#__PURE__*/__webpack_require__.n(table_column_);
|
|
302
|
+
|
|
303
|
+
// EXTERNAL MODULE: external "component-ui/lib/components/form-input"
|
|
304
|
+
var form_input_ = __webpack_require__(21);
|
|
305
|
+
var form_input_default = /*#__PURE__*/__webpack_require__.n(form_input_);
|
|
306
|
+
|
|
307
|
+
// EXTERNAL MODULE: external "element-ui/lib/popover"
|
|
308
|
+
var popover_ = __webpack_require__(53);
|
|
309
|
+
var popover_default = /*#__PURE__*/__webpack_require__.n(popover_);
|
|
310
|
+
|
|
311
|
+
// EXTERNAL MODULE: external "async-validator"
|
|
312
|
+
var external_async_validator_ = __webpack_require__(54);
|
|
313
|
+
var external_async_validator_default = /*#__PURE__*/__webpack_require__.n(external_async_validator_);
|
|
314
|
+
|
|
315
|
+
// CONCATENATED MODULE: ./src/components/table-editable/src/form-item.js
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
/* harmony default export */ var form_item = ({
|
|
321
|
+
name: "FormItem",
|
|
322
|
+
components: {
|
|
323
|
+
FormInput: form_input_default.a,
|
|
324
|
+
elPopover: popover_default.a
|
|
325
|
+
},
|
|
326
|
+
inheritAttrs: false,
|
|
327
|
+
props: {
|
|
328
|
+
prop: String,
|
|
329
|
+
label: String,
|
|
330
|
+
value: [String, Number, Boolean, Object, Array, Date],
|
|
331
|
+
rowData: Object,
|
|
332
|
+
row: Object,
|
|
333
|
+
actions: Array,
|
|
334
|
+
rules: {
|
|
335
|
+
type: Array,
|
|
336
|
+
default: function _default() {
|
|
337
|
+
return [];
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
on: Object,
|
|
341
|
+
slots: Object,
|
|
342
|
+
render: Function
|
|
343
|
+
},
|
|
344
|
+
data: function data() {
|
|
345
|
+
return {
|
|
346
|
+
inputConfig: null,
|
|
347
|
+
showMessage: false,
|
|
348
|
+
validateState: '',
|
|
349
|
+
validateMessage: '',
|
|
350
|
+
validateDisabled: false
|
|
351
|
+
};
|
|
352
|
+
},
|
|
353
|
+
computed: {
|
|
354
|
+
_tableEditable: function _tableEditable() {
|
|
355
|
+
var parent = this.$parent;
|
|
356
|
+
while (parent) {
|
|
357
|
+
if (parent.$options.componentName !== 'TableEditable') {
|
|
358
|
+
parent = parent.$parent;
|
|
359
|
+
} else {
|
|
360
|
+
return parent;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return false;
|
|
364
|
+
},
|
|
365
|
+
popoverShow: function popoverShow() {
|
|
366
|
+
if (this.showMessage && this.validateMessage) {
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
return false;
|
|
370
|
+
},
|
|
371
|
+
isRequired: function isRequired() {
|
|
372
|
+
var rules = this.rules;
|
|
373
|
+
var isRequired = false;
|
|
374
|
+
if (rules && rules.length) {
|
|
375
|
+
rules.every(function (rule) {
|
|
376
|
+
if (rule.required) {
|
|
377
|
+
isRequired = true;
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
return true;
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return isRequired;
|
|
384
|
+
},
|
|
385
|
+
actionEventMap: function actionEventMap() {
|
|
386
|
+
var eventMap = {};
|
|
387
|
+
if (!this.actions) {
|
|
388
|
+
return eventMap;
|
|
389
|
+
}
|
|
390
|
+
this.actions.forEach(function (item) {
|
|
391
|
+
eventMap[item.event] = item;
|
|
392
|
+
});
|
|
393
|
+
return eventMap;
|
|
394
|
+
},
|
|
395
|
+
eventOn: function eventOn() {
|
|
396
|
+
var itemOn = {};
|
|
397
|
+
if (!this.$listeners) {
|
|
398
|
+
return itemOn;
|
|
399
|
+
}
|
|
400
|
+
var that = this;
|
|
401
|
+
Object.keys(this.$listeners).forEach(function (eventName) {
|
|
402
|
+
itemOn[eventName] = function () {
|
|
403
|
+
that.execEvent.apply(that, [eventName].concat(Array.prototype.slice.call(arguments)));
|
|
404
|
+
};
|
|
405
|
+
});
|
|
406
|
+
return itemOn;
|
|
407
|
+
},
|
|
408
|
+
actionEventOn: function actionEventOn() {
|
|
409
|
+
var relItemOn = {};
|
|
410
|
+
if (!this.actions) {
|
|
411
|
+
return relItemOn;
|
|
412
|
+
}
|
|
413
|
+
// 联动函数执行
|
|
414
|
+
var that = this;
|
|
415
|
+
this.actions.forEach(function (item) {
|
|
416
|
+
relItemOn[item.event] = function () {
|
|
417
|
+
that.execEvent.apply(that, [item.event].concat(Array.prototype.slice.call(arguments)));
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
return relItemOn;
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
created: function created() {
|
|
424
|
+
this.inputConfig = Object.assign({
|
|
425
|
+
prop: this.prop,
|
|
426
|
+
label: this.label,
|
|
427
|
+
rules: this.rules
|
|
428
|
+
}, this.$attrs);
|
|
429
|
+
},
|
|
430
|
+
mounted: function mounted() {
|
|
431
|
+
if (this.prop) {
|
|
432
|
+
this.dispatch("TableEditable", "addField", [this]);
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
beforeDestroy: function beforeDestroy() {
|
|
436
|
+
this.dispatch("TableEditable", "removeField", [this]);
|
|
437
|
+
},
|
|
438
|
+
methods: {
|
|
439
|
+
execEvent: function execEvent(eventName) {
|
|
440
|
+
var _itemEvent$exec;
|
|
441
|
+
for (var _len = arguments.length, arg = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
442
|
+
arg[_key - 1] = arguments[_key];
|
|
443
|
+
}
|
|
444
|
+
//默认事件
|
|
445
|
+
if (this.$listeners && this.$listeners[eventName]) {
|
|
446
|
+
this.$emit.apply(this, [eventName, {
|
|
447
|
+
trigger: this.row,
|
|
448
|
+
triggerForm: this.rowData,
|
|
449
|
+
triggerConfig: this.inputConfig
|
|
450
|
+
}].concat(arg));
|
|
451
|
+
}
|
|
452
|
+
//联动配置事件
|
|
453
|
+
var itemEvent = this.actionEventMap[eventName];
|
|
454
|
+
if (!itemEvent) {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
var targetConfig = {};
|
|
458
|
+
var fieldMap = this._tableEditable.getRowField(this.row);
|
|
459
|
+
if (Array.isArray(itemEvent.target)) {
|
|
460
|
+
itemEvent.target.forEach(function (tarItem) {
|
|
461
|
+
targetConfig[tarItem] = fieldMap[tarItem] && fieldMap[tarItem].inputConfig;
|
|
462
|
+
});
|
|
463
|
+
} else if (typeof itemEvent.target === "string") {
|
|
464
|
+
targetConfig[itemEvent.target] = fieldMap[itemEvent.target] && fieldMap[itemEvent.target].inputConfig;
|
|
465
|
+
}
|
|
466
|
+
(_itemEvent$exec = itemEvent.exec).call.apply(_itemEvent$exec, [this, {
|
|
467
|
+
trigger: this.row,
|
|
468
|
+
triggerForm: this.rowData,
|
|
469
|
+
triggerConfig: this.inputConfig,
|
|
470
|
+
targetConfig: targetConfig
|
|
471
|
+
}].concat(arg));
|
|
472
|
+
},
|
|
473
|
+
dispatch: function dispatch(componentName, eventName, params) {
|
|
474
|
+
var parent = this.$parent || this.$root;
|
|
475
|
+
var name = parent.$options.componentName;
|
|
476
|
+
while (parent && (!name || name !== componentName)) {
|
|
477
|
+
parent = parent.$parent;
|
|
478
|
+
if (parent) {
|
|
479
|
+
name = parent.$options.componentName;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (parent) {
|
|
483
|
+
parent.$emit.apply(parent, [eventName].concat(params));
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
validate: function validate(trigger, callback) {
|
|
487
|
+
var _this = this;
|
|
488
|
+
if (callback === void 0) {
|
|
489
|
+
callback = function noop() {};
|
|
490
|
+
}
|
|
491
|
+
this.validateDisabled = false;
|
|
492
|
+
var rules = this.getFilteredRule(trigger);
|
|
493
|
+
if (!rules || rules.length === 0) {
|
|
494
|
+
callback();
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
this.validateState = 'validating';
|
|
498
|
+
var descriptor = {};
|
|
499
|
+
if (rules && rules.length > 0) {
|
|
500
|
+
rules.forEach(function (rule) {
|
|
501
|
+
delete rule.trigger;
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
descriptor[this.prop] = rules;
|
|
505
|
+
var validator = new external_async_validator_default.a(descriptor);
|
|
506
|
+
var model = {};
|
|
507
|
+
model[this.prop] = this.rowData[this.prop];
|
|
508
|
+
validator.validate(model, {
|
|
509
|
+
firstFields: true
|
|
510
|
+
}, function (errors, invalidFields) {
|
|
511
|
+
_this.validateState = !errors ? 'success' : 'error';
|
|
512
|
+
_this.validateMessage = errors ? errors[0].message : '';
|
|
513
|
+
callback(_this.validateMessage, invalidFields);
|
|
514
|
+
});
|
|
515
|
+
},
|
|
516
|
+
clearValidate: function clearValidate() {
|
|
517
|
+
this.validateState = "";
|
|
518
|
+
this.validateMessage = "";
|
|
519
|
+
this.validateDisabled = false;
|
|
520
|
+
},
|
|
521
|
+
onFieldBlur: function onFieldBlur() {
|
|
522
|
+
this.validate('blur');
|
|
523
|
+
},
|
|
524
|
+
onFieldInput: function onFieldInput() {
|
|
525
|
+
if (this.validateDisabled) {
|
|
526
|
+
this.validateDisabled = false;
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
this.validate('input');
|
|
530
|
+
},
|
|
531
|
+
onFieldChange: function onFieldChange() {
|
|
532
|
+
if (this.validateDisabled) {
|
|
533
|
+
this.validateDisabled = false;
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
this.validate('change');
|
|
537
|
+
},
|
|
538
|
+
getFilteredRule: function getFilteredRule(trigger) {
|
|
539
|
+
var rules = this.rules;
|
|
540
|
+
return rules.filter(function (rule) {
|
|
541
|
+
if (!rule.trigger || trigger === '') return true;
|
|
542
|
+
if (Array.isArray(rule.trigger)) {
|
|
543
|
+
return rule.trigger.indexOf(trigger) > -1;
|
|
544
|
+
} else {
|
|
545
|
+
return rule.trigger === trigger;
|
|
546
|
+
}
|
|
547
|
+
}).map(function (rule) {
|
|
548
|
+
return Object.assign({}, rule);
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
render: function render(h) {
|
|
553
|
+
var _this2 = this;
|
|
554
|
+
var param = {
|
|
555
|
+
attrs: Object.assign({}, this.inputConfig, {
|
|
556
|
+
value: this.value
|
|
557
|
+
}),
|
|
558
|
+
on: Object.assign({}, this.eventOn, this.actionEventOn, {
|
|
559
|
+
focus: function focus() {
|
|
560
|
+
_this2.execEvent("focus");
|
|
561
|
+
_this2.showMessage = true;
|
|
562
|
+
},
|
|
563
|
+
blur: function blur() {
|
|
564
|
+
_this2.execEvent("blur");
|
|
565
|
+
_this2.showMessage = false;
|
|
566
|
+
_this2.onFieldBlur();
|
|
567
|
+
},
|
|
568
|
+
input: function input(val) {
|
|
569
|
+
_this2.execEvent("input", val);
|
|
570
|
+
_this2.rowData[_this2.prop] = val;
|
|
571
|
+
_this2.onFieldInput();
|
|
572
|
+
},
|
|
573
|
+
change: function change(val, selectOption) {
|
|
574
|
+
_this2.execEvent("change", val, selectOption);
|
|
575
|
+
_this2.rowData[_this2.prop] = val;
|
|
576
|
+
_this2.onFieldChange();
|
|
577
|
+
}
|
|
578
|
+
}),
|
|
579
|
+
slots: this.slots,
|
|
580
|
+
scopedSlots: this.slots
|
|
581
|
+
};
|
|
582
|
+
return h("div", {
|
|
583
|
+
"class": ["column-form-item", {
|
|
584
|
+
"is-required": this.isRequired,
|
|
585
|
+
'is-error': this.validateState === 'error',
|
|
586
|
+
'is-validating': this.validateState === 'validating',
|
|
587
|
+
'is-success': this.validateState === 'success'
|
|
588
|
+
}]
|
|
589
|
+
}, [h("el-popover", {
|
|
590
|
+
"attrs": {
|
|
591
|
+
"popper-class": "popover-error",
|
|
592
|
+
"trigger": "manual",
|
|
593
|
+
"placement": "top-start",
|
|
594
|
+
"content": this.validateMessage,
|
|
595
|
+
"value": this.popoverShow
|
|
596
|
+
}
|
|
597
|
+
}, [h("div", {
|
|
598
|
+
"slot": "reference"
|
|
599
|
+
}, [h(form_input_default.a, babel_helper_vue_jsx_merge_props_default()([{}, param]))])])]);
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
// CONCATENATED MODULE: ./src/components/table-editable/src/column-item.js
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
/* harmony default export */ var column_item = ({
|
|
608
|
+
name: "ColumnItem",
|
|
609
|
+
components: {
|
|
610
|
+
TableColumn: table_column_default.a,
|
|
611
|
+
FormItem: form_item
|
|
612
|
+
},
|
|
613
|
+
inheritAttrs: false,
|
|
614
|
+
props: {
|
|
615
|
+
prop: String,
|
|
616
|
+
label: String,
|
|
617
|
+
value: [String, Number, Boolean, Object, Array, Date],
|
|
618
|
+
config: Object,
|
|
619
|
+
actions: Array,
|
|
620
|
+
on: Object,
|
|
621
|
+
render: Function
|
|
622
|
+
},
|
|
623
|
+
data: function data() {
|
|
624
|
+
return {};
|
|
625
|
+
},
|
|
626
|
+
methods: {
|
|
627
|
+
renderFormInput: function renderFormInput(h, scoped) {
|
|
628
|
+
var rowData = scoped.row;
|
|
629
|
+
var param = {
|
|
630
|
+
attrs: Object.assign({
|
|
631
|
+
prop: this.prop,
|
|
632
|
+
label: this.label,
|
|
633
|
+
actions: this.actions
|
|
634
|
+
}, this.config, {
|
|
635
|
+
value: rowData[this.prop],
|
|
636
|
+
rowData: rowData,
|
|
637
|
+
row: scoped
|
|
638
|
+
}),
|
|
639
|
+
on: Object.assign({}, this.$listeners),
|
|
640
|
+
slots: this.config.slots,
|
|
641
|
+
scopedSlots: this.config.slots
|
|
642
|
+
};
|
|
643
|
+
return h(form_item, babel_helper_vue_jsx_merge_props_default()([{}, param]));
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
render: function render(h) {
|
|
647
|
+
var _this = this;
|
|
648
|
+
var param = {
|
|
649
|
+
attrs: Object.assign({
|
|
650
|
+
prop: this.prop,
|
|
651
|
+
label: this.label
|
|
652
|
+
}, this.$attrs),
|
|
653
|
+
on: Object.assign({}, this.$listeners),
|
|
654
|
+
slots: this.$slots,
|
|
655
|
+
scopedSlots: this.$scopedSlots
|
|
656
|
+
};
|
|
657
|
+
if (this.config) {
|
|
658
|
+
param.scopedSlots["default"] = function (scoped) {
|
|
659
|
+
return _this.renderFormInput(h, scoped);
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
return h(table_column_default.a, babel_helper_vue_jsx_merge_props_default()([{}, param]));
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/table-editable/src/index.vue?vue&type=script&lang=js&
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
/* harmony default export */ var srcvue_type_script_lang_js_ = ({
|
|
669
|
+
name: "TableEditable",
|
|
670
|
+
componentName: "TableEditable",
|
|
671
|
+
components: {
|
|
672
|
+
elTable: table_default.a,
|
|
673
|
+
ColumnItem: column_item
|
|
674
|
+
},
|
|
675
|
+
provide: function provide() {
|
|
676
|
+
return {
|
|
677
|
+
table: this
|
|
678
|
+
};
|
|
679
|
+
},
|
|
680
|
+
props: {
|
|
681
|
+
rowKey: {
|
|
682
|
+
type: String,
|
|
683
|
+
default: function _default() {
|
|
684
|
+
return "id";
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
data: {
|
|
688
|
+
type: Array,
|
|
689
|
+
default: function _default() {
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
columns: {
|
|
694
|
+
type: Array,
|
|
695
|
+
default: function _default() {
|
|
696
|
+
return [];
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
actions: {
|
|
700
|
+
type: Array,
|
|
701
|
+
default: function _default() {
|
|
702
|
+
return [];
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
on: {
|
|
706
|
+
type: Object,
|
|
707
|
+
default: function _default() {
|
|
708
|
+
return {};
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
slots: {
|
|
712
|
+
type: Object,
|
|
713
|
+
default: function _default() {
|
|
714
|
+
return {};
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
data: function data() {
|
|
719
|
+
return {
|
|
720
|
+
rowId: null,
|
|
721
|
+
selection: [],
|
|
722
|
+
fields: []
|
|
723
|
+
};
|
|
724
|
+
},
|
|
725
|
+
computed: {
|
|
726
|
+
request: function request() {
|
|
727
|
+
return this.api.request || (this.$COMPONENT || {}).request;
|
|
728
|
+
},
|
|
729
|
+
tableProps: function tableProps() {
|
|
730
|
+
return Object.assign({
|
|
731
|
+
highlightCurrentRow: true,
|
|
732
|
+
stripe: true,
|
|
733
|
+
defaultExpandAll: true,
|
|
734
|
+
size: "mini"
|
|
735
|
+
}, this.$attrs, {
|
|
736
|
+
rowKey: this.rowKey,
|
|
737
|
+
data: this.data
|
|
738
|
+
});
|
|
739
|
+
},
|
|
740
|
+
tableListeners: function tableListeners() {
|
|
741
|
+
var _this = this;
|
|
742
|
+
return Object.assign({}, this.$listeners, {
|
|
743
|
+
"row-click": function rowClick(row) {
|
|
744
|
+
var selectColumns = _this.columns.filter(function (item) {
|
|
745
|
+
return item.control === "Selection";
|
|
746
|
+
});
|
|
747
|
+
if (selectColumns && selectColumns.length > 0) {
|
|
748
|
+
var selectColumn = selectColumns[0];
|
|
749
|
+
if (selectColumn.type === "radio") {
|
|
750
|
+
var key = selectColumn.prop || _this.tableProps.rowKey;
|
|
751
|
+
_this.rowId = row[key];
|
|
752
|
+
_this.selection = [row];
|
|
753
|
+
} else {
|
|
754
|
+
_this.$refs.table.toggleRowSelection(row); // 点击选中
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
_this.$emit("row-click", row);
|
|
759
|
+
},
|
|
760
|
+
"selection-change": function selectionChange(selection) {
|
|
761
|
+
_this.selection = selection;
|
|
762
|
+
_this.$emit("selection-change", selection);
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
},
|
|
766
|
+
rowData: function rowData() {
|
|
767
|
+
var rowData = {};
|
|
768
|
+
this.columns.forEach(function (column) {
|
|
769
|
+
if (column.prop) {
|
|
770
|
+
rowData[column.prop] = column.config && column.config.value;
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
return rowData;
|
|
774
|
+
},
|
|
775
|
+
actionItem: function actionItem() {
|
|
776
|
+
var relItem = {};
|
|
777
|
+
this.actions.forEach(function (item) {
|
|
778
|
+
if (!relItem[item.trigger]) {
|
|
779
|
+
relItem[item.trigger] = [];
|
|
780
|
+
}
|
|
781
|
+
relItem[item.trigger].push(item);
|
|
782
|
+
});
|
|
783
|
+
return relItem;
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
created: function created() {
|
|
787
|
+
var _this2 = this;
|
|
788
|
+
this.$on("addField", function (field) {
|
|
789
|
+
if (field) {
|
|
790
|
+
_this2.fields.push(field);
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
/* istanbul ignore next */
|
|
794
|
+
this.$on("removeField", function (field) {
|
|
795
|
+
if (field) {
|
|
796
|
+
_this2.fields.splice(_this2.fields.indexOf(field), 1);
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
},
|
|
800
|
+
methods: {
|
|
801
|
+
validate: function validate(callback) {
|
|
802
|
+
var _this3 = this;
|
|
803
|
+
var promise;
|
|
804
|
+
// if no callback, return promise
|
|
805
|
+
if (typeof callback !== 'function' && window.Promise) {
|
|
806
|
+
promise = new window.Promise(function (resolve, reject) {
|
|
807
|
+
callback = function callback(valid, invalidFields) {
|
|
808
|
+
valid ? resolve(valid) : reject(invalidFields);
|
|
809
|
+
};
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
var valid = true;
|
|
813
|
+
var count = 0;
|
|
814
|
+
// 如果需要验证的fields为空,调用验证时立刻返回callback
|
|
815
|
+
if (this.fields.length === 0 && callback) {
|
|
816
|
+
callback(true);
|
|
817
|
+
}
|
|
818
|
+
var invalidFields = [];
|
|
819
|
+
this.fields.forEach(function (field) {
|
|
820
|
+
field.validate('', function (message, fieldMsg) {
|
|
821
|
+
if (message) {
|
|
822
|
+
valid = false;
|
|
823
|
+
}
|
|
824
|
+
var rowIndex = field.row && field.row.$index;
|
|
825
|
+
if (!invalidFields[rowIndex]) {
|
|
826
|
+
invalidFields[rowIndex] = {};
|
|
827
|
+
}
|
|
828
|
+
Object.assign(invalidFields[rowIndex], fieldMsg);
|
|
829
|
+
if (typeof callback === 'function' && ++count === _this3.fields.length) {
|
|
830
|
+
callback(valid, invalidFields);
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
if (promise) {
|
|
835
|
+
return promise;
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
validateRow: function validateRow(rowIndex, callback) {
|
|
839
|
+
var promise;
|
|
840
|
+
// if no callback, return promise
|
|
841
|
+
if (typeof callback !== 'function' && window.Promise) {
|
|
842
|
+
promise = new window.Promise(function (resolve, reject) {
|
|
843
|
+
callback = function callback(valid, invalidFields) {
|
|
844
|
+
valid ? resolve(valid) : reject(invalidFields);
|
|
845
|
+
};
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
var valid = true;
|
|
849
|
+
var count = 0;
|
|
850
|
+
// 如果需要验证的fields为空,调用验证时立刻返回callback
|
|
851
|
+
var fields = this.fields.filter(function (item) {
|
|
852
|
+
return item.row && item.row.$index === rowIndex;
|
|
853
|
+
});
|
|
854
|
+
if (fields.length === 0 && callback) {
|
|
855
|
+
callback(true);
|
|
856
|
+
}
|
|
857
|
+
var invalidFields = {};
|
|
858
|
+
fields.forEach(function (field) {
|
|
859
|
+
field.validate('', function (message, fieldMsg) {
|
|
860
|
+
if (message) {
|
|
861
|
+
valid = false;
|
|
862
|
+
}
|
|
863
|
+
Object.assign(invalidFields, fieldMsg);
|
|
864
|
+
if (typeof callback === 'function' && ++count === fields.length) {
|
|
865
|
+
callback(valid, invalidFields);
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
if (promise) {
|
|
870
|
+
return promise;
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
validateField: function validateField(rowIndex, props, cb) {
|
|
874
|
+
props = [].concat(props);
|
|
875
|
+
var fields = this.fields.filter(function (item) {
|
|
876
|
+
return item.row && item.row.$index === rowIndex && props.indexOf(item.prop) !== -1;
|
|
877
|
+
});
|
|
878
|
+
if (!fields.length) {
|
|
879
|
+
console.warn('[Element Warn]please pass correct props!');
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
fields.forEach(function (field) {
|
|
883
|
+
field.validate('', cb);
|
|
884
|
+
});
|
|
885
|
+
},
|
|
886
|
+
clearValidate: function clearValidate(rowIndex, props) {
|
|
887
|
+
if (props === void 0) {
|
|
888
|
+
props = [];
|
|
889
|
+
}
|
|
890
|
+
var fields = this.fields;
|
|
891
|
+
if (typeof rowIndex === "number") {
|
|
892
|
+
fields = props.length ? this.fields.filter(function (item) {
|
|
893
|
+
return item.row && item.row.$index === rowIndex && props.indexOf(item.prop) !== -1;
|
|
894
|
+
}) : this.fields.filter(function (item) {
|
|
895
|
+
return item.row && item.row.$index === rowIndex;
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
fields.forEach(function (field) {
|
|
899
|
+
field.clearValidate();
|
|
900
|
+
});
|
|
901
|
+
},
|
|
902
|
+
getRowField: function getRowField(row) {
|
|
903
|
+
var fieldMap = {};
|
|
904
|
+
var fields = this.fields.filter(function (item) {
|
|
905
|
+
return item.row && item.row.$index === row.$index;
|
|
906
|
+
});
|
|
907
|
+
fields.forEach(function (item) {
|
|
908
|
+
fieldMap[item.prop] = item;
|
|
909
|
+
});
|
|
910
|
+
return fieldMap;
|
|
911
|
+
},
|
|
912
|
+
addRow: function addRow(data) {
|
|
913
|
+
this.data.push(Object.assign({}, this.rowData, data));
|
|
914
|
+
},
|
|
915
|
+
deleteRow: function deleteRow(index) {
|
|
916
|
+
this.data && this.data.splice(index, 1);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
// CONCATENATED MODULE: ./src/components/table-editable/src/index.vue?vue&type=script&lang=js&
|
|
921
|
+
/* harmony default export */ var table_editable_srcvue_type_script_lang_js_ = (srcvue_type_script_lang_js_);
|
|
922
|
+
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
923
|
+
var componentNormalizer = __webpack_require__(1);
|
|
924
|
+
|
|
925
|
+
// CONCATENATED MODULE: ./src/components/table-editable/src/index.vue
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
/* normalize component */
|
|
932
|
+
|
|
933
|
+
var component = Object(componentNormalizer["a" /* default */])(
|
|
934
|
+
table_editable_srcvue_type_script_lang_js_,
|
|
935
|
+
srcvue_type_template_id_1701e242_render,
|
|
936
|
+
staticRenderFns,
|
|
937
|
+
false,
|
|
938
|
+
null,
|
|
939
|
+
null,
|
|
940
|
+
null
|
|
941
|
+
|
|
942
|
+
)
|
|
943
|
+
|
|
944
|
+
/* harmony default export */ var src = (component.exports);
|
|
945
|
+
// CONCATENATED MODULE: ./src/components/table-editable/index.js
|
|
946
|
+
|
|
947
|
+
src.install = function (Vue) {
|
|
948
|
+
Vue.component(src.name, src);
|
|
949
|
+
};
|
|
950
|
+
/* harmony default export */ var table_editable = __webpack_exports__["default"] = (src);
|
|
951
|
+
|
|
952
|
+
/***/ })
|
|
953
|
+
|
|
954
|
+
/******/ });
|