最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue+element實(shí)現(xiàn)動(dòng)態(tài)加載表單

 更新時(shí)間:2020年12月13日 10:56:19   作者:劉白超  
這篇文章主要為大家詳細(xì)介紹了vue+element實(shí)現(xiàn)動(dòng)態(tài)加載表單,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue+element實(shí)現(xiàn)動(dòng)態(tài)加載表單的具體代碼,供大家參考,具體內(nèi)容如下

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

//html
<el-form :model="quesPaper" status-icon label-width="100px" label-position="top" size="small" v-loading="paperLoading" >  
 <el-form-item
 v-for="n in paperForm.answerList"
 :label="n.questionRepository.question"
 :key="n.key"
 >
 <!-- 單選 -->
 <el-radio-group v-model="n.optionId" v-if="n.questionRepository.type === 1">
 <el-radio v-for="(i, idx) in n.questionOption" :label="i.id" :key="idx" class="mb5">{{ i.questionOption }}</el-radio>
 </el-radio-group>
 <!-- 多選 -->
 <el-checkbox-group v-model="n.optionId" v-if="n.questionRepository.type === 2">
 <el-checkbox v-for="(i, idx) in n.questionOption" :label="i.id" :key="idx">{{ i.questionOption }}</el-checkbox>
 </el-checkbox-group>
 <!-- 填空 -->
 <el-input type="textarea" style="width: 600px" class="fl" v-model="n.answer" v-if="n.questionRepository.type === 3" :rows="4" placeholder="請輸入內(nèi)容" ></el-input>
 </el-form-item>


 <el-row class="mt20" type="flex" justify="start">
 <el-col :span="5">
 <el-button type="primary" size="small" @click.stop="saveStageAnswer">保存問卷</el-button>
 </el-col>
 </el-row>
</el-form>

//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)加載表單

特點(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)證,就刪了

<template>
<!-- 錄入數(shù)據(jù) -->
 <div class="DialyInputDetail" >
 <div class="fw fz16 color6 mb20 mt10">批量錄入<span class="colorRed">{{tabHeader.monthStr}}</span>數(shù)據(jù)</div>
 <el-form status-icon label-width="100px" :model="newForm" ref='newForm' label-position="top" size="small"> 
 <table border="1" class="fw fz14 color6 table">
 <tr>
  <td rowspan='2'>患者請用姓名<br/>或病歷號模糊篩選</td>
  <td :colspan="tabHeader.firstTables.length" class="tc colorRed lh40">以下信息每1個(gè)月登記一次</td>
  <td :colspan="tabHeader.secondTables.length" class="tc colorRed lh40">以下信息每3個(gè)月登記一次</td>
  <td :colspan="tabHeader.thirdTables.length" class="tc colorRed lh40">以下信息每6個(gè)月登記一次</td>
 </tr>
 <tr class="lh40">
  <td v-for="item in tabHeader.firstTables" :key="item.name" class="tc">{{item.name}}</td>
  <td v-for="n in tabHeader.secondTables" :key="n.name" class="tc">{{n.name}}</td>
  <td v-for="z in tabHeader.thirdTables" :key="z.nam" class="tc">{{z.name}}</td>
 </tr>
 
 <tr v-for="(w,index) in newForm.colList" :key="index+'a'" >
  <td> 
  <el-form-item
  :prop="'colList.'+index+'.patientId'"
  >
  <!--- :rules="{required: true, message: '不能為空', trigger: 'blur'}"-->
  <el-select v-model="w.patientId" size="small" style="width: 100px" filterable clearable>
  <el-option
   v-for="(ite, idx) in patientArr"
   :label="ite.patient" 
   :key="idx"
   :value="ite.id">
  </el-option>
  </el-select>
  </el-form-item>
  </td>
  <td class="tc" v-for="(n,j) in w.itemDataList" :key="j">
  <el-form-item
  :prop="'colList.'+index+'.itemDataList.' + j + '.itemValue'"
  >
  <!-- :rules="{required: true, message: '不能為空', trigger: 'blur'}"-->
  <el-select v-model="n.itemValue" size="small" style="width: 100px" v-if="n.type == 2" filterable clearable>
  <el-option
   v-for="(i, idx) in n.opts"
   :label="i" 
   :key="idx"
   :value="i">
  </el-option>
  </el-select>
  <el-input style="width: 100px" size="small" v-model="n.itemValue" v-if="n.type == 1" ></el-input>
  </el-form-item>
  </td>
 </tr>
 </table>  
 <el-row class="mt20" type="flex" justify="start">
 <el-col :span="5">
  <el-button type="primary" size="small" @click="submitNew('newForm')">提交數(shù)據(jù)</el-button>
 </el-col>
 </el-row>
 </el-form>
 </div>
</template>

<script>
import Vue from 'vue'

export default {
 name: 'DialyInputDetail',
 props:['dialysisId','dialysisCenter'],
 data() {
 return {
 tabHeader:{
 firstTables:[],
 secondTables:[],
 thirdTables:[],
 colNub:[]
 },
 dialyDetail:{},
 newForm:{
 id:'',
 colList:[
  // {
  // patientId:123,  //患者id
  // createUserId:123,  //當(dāng)前用戶id
  // createUserName:"管理員" ,
  // itemDataList:[{
  // itemId:'',
  // itemValue:'',
  // type:1
  // }] 
  // }
 ],
 },
 patientArr:[],
 }
 },
 created () { 
 this.getMedRdTables(this.dialysisId)
 this.getPatient(this.dialysisId)
 },
 methods: {
 getMedRdTables(id){//獲取錄入tab
 this.$axios.get(this.$my.api + '/bms/input/getMedRdTables?dialysisId='+id).then(res => { 
 if(res.data&&res.data.code === 200){ 
  this.tabHeader = res.data.data
  this.tabHeader.colNub = [...res.data.data.firstTables,...res.data.data.secondTables,...res.data.data.thirdTables] 
  this.newForm.colList = []
  for(let i=0;i<5;i++){//要push的對象,必須寫在循環(huán)體內(nèi)
  let arr = [] 
  let obj = {
  patientId:'',
  dialysisId:res.data.data.auth.dialysisId,  //透析中心id
  dialysisCenter:res.data.data.auth.dialysisCenter, //透析中心名稱
  //patientId:'',  //患者id
  //patient:'', //患者名稱
  inputAuthId:res.data.data.auth.id,  //透析中心權(quán)限id
  year:res.data.data.auth.inputYear,  //錄入年份
  month:res.data.data.auth.inputMonth, 
  createUserId:JSON.parse(localStorage.getItem('userInfo')).session.id,
  createUserName:JSON.parse(localStorage.getItem('userInfo')).session.name,
  }  
  this.tabHeader.colNub.map(n=>{
  arr.push({itemId:n.id ,opts:n.opts ,itemValue:'',type:n.type})
  })
  obj.itemDataList = arr
  this.newForm.colList.push(obj)
  }
 }else{
  this.$message({
  message: res.data.message,
  type: 'error',
  duration: 1500
  })
  return false
 } 
 }).catch(function (error) {})
 },
 getDialyDetail(id){//獲取透析中心詳情
 this.$axios.get(this.$my.api + '/bms/input/getDialyDetail?id='+id).then(res => { 
 if(res.data&&res.data.code === 200){ 
  this.dialyDetail = res.data.data
 }else{
  this.$message({
  message: res.data.message,
  type: 'error',
  duration: 1500
  })
  return false
 } 
 }).catch(function (error) {})
 },
 getPatient(id){
 this.$axios.get(this.$my.api + '/bms/input/getAllPatList?dialysisId='+id).then(res => { 
 if(res.data&&res.data.code === 200){ 
  this.patientArr = res.data.data
 }else{
  this.$message({
  message: res.data.message,
  type: 'error',
  duration: 1500
  })
  return false
 } 
 }).catch(function (error) {})
 },
 submitNew(formName){ //新增-原本所有都是必填項(xiàng),后改為name和hb值必填
 this.$refs[formName].validate((valid) => {
 if (valid) {
 let ok = false
 this.newForm.colList.map((item)=>{
  if(item.patientId){
  let name = item.itemDataList.find((n)=>n.itemId == 33)
  if(name&&name.itemValue=='') ok = true
  }
 })
 if(this.newForm.colList.every((item)=>item.patientId == '')){
  this.$message({
  message: '至少填寫一個(gè)患者',
  type: 'error',
  duration: 1500
  })
  return false
 }
 if(ok){
  this.$message({
  message: '透析前舒張壓(mmHg)不能為空',
  type: 'error',
  duration: 1500
  })
  return false
 }
 this.$axios.post(this.$my.api + '/bms/input/bathSaveRecord', this.newForm.colList).then(res => { 
  if(res.data&&res.data.code === 200){ 
  this.$message({
   message: res.data.message,
   type: 'success',
   duration: 1500
  })
  this.$refs[formName].resetFields();
  }else{
  this.$message({
   message: res.data.message,
   type: 'error',
   duration: 1500
  })
  } 
 }).catch( error =>{})
 } else {
 console.log('error submit!!');
 return false;
 }
 });
 }
 },
}
</script>

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

部分必選:

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í)顚?,再提?,
  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í)顚?,再提?,
  type: 'error',
  duration: 1500
 })
 return false
 }
 if(no){
 return false
 }
 // 部分必選 end

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue實(shí)現(xiàn)自定義多選與單選的答題功能

    vue實(shí)現(xiàn)自定義多選與單選的答題功能

    這篇文章主要介紹了使用vue實(shí)現(xiàn)自定義多選與單選的答題功能,vue組件中在表單方面提供了一個(gè)v-model指令,非常好用,具體實(shí)現(xiàn)過程大家跟隨腳本之家小編一起看看吧
    2018-07-07
  • vue實(shí)現(xiàn)百度下拉列表交互操作示例

    vue實(shí)現(xiàn)百度下拉列表交互操作示例

    這篇文章主要介紹了vue實(shí)現(xiàn)百度下拉列表交互操作,結(jié)合實(shí)例形式分析了vue.js使用jsonp針對百度接口進(jìn)行交互的相關(guān)操作技巧,需要的朋友可以參考下
    2019-03-03
  • vue3 定義使用全局變量的示例詳解

    vue3 定義使用全局變量的示例詳解

    全局變量(函數(shù)等)可以在任意組件內(nèi)訪問,可以當(dāng)組件間的傳值使用,這篇文章給大家介紹vue3 定義使用全局變量的示例詳解,感興趣的朋友跟隨小編一起看看吧
    2023-10-10
  • Vue3框架使用報(bào)錯(cuò)以及解決方案

    Vue3框架使用報(bào)錯(cuò)以及解決方案

    這篇文章主要介紹了Vue3框架使用報(bào)錯(cuò)以及解決方案,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • 基于Vue3和Plotly.js實(shí)現(xiàn)交互式3D圖

    基于Vue3和Plotly.js實(shí)現(xiàn)交互式3D圖

    這篇文章主要介紹了基于Vue3和Plotly.js實(shí)現(xiàn)交互式3D圖,本代碼旨在為數(shù)據(jù)可視化提供一個(gè)交互式圖表,允許用戶動(dòng)態(tài)控制圖表中線條的顏色和可見性,此功能對于探索大型數(shù)據(jù)集或突出特定數(shù)據(jù)子集非常有用,需要的朋友可以參考下
    2024-07-07
  • Element的el-tree控件后臺(tái)數(shù)據(jù)結(jié)構(gòu)的生成以及方法的抽取

    Element的el-tree控件后臺(tái)數(shù)據(jù)結(jié)構(gòu)的生成以及方法的抽取

    這篇文章主要介紹了Element的el-tree控件后臺(tái)數(shù)據(jù)結(jié)構(gòu)的生成以及方法的抽取,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-03-03
  • vue工程全局設(shè)置ajax的等待動(dòng)效的方法

    vue工程全局設(shè)置ajax的等待動(dòng)效的方法

    這篇文章主要介紹了vue工程全局設(shè)置ajax的等待動(dòng)效的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-02-02
  • 前端架構(gòu)vue架構(gòu)插槽slot使用教程

    前端架構(gòu)vue架構(gòu)插槽slot使用教程

    這篇文章主要為大家介紹了前端vue架構(gòu)插槽slot使用教程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-02-02
  • Vue3中如何使用異步請求示例詳解

    Vue3中如何使用異步請求示例詳解

    Vue3增加了很多讓人眼前一亮的特征,suspense 組件就是其中之一,對處理異步請求數(shù)據(jù)非常實(shí)用,下面這篇文章主要給大家介紹了關(guān)于Vue3中如何使用異步請求的相關(guān)資料,需要的朋友可以參考下
    2022-06-06
  • Vue.js 加入高德地圖的實(shí)現(xiàn)代碼

    Vue.js 加入高德地圖的實(shí)現(xiàn)代碼

    這篇文章主要介紹了Vue.js 加入高德地圖的實(shí)現(xiàn)方法,本文結(jié)合示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-12-12

最新評論

乡宁县| 汕头市| 北辰区| 呈贡县| 利川市| 平果县| 洱源县| 巍山| 白沙| 萨迦县| 萨嘎县| 双峰县| 乌兰察布市| 饶阳县| 共和县| 宜宾市| 青岛市| 准格尔旗| 朝阳区| 札达县| 山东省| 滦南县| 会东县| 鹤峰县| 体育| 马尔康县| 鸡西市| 卓尼县| 富裕县| 类乌齐县| 景泰县| 邵东县| 天峻县| 龙井市| 宾阳县| 馆陶县| 慈溪市| 喜德县| 阜平县| 湘阴县| 三穗县|