perf: 函数功能抽离

This commit is contained in:
jiangweidong
2023-05-16 17:39:57 +08:00
committed by Jiangjie.Bai
parent 8489d94643
commit 40ccab1a19

View File

@@ -63,9 +63,9 @@ export default {
title: this.$t('users.setWeCom'), title: this.$t('users.setWeCom'),
attrs: { attrs: {
type: 'primary', type: 'primary',
label: this.$store.state.users.profile.wecom_id ? this.$t('common.unbind') : this.$t('common.bind'), label: this.getBindLabel('wecom_id'),
disabled: this.isComponentDisabled('wecom_id'), disabled: this.isDisabled('wecom_id'),
showTip: this.isComponentDisabled('wecom_id'), showTip: this.isDisabled('wecom_id'),
tip: this.$t('users.UnbindHelpText') tip: this.$t('users.UnbindHelpText')
}, },
has: this.$store.getters.publicSettings.AUTH_WECOM, has: this.$store.getters.publicSettings.AUTH_WECOM,
@@ -80,9 +80,9 @@ export default {
title: this.$t('users.setDingTalk'), title: this.$t('users.setDingTalk'),
attrs: { attrs: {
type: 'primary', type: 'primary',
label: this.$store.state.users.profile.dingtalk_id ? this.$t('common.unbind') : this.$t('common.bind'), label: this.getBindLabel('dingtalk_id'),
disabled: this.isComponentDisabled('dingtalk_id'), disabled: this.isDisabled('dingtalk_id'),
showTip: this.isComponentDisabled('dingtalk_id'), showTip: this.isDisabled('dingtalk_id'),
tip: this.$t('users.UnbindHelpText') tip: this.$t('users.UnbindHelpText')
}, },
has: this.$store.getters.publicSettings.AUTH_DINGTALK, has: this.$store.getters.publicSettings.AUTH_DINGTALK,
@@ -97,9 +97,9 @@ export default {
title: this.$t('users.setFeiShu'), title: this.$t('users.setFeiShu'),
attrs: { attrs: {
type: 'primary', type: 'primary',
label: this.$store.state.users.profile.feishu_id ? this.$t('common.unbind') : this.$t('common.bind'), label: this.getBindLabel('feishu_id'),
disabled: this.isComponentDisabled('feishu_id'), disabled: this.isDisabled('feishu_id'),
showTip: this.isComponentDisabled('feishu_id'), showTip: this.isDisabled('feishu_id'),
tip: this.$t('users.UnbindHelpText') tip: this.$t('users.UnbindHelpText')
}, },
has: this.$store.getters.publicSettings.AUTH_FEISHU, has: this.$store.getters.publicSettings.AUTH_FEISHU,
@@ -127,7 +127,7 @@ export default {
attrs: { attrs: {
type: 'primary', type: 'primary',
label: this.$t('common.Update'), label: this.$t('common.Update'),
disabled: this.$store.state.users.profile.source.value !== 'local' disabled: this.isUserFromSource('local')
}, },
callbacks: { callbacks: {
click: function() { click: function() {
@@ -309,8 +309,17 @@ export default {
} }
}, },
methods: { methods: {
isComponentDisabled(source) { isBind(sourceField) {
return !!this.$store.state.users.profile[source] && this.$store.state.users.profile.source.value !== 'local' return !!this.$store.state.users.profile[sourceField]
},
getBindLabel(sourceField) {
return this.isBind(sourceField) ? this.$t('common.unbind') : this.$t('common.bind')
},
isUserFromSource(sourceName) {
return this.$store.state.users.profile.source.value !== sourceName
},
isDisabled(sourceField) {
return this.isBind(sourceField) && this.isUserFromSource('local')
}, },
updateUserReceiveBackends(val) { updateUserReceiveBackends(val) {
this.$axios.patch( this.$axios.patch(