uniapp新增一条数据增加一个折叠栏

html 复制代码
//折叠栏
<uni-collapse class='collapse' ref='collapse'>
			<uni-collapse-item v-for="(item, index) in dataForm.beefCattleNums" :key="index" :title="item.fatCalfNum" class='collapse-item' title-border='show' :border='false' @click=toggleItem(dataForm,index)>
        <view class="item">
          <view class="item-content">
            <view class="item">
              <text class="label">年份</text>
              <text class="text ellipsis num">{{item.fatCalfNum}}</text>
            </view>
          </view>
          <view class="item-content">
            <view class="item">
              <view class="label">货币资金(万元)</view>
              <text class="text ellipsis num">{{item.fatCalfNum1}}</text>
            </view>
          </view>
			</uni-collapse-item>
		</uni-collapse>

//新增按钮
<view class="table-footer-box">
      <image class="btn" src="/static/images/production/icon-add-bl.png" mode="" @click="addInventory"></image>
    </view>

//弹窗
<uni-popup ref="inventoryPopup" class="popup-cus">
      <add-bb-subject @addInventoryHandle="addInventoryHandle" @closeInventoryHandle="closeInventoryHandle"></add-bb-subject>
    </uni-popup>
javascript 复制代码
addInventory(){
            this.$refs.inventoryPopup.open()
      },
      addInventoryHandle(data){
        this.$refs.inventoryPopup.close()
        this.dataForm.beefCattleNums.push(Object.assign({}, data))  
      },
      closeInventoryHandle(){
        this.$refs.inventoryPopup.close()
      },

子组件:

html 复制代码
<view class="form-item">
          <view class="form-item-label">年份</view>
          <view class="form-item-content">
            <input v-model="dataForm.fatCalfNum" type="number" class="uni-input uni-input-box" placeholder-class="input-placeholder" confirm-type="done" placeholder="请输入年份" />
          </view>
        </view>
        <view class="form-item">
          <view class="form-item-label">货币资金(万元)</view>
          <view class="form-item-content">
            <input v-model="dataForm.fatCalfNum1" type="number" class="uni-input uni-input-box" placeholder-class="input-placeholder" confirm-type="done" placeholder="请输入货币资金" />
          </view>
        </view>
<view class="footer-box">
        <view class="btn-l-box" @click="cancelHandle">取消</view>
        <view class="btn-r-box" @click="submitHandle">确定</view>
      </view>

async submitHandle() {
      this.$emit('addInventoryHandle',this.dataForm)
    },
    cancelHandle(){
      this.$emit('closeInventoryHandle')
    }
相关推荐
Maverick0619 小时前
Oracle Redo 日志操作手册
数据库·oracle
攒了一袋星辰20 小时前
高并发强一致性顺序号生成系统 -- SequenceGenerator
java·数据库·mysql
jzlhll12320 小时前
kotlin Flow first() last()总结
开发语言·前端·kotlin
W.D.小糊涂20 小时前
gpu服务器安装windows+ubuntu24.04双系统
c语言·开发语言·数据库
云贝教育-郑老师20 小时前
【OceanBase 的多租户架构是怎样的?有什么优势?】
数据库·oceanbase
顶点多余21 小时前
使用C/C++语言链接Mysql详解
数据库·c++·mysql
xiaokangzhe21 小时前
MySQL 数据库操作
数据库·oracle
蓝冰凌21 小时前
Vue 3 中 defineExpose 的行为【defineExpose暴露ref变量】详解:自动解包、响应性与实际使用
前端·javascript·vue.js
奔跑的呱呱牛21 小时前
generate-route-vue基于文件系统的 Vue Router 动态路由生成工具
前端·javascript·vue.js