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.
132 lines
3.8 KiB
132 lines
3.8 KiB
<template> |
|
<div> |
|
<BasicTable @register="registerTable" |
|
@fetch-success="handleSelectionChange" |
|
@selection-change="handleSelectionChange" |
|
> |
|
<template #toolbar> |
|
<a-button v-auth="['config_add']" |
|
type="primary" |
|
@click="handleAdd()" |
|
>新增参数</a-button> |
|
<a-button v-auth="['config_edit']" |
|
type="primary" |
|
:disabled="state.single" |
|
@click="handleEdit()" |
|
>修改参数</a-button> |
|
<a-button v-auth="['config_del']" |
|
type="primary" |
|
:disabled="state.multiple" |
|
@click="handleDel()" |
|
>删除参数</a-button> |
|
</template> |
|
<template #action="{ record }"> |
|
<TableAction :actions="[ |
|
{ |
|
label: '编辑', |
|
icon: 'fa6-regular:pen-to-square', |
|
auth: ['role_edit'], |
|
onClick: handleEdit.bind(null, record) |
|
}, |
|
{ |
|
label: '删除', |
|
icon: 'ant-design:delete-outlined', |
|
auth: ['role_del'], |
|
color: 'error', |
|
onClick: handleDel.bind(null, record) |
|
}]" |
|
/> |
|
</template> |
|
</BasicTable> |
|
<ConfigModal @register="registerModal" @success="handleSuccess"/> |
|
</div> |
|
</template> |
|
<script lang="ts" setup> |
|
/** |
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
|
* author entfrm开发团队-王翔 |
|
*/ |
|
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
|
import { list, remove } from '/@/api/system/config'; |
|
import ConfigModal from './ConfigModal.vue'; |
|
import { columns, searchFormSchema } from './config.data'; |
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
import { reactive, toRaw } from 'vue'; |
|
import {useModal} from "/@/components/Modal"; |
|
|
|
const { createConfirm } = useMessage(); |
|
const { createMessage } = useMessage(); |
|
|
|
const state = reactive({ |
|
// 选中数组 |
|
ids: [], |
|
// 非单个禁用 |
|
single: true, |
|
// 非多个禁用 |
|
multiple: true |
|
}); |
|
|
|
const [registerModal, { openModal }] = useModal(); |
|
const [registerTable, { reload }] = useTable({ |
|
title: '角色列表', |
|
api: list, |
|
columns, |
|
formConfig: { |
|
labelWidth: 120, |
|
schemas: searchFormSchema |
|
}, |
|
useSearchForm: true, |
|
showTableSetting: true, |
|
bordered: true, |
|
rowSelection: { type: 'checkbox' }, |
|
showIndexColumn: false, |
|
clickToRowSelect: false, |
|
actionColumn: { |
|
width: 220, |
|
title: '操作', |
|
dataIndex: 'action', |
|
slots: { customRender: 'action' }, |
|
fixed: false |
|
} |
|
}); |
|
|
|
/** 处理多选框选中数据 */ |
|
function handleSelectionChange(selection?: Recordable) { |
|
const rawRows = toRaw(selection?.rows) || []; |
|
state.ids = rawRows.map(item => item.id); |
|
state.single = rawRows.length != 1; |
|
state.multiple = !rawRows.length; |
|
} |
|
|
|
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
|
function handleAdd() { |
|
openModal(true,{isUpdate: false }); |
|
} |
|
|
|
/** 编辑按钮操作,行内编辑 */ |
|
function handleEdit(record?: Recordable) { |
|
record = record || { id: toRaw(state.ids) }; |
|
openModal(true, { isUpdate: true, record }); |
|
} |
|
|
|
/** 删除按钮操作,行内删除 */ |
|
async function handleDel(record?: Recordable) { |
|
const ids = record?.id || toRaw(state.ids); |
|
createConfirm({ |
|
iconType: 'warning', |
|
title: '警告', |
|
content: `是否确认删除参数编号为${ids}参数吗?`, |
|
onOk: async () => { |
|
await remove({ids: ids}); |
|
createMessage.success('删除成功!'); |
|
handleSuccess(); |
|
} |
|
}); |
|
} |
|
|
|
/** 处理表单提交成功 */ |
|
function handleSuccess() { |
|
reload(); |
|
} |
|
|
|
</script>
|
|
|