问题:
1、添加数据后下拉框中未显示带入的数据
2、不可以重复添加相同的数据
3、复选框选中单行或多行以后点击按钮禁用对于行的input
大神们 帮忙看看怎么解决啊。
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<div id="app">
<div style="padding: 16px;">
<div>
<el-select
v-model="arrList"
multiple
@remove-tag="arrRemoveTag"
size="small"
collapse-tags
placeholder="请选择">
<el-option
v-for="item in selectList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-button type="primary" @click="selectionDialog = true">添加数据</el-button>
</div>
<el-table
ref="multipleTable"
:data="tableData"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="日期" width="120">
<template slot-scope="scope">
<el-input :disabled="isShow"></el-input>
</template>
</el-table-column>
<el-table-column prop="name" label="姓名" width="120">
<template slot-scope="scope">
<el-input :disabled="isShow"></el-input>
</template>
</el-table-column>
<el-table-column prop="address" label="地址">
<template slot-scope="scope">
<el-input :disabled="isShow"></el-input>
</template>
</el-table-column>
</el-table>
<el-button type="primary" @click="disableBtn">选中行禁用</el-button>
<div class="list">
<el-dialog
title="弹窗"
:visible.sync="selectionDialog"
width="40%">
<div class="tableDiv">
<el-table
:data="selectionTableData"
@selection-change="selectionChange"
style="width: 100%">
<el-table-column type="index" label="序号" width="70px"></el-table-column>
<el-table-column type="selection"></el-table-column>
<el-table-column prop="name" label="名字" width=""></el-table-column>
</el-table>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="selectionDialog = false">取 消</el-button>
<el-button size="small" type="primary" @click="confirm()">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</div>
new Vue({
el: '#app',
data () {
return {
isShow: false, // input 禁用
selectionDialog: false, // 弹窗
arrList: [], // 下拉输入框model
selectList: [],
tableData: [
// {
// date: '2016-05-03',
// name: '王小虎',
// address: '上海市普陀区金沙江路 1518 弄'
// }, {
// date: '2016-05-02',
// name: '王小虎',
// address: '上海市普陀区金沙江路 1518 弄'
// }, {
// date: '2016-05-04',
// name: '王小虎',
// address: '上海市普陀区金沙江路 1518 弄'
// }
],
selectionTableData: [
{
name: '王二小'
},
{
name: '李老四'
}
],
multipleSelection: [], // 页面多选
multipleList: [] // 弹窗多选
}
},
methods: {
// 页面
handleSelectionChange(val) {
this.multipleSelection = val;
},
// 弹窗
selectionChange(val) {
this.multipleList = val
},
// 选中一行或多行 禁用行 input
disableBtn () {
this.tableData.forEach((val,inx) => {
this.tableData[inx].isShow = true
console.log('val::',val)
console.log('inx::',inx)
})
// this.multipleSelection.forEach((item,index) => {
// console.log('itme::',item)
// console.log('index::',index)
// })
},
// 弹窗确定
confirm() {
this.multipleList.forEach((item,index) => {
if(this.arrList.indexOf(item.name) == -1){
this.arrList.push(item.name)
}
this.tableData = this.selectionTableData
})
this.selectionDialog = false
this.multipleList = []
},
arrRemoveTag (tag) {
console.log(tag);
},
}
})