vue-ant-patterns
Version:
vue-ant-patterns
230 lines (190 loc) • 5.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _antDesignVue = require('ant-design-vue');
var _dContainer = require('../../lib/d-container');
var _dContainer2 = _interopRequireDefault(_dContainer);
var _vueTypes = require('ant-design-vue/lib/_util/vue-types');
var _vueTypes2 = _interopRequireDefault(_vueTypes);
var _bizUtils = require('../_biz-utils');
var _LocaleReceiver = require('ant-design-vue/lib/locale-provider/LocaleReceiver');
var _LocaleReceiver2 = _interopRequireDefault(_LocaleReceiver);
var _en_US = require('./locale/en_US');
var _en_US2 = _interopRequireDefault(_en_US);
var _zh_CN = require('./locale/zh_CN');
var _zh_CN2 = _interopRequireDefault(_zh_CN);
var _miniRecognition = require('./miniRecognition');
var _miniRecognition2 = _interopRequireDefault(_miniRecognition);
var _fullRecognition = require('./fullRecognition');
var _fullRecognition2 = _interopRequireDefault(_fullRecognition);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var Horizontal = _dContainer2['default'].Horizontal;
var Step = _antDesignVue.Steps.Step;
var Option = _antDesignVue.Select.Option;
// const API_URL = 'http://192.168.167.210:9090/platform/api';
var API_PLATFORM = (global || window).globalJSConfig.SERVICE_CONFIG.API_PLATFORM;
var langType = {
'zh-cn': _zh_CN2['default'],
'en-us': _en_US2['default']
};
var BRecognition = {
name: 'BRecognition',
props: {
type: {
type: String,
'default': 'mini' // mini || full
},
empId: {
type: String,
'default': ''
},
// 隐藏信息完整度及标签展示区
hideIntegrityAndTags: {
type: Boolean,
'default': false
},
// 折叠区
collapsible: {
type: Boolean,
'default': true
},
defTagsList: {
type: Array,
'default': function _default() {
return [];
}
},
// 是否显示完整度
showIntegrity: {
type: Boolean,
'default': true
}
},
data: function data() {
var type = this.$props.type;
return {
localeCode: 'zh-cn',
recoInfo: {},
v_type: type,
tagsList: []
};
},
watch: {
empId: function empId(val) {
// 初始化人员数据
this.initInfo();
this.getTags();
}
},
components: {
fullRecognition: _fullRecognition2['default'],
miniRecognition: _miniRecognition2['default']
},
computed: {},
created: function created() {
// 初始化人员数据
this.initInfo();
this.getTags();
},
mounted: function mounted() {},
methods: {
/**
* 获取默认语言
*/
getDefaultLocale: function getDefaultLocale() {
var result = {
lang: (0, _extends3['default'])({}, _zh_CN2['default'])
};
return result;
},
// 初始化数据
initInfo: function initInfo() {
var _this = this;
(0, _bizUtils.request)({
url: API_PLATFORM + 'employeeCoreController/getEmployeeListById',
data: {
empId: this.empId === '' ? this.$ils.get('employeeDto').employeeId : this.empId
}
}).then(function (_ref) {
var data = _ref.data;
_this.recoInfo = data.data[0];
})['catch'](function (error) {
console.log(error);
_this.$message.error(error);
});
},
// 获取员工画像接口
getTags: function getTags() {
var _this2 = this;
(0, _bizUtils.request)({
url: API_PLATFORM + 'daTagController/getLimitTags',
data: {
empId: this.empId === '' ? this.$ils.get('employeeDto').employeeId : this.empId,
limit: '100'
}
}).then(function (_ref2) {
var data = _ref2.data;
_this2.tagsList = data.data.tags;
if (data.data.tags.length === 0 && _this2.$props.defTagsList.length > 0) {
_this2.tagsList = _this2.$props.defTagsList;
}
})['catch'](function (error) {
console.log(error);
_this2.$message.error(error);
});
},
editAction: function editAction() {
this.$emit('editAction');
},
renderComponent: function renderComponent(contextLocale, locale) {
var _this3 = this;
var h = this.$createElement;
this.localeCode = locale;
var localMsg = langType[locale];
var $slots = this.$slots,
$props = this.$props;
var hideIntegrityAndTags = $props.hideIntegrityAndTags,
collapsible = $props.collapsible,
showIntegrity = $props.showIntegrity;
var recProps = {
props: {
recognitionInfo: this.recoInfo,
option: $slots ? $slots.option : null,
localMsg: localMsg,
tagsList: this.tagsList, // 标签
hideIntegrityAndTags: hideIntegrityAndTags,
collapsible: collapsible,
showIntegrity: showIntegrity
},
on: {
// 切换模式
changeType: function changeType(val) {
_this3.v_type = val;
}
}
};
return h(
_dContainer2['default'],
{ 'class': 'transition_container' },
[this.v_type === 'full' ? h('full-Recognition', recProps) : h('mini-Recognition', recProps)]
);
}
},
render: function render() {
var h = arguments[0];
return h(_LocaleReceiver2['default'], {
attrs: {
componentName: 'bRecognition',
defaultLocale: this.getDefaultLocale
},
scopedSlots: { 'default': this.renderComponent }
});
}
};
BRecognition.install = function (Vue) {
Vue.component(BRecognition.name, BRecognition);
};
exports['default'] = BRecognition;