Commit b54bf3c1 authored by shangtx's avatar shangtx

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

parent 7d166c7d
......@@ -21,6 +21,16 @@
@click="enableChange(record, index)"
/>
</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>
<SubClassEdit ref="SubClassEdit" :success="reset" />
<CategoryEdit ref="CategoryEdit" :success="reset" />
......@@ -51,6 +61,13 @@ const columns = [
dataIndex: 'enabled',
filter: { type: SearchType.ENUM }
},
{
title: '首页展示',
scopedSlots: { customRender: 'showInHome' },
enum: 'SYS0002',
dataIndex: 'showInHome',
filter: { type: SearchType.ENUM }
},
{
title: '创建时间',
dataIndex: 'createTime',
......@@ -73,6 +90,7 @@ export default {
pagination: false,
codes: [['SYS0002'], []],
loadingKeys: [],
showInHomeLoadingKeys: [],
rowKey: 'key'
}
},
......@@ -82,12 +100,10 @@ export default {
this.expandedRowKeys = this.dataSource.map((d) => d.id + '')
},
enableChange(record, index) {
console.info('record', record)
if (this.loadingKeys.includes(record.id)) {
return
}
this.loadingKeys.push(record.id)
console.info('index', index)
saveOrUpdateSubClass({ id: record.id, enabled: !record.enabled })
.then(({ code }) => {
if (code == 200) {
......@@ -95,15 +111,36 @@ export default {
const pIndex = this.dataSource.findIndex(
(d) => d.id == record.categoryId
)
console.info(pIndex)
this.dataSource[pIndex].children[index].enabled = !record.enabled
console.info(this.dataSource)
}
})
.finally(() => {
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) {
const categoryName = this.dataSource.filter(
(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