表格按钮组组件

frame
lijingjia 1 day ago
parent c75d1fe556
commit 7532c41c98

@ -1,75 +1,58 @@
import { ref } from 'vue' /*
* @Desc:
* @Author: lijj
* @Date: 2024-09-26 08:43:39
*/
import { BasicColumn, FormSchema } from '/@/components/Table' import { BasicColumn, FormSchema } from '/@/components/Table'
import { getTablesByClient } from '/@/views/baseinfo/formcopy/api'
import { getColumns, getClientPermissionList } from '/@/api/system/role'
import { Tag } from 'ant-design-vue'
// 引入字典数据
import { getDictOption } from '/@/utils/dictUtil'
// 下拉框数据接口
import { GetClientListByCode } from '/@/api/common'
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '权限模板类型', title: '权限模板类型',
dataIndex: 'templateName', dataIndex: 'templateName',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '权限模板范围', title: '权限模板范围',
dataIndex: 'ruleScopeName', dataIndex: 'ruleScopeName',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '资源标识', title: '资源标识',
dataIndex: 'permissionEntity', dataIndex: 'permissionEntity',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '中文视图名', title: '中文视图名',
dataIndex: 'columnView', dataIndex: 'columnView',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '排序号', title: '排序号',
dataIndex: 'orderNo', dataIndex: 'orderNo',
width: 50, width: 80,
align: 'left'
}, },
{ {
title: '可视/可操作', title: '可视/可操作',
dataIndex: 'ruleType', dataIndex: 'ruleType',
width: 120, width: 120,
customRender: ({ text }) => { align: 'left'
if (text === 'visible') {
return '可视'
} else if (text === 'operate') {
return '可操作'
}
return text
},
}, },
{ {
title: '是否启用', title: '是否启用',
dataIndex: 'status', dataIndex: 'status',
width: 80, width: 90,
customRender: ({ text }) => { align: 'left'
if (text === 0) {
return <Tag color="success"></Tag>
} else if (text === 1) {
return <Tag color="error"></Tag>
}
return text
},
}, },
{ {
title: '权限描述', title: '权限描述',
dataIndex: 'description', dataIndex: 'description',
width: 200, width: 200,
}, align: 'left'
// { }
// title: '备注??',
// dataIndex: 'note',
// width: 200,
// },
] ]
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [

@ -1,83 +1,39 @@
<template> <template>
<div> <div class="p20">
<BasicTable class="ds-table" @register="registerTable" @row-dbClick="handleAudit"> <BasicTable class="ds-table" @register="registerTable" @row-dbClick="handleAudit">
<template #tableTitle> <template #tableTitle>
<div class="tableTitleBox"> <TableButton
<a-tooltip placement="top" :mouseEnterDelay="0.5"> :show="{ add: null, del: null, copy: null }"
<template #title> @add="handleCreate"
<span>新建</span> @del="handleDelete"
</template> @copy="handleCopy"
<span class="ds-action-svg-btn">
<a-button v-repeat type="link" @click="handleCreate">
<img src="../../../assets/svg/infoclient/xinjian.svg" class="SvgImg" />
</a-button>
</span>
</a-tooltip>
<a-tooltip placement="top" :mouseEnterDelay="0.5">
<template #title>
<span>复制</span>
</template>
<a-button v-repeat type="link" @click="handleCopy">
<img src="../../../assets/svg/infoclient/fuzhi.svg" class="SvgImg" />
</a-button>
</a-tooltip>
<a-tooltip placement="top" :mouseEnterDelay="0.5">
<template #title>
<span>删除</span>
</template>
<span class="ds-action-svg-btn">
<a-popconfirm title="确定删除当前选中数据?" ok-text="" cancel-text="" @confirm="handleDelete">
<a-button v-repeat type="link">
<img src="../../../assets/svg/infoclient/shanchu.svg" class="SvgImg" />
</a-button>
</a-popconfirm>
</span>
</a-tooltip>
</div>
<!-- <a-button type="link" @click="handleCreate">
<span class="iconfont icon-new_document"></span>
添加
</a-button>
<a-popconfirm
title="确定删除当前选中数据?"
ok-text="是"
cancel-text="否"
@confirm="handleDelete"
> >
<a-button type="link"> </TableButton>
<span class="iconfont icon-shanchu21"></span>
删除
</a-button>
</a-popconfirm> -->
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.dataIndex === 'ruleType'">
<TableAction :actions="[ {{ record.ruleType == 'visible' ? '可视' : (record.ruleType == 'operate' ? '可操作' : '-') }}
{ </template>
icon: 'clarity:note-edit-line', <template v-if="column.dataIndex == 'status'">
tooltip: '编辑', <a-tag v-if="record.status == '0'" color="success"></a-tag>
onClick: handleAudit.bind(null, record), <a-tag v-else color="error">禁用</a-tag>
},
]" />
</template> </template>
</template> </template>
</BasicTable> </BasicTable>
<TenantAuditStepModal @register="registerModal" @success="handleSuccess" /> <TenantAuditStepModal @register="registerModal" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup name="权限模版">
import { defineComponent, onMounted, ref } from 'vue' import { BasicTable, useTable, TableAction } from '/@/components/Table'
import { BasicTable, useTable, TableAction, SorterResult } from '/@/components/Table'
import { ApiList, ApiDel, BatchCopyDataRuleTemplate } from './api' import { ApiList, ApiDel, BatchCopyDataRuleTemplate } from './api'
import { useModal } from '/@/components/Modal' import { useModal } from '/@/components/Modal'
import TenantAuditStepModal from './TenantAuditStepModal.vue' import TenantAuditStepModal from './TenantAuditStepModal.vue'
import { columns, searchFormSchema } from './columns' import { columns, searchFormSchema } from './columns'
import { formatParams } from '/@/hooks/web/common' import { formatParams } from '/@/hooks/web/common'
import { useMessage } from '/@/hooks/web/useMessage' import { useMessage } from '/@/hooks/web/useMessage'
const { notification } = useMessage() const { createMessage } = useMessage()
const [registerModal, { openModal }] = useModal() const [registerModal, { openModal }] = useModal()
const [registerTable, { reload, getSelectRows, getForm, getPaginationRef }] = useTable({ const [registerTable, { reload, getVxeSelectRows }] = useTable({
title: '',
api: async (p) => { api: async (p) => {
const res: API.DataResult = await ApiList(p) const res: API.DataResult = await ApiList(p)
return new Promise((resolve) => { return new Promise((resolve) => {
@ -98,19 +54,12 @@ const [registerTable, { reload, getSelectRows, getForm, getPaginationRef }] = us
useSearchForm: true, useSearchForm: true,
showTableSetting: true, showTableSetting: true,
bordered: true, bordered: true,
showIndexColumn: true,
indexColumnProps: {
width: 60,
},
canResize: true, canResize: true,
resizeHeightOffset: 35,
immediate: true, immediate: true,
actionColumn: { resizeHeightOffset: 45,
width: 80, tableComponent: 'vxe',
title: '操作', id: '0',
dataIndex: 'action', autoHeight: window.innerHeight - 330.5
fixed: 'right',
},
// rowSelection: { type: 'checkbox' }, // rowSelection: { type: 'checkbox' },
// clickToRowSelect: false, // clickToRowSelect: false,
}) })
@ -127,28 +76,28 @@ function handleAudit(record: Recordable) {
} }
function handleCopy() { function handleCopy() {
let ids = [] let ids = []
ids = getSelectRows().map((item) => { ids = getVxeSelectRows().map((item) => {
return item.id return item.id
}) })
if (ids.length == 0) { if (ids.length == 0) {
notification.error('请选择要复制的数据') createMessage.warning('请选择要复制的数据')
return false return false
} }
BatchCopyDataRuleTemplate({ids:ids}).then(res=>{ BatchCopyDataRuleTemplate({ids:ids}).then(res=>{
if(res.succeeded){ if(res.succeeded){
notification.success('复制成功') createMessage.success('复制成功')
reload() reload()
} }
}) })
} }
// //
async function handleDelete(record: Recordable) { async function handleDelete(record: Recordable) {
const select = getSelectRows() const select = getVxeSelectRows()
let ApiData: any = { let ApiData: any = {
ids: [], ids: [],
} }
if (select.length === 0) { if (select.length === 0) {
notification.warning({ message: '请至少选择一条数据', duration: 3 }) createMessage.warning('请至少选择一条数据')
return false return false
} else { } else {
ApiData.ids = select.map((item) => { ApiData.ids = select.map((item) => {
@ -158,19 +107,9 @@ async function handleDelete(record: Recordable) {
ApiDel(ApiData).then((res) => { ApiDel(ApiData).then((res) => {
console.log(res) console.log(res)
notification.success({ message: res.message, duration: 3 }) createMessage.success(res.message)
reload() reload()
}) })
// const res: API.DataResult = await ApiDel({
// id: '',
// ids: [record.id],
// })
// if (res.succeeded) {
// notification.success({ message: res.message, duration: 3 })
// reload()
// } else {
// notification.error({ message: res.message, duration: 3 })
// }
} }
function handleSuccess() { function handleSuccess() {
reload() reload()

@ -1,24 +1,33 @@
/*
* @Desc:
* @Author: lijj
* @Date: 2024-05-13 09:06:51
*/
import { BasicColumn, FormSchema } from '/@/components/Table' import { BasicColumn, FormSchema } from '/@/components/Table'
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '角色唯一码', title: '角色唯一码',
dataIndex: 'roleCode', dataIndex: 'roleCode',
width: 100, width: 100,
align: 'left'
}, },
{ {
title: '角色名称', title: '角色名称',
dataIndex: 'roleName', dataIndex: 'roleName',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'createTime', dataIndex: 'createTime',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '备注', title: '备注',
dataIndex: 'note', dataIndex: 'note',
width: 150, width: 150,
align: 'left'
}, },
] ]

@ -1,90 +1,69 @@
<template> <template>
<div> <div class="p20">
<BasicTable @register="registerTable"> <BasicTable class="ds-table" @register="registerTable" @row-dbClick="handleEdit">
<template #toolbar> <template #tableTitle>
<a-button type="primary" @click="handleCreate"> </a-button> <TableButton
:show="{ add: null }"
@add="handleCreate"
>
</TableButton>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'roleName'"> <template v-if="column.key === 'roleName'">
<span style="color: #0d84ff" @click="handleEdit(record)">{{ record.roleName }}</span> <span style="color: #0d84ff" @click="handleEdit(record)">{{ record.roleName }}</span>
</template> </template>
<template v-if="column.key === 'action'"> </template>
<TableAction <template v-slot:tableAction="{ record }">
:actions="[ <a-tooltip placement="top" :mouseEnterDelay="0.5">
{ <template #title>
icon: 'clarity:note-edit-line', <span>授权</span>
tooltip: '编辑', </template>
onClick: handleEdit.bind(null, record), <a-button @click="handlePermission(record)" type="link">
}, <span class="iconfont icon-renwu_"></span>
{ </a-button>
icon: 'ant-design:trademark-circle-outlined', </a-tooltip>
tooltip: '授权', <a-tooltip placement="top" :mouseEnterDelay="0.5">
onClick: handlePermission.bind(null, record), <template #title>
}, <span>删除</span>
{ </template>
icon: 'ant-design:delete-outlined', <a-popconfirm
tooltip: '删除', title="确定删除当前选中数据?"
color: 'error', ok-text="是"
popConfirm: { cancel-text="否"
title: '是否要删除此条数据?', @confirm="handleDelete(record)"
okText: '是', >
cancelText: '否', <a-button type="link">
confirm: handleDelete.bind(null, record), <span class="iconfont icon-shanchu3"></span>
}, </a-button>
}, </a-popconfirm>
]" </a-tooltip>
/>
</template>
</template> </template>
</BasicTable> </BasicTable>
<RoleModal @register="registerModal" @success="handleSuccess" /> <RoleModal @register="registerModal" @success="handleSuccess" />
<RolePermissionModal @register="registerPermissionModal" @success="handleSuccess" /> <RolePermissionModal @register="registerPermissionModal" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup name="角色管理">
import { defineComponent, onMounted, ref } from 'vue' import { BasicTable, useTable } from '/@/components/Table'
import { BasicTable, useTable, TableAction } from '/@/components/Table'
import { getRoleList, deleteRole } from '/@/api/system/role' import { getRoleList, deleteRole } from '/@/api/system/role'
import { useModal } from '/@/components/Modal' import { useModal } from '/@/components/Modal'
import RoleModal from './RoleModal.vue' import RoleModal from './RoleModal.vue'
import RolePermissionModal from './RolePermissionModal.vue' import RolePermissionModal from './RolePermissionModal.vue'
import { columns, searchFormSchema } from './columns' import { columns, searchFormSchema } from './columns'
import { useMessage } from '../../../hooks/web/useMessage' import { useMessage } from '../../../hooks/web/useMessage'
import { formatParams } from '/@/hooks/web/common'
const { createMessage } = useMessage() const { createMessage } = useMessage()
const [registerModal, { openModal }] = useModal() const [registerModal, { openModal }] = useModal()
const [registerPermissionModal, { openModal: openPermissionModal }] = useModal() const [registerPermissionModal, { openModal: openPermissionModal }] = useModal()
const [registerTable, { reload, getForm, getPaginationRef }] = useTable({ const [registerTable, { reload, getVxeSelectRows }] = useTable({
title: '角色列表',
// api: getSysDictTypeList,
api: async (p) => { api: async (p) => {
const res: API.DataResult = await getRoleList(p) const res: API.DataResult = await getRoleList(p)
// console.log(items);
return new Promise((resolve) => { return new Promise((resolve) => {
resolve({ data: [...res.data], total: res.count }) resolve({ data: [...res.data], total: res.count })
}) })
}, },
beforeFetch: () => { beforeFetch: (p) => {
var currentPageInfo: any = getPaginationRef() return formatParams(p)
var data = getForm().getFieldsValue()
const postParam: API.PageRequest = {
queryCondition: '',
pageCondition: {
pageIndex: currentPageInfo.current,
pageSize: currentPageInfo.pageSize,
sortConditions: [],
},
}
let condition: API.ConditionItem[] = []
if (!!data.RoleName) {
condition.push({
FieldName: 'RoleName',
FieldValue: data.RoleName,
ConditionalType: 1,
})
}
postParam.queryCondition = JSON.stringify(condition)
// console.log(postParam);
return postParam
}, },
columns, columns,
formConfig: { formConfig: {
@ -100,11 +79,15 @@
showIndexColumn: true, showIndexColumn: true,
canResize: false, canResize: false,
actionColumn: { actionColumn: {
width: 80, width: 100,
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
fixed: undefined, fixed: undefined,
}, },
resizeHeightOffset: 45,
tableComponent: 'vxe',
id: '0',
autoHeight: window.innerHeight - 330.5
}) })
function handleCreate() { function handleCreate() {
@ -138,7 +121,6 @@
createMessage.warning(res.message) createMessage.warning(res.message)
} }
} }
function handleSuccess() { function handleSuccess() {
reload() reload()
} }

@ -57,107 +57,109 @@ export const columns: BasicColumn[] = [
title: '用户编码', title: '用户编码',
dataIndex: 'userCode', dataIndex: 'userCode',
width: 100, width: 100,
align: 'left'
}, },
{ {
title: '用户名称', title: '用户名称',
dataIndex: 'userName', dataIndex: 'userName',
width: 120, width: 120,
align: 'left'
}, },
{ {
title: '英文名称', title: '英文名称',
dataIndex: 'userEnName', dataIndex: 'userEnName',
width: 120, width: 120,
align: 'left'
}, },
{ {
title: '用户类型', title: '用户类型',
dataIndex: 'userType', dataIndex: 'userType',
width: 120, width: 120,
customRender: ({ text }) => { align: 'left'
if (text === 1) {
return <Tag color="success"></Tag>
} else if (text === 2) {
return <Tag color="blue"></Tag>
}
return text
},
}, },
{ {
title: '员工代码', title: '员工代码',
dataIndex: 'userNumber', dataIndex: 'userNumber',
width: 120, width: 120,
align: 'left'
}, },
{ {
title: '助记码', title: '助记码',
dataIndex: 'pinYinCode', dataIndex: 'pinYinCode',
width: 120, width: 120,
align: 'left'
}, },
{ {
title: '性别', title: '性别',
dataIndex: 'sex', dataIndex: 'sex',
width: 120, width: 120,
customRender: ({ text }) => { align: 'left'
if (text === 1) {
return <Tag color="blue"></Tag>
} else if (text === 2) {
return <Tag color="error"></Tag>
}
return text
},
}, },
{ {
title: '默认机构', title: '默认机构',
dataIndex: 'defaultOrgName', dataIndex: 'defaultOrgName',
width: 140, width: 140,
align: 'left'
}, },
{ {
title: '默认部门', title: '默认部门',
dataIndex: 'deptName', dataIndex: 'deptName',
width: 140, width: 140,
align: 'left'
}, },
{ {
title: '手机号', title: '手机号',
dataIndex: 'phone', dataIndex: 'phone',
width: 140, width: 140,
align: 'left'
}, },
{ {
title: '电话', title: '电话',
dataIndex: 'tel', dataIndex: 'tel',
width: 120, width: 120,
align: 'left'
}, },
{ {
title: '办公电话', title: '办公电话',
dataIndex: 'officePhone', dataIndex: 'officePhone',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '邮箱', title: '邮箱',
dataIndex: 'email', dataIndex: 'email',
width: 100, width: 100,
align: 'left'
}, },
{ {
title: '职务', title: '职务',
dataIndex: 'duty', dataIndex: 'duty',
width: 100, width: 100,
align: 'left'
}, },
{ {
title: '角色', title: '角色',
dataIndex: 'roleName', dataIndex: 'roleName',
width: 100, width: 100,
align: 'left'
}, },
{ {
title: '财务软件代码', title: '财务软件代码',
dataIndex: 'financeSoftCode', dataIndex: 'financeSoftCode',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'createTime', dataIndex: 'createTime',
width: 200, width: 200,
align: 'left'
}, },
{ {
title: '备注', title: '备注',
dataIndex: 'note', dataIndex: 'note',
width: 150, width: 150,
align: 'left'
}, },
] ]

@ -2,39 +2,29 @@
<div class="p20"> <div class="p20">
<BasicTable class="ds-table" @register="registerTable" @row-dbClick="handleEdit"> <BasicTable class="ds-table" @register="registerTable" @row-dbClick="handleEdit">
<template #tableTitle> <template #tableTitle>
<a-button type="link" @click="handleCreate"> <TableButton
<span class="iconfont icon-new_document"></span> :show="{ add: null, del: null }"
新增 @add="handleCreate"
</a-button> @del="handleDelete"
>
</TableButton>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'userName'"> <template v-if="column.dataIndex == 'userType'">
<span style="color: #0d84ff" @click="handleEdit(record)">{{ record.userName }}</span> <a-tag v-if="record.userType == '1'" color="success"></a-tag>
<a-tag v-else color="blue">普通用户</a-tag>
</template>
<template v-if="column.dataIndex == 'sex'">
<a-tag v-if="record.sex == '1'" color="blue"></a-tag>
<a-tag v-else color="error"></a-tag>
</template> </template>
</template>
<template v-slot:tableAction="{ record }">
<a-tooltip placement="top" :mouseEnterDelay="0.5">
<template #title>
<span>删除</span>
</template>
<a-popconfirm
title="是否要删除此条数据?"
ok-text="是"
cancel-text="否"
@confirm="handleDelete(record)"
>
<a-button type="link">
<span class="iconfont icon-del"></span>
</a-button>
</a-popconfirm>
</a-tooltip>
</template> </template>
</BasicTable> </BasicTable>
<UserModal @register="registerModal" @success="handleSuccess" /> <UserModal @register="registerModal" @success="handleSuccess" />
<UserPermissionModal @register="registerPermissionModal" @success="handleSuccess" /> <UserPermissionModal @register="registerPermissionModal" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup name="用户管理">
import { onMounted } from 'vue' import { onMounted } from 'vue'
import { BasicTable, useTable } from '/@/components/Table' import { BasicTable, useTable } from '/@/components/Table'
import { getUserList, BatchDelUser } from '/@/api/system/user' import { getUserList, BatchDelUser } from '/@/api/system/user'
@ -47,7 +37,7 @@
import { useMessage } from '/@/hooks/web/useMessage' import { useMessage } from '/@/hooks/web/useMessage'
const { createMessage } = useMessage() const { createMessage } = useMessage()
const [registerPermissionModal, { openModal: openPermissionModal }] = useModal() const [registerPermissionModal, { openModal: openPermissionModal }] = useModal()
const [registerTable, { reload }] = useTable({ const [registerTable, { reload, getVxeSelectRows }] = useTable({
api: async (p) => { api: async (p) => {
const res: API.DataResult = await getUserList(p) const res: API.DataResult = await getUserList(p)
return new Promise((resolve) => { return new Promise((resolve) => {
@ -69,12 +59,6 @@
showTableSetting: true, showTableSetting: true,
bordered: true, bordered: true,
canResize: true, canResize: true,
actionColumn: {
width: 50,
title: '操作',
dataIndex: 'action',
fixed: 'right',
},
resizeHeightOffset: 45, resizeHeightOffset: 45,
tableComponent: 'vxe', tableComponent: 'vxe',
id: '0', id: '0',
@ -100,18 +84,24 @@
isUpdate: true, isUpdate: true,
}) })
} }
// function handleDelete() {
async function handleDelete(record) { const select = getVxeSelectRows()
const res = await BatchDelUser({ let ApiData: any = {
id: '', ids: [],
ids: [record.id], }
}) if (select.length === 0) {
if (res.succeeded) { createMessage.warning('请至少选择一条数据')
createMessage.success(res.message) return false
reload()
} else { } else {
createMessage.warning(res.message) ApiData.ids = select.map((item) => {
return item.id
})
} }
BatchDelUser(ApiData).then((res) => {
createMessage.success(res.message)
reload()
})
} }
onMounted(() => { onMounted(() => {
// //

Loading…
Cancel
Save