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 == lineInfosi.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: '',

});

},

}

相关推荐
丷丩1 小时前
MapLibre GL JS第19课:实时更新要素
前端·javascript·gis·map·mapbox·maplibre gl js
xiaohua0708day2 小时前
Lodash库
前端·javascript·vue.js
万物皆对象6662 小时前
切换路由时页面空白问题(vue3)
前端·vue.js·typescript
突然好热2 小时前
TS 调试技巧
前端·javascript·typescript
h64648564h2 小时前
Flutter 国际化(i18n)全指南:一键切换中/英/日多语言
前端·javascript·flutter
丷丩4 小时前
MapLibre GL JS第8课:禁用滚动缩放
javascript·mapbox·maplibre gl js
李剑一4 小时前
小红书前端架构面试问的挺深入啊!面试官:Vue中组合式API与选项式API的设计权衡
vue.js·面试
一 乐5 小时前
汽车租赁|基于SprinBoot+vue的汽车租赁管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·汽车·论文·毕设·汽车租赁管理系统
kyriewen6 小时前
面试8家前端岗位后,我发现了一个残酷的事实:AI不是加分项,是门槛
前端·javascript·面试
MageGojo8 小时前
做节日活动页时,如何用 API 快速生成对联内容
javascript·python·节日·对联生成