|
@@ -91,12 +91,18 @@ export default {
|
|
|
isEdit() {
|
|
|
return this.user.id;
|
|
|
},
|
|
|
+ rules() {
|
|
|
+ return {
|
|
|
+ loginName: [{ required: true, message: "登录名必填" }],
|
|
|
+ name: [{ required: true, message: "姓名必填" }],
|
|
|
+ password: [{ required: !this.isEdit, message: "密码必填" }],
|
|
|
+ };
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
visible: false,
|
|
|
form: {},
|
|
|
- rules: {},
|
|
|
loading: false,
|
|
|
};
|
|
|
},
|
|
@@ -125,6 +131,14 @@ export default {
|
|
|
this.visible = false;
|
|
|
},
|
|
|
async submitForm() {
|
|
|
+ try {
|
|
|
+ const valid = await this.$refs.form.validate();
|
|
|
+ if (!valid) return;
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
let data = this.form;
|
|
|
if (this.isEdit) {
|
|
|
data = { ...data, id: this.user.id };
|