表格按钮组组件

frame
lijingjia 21 hours 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 { 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[] = [
{
title: '权限模板类型',
dataIndex: 'templateName',
width: 200,
align: 'left'
},
{
title: '权限模板范围',
dataIndex: 'ruleScopeName',
width: 200,
align: 'left'
},
{
title: '资源标识',
dataIndex: 'permissionEntity',
width: 200,
align: 'left'
},
{
title: '中文视图名',
dataIndex: 'columnView',
width: 200,
align: 'left'
},
{
title: '排序号',
dataIndex: 'orderNo',
width: 50,
width: 80,
align: 'left'
},
{
title: '可视/可操作',
dataIndex: 'ruleType',
width: 120,
customRender: ({ text }) => {
if (text === 'visible') {
return '可视'
} else if (text === 'operate') {
return '可操作'
}
return text
},
align: 'left'
},
{
title: '是否启用',
dataIndex: 'status',
width: 80,
customRender: ({ text }) => {
if (text === 0) {
return <Tag color="success"></Tag>
} else if (text === 1) {
return <Tag color="error"></Tag>
}
return text
},
width: 90,
align: 'left'
},
{
title: '权限描述',
dataIndex: 'description',
width: 200,
},
// {
// title: '备注??',
// dataIndex: 'note',
// width: 200,
// },
align: 'left'
}
]
export const searchFormSchema: FormSchema[] = [

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

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

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

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

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

Loading…
Cancel
Save