UP scFormTable 1.3 增加外部新增删除方法
This commit is contained in:
parent
1c8869c476
commit
c31958d0b7
|
@ -1,10 +1,10 @@
|
||||||
<!--
|
<!--
|
||||||
* @Descripttion: 表单表格
|
* @Descripttion: 表单表格
|
||||||
* @version: 1.2
|
* @version: 1.3
|
||||||
* @Author: sakuya
|
* @Author: sakuya
|
||||||
* @Date: 2023年2月9日12:32:26
|
* @Date: 2023年2月9日12:32:26
|
||||||
* @LastEditors: sakuya
|
* @LastEditors: sakuya
|
||||||
* @LastEditTime: 2023年2月17日09:52:24
|
* @LastEditTime: 2023年2月17日10:41:47
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -98,6 +98,15 @@
|
||||||
},
|
},
|
||||||
rowDel(row, index){
|
rowDel(row, index){
|
||||||
this.data.splice(index, 1)
|
this.data.splice(index, 1)
|
||||||
|
},
|
||||||
|
//插入行
|
||||||
|
pushRow(row){
|
||||||
|
const temp = row || JSON.parse(JSON.stringify(this.addTemplate))
|
||||||
|
this.data.push(temp)
|
||||||
|
},
|
||||||
|
//根据index删除
|
||||||
|
deleteRow(index){
|
||||||
|
this.data.splice(index, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<el-input v-model="form.title"></el-input>
|
<el-input v-model="form.title"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="表格" prop="list">
|
<el-form-item label="表格" prop="list">
|
||||||
<sc-form-table v-model="form.list" :addTemplate="addTemplate" drag-sort placeholder="暂无数据">
|
<sc-form-table ref="table" v-model="form.list" :addTemplate="addTemplate" drag-sort placeholder="暂无数据">
|
||||||
<el-table-column prop="time" label="时间" width="180">
|
<el-table-column prop="time" label="时间" width="180">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-time-select v-model="scope.row.time"></el-time-select>
|
<el-time-select v-model="scope.row.time"></el-time-select>
|
||||||
|
@ -44,6 +44,10 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
<el-card shadow="never" header="方法" style="margin-top: 15px;">
|
||||||
|
<el-button type="primary" @click="pushRow">外部插入行</el-button>
|
||||||
|
<el-button type="primary" @click="deleteRow">外部删除第一行</el-button>
|
||||||
|
</el-card>
|
||||||
</el-main>
|
</el-main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -108,6 +112,19 @@
|
||||||
},
|
},
|
||||||
resetForm(){
|
resetForm(){
|
||||||
this.$refs.ruleForm.resetFields();
|
this.$refs.ruleForm.resetFields();
|
||||||
|
},
|
||||||
|
pushRow(){
|
||||||
|
const data = {
|
||||||
|
time: '18:00',
|
||||||
|
type: '1',
|
||||||
|
val: '0',
|
||||||
|
open: true,
|
||||||
|
checked: true
|
||||||
|
}
|
||||||
|
this.$refs.table.pushRow(data)
|
||||||
|
},
|
||||||
|
deleteRow(){
|
||||||
|
this.$refs.table.deleteRow(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue