import type { VxeGridProps } from '#/adapter/vxe-table'; import { computed } from 'vue'; import { z } from '@vben/common-ui'; import { $t } from '#/locales'; import { postOneNetAccountListAsync } from '#/api-client'; export const querySchema = computed(() => [ { component: 'Input', fieldName: 'productName', label: $t('abp.OneNETManagement.ProductName'), }, ]); export const tableSchema: any = computed((): VxeGridProps['columns'] => [ { title: $t('common.seq'), type: 'seq', width: 50 }, { field: 'oneNETProductId', title: $t('abp.OneNETManagement.OneNETProductId'), minWidth: '150', }, { field: 'productName', title: $t('abp.OneNETManagement.ProductName'), minWidth: '150', }, { field: 'productKey', title: $t('abp.OneNETManagement.ProductKey'), minWidth: '150', }, { field: 'productSecret', title: $t('abp.OneNETManagement.ProductSecret'), minWidth: '150', }, { field: 'accountName', title: $t('abp.OneNETManagement.AccountName'), minWidth: '150', }, { field: 'enabled', title: $t('common.isEnable'), minWidth: '150', slots: { default: 'isEnable' }, }, { title: $t('common.action'), field: 'action', fixed: 'right', width: '150', slots: { default: 'action' }, }, ]); export const addProductFormSchema: any = computed(() => [ { component: 'ApiSelect', fieldName: 'oneNETAccountId', label: $t('abp.OneNETManagement.BelongingAccountName'), componentProps: { api: postOneNetAccountListAsync, params: { body: { pageIndex: 1, pageSize: 1000, }, }, labelField: 'accountName', valueField: 'oneNETAccountId', immediate: true, afterFetch: (res: any) => { console.log('ApiSelect afterFetch res:', res); // 如果是 Axios 响应对象,提取 data if (res && res.data) { console.log('提取 res.data:', res.data); const data = res.data; // 确保返回的是数组格式 if (Array.isArray(data)) { console.log('返回数组,长度:', data.length); return data; } // 如果是包装在 items 中的,提取出来 if (data && Array.isArray(data.items)) { console.log('返回items数组,长度:', data.items.length); return data.items; } // 如果是包装在 data 中的,提取出来 if (data && Array.isArray(data.data)) { console.log('返回data数组,长度:', data.data.length); return data.data; } } // 如果都不是,返回空数组 console.log('没有找到数组数据,返回空数组'); return []; }, placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`, }, rules: z.string().min(1, { message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`, }), }, { component: 'Input', fieldName: 'oneNETProductId', label: $t('abp.OneNETManagement.OneNETProductId'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETProductId')}`, }), }, { component: 'Input', fieldName: 'productName', label: $t('abp.OneNETManagement.ProductName'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductName')}`, }), }, { component: 'Input', fieldName: 'productKey', label: $t('abp.OneNETManagement.ProductKey'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductKey')}`, }), }, { component: 'Input', fieldName: 'productSecret', label: $t('abp.OneNETManagement.ProductSecret'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductSecret')}`, }), }, { component: 'Switch', componentProps: { class: 'w-auto', }, fieldName: 'enabled', label: $t('common.isEnable'), }, ]); export const editProductFormSchemaEdit: any = computed(() => [ { component: 'Input', fieldName: 'oneNETProductId', label: $t('abp.OneNETManagement.OneNETProductId'), disabled: true, }, { component: 'Input', fieldName: 'productName', label: $t('abp.OneNETManagement.ProductName'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductName')}`, }), }, { component: 'Input', fieldName: 'productKey', label: $t('abp.OneNETManagement.ProductKey'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductKey')}`, }), }, { component: 'Input', fieldName: 'productSecret', label: $t('abp.OneNETManagement.ProductSecret'), rules: z.string().min(1, { message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductSecret')}`, }), }, { component: 'ApiSelect', fieldName: 'accountName', label: $t('abp.OneNETManagement.AccountName'), componentProps: { api: postOneNetAccountListAsync, params: { body: { pageIndex: 1, pageSize: 1000, }, }, labelField: 'accountName', valueField: 'oneNETAccountId', immediate: true, afterFetch: (res: any) => { console.log('ApiSelect afterFetch res:', res); // 如果是 Axios 响应对象,提取 data if (res && res.data) { console.log('提取 res.data:', res.data); const data = res.data; // 确保返回的是数组格式 if (Array.isArray(data)) { console.log('返回数组,长度:', data.length); return data; } // 如果是包装在 items 中的,提取出来 if (data && Array.isArray(data.items)) { console.log('返回items数组,长度:', data.items.length); return data.items; } // 如果是包装在 data 中的,提取出来 if (data && Array.isArray(data.data)) { console.log('返回data数组,长度:', data.data.length); return data.data; } } // 如果都不是,返回空数组 console.log('没有找到数组数据,返回空数组'); return []; }, placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.AccountName')}`, }, rules: z.string().min(1, { message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.AccountName')}`, }), }, { component: 'Switch', componentProps: { class: 'w-auto', }, fieldName: 'enabled', label: $t('common.isEnable'), }, ]);