123 lines
3.2 KiB
Vue
123 lines
3.2 KiB
Vue
<template>
|
|
<div v-if="columns?.length">
|
|
<DynamicTable row-key="id"
|
|
header-title="分组管理"
|
|
title-tooltip=""
|
|
:data-request="Api.saleQuotationGroup.saleQuotationGroupList"
|
|
:columns="columns"
|
|
bordered
|
|
size="small">
|
|
<template #toolbar>
|
|
<a-button type="primary"
|
|
:disabled="!$auth('sale_quotation:sale_quotation_group:create')"
|
|
@click="openEditModal({})">
|
|
新增
|
|
</a-button>
|
|
</template>
|
|
</DynamicTable>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="tsx">
|
|
import { useTable } 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 { ref, onMounted } from 'vue';
|
|
defineOptions({
|
|
name: 'SaleQuotationGroup',
|
|
});
|
|
const [DynamicTable, dynamicTableInstance] = useTable({ formProps: { autoSubmitOnEnter: true } });
|
|
const [showModal] = useFormModal();
|
|
|
|
// saleQuotationGroupList;
|
|
let columns = ref<TableColumnItem[]>();
|
|
onMounted(() => {
|
|
columns.value = [
|
|
...baseColumns,
|
|
{
|
|
title: '操作',
|
|
maxWidth: 150,
|
|
width: 150,
|
|
minWidth: 150,
|
|
fixed: 'right',
|
|
dataIndex: 'ACTION',
|
|
hideInSearch: true,
|
|
actions: ({ record }) => [
|
|
// {
|
|
// icon: 'ant-design:plus-outlined',
|
|
// tooltip: '添加配件',
|
|
// onClick: () => openEditModal(record),
|
|
// },
|
|
{
|
|
icon: 'ant-design:edit-outlined',
|
|
tooltip: '编辑',
|
|
auth: {
|
|
perm: 'sale_quotation:sale_quotation_group:update',
|
|
effect: 'disable',
|
|
},
|
|
onClick: () => openEditModal(record),
|
|
},
|
|
{
|
|
icon: 'ant-design:delete-outlined',
|
|
color: 'red',
|
|
tooltip: '删除此分组',
|
|
auth: 'sale_quotation:sale_quotation_group:delete',
|
|
popConfirm: {
|
|
title: '你确定要删除吗?',
|
|
placement: 'left',
|
|
onConfirm: () => delRowConfirm(record.id),
|
|
},
|
|
},
|
|
|
|
],
|
|
},
|
|
];
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
* @description 打开新增/编辑弹窗
|
|
*/
|
|
const openEditModal = async (record: Partial<TableListItem>) => {
|
|
const [formRef] = await showModal({
|
|
modalProps: {
|
|
title: `${record.id ? '编辑' : '新增'}分组`,
|
|
width: '50%',
|
|
onFinish: async (values) => {
|
|
if (record.id) {
|
|
await Api.saleQuotationGroup.saleQuotationGroupUpdate({ id: record.id }, values);
|
|
} else {
|
|
await Api.saleQuotationGroup.saleQuotationGroupCreate(values);
|
|
}
|
|
dynamicTableInstance?.reload();
|
|
},
|
|
},
|
|
formProps: {
|
|
labelWidth: 100,
|
|
schemas: formSchemas,
|
|
},
|
|
});
|
|
|
|
// 如果是编辑的话,需要获取角色详情
|
|
if (record.id) {
|
|
const info = await Api.saleQuotationGroup.saleQuotationGroupInfo({ id: record.id });
|
|
formRef?.setFieldsValue({
|
|
...info,
|
|
});
|
|
}
|
|
};
|
|
const delRowConfirm = async (record) => {
|
|
await Api.saleQuotationGroup.saleQuotationGroupDelete({ id: record });
|
|
dynamicTableInstance?.reload();
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
<style lang="less" scoped></style>
|