SysSetting.vue
7.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
<template>
<div class="fullheight">
<el-form v-form data-vv-scope="propertyForm">
<table class="form-table" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<th width="130px">系统管理端名称:</th>
<td>
<ht-input v-model="sysSettingData.manageName" class="ht" placeholder="请输入系统管理端名称" autocomplete="off" :maxlength="50" :showWordLimit="true"></ht-input>
</td>
</tr>
<tr>
<th width="130px">系统管理端Logo:</th>
<td>
<FileUpload ref="manageLogo" model-name="sysSettingData.manageLogo" :accept='`.jpg,.jpeg,.png,.JPG,.JPEG`' :limit="1" :multiple="false"> </FileUpload>
</td>
</tr>
<tr>
<th width="130px">系统应用端名称:</th>
<td>
<ht-input v-model="sysSettingData.frontName" class="ht" placeholder="请输入系统应用端名称" autocomplete="off" :maxlength="50" :showWordLimit="true"></ht-input>
</td>
</tr>
<tr>
<th width="130px">系统应用端Logo:</th>
<td>
<FileUpload ref="frontLogo" model-name="sysSettingData.frontLogo" :accept='`.jpg,.jpeg,.png,.JPG,.JPEG`' :limit="1" :multiple="false"> </FileUpload>
</td>
</tr>
<tr>
<th width="130px">系统登录页Logo:</th>
<td>
<FileUpload ref="ico" model-name="sysSettingData.ico" :accept='`.jpg,.jpeg,.png,.JPG,.JPEG`' :limit="1" :multiple="false"> </FileUpload>
</td>
</tr>
</tbody>
</table>
</el-form>
<br>
<ht-submit-button
:url="saveUrl"
:isSubmit="isSubmit"
:model="currentProperty"
scope-name="propertyForm"
@before-save-data="beforeSaveData"
>{{$t("eip.common.save")}}</ht-submit-button>
<el-button type="danger" @click="handleClear">{{$t('eip.common.clear')}}</el-button>
</div>
</template>
<script>
const FileUpload = () => import("@/components/common/FileUpload.vue");
import portal from "@/api/portal.js";
import req from "@/request.js";
export default {
name: "sysSetting",
components: {
FileUpload,
},
data() {
return {
isSubmit:false,
saveUrl: `${window.context.portal}/sys/sysProperties/v1/save`,
sysSettingData:{manageLogo:[],frontLogo:[],ico:[],manageName:"",frontName:""},
currentProperty: { encrypt: 1 ,name:"系统Logo/名称",alias:"sysSetting",description:"当前系统的管理端Logo、应用端Logo、登录页Logo和名称。",value:""}
}
},
watch: {
"currentProperty.value": {
handler(newVal, oldVal) {
const this_ = this;
if (newVal) {
setTimeout(function(){
this_.init();
},1000);
}
},
immediate: true,
deep: true
}
},
mounted() {
this.init();
},
methods: {
//查看系统设置
init(){
const this_ = this;
this_.sysSettingData={manageLogo:[],frontLogo:[],ico:[],manageName:"",frontName:""},
portal.getDecryptBySysSetting().then(response => {
if(response && response.value){
this_.sysSettingData = JSON.parse(response.value);
setTimeout(function(){
if(this_.sysSettingData.manageLogo.length>0){
this_.$refs.manageLogo.setFiles(this_.sysSettingData.manageLogo);
}
if(this_.sysSettingData.frontLogo.length>0){
this_.$refs.frontLogo.setFiles(this_.sysSettingData.frontLogo);
}
if(this_.sysSettingData.ico.length>0){
this_.$refs.ico.setFiles(this_.sysSettingData.ico);
}
},1000);
this_.currentProperty.id = response.id;
}
});
},
//保存前
beforeSaveData() {
const this_ = this;
this_.isSubmit = true;
if(this_.$refs.manageLogo.getFiles().length>0){
this.sysSettingData.manageLogo = this_.$refs.manageLogo.getFiles();
}
if(this_.$refs.frontLogo.getFiles().length>0){
this_.sysSettingData.frontLogo = this_.$refs.frontLogo.getFiles();
}
if(this_.$refs.ico.getFiles().length>0){
this_.sysSettingData.ico = this_.$refs.ico.getFiles();
}
if(this_.sysSettingData.manageLogo.length==0 && this_.sysSettingData.frontLogo.length==0 && this_.sysSettingData.ico.length==0
&& this_.sysSettingData.manageName=="" && this_.sysSettingData.frontName==""){
this_.isSubmit = false;
this_.$message.warning("请填写其中一项再保存");
return;
}
this_.currentProperty.value = JSON.stringify(this_.sysSettingData);
},
//清空系统设置
handleClear(){
const this_ = this;
if(!this_.currentProperty.id){
this_.$message.warning("请先保存数据再清空");
return;
}
req.remove(`${window.context.portal}/sys/sysProperties/v1/remove?ids=${this_.currentProperty.id}`).then(response => {
if(response.data){
if(response.data.state){
this_.sysSettingData = {manageLogo:[],frontLogo:[],ico:[],manageName:"",frontName:""};
this_.currentProperty = { encrypt: 1 ,name:"系统Logo/名称",alias:"sysSetting",description:"当前系统的管理端Logo、应用端Logo、登录页Logo和名称。",value:""};
this_.$refs.manageLogo.setFiles([]);
this_.$refs.frontLogo.setFiles([]);
this_.$refs.ico.setFiles([]);
this_.$forceUpdate();
this_.$message.success("清空成功,请重新登录后查看");
}
}
});
}
}
};
</script>
<style lang="scss" scoped>
.ht {
width: 100%;
}
.table > thead > tr > th,
.table > thead > th,
.table > tr > th,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > tr > td,
.table > tfoot > tr > td {
border-top: 1px solid #e7eaec;
border-left: 1px solid #e7eaec;
line-height: 1.42857;
padding: 4px 8px;
vertical-align: middle;
text-align: center;
}
.table {
border-bottom: 1px solid #e7eaec;
border-right: 1px solid #e7eaec;
width: 100%;
border-spacing: 0;
}
</style>