应用库搜索优化
This commit is contained in:
@@ -10,8 +10,8 @@
|
|||||||
</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" :dict="dict">
|
:size.sync="page.size" @getList="getTableData" tableSize="mini" :dict="dict" v-bind="$attrs">
|
||||||
<el-table-column slot="chb" width="100px">
|
<el-table-column slot="chb" width="100px" v-if="!disabled">
|
||||||
<template #header>
|
<template #header>
|
||||||
<el-checkbox v-if="multiple" v-model="selectAll" @change="handleCheckAll"/>
|
<el-checkbox v-if="multiple" v-model="selectAll" @change="handleCheckAll"/>
|
||||||
</template>
|
</template>
|
||||||
@@ -46,7 +46,9 @@ export default {
|
|||||||
},
|
},
|
||||||
nodeKey: {default: "id"},
|
nodeKey: {default: "id"},
|
||||||
searchKey: {default: "name"},
|
searchKey: {default: "name"},
|
||||||
multiple: Boolean
|
multiple: Boolean,
|
||||||
|
disabled: Boolean,
|
||||||
|
meta: {default: () => []}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -73,25 +75,31 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getTableData() {
|
getTableData() {
|
||||||
let {page, search, action, nodeKey} = this
|
const {page, search, action, meta, searchKey, dict} = this
|
||||||
this.instance?.post(action, null, {
|
if (meta.length > 0) {
|
||||||
|
const reg = new RegExp(search[searchKey])
|
||||||
|
this.handleTableData(meta.filter(e => reg.test(e.label) || reg.test(e.name) || reg.test(dict.getLabel('appsCategory', e.category))))
|
||||||
|
} else this.instance?.post(action, null, {
|
||||||
params: {...page, ...search}
|
params: {...page, ...search}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res?.data) {
|
if (res?.data) {
|
||||||
const list = res.data.records || res.data || []
|
|
||||||
list.map(e => {
|
|
||||||
e.category = e.libPath.replace(/^\/[^\/]+\/([^\/]+)\/.+/, '$1')
|
|
||||||
if (/\/project\//.test(e.libPath)) {
|
|
||||||
e.project = e.libPath.replace(/.*project\/([^\/]+)\/.+/, '$1')
|
|
||||||
} else if (/\/core\//.test(e.libPath)) {
|
|
||||||
e.project = "core"
|
|
||||||
} else e.project = "standard"
|
|
||||||
})
|
|
||||||
this.tableData = list.map(e => ({...e, checked: this.selected.includes(e[nodeKey])}))
|
|
||||||
this.page.total = res.data.total
|
this.page.total = res.data.total
|
||||||
|
this.handleTableData(res.data.records || res.data || [])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
handleTableData(list) {
|
||||||
|
const {nodeKey} = this
|
||||||
|
list.map(e => {
|
||||||
|
e.category = e.libPath.replace(/^\/[^\/]+\/([^\/]+)\/.+/, '$1')
|
||||||
|
if (/\/project\//.test(e.libPath)) {
|
||||||
|
e.project = e.libPath.replace(/.*project\/([^\/]+)\/.+/, '$1')
|
||||||
|
} else if (/\/core\//.test(e.libPath)) {
|
||||||
|
e.project = "core"
|
||||||
|
} else e.project = "standard"
|
||||||
|
})
|
||||||
|
this.tableData = list.map(e => ({...e, checked: this.selected.includes(e[nodeKey])}))
|
||||||
|
},
|
||||||
handleCheck(row) {
|
handleCheck(row) {
|
||||||
const {nodeKey} = this
|
const {nodeKey} = this
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<ai-card title="主库应用">
|
<ai-card title="主库应用">
|
||||||
<template #content>
|
<template #content>
|
||||||
<ai-lib-table v-if="form.type" v-model="form.apps" v-bind="$props" multiple searchKey="name"
|
<ai-lib-table v-if="form.type" v-model="form.apps" v-bind="$props" multiple searchKey="name"
|
||||||
:action="`/node/wechatapps/list?type=${form.type}&isMain=1`"/>
|
:action="`/node/wechatapps/list?type=${form.type}&isMain=1`" border/>
|
||||||
<ai-empty v-else>请先选择系统类型</ai-empty>
|
<ai-empty v-else>请先选择系统类型</ai-empty>
|
||||||
</template>
|
</template>
|
||||||
</ai-card>
|
</ai-card>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="方案应用" lazy>
|
<el-tab-pane label="方案应用" lazy>
|
||||||
<ai-table :tableData="appList" :colConfigs="colConfigs" :isShowPagination="false" :dict="dict"/>
|
<ai-lib-table :meta="appList" :isShowPagination="false" v-bind="$props" disabled/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</template>
|
</template>
|
||||||
@@ -95,12 +95,6 @@ export default {
|
|||||||
customPath: {required: true, message: "请输入"},
|
customPath: {required: true, message: "请输入"},
|
||||||
extra: {required: true, message: "请设置主页配置"},
|
extra: {required: true, message: "请设置主页配置"},
|
||||||
},
|
},
|
||||||
colConfigs: [
|
|
||||||
{prop: 'label', label: "应用名称"},
|
|
||||||
{prop: 'project', label: "项目/框架"},
|
|
||||||
{prop: 'category', label: "分类", dict: "appsCategory"},
|
|
||||||
{prop: 'name', label: "模块名"},
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
Reference in New Issue
Block a user