158 lines
3.8 KiB
TypeScript
158 lines
3.8 KiB
TypeScript
import type { VbenFormSchema } from '#/adapter/form';
|
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|
import type { ProgressApi } from '#/api/report/progress';
|
|
|
|
import dayjs from 'dayjs';
|
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
|
|
import { getCustomerList } from '#/api/license/customer';
|
|
import { getProjectList } from '#/api/license/project';
|
|
import { $t } from '#/locales';
|
|
import { DICT_TYPE, getRangePickerDefaultProps } from '#/utils';
|
|
|
|
dayjs.extend(relativeTime);
|
|
|
|
// ==================== 已过期 ====================
|
|
export function useExpiredGridFormSchema(): VbenFormSchema[] {
|
|
return [
|
|
{
|
|
fieldName: 'customerId',
|
|
label: $t('license.customer'),
|
|
component: 'ApiSelect',
|
|
componentProps: {
|
|
api: getCustomerList,
|
|
allowClear: true,
|
|
fieldNames: { label: 'name', value: 'id' },
|
|
showSearch: true,
|
|
filterOption: (input: string, option: any) =>
|
|
option.name.toLowerCase().includes(input.toLowerCase()),
|
|
},
|
|
},
|
|
{
|
|
fieldName: 'projectId',
|
|
label: $t('license.project'),
|
|
component: 'ApiSelect',
|
|
componentProps: {
|
|
api: getProjectList,
|
|
allowClear: true,
|
|
fieldNames: { label: 'name', value: 'id' },
|
|
showSearch: true,
|
|
filterOption: (input: string, option: any) =>
|
|
option.name.toLowerCase().includes(input.toLowerCase()),
|
|
},
|
|
},
|
|
{
|
|
fieldName: 'serialNo',
|
|
label: 'SN',
|
|
component: 'Input',
|
|
componentProps: {
|
|
allowClear: true,
|
|
},
|
|
},
|
|
{
|
|
fieldName: 'expiryDate',
|
|
label: '到期时间',
|
|
component: 'RangePicker',
|
|
defaultValue: [dayjs().subtract(7, 'days'), dayjs()],
|
|
componentProps: {
|
|
...getRangePickerDefaultProps(),
|
|
format: 'YYYY-MM-DD',
|
|
showTime: false,
|
|
},
|
|
},
|
|
];
|
|
}
|
|
|
|
/** 列表的字段 */
|
|
export function useExpiredGridColumns(): VxeTableGridOptions<ProgressApi.Progress>['columns'] {
|
|
return [
|
|
{
|
|
field: 'customerName',
|
|
title: '客户名称',
|
|
showOverflow: false,
|
|
minWidth: 60,
|
|
},
|
|
{
|
|
field: 'projectName',
|
|
title: '项目名称',
|
|
showOverflow: false,
|
|
minWidth: 80,
|
|
},
|
|
{
|
|
field: 'status',
|
|
title: $t('project.status'),
|
|
minWidth: 40,
|
|
cellRender: {
|
|
name: 'CellDict',
|
|
props: { type: DICT_TYPE.LIC_PROJECT_STATUS },
|
|
},
|
|
},
|
|
{
|
|
field: 'businessStatus',
|
|
title: $t('project.businessStatus'),
|
|
minWidth: 40,
|
|
cellRender: {
|
|
name: 'CellDict',
|
|
props: { type: DICT_TYPE.LIC_BUSINESS_STATUS },
|
|
},
|
|
},
|
|
{
|
|
field: 'serialNo',
|
|
title: 'SN',
|
|
showOverflow: false,
|
|
minWidth: 40,
|
|
},
|
|
{
|
|
field: 'businessOwnerName',
|
|
title: '业务负责人',
|
|
minWidth: 40,
|
|
},
|
|
{
|
|
field: 'technicalOwnerAName',
|
|
title: '技术负责人1',
|
|
minWidth: 40,
|
|
},
|
|
{
|
|
field: 'technicalOwnerBName',
|
|
title: '技术负责人2',
|
|
visible: false,
|
|
minWidth: 40,
|
|
},
|
|
{
|
|
field: 'startTime',
|
|
title: '项目开始时间',
|
|
minWidth: 80,
|
|
visible: false,
|
|
formatter: 'formatDateTime',
|
|
},
|
|
{
|
|
field: 'expiryDate',
|
|
title: '到期时间',
|
|
minWidth: 80,
|
|
formatter: 'formatDateTime',
|
|
},
|
|
{
|
|
field: 'expiryDateFormat',
|
|
title: '已到期',
|
|
minWidth: 80,
|
|
formatter: ({ cellValue }) => {
|
|
if (!cellValue) return '';
|
|
// const days = dayjs(cellValue).diff(dayjs(), 'day');
|
|
// if (days > 0) {
|
|
// return `${days} 天`;
|
|
// }
|
|
// if (days === 0) {
|
|
// return '今天到期';
|
|
// }
|
|
return dayjs(cellValue).fromNow(true);
|
|
},
|
|
},
|
|
{
|
|
field: 'applicationTime',
|
|
title: '申请时间',
|
|
minWidth: 80,
|
|
formatter: 'formatDateTime',
|
|
},
|
|
];
|
|
}
|