Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions frontend/packages/lib-shared/method/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,3 +705,33 @@ export function getCopiedName(name: string, suffix = 'copy', maxLen = 255): stri
}
return baseName + suffix;
}

/**
* 通用数字千分位展示
* @param value 数值或数值字符串
* @param options 小数位配置
* @returns 格式化后的字符串
*/
export function formatThousands(
value: string | number | null | undefined,
options?: {
minimumFractionDigits?: number;
maximumFractionDigits?: number;
}
) {
if (value === null || value === undefined || value === '') {
return '';
}

const numberValue = Number(value);
if (!Number.isFinite(numberValue)) {
return String(value);
}

const decimalLength = String(value).includes('.') ? String(value).split('.')[1]?.length || 0 : 0;

return numberValue.toLocaleString('en-US', {
minimumFractionDigits: options?.minimumFractionDigits,
maximumFractionDigits: options?.maximumFractionDigits ?? decimalLength,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
default: [],
});

function normalizeSelectedIds(defaultValue?: string | number | (string | number)[]) {
let defaultIds: (string | number)[] = [];
if (Array.isArray(defaultValue)) {
defaultIds = defaultValue;
} else if (defaultValue !== undefined && defaultValue !== null && defaultValue !== '') {
defaultIds = [defaultValue];
}
const currentValueIds = Array.isArray(value.value) ? value.value : [];
return [...new Set([...defaultIds, ...currentValueIds])];
}

function getParams(): FilterResult {
const conditions = props.fieldConfig.combineSearch?.conditions
.map((item) => ({
Expand Down Expand Up @@ -129,11 +140,14 @@
keyword: val?.[0]?.name || '',
});
await loadList();
const newRows = propsRes.value.data.filter(
(item) => props.fieldConfig.defaultValue?.includes(item.id) || value.value.includes(item.id)
);
value.value = newRows.map((e) => e.id) as (string | number)[];
emit('change', value.value, newRows, fieldList.value);
const selectedIds = normalizeSelectedIds(props.fieldConfig.defaultValue);
const newRows = propsRes.value.data.filter((item) => selectedIds.includes(item.id));
const fallbackRows = val.filter((item) => selectedIds.includes(item.id));

// 如果补全请求未查到目标项,仍需保留初始化值,避免出现先带入后被清空的问题
const mergedRows = [...newRows, ...fallbackRows.filter((item) => !newRows.some((row) => row.id === item.id))];
value.value = selectedIds;
emit('change', value.value, mergedRows, fieldList.value);
} else if (val?.some((e) => e.isFormLinkFilled)) {
// 这里将表单联动填充的初始化选项 emit 出去,触发 change 让数据源显示字段回显
emit('change', value.value, val, fieldList.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
fieldList.value.forEach((item) => {
if ([FieldTypeEnum.FORMULA, FieldTypeEnum.INPUT, FieldTypeEnum.SERIAL_NUMBER].includes(item.type)) {
const { fields } = safeParseFormula(item.formula ?? '');
fields.forEach((e: any) => {
fields?.forEach((e: any) => {
let options = [];
const targetField = fieldMap.get(e.fieldId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function useStatusFormItemModelConfig(): Record<StatusBizType, FormItemMo
formItemClass: 'w-full flex-initial',
inputProps: { maxlength: 16 },
rule: [
{ required: true, message: t('common.notNull', { value: '' }) },
{ required: true, message: t('common.notNull', { value: t('opportunity.opportunityStage') }) },
{ notRepeat: true, message: t('module.capacitySet.repeatMsg') },
],
},
Expand Down Expand Up @@ -189,7 +189,7 @@ export function useStatusFormItemModelConfig(): Record<StatusBizType, FormItemMo
rule: [
{
required: true,
message: t('common.notNull', { value: t('order.status') }),
message: t('common.notNull', { value: t('module.contract.stage') }),
},
{ notRepeat: true, message: t('module.capacitySet.repeatMsg') },
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
</n-tooltip>
<div class="crm-stage-board-item-desc-value">
<CrmTableButton
v-if="props.item.customerName"
v-if="props.item.customerName && hasAnyPermission(['CUSTOMER_MANAGEMENT:READ'])"
size="small"
class="text-[14px]"
@click="emit('openDetail', 'customer', props.item)"
>
<template #trigger>{{ props.item.customerName }}</template>
{{ props.item.customerName }}
</CrmTableButton>
<div v-else>-</div>
<CrmNameTooltip v-else :text="props.item.customerName ?? '-'" />
</div>
</div>
<div class="crm-stage-board-item-desc crm-stage-board-item-desc--wide">
Expand All @@ -67,12 +67,7 @@
{{ fieldLabelMap.alreadyPayAmount }}
</n-tooltip>
<div class="crm-stage-board-item-desc-value">
{{
formatNumberValue(
props.item.alreadyPayAmount,
(props.fieldList.find((field) => field.businessKey === 'alreadyPayAmount') as FormCreateField) || {}
)
}}
{{ formatThousands(props.item.alreadyPayAmount) || '-' }}
</div>
</div>
<div class="crm-stage-board-item-desc crm-stage-board-item-desc--wide">
Expand Down Expand Up @@ -111,11 +106,15 @@
import dayjs from 'dayjs';

import { useI18n } from '@lib/shared/hooks/useI18n';
import { formatThousands } from '@lib/shared/method';
import { formatNumberValue } from '@lib/shared/method/formCreate';

import CrmNameTooltip from '@/components/pure/crm-name-tooltip/index.vue';
import CrmTableButton from '@/components/pure/crm-table-button/index.vue';
import { FormCreateField } from '@/components/business/crm-form-create/types';

import { hasAnyPermission } from '@/utils/permission';

const props = defineProps<{
item: any;
fieldList: FormCreateField[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
</n-tooltip>
<div class="crm-stage-board-item-desc-value">
<CrmTableButton
v-if="props.item.customerName"
v-if="props.item.customerName && hasAnyPermission(['CUSTOMER_MANAGEMENT:READ'])"
size="small"
class="text-[14px]"
@click="emit('openDetail', 'customer', props.item)"
>
<template #trigger>{{ props.item.customerName }}</template>
{{ props.item.customerName }}
</CrmTableButton>
<div v-else>-</div>
<CrmNameTooltip v-else :text="props.item.customerName ?? '-'" />
</div>
</div>
<div class="crm-stage-board-item-desc">
Expand Down Expand Up @@ -95,10 +95,13 @@

import { formatNumberValue } from '@lib/shared/method/formCreate';

import CrmNameTooltip from '@/components/pure/crm-name-tooltip/index.vue';
import CrmTableButton from '@/components/pure/crm-table-button/index.vue';
import CrmTagGroup from '@/components/pure/crm-tag-group/index.vue';
import { FormCreateField } from '@/components/business/crm-form-create/types';

import { hasAnyPermission } from '@/utils/permission';

const props = defineProps<{
item: any;
fieldList: FormCreateField[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
</n-tooltip>
<div class="crm-stage-board-item-desc-value">
<CrmTableButton
v-if="props.item.contractName"
v-if="props.item.contractName && hasAnyPermission(['CONTRACT:READ'])"
size="small"
class="text-[14px]"
@click="emit('openDetail', 'contract', props.item)"
>
<template #trigger>{{ props.item.contractName }}</template>
{{ props.item.contractName }}
</CrmTableButton>
<div v-else>-</div>
<CrmNameTooltip v-else :text="props.item.contractName ?? '-'" />
</div>
</div>
<div class="crm-stage-board-item-desc">
Expand All @@ -57,15 +57,15 @@
</n-tooltip>
<div class="crm-stage-board-item-desc-value">
<CrmTableButton
v-if="props.item.customerName"
v-if="props.item.customerName && hasAnyPermission(['CUSTOMER_MANAGEMENT:READ'])"
size="small"
class="text-[14px]"
@click="emit('openDetail', 'customer', props.item)"
>
<template #trigger>{{ props.item.customerName }}</template>
{{ props.item.customerName }}
</CrmTableButton>
<div v-else>-</div>
<CrmNameTooltip v-else :text="props.item.customerName ?? '-'" />
</div>
</div>
<div class="crm-stage-board-item-desc">
Expand Down Expand Up @@ -103,9 +103,12 @@
import { useI18n } from '@lib/shared/hooks/useI18n';
import { formatNumberValue } from '@lib/shared/method/formCreate';

import CrmNameTooltip from '@/components/pure/crm-name-tooltip/index.vue';
import CrmTableButton from '@/components/pure/crm-table-button/index.vue';
import { FormCreateField } from '@/components/business/crm-form-create/types';

import { hasAnyPermission } from '@/utils/permission';

const props = defineProps<{
item: any;
fieldList: FormCreateField[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export default {
'process.process.approvalAuthority': 'Approval permissions',
'process.process.approvalAuthority.batchAction': 'Allow approver to batch process',
'process.process.approvalAuthority.batchActionTip':
'Submitter can still cancel after first approval node passes (does not apply to applications initiated before configuration)',
'After checked, the approver in handling this process, can be batch processing tasks',
'process.process.approvalAuthority.revokable': 'Allow approver to revoke',
'process.process.approvalAuthority.addTempApprover':
'When checked, approver can add temporary approver in the approval flow',
'After checking, if the approver agrees and the subsequent approver has not approved, it can be withdrawn for new approval',
'process.process.approvalAuthority.allowAddSign': 'Allow adding signatory',
'process.process.approvalAuthority.allowAddTempApprover':
'When checked, approver can add temporary approver in the approval flow',
'After checking, the approver can add temporary approvers to the approval process',
'process.process.processName': 'Process Name',
'process.process.basic.businessType': 'Business Type',
'process.process.basic.executionTiming': 'Execution timing',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ export default {
'process.process.approvalRejectOpinion': '审批人同意或驳回流程时,需要填写审批意见',
'process.process.approvalAuthority': '审批权限',
'process.process.approvalAuthority.batchAction': '允许审批人批量处理',
'process.process.approvalAuthority.batchActionTip':
'第一个审批节点通过后,提交人仍可撤销申请(配置前已发起的申请不生效)',
'process.process.approvalAuthority.batchActionTip': '勾选后,审批人在处理此流程任务时,可批量处理多个任务',
'process.process.approvalAuthority.revokable': '允许审批人撤回',
'process.process.approvalAuthority.addTempApprover': '勾选后,审批人可在审批流程中增加临时审批人',
'process.process.approvalAuthority.addTempApprover': '勾选后,若审批人同意且后续审批人尚未审批,可撤回重新进行审批',
'process.process.approvalAuthority.allowAddSign': '允许加签',
'process.process.approvalAuthority.allowAddTempApprover': '勾选后,审批人可在审批流程中增加临时审批人',
'process.process.processName': '流程名称',
Expand Down
Loading