多选优化,可以全选了
This commit is contained in:
@@ -10,8 +10,11 @@
|
|||||||
</template>
|
</template>
|
||||||
</ai-search-bar>
|
</ai-search-bar>
|
||||||
<ai-table :tableData="tableData" :total="page.total" :current.sync="page.current" :colConfigs="columns"
|
<ai-table :tableData="tableData" :total="page.total" :current.sync="page.current" :colConfigs="columns"
|
||||||
:size.sync="page.size" border @getList="getTableData" tableSize="mini" height="430px">
|
:size.sync="page.size" border @getList="getTableData" tableSize="mini">
|
||||||
<el-table-column slot="chb" width="100px">
|
<el-table-column slot="chb" width="100px">
|
||||||
|
<template #header>
|
||||||
|
<el-checkbox v-if="multiple" v-model="selectAll" @change="handleCheckAll"/>
|
||||||
|
</template>
|
||||||
<template slot-scope="{row}">
|
<template slot-scope="{row}">
|
||||||
<el-checkbox v-model="row.checked" @change="handleCheck(row)"/>
|
<el-checkbox v-model="row.checked" @change="handleCheck(row)"/>
|
||||||
</template>
|
</template>
|
||||||
@@ -37,6 +40,7 @@ export default {
|
|||||||
default: () => [
|
default: () => [
|
||||||
{prop: 'label', label: "应用名称"},
|
{prop: 'label', label: "应用名称"},
|
||||||
{prop: 'project', label: "项目/框架"},
|
{prop: 'project', label: "项目/框架"},
|
||||||
|
{prop: 'category', label: "分类"},
|
||||||
{prop: 'name', label: "模块名"},
|
{prop: 'name', label: "模块名"},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -49,6 +53,7 @@ export default {
|
|||||||
page: {total: 0, current: 1, size: 10},
|
page: {total: 0, current: 1, size: 10},
|
||||||
search: {},
|
search: {},
|
||||||
tableData: [],
|
tableData: [],
|
||||||
|
selectAll: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -75,6 +80,7 @@ export default {
|
|||||||
if (res?.data) {
|
if (res?.data) {
|
||||||
const list = res.data.records || res.data || []
|
const list = res.data.records || res.data || []
|
||||||
list.map(e => {
|
list.map(e => {
|
||||||
|
e.category = e.libPath.replace(/^\/[^\/]+\/([^\/]+)\/.+/, '$1')
|
||||||
if (/\/project\//.test(e.libPath)) {
|
if (/\/project\//.test(e.libPath)) {
|
||||||
e.project = e.libPath.replace(/.*project\/([^\/]+)\/.+/, '$1')
|
e.project = e.libPath.replace(/.*project\/([^\/]+)\/.+/, '$1')
|
||||||
} else if (/\/core\//.test(e.libPath)) {
|
} else if (/\/core\//.test(e.libPath)) {
|
||||||
@@ -99,6 +105,14 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.$emit("change", row.checked ? row[nodeKey] : '')
|
this.$emit("change", row.checked ? row[nodeKey] : '')
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
handleCheckAll(v) {
|
||||||
|
const {nodeKey} = this
|
||||||
|
let selected = this.tableData.map(e => {
|
||||||
|
e.checked = v
|
||||||
|
return e
|
||||||
|
}).filter(e => e.checked)?.map(e => e[nodeKey]) || []
|
||||||
|
this.$emit("change", selected)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|||||||
Reference in New Issue
Block a user