review:同步 vue5 官方的差异
parent
0f0ae5de48
commit
4062bb03fb
|
|
@ -21,8 +21,7 @@
|
||||||
// CSS 变量提示
|
// CSS 变量提示
|
||||||
"vunguyentuan.vscode-css-variables",
|
"vunguyentuan.vscode-css-variables",
|
||||||
// 在 package.json 中显示 PNPM catalog 的版本
|
// 在 package.json 中显示 PNPM catalog 的版本
|
||||||
"antfu.pnpm-catalog-lens",
|
"antfu.pnpm-catalog-lens"
|
||||||
"augment.vscode-augment"
|
|
||||||
],
|
],
|
||||||
"unwantedRecommendations": [
|
"unwantedRecommendations": [
|
||||||
// 和 volar 冲突
|
// 和 volar 冲突
|
||||||
|
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
import type { PageParam, PageResult } from '@vben/request';
|
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
|
||||||
|
|
||||||
export namespace ProductUnitApi {
|
|
||||||
/** 产品单位信息 */
|
|
||||||
export interface ProductUnit {
|
|
||||||
id: number; // 编号
|
|
||||||
groupId?: number; // 分组编号
|
|
||||||
name?: string; // 单位名称
|
|
||||||
basic?: number; // 基础单位
|
|
||||||
number?: number; // 单位数量/相对于基础单位
|
|
||||||
usageType: number; // 用途
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询产品单位分页 */
|
|
||||||
export function getProductUnitPage(params: PageParam) {
|
|
||||||
return requestClient.get<PageResult<ProductUnitApi.ProductUnit>>(
|
|
||||||
'/basic/product-unit/page',
|
|
||||||
{ params },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询产品单位详情 */
|
|
||||||
export function getProductUnit(id: number) {
|
|
||||||
return requestClient.get<ProductUnitApi.ProductUnit>(
|
|
||||||
`/basic/product-unit/get?id=${id}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 新增产品单位 */
|
|
||||||
export function createProductUnit(data: ProductUnitApi.ProductUnit) {
|
|
||||||
return requestClient.post('/basic/product-unit/create', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 修改产品单位 */
|
|
||||||
export function updateProductUnit(data: ProductUnitApi.ProductUnit) {
|
|
||||||
return requestClient.put('/basic/product-unit/update', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除产品单位 */
|
|
||||||
export function deleteProductUnit(id: number) {
|
|
||||||
return requestClient.delete(`/basic/product-unit/delete?id=${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量删除产品单位 */
|
|
||||||
export function deleteProductUnitListByIds(ids: number[]) {
|
|
||||||
return requestClient.delete(
|
|
||||||
`/basic/product-unit/delete-list?ids=${ids.join(',')}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出产品单位 */
|
|
||||||
export function exportProductUnit(params: any) {
|
|
||||||
return requestClient.download('/basic/product-unit/export-excel', { params });
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
import type { PageParam, PageResult } from '@vben/request';
|
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
|
||||||
|
|
||||||
export namespace ProductUnitGroupApi {
|
|
||||||
/** 产品单位组信息 */
|
|
||||||
export interface ProductUnitGroup {
|
|
||||||
id: number; // 编号
|
|
||||||
name?: string; // 产品单位组名称
|
|
||||||
status?: number; // 开启状态
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询产品单位组分页 */
|
|
||||||
export function getProductUnitGroupPage(params: PageParam) {
|
|
||||||
return requestClient.get<PageResult<ProductUnitGroupApi.ProductUnitGroup>>(
|
|
||||||
'/basic/product-unit-group/page',
|
|
||||||
{ params },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询产品单位组详情 */
|
|
||||||
export function getProductUnitGroup(id: number) {
|
|
||||||
return requestClient.get<ProductUnitGroupApi.ProductUnitGroup>(
|
|
||||||
`/basic/product-unit-group/get?id=${id}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 新增产品单位组 */
|
|
||||||
export function createProductUnitGroup(
|
|
||||||
data: ProductUnitGroupApi.ProductUnitGroup,
|
|
||||||
) {
|
|
||||||
return requestClient.post('/basic/product-unit-group/create', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 修改产品单位组 */
|
|
||||||
export function updateProductUnitGroup(
|
|
||||||
data: ProductUnitGroupApi.ProductUnitGroup,
|
|
||||||
) {
|
|
||||||
return requestClient.put('/basic/product-unit-group/update', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除产品单位组 */
|
|
||||||
export function deleteProductUnitGroup(id: number) {
|
|
||||||
return requestClient.delete(`/basic/product-unit-group/delete?id=${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量删除产品单位组 */
|
|
||||||
export function deleteProductUnitGroupListByIds(ids: number[]) {
|
|
||||||
return requestClient.delete(
|
|
||||||
`/basic/product-unit-group/delete-list?ids=${ids.join(',')}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出产品单位组 */
|
|
||||||
export function exportProductUnitGroup(params: any) {
|
|
||||||
return requestClient.download(
|
|
||||||
'/basic/product-unit-group/export-excel',
|
|
||||||
params,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
// OA请假相关路由配置
|
// OA 请假相关路由配置
|
||||||
const routes: RouteRecordRaw[] = [
|
const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
path: '/bpm/oa',
|
path: '/bpm/oa',
|
||||||
|
|
|
||||||
|
|
@ -1,174 +0,0 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|
||||||
import type { ProductUnitApi } from '#/api/basic/productunit';
|
|
||||||
|
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
fieldName: 'id',
|
|
||||||
component: 'Input',
|
|
||||||
dependencies: {
|
|
||||||
triggerFields: [''],
|
|
||||||
show: () => false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'groupId',
|
|
||||||
label: '分组编号',
|
|
||||||
rules: 'required',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
placeholder: '请输入分组编号',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'name',
|
|
||||||
label: '单位名称',
|
|
||||||
rules: 'required',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
placeholder: '请输入单位名称',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'basic',
|
|
||||||
label: '基础单位',
|
|
||||||
rules: 'required',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
placeholder: '请输入基础单位',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'number',
|
|
||||||
label: '单位数量/相对于基础单位',
|
|
||||||
rules: 'required',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
placeholder: '请输入单位数量/相对于基础单位',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'usageType',
|
|
||||||
label: '用途',
|
|
||||||
component: 'Select',
|
|
||||||
componentProps: {
|
|
||||||
options: [],
|
|
||||||
placeholder: '请选择用途',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
fieldName: 'groupId',
|
|
||||||
label: '分组编号',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请输入分组编号',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'name',
|
|
||||||
label: '单位名称',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请输入单位名称',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'basic',
|
|
||||||
label: '基础单位',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请输入基础单位',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'number',
|
|
||||||
label: '单位数量/相对于基础单位',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请输入单位数量/相对于基础单位',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'usageType',
|
|
||||||
label: '用途',
|
|
||||||
component: 'Select',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
options: [],
|
|
||||||
placeholder: '请选择用途',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'createTime',
|
|
||||||
label: '创建时间',
|
|
||||||
component: 'RangePicker',
|
|
||||||
componentProps: {
|
|
||||||
...getRangePickerDefaultProps(),
|
|
||||||
allowClear: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 列表的字段 */
|
|
||||||
export function useGridColumns(): VxeTableGridOptions<ProductUnitApi.ProductUnit>['columns'] {
|
|
||||||
return [
|
|
||||||
{ type: 'checkbox', width: 40 },
|
|
||||||
{
|
|
||||||
field: 'id',
|
|
||||||
title: '编号',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'groupId',
|
|
||||||
title: '分组编号',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'name',
|
|
||||||
title: '单位名称',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'basic',
|
|
||||||
title: '基础单位',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'number',
|
|
||||||
title: '单位数量/相对于基础单位',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'usageType',
|
|
||||||
title: '用途',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'createTime',
|
|
||||||
title: '创建时间',
|
|
||||||
minWidth: 120,
|
|
||||||
formatter: 'formatDateTime',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '操作',
|
|
||||||
width: 200,
|
|
||||||
fixed: 'right',
|
|
||||||
slots: { default: 'actions' },
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,188 +0,0 @@
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|
||||||
import type { ProductUnitApi } from '#/api/basic/productunit';
|
|
||||||
|
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
|
||||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
||||||
import {
|
|
||||||
deleteProductUnit,
|
|
||||||
deleteProductUnitListByIds,
|
|
||||||
exportProductUnit,
|
|
||||||
getProductUnitPage,
|
|
||||||
} from '#/api/basic/productunit';
|
|
||||||
import { $t } from '#/locales';
|
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
|
||||||
import Form from './modules/form.vue';
|
|
||||||
|
|
||||||
const [FormModal, formModalApi] = useVbenModal({
|
|
||||||
connectedComponent: Form,
|
|
||||||
destroyOnClose: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 刷新表格 */
|
|
||||||
function onRefresh() {
|
|
||||||
gridApi.query();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 创建产品单位 */
|
|
||||||
function handleCreate() {
|
|
||||||
formModalApi.setData({}).open();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 编辑产品单位 */
|
|
||||||
function handleEdit(row: ProductUnitApi.ProductUnit) {
|
|
||||||
formModalApi.setData(row).open();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除产品单位 */
|
|
||||||
async function handleDelete(row: ProductUnitApi.ProductUnit) {
|
|
||||||
const hideLoading = message.loading({
|
|
||||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await deleteProductUnit(row.id as number);
|
|
||||||
message.success({
|
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
onRefresh();
|
|
||||||
} finally {
|
|
||||||
hideLoading();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量删除产品单位 */
|
|
||||||
async function handleDeleteBatch() {
|
|
||||||
const hideLoading = message.loading({
|
|
||||||
content: $t('ui.actionMessage.deleting'),
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await deleteProductUnitListByIds(deleteIds.value);
|
|
||||||
message.success({
|
|
||||||
content: $t('ui.actionMessage.deleteSuccess'),
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
onRefresh();
|
|
||||||
} finally {
|
|
||||||
hideLoading();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteIds = ref<number[]>([]); // 待删除产品单位 ID
|
|
||||||
function setDeleteIds({ records }: { records: ProductUnitApi.ProductUnit[] }) {
|
|
||||||
deleteIds.value = records.map((item) => item.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出表格 */
|
|
||||||
async function handleExport() {
|
|
||||||
const data = await exportProductUnit(await gridApi.formApi.getValues());
|
|
||||||
downloadFileFromBlobPart({ fileName: '产品单位.xls', source: data });
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
|
||||||
formOptions: {
|
|
||||||
schema: useGridFormSchema(),
|
|
||||||
},
|
|
||||||
gridOptions: {
|
|
||||||
columns: useGridColumns(),
|
|
||||||
height: 'auto',
|
|
||||||
pagerConfig: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
proxyConfig: {
|
|
||||||
ajax: {
|
|
||||||
query: async ({ page }, formValues) => {
|
|
||||||
return await getProductUnitPage({
|
|
||||||
pageNo: page.currentPage,
|
|
||||||
pageSize: page.pageSize,
|
|
||||||
...formValues,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rowConfig: {
|
|
||||||
keyField: 'id',
|
|
||||||
isHover: true,
|
|
||||||
},
|
|
||||||
toolbarConfig: {
|
|
||||||
refresh: true,
|
|
||||||
search: true,
|
|
||||||
},
|
|
||||||
} as VxeTableGridOptions<ProductUnitApi.ProductUnit>,
|
|
||||||
gridEvents: {
|
|
||||||
checkboxAll: setDeleteIds,
|
|
||||||
checkboxChange: setDeleteIds,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Page auto-content-height>
|
|
||||||
<FormModal @success="onRefresh" />
|
|
||||||
|
|
||||||
<Grid table-title="产品单位列表">
|
|
||||||
<template #toolbar-tools>
|
|
||||||
<TableAction
|
|
||||||
:actions="[
|
|
||||||
{
|
|
||||||
label: $t('ui.actionTitle.create', ['产品单位']),
|
|
||||||
type: 'primary',
|
|
||||||
icon: ACTION_ICON.ADD,
|
|
||||||
auth: ['basic:product-unit:create'],
|
|
||||||
onClick: handleCreate,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('ui.actionTitle.export'),
|
|
||||||
type: 'primary',
|
|
||||||
icon: ACTION_ICON.DOWNLOAD,
|
|
||||||
auth: ['basic:product-unit:export'],
|
|
||||||
onClick: handleExport,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('ui.actionTitle.deleteBatch'),
|
|
||||||
type: 'primary',
|
|
||||||
danger: true,
|
|
||||||
icon: ACTION_ICON.DELETE,
|
|
||||||
disabled: isEmpty(deleteIds),
|
|
||||||
auth: ['basic:product-unit:delete'],
|
|
||||||
onClick: handleDeleteBatch,
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #actions="{ row }">
|
|
||||||
<TableAction
|
|
||||||
:actions="[
|
|
||||||
{
|
|
||||||
label: $t('common.edit'),
|
|
||||||
type: 'link',
|
|
||||||
icon: ACTION_ICON.EDIT,
|
|
||||||
auth: ['basic:product-unit:update'],
|
|
||||||
onClick: handleEdit.bind(null, row),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('common.delete'),
|
|
||||||
type: 'link',
|
|
||||||
danger: true,
|
|
||||||
icon: ACTION_ICON.DELETE,
|
|
||||||
auth: ['basic:product-unit:delete'],
|
|
||||||
popConfirm: {
|
|
||||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
|
||||||
confirm: handleDelete.bind(null, row),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</Grid>
|
|
||||||
</Page>
|
|
||||||
</template>
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { ProductUnitApi } from '#/api/basic/productunit';
|
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
|
||||||
import {
|
|
||||||
createProductUnit,
|
|
||||||
getProductUnit,
|
|
||||||
updateProductUnit,
|
|
||||||
} from '#/api/basic/productunit';
|
|
||||||
import { $t } from '#/locales';
|
|
||||||
|
|
||||||
import { useFormSchema } from '../data';
|
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
|
||||||
const formData = ref<ProductUnitApi.ProductUnit>();
|
|
||||||
const getTitle = computed(() => {
|
|
||||||
return formData.value?.id
|
|
||||||
? $t('ui.actionTitle.edit', ['产品单位'])
|
|
||||||
: $t('ui.actionTitle.create', ['产品单位']);
|
|
||||||
});
|
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
|
||||||
commonConfig: {
|
|
||||||
componentProps: {
|
|
||||||
class: 'w-full',
|
|
||||||
},
|
|
||||||
formItemClass: 'col-span-2',
|
|
||||||
labelWidth: 80,
|
|
||||||
},
|
|
||||||
layout: 'horizontal',
|
|
||||||
schema: useFormSchema(),
|
|
||||||
showDefaultActions: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
|
||||||
async onConfirm() {
|
|
||||||
const { valid } = await formApi.validate();
|
|
||||||
if (!valid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
modalApi.lock();
|
|
||||||
// 提交表单
|
|
||||||
const data = (await formApi.getValues()) as ProductUnitApi.ProductUnit;
|
|
||||||
try {
|
|
||||||
await (formData.value?.id
|
|
||||||
? updateProductUnit(data)
|
|
||||||
: createProductUnit(data));
|
|
||||||
// 关闭并提示
|
|
||||||
await modalApi.close();
|
|
||||||
emit('success');
|
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
|
||||||
} finally {
|
|
||||||
modalApi.unlock();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async onOpenChange(isOpen: boolean) {
|
|
||||||
if (!isOpen) {
|
|
||||||
formData.value = undefined;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 加载数据
|
|
||||||
let data = modalApi.getData<ProductUnitApi.ProductUnit>();
|
|
||||||
if (!data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.id) {
|
|
||||||
modalApi.lock();
|
|
||||||
try {
|
|
||||||
data = await getProductUnit(data.id);
|
|
||||||
} finally {
|
|
||||||
modalApi.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 设置到 values
|
|
||||||
formData.value = data;
|
|
||||||
await formApi.setValues(formData.value);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Modal :title="getTitle">
|
|
||||||
<Form class="mx-4" />
|
|
||||||
</Modal>
|
|
||||||
</template>
|
|
||||||
|
|
@ -1,108 +0,0 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|
||||||
import type { ProductUnitGroupApi } from '#/api/basic/productunitgroup';
|
|
||||||
|
|
||||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
fieldName: 'id',
|
|
||||||
component: 'Input',
|
|
||||||
dependencies: {
|
|
||||||
triggerFields: [''],
|
|
||||||
show: () => false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'name',
|
|
||||||
label: '产品单位组名称',
|
|
||||||
rules: 'required',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
placeholder: '请输入产品单位组名称',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'status',
|
|
||||||
label: '开启状态',
|
|
||||||
rules: 'required',
|
|
||||||
component: 'RadioGroup',
|
|
||||||
componentProps: {
|
|
||||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
|
||||||
buttonStyle: 'solid',
|
|
||||||
optionType: 'button',
|
|
||||||
},
|
|
||||||
defaultValue: 0,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
fieldName: 'name',
|
|
||||||
label: '产品单位组名称',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请输入产品单位组名称',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'status',
|
|
||||||
label: '开启状态',
|
|
||||||
component: 'Select',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
options: [],
|
|
||||||
placeholder: '请选择开启状态',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'createTime',
|
|
||||||
label: '创建时间',
|
|
||||||
component: 'RangePicker',
|
|
||||||
componentProps: {
|
|
||||||
...getRangePickerDefaultProps(),
|
|
||||||
allowClear: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 列表的字段 */
|
|
||||||
export function useGridColumns(): VxeTableGridOptions<ProductUnitGroupApi.ProductUnitGroup>['columns'] {
|
|
||||||
return [
|
|
||||||
{ type: 'checkbox', width: 40 },
|
|
||||||
{
|
|
||||||
field: 'id',
|
|
||||||
title: '编号',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'name',
|
|
||||||
title: '产品单位组名称',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'status',
|
|
||||||
title: '开启状态',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'createTime',
|
|
||||||
title: '创建时间',
|
|
||||||
minWidth: 120,
|
|
||||||
formatter: 'formatDateTime',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '操作',
|
|
||||||
width: 200,
|
|
||||||
fixed: 'right',
|
|
||||||
slots: { default: 'actions' },
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,192 +0,0 @@
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|
||||||
import type { ProductUnitGroupApi } from '#/api/basic/productunitgroup';
|
|
||||||
|
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
|
||||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
||||||
import {
|
|
||||||
deleteProductUnitGroup,
|
|
||||||
deleteProductUnitGroupListByIds,
|
|
||||||
exportProductUnitGroup,
|
|
||||||
getProductUnitGroupPage,
|
|
||||||
} from '#/api/basic/productunitgroup';
|
|
||||||
import { $t } from '#/locales';
|
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
|
||||||
import Form from './modules/form.vue';
|
|
||||||
|
|
||||||
const [FormModal, formModalApi] = useVbenModal({
|
|
||||||
connectedComponent: Form,
|
|
||||||
destroyOnClose: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 刷新表格 */
|
|
||||||
function onRefresh() {
|
|
||||||
gridApi.query();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 创建产品单位组 */
|
|
||||||
function handleCreate() {
|
|
||||||
formModalApi.setData({}).open();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 编辑产品单位组 */
|
|
||||||
function handleEdit(row: ProductUnitGroupApi.ProductUnitGroup) {
|
|
||||||
formModalApi.setData(row).open();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除产品单位组 */
|
|
||||||
async function handleDelete(row: ProductUnitGroupApi.ProductUnitGroup) {
|
|
||||||
const hideLoading = message.loading({
|
|
||||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await deleteProductUnitGroup(row.id as number);
|
|
||||||
message.success({
|
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
onRefresh();
|
|
||||||
} finally {
|
|
||||||
hideLoading();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量删除产品单位组 */
|
|
||||||
async function handleDeleteBatch() {
|
|
||||||
const hideLoading = message.loading({
|
|
||||||
content: $t('ui.actionMessage.deleting'),
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await deleteProductUnitGroupListByIds(deleteIds.value);
|
|
||||||
message.success({
|
|
||||||
content: $t('ui.actionMessage.deleteSuccess'),
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
onRefresh();
|
|
||||||
} finally {
|
|
||||||
hideLoading();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteIds = ref<number[]>([]); // 待删除产品单位组 ID
|
|
||||||
function setDeleteIds({
|
|
||||||
records,
|
|
||||||
}: {
|
|
||||||
records: ProductUnitGroupApi.ProductUnitGroup[];
|
|
||||||
}) {
|
|
||||||
deleteIds.value = records.map((item) => item.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出表格 */
|
|
||||||
async function handleExport() {
|
|
||||||
const data = await exportProductUnitGroup(await gridApi.formApi.getValues());
|
|
||||||
downloadFileFromBlobPart({ fileName: '产品单位组.xls', source: data });
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
|
||||||
formOptions: {
|
|
||||||
schema: useGridFormSchema(),
|
|
||||||
},
|
|
||||||
gridOptions: {
|
|
||||||
columns: useGridColumns(),
|
|
||||||
height: 'auto',
|
|
||||||
pagerConfig: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
proxyConfig: {
|
|
||||||
ajax: {
|
|
||||||
query: async ({ page }, formValues) => {
|
|
||||||
return await getProductUnitGroupPage({
|
|
||||||
pageNo: page.currentPage,
|
|
||||||
pageSize: page.pageSize,
|
|
||||||
...formValues,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rowConfig: {
|
|
||||||
keyField: 'id',
|
|
||||||
isHover: true,
|
|
||||||
},
|
|
||||||
toolbarConfig: {
|
|
||||||
refresh: true,
|
|
||||||
search: true,
|
|
||||||
},
|
|
||||||
} as VxeTableGridOptions<ProductUnitGroupApi.ProductUnitGroup>,
|
|
||||||
gridEvents: {
|
|
||||||
checkboxAll: setDeleteIds,
|
|
||||||
checkboxChange: setDeleteIds,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Page auto-content-height>
|
|
||||||
<FormModal @success="onRefresh" />
|
|
||||||
|
|
||||||
<Grid table-title="产品单位组列表">
|
|
||||||
<template #toolbar-tools>
|
|
||||||
<TableAction
|
|
||||||
:actions="[
|
|
||||||
{
|
|
||||||
label: $t('ui.actionTitle.create', ['产品单位组']),
|
|
||||||
type: 'primary',
|
|
||||||
icon: ACTION_ICON.ADD,
|
|
||||||
auth: ['basic:product-unit-group:create'],
|
|
||||||
onClick: handleCreate,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('ui.actionTitle.export'),
|
|
||||||
type: 'primary',
|
|
||||||
icon: ACTION_ICON.DOWNLOAD,
|
|
||||||
auth: ['basic:product-unit-group:export'],
|
|
||||||
onClick: handleExport,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('ui.actionTitle.deleteBatch'),
|
|
||||||
type: 'primary',
|
|
||||||
danger: true,
|
|
||||||
icon: ACTION_ICON.DELETE,
|
|
||||||
disabled: isEmpty(deleteIds),
|
|
||||||
auth: ['basic:product-unit-group:delete'],
|
|
||||||
onClick: handleDeleteBatch,
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #actions="{ row }">
|
|
||||||
<TableAction
|
|
||||||
:actions="[
|
|
||||||
{
|
|
||||||
label: $t('common.edit'),
|
|
||||||
type: 'link',
|
|
||||||
icon: ACTION_ICON.EDIT,
|
|
||||||
auth: ['basic:product-unit-group:update'],
|
|
||||||
onClick: handleEdit.bind(null, row),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('common.delete'),
|
|
||||||
type: 'link',
|
|
||||||
danger: true,
|
|
||||||
icon: ACTION_ICON.DELETE,
|
|
||||||
auth: ['basic:product-unit-group:delete'],
|
|
||||||
popConfirm: {
|
|
||||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
|
||||||
confirm: handleDelete.bind(null, row),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</Grid>
|
|
||||||
</Page>
|
|
||||||
</template>
|
|
||||||
|
|
@ -1,92 +0,0 @@
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { ProductUnitGroupApi } from '#/api/basic/productunitgroup';
|
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
|
||||||
import {
|
|
||||||
createProductUnitGroup,
|
|
||||||
getProductUnitGroup,
|
|
||||||
updateProductUnitGroup,
|
|
||||||
} from '#/api/basic/productunitgroup';
|
|
||||||
import { $t } from '#/locales';
|
|
||||||
|
|
||||||
import { useFormSchema } from '../data';
|
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
|
||||||
const formData = ref<ProductUnitGroupApi.ProductUnitGroup>();
|
|
||||||
const getTitle = computed(() => {
|
|
||||||
return formData.value?.id
|
|
||||||
? $t('ui.actionTitle.edit', ['产品单位组'])
|
|
||||||
: $t('ui.actionTitle.create', ['产品单位组']);
|
|
||||||
});
|
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
|
||||||
commonConfig: {
|
|
||||||
componentProps: {
|
|
||||||
class: 'w-full',
|
|
||||||
},
|
|
||||||
formItemClass: 'col-span-2',
|
|
||||||
labelWidth: 80,
|
|
||||||
},
|
|
||||||
layout: 'horizontal',
|
|
||||||
schema: useFormSchema(),
|
|
||||||
showDefaultActions: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
|
||||||
async onConfirm() {
|
|
||||||
const { valid } = await formApi.validate();
|
|
||||||
if (!valid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
modalApi.lock();
|
|
||||||
// 提交表单
|
|
||||||
const data =
|
|
||||||
(await formApi.getValues()) as ProductUnitGroupApi.ProductUnitGroup;
|
|
||||||
try {
|
|
||||||
await (formData.value?.id
|
|
||||||
? updateProductUnitGroup(data)
|
|
||||||
: createProductUnitGroup(data));
|
|
||||||
// 关闭并提示
|
|
||||||
await modalApi.close();
|
|
||||||
emit('success');
|
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
|
||||||
} finally {
|
|
||||||
modalApi.unlock();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async onOpenChange(isOpen: boolean) {
|
|
||||||
if (!isOpen) {
|
|
||||||
formData.value = undefined;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 加载数据
|
|
||||||
let data = modalApi.getData<ProductUnitGroupApi.ProductUnitGroup>();
|
|
||||||
if (!data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.id) {
|
|
||||||
modalApi.lock();
|
|
||||||
try {
|
|
||||||
data = await getProductUnitGroup(data.id);
|
|
||||||
} finally {
|
|
||||||
modalApi.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 设置到 values
|
|
||||||
formData.value = data;
|
|
||||||
await formApi.setValues(formData.value);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Modal :title="getTitle">
|
|
||||||
<Form class="mx-4" />
|
|
||||||
</Modal>
|
|
||||||
</template>
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
import type { PageParam, PageResult } from '@vben/request';
|
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
|
||||||
|
|
||||||
// TODO @xingyu:貌似模块不对
|
|
||||||
|
|
||||||
export namespace ProductUnitApi {
|
|
||||||
/** 产品单位信息 */
|
|
||||||
export interface ProductUnit {
|
|
||||||
id: number; // 编号
|
|
||||||
groupId?: number; // 分组编号
|
|
||||||
name?: string; // 单位名称
|
|
||||||
basic?: number; // 基础单位
|
|
||||||
number?: number; // 单位数量/相对于基础单位
|
|
||||||
usageType: number; // 用途
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询产品单位分页 */
|
|
||||||
export function getProductUnitPage(params: PageParam) {
|
|
||||||
return requestClient.get<PageResult<ProductUnitApi.ProductUnit>>(
|
|
||||||
'/basic/product-unit/page',
|
|
||||||
{ params },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询产品单位详情 */
|
|
||||||
export function getProductUnit(id: number) {
|
|
||||||
return requestClient.get<ProductUnitApi.ProductUnit>(
|
|
||||||
`/basic/product-unit/get?id=${id}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 新增产品单位 */
|
|
||||||
export function createProductUnit(data: ProductUnitApi.ProductUnit) {
|
|
||||||
return requestClient.post('/basic/product-unit/create', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 修改产品单位 */
|
|
||||||
export function updateProductUnit(data: ProductUnitApi.ProductUnit) {
|
|
||||||
return requestClient.put('/basic/product-unit/update', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除产品单位 */
|
|
||||||
export function deleteProductUnit(id: number) {
|
|
||||||
return requestClient.delete(`/basic/product-unit/delete?id=${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量删除产品单位 */
|
|
||||||
export function deleteProductUnitListByIds(ids: number[]) {
|
|
||||||
return requestClient.delete(
|
|
||||||
`/basic/product-unit/delete-list?ids=${ids.join(',')}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出产品单位 */
|
|
||||||
export function exportProductUnit(params: any) {
|
|
||||||
return requestClient.download('/basic/product-unit/export-excel', { params });
|
|
||||||
}
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
import type { PageParam, PageResult } from '@vben/request';
|
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
|
||||||
|
|
||||||
// TODO @xingyu:貌似模块不对
|
|
||||||
|
|
||||||
export namespace ProductUnitGroupApi {
|
|
||||||
/** 产品单位组信息 */
|
|
||||||
export interface ProductUnitGroup {
|
|
||||||
id: number; // 编号
|
|
||||||
name?: string; // 产品单位组名称
|
|
||||||
status?: number; // 开启状态
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询产品单位组分页 */
|
|
||||||
export function getProductUnitGroupPage(params: PageParam) {
|
|
||||||
return requestClient.get<PageResult<ProductUnitGroupApi.ProductUnitGroup>>(
|
|
||||||
'/basic/product-unit-group/page',
|
|
||||||
{ params },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询产品单位组详情 */
|
|
||||||
export function getProductUnitGroup(id: number) {
|
|
||||||
return requestClient.get<ProductUnitGroupApi.ProductUnitGroup>(
|
|
||||||
`/basic/product-unit-group/get?id=${id}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 新增产品单位组 */
|
|
||||||
export function createProductUnitGroup(
|
|
||||||
data: ProductUnitGroupApi.ProductUnitGroup,
|
|
||||||
) {
|
|
||||||
return requestClient.post('/basic/product-unit-group/create', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 修改产品单位组 */
|
|
||||||
export function updateProductUnitGroup(
|
|
||||||
data: ProductUnitGroupApi.ProductUnitGroup,
|
|
||||||
) {
|
|
||||||
return requestClient.put('/basic/product-unit-group/update', data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除产品单位组 */
|
|
||||||
export function deleteProductUnitGroup(id: number) {
|
|
||||||
return requestClient.delete(`/basic/product-unit-group/delete?id=${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量删除产品单位组 */
|
|
||||||
export function deleteProductUnitGroupListByIds(ids: number[]) {
|
|
||||||
return requestClient.delete(
|
|
||||||
`/basic/product-unit-group/delete-list?ids=${ids.join(',')}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出产品单位组 */
|
|
||||||
export function exportProductUnitGroup(params: any) {
|
|
||||||
return requestClient.download(
|
|
||||||
'/basic/product-unit-group/export-excel',
|
|
||||||
params,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
// TODO @芋艿:后续合并到 diy-editor 里,并不是通用的;
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
import AppLinkSelectDialog from './app-link-select-dialog.vue';
|
import AppLinkSelectDialog from './app-link-select-dialog.vue';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
// TODO @芋艿:后续合并到 diy-editor 里,并不是通用的;
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
import { PREDEFINE_COLORS } from '#/utils/constants';
|
import { PREDEFINE_COLORS } from '#/utils/constants';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
// TODO @芋艿:后续合并到 diy-editor 里,并不是通用的;
|
||||||
|
|
||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
import { cloneDeep } from '@vben/utils';
|
import { cloneDeep } from '@vben/utils';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
// TODO @芋艿:后续合并到 diy-editor 里,并不是通用的;
|
||||||
import { useVModels } from '@vueuse/core';
|
import { useVModels } from '@vueuse/core';
|
||||||
import { ElColorPicker, ElInput } from 'element-plus';
|
import { ElColorPicker, ElInput } from 'element-plus';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
// TODO @芋艿:后续合并到 diy-editor 里,并不是通用的;
|
||||||
import type { Point, Rect } from './util';
|
import type { Point, Rect } from './util';
|
||||||
|
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
// TODO @芋艿:后续合并到 diy-editor 里,并不是通用的;
|
||||||
/**
|
/**
|
||||||
* 垂直按钮组
|
* 垂直按钮组
|
||||||
* Element官方的按钮组只支持水平显示,通过重写样式实现垂直布局
|
* Element官方的按钮组只支持水平显示,通过重写样式实现垂直布局
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
|
// TODO @chihuo:这个合并到 mall.ts 里
|
||||||
const routes: RouteRecordRaw[] = [
|
const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
path: '/diy',
|
path: '/diy',
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// TODO @xingyu:要不要抽到 package 里?
|
||||||
/**
|
/**
|
||||||
* 将值复制到目标对象,且以目标对象属性为准,例:target: {a:1} source:{a:2,b:3} 结果为:{a:2}
|
* 将值复制到目标对象,且以目标对象属性为准,例:target: {a:1} source:{a:2,b:3} 结果为:{a:2}
|
||||||
* @param target 目标对象
|
* @param target 目标对象
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// TODO @xingyu:要不要融合到 /packages/@core/base/shared/src/utils/time.ts 里?
|
||||||
/**
|
/**
|
||||||
* 将毫秒,转换成时间字符串。例如说,xx 分钟
|
* 将毫秒,转换成时间字符串。例如说,xx 分钟
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
// 参数校验,对标 Hutool 的 Validator 工具类
|
// 参数校验,对标 Hutool 的 Validator 工具类
|
||||||
|
// TODO @xingyu:要不要抽到 package 里?
|
||||||
|
|
||||||
/** 手机号正则表达式(中国) */
|
/** 手机号正则表达式(中国) */
|
||||||
const MOBILE_REGEX = /(?:0|86|\+86)?1[3-9]\d{9}/;
|
const MOBILE_REGEX = /(?:0|86|\+86)?1[3-9]\d{9}/;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,12 @@ Alert提供的功能与Modal类似,但只适用于简单应用场景。例如
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
::: tip 注意
|
||||||
|
|
||||||
|
Alert提供的快捷方法alert、confirm、prompt动态创建的弹窗在已打开的情况下,不支持HMR(热更新),代码变更后需要关闭这些弹窗后重新打开。
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
::: tip README
|
::: tip README
|
||||||
|
|
||||||
下方示例代码中的,存在一些主题色未适配、样式缺失的问题,这些问题只在文档内会出现,实际使用并不会有这些问题,可忽略,不必纠结。
|
下方示例代码中的,存在一些主题色未适配、样式缺失的问题,这些问题只在文档内会出现,实际使用并不会有这些问题,可忽略,不必纠结。
|
||||||
|
|
@ -32,6 +38,23 @@ Alert提供的功能与Modal类似,但只适用于简单应用场景。例如
|
||||||
|
|
||||||
<DemoPreview dir="demos/vben-alert/prompt" />
|
<DemoPreview dir="demos/vben-alert/prompt" />
|
||||||
|
|
||||||
|
## useAlertContext
|
||||||
|
|
||||||
|
当弹窗的content、footer、icon使用自定义组件时,在这些组件中可以使用 `useAlertContext` 获取当前弹窗的上下文对象,用来主动控制弹窗。
|
||||||
|
|
||||||
|
::: tip 注意
|
||||||
|
|
||||||
|
`useAlertContext`只能用在setup或者函数式组件中。
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
| 方法 | 描述 | 类型 | 版本要求 |
|
||||||
|
| --------- | ------------------ | -------- | -------- |
|
||||||
|
| doConfirm | 调用弹窗的确认操作 | ()=>void | >5.5.4 |
|
||||||
|
| doCancel | 调用弹窗的取消操作 | ()=>void | >5.5.4 |
|
||||||
|
|
||||||
## 类型说明
|
## 类型说明
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue