UNPKG

captain-ui

Version:

有赞vue wap业务组件库

109 lines (101 loc) 2.78 kB
"use strict"; exports.__esModule = true; exports.default = void 0; var _default = { render: function render() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('li', { staticClass: "cap-filter-bar__item", class: { 'cap-filter-bar__item--sort': _vm.type === 'sort', 'cap-filter-bar__item--active': _vm.active }, style: { color: _vm.active ? _vm.color : '' }, on: { "click": _vm.handleClick } }, [_vm._v("\n " + _vm._s(_vm.title) + "\n "), _vm.type === 'sort' ? _c('div', { staticClass: "cap-filter-bar__sort-icon", class: (_obj = {}, _obj["cap-filter-bar__sort-icon--" + _vm.direction] = _vm.direction, _obj) }, [_c('div', { staticClass: "cap-filter-bar__sort-icon__ascend", style: { borderColor: _vm.active && _vm.direction === 'ascend' ? _vm.color : '' } }), _c('div', { staticClass: "cap-filter-bar__sort-icon__descend", style: { borderColor: _vm.active && _vm.direction === 'descend' ? _vm.color : '' } })]) : _vm._e()]); var _obj; }, name: 'cap-filter-item', props: { title: { type: String, default: '' }, type: { type: String, default: '', validator: function validator(value) { if (value && value !== 'sort') { return false; } return true; } }, defaultDirection: { type: String, default: '', validator: function validator(value) { if (!value) { return true; } return ['ascend', 'descend'].indexOf(value) !== -1; } } }, data: function data() { return { filterIndex: this.$parent.$children.indexOf(this), color: this.$parent.color }; }, computed: { active: function active() { return this.$parent.currentFilter === this.$parent.$children.indexOf(this); }, direction: function direction() { if (this.$parent.commonFilters.length > 0) { return this.$parent.commonFilters[this.$parent.$children.indexOf(this)].sortDirection || ''; } return ''; } }, methods: { handleClick: function handleClick() { var title = this.title, type = this.type, defaultDirection = this.defaultDirection, sortDirection = this.direction, filterIndex = this.filterIndex; var filter = this.type === 'sort' ? { title: title, type: type, defaultDirection: defaultDirection, sortDirection: sortDirection } : { title: title, type: type }; this.$parent.handleClick(filter, filterIndex); } } }; exports.default = _default;