表单提交组件之间的校验
This commit is contained in:
@ -8,3 +8,19 @@ export function expertList(data) {
|
||||
data,
|
||||
})
|
||||
}
|
||||
// 专家详细信息
|
||||
export function expertDetail(data) {
|
||||
return request({
|
||||
url: '/admin/v1/manage/expert/detail',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
// 专家信息添加
|
||||
export function expertAdd(data) {
|
||||
return request({
|
||||
url: '/admin/v1/manage/expert/add',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
@ -126,7 +126,11 @@ export default {
|
||||
this.districtSelectList = await this.getProvinceByParent(id);
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs["form"].validate((valid) => valid);
|
||||
let flag = false;
|
||||
this.$refs["form"].validate((valid) => {
|
||||
flag = valid;
|
||||
});
|
||||
return flag;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
|
@ -254,13 +254,14 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
const flag = false;
|
||||
let flag = false;
|
||||
this.$refs["form"].validate((valid) => {
|
||||
const cityForm = this.$refs.cityForm.submitForm();
|
||||
const fieldForm = this.$refs.fieldForm.submitForm();
|
||||
const keywordsForm = this.$refs.keywordsForm.submitForm();
|
||||
const researchsForm = this.$refs.researchsForm.submitForm();
|
||||
if (cityForm && fieldForm && keywordsForm && researchsForm) {
|
||||
console.log(true);
|
||||
flag = !flag;
|
||||
}
|
||||
});
|
||||
|
@ -152,7 +152,11 @@ export default {
|
||||
this.value.industrys.splice(index, 1);
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs["form"].validate((valid) => valid);
|
||||
let flag = false;
|
||||
this.$refs["form"].validate((valid) => {
|
||||
flag = valid;
|
||||
});
|
||||
return flag;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
|
@ -6,7 +6,12 @@
|
||||
:label="title + ':'"
|
||||
:prop="fieldKey"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入并添加', trigger: 'blur' },
|
||||
{
|
||||
required: true,
|
||||
type: 'array',
|
||||
message: '请输入并添加',
|
||||
trigger: 'change',
|
||||
},
|
||||
]"
|
||||
>
|
||||
<el-row type="flex" justify="space-between">
|
||||
@ -66,7 +71,11 @@ export default {
|
||||
this.value[val].splice(index, 1);
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs["form"].validate((valid) => valid);
|
||||
let flag = false;
|
||||
this.$refs["form"].validate((valid) => {
|
||||
flag = valid;
|
||||
});
|
||||
return flag;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -9,6 +9,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import ExpertForm from "@/views/components/ExpertForm";
|
||||
import { expertDetail, expertAdd } from "@/api/examine/expert";
|
||||
export default {
|
||||
components: {
|
||||
ExpertForm,
|
||||
@ -17,8 +18,8 @@ export default {
|
||||
return {
|
||||
form: {
|
||||
image: undefined,
|
||||
name: "1",
|
||||
mobile: "13911111111",
|
||||
name: undefined,
|
||||
mobile: undefined,
|
||||
research_id: undefined, // 所属单位
|
||||
laboratory_id: undefined, // 所属实验室
|
||||
tenant_id: undefined,
|
||||
@ -44,6 +45,9 @@ export default {
|
||||
submitForm() {
|
||||
if (this.$refs.expertForm.submitForm()) {
|
||||
console.log(this.form);
|
||||
// expertAdd(this.form).then((res) => {
|
||||
// console.log(res);
|
||||
// });
|
||||
} else {
|
||||
console.log("校验未通过");
|
||||
}
|
||||
@ -73,9 +77,10 @@ export default {
|
||||
this.$router.go(-1);
|
||||
return;
|
||||
}
|
||||
console.log(id);
|
||||
// this.queryParams.reportedId = id;
|
||||
// this.getReportDetail();
|
||||
expertDetail({ id }).then((res) => {
|
||||
console.log(res);
|
||||
this.form = res.data;
|
||||
});
|
||||
},
|
||||
};
|
||||
</script>
|
@ -100,8 +100,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { delUser } from "@/api/system/user";
|
||||
|
||||
import { expertList } from "@/api/examine/expert";
|
||||
|
||||
export default {
|
||||
|
Reference in New Issue
Block a user