|
@@ -0,0 +1,154 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="common-screen-item">
|
|
3
|
+ <label class="common-screen-label">{{ labelName }}</label>
|
|
4
|
+ <!-- 系统管理员 -->
|
|
5
|
+ <el-cascader v-if="isSuperManage" v-model="system_enterprise_res" size="small" :options="enterpriseList" :props="{value:'self_id',label:'self_name',children:'manage_corp_list'}" @change="onChangeCorpidSystem" clearable filterable :placeholder="placeholder" class="select-cls cascader" />
|
|
6
|
+ <!-- 非系统管理员 -->
|
|
7
|
+ <el-select v-else v-model="enterprise_res" size="small" filterable :placeholder="placeholder" @change="onChangeCorpid" clearable class="select-cls">
|
|
8
|
+ <el-option v-for="(item, index) in enterpriseList" :key="index+'enterpriseList'" :label="item.corp_name?item.corp_name:item.corp_full_name?item.corp_full_name:item.corpid" :value="item.corpid" />
|
|
9
|
+ </el-select>
|
|
10
|
+ </div>
|
|
11
|
+</template>
|
|
12
|
+
|
|
13
|
+<script>
|
|
14
|
+export default {
|
|
15
|
+ props: {
|
|
16
|
+ value: {
|
|
17
|
+ type: String,
|
|
18
|
+ default: () => '',
|
|
19
|
+ },
|
|
20
|
+ labelName: {
|
|
21
|
+ type: String,
|
|
22
|
+ default: () => '企微主体'
|
|
23
|
+ },
|
|
24
|
+ placeholder: {
|
|
25
|
+ type: String,
|
|
26
|
+ default: () => '请选择'
|
|
27
|
+ },
|
|
28
|
+ },
|
|
29
|
+ data() {
|
|
30
|
+ return {
|
|
31
|
+ enterpriseList: [], // 企微主体数据
|
|
32
|
+ enterprise: {}, // 当前选择的企微信息
|
|
33
|
+ system_enterprise_res: [], // 企微主体数据
|
|
34
|
+ enterprise_res: '',
|
|
35
|
+ }
|
|
36
|
+ },
|
|
37
|
+ computed: {
|
|
38
|
+ isSuperManage() {
|
|
39
|
+ return this.$cookie.getCookie('isSuperManage') == 1
|
|
40
|
+ },
|
|
41
|
+ },
|
|
42
|
+ watch: {
|
|
43
|
+ value(newVal) {
|
|
44
|
+ if (!newVal) { // 初始化当前企微数据
|
|
45
|
+ this.enterprise = {}
|
|
46
|
+ this.system_enterprise_res = []
|
|
47
|
+ this.enterprise_res = ''
|
|
48
|
+ return
|
|
49
|
+ }
|
|
50
|
+ if (this.isSuperManage) { // 获取超管下的当前企微信息
|
|
51
|
+ this.handleGetCurrentEnterpriseSys(newVal)
|
|
52
|
+ const res = this.enterpriseList.find(e => {
|
|
53
|
+ return e.manage_corp_list && e.manage_corp_list.length && e.manage_corp_list.some(corp => corp.corpid == newVal)
|
|
54
|
+ })
|
|
55
|
+ this.system_enterprise_res = res ? [String(res.group_id), newVal] : []
|
|
56
|
+ } else { // 获取当前企微信息
|
|
57
|
+ this.handleGetCurrentEnterprise(newVal)
|
|
58
|
+ this.enterprise_res = this.enterprise.corpid || ''
|
|
59
|
+ }
|
|
60
|
+ }
|
|
61
|
+ },
|
|
62
|
+ mounted() {
|
|
63
|
+ this.handleInitCorpOptions()
|
|
64
|
+ },
|
|
65
|
+ methods: {
|
|
66
|
+ // 企业筛选初始化
|
|
67
|
+ handleInitCorpOptions() {
|
|
68
|
+ if (this.isSuperManage) {//系统管理员
|
|
69
|
+ const enterpriseList = this.$store.state.authorize_corpList;
|
|
70
|
+ enterpriseList.forEach(item => {//为了el-cascader更改props
|
|
71
|
+ item.self_id = item.group_id.toString();
|
|
72
|
+ item.self_name = item.group_name;
|
|
73
|
+ item.manage_corp_list.forEach(item1 => {
|
|
74
|
+ item1.self_id = item1.corpid;
|
|
75
|
+ item1.self_name = item1.corp_name;
|
|
76
|
+ })
|
|
77
|
+ });
|
|
78
|
+ this.enterpriseList = enterpriseList
|
|
79
|
+ } else {
|
|
80
|
+ this.enterpriseList = this.$store.state.authorize_corpList;
|
|
81
|
+ }
|
|
82
|
+ },
|
|
83
|
+ handleGetCurrentEnterprise(currentCorpid) {
|
|
84
|
+ if (!currentCorpid) {
|
|
85
|
+ this.enterprise = {}
|
|
86
|
+ } else {
|
|
87
|
+ const res = this.enterpriseList.filter(v => v.corpid == currentCorpid)[0];
|
|
88
|
+ this.enterprise = res || {}
|
|
89
|
+ }
|
|
90
|
+ },
|
|
91
|
+ handleGetCurrentEnterpriseSys(currentCorpid) {
|
|
92
|
+ if (!currentCorpid) {
|
|
93
|
+ this.enterprise = {}
|
|
94
|
+ } else {
|
|
95
|
+ this.enterprise = {}
|
|
96
|
+ this.enterpriseList.forEach((item) => {
|
|
97
|
+ item.manage_corp_list.forEach((item1) => {
|
|
98
|
+ if (item1.corpid == currentCorpid) {
|
|
99
|
+ this.enterprise = item1
|
|
100
|
+ }
|
|
101
|
+ })
|
|
102
|
+ })
|
|
103
|
+ }
|
|
104
|
+ },
|
|
105
|
+ onChangeCorpidSystem(val) {
|
|
106
|
+ if (val && val.length) {
|
|
107
|
+ this.handleGetCurrentEnterpriseSys(val[1])
|
|
108
|
+ } else {
|
|
109
|
+ this.handleGetCurrentEnterpriseSys('')
|
|
110
|
+ }
|
|
111
|
+ this.handleEmit()
|
|
112
|
+ },
|
|
113
|
+ onChangeCorpid(val) {
|
|
114
|
+ this.handleGetCurrentEnterprise(val)
|
|
115
|
+ this.handleEmit()
|
|
116
|
+ },
|
|
117
|
+ handleEmit() {
|
|
118
|
+ this.$emit('input', this.enterprise.corpid || '')
|
|
119
|
+ this.$emit('change', this.enterprise.corpid ? this.enterprise : null)
|
|
120
|
+ },
|
|
121
|
+ }
|
|
122
|
+}
|
|
123
|
+</script>
|
|
124
|
+
|
|
125
|
+<style lang="scss" scoped>
|
|
126
|
+.select-cls {
|
|
127
|
+ /deep/ .el-input__inner {
|
|
128
|
+ width: 210px;
|
|
129
|
+ }
|
|
130
|
+ /deep/ &.el-select .el-input.is-focus .el-input__inner,
|
|
131
|
+ /deep/ &.el-select .el-input__inner:focus,
|
|
132
|
+ /deep/ &.el-cascader .el-input.is-focus .el-input__inner,
|
|
133
|
+ /deep/ &.el-cascader .el-input__inner:focus {
|
|
134
|
+ border-color: #DCDFE6;
|
|
135
|
+ }
|
|
136
|
+ /deep/ .el-input__suffix {
|
|
137
|
+ border-top-right-radius: 4px;
|
|
138
|
+ border-bottom-right-radius: 4px;
|
|
139
|
+ border: 1px solid #DCDFE6;
|
|
140
|
+ right: 0;
|
|
141
|
+ width: 30px;
|
|
142
|
+ background-color: #F1F1F1;
|
|
143
|
+ .el-input__icon {
|
|
144
|
+ color: #909399;
|
|
145
|
+ }
|
|
146
|
+ }
|
|
147
|
+ &.cascader {
|
|
148
|
+ /deep/ .el-input__suffix {
|
|
149
|
+ height: 32px;
|
|
150
|
+ top: 2px;
|
|
151
|
+ }
|
|
152
|
+ }
|
|
153
|
+}
|
|
154
|
+</style>
|