iep-ui
Version:
An enterprise-class UI design language and Vue-based implementation
118 lines (99 loc) • 2.77 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _vueTypes = require('../_util/vue-types');
var _vueTypes2 = _interopRequireDefault(_vueTypes);
var _configConsumerProps = require('../config-provider/configConsumerProps');
var _satisfice = require('./icons/satisfice');
var _satisfice2 = _interopRequireDefault(_satisfice);
var _sSatisfice = require('./icons/sSatisfice');
var _sSatisfice2 = _interopRequireDefault(_sSatisfice);
var _lodash = require('lodash');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
exports['default'] = {
name: 'IepSundryRate',
model: {
prop: 'value',
event: 'change'
},
props: {
text: _vueTypes2['default'].string,
value: _vueTypes2['default'].value,
normalColor: _vueTypes2['default'].string.def('#8a97a0'),
activeColor: _vueTypes2['default'].string.def('#00c822')
},
inject: {
configProvider: { 'default': function _default() {
return _configConsumerProps.ConfigConsumerProps;
} }
},
data: function data() {
return {
localValue: false
};
},
watch: {
value: {
handler: function handler(e) {
this.localValue = e;
}
}
},
methods: {
handleTap: function handleTap() {
this.localValue = !this.localValue;
this.$emit('change', this.localValue);
}
},
render: function render() {
var _this = this;
var h = arguments[0];
var customizePrefixCls = this.prefixCls,
$slots = this.$slots,
$props = this.$props,
localValue = this.localValue;
var getPrefixCls = this.configProvider.getPrefixCls;
var prefixCls = getPrefixCls('iep-sundry-rate', customizePrefixCls);
var text = $props.text,
normalColor = $props.normalColor,
activeColor = $props.activeColor;
var textVNodes = h(
'div',
{ 'class': prefixCls + '-text' },
[localValue ? '满意' : '不满意']
);
if (!(0, _lodash.isEmpty)(text)) {
textVNodes = h(
'div',
{ 'class': prefixCls + '-text' },
[text]
);
}
if (!(0, _lodash.isEmpty)($slots['default'])) {
textVNodes = h(
'div',
{ 'class': prefixCls + '-text' },
[$slots['default']]
);
}
return h(
'div',
{ 'class': prefixCls, on: {
'click': function click() {
return _this.handleTap();
}
}
},
[h(
'div',
{ 'class': prefixCls + '-icon' },
[localValue ? h(_sSatisfice2['default'], {
attrs: { color: activeColor }
}) : h(_satisfice2['default'], {
attrs: { color: normalColor }
})]
), textVNodes]
);
}
};
;