vue动态生成行

vue代码

<el-table :data="form.lineInfos" :border=true style="width: 99.99%;">

<el-table-column type="index" label="序号" width="50"></el-table-column>

<el-table-column prop="unitPrice" label="单价" width="150">

<template slot-scope="scope">

<el-input-number v-model="scope.row.unitPrice" controls-position="right"

:min="1" :precision="2" :max="999999" size="small"

@blur="unitPriceInput($event)"></el-input-number>

</template>

</el-table-column>

<el-table-column prop="deliverCharge" label="送货费" width="150">

<template slot-scope="scope">

<el-input-number v-model="scope.row.deliverCharge" controls-position="right"

:min="1" :precision="2" :max="999999" size="small"></el-input-number>

</template>

</el-table-column>

<el-table-column prop="landingCharge" label="卸货费" width="150">

<template slot-scope="scope">

<el-input-number v-model="scope.row.landingCharge" controls-position="right"

:min="1" :precision="2" :max="999999" size="small"></el-input-number>

</template>

</el-table-column>

<el-table-column prop="totalPrice" label="总价" width="150">

<template slot-scope="scope">

<el-input v-model="scope.row.totalPrice" id="totalPrice" size="small" placeholder="请输入" />

</template>

</el-table-column>

<el-table-column prop="startRoute" label="起始线路" width="350">

<template slot-scope="scope">

<el-input v-model="scope.row.startRoute" placeholder="请输入终点线路" />

</template>

</el-table-column>

<el-table-column prop="endRoute" label="终点线路" width="350">

<template slot-scope="scope">

<el-input v-model="scope.row.endRoute" placeholder="请输入终点线路" />

</template>

</el-table-column>

<el-table-column label="操作" width="100">

<template slot-scope="scope">

<el-button size="mini" type="danger" plain @click="removeLineInfos(scope.$index, scope.row)">删除</el-button>

</template>

</el-table-column>

</el-table>

js代码

export default {

name: "LineEdit",

data() {

return {

form: {

lineInfos: [{

value: ''

}],

}

}

}

// 动态删除行

removeLineInfos(index, row){

var that = this;

this.$confirm('确认删除吗?', '提示', {

confirmButtonText: '确定',

cancelButtonText: '取消',

type: 'warning'

}).then(() => {

//点击确定的操作(调用接口)

var lineInfos = that.form.lineInfos;

for (var i = 0; i < lineInfos.length; i++) {

if (row.id == lineInfos[i].id) {

that.form.lineInfos.splice(i, 1);

}

}

}).catch(() => {

//点取消的提示

return;

});

},

// 动态增加行

addLineInfos(){

var member = this.form.lineInfos;

console.log(member);

var length = member.length;

this.form.lineInfos.push(

{

id: parseInt(length),

name: '',

relationship: '',

mobile: '',

birthday: '',

gongzuodanwei: '',

});

},

}

相关推荐
chilavert3185 分钟前
技术演进中的开发沉思-259 Ajax:浏览器历史管理
javascript·ajax·okhttp·状态模式
招风的黑耳7 分钟前
基于 Axure 与 Element UI 风格的拖动行排序表格设计
elementui·axure·表格·拖动
南知意-8 分钟前
从零搭建 Live2D 看板娘教程(自建API避墙版)
服务器·前端·vue.js·开源·博客·美化·看板娘
来杯三花豆奶15 分钟前
Vue 2 中 Store (Vuex) 从入门到精通
前端·javascript·vue.js
四瓣纸鹤15 分钟前
从vue2和vue3的区别聊起
vue.js·状态模式
Web打印27 分钟前
HttpPrinter是一款基于HTTP协议的跨平台Web打印解决方案,
javascript·php
少油少盐不要辣33 分钟前
前端如何处理AI模型返回的流数据
前端·javascript·人工智能
跟着珅聪学java36 分钟前
以下是使用JavaScript动态拼接数组内容到HTML的多种方法及示例:
开发语言·前端·javascript
巴拉巴拉~~44 分钟前
KMP 算法通用图表组件:KmpChartWidget 多维度可视化 + PMT 表渲染 + 性能对比
前端·javascript·microsoft
智算菩萨1 小时前
基于spaCy的英文自然语言处理系统:低频词提取与高级文本分析
前端·javascript·easyui