亚洲AVI,黑人巨茎大战欧美白妇,初高中生洗澡自慰高清网站,欧美日韩无砖专区一中文字

重慶分公司,新征程啟航

為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)

如何在vue中利用element動(dòng)態(tài)加載表單-創(chuàng)新互聯(lián)

本篇文章給大家分享的是有關(guān)如何在vue中利用element動(dòng)態(tài)加載表單,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

神木網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),神木網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為神木上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個(gè)售后服務(wù)好的神木做網(wǎng)站的公司定做!

一、問卷動(dòng)態(tài)加載表單


//html
  
 
 
 
 {{ i.questionOption }}
 
 
 
 {{ i.questionOption }}
 
 
 
 


 
 
 保存問卷
 
 


//data數(shù)據(jù)
paperForm: { // 問卷表單
 answerList:[{
 questionRepository:'',
 questionOption:[],

 questionId: '',
 optionId:'',
 answer: ''
 }]
 },
//接口
getPaperByDrugStatus(drugStatus, id){ // 根據(jù)用藥狀態(tài)獲取問卷
 this.paperLoading = true
 this.$axios.get(this.$api + 'xxx/xxx?paperId='+this.selectStage.paperId + '&drugStatus=' + drugStatus).then(res => {
 if(res.data.code === 200){
 let answerArr = []
 let questionArr = []
 res.data.data.questionToList.map((item)=>{
 item.optionList.map((n)=>{
  questionArr.push({
  id:n.id,
  questionOption:n.questionOption
  })
 })
 answerArr.push({
  questionOption:questionArr,
  questionRepository:item.questionRepository,

  questionId:item.questionRepository.id,
  optionId:item.questionRepository.type === 2?[]:'',
  answer: ''
 })
 })
 console.log(answerArr)
 this.paperForm = { // 問卷表單
 answerList:answerArr
 }
 setTimeout(() => {
 this.paperLoading = false
 }, 300)
 }
 })
},

二、批量數(shù)據(jù)動(dòng)態(tài)加載表單

如何在vue中利用element動(dòng)態(tài)加載表單

特點(diǎn):

1.每一行的輸入框,根據(jù)后臺(tái)返回值,動(dòng)態(tài)生成,數(shù)量可增可減。
2.行數(shù)根據(jù)自己設(shè)置的值 5 ,自動(dòng)循環(huán)生成。
3.驗(yàn)證需要:prop和:rules,如果不驗(yàn)證,就刪了






.table{
 border-color: #aaa;
 width: 1000px;
 overflow: auto;
}
.table .el-form-item--small.el-form-item{
 margin: 8px;
}

部分必選:

data(){
 return {
 formList:[{
 patient:'',
 caseNumber:'',
 year:'',
 sex:'',
 dialysisAge:'',
 primaryDisease:'',
 diagnosis:'',
 creatinine:'',
 gfr:'',
 weekTreatTimes:'',
 weekDialysisHours:''
 },{
 patient:'',
 caseNumber:'',
 year:'',
 sex:'',
 dialysisAge:'',
 primaryDisease:'',
 diagnosis:'',
 creatinine:'',
 gfr:'',
 weekTreatTimes:'',
 weekDialysisHours:''
 },{
 patient:'',
 caseNumber:'',
 year:'',
 sex:'',
 dialysisAge:'',
 primaryDisease:'',
 diagnosis:'',
 creatinine:'',
 gfr:'',
 weekTreatTimes:'',
 weekDialysisHours:''
 }]
 },
 methods:{
 submitData(){
 let param={
 dialysisId:this.$route.query.id,
 dialysisCenter:this.$route.query.name,
 createUserName:JSON.parse(localStorage.getItem('userInfo')).session.name,
 createUserId:JSON.parse(localStorage.getItem('userInfo')).session.id,
 patientList:nweArr
 }
 // 部分必選 start
 let ok = false
 // 需要必選的值
 let rules = [{name:'patient',msg:'姓名'},{name:'caseNumber',msg:'身份證'},{name:'year',msg:'年齡'},{name:'sex',msg:'性別'}]
  this.formList.map((item)=>{
  //每一行,是否有值
  let hangNoVal = Object.keys(item).every(n=>item[n] == '')
  if(!hangNoVal){ //任意一個(gè)有值
  for(let i of rules){ 
  if(item[i.name] == ''){//必填項(xiàng)是否有值
   this.$message({
   message: i.msg+'不能為空!',
   type: 'error',
   duration: 1500
   })
   break
  }
  }
  }else{
  ok = true
  }
  })
  if(ok){
  this.$message({
  message: '請?zhí)顚?,再提?#39;,
  type: 'error',
  duration: 1500
  })
  return false
  }
 // 部分必選 end
 this.$axios.post(this.$my.api + '/bms/input/bathSavePat',param).then(res => { 
 if(res.data&&res.data.code === 200){ 
 //ok
 } 
 }).catch(function (error) {})
 },
 }
}

//情況二:有輸入,才必填
// 部分必選 start
let ok = []
let no = ''
 // 需要必選的值
 let rules = [{name:'patient',msg:'姓名'},{name:'caseNumber',msg:'身份證'},{name:'year',msg:'年齡'},{name:'sex',msg:'性別'}]
 this.formList.map((item)=>{
 //每一行,是否有值
 let hangNoVal = Object.keys(item).every(n=>item[n] == '')
 if(!hangNoVal){ //任意一個(gè)有值
  ok.push(false)
  for(let i of rules){ 
  if(item[i.name] == ''){//必填項(xiàng)是否有值
  no = true
  this.$message({
   message: i.msg+'不能為空!',
   type: 'error',
   duration: 1500
  })
  break
  }
  }
 }else{
  ok.push(true)
 }
 })
 if(ok.every(n=>n == true)){
 this.$message({
  message: '請?zhí)顚?,再提?#39;,
  type: 'error',
  duration: 1500
 })
 return false
 }
 if(no){
 return false
 }
 // 部分必選 end

以上就是如何在vue中利用element動(dòng)態(tài)加載表單,小編相信有部分知識點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。


分享名稱:如何在vue中利用element動(dòng)態(tài)加載表單-創(chuàng)新互聯(lián)
URL分享:http://news.spvevtbd.cn/article/dscpdo.html

其他資訊

在線咨詢
服務(wù)熱線
服務(wù)熱線:028-86922220
TOP