计算出表格里多行商品的总价

var trNum = document.getElementById('sample_editable_1').getElementsByTagName('tr').length
function $(id){
return document.getElementById(id);
}
function init(){
for(var i=0;i<trNum-1;i++){
   $("SrmBidGoods["+i+"].quantity").οnkeyup=function(){
    stotal(i);
   }

   $("SrmBidGoods["+i+"].supplierQuote").οnkeyup=function(){
    stotal(i);
   }
}
}

function stotal(c){
var supplierTotalQuote = 0;
for(var i=0;i<trNum-1;i++){
   x = parseFloat($("SrmBidGoods["+i+"].quantity").value);
   y = parseFloat(checkempty($("SrmBidGoods["+i+"].supplierQuote").value))
   $("SrmBidGoods["+i+"].goodsTotleQuote").value = parseFloat((x * y).toFixed(3));
  supplierTotalQuote = supplierTotalQuote + parseFloat($("SrmBidGoods["+i+"].goodsTotleQuote").value);
}
$("supplierTotalQuote").value = supplierTotalQuote;
}
可以通过以下步骤实现: 1. 在表格需要修改的多行数据,可以使用`selection-change`事件监听选状态的变化,在事件处理函数获取当前选多行数据的ID等信息。 2. 弹修改框,可以使用`el-dialog`组件,设置`visible`属性为`true`来显示弹框。 3. 在弹设置需要修改的列的输入框,可以使用`el-input`组件。 4. 在弹设置提交按钮,点击提交按钮时,可以使用`el-message`组件显示提交结果,并将修改后的数据提交给后台进行保存。 以下是一个示例代码: ```html <template> <div> <el-button type="primary" @click="showEditDialog">修改</el-button> <el-table :data="tableData" :row-key="row => row.id" @selection-change="handleSelectionChange"> <el-table-column prop="id" label="ID"></el-table-column> <el-table-column prop="name" label="姓名"></el-table-column> <el-table-column prop="age" label="年龄"></el-table-column> </el-table> <el-dialog :visible.sync="editDialogVisible" title="批量修改" @close="handleEditDialogClose"> <el-form :model="editForm" ref="editForm"> <el-form-item label="年龄"> <el-input v-model="editForm.age"></el-input> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button @click="editDialogVisible = false">取 消</el-button> <el-button type="primary" @click="handleEditSubmit">确 定</el-button> </div> </el-dialog> </div> </template> <script> export default { data() { return { tableData: [ { id: 1, name: "张三", age: 20 }, { id: 2, name: "李四", age: 25 }, { id: 3, name: "王五", age: 30 } ], editDialogVisible: false, editForm: { age: "" }, selectedRows: [] }; }, methods: { showEditDialog() { if (this.selectedRows.length === 0) { this.$message.warning("请选择需要修改的数据"); return; } this.editDialogVisible = true; }, handleSelectionChange(selection) { this.selectedRows = selection; }, handleEditDialogClose() { this.$refs.editForm.resetFields(); }, handleEditSubmit() { const ids = this.selectedRows.map(row => row.id); const data = { age: this.editForm.age }; // 发送修改请求 this.$http.post("/api/batch-update", { ids, data }).then(response => { this.$message.success("修改成功"); this.editDialogVisible = false; // 更新表格数据 this.tableData = this.tableData.map(row => { if (ids.indexOf(row.id) !== -1) { return { ...row, ...data }; } else { return row; } }); }).catch(error => { this.$message.error("修改失败"); }); } } }; </script> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值