Commit 68e9d6cd authored by shangtx's avatar shangtx

feat: 服务管理增加首页展示设置

parent f0f5ecd6
...@@ -21,6 +21,16 @@ ...@@ -21,6 +21,16 @@
@click="enableChange(record, index)" @click="enableChange(record, index)"
/> />
</template> </template>
<template #showInHome="{ record, index }">
<a-switch
v-if="hasPerm('SYS0210101.ENABLE') && record.type == 2"
:checked="record.showInHome"
checked-children="展示"
un-checked-children="隐藏"
:loading="showInHomeLoadingKeys.includes(record.id)"
@click="showInHomeChange(record, index)"
/>
</template>
<template #free> <template #free>
<SubClassEdit ref="SubClassEdit" :success="reset" /> <SubClassEdit ref="SubClassEdit" :success="reset" />
<CategoryEdit ref="CategoryEdit" :success="reset" /> <CategoryEdit ref="CategoryEdit" :success="reset" />
...@@ -51,6 +61,13 @@ const columns = [ ...@@ -51,6 +61,13 @@ const columns = [
dataIndex: 'enabled', dataIndex: 'enabled',
filter: { type: SearchType.ENUM } filter: { type: SearchType.ENUM }
}, },
{
title: '首页展示',
scopedSlots: { customRender: 'showInHome' },
enum: 'SYS0002',
dataIndex: 'showInHome',
filter: { type: SearchType.ENUM }
},
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'createTime', dataIndex: 'createTime',
...@@ -73,6 +90,7 @@ export default { ...@@ -73,6 +90,7 @@ export default {
pagination: false, pagination: false,
codes: [['SYS0002'], []], codes: [['SYS0002'], []],
loadingKeys: [], loadingKeys: [],
showInHomeLoadingKeys: [],
rowKey: 'key' rowKey: 'key'
} }
}, },
...@@ -82,12 +100,10 @@ export default { ...@@ -82,12 +100,10 @@ export default {
this.expandedRowKeys = this.dataSource.map((d) => d.id + '') this.expandedRowKeys = this.dataSource.map((d) => d.id + '')
}, },
enableChange(record, index) { enableChange(record, index) {
console.info('record', record)
if (this.loadingKeys.includes(record.id)) { if (this.loadingKeys.includes(record.id)) {
return return
} }
this.loadingKeys.push(record.id) this.loadingKeys.push(record.id)
console.info('index', index)
saveOrUpdateSubClass({ id: record.id, enabled: !record.enabled }) saveOrUpdateSubClass({ id: record.id, enabled: !record.enabled })
.then(({ code }) => { .then(({ code }) => {
if (code == 200) { if (code == 200) {
...@@ -95,15 +111,36 @@ export default { ...@@ -95,15 +111,36 @@ export default {
const pIndex = this.dataSource.findIndex( const pIndex = this.dataSource.findIndex(
(d) => d.id == record.categoryId (d) => d.id == record.categoryId
) )
console.info(pIndex)
this.dataSource[pIndex].children[index].enabled = !record.enabled this.dataSource[pIndex].children[index].enabled = !record.enabled
console.info(this.dataSource)
} }
}) })
.finally(() => { .finally(() => {
this.loadingKeys.splice(this.loadingKeys.indexOf(record.id), 1) this.loadingKeys.splice(this.loadingKeys.indexOf(record.id), 1)
}) })
}, },
showInHomeChange(record, index) {
if (this.loadingKeys.includes(record.id)) {
return
}
this.showInHomeLoadingKeys.push(record.id)
saveOrUpdateSubClass({ id: record.id, showInHome: !record.showInHome })
.then(({ code }) => {
if (code == 200) {
this.$message.success('保存成功')
const pIndex = this.dataSource.findIndex(
(d) => d.id == record.categoryId
)
this.dataSource[pIndex].children[index].showInHome =
!record.showInHome
}
})
.finally(() => {
this.showInHomeLoadingKeys.splice(
this.showInHomeLoadingKeys.indexOf(record.id),
1
)
})
},
edit(record) { edit(record) {
const categoryName = this.dataSource.filter( const categoryName = this.dataSource.filter(
(d) => d.id == record.categoryId (d) => d.id == record.categoryId
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment