vue 循环input获取值

html代码,循环input,v-model绑定

<view class="content">
            <u--form >
                <view class="list" v-for="(item,index) in analyzeData" :key="item.id">
                    <u-form-item borderBottom>
                        <view slot="label">
                            <view style="min-width: 150rpx;">{{item.analysis_items}}</view>
                            <view>{{item.optionList}} </view>
                        </view>
                        <u--input placeholder="请输入内容" border="none" v-model="item.analyze_item_content"
                            @change="change(item.analyze_item_content,index)"></u--input>
                    </u-form-item>
                </view>
            </u--form>
        </view>

data数据


data() {
            return {
                analyzeData: [],
            }
        },

调取后端接口,获取数据


 // 获取分析内容 --- analyzeData
            getAnalysisContent() {
                let that = this
                const params = {
                    namespace: 'deco_soms', //命名空间
                    TemplateId: 'special_management_information', //对象模板ID
                    serviceId: 'jobSiteAnalysis', //对象服务ID
                    namespaceChannel: 'deco_soms',
                    params: {
                        operationID: this.operation_type, //作业类型id
                        ID: this.specialID //自建id
                    },
                }
                getNamespaceService(params).then(res => {
                    console.log(res)
                    console.log("888", Object.values(res.data.data.result.message))
                    if (res.data.code == 200) {
                        this.analyzeData = Object.values(res.data.data.result.message)
                    }
                    console.log("分析内容", this.analyzeData)
                })
            },

change方法获取每一个input的值


methods: {
           
           //获取input的值
            change(item, index) {
                console.log('change', item, index);
                this.analyzeData[index].analyze_item_content = item

                console.log(this.analyzeData)
            },


            // 提交
            submit() {
                let that = this
                for (var i = 0; i < this.analyzeData.length; i++) {
                    console.log(that.analyzeData[i].system_id)
                    if (that.analyzeData[i].analyze_item_content != null) {
                        var params = {
                            namespace: 'deco_soms', //命名空间
                            TemplateId: 'special_management_jobsite_analysis', 
                            serviceId: 'UpdateDataTableEntry', //对象服务ID
                            namespaceChannel: 'system',
                            params: {

                                where: {
                                    "system.id": that.analyzeData[i].system_id
                                },
                                update: {
                                    "analyze_item_content": that.analyzeData[i].analyze_item_content
                                },
                            },
                        }
                        getNamespaceService(params).then(res => {
                            console.log("提交", res)
                            if (res.data.code == 200) {
                                
                            }
                        })
                    }
                }

            },

        }
    

结果:

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值