backSide.vue
6.15 KB
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
204
205
206
207
208
209
210
211
<template>
<div>
<el-row class="manage-head-wrapper">
<el-col :span="24" :sm="24">
<span class="condition-item-text">关键词:</span>
<div class="manage-select-box">
<el-input v-model="keyWord" class="search-inp" placeholder="请输入要查询的关键词" clearable />
</div>
<el-button type="primary" class="search-btn" plain size="mini" @click="searchData()">
{{ $t('button.search') }}</el-button>
<!-- <el-button type="primary" style="float:right" class="search-btn" plain size="mini" @click="exportData()">
导出<i class="el-icon-download el-icon--right"></i></el-button> -->
<el-button type="primary" style="float:right" class="search-btn" plain size="mini" @click="saveData()">
提交配置</el-button>
</el-col>
</el-row>
<el-row class="manage-content">
<el-col :span="24">
<el-table id="languageTable" :data="tableData" border :max-height="tableHeight" v-loading="loading" style="width: 100%"
header-row-class-name="manage-tab-head">
<el-table-column label="Key" align="center" prop="key">
<template #default="{ row }">
{{ row.key }}
</template>
</el-table-column>
<el-table-column label="中文" align="center" prop="zh">
<template #default="{ row }">
<el-input class="nborder" v-model="row.zh" />
</template>
</el-table-column>
<el-table-column label="英文" align="center" prop="en">
<template #default="{ row }">
<el-input class="nborder" v-model="row.en" />
</template>
</el-table-column>
<el-table-column label="繁体" align="center" prop="tw">
<template #default="{ row }">
<el-input class="nborder" v-model="row.tw" />
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
</div>
</template>
<script>
var tempTableData = [];
import _ from 'underscore';
export default {
data() {
return {
keyWord: '',
dloading: false,
loading: true,
tableData: []
}
},
components: {
},
computed: {
tableHeight() {
const windowInnerHeight = window.innerHeight
return windowInnerHeight - 200
},
},
mounted() {
},
created() {
this.getLangData();
window.language = this;
},
methods: {
exportData(){
this.dealExport('languageTable','国际化文件');
},
async searchData(isAdd) {
this.loading = true;
await this.timeWait(100);
if (!this.keyWord) {
this.tableData = tempTableData;
this.loading = false;
return;
}
this.tableData = _.filter(tempTableData, item => {
return [item.zh, (item.en || '').toLowerCase(), item.tw].join('#').includes(this.keyWord.toLowerCase());
})
this.$nextTick(() => {
setTimeout(() => {
this.loading = false;
}, 1500);
})
},
timeWait(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, time);
})
},
// 新搜索条件 end
async getLangData() {
this.loadLang().then(res=>{
let {zh_CN,en_US,zh_TW} = res.data.data;
this.setTableData({
en: en_US,
tw: zh_TW,
zh: zh_CN
});
})
},
loadLang(lang) {
return this.$api.management.getBackLanguage();
},
setLang(params) {
//let formData = new FormData();
//formData.append('content', content);
return this.$api.management.setBackLanguage(params);
},
setTableData(data) {
let keys = _.keys(data.zh);
tempTableData = [];
_.each(keys, key => {
tempTableData.push({
key: key,
en: data.en[key],
tw: data.tw[key],
zh: data.zh[key],
});
});
this.tableData = tempTableData;
this.$nextTick(() => {
this.loading = false;
})
},
async saveData() {
this.loading = true;
let enObj = {}, twObj = {}, zhObj = {};
_.each(tempTableData, item => {
let key = item.key;
enObj[key] = item.en;
twObj[key] = item.tw;
zhObj[key] = item.zh;
})
let res = this.setLang({
zh_CN:zhObj,
en_US:enObj,
zh_TW:twObj
});
this.loading = false;
this.$message({
message: '保存成功',
type: 'success'
});
},
}
}
</script>
<style scoped>
.manage-input-box {
margin-right: 10px;
}
.condition-item-text {
float: left;
position: relative;
top: 6px;
}
.btn-box:after,
.btn-box:before {
content: '';
display: table;
}
.btn-box:after {
clear: both;
}
.fl-btn+.fl-btn {
margin-right: 20px;
}
.online-column {
color: #67c23a;
}
.offline-column {
color: #f56c6c;
}
.iplink-column {
text-decoration: underline;
}
.manage-content {
padding-bottom: 0;
}
.manage-content /deep/ .nborder .el-input__inner {
border: none;
height: 30px !important;
background-color: transparent;
}
.manage-content /deep/ .cell {
padding: 0;
}
</style>