|
@ -4,7 +4,7 @@ |
|
|
<el-button type="primary" @click="tableJs.addRow($refs.fubiao)"> |
|
|
<el-button type="primary" @click="tableJs.addRow($refs.fubiao)"> |
|
|
新增 |
|
|
新增 |
|
|
</el-button> |
|
|
</el-button> |
|
|
<el-button type="danger" @click="deleteFn"> |
|
|
<el-button type="danger" @click="tableJs.delRow($refs.fubiao)"> |
|
|
删除 |
|
|
删除 |
|
|
</el-button> |
|
|
</el-button> |
|
|
</div> |
|
|
</div> |
|
@ -14,7 +14,6 @@ |
|
|
:data.sync="tableData" |
|
|
:data.sync="tableData" |
|
|
border |
|
|
border |
|
|
style="width: 100%" |
|
|
style="width: 100%" |
|
|
@selection-change="handleSelectionChange" |
|
|
|
|
|
> |
|
|
> |
|
|
<el-table-column |
|
|
<el-table-column |
|
|
type="selection" |
|
|
type="selection" |
|
@ -32,7 +31,6 @@ |
|
|
class="inline-input" |
|
|
class="inline-input" |
|
|
:fetch-suggestions="querySearch" |
|
|
:fetch-suggestions="querySearch" |
|
|
placeholder="请输入内容" |
|
|
placeholder="请输入内容" |
|
|
@select="handleSelect" |
|
|
|
|
|
/> |
|
|
/> |
|
|
</template> |
|
|
</template> |
|
|
<el-table-column v-for="(k, i) in item.child" :key="i" :label="k.label" :prop="k.prop"> |
|
|
<el-table-column v-for="(k, i) in item.child" :key="i" :label="k.label" :prop="k.prop"> |
|
@ -42,7 +40,6 @@ |
|
|
class="inline-input" |
|
|
class="inline-input" |
|
|
:fetch-suggestions="querySearch" |
|
|
:fetch-suggestions="querySearch" |
|
|
placeholder="请输入内容" |
|
|
placeholder="请输入内容" |
|
|
@select="handleSelect" |
|
|
|
|
|
/> |
|
|
/> |
|
|
</template> |
|
|
</template> |
|
|
</el-table-column> |
|
|
</el-table-column> |
|
@ -83,20 +80,13 @@ export default { |
|
|
value: '/', |
|
|
value: '/', |
|
|
id: '3' |
|
|
id: '3' |
|
|
} |
|
|
} |
|
|
], |
|
|
] |
|
|
multipleSelection: [] |
|
|
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: {}, |
|
|
|
|
|
created() {}, |
|
|
|
|
|
methods: { |
|
|
methods: { |
|
|
handleSelectionChange(val) { |
|
|
|
|
|
console.log(val) |
|
|
|
|
|
this.multipleSelection = val |
|
|
|
|
|
}, |
|
|
|
|
|
querySearch(queryString, cb) { |
|
|
querySearch(queryString, cb) { |
|
|
var restaurants = this.options |
|
|
const restaurants = this.options |
|
|
var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants |
|
|
const results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants |
|
|
// 调用 callback 返回建议列表的数据 |
|
|
// 调用 callback 返回建议列表的数据 |
|
|
cb(results) |
|
|
cb(results) |
|
|
}, |
|
|
}, |
|
@ -104,32 +94,6 @@ export default { |
|
|
return (restaurant) => { |
|
|
return (restaurant) => { |
|
|
return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0) |
|
|
return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0) |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
handleSelect(item) { |
|
|
|
|
|
console.log(item) |
|
|
|
|
|
}, |
|
|
|
|
|
addtable() { |
|
|
|
|
|
this.tableData.push({}) |
|
|
|
|
|
}, |
|
|
|
|
|
deleteFn() { |
|
|
|
|
|
if (this.multipleSelection.length === 0) { |
|
|
|
|
|
this.$alert('请先选择要删除的数据', '提示', { |
|
|
|
|
|
confirmButtonText: '确定' |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.multipleSelection.forEach((val, index) => { |
|
|
|
|
|
console.log(val) |
|
|
|
|
|
// 遍历源数据 |
|
|
|
|
|
this.tableData.forEach((v, i) => { |
|
|
|
|
|
console.log(v) |
|
|
|
|
|
// 如果选中数据和源数据的某一条唯一标识符相等,删除对应的源数据 |
|
|
|
|
|
if (val.id === v.id) { |
|
|
|
|
|
this.tableData.splice(i, 1) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|