diff --git a/src/components/Detail/src/Detail.vue b/src/components/Detail/src/Detail.vue index d88b999..45da9ea 100644 --- a/src/components/Detail/src/Detail.vue +++ b/src/components/Detail/src/Detail.vue @@ -117,6 +117,7 @@ :apiCreate="apiCreate" :fromeWhere="fromeWhere" :isDetail="true" + @onChange="onChange" @searchTableSuccess="searchTableSuccess" :detailData="detailData" @submitForm="submitForm" @@ -135,7 +136,6 @@ import BasicForm from '@/components/BasicForm/src/BasicForm.vue' import TableHead from '@/components/TableHead/src/TableHead.vue' import DetailTable from '@/components/DetailTable/src/DetailTable.vue' import { isString } from '@/utils/is' -import { Console } from 'console' defineOptions({ name: 'Detail' }) @@ -277,6 +277,12 @@ const props = defineProps({ required: false, default: true }, + // 表格按钮权限控制 + buttonControllFunction: { + type: Function, + required: false, + default: undefined + }, }) const isShowDrawer = ref(false) const detailLoading = ref(false) @@ -350,7 +356,7 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName: let detailButtonAdd: any = [] detailButtonAdd = props.isShowAddBtn?[ defaultButtons.defaultAddBtn({ - hide: isShowMainButton(row, ['1']) + hide: !isShowMainButton(row, 'add') }) ]:[] HeadButttondata.value = [...detailButtonAdd] @@ -359,10 +365,10 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName: buttondata.value = [ ...[ defaultButtons.mainListEditBtn({ - hide: isShowMainButton(row, ['1']) + hide: !isShowMainButton(row, 'edit') }), // 编辑 defaultButtons.mainListDeleteBtn({ - hide: isShowMainButton(row, ['1']) + hide: !isShowMainButton(row, 'delete') }) ], // 删除 ...props.buttondataTable @@ -404,7 +410,12 @@ detailAllSchemasRef.value = props.detailAllSchemas // 根据状态返回该按钮是否显示 const isShowMainButton = (row, val) => { - return false + if (props.buttonControllFunction != undefined) { + return props.buttonControllFunction(row, val) + } else { + return true + } + } // 获得表格的各种操作 @@ -504,7 +515,8 @@ const emit = defineEmits([ 'detailOpenForm', 'tableFormButton', 'openImage', - 'detailSubmitForm' + 'detailSubmitForm', + 'detailOnChange' ]) /** 删除按钮操作 */ const handleDelete = async (id: number) => { @@ -576,6 +588,11 @@ watch( getList() } ) + +function onChange(field, cur, item) { + emit('detailOnChange', field, cur, item) +} +