ImportCheckJarManager.vue
8.71 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<template>
<el-dialog
title="选择校验Jar包"
width="70%"
class="check-jar"
append-to-body
:close-on-click-modal="false"
:visible.sync="outerVisible"
>
<div class="fullheight" v-if="outerVisible">
<ht-table
@load="loadData"
:data="data"
:pageResult="pageResult"
:selection="true"
quick-search-props="classPath,desc"
:show-export="false"
:show-custom-column="false"
highlight-current-row
:selectable="false"
ref="htTable"
@row-click="rowClick"
>
<template v-slot:toolbar>
<el-button-group>
<el-button size="small" @click="showDialog()" icon="el-icon-plus">添加</el-button>
</el-button-group>
</template>
<template>
<ht-table-column type="index" width="50" align="center" label="序号" />
<ht-table-column prop="desc" label="描述" :sortable="true" :show-overflow-tooltip="true" />
<ht-table-column
prop="classPath"
label="校验类路径"
:sortable="true"
:show-overflow-tooltip="true"
/>
</template>
<ht-table-column label="操作" align="left" width="150">
<template v-slot="{row}">
<el-button size="mini" @click="showDialog(row.id,$event)">编辑</el-button>
<el-button size="mini" type="danger" @click="removeJar(row.id,$event)">删除</el-button>
</template>
</ht-table-column>
</ht-table>
<el-dialog
width="50%"
:title="importCheckJar.id?'编辑校验Jar包':'添加校验Jar包'"
class="sp-manager__dialog"
append-to-body
:visible="dialogVisible"
:before-close="beforeCloseDialog"
:close-on-click-modal="false"
top="20vh"
>
<el-form v-form data-vv-scope="importCheckJarForm">
<ht-form-item label="描述">
<ht-input v-model="importCheckJar.desc" validate="required" />
</ht-form-item>
<ht-form-item label="校验类路径">
<ht-input v-model="importCheckJar.classPath" validate="required" />
</ht-form-item>
<ht-form-item label="Jar包">
<el-upload
class="upload-demo"
:action="actionUrl"
:on-remove="handleRemove"
:file-list="files"
:headers="header"
:on-success="success"
:before-upload="beforeUpload"
ref="fileUp"
:limit="2"
accept=".jar"
>
<el-tooltip class="item" effect="dark" content="上传自定义Jar包" placement="top-end">
<el-button size="small" icon="el-icon-upload"></el-button>
</el-tooltip>
</el-upload>
</ht-form-item>
</el-form>
<div slot="footer" style="text-align: center">
<el-button @click="saveData">{{$t("eip.common.save")}}</el-button>
<el-button @click="beforeCloseDialog">{{$t("eip.common.cancel")}}</el-button>
</div>
</el-dialog>
<div slot="footer" style="text-align: right">
<el-button @click="outerVisible = false">{{$t("eip.common.cancel")}}</el-button>
<el-button @click="confirm" type="primary">确定</el-button>
</div>
</div>
</el-dialog>
</template>
<script>
import { mapState, mapActions } from "vuex";
export default {
data() {
return {
dialogVisible: false,
data: [],
pageResult: {
page: 1,
pageSize: 50,
total: 0
},
importCheckJar: {},
outerVisible: false,
files: [],
curSelect: ""
};
},
computed: mapState({
header: state => {
return { Authorization: `Bearer ${state.login.currentUser.token}` };
},
actionUrl: function() {
return window.context.portal + "/system/file/v1/upload";
}
}),
mounted() {
this.$validator = this.$root.$validator;
},
methods: {
beforeUpload(file) {
if (this.files && this.files.length > 0) {
if (this.files.length == 1) {
return new Promise((resolve, reject) => {
this.$confirm("已有Jar包, 是否确认覆盖?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
resolve();
})
.catch(() => {
reject();
});
});
} else {
this.$message.waring("最多只能上传一个模板");
return false;
}
} else {
return true;
}
},
handleRemove(file, fileList) {
if (fileList && fileList.length == 1) {
return;
}
let this_ = this;
setTimeout(function() {
this_.importCheckJar.filePath = "";
}, 50);
},
success(response, file, fileList) {
this.files = [];
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].response) {
let value = fileList[i].response;
let arrarFile = {};
arrarFile.id = value.fileId;
arrarFile.name = value.fileName;
arrarFile.size = value.size;
this.files.push(arrarFile);
}
}
this.importCheckJar.filePath = JSON.stringify(this.files);
},
show() {
this.outerVisible = true;
this.curSelect = {};
},
showDialog(id, e) {
if (id) {
if (e && e.preventDefault) {
e.preventDefault(); //非IE浏览器
} else {
window.event.returnValue = false;
} //IE浏览器
this.$http
.get("${form}/form/formImportCheckJar/v1/getJson?id=" + `${id}`)
.then(
resp => {
this.importCheckJar = resp.data;
if (this.importCheckJar.filePath) {
this.files = JSON.parse(this.importCheckJar.filePath);
}
this.dialogVisible = true;
},
error => {}
);
} else {
this.files = [];
this.dialogVisible = true;
}
},
beforeCloseDialog() {
this.importCheckJar = {};
this.dialogVisible = false;
},
loadData(param, cb) {
this.curSelect = "";
this.$http
.post("${form}/form/formImportCheckJar/v1/listJson", param)
.then(
resp => {
let response = resp.data;
this.data = response.rows;
this.pageResult = {
page: response.page,
pageSize: response.pageSize,
total: response.total
};
},
error => {}
)
.finally(() => cb());
},
afterSaveData() {
setTimeout(() => {
this.beforeCloseDialog();
this.$refs.htTable.load();
}, 500);
},
saveData() {
if (!this.importCheckJar.desc) {
this.$message.warning("请填写描述");
return false;
}
if (!this.importCheckJar.classPath) {
this.$message.warning("请填写校验类路径");
return false;
}
if (!this.importCheckJar.filePath) {
this.$message.warning("请上传Jar包");
return false;
}
this.$http
.post("${form}/form/formImportCheckJar/v1/save", this.importCheckJar)
.then(
resp => {
let data = resp.data;
if (data.state) {
this.$message.success("保存成功");
this.$refs.htTable.load();
this.dialogVisible = false;
}
},
error => {}
);
},
afterSaveData() {
setTimeout(() => {
this.beforeCloseDialog();
this.$refs.htTable.load();
}, 500);
},
removeJar(id) {
let this_ = this;
this.$confirm("确定删除Jar包配置吗?")
.then(() => {
this_.$http
.remove("${form}/form/formImportCheckJar/v1/remove?ids=" + id)
.then(
resp => {
if (resp.data && resp.data.state) {
this_.$message.success("删除成功");
this_.$refs.htTable.load();
}
},
error => {}
);
})
.catch(() => {});
},
rowClick(row, column, event) {
this.curSelect = row;
},
confirm() {
if (!this.curSelect) {
this.$message.warning("请选择Jar包");
return;
}
this.$emit("on-confirm", this.curSelect);
this.outerVisible = false;
}
}
};
</script>
<style lang="scss" scoped>
.sp-manager__dialog /deep/ > .el-dialog > .el-dialog__body {
height: calc(100% - 170px);
}
.check-jar /deep/ .el-dialog__body {
padding: 10px 20px;
}
</style>