fix: edit button permission issue
This commit is contained in:
parent
6f0f34a33c
commit
c0df1d704a
|
@ -1637,7 +1637,7 @@ declare namespace API {
|
|||
/** 产品名称 */
|
||||
name?: string;
|
||||
/** 产品规格 */
|
||||
productSpecification: string;
|
||||
productSpecification?: string;
|
||||
/** 所属公司 */
|
||||
companyId?: number;
|
||||
/** 单位 */
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<template #toolbar>
|
||||
<a-button
|
||||
type="primary"
|
||||
:disabled="!$auth('system:role:create')"
|
||||
:disabled="!$auth('app:company:create')"
|
||||
@click="openEditModal({})"
|
||||
>
|
||||
新增
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
<template>
|
||||
<div v-if="columns?.length">
|
||||
<DynamicTable
|
||||
row-key="id"
|
||||
<DynamicTable row-key="id"
|
||||
header-title="产品管理"
|
||||
title-tooltip=""
|
||||
:data-request="Api.product.productList"
|
||||
:columns="columns"
|
||||
:exportFileName="'产品'"
|
||||
bordered
|
||||
size="small"
|
||||
>
|
||||
size="small">
|
||||
<template #toolbar>
|
||||
<a-button
|
||||
type="primary"
|
||||
:disabled="!$auth('system:role:create')"
|
||||
@click="openEditModal({})"
|
||||
>
|
||||
<a-button type="primary"
|
||||
:disabled="!$auth('app:product:create')"
|
||||
@click="openEditModal({})">
|
||||
新增
|
||||
</a-button>
|
||||
</template>
|
||||
|
@ -24,25 +20,25 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { useTable, type LoadDataParams, type TableColumn } from '@/components/core/dynamic-table';
|
||||
import { baseColumns, type TableColumnItem, type TableListItem } from './columns';
|
||||
import Api from '@/api/';
|
||||
import { useFormModal, useModal } from '@/hooks/useModal';
|
||||
import { formSchemas } from './formSchemas';
|
||||
import { Button } from 'ant-design-vue';
|
||||
import AttachmentManage from '@/components/business/attachment-manage/index.vue';
|
||||
import AttachmentUpload from '@/components/business/attachment-upload/index.vue';
|
||||
import { ref, onMounted, type FunctionalComponent } from 'vue';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
defineOptions({
|
||||
import { useTable, type LoadDataParams, type TableColumn } from '@/components/core/dynamic-table';
|
||||
import { baseColumns, type TableColumnItem, type TableListItem } from './columns';
|
||||
import Api from '@/api/';
|
||||
import { useFormModal, useModal } from '@/hooks/useModal';
|
||||
import { formSchemas } from './formSchemas';
|
||||
import { Button } from 'ant-design-vue';
|
||||
import AttachmentManage from '@/components/business/attachment-manage/index.vue';
|
||||
import AttachmentUpload from '@/components/business/attachment-upload/index.vue';
|
||||
import { ref, onMounted, type FunctionalComponent } from 'vue';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
defineOptions({
|
||||
name: 'Product',
|
||||
});
|
||||
const [DynamicTable, dynamicTableInstance] = useTable({ formProps: { autoSubmitOnEnter: true } });
|
||||
const [showModal] = useFormModal();
|
||||
const [fnModal] = useModal();
|
||||
const isUploadPopupVisiable = ref(false);
|
||||
let columns = ref<TableColumnItem[]>();
|
||||
onMounted(() => {
|
||||
});
|
||||
const [DynamicTable, dynamicTableInstance] = useTable({ formProps: { autoSubmitOnEnter: true } });
|
||||
const [showModal] = useFormModal();
|
||||
const [fnModal] = useModal();
|
||||
const isUploadPopupVisiable = ref(false);
|
||||
let columns = ref<TableColumnItem[]>();
|
||||
onMounted(() => {
|
||||
columns.value = [
|
||||
...baseColumns,
|
||||
{
|
||||
|
@ -91,9 +87,9 @@
|
|||
],
|
||||
},
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
const openAttachmentUploadModal = async (record: TableListItem) => {
|
||||
const openAttachmentUploadModal = async (record: TableListItem) => {
|
||||
isUploadPopupVisiable.value = true;
|
||||
fnModal.show({
|
||||
width: 800,
|
||||
|
@ -114,23 +110,23 @@
|
|||
open: isUploadPopupVisiable.value,
|
||||
footer: null,
|
||||
});
|
||||
};
|
||||
const handleUploadClose = (hasSuccess: boolean) => {
|
||||
};
|
||||
const handleUploadClose = (hasSuccess: boolean) => {
|
||||
fnModal.hide();
|
||||
isUploadPopupVisiable.value = false;
|
||||
};
|
||||
const afterUploadCallback = async (
|
||||
};
|
||||
const afterUploadCallback = async (
|
||||
files: { filename: { path: string; id: number } }[],
|
||||
id: number,
|
||||
) => {
|
||||
) => {
|
||||
await Api.product.productUpdate({ id }, { fileIds: files.map((item) => item.filename.id) });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @description 打开新增/编辑弹窗
|
||||
*/
|
||||
const openEditModal = async (record: Partial<TableListItem>) => {
|
||||
const openEditModal = async (record: Partial<TableListItem>) => {
|
||||
const [formRef] = await showModal({
|
||||
modalProps: {
|
||||
title: `${record.id ? '编辑' : '新增'}产品`,
|
||||
|
@ -157,13 +153,13 @@
|
|||
...info,
|
||||
});
|
||||
}
|
||||
};
|
||||
const delRowConfirm = async (record) => {
|
||||
};
|
||||
const delRowConfirm = async (record) => {
|
||||
await Api.product.productDelete({ id: record });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
};
|
||||
|
||||
const FilesRender: FunctionalComponent<TableListItem> = (product: TableListItem) => {
|
||||
const FilesRender: FunctionalComponent<TableListItem> = (product: TableListItem) => {
|
||||
const [fnModal] = useModal();
|
||||
return (
|
||||
<Button
|
||||
|
@ -175,9 +171,9 @@
|
|||
{product.files?.length || 0}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const openFilesManageModal = (fnModal, product: TableListItem) => {
|
||||
const openFilesManageModal = (fnModal, product: TableListItem) => {
|
||||
const fileIds = product.files?.map((item) => item.id) || [];
|
||||
fnModal.show({
|
||||
width: 1200,
|
||||
|
@ -193,11 +189,11 @@
|
|||
destroyOnClose: true,
|
||||
footer: null,
|
||||
});
|
||||
};
|
||||
const unlinkAttachments = async (id: number, unlinkIds: number[]) => {
|
||||
};
|
||||
const unlinkAttachments = async (id: number, unlinkIds: number[]) => {
|
||||
await Api.product.unlinkAttachments({ id }, { fileIds: unlinkIds });
|
||||
dynamicTableInstance?.reload();
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<template #toolbar>
|
||||
<a-button
|
||||
type="primary"
|
||||
:disabled="!$auth('system:role:create')"
|
||||
:disabled="!$auth('app:project:create')"
|
||||
@click="openEditModal({})"
|
||||
>
|
||||
新增
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
if (!isJpgOrPng) {
|
||||
message.error('You can only upload JPG/PNG file!');
|
||||
}
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
const isLt2M = file.size / 1024 / 1024 < 30;
|
||||
if (!isLt2M) {
|
||||
message.error('Image must smaller than 2MB!');
|
||||
message.error('Image must smaller than 30MB!');
|
||||
}
|
||||
|
||||
return isJpgOrPng && isLt2M;
|
||||
|
|
Loading…
Reference in New Issue