1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
| <template>
| <el-transfer
| v-model="status.value"
| filterable
| :props="status.props"
| :titles="['未添加标签页', '已添加标签页']"
| :button-texts="['移除', '添加']"
| :data="status.data"
| class="transfer-width320"
| @change="handlerChange"
| >
| </el-transfer>
| </template>
|
| <script>
| import const_page from "@/assets/js/const/const_page";
| import getItemByKey from "@/assets/js/tools/getItemByKey";
| import i18n from '../i18n/realTime';
| import { createI18nOption } from '@/assets/js/tools/i18n';
| const i18nMixin = createI18nOption(i18n, [[i18nConst_61850, '61850']]);
| import {
| getPageParamUserAllList,
| upPageParamUserList,
| addPageParamUserList
| } from "@/views/pageSetting/js/api";
| export default {
| name: "TabsConfig",
| components: {},
| data() {
| return {
| status: {
| props: {
| key: "key",
| label: "label"
| },
| value: [],
| data: []
| }
| };
| },
| methods: {
| handlerChange(list, type, values) {
| // 根据类型确定事件
| switch (type) {
| case "left":
| this.remove(values);
| break;
| case "right":
| this.add(values);
| break;
| }
| },
| add(list) {
| let params = {
| operationFlag: 1
| };
| let postData = [];
| list.map(item => {
| postData.push({
| key: item,
| type: 1
| });
| });
| upPageParamUserList(params, postData)
| .then(res => {
| let rs = res.data;
| if (rs.code == 1) {
| // 提示信息
| this.$message({
| type: "success",
| message: rs.msg
| });
| } else {
| // 提示信息
| this.$message({
| type: "error",
| message: rs.msg
| });
| }
| // 更新数据
| this.searchPageConfig();
| })
| .catch(error => {
| console.log(error);
| });
| },
| remove(list) {
| let params = {
| operationFlag: -1
| };
| let postData = [];
| list.map(item => {
| postData.push({
| key: item,
| type: 1
| });
| });
| upPageParamUserList(params, postData)
| .then(res => {
| let rs = res.data;
| if (rs.code == 1) {
| // 提示信息
| this.$message({
| type: "success",
| message: rs.msg
| });
| } else {
| // 提示信息
| this.$message({
| type: "error",
| message: rs.msg
| });
| }
| // 更新数据
| this.searchPageConfig();
| })
| .catch(error => {
| console.log(error);
| });
| },
| initList() {
| let tabs = const_page.realTime;
| addPageParamUserList(tabs)
| .then(res => {
| let rs = res.data;
| if (rs.code == 1) {
| // 提示信息
| this.$message({
| type: "success",
| message: rs.msg
| });
| } else {
| // 提示信息
| this.$message({
| type: "error",
| message: rs.msg
| });
| }
| })
| .catch(error => {
| console.log(error);
| });
| },
| searchPageConfig() {
| let postData = {
| type: 1
| };
| getPageParamUserAllList(postData)
| .then(res => {
| let rs = res.data;
| let newData = [];
| let data = rs.data;
| console.log("data", data);
| if (JSON.stringify(data) != "{}") {
| for (let key in data) {
| newData.push(...data[key]);
| }
| // 更新选中状态
| this.changeValue(newData);
| } else {
| this.initList();
| }
| })
| .catch(error => {
| console.log(error);
| });
| },
| getPageConfigData() {
| let tabs = const_page.realTime;
| return tabs.map(item => {
| return {
| key: item.key,
| type: item.type,
| label: item.label,
| show: item.show
| };
| });
| },
| changeValue(data) {
| let tabs = this.getPageConfigData();
| tabs = tabs.map(item => {
| let itemData = getItemByKey(item.key, data);
| item.show = itemData == 0 ? true : itemData.show;
| return item;
| });
| this.status.value = tabs
| .filter(item => {
| return item.show;
| })
| .map(item => {
| return item.key;
| });
| }
| },
| mounted() {
| let tabs = this.getPageConfigData();
| this.status.data = tabs;
| this.searchPageConfig();
| }
| };
| </script>
|
| <style scoped></style>
|
|