This commit is contained in:
wangzzpeng
2026-09-28 09:27:51 +08:00
parent 7bc84bbe5e
commit 6eb2bfcbfd
25 changed files with 2887 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
<script setup lang="ts">
// 业务类型图标(内联 SVG,无外部图标依赖)
// 每张卡的图标 = 浅色圆角底 + 类型主题色图形,配色取自需求提报设计稿
import type { BizIconKey } from '@/types/business/demand'
interface Props {
/** 图标标识(由 utils/bizTypeMeta.ts 的业务类型映射表给出) */
name: BizIconKey
/** 边长(设计稿为 40px) */
size?: number
}
withDefaults(defineProps<Props>(), { size: 40 })
</script>
<template>
<svg
class="biz-icon"
:width="size"
:height="size"
viewBox="0 0 40 40"
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<!-- 互联网软件:浅蓝底 + 代码尖括号 -->
<g v-if="name === 'code'">
<rect width="40" height="40" rx="8" fill="#e9f0ff" />
<path
d="M16.5 13.5 10 20l6.5 6.5M23.5 13.5 30 20l-6.5 6.5"
stroke="#2f6bff"
stroke-width="2.2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</g>
<!-- 硬件电路:浅绿底 + 芯片 -->
<g v-else-if="name === 'chip'">
<rect width="40" height="40" rx="8" fill="#eaf6e4" />
<rect x="12" y="12" width="16" height="16" rx="2.5" stroke="#4f9c25" stroke-width="2.2" />
<rect x="17" y="17" width="6" height="6" rx="1" fill="#4f9c25" />
<path
d="M17 8v4M23 8v4M17 28v4M23 28v4M8 17h4M8 23h4M28 17h4M28 23h4"
stroke="#4f9c25"
stroke-width="2"
stroke-linecap="round"
/>
</g>
<!-- 物联网全案:浅紫底 + 球体网格 -->
<g v-else-if="name === 'iot'">
<rect width="40" height="40" rx="8" fill="#f1e9fd" />
<circle cx="20" cy="20" r="10" stroke="#7a3fd6" stroke-width="2.2" />
<path
d="M20 10c3 3 3 17 0 20M20 10c-3 3-3 17 0 20M10.5 17h19M10.5 23h19"
stroke="#7a3fd6"
stroke-width="1.8"
stroke-linecap="round"
/>
</g>
<!-- 生产制造:浅橙底 + 厂房 -->
<g v-else-if="name === 'factory'">
<rect width="40" height="40" rx="8" fill="#fdf1e4" />
<path
d="M9 29V17l7 4.5V17l7 4.5V13l8 3v13z"
stroke="#d97c14"
stroke-width="2.2"
stroke-linejoin="round"
/>
<path
d="M13.5 29v-3.5M20 29v-3.5M26 29v-3.5"
stroke="#d97c14"
stroke-width="2"
stroke-linecap="round"
/>
</g>
<!-- 其他(含字典里未登记的类型):中性灰四宫格 -->
<g v-else>
<rect width="40" height="40" rx="8" fill="#f2f3f5" />
<rect x="12" y="12" width="7" height="7" rx="2" fill="#9aa3b0" />
<rect x="21" y="12" width="7" height="7" rx="2" fill="#9aa3b0" />
<rect x="12" y="21" width="7" height="7" rx="2" fill="#9aa3b0" />
<rect x="21" y="21" width="7" height="7" rx="2" fill="#9aa3b0" />
</g>
</svg>
</template>
<style lang="less" scoped>
.biz-icon {
display: block;
flex-shrink: 0;
}
</style>

View File

@@ -0,0 +1,129 @@
<script setup lang="ts">
// 底部固定操作条(设计稿:通栏白底 + 顶部细线;左侧提示 + 右侧三个按钮)
interface Props {
saving?: boolean
submitting?: boolean
}
const props = withDefaults(defineProps<Props>(), { saving: false, submitting: false })
const emit = defineEmits<{
'save-draft': []
reset: []
submit: []
}>()
</script>
<template>
<div class="demand-bar">
<div class="container demand-bar__inner">
<p class="demand-bar__tip">
<span class="demand-bar__info" aria-hidden="true">i</span>
提交后我们的专业顾问将在一个工作日内与您联系,为您提供一对一服务
</p>
<div class="demand-bar__actions">
<button
class="demand-bar__btn"
type="button"
:disabled="props.saving || props.submitting"
@click="emit('save-draft')"
>
{{ props.saving ? '保存中…' : '保存草稿' }}
</button>
<button
class="demand-bar__btn"
type="button"
:disabled="props.saving || props.submitting"
@click="emit('reset')"
>
重置
</button>
<button
class="demand-bar__btn demand-bar__btn--primary"
type="button"
:disabled="props.submitting"
@click="emit('submit')"
>
{{ props.submitting ? '提交中…' : '立即提报' }}
</button>
</div>
</div>
</div>
</template>
<style lang="less" scoped>
.demand-bar {
position: fixed;
right: 0;
bottom: 0;
left: 0;
z-index: 10;
border-top: 1px solid @border-color;
background: @white;
&__inner {
.flex(row, space-between, center);
height: 72px;
gap: @spacing-base;
}
&__tip {
.flex(row, flex-start, center);
gap: @spacing-sm;
min-width: 0;
font-size: @font-size-base;
color: @text-color;
}
&__info {
.flex(row, center, center);
flex-shrink: 0;
width: 16px;
height: 16px;
border: 1px solid @primary-color;
border-radius: 50%;
font-size: 11px;
font-style: normal;
font-weight: 600;
color: @primary-color;
}
&__actions {
.flex(row, flex-end, center);
gap: @spacing-base;
flex-shrink: 0;
}
&__btn {
height: 36px;
padding: 0 @spacing-lg;
border: none;
border-radius: @radius-round;
background: @demand-secondary-bg;
font-size: @font-size-base;
color: @heading-color;
cursor: pointer;
transition: background 0.2s, opacity 0.2s;
&:hover:not(:disabled) {
background: darken(@demand-secondary-bg, 6%);
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
&--primary {
// 设计稿按钮宽度(247px @1400 版面)由 min-width 兜住,短文案也不塌
min-width: 240px;
background: @primary-color;
color: @white;
&:hover:not(:disabled) {
background: @primary-hover;
}
}
}
}
</style>

View File

@@ -0,0 +1,336 @@
<script setup lang="ts">
// 附件上传行 + 附件列表(真实接口:POST /web/workOrderDraft/upload → SysOssVo)
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import type { DemandAttachment } from '@/types/business/demand'
import { formatFileSize } from '@/utils/format'
interface Props {
files: DemandAttachment[]
uploading?: boolean
}
const props = withDefaults(defineProps<Props>(), { uploading: false })
const emit = defineEmits<{
upload: [file: File]
remove: [file: DemandAttachment]
}>()
const inputRef = ref<HTMLInputElement | null>(null)
/** 与后端/UploadArea 同口径:单文件不超过 1G */
const MAX_SIZE = 1024 * 1024 * 1024
/** 文件类型标识色(设计稿里 PDF 红、Word 蓝等,按后缀归类) */
const FILE_TONES: Record<string, string> = {
pdf: '#f54a45',
doc: '#2f6bff',
docx: '#2f6bff',
xls: '#1f9d55',
xlsx: '#1f9d55',
csv: '#1f9d55',
ppt: '#f08a24',
pptx: '#f08a24',
zip: '#f08a24',
rar: '#f08a24',
'7z': '#f08a24',
png: '#7a3fd6',
jpg: '#7a3fd6',
jpeg: '#7a3fd6',
gif: '#7a3fd6',
webp: '#7a3fd6',
}
/** 缩写展示(长后缀截断,压缩包统一 ZIP) */
const FILE_LABELS: Record<string, string> = {
doc: 'DOC',
docx: 'DOC',
xls: 'XLS',
xlsx: 'XLS',
csv: 'CSV',
ppt: 'PPT',
pptx: 'PPT',
zip: 'ZIP',
rar: 'ZIP',
'7z': 'ZIP',
}
function suffixOf(file: DemandAttachment): string {
if (file.type) return file.type.replace(/^\./, '').toLowerCase()
const name = file.originalName ?? ''
const dot = name.lastIndexOf('.')
return dot >= 0 ? name.slice(dot + 1).toLowerCase() : ''
}
function toneOf(file: DemandAttachment): string {
return FILE_TONES[suffixOf(file)] ?? '#8a94a6'
}
function labelOf(file: DemandAttachment): string {
const suffix = suffixOf(file)
return FILE_LABELS[suffix] ?? (suffix ? suffix.slice(0, 3).toUpperCase() : 'FILE')
}
function pick(): void {
inputRef.value?.click()
}
function onChange(event: Event): void {
const input = event.target as HTMLInputElement
for (const file of Array.from(input.files ?? [])) {
if (file.size > MAX_SIZE) {
ElMessage.warning(`「${file.name}」超过1G,未上传`)
continue
}
emit('upload', file)
}
// 清空以便再次选择同一个文件
input.value = ''
}
/** 预览:OSS 地址浏览器可直接打开(图片 / PDF) */
function onPreview(file: DemandAttachment): void {
if (!file.url) return
window.open(file.url, '_blank', 'noopener')
}
/** 下载:a[download] 对跨域地址可能被忽略,加 target=_blank 兜底 */
function onDownload(file: DemandAttachment): void {
if (!file.url) return
const link = document.createElement('a')
link.href = file.url
link.download = file.originalName ?? ''
link.target = '_blank'
link.rel = 'noopener'
link.click()
}
</script>
<template>
<div class="demand-attach">
<div class="demand-attach__head">
<span class="demand-attach__label">附件上传</span>
<span class="demand-attach__hint">支持图片/文档/压缩包,大小不超过1G</span>
<button
class="demand-attach__pick"
type="button"
:disabled="props.uploading"
@click="pick"
>
{{ props.uploading ? '上传中…' : '上传文档' }}
</button>
<input
ref="inputRef"
class="demand-attach__input"
type="file"
multiple
@change="onChange"
>
</div>
<ul v-if="props.files.length > 0" class="demand-attach__list">
<li
v-for="(file, index) in props.files"
:key="`${file.ossId ?? file.originalName}-${index}`"
class="demand-attach__item"
>
<span
class="demand-attach__badge"
:style="{ color: toneOf(file), backgroundColor: `${toneOf(file)}1a` }"
>
{{ labelOf(file) }}
</span>
<div class="demand-attach__meta">
<span class="demand-attach__name" :title="file.originalName ?? ''">
{{ file.originalName }}
</span>
<span class="demand-attach__sub">
<template v-if="file.fileSize">{{ formatFileSize(file.fileSize) }} · </template>上传于 {{ file.createTime || '—' }}
</span>
</div>
<div class="demand-attach__acts">
<button
class="demand-attach__act"
type="button"
:disabled="!file.url"
@click="onPreview(file)"
>
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8s-2.4 4.5-6.5 4.5S1.5 8 1.5 8Z"
stroke="currentColor"
stroke-width="1.2"
/>
<circle cx="8" cy="8" r="1.8" stroke="currentColor" stroke-width="1.2" />
</svg>
预览
</button>
<button
class="demand-attach__act"
type="button"
:disabled="!file.url"
@click="onDownload(file)"
>
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="M8 2v8m0 0 3-3m-3 3L5 7M3 13h10"
stroke="currentColor"
stroke-width="1.2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
下载
</button>
<button
class="demand-attach__act demand-attach__act--danger"
type="button"
@click="emit('remove', file)"
>
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5 5 13h6l.5-8.5M6.8 7v3.5M9.2 7v3.5"
stroke="currentColor"
stroke-width="1.2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
删除
</button>
</div>
</li>
</ul>
</div>
</template>
<style lang="less" scoped>
.demand-attach {
.flex(column, flex-start, stretch);
gap: @spacing-sm;
&__head {
.flex(row, flex-start, center);
gap: @spacing-sm;
}
&__label {
font-size: @font-size-base;
font-weight: 600;
color: @heading-color;
}
&__hint {
flex: 1;
min-width: 0;
font-size: @font-size-sm;
color: @text-color-secondary;
}
&__pick {
flex-shrink: 0;
height: 28px;
padding: 0 @spacing-base;
border: 1px solid @border-color-dark;
border-radius: @radius-sm;
background: @white;
font-size: @font-size-sm;
color: @text-color;
cursor: pointer;
transition: border-color 0.2s, color 0.2s;
&:hover:not(:disabled) {
border-color: @primary-color;
color: @primary-color;
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
&__input {
display: none;
}
&__list {
.flex(column, flex-start, stretch);
gap: @spacing-sm;
margin: 0;
padding: 0;
list-style: none;
}
&__item {
.flex(row, flex-start, center);
gap: @spacing-sm;
padding: @spacing-sm @spacing-base;
border-radius: @radius-sm;
background: @bg-color-light;
}
&__badge {
.flex(row, center);
flex-shrink: 0;
width: 34px;
height: 34px;
border-radius: @radius-sm;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.2px;
}
&__meta {
.flex(column, flex-start, stretch);
flex: 1;
gap: 2px;
min-width: 0;
}
&__name {
font-size: @font-size-base;
color: @heading-color;
.ellipsis();
}
&__sub {
font-size: @font-size-sm;
color: @text-color-secondary;
}
&__acts {
.flex(row, flex-end, center);
gap: @spacing-base;
flex-shrink: 0;
}
&__act {
.flex(row, center, center);
gap: 4px;
font-size: @font-size-sm;
color: @text-color;
cursor: pointer;
transition: color 0.2s;
&:hover:not(:disabled) {
color: @primary-color;
}
&:disabled {
color: @text-color-disabled;
cursor: not-allowed;
}
&--danger {
color: @danger-color;
&:hover:not(:disabled) {
color: @danger-color;
opacity: 0.8;
}
}
}
}
</style>

View File

@@ -0,0 +1,132 @@
<script setup lang="ts">
// ① 选择业务类型:值域 100% 来自项目提报列表 /web/projectSubmission/list(接口有几条就渲染几张卡,
// 前端不额外追加「其他」;接口没下发就没有该选项)。
import type { BizTypeOption } from '@/types/business/demand'
import BizTypeIcon from './BizTypeIcon.vue'
interface Props {
options: BizTypeOption[]
modelValue: string
}
const props = defineProps<Props>()
const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
</script>
<template>
<div class="biz-types">
<!-- 接口一条都没下发时给一行说明:不是渲染失败,而是确实没有可选类型(前端不造兜底项) -->
<p v-if="!props.options.length" class="biz-types__empty">暂无可选业务类型</p>
<div v-else class="biz-types__grid">
<button
v-for="option in props.options"
:key="option.value"
class="biz-types__card"
:class="{ 'is-active': props.modelValue === option.value }"
type="button"
@click="emit('update:modelValue', option.value)"
>
<span class="biz-types__check" aria-hidden="true" />
<!-- 后端 Logo(已换链为可访问地址)优先,取不到时回退前端内联 SVG -->
<img
v-if="option.iconUrl"
class="biz-types__logo"
:src="option.iconUrl"
:alt="option.label"
>
<BizTypeIcon
v-else
class="biz-types__icon"
:name="option.icon"
:size="40"
/>
<span class="biz-types__name">{{ option.label }}</span>
<span v-if="option.desc" class="biz-types__desc">{{ option.desc }}</span>
</button>
</div>
</div>
</template>
<style lang="less" scoped>
.biz-types {
&__empty {
padding: @spacing-base 0;
font-size: @font-size-sm;
color: @text-color-secondary;
}
&__grid {
// auto-fill(不是 auto-fit):条目不足 5 个时保留空轨道,卡片尺寸与设计稿一致(约 251px),
// 不会被拉伸变形;满 5 个时正好落在设计稿的 5 列上。
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: @spacing-base;
}
&__card {
position: relative;
.flex(column, flex-start, stretch);
gap: @spacing-xs;
padding: @spacing-base;
border: 1px solid @border-color;
border-radius: @radius-base;
background: @white;
text-align: left;
cursor: pointer;
transition: border-color 0.2s, background 0.2s;
&:hover {
border-color: @demand-accent;
}
&.is-active {
border-color: @demand-accent;
background: @demand-selected-bg;
}
}
/** 右上角选中标记:未选为空心圈,选中为实心蓝点 */
&__check {
position: absolute;
top: 12px;
right: 12px;
width: 16px;
height: 16px;
border: 1px solid @border-color-dark;
border-radius: 50%;
background: @white;
transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
&__card.is-active &__check {
border-color: @demand-accent;
background: @demand-accent;
box-shadow: inset 0 0 0 3px @demand-selected-bg;
}
&__icon {
margin-bottom: @spacing-xs;
}
/** 后端 Logo:与内联 SVG 同尺寸,保证两种来源视觉一致 */
&__logo {
width: 40px;
height: 40px;
margin-bottom: @spacing-xs;
object-fit: contain;
}
&__name {
font-size: @font-size-lg;
font-weight: 600;
color: @heading-color;
}
&__desc {
font-size: @font-size-sm;
color: @text-color-secondary;
line-height: 1.5;
}
}
</style>

View File

@@ -0,0 +1,126 @@
<script setup lang="ts">
// ③ 确认信息并补充备注:用户名称 / 用户手机号(登录账号资料预填)+ 补充备注
import { computed } from 'vue'
import type { Demand } from '@/types/business/demand'
interface Props {
demand: Demand
}
const props = defineProps<Props>()
const emit = defineEmits<{ update: [partial: Partial<Demand>] }>()
const REMARK_MAX = 500
const remarkLength = computed(() => props.demand.supplementaryRemarks.length)
function onUserName(event: Event): void {
emit('update', { userName: (event.target as HTMLInputElement).value })
}
function onUserPhone(event: Event): void {
emit('update', { userPhone: (event.target as HTMLInputElement).value })
}
function onRemark(event: Event): void {
emit('update', { supplementaryRemarks: (event.target as HTMLTextAreaElement).value })
}
</script>
<template>
<div class="demand-confirm">
<div class="demand-confirm__row">
<div class="demand-confirm__field">
<label class="demand-confirm__label" for="demand-user-name">用户名称</label>
<input
id="demand-user-name"
class="demand-confirm__input"
type="text"
maxlength="30"
:value="props.demand.userName"
placeholder="请输入用户名称"
@input="onUserName"
>
</div>
<div class="demand-confirm__field">
<label class="demand-confirm__label" for="demand-user-phone">用户手机号</label>
<input
id="demand-user-phone"
class="demand-confirm__input"
type="tel"
maxlength="30"
:value="props.demand.userPhone"
placeholder="请输入用户手机号"
@input="onUserPhone"
>
</div>
</div>
<div class="demand-confirm__field">
<label class="demand-confirm__label" for="demand-remark">补充备注</label>
<div class="demand-confirm__area">
<textarea
id="demand-remark"
class="demand-confirm__textarea"
:maxlength="REMARK_MAX"
:value="props.demand.supplementaryRemarks"
placeholder="其他需要说明的事项…"
@input="onRemark"
/>
<span class="demand-confirm__count">{{ remarkLength }}/{{ REMARK_MAX }}字</span>
</div>
</div>
</div>
</template>
<style lang="less" scoped>
.demand-confirm {
.flex(column, flex-start, stretch);
gap: @spacing-lg;
&__row {
.flex(row, flex-start, stretch);
gap: @spacing-base;
}
&__field {
.flex(column, flex-start, stretch);
flex: 1 1 50%;
gap: @spacing-sm;
min-width: 0;
}
&__label {
font-size: @font-size-base;
font-weight: 600;
color: @heading-color;
}
&__input {
.text-control();
height: 36px;
}
&__area {
position: relative;
width: 100%;
}
&__textarea {
.text-control();
min-height: 132px;
padding: @spacing-sm @spacing-base 24px;
line-height: 1.7;
resize: vertical;
}
&__count {
position: absolute;
right: @spacing-sm;
bottom: @spacing-xs;
font-size: @font-size-sm;
color: @text-color-secondary;
}
}
</style>

View File

@@ -0,0 +1,297 @@
<script setup lang="ts">
// ② 填写需求信息:项目名称 / 核心需求描述 / 预算范围 + 预计开发周期 / 附件上传
//
// 预算范围:值域来自字典 vm_budget_range,5 项同排等宽。
// 前 4 项 → 胶囊按钮(点选 = 选中该档位)
// 最后一项(字典 label「手填」)→ **本身就是一个输入框**,占位文案就是「手填」,
// 直接在里面写金额;不再有"点一下额外展开一个输入框"的交互。
// 手写内容直接写进 form.budgetRange(后端没有 budgetCustom 的落库位置),故限长 30。
import { computed, ref } from 'vue'
import type { Demand, DemandAttachment, DictOption } from '@/types/business/demand'
import { MANUAL_BUDGET_MAX, isManualBudget } from '@/utils/budgetMeta'
import DemandAttachments from './DemandAttachments.vue'
interface Props {
demand: Demand
/** 预算范围选项(字典 vm_budget_range,手填项已由 store 排到最后) */
budgetOptions: DictOption[]
/** 附件是否正在上传(透传给附件区做按钮禁用) */
uploading?: boolean
}
const props = withDefaults(defineProps<Props>(), { uploading: false })
const emit = defineEmits<{
update: [partial: Partial<Demand>]
upload: [file: File]
'remove-file': [file: DemandAttachment]
}>()
const DESCRIPTION_MAX = 500
const descLength = computed(() => props.demand.requirementDesc.length)
/** 前 4 项:普通胶囊按钮 */
const presetOptions = computed(() =>
props.budgetOptions.filter((option) => !isManualBudget(option.dictLabel)),
)
/** 最后一项:输入框(占位文案直接用字典 label,后端为「手填」) */
const manualOption = computed(
() => props.budgetOptions.find((option) => isManualBudget(option.dictLabel)) ?? null,
)
const manualPlaceholder = computed(() => manualOption.value?.dictLabel ?? '手填')
/** 输入框聚焦中(用于"刚点进来还没打字"时也给选中态反馈) */
const manualFocused = ref(false)
/** 输入框 DOM 引用(点预设时要把它真的失焦) */
const manualInput = ref<HTMLInputElement | null>(null)
/** 当前是否选中了某个预设胶囊(用于保证"恰有一个控件高亮") */
const presetSelected = computed(() =>
presetOptions.value.some((option) => option.dictValue === props.demand.budgetRange),
)
/** 输入框选中态:已写入手填内容,或正在输入且此时没有选中预设 */
const manualActive = computed(() =>
props.demand.budgetManual || (manualFocused.value && !presetSelected.value),
)
/** 输入框显示值:非手填模式下留空,把位置让给占位文案 */
const manualValue = computed(() => (props.demand.budgetManual ? props.demand.budgetRange : ''))
function onProjectName(event: Event): void {
emit('update', { projectName: (event.target as HTMLInputElement).value })
}
function onDescription(event: Event): void {
emit('update', { requirementDesc: (event.target as HTMLTextAreaElement).value })
}
function onCycle(event: Event): void {
const raw = (event.target as HTMLInputElement).value
emit('update', { developmentCycle: raw === '' ? '' : Number(raw) })
}
/** 预设胶囊是否选中(手填模式下预设一律不选中,避免两个控件同时高亮) */
function isPresetActive(option: DictOption): boolean {
return !props.demand.budgetManual && props.demand.budgetRange === option.dictValue
}
function onBudget(option: DictOption): void {
// 先让输入框真的失焦,避免"在输入框里打完字又改点档位"时两个控件同时高亮
manualFocused.value = false
manualInput.value?.blur()
emit('update', { budgetRange: option.dictValue, budgetManual: false })
}
/** 在输入框里打字即进入手写模式,内容直接作为 budgetRange */
function onBudgetManualInput(event: Event): void {
emit('update', { budgetRange: (event.target as HTMLInputElement).value, budgetManual: true })
}
/** 失焦时若一个字都没写,退回"未选择"(避免空手写值卡住提交校验) */
function onBudgetManualBlur(event: Event): void {
manualFocused.value = false
if ((event.target as HTMLInputElement).value.trim() === '') {
emit('update', { budgetRange: '', budgetManual: false })
}
}
</script>
<template>
<div class="demand-info">
<div class="demand-info__field">
<label class="demand-info__label" for="demand-project-name">
项目名称<span class="demand-info__required">*</span>
</label>
<input
id="demand-project-name"
class="demand-info__input"
type="text"
maxlength="100"
:value="props.demand.projectName"
placeholder="请输入项目名称"
@input="onProjectName"
>
</div>
<div class="demand-info__field">
<label class="demand-info__label" for="demand-description">
核心需求描述<span class="demand-info__required">*</span>
</label>
<div class="demand-info__area">
<textarea
id="demand-description"
class="demand-info__textarea"
:maxlength="DESCRIPTION_MAX"
:value="props.demand.requirementDesc"
placeholder="请详细描述您的需求,包括功能模块、使用场景、目标用户等…"
@input="onDescription"
/>
<span class="demand-info__count">{{ descLength }}/{{ DESCRIPTION_MAX }}字</span>
</div>
</div>
<div class="demand-info__row">
<div class="demand-info__field">
<span class="demand-info__label">预算范围</span>
<div class="demand-info__budgets">
<button
v-for="option in presetOptions"
:key="option.dictValue"
class="demand-info__budget"
:class="{ 'is-active': isPresetActive(option) }"
type="button"
@click="onBudget(option)"
>
{{ option.dictLabel }}
</button>
<!-- 第 5 个控件即输入框:直接写金额(后端 budgetRange 列 varchar(30),故限长 30) -->
<input
v-if="manualOption"
id="demand-budget-manual"
ref="manualInput"
class="demand-info__budget demand-info__budget--manual"
:class="{ 'is-active': manualActive }"
type="text"
:maxlength="MANUAL_BUDGET_MAX"
:value="manualValue"
:placeholder="manualPlaceholder"
:title="manualPlaceholder"
@input="onBudgetManualInput"
@focus="manualFocused = true"
@blur="onBudgetManualBlur"
>
</div>
</div>
<div class="demand-info__field">
<label class="demand-info__label" for="demand-cycle">预计开发周期</label>
<input
id="demand-cycle"
class="demand-info__input"
type="number"
min="1"
:value="props.demand.developmentCycle"
placeholder="请输入预计开发周期(工作日)"
@input="onCycle"
>
</div>
</div>
<DemandAttachments
:files="props.demand.attachmentInfo"
:uploading="props.uploading"
@upload="(file) => emit('upload', file)"
@remove="(file) => emit('remove-file', file)"
/>
</div>
</template>
<style lang="less" scoped>
.demand-info {
.flex(column, flex-start, stretch);
gap: @spacing-lg;
&__field {
.flex(column, flex-start, stretch);
gap: @spacing-sm;
min-width: 0;
}
&__row {
.flex(row, flex-start, stretch);
gap: @spacing-base;
.demand-info__field {
flex: 1 1 50%;
width: 50%;
}
}
&__label {
font-size: @font-size-base;
font-weight: 600;
color: @heading-color;
}
&__required {
margin-left: 2px;
color: @danger-color;
}
&__input {
.text-control();
height: 36px;
}
&__area {
position: relative;
width: 100%;
}
&__textarea {
.text-control();
min-height: 132px;
padding: @spacing-sm @spacing-base 24px;
line-height: 1.7;
resize: vertical;
}
&__count {
position: absolute;
right: @spacing-sm;
bottom: @spacing-xs;
font-size: @font-size-sm;
color: @text-color-secondary;
}
&__budgets {
.flex(row, flex-start, stretch);
gap: @spacing-base;
}
/** 预算控件外观:4 个胶囊按钮 + 第 5 个手填输入框共用同一套规格 */
&__budget {
flex: 1;
min-width: 0;
height: 36px;
padding: 0 @spacing-sm;
border: 1px solid @border-color;
border-radius: @radius-sm;
background: @white;
font-size: @font-size-base;
font-family: inherit;
color: @text-color;
text-align: center;
cursor: pointer;
transition: all 0.2s;
box-sizing: border-box;
&:hover {
border-color: @demand-accent;
color: @demand-accent;
}
&.is-active {
border-color: @demand-accent;
background: @demand-selected-bg;
color: @demand-accent;
font-weight: 600;
}
}
/** 手填输入框:外观同胶囊,占位文案即「手填」 */
&__budget--manual {
outline: none;
&::placeholder {
font-weight: 400;
color: @text-color-secondary;
}
}
}
</style>