vue中动态给不同表单赋值

        这里的业务是通过关联的 id 发送不同的请求获取表单的数据,然后回显到页面中,整个的页面是由多个表单拼接起来的

        点击下一步的时候,获取下一个表单的内容。 

 // 查询
            getForm(index) {
                switch (index) {
                    case 0:
                        this.getFromInfo("inputForm",this.inputForm)
                        break;
                    case 1:
                        this.getFromInfo("projectApproval", this.projectApproval)
                        break;
                    case 2:
                        this.getFromInfo("preliminaryDesign", this.preliminaryDesign)
                        break;
                    case 3:
                        this.getFromInfo("landApproval", this.landApproval)
                        break;
                    case 4:
                        this.getFromInfo("landPlanning", this.landPlanning)
                        break;
                    case 5:
                        this.getFromInfo("invitationBids", this.invitationBids)
                        break;
                    case 6:
                        this.getFromInfo("fireDesignReview", this.fireDesignReview)
                        break;
                    case 7:
                        this.getFromInfo("expertArgumentation", this.expertArgumentation)
                        break;
                    case 8:
                        this.getFromInfo("constructionPermit", this.constructionPermit)
                        break;
                    case 9:
                        this.getFromInfo("qualitySupervisionRegistration", this.qualitySupervisionRegistration)
                        break;
                    case 10:
                        this.getFromInfo("safeSupervisionRegistration", this.safeSupervisionRegistration)
                        break;
                    case 11:
                        this.getFromInfo("buildRecordSubmission", this.buildRecordSubmission)
                        break;
                }
            },
            getFromInfo(formType, formData) {
                this.get('${ctx}/buildproject/' + formType + '/info', {id: this.inputForm.id}).then((res) => {
                    formData = res.data;
                    this[formType] = formData;
                })
            },

        getFromInfo接受两个参数(表单的名称,表单数据结构),然后发送相应的请求获取到数据,返回给到表单中,这里最重要的一步就是  this[formType] = formData; this[] 可以指向相应的对象。比如 fromType为 inputForm 时,this[inputForm] 等同于 this.inputForm

相关推荐

  1. vue生成动态

    2024-01-10 12:30:01       51 阅读
  2. vue+elementui遍历生成添加效验

    2024-01-10 12:30:01       51 阅读
  3. vue3 如何添加效验+正则表达式

    2024-01-10 12:30:01       31 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-10 12:30:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-10 12:30:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-10 12:30:01       87 阅读
  4. Python语言-面向对象

    2024-01-10 12:30:01       96 阅读

热门阅读

  1. Qt之字节数组类QByteArray

    2024-01-10 12:30:01       65 阅读
  2. 神经网络(Neural Networks)

    2024-01-10 12:30:01       64 阅读
  3. 控制台程序退出时触发事件

    2024-01-10 12:30:01       56 阅读
  4. Python使用函数统计指定数字的个数

    2024-01-10 12:30:01       51 阅读
  5. vue首次加载白屏问题

    2024-01-10 12:30:01       62 阅读
  6. Acwing 844 走迷宫

    2024-01-10 12:30:01       61 阅读
  7. Golang 快乐数 leetcode202 map哈希表 快慢指针法

    2024-01-10 12:30:01       55 阅读
  8. MongoDB之安全管理

    2024-01-10 12:30:01       57 阅读
  9. docker-宿主机与容器的命令执行方法

    2024-01-10 12:30:01       52 阅读