vue 多表单提交

<template>	
	<div>
	<div>
	 <el-form ref="userForm" :model="userInfo">
		 <el-row>
		   <el-col :span="12">
			<el-form-item label="人员姓名:">
			    <el-input v-model="userInfo.userName">
				</el-input>
		    </el-form-item>
		   </el-col>
		   <el-col :span="12">
			<el-form-item label="性别:">
			    <el-input v-model="userInfo.sex">
				</el-input>
		    </el-form-item>
		   </el-col>
		 </el-row>
		 <el-row>
		   <el-col :span="12">
			<el-form-item label="年龄:">
			    <el-input v-model="userInfo.age">
				</el-input>
		    </el-form-item>
		   </el-col>
		   <el-col :span="12">
			<el-form-item label="联系电话:">
			    <el-input v-model="userInfo.tel">
				</el-input>
		    </el-form-item>
		   </el-col>
		 </el-row>
		 <el-row>
		   <el-col :span="12">
			<el-form-item label="地址:">
			    <el-input v-model="userInfo.address">
				</el-input>
		    </el-form-item>
		   </el-col>
		   <el-col :span="12">
			<el-form-item label="所属部门:">
			    <el-input v-model="userInfo.department">
				</el-input>
		    </el-form-item>
		   </el-col>
		 </el-row>	  
	 </el-form>
	</div>
	<div>
	 <el-form ref="deptForm" :model="deptInfo">
		 <el-row>
		   <el-col :span="12">
			<el-form-item label="部门编码:">
			    <el-input v-model="deptInfo.deptCode">
				</el-input>
		    </el-form-item>
		   </el-col>
		   <el-col :span="12">
			<el-form-item label="部门名称:">
			    <el-input v-model="deptInfo.deptName">
				</el-input>
		    </el-form-item>
		   </el-col>
		 </el-row>		  
	 </el-form>
	</div>
	<div class="edit_btn el-fomr position_btn">
		<el-button type="primary" class="btn_close" @click="cancel">取消</el-button>
		<el-button type="primary" :loading="btnLoading" @click="save">保存</el-button>
	</div>
	</div>
</template>
<script>
export default {
  data() {
    return {
      reload: true,
      tabIndex: "0",
      contentStyleObj: {
        height: "670px",
      },
      userInfo: {
        userName:"李云吉",
        sex:"男",
        age:20,
		tel:"13775175890",
		address:"",
		department:""
      },
	  deptInfo: {
        deptName:"研发部",
        deptCode:"001"
      },
	  btnLoading: false
    };
  },
  mounted() {
  },
  methods: {
    cancel() {
      window.parent._closeDialog({
        success: "关闭",
      });
    },
    save() {
      this.btnLoading = true;
      let userForm=new Promise((resolve,reject)=>{
        this.$refs["userForm"].validate((valid)=>{
          if(valid){
            resolve();
          }
          else{
		    this.btnLoading = false;
            return false;
          }
 
        });
      });
      let deptForm=new Promise((resolve,reject)=>{
        this.$refs["deptForm"].validate((valid)=>{
          if(valid){
            resolve();
          }
          else{
		    this.btnLoading = false;
            return false;
          }
        });
      });
      Promise.all([userForm,deptForm]).then(()=>{
       //TODO:需要处理的业务
      });
    },
  }
};
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值