import SaveForm from '@/components/save-form' import Pagination from '@/components/pagination' import { NButton, NCascader, NDataTable, NFormItem, NInput, NModal, NSpace, NTag, useDialog, useMessage } from 'naive-ui' import { defineComponent, onMounted, reactive, ref } from 'vue' import { sysApplicationPage, sysRolePage, sysRoleRemove } from '../api' import RoleOperation from './role-operation' import { formatDataList } from '@/utils/urlUtils' export default defineComponent({ name: 'subsidy-list', setup() { const state = reactive({ loading: false, pagination: { page: 1, rows: 10, pageTotal: 0 }, searchForm: { appId: null, roleName: null }, dataList: [] as any, applyList: [] as any, visiableRole: false, roleOperation: 'add', roleData: {} as any }) const dialog = useDialog() const message = useMessage() const columns = () => { return [ { title: '编号', key: 'id' }, { title: '应用名', key: 'appName' }, { title: '角色名称', key: 'roleName' }, { title: '角色状态', key: 'enable', render(row: any) { return row.enable ? 开启 : 关闭 } }, { title: '角色描述', key: 'roleDesc' }, { title: '创建时间', key: 'createTime' }, { title: '操作', key: 'operation', render(row: any) { return ( { state.visiableRole = true state.roleOperation = 'edit' state.roleData = row }} > 修改 onRemove(row)} //v-auth="sysRole/remove1597890339439759362" > 删除 ) } } ] } const onRemove = (row: any): void => { console.log(row, 'row') dialog.warning({ title: '警告', content: `删除"${row.roleName}",是否继续?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await sysRoleRemove({ id: row.id }) getList() message.success('删除成功') } catch {} } }) } const getList = async () => { try { state.loading = true const { data } = await sysRolePage({ ...state.pagination, ...state.searchForm }) state.loading = false state.pagination.pageTotal = Number(data.total) state.dataList = data.rows || [] } catch { state.loading = false } } const getApplyList = async (parentId = 0) => { try { const { data } = await sysApplicationPage({ page: 1, rows: 999, leafQuery: true, parentId }) state.applyList = formatDataList(data.rows || [], 'bizApps') } catch {} } const saveForm = ref() const onSubmit = () => { state.pagination.page = 1 getList() } const onSearch = () => { saveForm.value?.submit() } const onBtnReset = () => { saveForm.value?.reset() } onMounted(() => { getList() getApplyList() }) return () => (
(state.searchForm = val)} > 搜索 重置
{ state.visiableRole = true state.roleData = {} state.roleOperation = 'add' }} > 添加角色
(state.visiableRole = false)} onGetList={getList} />
) } })