提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
:title="!dataForm.id ? '新增' : '修改'" |
|
4 |
:close-on-click-modal="false" |
|
5 |
:visible.sync="visible" |
|
6 |
append-to-body |
|
7 |
> |
|
8 |
<el-form |
|
9 |
:model="dataForm" |
|
10 |
:rules="dataRule" |
|
11 |
ref="dataForm" |
|
12 |
@keyup.enter.native="dataFormSubmit()" |
|
13 |
label-width="120px" |
|
14 |
> |
|
15 |
<el-row :gutter="20"> |
|
16 |
<el-col :span="24"> |
|
17 |
<el-form-item label="URL" prop="loginUrl"> |
|
18 |
<el-input v-model="dataForm.loginUrl" placeholder="URL"></el-input> |
|
19 |
</el-form-item> |
|
20 |
</el-col> |
|
21 |
</el-row> |
|
22 |
<el-row :gutter="20"> |
|
23 |
<el-col :span="12"> |
|
24 |
<el-form-item label="ClientId" prop="clientId"> |
|
25 |
<el-input v-model="dataForm.clientId" placeholder="ClientId"></el-input> |
|
26 |
</el-form-item> |
|
27 |
</el-col> |
|
28 |
<el-col :span="12"> |
|
29 |
<el-form-item label="ClientSecret" prop="clientSecret"> |
|
30 |
<el-input v-model="dataForm.clientSecret" placeholder="ClientSecret"></el-input> |
|
31 |
</el-form-item> |
|
32 |
</el-col> |
|
33 |
</el-row> |
|
34 |
<el-row :gutter="20"> |
|
35 |
<el-col :span="12"> |
|
36 |
<el-form-item label="用户名" prop="username"> |
|
37 |
<el-input v-model="dataForm.username" placeholder="用户名"></el-input> |
|
38 |
</el-form-item> |
|
39 |
</el-col> |
|
40 |
<el-col :span="12"> |
|
41 |
<el-form-item label="密码" prop="password"> |
|
42 |
<el-input v-model="dataForm.password" placeholder="密码"></el-input> |
|
43 |
</el-form-item> |
|
44 |
</el-col> |
|
45 |
</el-row> |
|
46 |
<el-row :gutter="20"> |
|
47 |
<el-col :span="24"> |
|
48 |
<el-form-item label="token" prop="token"> |
|
49 |
<el-input |
|
50 |
v-model="dataForm.token" |
|
51 |
placeholder="token" |
|
52 |
type="textarea" |
|
53 |
:autosize="{ minRows: 2, maxRows: 2}" |
|
54 |
></el-input> |
|
55 |
</el-form-item> |
|
56 |
</el-col> |
|
57 |
</el-row> |
|
58 |
</el-form> |
|
59 |
<span slot="footer" class="dialog-footer"> |
|
60 |
<el-button @click="visible = false">取消</el-button> |
|
61 |
<el-button :loading="loading" type="primary" @click="dataFormSubmit()">确定</el-button> |
|
62 |
</span> |
|
63 |
</el-dialog> |
|
64 |
</template> |
|
65 |
|
|
66 |
<script> |
|
67 |
import DictSelectTag from "@/components/dict/dict-select-tag"; |
|
68 |
|
|
69 |
export default { |
|
70 |
components: { |
|
71 |
DictSelectTag, |
|
72 |
}, |
|
73 |
data() { |
|
74 |
return { |
|
75 |
loading: false, |
|
76 |
visible: false, |
|
77 |
dataForm: { |
|
78 |
id: '', |
|
79 |
loginUrl: '', |
|
80 |
clientId: '', |
|
81 |
clientSecret: '', |
|
82 |
username: '', |
|
83 |
password: '', |
|
84 |
token: '', |
|
85 |
}, |
|
86 |
dataRule: { |
|
87 |
loginUrl: [ |
|
88 |
{required: true, message: "不能为空", trigger: "blur"}, |
|
89 |
] |
|
90 |
}, |
|
91 |
}; |
|
92 |
}, |
|
93 |
methods: { |
|
94 |
init(id) { |
|
95 |
this.dataForm.id = id || 0; |
|
96 |
this.visible = true; |
|
97 |
this.$nextTick(() => { |
|
98 |
this.$refs["dataForm"].resetFields(); |
|
99 |
if (this.dataForm.id) { |
|
100 |
this.getInfo() |
|
101 |
} |
|
102 |
}); |
|
103 |
}, |
|
104 |
// 获取信息 |
|
105 |
getInfo() { |
|
106 |
this.$http.get(`/data/http/token/info/${this.dataForm.id}`).then(({data: res}) => { |
|
107 |
if (res.code !== 0) { |
|
108 |
return this.$message.error(res.msg) |
|
109 |
} |
|
110 |
this.dataForm = { |
|
111 |
...this.dataForm, |
|
112 |
...res.data |
|
113 |
} |
|
114 |
}).catch(() => { |
|
115 |
}) |
|
116 |
}, |
|
117 |
|
|
118 |
// 表单提交 |
|
119 |
dataFormSubmit () { |
|
120 |
this.$refs['dataForm'].validate((valid) => { |
|
121 |
if (!valid) { |
|
122 |
return false |
|
123 |
} |
|
124 |
this.loading = true |
|
125 |
this.$http['post'](`/data/http/token/${!this.dataForm.id ? 'add' : 'update'}`, this.dataForm).then(({data: res}) => { |
|
126 |
this.loading = false |
|
127 |
if (res.code !== 0) { |
|
128 |
return this.$message.error(res.msg) |
|
129 |
} |
|
130 |
this.$message({ |
|
131 |
message: this.$t('prompt.success'), |
|
132 |
type: 'success', |
|
133 |
duration: 500, |
|
134 |
onClose: () => { |
|
135 |
this.visible = false |
|
136 |
this.$emit('refreshDataList') |
|
137 |
} |
|
138 |
}) |
|
139 |
}).catch(() => { |
|
140 |
}) |
|
141 |
}) |
|
142 |
} |
|
143 |
}, |
|
144 |
}; |
|
145 |
</script> |
|
146 |
<style> |
|
147 |
.el-select { |
|
148 |
width: 100%; |
|
149 |
} |
|
150 |
|
|
151 |
.el-input-group__append { |
|
152 |
padding: 0 5px 0 5px; |
|
153 |
} |
|
154 |
|
|
155 |
.el-input-group__prepend { |
|
156 |
padding: 0 5px 0 5px; |
|
157 |
} |
|
158 |
</style> |