You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
194 lines
5.7 KiB
194 lines
5.7 KiB
<template> |
|
<div> |
|
<BasicTable |
|
@register="registerTable" |
|
@selection-change="handleSelectionChange" |
|
> |
|
<template #expandedRowRender="{ record }"> |
|
<BasicTable @register="pushTypeRegisterTable"> |
|
<template #bodyCell="{ column, record }"> |
|
<template v-if="column.key === 'action'"> |
|
<TableAction :actions="[ |
|
{ |
|
label: '编辑', |
|
icon: 'fa6-regular:pen-to-square', |
|
onClick: handlePushTypeEdit.bind(null, record) |
|
}]" |
|
/> |
|
</template> |
|
</template> |
|
</BasicTable> |
|
</template> |
|
<template #toolbar> |
|
<a-button |
|
type="primary" |
|
:disabled="state.single" |
|
@click="()=>{}" |
|
>推送通知</a-button> |
|
<a-button |
|
type="primary" |
|
:disabled="state.multiple" |
|
@click="handleDel()" |
|
>取消关注</a-button> |
|
</template> |
|
<template #bodyCell="{ column, record }"> |
|
<template v-if="column.key === 'action'"> |
|
<TableAction |
|
:actions="[ |
|
{ |
|
label: '查看', |
|
icon: 'fa6-regular:pen-to-square', |
|
onClick: handleViewEdit.bind(null, record) |
|
}]" |
|
:dropDownActions="[ |
|
{ |
|
label: '推送通知', |
|
icon: 'fa6-regular:pen-to-square', |
|
onClick: ()=>{} |
|
}, |
|
{ |
|
label: '取消关注', |
|
icon: 'ant-design:delete-outlined', |
|
color: 'error', |
|
onClick: handleDel.bind(null, record) |
|
}]" |
|
/> |
|
</template> |
|
</template> |
|
</BasicTable> |
|
<ConcernModal @register="registerModal" @success="handleRefreshTable"/> |
|
<TypeModal @register="pushTypeRegisterModal" @success="handleRefreshPushTypeTable"/> |
|
</div> |
|
</template> |
|
|
|
<script lang="ts" setup> |
|
import { reactive, toRaw } from 'vue'; |
|
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
|
import { listPushConcernFan, delPushConcernFan } from '/@/api/platform/common/controller/pushConcernFan'; |
|
import { useModal } from '/@/components/Modal'; |
|
import ConcernModal from './ConcernModal.vue'; |
|
import TypeModal from '../pushType/TypeModal.vue'; |
|
import { columns, searchFormSchema } from './concern.data'; |
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
import { useUserStore } from '/@/store/modules/user'; |
|
import { columns as pushTypeColumns, searchFormSchema as pushTypeSearchFormSchema} from '../pushType/type.data'; |
|
import { listPushConcernFanType } from '/@/api/platform/common/controller/pushConcernFanType'; |
|
|
|
const userStore = useUserStore(); |
|
const userInfoStore = userStore.getUserInfo; |
|
|
|
interface TableState { |
|
single: boolean; |
|
multiple: boolean; |
|
} |
|
|
|
const state = reactive<TableState>({ |
|
// 非单个禁用 |
|
single: true, |
|
// 非多个禁用 |
|
multiple: true |
|
}); |
|
const { createConfirm, createMessage } = useMessage(); |
|
const [registerModal, { openModal }] = useModal(); |
|
const [pushTypeRegisterModal, { openModal: pushTypeOpenModal }] = useModal(); |
|
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
|
title: '关注列表', |
|
api: listPushConcernFan, |
|
rowKey: 'id', |
|
columns, |
|
formConfig: { |
|
compact: true, |
|
labelWidth: 80, |
|
schemas: searchFormSchema, |
|
autoSubmitOnEnter: true, |
|
showAdvancedButton: true, |
|
autoAdvancedLine: 3, |
|
}, |
|
rowSelection: { type: 'checkbox' }, |
|
useSearchForm: true, |
|
showTableSetting: true, |
|
bordered: true, |
|
clickToRowSelect: false, |
|
showIndexColumn: false, |
|
actionColumn: { |
|
width: 220, |
|
title: '操作', |
|
dataIndex: 'action', |
|
fixed: false |
|
}, |
|
searchInfo: { |
|
status: '1', |
|
fanUserId: userInfoStore.id |
|
}, |
|
handleSearchInfoFn: () => clearSelectedRowKeys() |
|
}); |
|
const [pushTypeRegisterTable, { reload: pushTypeReload }] = useTable({ |
|
title: '推送类型列表', |
|
api: listPushConcernFanType, |
|
rowKey: 'id', |
|
columns: pushTypeColumns, |
|
formConfig: { |
|
compact: true, |
|
labelWidth: 80, |
|
schemas: pushTypeSearchFormSchema, |
|
autoSubmitOnEnter: true, |
|
showAdvancedButton: true, |
|
autoAdvancedLine: 3, |
|
}, |
|
useSearchForm: true, |
|
showTableSetting: true, |
|
bordered: true, |
|
clickToRowSelect: false, |
|
showIndexColumn: false, |
|
actionColumn: { |
|
width: 220, |
|
title: '操作', |
|
dataIndex: 'action', |
|
fixed: false |
|
}, |
|
}); |
|
|
|
/** 处理多选框选中数据 */ |
|
function handleSelectionChange(selection?: Recordable) { |
|
const rowSelection = toRaw(selection?.keys) || []; |
|
state.single = rowSelection.length != 1; |
|
state.multiple = !rowSelection.length; |
|
} |
|
|
|
/** 查看按钮操作,行内查看 */ |
|
function handleViewEdit(record?: Recordable) { |
|
record = record || { id: getSelectRowKeys() }; |
|
openModal(true, { _tag: 'view', record }); |
|
} |
|
|
|
function handlePushTypeEdit(record?: Recordable) { |
|
record = record || { id: getSelectRowKeys() }; |
|
pushTypeOpenModal(true, { _tag: 'concernEdit', record }); |
|
} |
|
|
|
/** 删除按钮操作,行内删除 */ |
|
async function handleDel(record?: Recordable) { |
|
const ids = record?.id || getSelectRowKeys(); |
|
createConfirm({ |
|
iconType: 'warning', |
|
title: '警告', |
|
content: `是否确认取消编号为${ids}的数据?`, |
|
onOk: async () => { |
|
await delPushConcernFan(ids); |
|
createMessage.success('取消成功!'); |
|
handleRefreshTable(); |
|
} |
|
}); |
|
} |
|
|
|
/** 处理表格刷新 */ |
|
function handleRefreshTable() { |
|
clearSelectedRowKeys(); |
|
reload(); |
|
} |
|
|
|
function handleRefreshPushTypeTable() { |
|
pushTypeReload(); |
|
} |
|
|
|
</script>
|
|
|