| | |
| | | <div class="stats-card"> |
| | | <span class="card-header" v-if="!isLoading"> {{ displayWord }}</span> |
| | | <span class="card-header" v-else>加载中...</span> |
| | | <div class="contract-period">签约期限:{{ contractPeriod }}</div> |
| | | <div class="contract-period">签约期限:{{ signTermStartDate || '' }} - {{ signTermEndDate || '' }}</div> |
| | | |
| | | <div class="stats-group"> |
| | | <div class="stat-item"> |
| | |
| | | semanticWordId?: string; // 语义词ID |
| | | cardIndex?: number; // 卡片索引,用于区分显示哪个test字段 |
| | | llmTab?: string; // 当前选择的大模型 |
| | | contractPeriod: string; // 签约期限 |
| | | signTermStartDate: string; // 签约期限开始日期 |
| | | signTermEndDate: string; // 签约期限结束日期 |
| | | signRank: number; // 签约排名 |
| | | avgRank: number; // 平均排名 |
| | | onlineDate: string; // 上词日期 |
| | |
| | | }; |
| | | |
| | | const displayWord = ref<string>(''); |
| | | const signTermStartDate = ref(props.signTermStartDate || ''); |
| | | const signTermEndDate = ref(props.signTermEndDate || ''); |
| | | const isLoading = computed(() => (props.word ? false : true)); // 计算加载状态 |
| | | const defaultStats: CardStats = { |
| | | signRank: props.signRank, |
| | |
| | | }; |
| | | const resetStats = () => { |
| | | cardStats.value = { ...defaultStats }; |
| | | signTermStartDate.value = props.signTermStartDate || ''; |
| | | signTermEndDate.value = props.signTermEndDate || ''; |
| | | }; |
| | | |
| | | // 使用传入的outWord,如果没有则使用默认值 |
| | |
| | | acceptIndicator: target.acceptIndicator ?? '--', |
| | | achievedRate: target.reachedTarget ?? '--', |
| | | }; |
| | | signTermStartDate.value = target.signTermStartDate ?? props.signTermStartDate ?? ''; |
| | | signTermEndDate.value = target.signTermEndDate ?? props.signTermEndDate ?? ''; |
| | | } catch (error) { |
| | | console.error('获取robin数据失败:', error); |
| | | displayWord.value = '获取失败'; |
| | |
| | | } |
| | | ); |
| | | |
| | | // 监听签约期限 props,保持默认值同步 |
| | | watch( |
| | | () => [props.signTermStartDate, props.signTermEndDate], |
| | | ([start, end]) => { |
| | | signTermStartDate.value = start || ''; |
| | | signTermEndDate.value = end || ''; |
| | | } |
| | | ); |
| | | |
| | | // 组件挂载时获取数据 |
| | | onMounted(() => { |
| | | if (props.queryEnabled && props.word) { |
| | |
| | | submitFunc: customSubmitFunc, |
| | | }); |
| | | |
| | | const phonePattern = /^1[3-9]\d{9}$/; |
| | | const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; |
| | | |
| | | function getPhoneRules(required: boolean) { |
| | | const rules: any[] = []; |
| | | if (required) { |
| | | rules.push({ |
| | | required: true, |
| | | message: '请输入客户电话', |
| | | }); |
| | | } |
| | | rules.push({ |
| | | validator: (_: any, value: string) => { |
| | | if (!value) { |
| | | return Promise.resolve(); |
| | | } |
| | | return phonePattern.test(value) ? Promise.resolve() : Promise.reject('请输入正确的手机号码格式'); |
| | | }, |
| | | }); |
| | | return rules; |
| | | } |
| | | |
| | | function getEmailRules(required: boolean) { |
| | | const rules: any[] = []; |
| | | if (required) { |
| | | rules.push({ |
| | | required: true, |
| | | message: '请输入客户邮箱', |
| | | }); |
| | | } |
| | | rules.push({ |
| | | validator: (_: any, value: string) => { |
| | | if (!value) { |
| | | return Promise.resolve(); |
| | | } |
| | | return emailPattern.test(value) ? Promise.resolve() : Promise.reject('请输入正确的邮箱格式'); |
| | | }, |
| | | }); |
| | | return rules; |
| | | } |
| | | |
| | | // 查询用户角色并更新表单验证规则 |
| | | async function checkUserRoleAndUpdateSchema() { |
| | | try { |
| | |
| | | // 判断是否为代理商角色 |
| | | const isAgent = roleMessage.includes('代理商'); |
| | | |
| | | if (isAgent) { |
| | | // 代理商角色:客户电话和客户邮箱为非必填项 |
| | | updateSchema([ |
| | | { |
| | | field: 'customerPhone', |
| | | required: false, |
| | | rules: [ |
| | | { |
| | | pattern: /^1[3-9]\d{9}$/, |
| | | message: '请输入正确的手机号码格式', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | field: 'customerEmail', |
| | | required: false, |
| | | rules: [ |
| | | { |
| | | pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/, |
| | | message: '请输入正确的邮箱格式', |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | console.log('当前用户为代理商,客户电话和客户邮箱已设置为非必填'); |
| | | } else { |
| | | // 其他角色:保持必填 |
| | | updateSchema([ |
| | | { |
| | | field: 'customerPhone', |
| | | required: true, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入客户电话', |
| | | }, |
| | | { |
| | | pattern: /^1[3-9]\d{9}$/, |
| | | message: '请输入正确的手机号码格式', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | field: 'customerEmail', |
| | | required: true, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入客户邮箱', |
| | | }, |
| | | { |
| | | pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/, |
| | | message: '请输入正确的邮箱格式', |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | } |
| | | const schemaPayload = isAgent |
| | | ? [ |
| | | { |
| | | field: 'customerPhone', |
| | | required: false, |
| | | rules: getPhoneRules(false), |
| | | }, |
| | | { |
| | | field: 'customerEmail', |
| | | required: false, |
| | | rules: getEmailRules(false), |
| | | }, |
| | | ] |
| | | : [ |
| | | { |
| | | field: 'customerPhone', |
| | | required: true, |
| | | rules: getPhoneRules(true), |
| | | }, |
| | | { |
| | | field: 'customerEmail', |
| | | required: true, |
| | | rules: getEmailRules(true), |
| | | }, |
| | | ]; |
| | | |
| | | updateSchema(schemaPayload); |
| | | } else { |
| | | console.warn('查询用户角色失败:', response?.message); |
| | | } |
| | |
| | | const [register, { validate, setProps }] = useForm({ |
| | | labelWidth: 120, |
| | | schemas: step2Schemas, |
| | | // 预置表单数据,避免必填校验把默认显示的 3 视为未填写 |
| | | model: { |
| | | contractPeriod: 3, |
| | | }, |
| | | actionColOptions: { |
| | | span: 14, |
| | | }, |
| | |
| | | word: '', |
| | | ranking: '1', |
| | | price: undefined, |
| | | month: undefined, |
| | | month: 3, |
| | | acceptindicator: undefined |
| | | }, |
| | | ]); |
| | |
| | | word: '', |
| | | ranking: '1', |
| | | price: undefined, |
| | | month: undefined, |
| | | month: 3, |
| | | acceptindicator: undefined |
| | | }; |
| | | tableData.value.push(newRow); |
| | |
| | | component: 'Input', |
| | | label: '合作周期', |
| | | required: true, |
| | | defaultValue: 3, |
| | | // defaultValue: 3, |
| | | render: ({ model, field }) => { |
| | | return h(Input, { |
| | | placeholder: '请输入正整数', |
| | |
| | | submitFunc: customSubmitFunc, |
| | | }); |
| | | |
| | | const phonePattern = /^1[3-9]\d{9}$/; |
| | | const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; |
| | | |
| | | function getPhoneRules(required: boolean) { |
| | | const rules: any[] = []; |
| | | if (required) { |
| | | rules.push({ |
| | | required: true, |
| | | message: '请输入客户电话', |
| | | }); |
| | | } |
| | | rules.push({ |
| | | validator: (_: any, value: string) => { |
| | | if (!value) { |
| | | return Promise.resolve(); |
| | | } |
| | | return phonePattern.test(value) ? Promise.resolve() : Promise.reject('请输入正确的手机号码格式'); |
| | | }, |
| | | }); |
| | | return rules; |
| | | } |
| | | |
| | | function getEmailRules(required: boolean) { |
| | | const rules: any[] = []; |
| | | if (required) { |
| | | rules.push({ |
| | | required: true, |
| | | message: '请输入客户邮箱', |
| | | }); |
| | | } |
| | | rules.push({ |
| | | validator: (_: any, value: string) => { |
| | | if (!value) { |
| | | return Promise.resolve(); |
| | | } |
| | | return emailPattern.test(value) ? Promise.resolve() : Promise.reject('请输入正确的邮箱格式'); |
| | | }, |
| | | }); |
| | | return rules; |
| | | } |
| | | |
| | | // 查询用户角色并更新表单验证规则 |
| | | async function checkUserRoleAndUpdateSchema() { |
| | | try { |
| | |
| | | // 判断是否为代理商角色 |
| | | const isAgent = roleMessage.includes('代理商'); |
| | | |
| | | if (isAgent) { |
| | | // 代理商角色:客户电话和客户邮箱为非必填项 |
| | | updateSchema([ |
| | | { |
| | | field: 'customerPhone', |
| | | required: false, |
| | | rules: [ |
| | | { |
| | | pattern: /^1[3-9]\d{9}$/, |
| | | message: '请输入正确的手机号码格式', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | field: 'customerEmail', |
| | | required: false, |
| | | rules: [ |
| | | { |
| | | pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/, |
| | | message: '请输入正确的邮箱格式', |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | console.log('当前用户为代理商,客户电话和客户邮箱已设置为非必填'); |
| | | } else { |
| | | // 其他角色:保持必填 |
| | | updateSchema([ |
| | | { |
| | | field: 'customerPhone', |
| | | required: true, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入客户电话', |
| | | }, |
| | | { |
| | | pattern: /^1[3-9]\d{9}$/, |
| | | message: '请输入正确的手机号码格式', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | field: 'customerEmail', |
| | | required: true, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入客户邮箱', |
| | | }, |
| | | { |
| | | pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/, |
| | | message: '请输入正确的邮箱格式', |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | } |
| | | const schemaPayload = isAgent |
| | | ? [ |
| | | { |
| | | field: 'customerPhone', |
| | | required: false, |
| | | rules: getPhoneRules(false), |
| | | }, |
| | | { |
| | | field: 'customerEmail', |
| | | required: false, |
| | | rules: getEmailRules(false), |
| | | }, |
| | | ] |
| | | : [ |
| | | { |
| | | field: 'customerPhone', |
| | | required: true, |
| | | rules: getPhoneRules(true), |
| | | }, |
| | | { |
| | | field: 'customerEmail', |
| | | required: true, |
| | | rules: getEmailRules(true), |
| | | }, |
| | | ]; |
| | | |
| | | updateSchema(schemaPayload); |
| | | } else { |
| | | console.warn('查询用户角色失败:', response?.message); |
| | | } |