1 | module.exports =
|
2 | (function(modules) {
|
3 |
|
4 | var installedModules = {};
|
5 |
|
6 |
|
7 | function __webpack_require__(moduleId) {
|
8 |
|
9 |
|
10 | if(installedModules[moduleId]) {
|
11 | return installedModules[moduleId].exports;
|
12 | }
|
13 |
|
14 | var module = installedModules[moduleId] = {
|
15 | i: moduleId,
|
16 | l: false,
|
17 | exports: {}
|
18 | };
|
19 |
|
20 |
|
21 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
22 |
|
23 |
|
24 | module.l = true;
|
25 |
|
26 |
|
27 | return module.exports;
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 | __webpack_require__.m = modules;
|
33 |
|
34 |
|
35 | __webpack_require__.c = installedModules;
|
36 |
|
37 |
|
38 | __webpack_require__.d = function(exports, name, getter) {
|
39 | if(!__webpack_require__.o(exports, name)) {
|
40 | Object.defineProperty(exports, name, {
|
41 | configurable: false,
|
42 | enumerable: true,
|
43 | get: getter
|
44 | /******/ });
|
45 | /******/ }
|
46 | /******/ };
|
47 | /******/
|
48 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
49 | /******/ __webpack_require__.n = function(module) {
|
50 | var getter = module && module.__esModule ?
|
51 | function getDefault() { return module['default']; } :
|
52 | function getModuleExports() { return module; };
|
53 | __webpack_require__.d(getter, 'a', getter);
|
54 | return getter;
|
55 | };
|
56 |
|
57 |
|
58 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
59 |
|
60 |
|
61 | __webpack_require__.p = "/dist/";
|
62 |
|
63 |
|
64 | return __webpack_require__(__webpack_require__.s = 320);
|
65 | })
|
66 |
|
67 | ({
|
68 |
|
69 | 0:
|
70 | (function(module, exports) {
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | module.exports = function normalizeComponent (
|
79 | rawScriptExports,
|
80 | compiledTemplate,
|
81 | functionalTemplate,
|
82 | injectStyles,
|
83 | scopeId,
|
84 | moduleIdentifier /* server only */
|
85 | ) {
|
86 | var esModule
|
87 | var scriptExports = rawScriptExports = rawScriptExports || {}
|
88 |
|
89 |
|
90 | var type = typeof rawScriptExports.default
|
91 | if (type === 'object' || type === 'function') {
|
92 | esModule = rawScriptExports
|
93 | scriptExports = rawScriptExports.default
|
94 | }
|
95 |
|
96 |
|
97 | var options = typeof scriptExports === 'function'
|
98 | ? scriptExports.options
|
99 | : scriptExports
|
100 |
|
101 |
|
102 | if (compiledTemplate) {
|
103 | options.render = compiledTemplate.render
|
104 | options.staticRenderFns = compiledTemplate.staticRenderFns
|
105 | options._compiled = true
|
106 | }
|
107 |
|
108 |
|
109 | if (functionalTemplate) {
|
110 | options.functional = true
|
111 | }
|
112 |
|
113 |
|
114 | if (scopeId) {
|
115 | options._scopeId = scopeId
|
116 | }
|
117 |
|
118 | var hook
|
119 | if (moduleIdentifier) {
|
120 | hook = function (context) {
|
121 |
|
122 | context =
|
123 | context ||
|
124 | (this.$vnode && this.$vnode.ssrContext) ||
|
125 | (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext)
|
126 |
|
127 | if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
128 | context = __VUE_SSR_CONTEXT__
|
129 | }
|
130 |
|
131 | if (injectStyles) {
|
132 | injectStyles.call(this, context)
|
133 | }
|
134 |
|
135 | if (context && context._registeredComponents) {
|
136 | context._registeredComponents.add(moduleIdentifier)
|
137 | }
|
138 | }
|
139 |
|
140 |
|
141 | options._ssrRegister = hook
|
142 | } else if (injectStyles) {
|
143 | hook = injectStyles
|
144 | }
|
145 |
|
146 | if (hook) {
|
147 | var functional = options.functional
|
148 | var existing = functional
|
149 | ? options.render
|
150 | : options.beforeCreate
|
151 |
|
152 | if (!functional) {
|
153 |
|
154 | options.beforeCreate = existing
|
155 | ? [].concat(existing, hook)
|
156 | : [hook]
|
157 | } else {
|
158 |
|
159 |
|
160 | options._injectStyles = hook
|
161 |
|
162 | options.render = function renderWithStyleInjection (h, context) {
|
163 | hook.call(context)
|
164 | return existing(h, context)
|
165 | }
|
166 | }
|
167 | }
|
168 |
|
169 | return {
|
170 | esModule: esModule,
|
171 | exports: scriptExports,
|
172 | options: options
|
173 | }
|
174 | }
|
175 |
|
176 |
|
177 | }),
|
178 |
|
179 | 3:
|
180 | (function(module, exports) {
|
181 |
|
182 | module.exports = require("element-ui/lib/utils/dom");
|
183 |
|
184 | }),
|
185 |
|
186 | 320:
|
187 | (function(module, exports, __webpack_require__) {
|
188 |
|
189 | "use strict";
|
190 |
|
191 |
|
192 | exports.__esModule = true;
|
193 |
|
194 | var _main = __webpack_require__(321);
|
195 |
|
196 | var _main2 = _interopRequireDefault(_main);
|
197 |
|
198 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
199 |
|
200 |
|
201 | _main2.default.install = function (Vue) {
|
202 | Vue.component(_main2.default.name, _main2.default);
|
203 | };
|
204 |
|
205 | exports.default = _main2.default;
|
206 |
|
207 | }),
|
208 |
|
209 | 321:
|
210 | (function(module, __webpack_exports__, __webpack_require__) {
|
211 |
|
212 | "use strict";
|
213 | Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
214 | var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue__ = __webpack_require__(322);
|
215 | var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue__);
|
216 | var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_02f4e282_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_main_vue__ = __webpack_require__(323);
|
217 | var normalizeComponent = __webpack_require__(0)
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 | var __vue_template_functional__ = false
|
224 |
|
225 | var __vue_styles__ = null
|
226 |
|
227 | var __vue_scopeId__ = null
|
228 |
|
229 | var __vue_module_identifier__ = null
|
230 | var Component = normalizeComponent(
|
231 | __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_main_vue___default.a,
|
232 | __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_02f4e282_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_main_vue__["a" ],
|
233 | __vue_template_functional__,
|
234 | __vue_styles__,
|
235 | __vue_scopeId__,
|
236 | __vue_module_identifier__
|
237 | )
|
238 |
|
239 | __webpack_exports__["default"] = (Component.exports);
|
240 |
|
241 |
|
242 | }),
|
243 |
|
244 | 322:
|
245 | (function(module, exports, __webpack_require__) {
|
246 |
|
247 | "use strict";
|
248 |
|
249 |
|
250 | exports.__esModule = true;
|
251 |
|
252 | var _dom = __webpack_require__(3);
|
253 |
|
254 | var _migrating = __webpack_require__(8);
|
255 |
|
256 | var _migrating2 = _interopRequireDefault(_migrating);
|
257 |
|
258 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 | exports.default = {
|
296 | name: 'ElRate',
|
297 |
|
298 | mixins: [_migrating2.default],
|
299 |
|
300 | inject: {
|
301 | elForm: {
|
302 | default: ''
|
303 | }
|
304 | },
|
305 |
|
306 | data: function data() {
|
307 | return {
|
308 | pointerAtLeftHalf: true,
|
309 | currentValue: this.value,
|
310 | hoverIndex: -1
|
311 | };
|
312 | },
|
313 |
|
314 |
|
315 | props: {
|
316 | value: {
|
317 | type: Number,
|
318 | default: 0
|
319 | },
|
320 | lowThreshold: {
|
321 | type: Number,
|
322 | default: 2
|
323 | },
|
324 | highThreshold: {
|
325 | type: Number,
|
326 | default: 4
|
327 | },
|
328 | max: {
|
329 | type: Number,
|
330 | default: 5
|
331 | },
|
332 | colors: {
|
333 | type: Array,
|
334 | default: function _default() {
|
335 | return ['#F7BA2A', '#F7BA2A', '#F7BA2A'];
|
336 | }
|
337 | },
|
338 | voidColor: {
|
339 | type: String,
|
340 | default: '#C6D1DE'
|
341 | },
|
342 | disabledVoidColor: {
|
343 | type: String,
|
344 | default: '#EFF2F7'
|
345 | },
|
346 | iconClasses: {
|
347 | type: Array,
|
348 | default: function _default() {
|
349 | return ['el-icon-star-on', 'el-icon-star-on', 'el-icon-star-on'];
|
350 | }
|
351 | },
|
352 | voidIconClass: {
|
353 | type: String,
|
354 | default: 'el-icon-star-off'
|
355 | },
|
356 | disabledVoidIconClass: {
|
357 | type: String,
|
358 | default: 'el-icon-star-on'
|
359 | },
|
360 | disabled: {
|
361 | type: Boolean,
|
362 | default: false
|
363 | },
|
364 | allowHalf: {
|
365 | type: Boolean,
|
366 | default: false
|
367 | },
|
368 | showText: {
|
369 | type: Boolean,
|
370 | default: false
|
371 | },
|
372 | showScore: {
|
373 | type: Boolean,
|
374 | default: false
|
375 | },
|
376 | textColor: {
|
377 | type: String,
|
378 | default: '#1f2d3d'
|
379 | },
|
380 | texts: {
|
381 | type: Array,
|
382 | default: function _default() {
|
383 | return ['极差', '失望', '一般', '满意', '惊喜'];
|
384 | }
|
385 | },
|
386 | scoreTemplate: {
|
387 | type: String,
|
388 | default: '{value}'
|
389 | }
|
390 | },
|
391 |
|
392 | computed: {
|
393 | text: function text() {
|
394 | var result = '';
|
395 | if (this.showScore) {
|
396 | result = this.scoreTemplate.replace(/\{\s*value\s*\}/, this.rateDisabled ? this.value : this.currentValue);
|
397 | } else if (this.showText) {
|
398 | result = this.texts[Math.ceil(this.currentValue) - 1];
|
399 | }
|
400 | return result;
|
401 | },
|
402 | decimalStyle: function decimalStyle() {
|
403 | var width = '';
|
404 | if (this.rateDisabled) {
|
405 | width = (this.valueDecimal < 50 ? 0 : 50) + '%';
|
406 | }
|
407 | if (this.allowHalf) {
|
408 | width = '50%';
|
409 | }
|
410 | return {
|
411 | color: this.activeColor,
|
412 | width: width
|
413 | };
|
414 | },
|
415 | valueDecimal: function valueDecimal() {
|
416 | return this.value * 100 - Math.floor(this.value) * 100;
|
417 | },
|
418 | decimalIconClass: function decimalIconClass() {
|
419 | return this.getValueFromMap(this.value, this.classMap);
|
420 | },
|
421 | voidClass: function voidClass() {
|
422 | return this.rateDisabled ? this.classMap.disabledVoidClass : this.classMap.voidClass;
|
423 | },
|
424 | activeClass: function activeClass() {
|
425 | return this.getValueFromMap(this.currentValue, this.classMap);
|
426 | },
|
427 | colorMap: function colorMap() {
|
428 | return {
|
429 | lowColor: this.colors[0],
|
430 | mediumColor: this.colors[1],
|
431 | highColor: this.colors[2],
|
432 | voidColor: this.voidColor,
|
433 | disabledVoidColor: this.disabledVoidColor
|
434 | };
|
435 | },
|
436 | activeColor: function activeColor() {
|
437 | return this.getValueFromMap(this.currentValue, this.colorMap);
|
438 | },
|
439 | classes: function classes() {
|
440 | var result = [];
|
441 | var i = 0;
|
442 | var threshold = this.currentValue;
|
443 | if (this.allowHalf && this.currentValue !== Math.floor(this.currentValue)) {
|
444 | threshold--;
|
445 | }
|
446 | for (; i < threshold; i++) {
|
447 | result.push(this.activeClass);
|
448 | }
|
449 | for (; i < this.max; i++) {
|
450 | result.push(this.voidClass);
|
451 | }
|
452 | return result;
|
453 | },
|
454 | classMap: function classMap() {
|
455 | return {
|
456 | lowClass: this.iconClasses[0],
|
457 | mediumClass: this.iconClasses[1],
|
458 | highClass: this.iconClasses[2],
|
459 | voidClass: this.voidIconClass,
|
460 | disabledVoidClass: this.disabledVoidIconClass
|
461 | };
|
462 | },
|
463 | rateDisabled: function rateDisabled() {
|
464 | return this.disabled || (this.elForm || {}).disabled;
|
465 | }
|
466 | },
|
467 |
|
468 | watch: {
|
469 | value: function value(val) {
|
470 | this.currentValue = val;
|
471 | this.pointerAtLeftHalf = this.value !== Math.floor(this.value);
|
472 | }
|
473 | },
|
474 |
|
475 | methods: {
|
476 | getMigratingConfig: function getMigratingConfig() {
|
477 | return {
|
478 | props: {
|
479 | 'text-template': 'text-template is renamed to score-template.'
|
480 | }
|
481 | };
|
482 | },
|
483 | getValueFromMap: function getValueFromMap(value, map) {
|
484 | var result = '';
|
485 | if (value <= this.lowThreshold) {
|
486 | result = map.lowColor || map.lowClass;
|
487 | } else if (value >= this.highThreshold) {
|
488 | result = map.highColor || map.highClass;
|
489 | } else {
|
490 | result = map.mediumColor || map.mediumClass;
|
491 | }
|
492 | return result;
|
493 | },
|
494 | showDecimalIcon: function showDecimalIcon(item) {
|
495 | var showWhenDisabled = this.rateDisabled && this.valueDecimal > 0 && item - 1 < this.value && item > this.value;
|
496 |
|
497 | var showWhenAllowHalf = this.allowHalf && this.pointerAtLeftHalf && item - 0.5 <= this.currentValue && item > this.currentValue;
|
498 | return showWhenDisabled || showWhenAllowHalf;
|
499 | },
|
500 | getIconStyle: function getIconStyle(item) {
|
501 | var voidColor = this.rateDisabled ? this.colorMap.disabledVoidColor : this.colorMap.voidColor;
|
502 | return {
|
503 | color: item <= this.currentValue ? this.activeColor : voidColor
|
504 | };
|
505 | },
|
506 | selectValue: function selectValue(value) {
|
507 | if (this.rateDisabled) {
|
508 | return;
|
509 | }
|
510 | if (this.allowHalf && this.pointerAtLeftHalf) {
|
511 | this.$emit('input', this.currentValue);
|
512 | this.$emit('change', this.currentValue);
|
513 | } else {
|
514 | this.$emit('input', value);
|
515 | this.$emit('change', value);
|
516 | }
|
517 | },
|
518 | handleKey: function handleKey(e) {
|
519 | if (this.rateDisabled) {
|
520 | return;
|
521 | }
|
522 | var currentValue = this.currentValue;
|
523 | var keyCode = e.keyCode;
|
524 | if (keyCode === 38 || keyCode === 39) {
|
525 |
|
526 | if (this.allowHalf) {
|
527 | currentValue += 0.5;
|
528 | } else {
|
529 | currentValue += 1;
|
530 | }
|
531 | e.stopPropagation();
|
532 | e.preventDefault();
|
533 | } else if (keyCode === 37 || keyCode === 40) {
|
534 | if (this.allowHalf) {
|
535 | currentValue -= 0.5;
|
536 | } else {
|
537 | currentValue -= 1;
|
538 | }
|
539 | e.stopPropagation();
|
540 | e.preventDefault();
|
541 | }
|
542 | currentValue = currentValue < 0 ? 0 : currentValue;
|
543 | currentValue = currentValue > this.max ? this.max : currentValue;
|
544 |
|
545 | this.$emit('input', currentValue);
|
546 | this.$emit('change', currentValue);
|
547 | },
|
548 | setCurrentValue: function setCurrentValue(value, event) {
|
549 | if (this.rateDisabled) {
|
550 | return;
|
551 | }
|
552 |
|
553 | if (this.allowHalf) {
|
554 | var target = event.target;
|
555 | if ((0, _dom.hasClass)(target, 'el-rate__item')) {
|
556 | target = target.querySelector('.el-rate__icon');
|
557 | }
|
558 | if ((0, _dom.hasClass)(target, 'el-rate__decimal')) {
|
559 | target = target.parentNode;
|
560 | }
|
561 | this.pointerAtLeftHalf = event.offsetX * 2 <= target.clientWidth;
|
562 | this.currentValue = this.pointerAtLeftHalf ? value - 0.5 : value;
|
563 | } else {
|
564 | this.currentValue = value;
|
565 | }
|
566 | this.hoverIndex = value;
|
567 | },
|
568 | resetCurrentValue: function resetCurrentValue() {
|
569 | if (this.rateDisabled) {
|
570 | return;
|
571 | }
|
572 | if (this.allowHalf) {
|
573 | this.pointerAtLeftHalf = this.value !== Math.floor(this.value);
|
574 | }
|
575 | this.currentValue = this.value;
|
576 | this.hoverIndex = -1;
|
577 | }
|
578 | },
|
579 |
|
580 | created: function created() {
|
581 | if (!this.value) {
|
582 | this.$emit('input', 0);
|
583 | }
|
584 | }
|
585 | };
|
586 |
|
587 | }),
|
588 |
|
589 | 323:
|
590 | (function(module, __webpack_exports__, __webpack_require__) {
|
591 |
|
592 | "use strict";
|
593 | var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"el-rate",attrs:{"role":"slider","aria-valuenow":_vm.currentValue,"aria-valuetext":_vm.text,"aria-valuemin":"0","aria-valuemax":_vm.max,"tabindex":"0"},on:{"keydown":_vm.handleKey}},[_vm._l((_vm.max),function(item,key){return _c('span',{key:key,staticClass:"el-rate__item",style:({ cursor: _vm.rateDisabled ? 'auto' : 'pointer' }),on:{"mousemove":function($event){_vm.setCurrentValue(item, $event)},"mouseleave":_vm.resetCurrentValue,"click":function($event){_vm.selectValue(item)}}},[_c('i',{staticClass:"el-rate__icon",class:[_vm.classes[item - 1], { 'hover': _vm.hoverIndex === item }],style:(_vm.getIconStyle(item))},[(_vm.showDecimalIcon(item))?_c('i',{staticClass:"el-rate__decimal",class:_vm.decimalIconClass,style:(_vm.decimalStyle)}):_vm._e()])])}),(_vm.showText || _vm.showScore)?_c('span',{staticClass:"el-rate__text",style:({ color: _vm.textColor })},[_vm._v(_vm._s(_vm.text))]):_vm._e()],2)}
|
594 | var staticRenderFns = []
|
595 | var esExports = { render: render, staticRenderFns: staticRenderFns }
|
596 | __webpack_exports__["a"] = (esExports);
|
597 |
|
598 | }),
|
599 |
|
600 | 8:
|
601 | (function(module, exports) {
|
602 |
|
603 | module.exports = require("element-ui/lib/mixins/migrating");
|
604 |
|
605 | })
|
606 |
|
607 | }); |
\ | No newline at end of file |