PlanDetail.vue 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716
  1. <template>
  2. <div class="plan-detail page-container">
  3. <!-- Page Header -->
  4. <PageHeader :title="plan.name || '方案详情'" :subtitle="subtitleText">
  5. <template #actions>
  6. <el-button @click="goBack">
  7. <el-icon><ArrowLeft /></el-icon> 返回
  8. </el-button>
  9. <el-button v-if="!isRunning" type="primary" @click="startSimulation" :loading="starting || preflightLoading">
  10. <el-icon><VideoPlay /></el-icon> 启动仿真
  11. </el-button>
  12. <el-button v-else type="danger" @click="stopSimulation" :loading="stopping">
  13. <el-icon><VideoPause /></el-icon> 停止仿真
  14. </el-button>
  15. <el-button @click="showUpload = true">
  16. <el-icon><Upload /></el-icon> 上传结果
  17. </el-button>
  18. </template>
  19. </PageHeader>
  20. <!-- Running Progress Banner -->
  21. <div v-if="isRunning" class="progress-banner">
  22. <div class="progress-info">
  23. <span class="status-dot running" />
  24. <span class="progress-title">仿真运行中</span>
  25. <span class="progress-detail">
  26. {{ activeTask?.completed_points || 0 }} / {{ activeTask?.total_points || 0 }} 点
  27. · {{ activeTask?.progress || 0 }}%
  28. · 预计剩余 {{ estimatedRemaining }}
  29. </span>
  30. </div>
  31. <el-progress
  32. :percentage="activeTask?.progress || 0"
  33. :stroke-width="6"
  34. class="progress-bar"
  35. />
  36. </div>
  37. <!-- Main Tabs -->
  38. <el-tabs v-model="activeTab" class="plan-tabs">
  39. <!-- ========== Tab 1: Overview ========== -->
  40. <el-tab-pane label="概览" name="overview">
  41. <!-- Stat Cards -->
  42. <el-row :gutter="16" class="stat-row">
  43. <el-col :span="6">
  44. <StatCard label="扫描变量数" :value="scanVariables.length" unit="个" />
  45. </el-col>
  46. <el-col :span="6">
  47. <StatCard label="固定参数" :value="fixedParams.length" unit="项" />
  48. </el-col>
  49. <el-col :span="6">
  50. <StatCard label="预计数据点" :value="estimatedPoints" unit="点" />
  51. </el-col>
  52. <el-col :span="6">
  53. <StatCard
  54. label="预计耗时"
  55. :value="estimatedTimeMin"
  56. unit="分钟"
  57. :valueColor="estimatedTimeMin > 120 ? 'var(--color-warning)' : ''"
  58. />
  59. <div class="est-basis">{{ estimatedTimeBasis }}</div>
  60. </el-col>
  61. </el-row>
  62. <!-- AI Design Rationale -->
  63. <SectionCard title="AI 设计思路" v-if="plan.ai_reasoning">
  64. <div class="ai-reasoning">{{ plan.ai_reasoning }}</div>
  65. </SectionCard>
  66. <!-- Acceptance Criteria -->
  67. <SectionCard title="验收标准">
  68. <div v-if="acceptanceItems.length" class="criteria-list">
  69. <div v-for="(c, idx) in acceptanceItems" :key="idx" class="criteria-item">
  70. <el-icon class="criteria-icon"><CircleCheck /></el-icon>
  71. <span class="criteria-text">{{ c.text }}</span>
  72. <el-tag size="small" effect="plain" :type="c.origin === 'AI 设定' ? 'primary' : 'warning'" class="criteria-origin">{{ c.origin }}</el-tag>
  73. </div>
  74. </div>
  75. <el-empty v-else description="暂无验收标准,可在边界条件中设置目标转矩/效率/损耗等" :image-size="60" />
  76. </SectionCard>
  77. <!-- Latest Results Summary -->
  78. <SectionCard
  79. v-if="results.length"
  80. title="最新结果摘要"
  81. :subtitle="`共 ${results.length} 个数据点`"
  82. >
  83. <template #actions>
  84. <el-button size="small" text type="primary" @click="activeTab = 'results'">
  85. 查看全部 <el-icon><ArrowRight /></el-icon>
  86. </el-button>
  87. </template>
  88. <el-table :data="results.slice(0, 5)" size="small" border>
  89. <el-table-column label="#" type="index" width="50" />
  90. <el-table-column v-for="col in coreResultColumns" :key="col.key" :prop="col.key" :label="col.label" min-width="110" align="right">
  91. <template #default="{ row }">
  92. <el-tooltip
  93. v-if="col.key === 'status' && isFailed(row) && row.error_message"
  94. :content="row.error_message"
  95. placement="top"
  96. :show-after="100"
  97. raw-content
  98. >
  99. <span class="text-danger status-failed-cell">{{ formatCell(row[col.key]) }}</span>
  100. </el-tooltip>
  101. <span v-else :class="{ 'text-danger': isFailed(row) }">{{ formatCell(row[col.key]) }}</span>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. </SectionCard>
  106. <!-- Quick Actions -->
  107. <SectionCard title="快捷操作">
  108. <div class="quick-actions">
  109. <div class="quick-action-card" @click="activeTab = 'parameters'">
  110. <el-icon :size="24" color="var(--color-primary)"><Setting /></el-icon>
  111. <div class="qa-title">编辑参数</div>
  112. <div class="qa-desc">扫描变量、边界条件、固定参数</div>
  113. </div>
  114. <div class="quick-action-card" @click="activeTab = 'results'">
  115. <el-icon :size="24" color="var(--color-success)"><DataAnalysis /></el-icon>
  116. <div class="qa-title">查看结果</div>
  117. <div class="qa-desc">{{ results.length }} 个数据点</div>
  118. </div>
  119. <div class="quick-action-card" @click="activeTab = 'ai'">
  120. <el-icon :size="24" color="#7c3aed"><MagicStick /></el-icon>
  121. <div class="qa-title">AI 闭环</div>
  122. <div class="qa-desc">分析、迭代、经验提取</div>
  123. </div>
  124. <div class="quick-action-card" @click="downloadResults">
  125. <el-icon :size="24" color="var(--color-warning)"><Download /></el-icon>
  126. <div class="qa-title">下载结果</div>
  127. <div class="qa-desc">CSV / JSON 格式</div>
  128. </div>
  129. </div>
  130. </SectionCard>
  131. </el-tab-pane>
  132. <!-- ========== Tab 2: Parameters ========== -->
  133. <el-tab-pane label="方案参数" name="parameters">
  134. <!-- Scan Variables -->
  135. <SectionCard title="扫描变量">
  136. <template #actions>
  137. <el-button v-if="scanVarsDirty" size="small" type="warning" :loading="savingVars" @click="saveScanVariables">
  138. 保存修改
  139. </el-button>
  140. <el-button size="small" type="primary" @click="showAddVar = true">
  141. <el-icon><Plus /></el-icon> 添加变量
  142. </el-button>
  143. </template>
  144. <el-table :data="scanVariables" size="small" border>
  145. <el-table-column prop="name" label="变量名" min-width="140" />
  146. <el-table-column prop="name_cn" label="中文名" min-width="120" />
  147. <el-table-column label="取值" min-width="200">
  148. <template #default="{ row }">
  149. <span v-if="Array.isArray(row.values) && row.values.length" class="var-values">{{ row.values.join(' / ') }}</span>
  150. <span v-else>{{ row.min_value }} ~ {{ row.max_value }} (步长 {{ row.step }})</span>
  151. </template>
  152. </el-table-column>
  153. <el-table-column prop="unit" label="单位" width="80" align="center" />
  154. <el-table-column label="点数" width="80" align="center">
  155. <template #default="{ row }">{{ calcPoints(row) }}</template>
  156. </el-table-column>
  157. <el-table-column label="操作" width="100" fixed="right">
  158. <template #default="{ row, $index }">
  159. <el-button size="small" link type="danger" @click="removeVariable($index)">删除</el-button>
  160. </template>
  161. </el-table-column>
  162. </el-table>
  163. <el-empty v-if="!scanVariables.length" description="暂无扫描变量,点击添加" :image-size="60" />
  164. </SectionCard>
  165. <!-- Boundary Conditions -->
  166. <SectionCard title="边界条件">
  167. <template #actions>
  168. <template v-if="!bcEditing">
  169. <el-button size="small" @click="startBcEdit">
  170. <el-icon><Edit /></el-icon> 编辑
  171. </el-button>
  172. </template>
  173. <template v-else>
  174. <el-button size="small" @click="bcEditing = false">取消</el-button>
  175. <el-button size="small" type="primary" :loading="bcSaving" @click="saveBcEdit">保存</el-button>
  176. </template>
  177. </template>
  178. <el-descriptions :column="3" border size="small">
  179. <el-descriptions-item
  180. v-for="bc in boundaryConditions"
  181. :key="bc.key"
  182. :label="bc.label"
  183. >
  184. <template #label>
  185. <span>{{ bc.label }}</span>
  186. <el-tag
  187. v-if="bc.source === 'user'"
  188. size="small" effect="plain" type="success" class="bc-source-tag"
  189. >用户指定</el-tag>
  190. <el-tag
  191. v-else-if="bc.source === 'ai'"
  192. size="small" effect="plain" type="primary" class="bc-source-tag"
  193. >AI 补充</el-tag>
  194. <el-tag
  195. v-else-if="bc.source === 'edited'"
  196. size="small" effect="plain" type="warning" class="bc-source-tag"
  197. >已修改</el-tag>
  198. </template>
  199. <template v-if="bcEditing">
  200. <el-select
  201. v-if="bc.type === 'enum'"
  202. v-model="bcEditForm[bc.key]"
  203. clearable
  204. placeholder="未设置"
  205. size="small"
  206. style="width: 100%"
  207. >
  208. <el-option v-for="opt in bc.options" :key="opt" :label="opt" :value="opt" />
  209. </el-select>
  210. <el-input-number
  211. v-else
  212. v-model="bcEditForm[bc.key]"
  213. :precision="bc.type === 'int' ? 0 : 2"
  214. :placeholder="'未设置'"
  215. controls-position="right"
  216. size="small"
  217. style="width: 100%"
  218. />
  219. </template>
  220. <template v-else>
  221. {{ bc.value !== undefined && bc.value !== null && bc.value !== '' ? bc.value + (bc.unit ? ' ' + bc.unit : '') : '未设置' }}
  222. </template>
  223. </el-descriptions-item>
  224. </el-descriptions>
  225. </SectionCard>
  226. <!-- Fixed Parameters (collapsible) -->
  227. <SectionCard title="固定参数">
  228. <template #actions>
  229. <span class="fixed-summary">
  230. {{ modifiedFixedParams.length }} 项已修改 / 共 {{ fixedParams.length }} 项
  231. </span>
  232. <el-button size="small" @click="showAllFixed = !showAllFixed">
  233. {{ showAllFixed ? '只看修改项' : '全部展开' }}
  234. </el-button>
  235. <template v-if="!fixedEditing">
  236. <el-button size="small" @click="startFixedEdit">
  237. <el-icon><Edit /></el-icon> 编辑
  238. </el-button>
  239. </template>
  240. <template v-else>
  241. <el-button size="small" @click="fixedEditing = false">取消</el-button>
  242. <el-button size="small" type="primary" :loading="fixedSaving" @click="saveFixedParams">保存</el-button>
  243. </template>
  244. </template>
  245. <!-- Modified params always visible -->
  246. <div v-if="modifiedFixedParams.length" class="fixed-modified">
  247. <div class="fixed-group-title">
  248. <el-icon><Star /></el-icon> 已修改参数
  249. </div>
  250. <el-table :data="modifiedFixedParams" size="small" border>
  251. <el-table-column prop="name_cn" label="参数" min-width="140" />
  252. <el-table-column prop="name" label="Motor-CAD 变量" min-width="160">
  253. <template #default="{ row }">
  254. <code class="var-code">{{ row.motorcad_var || row.name }}</code>
  255. </template>
  256. </el-table-column>
  257. <el-table-column label="当前值" width="120" align="right">
  258. <template #default="{ row }">
  259. <span class="modified-value">{{ row.value }}</span>
  260. </template>
  261. </el-table-column>
  262. <el-table-column label="默认值" width="100" align="center">
  263. <template #default="{ row }">
  264. <span class="text-muted">{{ getDefaultValue(row.name) }}</span>
  265. </template>
  266. </el-table-column>
  267. <el-table-column prop="unit" label="单位" width="70" align="center" />
  268. <el-table-column prop="category_cn" label="分类" width="100" align="center" />
  269. </el-table>
  270. </div>
  271. <!-- All params (collapsible by category) -->
  272. <div v-if="showAllFixed" class="fixed-all">
  273. <div v-for="cat in fixedCategories" :key="cat" class="fixed-category">
  274. <div class="fixed-category-title" @click="toggleCategory(cat)">
  275. <el-icon class="cat-arrow">
  276. <ArrowDown v-if="expandedCategories[cat] !== false" />
  277. <ArrowRight v-else />
  278. </el-icon>
  279. {{ cat }}
  280. <span class="cat-count">({{ fixedParamsByCategory(cat).length }})</span>
  281. </div>
  282. <el-table
  283. v-if="expandedCategories[cat] !== false"
  284. :data="fixedParamsByCategory(cat)"
  285. size="small"
  286. border
  287. >
  288. <el-table-column prop="name_cn" label="参数" min-width="130" />
  289. <el-table-column prop="name" label="变量名" min-width="150">
  290. <template #default="{ row }">
  291. <code class="var-code">{{ row.motorcad_var || row.name }}</code>
  292. <el-tag v-if="row.description_cn?.includes('需确认')" size="small" type="warning" effect="plain">需确认</el-tag>
  293. </template>
  294. </el-table-column>
  295. <el-table-column label="值" width="140" align="right">
  296. <template #default="{ row }">
  297. <template v-if="fixedEditing">
  298. <el-select
  299. v-if="typeof row.value === 'boolean' || row.value === 'True' || row.value === 'False'"
  300. v-model="fixedEditValues[row.name]"
  301. size="small"
  302. style="width: 110px"
  303. >
  304. <el-option label="True" value="True" />
  305. <el-option label="False" value="False" />
  306. </el-select>
  307. <el-input-number
  308. v-else-if="!isNaN(Number(row.value)) && String(row.value).trim() !== ''"
  309. v-model="fixedEditValues[row.name]"
  310. :precision="Number.isInteger(Number(row.value)) ? 0 : 4"
  311. controls-position="right"
  312. size="small"
  313. style="width: 130px"
  314. />
  315. <el-input v-else v-model="fixedEditValues[row.name]" size="small" style="width: 130px" />
  316. </template>
  317. <span v-else :class="{ 'modified-value': isFixedModified(row) }">{{ row.value }}</span>
  318. </template>
  319. </el-table-column>
  320. <el-table-column prop="unit" label="单位" width="70" align="center" />
  321. <el-table-column prop="description_cn" label="说明" min-width="140" show-overflow-tooltip />
  322. </el-table>
  323. </div>
  324. </div>
  325. <el-empty
  326. v-if="!modifiedFixedParams.length && !showAllFixed"
  327. description="所有参数均为默认值"
  328. :image-size="60"
  329. />
  330. </SectionCard>
  331. </el-tab-pane>
  332. <!-- ========== Tab 3: Results ========== -->
  333. <el-tab-pane :label="`仿真结果 (${results.length})`" name="results">
  334. <SectionCard title="仿真结果" no-padding>
  335. <template #actions>
  336. <el-button size="small" @click="openColumnSettings" :disabled="!results.length">
  337. <el-icon><Setting /></el-icon> 列设置
  338. </el-button>
  339. <el-button size="small" @click="downloadResults" :disabled="!results.length">
  340. <el-icon><Download /></el-icon> 下载 CSV
  341. </el-button>
  342. </template>
  343. <el-table :data="results" size="small" border max-height="600">
  344. <el-table-column label="#" type="index" width="50" fixed="left" />
  345. <el-table-column
  346. v-for="col in displayColumns"
  347. :key="col.key"
  348. :prop="col.key"
  349. :label="col.label"
  350. :min-width="col.width || 110"
  351. align="right"
  352. >
  353. <template #default="{ row }">
  354. <el-tooltip
  355. v-if="col.key === 'status' && isFailed(row) && row.error_message"
  356. :content="row.error_message"
  357. placement="top"
  358. :show-after="100"
  359. raw-content
  360. >
  361. <span class="text-danger status-failed-cell">{{ formatCell(row[col.key]) }}</span>
  362. </el-tooltip>
  363. <span v-else :class="{ 'text-danger': isFailed(row) }">{{ formatCell(row[col.key]) }}</span>
  364. </template>
  365. </el-table-column>
  366. </el-table>
  367. <el-empty v-if="!results.length" description="暂无仿真结果" :image-size="80" />
  368. </SectionCard>
  369. </el-tab-pane>
  370. <!-- ========== Tab 4: AI Loop ========== -->
  371. <el-tab-pane label="AI 闭环" name="ai">
  372. <!-- Step indicator -->
  373. <el-steps :active="aiStep" finish-status="success" align-center class="ai-steps">
  374. <el-step title="AI 分析" description="分析当前结果" />
  375. <el-step title="生成迭代" description="生成下一轮方案" />
  376. <el-step title="提取经验" description="沉淀到经验库" />
  377. </el-steps>
  378. <!-- Step 1: AI Analysis -->
  379. <SectionCard title="1. AI 结果分析">
  380. <template #actions>
  381. <el-button
  382. size="small"
  383. type="primary"
  384. :loading="analyzing"
  385. @click="runAIAnalysis"
  386. :disabled="!results.length"
  387. >
  388. <el-icon><MagicStick /></el-icon> 运行分析
  389. </el-button>
  390. </template>
  391. <div v-if="aiAnalysis" class="ai-analysis-content">
  392. <div class="ai-section">
  393. <div class="ai-section-title">关键发现</div>
  394. <div class="ai-section-body">{{ aiAnalysis.findings || '暂无' }}</div>
  395. </div>
  396. <div class="ai-section">
  397. <div class="ai-section-title">优化建议</div>
  398. <div class="ai-section-body">{{ aiAnalysis.suggestions || '暂无' }}</div>
  399. </div>
  400. </div>
  401. <el-empty v-else description="点击运行 AI 分析当前仿真结果" :image-size="60" />
  402. </SectionCard>
  403. <!-- Step 2: Generate Iteration -->
  404. <SectionCard title="2. 生成下一轮迭代方案">
  405. <template #actions>
  406. <el-button
  407. size="small"
  408. type="primary"
  409. :loading="generating"
  410. @click="generateIteration"
  411. :disabled="!aiAnalysis"
  412. >
  413. <el-icon><RefreshRight /></el-icon> 生成迭代方案
  414. </el-button>
  415. </template>
  416. <div v-if="iterationPlan" class="iteration-content">
  417. <el-alert
  418. :title="`迭代方案已生成:${iterationPlan.name || '新方案'}`"
  419. type="success"
  420. :closable="false"
  421. show-icon
  422. />
  423. <div class="mt-3">
  424. <el-button type="primary" @click="viewIteration">查看迭代方案</el-button>
  425. </div>
  426. </div>
  427. <el-empty v-else description="先运行 AI 分析,再生成迭代方案" :image-size="60" />
  428. </SectionCard>
  429. <!-- Step 3: Extract Experience -->
  430. <SectionCard title="3. 提取经验入库">
  431. <template #actions>
  432. <el-button
  433. size="small"
  434. type="primary"
  435. :loading="extracting"
  436. @click="extractExperience"
  437. :disabled="!results.length"
  438. >
  439. <el-icon><Collection /></el-icon> 提取经验
  440. </el-button>
  441. </template>
  442. <div v-if="experienceExtracted" class="experience-content">
  443. <el-alert title="经验已成功提取到经验库" type="success" :closable="false" show-icon />
  444. <div class="mt-3">
  445. <el-button @click="$router.push('/experience')">查看经验库</el-button>
  446. </div>
  447. </div>
  448. <el-empty v-else description="将本次仿真的关键参数和结论提取为经验" :image-size="60" />
  449. </SectionCard>
  450. </el-tab-pane>
  451. </el-tabs>
  452. <!-- Add Variable Dialog -->
  453. <el-dialog v-model="showAddVar" title="添加扫描变量" width="500px">
  454. <el-form :model="newVar" label-width="100px">
  455. <el-form-item label="变量名">
  456. <el-select v-model="newVar.name" filterable placeholder="选择 Motor-CAD 变量" @change="onVarSelect">
  457. <el-option
  458. v-for="v in availableScanParams"
  459. :key="v.name"
  460. :label="`${v.name_cn} (${v.name}) -> ${v.motorcad_var}`"
  461. :value="v.name"
  462. />
  463. </el-select>
  464. </el-form-item>
  465. <el-form-item label="最小值">
  466. <el-input-number v-model="newVar.min_value" :precision="4" controls-position="right" style="width: 100%" />
  467. </el-form-item>
  468. <el-form-item label="最大值">
  469. <el-input-number v-model="newVar.max_value" :precision="4" controls-position="right" style="width: 100%" />
  470. </el-form-item>
  471. <el-form-item label="步长">
  472. <el-input-number v-model="newVar.step" :precision="4" :min="0.0001" controls-position="right" style="width: 100%" />
  473. </el-form-item>
  474. </el-form>
  475. <template #footer>
  476. <el-button @click="showAddVar = false">取消</el-button>
  477. <el-button type="primary" @click="confirmAddVar">确认添加</el-button>
  478. </template>
  479. </el-dialog>
  480. <!-- Upload Results Dialog -->
  481. <el-dialog v-model="showUpload" title="上传仿真结果" width="500px">
  482. <el-upload
  483. drag
  484. action="#"
  485. :auto-upload="false"
  486. :on-change="onFileChange"
  487. accept=".csv,.json"
  488. >
  489. <el-icon class="el-icon--upload"><UploadFilled /></el-icon>
  490. <div class="el-upload__text">拖拽文件到此处,或<em>点击上传</em></div>
  491. <template #tip>
  492. <div class="el-upload__tip">支持 CSV / JSON 格式的仿真结果文件</div>
  493. </template>
  494. </el-upload>
  495. <template #footer>
  496. <el-button @click="showUpload = false">取消</el-button>
  497. <el-button type="primary" :loading="uploading" @click="confirmUpload" :disabled="!uploadFile">
  498. 上传
  499. </el-button>
  500. </template>
  501. </el-dialog>
  502. <!-- Pre-flight Checklist Dialog -->
  503. <el-dialog v-model="showPreflight" title="仿真前检查" width="560px" :close-on-click-modal="false">
  504. <div v-if="preflight" class="preflight-body">
  505. <div v-for="c in preflight.checks" :key="c.key" class="preflight-item" :class="`is-${c.status}`">
  506. <el-icon class="preflight-icon">
  507. <CircleCheckFilled v-if="c.status === 'pass'" />
  508. <WarningFilled v-else-if="c.status === 'warn'" />
  509. <CircleCloseFilled v-else />
  510. </el-icon>
  511. <div class="preflight-content">
  512. <div class="preflight-label">{{ PREFLIGHT_LABELS[c.key] || c.key }}</div>
  513. <div class="preflight-message">{{ preflightMessage(c) }}</div>
  514. <el-button
  515. v-if="c.key === 'model_path' && c.status === 'fail' && c.fixable"
  516. size="small"
  517. type="primary"
  518. class="preflight-fix"
  519. :loading="applyingDefaultModel"
  520. @click="applyDefaultModel(c.default_model)"
  521. >
  522. 使用拓扑默认模型({{ c.default_model }})
  523. </el-button>
  524. </div>
  525. </div>
  526. <el-divider />
  527. <div class="thermal-mode-row">
  528. <span class="thermal-mode-label">热仿真模式</span>
  529. <el-radio-group v-model="thermalMode" size="small">
  530. <el-radio value="off">仅电磁(最快)</el-radio>
  531. <el-radio value="steady">电磁+稳态热(默认)</el-radio>
  532. <el-radio value="coupled">磁热耦合(精算)</el-radio>
  533. </el-radio-group>
  534. </div>
  535. <el-alert v-if="!preflight.ok" type="error" :closable="false" style="margin-top: 12px">
  536. 存在未通过的检查项,请先处理后再启动仿真。
  537. </el-alert>
  538. </div>
  539. <template #footer>
  540. <el-button @click="showPreflight = false">取消</el-button>
  541. <el-button type="primary" :disabled="!preflight?.ok" :loading="starting" @click="confirmStartSimulation">
  542. 确认启动
  543. </el-button>
  544. </template>
  545. </el-dialog>
  546. <!-- Result Column Settings Dialog -->
  547. <el-dialog v-model="showColumnSettings" title="结果列设置" width="480px">
  548. <div class="column-settings-tip">勾选要在结果表中显示的列(默认显示核心指标与扫描变量)</div>
  549. <el-checkbox-group v-model="visibleColumnKeys" class="column-settings-group">
  550. <el-checkbox v-for="col in allResultColumns" :key="col.key" :label="col.key" class="column-settings-item">
  551. {{ col.label }}
  552. </el-checkbox>
  553. </el-checkbox-group>
  554. <template #footer>
  555. <el-button @click="resetColumns">恢复默认</el-button>
  556. <el-button type="primary" @click="confirmColumnSettings">确定</el-button>
  557. </template>
  558. </el-dialog>
  559. </div>
  560. </template>
  561. <script setup lang="ts">
  562. import { ref, reactive, computed, onMounted, onUnmounted, watch } from 'vue'
  563. import { useRoute, useRouter } from 'vue-router'
  564. import { ElMessage, ElMessageBox } from 'element-plus'
  565. import {
  566. ArrowLeft, VideoPlay, VideoPause, Upload, Plus, Edit,
  567. Download, DataAnalysis, MagicStick, Setting, CircleCheck,
  568. Star, ArrowDown, ArrowRight, RefreshRight, Collection, UploadFilled,
  569. CircleCheckFilled, WarningFilled, CircleCloseFilled,
  570. } from '@element-plus/icons-vue'
  571. import api from '@/api'
  572. import StatCard from '@/components/StatCard.vue'
  573. import SectionCard from '@/components/SectionCard.vue'
  574. import PageHeader from '@/components/PageHeader.vue'
  575. const route = useRoute()
  576. const router = useRouter()
  577. const planId = computed(() => Number(route.params.id))
  578. // State
  579. const plan = reactive<any>({})
  580. const results = ref<any[]>([])
  581. const activeTask = ref<any>(null)
  582. const activeTab = ref('overview')
  583. const isRunning = ref(false)
  584. const starting = ref(false)
  585. const stopping = ref(false)
  586. const analyzing = ref(false)
  587. const generating = ref(false)
  588. const extracting = ref(false)
  589. const uploading = ref(false)
  590. const uploadFile = ref<File | null>(null)
  591. const showAddVar = ref(false)
  592. const scanVarsDirty = ref(false)
  593. const savingVars = ref(false)
  594. const showUpload = ref(false)
  595. const showAllFixed = ref(true) // default fully expanded (user requirement 2026-09-03)
  596. const showPreflight = ref(false)
  597. const preflight = ref<any>(null)
  598. const preflightLoading = ref(false)
  599. const applyingDefaultModel = ref(false)
  600. const solveTimeStats = ref<any>(null)
  601. const aiStep = ref(0)
  602. const aiAnalysis = ref<any>(null)
  603. const iterationPlan = ref<any>(null)
  604. const experienceExtracted = ref(false)
  605. const newVar = reactive({
  606. name: '',
  607. name_cn: '',
  608. min_value: 0,
  609. max_value: 1,
  610. step: 0.1,
  611. unit: '',
  612. })
  613. const expandedCategories = reactive<Record<string, boolean>>({})
  614. // Scan parameter catalog (frontend copy; B3 will unify with backend)
  615. const SCAN_PARAM_CN: Record<string, string> = {
  616. Airgap: '气隙长度',
  617. Magnet_Length: '磁钢轴向长度',
  618. Magnet_Thickness: '磁钢径向厚度',
  619. 'Magnet_Arc_[ED]': '磁钢极弧角',
  620. RMSCurrent: '额定电流',
  621. Shaft_Speed: '额定转速',
  622. Slot_Depth: '槽深',
  623. Slot_Width: '槽宽',
  624. Tooth_Width: '齿宽',
  625. Turns_per_Coil: '每线圈匝数',
  626. Stator_Outer_Diameter: '定子外径',
  627. Stator_Inner_Diameter: '定子内径',
  628. Stator_Axial_Length: '定子轴向长度',
  629. Wire_Diameter: '线径',
  630. }
  631. const categoryCnMap: Record<string, string> = {
  632. Geometry: '几何尺寸',
  633. Stator: '定子参数',
  634. Rotor: '转子参数',
  635. Performance: '性能规格',
  636. Winding: '绕组参数',
  637. Material: '材料属性',
  638. Thermal: '热与冷却',
  639. Simulation: '仿真设置',
  640. System: '仿真设置',
  641. Mechanical: '其他',
  642. Electrical: '性能规格',
  643. General: '其他',
  644. }
  645. // BC field catalog loaded from the backend single-source (P1-1). The plan
  646. // boundary display renders from this canonical catalog instead of a local
  647. // hard-coded template that had drifted to a third key naming.
  648. const bcFieldCatalog = ref<any[]>([])
  649. // Fixed parameter default template (36 params)
  650. const ALL_FIXED_PARAM_TEMPLATE = [
  651. { name: 'Outer_Rotor_Diameter', motorcad_var: null, name_cn: '转子外径', unit: 'mm', value: 200.0, category: 'Geometry', description_cn: '转子背铁外径' },
  652. { name: 'Inner_Rotor_Diameter', motorcad_var: null, name_cn: '转子内径', unit: 'mm', value: 120.0, category: 'Geometry', description_cn: '转子背铁内径' },
  653. { name: 'Stator_Outer_Diameter', motorcad_var: null, name_cn: '定子外径', unit: 'mm', value: 198.0, category: 'Geometry', description_cn: '定子冲片外径' },
  654. { name: 'Stator_Inner_Diameter', motorcad_var: null, name_cn: '定子内径', unit: 'mm', value: 122.0, category: 'Geometry', description_cn: '定子冲片内径' },
  655. { name: 'Airgap', motorcad_var: 'Airgap', name_cn: '气隙长度', unit: 'mm', value: 1.0, category: 'Geometry', description_cn: '定转子之间气隙' },
  656. { name: 'Stator_Yoke_Thickness', motorcad_var: null, name_cn: '定子轭厚', unit: 'mm', value: 10.0, category: 'Stator', description_cn: '定子轭部径向厚度' },
  657. { name: 'Slot_Depth', motorcad_var: 'Slot_Depth', name_cn: '槽深', unit: 'mm', value: 7.0, category: 'Stator', description_cn: '定子槽深度' },
  658. { name: 'Slot_Width', motorcad_var: 'Slot_Width', name_cn: '槽宽', unit: 'mm', value: 8.5, category: 'Stator', description_cn: '定子槽口宽度' },
  659. { name: 'Tooth_Width', motorcad_var: 'Tooth_Width', name_cn: '齿宽', unit: 'mm', value: 7.0, category: 'Stator', description_cn: '定子齿宽度' },
  660. { name: 'Number_of_Slots', motorcad_var: 'Slot_Number', name_cn: '槽数', unit: '', value: 12, category: 'Stator', description_cn: '定子总槽数' },
  661. { name: 'Rotor_Back_Iron_Thickness', motorcad_var: null, name_cn: '转子背铁厚', unit: 'mm', value: 8.0, category: 'Rotor', description_cn: '转子背铁径向厚度' },
  662. { name: 'Magnet_Length', motorcad_var: 'Magnet_Length', name_cn: '磁钢轴向长度', unit: 'mm', value: 3.0, category: 'Rotor', description_cn: '永磁体轴向厚度' },
  663. { name: 'Magnet_Thickness', motorcad_var: 'Magnet_Thickness', name_cn: '磁钢径向厚度', unit: 'mm', value: 13.0, category: 'Rotor', description_cn: '磁钢环径向厚度' },
  664. { name: 'Magnet_Arc_[ED]', motorcad_var: 'Magnet_Arc_[ED]', name_cn: '磁钢极弧角', unit: 'deg', value: 121.0, category: 'Rotor', description_cn: '磁钢极弧角度(电角度)' },
  665. { name: 'Number_of_Poles', motorcad_var: 'Pole_Number', name_cn: '极数', unit: '', value: 10, category: 'Rotor', description_cn: '电机总极数' },
  666. { name: 'Current_Advance_Angle', motorcad_var: null, name_cn: '电流超前角', unit: 'deg', value: 0.0, category: 'Performance', description_cn: '弱磁控制电流超前角' },
  667. { name: 'DC_Link_Voltage', motorcad_var: 'DCBusVoltage', name_cn: '母线电压', unit: 'V', value: 13.5, category: 'Performance', description_cn: '直流母线电压' },
  668. { name: 'RMSCurrent', motorcad_var: 'RMSCurrent', name_cn: '额定电流', unit: 'A', value: 21.0, category: 'Performance', description_cn: '额定相电流(RMS)' },
  669. { name: 'Shaft_Speed', motorcad_var: 'Shaft_Speed', name_cn: '额定转速', unit: 'rpm', value: 5000.0, category: 'Performance', description_cn: '电机额定转速' },
  670. { name: 'Max_Speed', motorcad_var: 'WindageGraph_MaxSpeed', name_cn: '最高转速', unit: 'rpm', value: 7500.0, category: 'Performance', description_cn: '电机最高转速(变量名需确认)' },
  671. { name: 'Turns_per_Coil', motorcad_var: 'ConductorsPerSlot', name_cn: '每线圈匝数', unit: '', value: 20, category: 'Winding', description_cn: '每个线圈的匝数' },
  672. { name: 'Parallel_Paths', motorcad_var: 'ParallelPaths', name_cn: '并联支路数', unit: '', value: 1, category: 'Winding', description_cn: '绕组并联支路数' },
  673. { name: 'Copper_Fill_Factor', motorcad_var: 'Slot_Fill', name_cn: '槽满率', unit: '', value: 0.45, category: 'Winding', description_cn: '铜线面积与槽面积之比' },
  674. { name: 'Wire_Diameter', motorcad_var: 'Wire_Diameter', name_cn: '线径', unit: 'mm', value: 1.63, category: 'Winding', description_cn: '漆包线直径' },
  675. { name: 'Winding_Connection', motorcad_var: 'WindingConnection', name_cn: '绕组连接方式', unit: '', value: 'Star', category: 'Winding', description_cn: '绕组连接方式(星/三角)(变量名需确认)' },
  676. { name: 'Current_Density', motorcad_var: null, name_cn: '电流密度', unit: 'A/mm2', value: 6.0, category: 'Winding', description_cn: '绕组电流密度(变量名需确认)' },
  677. { name: 'Magnet_Material', motorcad_var: 'Material_Magnet', name_cn: '磁钢材料', unit: '', value: 'NdFeB_N42SH', category: 'Material', description_cn: '永磁体材料牌号' },
  678. { name: 'Steel_Grade', motorcad_var: 'Material_Stator_Lam_Yoke', name_cn: '硅钢片牌号', unit: '', value: 'M19_24G', category: 'Material', description_cn: '电工硅钢片牌号' },
  679. { name: 'Magnet_Temperature', motorcad_var: 'InitialMagnetTemperature', name_cn: '磁钢温度', unit: 'C', value: 40.0, category: 'Material', description_cn: '磁钢工作温度' },
  680. { name: 'Magnet_Remanence', motorcad_var: 'Magnet_Br_at_RefTemp', name_cn: '剩磁', unit: 'T', value: 1.31, category: 'Material', description_cn: '永磁体剩磁密度(变量名需确认)' },
  681. { name: 'Ambient_Temperature', motorcad_var: 'Ambient_Temperature', name_cn: '环境温度', unit: 'C', value: 40.0, category: 'Thermal', description_cn: '环境空气温度' },
  682. { name: 'Cooling_Method', motorcad_var: 'Cooling_Type', name_cn: '冷却方式', unit: '', value: 'Natural', category: 'Thermal', description_cn: '冷却方式(自然/强迫风冷/水冷)' },
  683. { name: 'Insulation_Class', motorcad_var: null, name_cn: '绝缘等级', unit: '', value: 'F', category: 'Thermal', description_cn: '绝缘等级(A/E/B/F/H)(变量名需确认)' },
  684. { name: 'TorquePointsPerCycle', motorcad_var: 'TorquePointsPerCycle', name_cn: '每周期转矩采样点', unit: '', value: 30, category: 'Simulation', description_cn: '每电周期转矩计算采样点数' },
  685. { name: 'CurrentDefinition', motorcad_var: null, name_cn: '电流定义方式', unit: '', value: 1.0, category: 'Simulation', description_cn: '1=有效值, 2=峰值电流定义' },
  686. { name: 'AirgapMeshPoints_mesh', motorcad_var: 'AirgapMeshPoints_mesh', name_cn: '气隙网格点数', unit: '', value: 600.0, category: 'Simulation', description_cn: '气隙网格点数(显式求解网格加密)' },
  687. { name: 'MessageDisplayState', motorcad_var: 'MessageDisplayState', name_cn: '消息显示', unit: '', value: 2.0, category: 'Simulation', description_cn: '脚本运行时抑制弹窗' },
  688. ]
  689. // Computed
  690. const subtitleText = computed(() => {
  691. const parts: string[] = []
  692. if (plan.topology) parts.push(plan.topology)
  693. if (plan.created_at) parts.push(`创建于 ${new Date(plan.created_at).toLocaleDateString('zh-CN')}`)
  694. return parts.join(' · ')
  695. })
  696. // Scan variables live under plan_data.variables in the plan payload (P0 fix:
  697. // previously read the non-existent plan.scan_variables, so the overview stat
  698. // cards and the parameters tab always showed 0/empty for every plan).
  699. const scanVariables = computed(() => plan.plan_data?.variables || plan.scan_variables || [])
  700. const fixedParams = computed(() => {
  701. const fps = plan.fixed_parameters || []
  702. // Backfill from template if missing
  703. if (fps.length === 0) {
  704. return ALL_FIXED_PARAM_TEMPLATE.map(p => ({ ...p, category_cn: categoryCnMap[p.category] || p.category }))
  705. }
  706. return fps.map((p: any) => ({
  707. ...p,
  708. category_cn: p.category_cn || categoryCnMap[p.category] || p.category,
  709. name_cn: p.name_cn || SCAN_PARAM_CN[p.name] || p.name,
  710. }))
  711. })
  712. // BC lives under plan_data (not top-level). Show ALL catalog fields (unset
  713. // ones included) so the full 25-field boundary picture is visible; tag each
  714. // with its source (user-specified / AI-supplemented / edited).
  715. const bcMeta = computed(() => plan.plan_data?.bc_meta || {})
  716. const boundaryConditions = computed(() => {
  717. const bc = plan.plan_data?.boundary_conditions || plan.boundary_conditions || {}
  718. return bcFieldCatalog.value.map(t => ({
  719. ...t,
  720. value: bc[t.key],
  721. source: bcMeta.value[t.key]?.source || (bc[t.key] != null && bc[t.key] !== '' ? 'user' : ''),
  722. }))
  723. })
  724. // Acceptance criteria: AI-provided criteria first, then derived from BC target
  725. // fields so the overview always shows the plan's goals at a glance.
  726. const ACCEPTANCE_FROM_BC: { key: string; metric: string; label: string; op: string; unit: string }[] = [
  727. { key: 'target_torque_nm', metric: 'tavg_nm', label: '平均转矩', op: '>=', unit: 'Nm' },
  728. { key: 'target_efficiency_pct', metric: 'efficiency_pct', label: '效率', op: '>=', unit: '%' },
  729. { key: 'max_losses_w', metric: 'total_losses_w', label: '总损耗', op: '<=', unit: 'W' },
  730. { key: 'target_ripple_pct', metric: 'ripple_pct', label: '转矩脉动', op: '<=', unit: '%' },
  731. { key: 'max_axial_force_n', metric: 'axial_force_n', label: '轴向力', op: '<=', unit: 'N' },
  732. { key: 'outer_diameter_mm', metric: 'outer_diameter', label: '外径', op: '<=', unit: 'mm' },
  733. { key: 'axial_length_mm', metric: 'axial_length', label: '轴向长度', op: '<=', unit: 'mm' },
  734. ]
  735. const acceptanceItems = computed(() => {
  736. const ac = plan.plan_data?.acceptance_criteria || plan.acceptance_criteria
  737. const items: { text: string; origin: string }[] = []
  738. if (ac && Array.isArray(ac.hard_constraints)) {
  739. ac.hard_constraints.forEach((c: string) => items.push({ text: c, origin: 'AI 设定' }))
  740. } else if (typeof ac === 'string' && ac) {
  741. items.push({ text: ac, origin: 'AI 设定' })
  742. }
  743. const bc = plan.plan_data?.boundary_conditions || {}
  744. ACCEPTANCE_FROM_BC.forEach(m => {
  745. const v = bc[m.key]
  746. if (v !== undefined && v !== null && v !== '') {
  747. items.push({ text: `${m.label} ${m.op} ${v} ${m.unit}`.trim(), origin: '边界条件' })
  748. }
  749. })
  750. return items
  751. })
  752. const estimatedPoints = computed(() => {
  753. if (!scanVariables.value.length) return 0
  754. return scanVariables.value.reduce((acc: number, v: any) => acc * calcPoints(v), 1)
  755. })
  756. // Per-point duration calibrated from measured solve times (P2-1); falls back
  757. // to the 2.5 min/point heuristic when no measurement exists yet.
  758. const perPointMin = computed(() => {
  759. const avg = solveTimeStats.value?.avg_s
  760. return avg ? avg / 60 : 2.5
  761. })
  762. const estimatedTimeMin = computed(() => {
  763. return Math.round(estimatedPoints.value * perPointMin.value)
  764. })
  765. const estimatedTimeBasis = computed(() => {
  766. const s = solveTimeStats.value
  767. if (s && s.count) return `基于最近 ${s.count} 次实测(~${Math.round(s.avg_s)}s/点)`
  768. return '按经验值 2.5 分钟/点估算'
  769. })
  770. const estimatedRemaining = computed(() => {
  771. if (!activeTask.value || !activeTask.value.total_points) return '-'
  772. const remaining = activeTask.value.total_points - (activeTask.value.completed_points || 0)
  773. const mins = Math.round(remaining * perPointMin.value)
  774. if (mins < 60) return `${mins} 分钟`
  775. return `${(mins / 60).toFixed(1)} 小时`
  776. })
  777. const modifiedFixedParams = computed(() => {
  778. return fixedParams.value.filter((p: any) => {
  779. const def = ALL_FIXED_PARAM_TEMPLATE.find(t => t.name === p.name)
  780. if (!def) return true // unknown param, treat as modified
  781. return String(p.value) !== String(def.value)
  782. })
  783. })
  784. const fixedCategories = computed<string[]>(() => {
  785. const fps = fixedParams.value as any[]
  786. const cats = [...new Set(fps.map((p: any) => String(p.category_cn || p.category || '其他')))]
  787. return cats
  788. })
  789. // Topology-aware variable catalog fetched from backend
  790. const variableCatalog = ref<any>(null)
  791. async function loadVariableCatalog() {
  792. try {
  793. const topo = (plan.topology as string) || 'SSSR'
  794. const res: any = await api.get('/plans/variable-catalog', { params: { topology: topo } })
  795. variableCatalog.value = res
  796. } catch (e) {
  797. console.error('Failed to load variable catalog:', e)
  798. }
  799. }
  800. const availableScanParams = computed(() => {
  801. const usedNames = new Set(scanVariables.value.map((v: any) => v.name))
  802. // Prefer backend template (topology-aware with motorcad_var), fallback to local
  803. const template = variableCatalog.value?.template || ALL_FIXED_PARAM_TEMPLATE
  804. return template
  805. .filter((p: any) => !usedNames.has(p.name))
  806. .map((p: any) => ({
  807. name: p.name,
  808. name_cn: p.name_cn || p.name,
  809. unit: p.unit,
  810. motorcad_var: p.motorcad_var || p.name,
  811. }))
  812. })
  813. const coreResultColumns = [
  814. { key: 'tavg_nm', label: '平均转矩(Nm)', width: 120 },
  815. { key: 'ripple_pct', label: '转矩脉动(%)', width: 110 },
  816. { key: 'efficiency_pct', label: '效率(%)', width: 90 },
  817. { key: 'total_losses_w', label: '总损耗(W)', width: 110 },
  818. { key: 'status', label: '状态', width: 80 },
  819. ]
  820. const allResultColumns = computed(() => {
  821. if (!results.value.length) return coreResultColumns
  822. const keys = Object.keys(results.value[0]) as string[]
  823. const labelMap: Record<string, string> = {
  824. point_id: '点ID', index: '序号', Airgap: '气隙(mm)', Magnet_Length: '磁钢长(mm)',
  825. Magnet_Thickness: '磁钢厚(mm)', 'Magnet_Arc_[ED]': '极弧角(deg)',
  826. RMSCurrent: '电流(A)', Shaft_Speed: '转速(rpm)',
  827. tavg_nm: '平均转矩(Nm)', ripple_pct: '转矩脉动(%)',
  828. average_torque_nm: '平均转矩(Nm)', torque_ripple_pct: '转矩脉动(%)',
  829. cogging_torque_nm: '齿槽转矩(Nm)', efficiency_pct: '效率(%)',
  830. total_losses_w: '总损耗(W)', copper_loss_w: '铜耗(W)',
  831. iron_loss_w: '铁耗(W)', magnet_loss_w: '磁钢耗(W)',
  832. max_flux_density_t: '最大磁密(T)', status: '状态',
  833. solve_time_s: '求解时间(s)', error: '错误信息', error_message: '错误信息',
  834. }
  835. return keys.map(k => ({
  836. key: k,
  837. label: labelMap[k] || k,
  838. width: k === 'error' ? 200 : 110,
  839. }))
  840. })
  841. // --- Result column settings (P2-4) ---
  842. // Default: core metric columns + the plan's scan-variable input columns. All
  843. // 35+ metrics remain available on demand via the column-settings dialog
  844. // instead of being laid out unconditionally.
  845. const showColumnSettings = ref(false)
  846. const visibleColumnKeys = ref<string[] | null>(loadSavedColumns()) // null = use defaults
  847. // Persist the column preference across sessions (localStorage). The choice is
  848. // global (shared by all plans) since metric columns are plan-independent.
  849. const COLUMN_STORAGE_KEY = 'afm:plan-result-columns'
  850. function loadSavedColumns(): string[] | null {
  851. try {
  852. const raw = localStorage.getItem(COLUMN_STORAGE_KEY)
  853. if (!raw) return null
  854. const parsed = JSON.parse(raw)
  855. return Array.isArray(parsed) && parsed.length ? parsed : null
  856. } catch {
  857. return null
  858. }
  859. }
  860. function persistColumns() {
  861. try {
  862. if (visibleColumnKeys.value === null) {
  863. localStorage.removeItem(COLUMN_STORAGE_KEY)
  864. } else {
  865. localStorage.setItem(COLUMN_STORAGE_KEY, JSON.stringify(visibleColumnKeys.value))
  866. }
  867. } catch { /* storage may be unavailable; non-fatal */ }
  868. }
  869. const defaultColumnKeys = computed(() => {
  870. const keys = coreResultColumns.map(c => c.key)
  871. scanVariables.value.forEach((v: any) => {
  872. if (v?.name && !keys.includes(v.name)) keys.push(v.name)
  873. })
  874. return keys
  875. })
  876. const displayColumns = computed(() => {
  877. const all = allResultColumns.value
  878. const sel = new Set(visibleColumnKeys.value ?? defaultColumnKeys.value)
  879. return all.filter(c => sel.has(c.key))
  880. })
  881. const openColumnSettings = () => {
  882. if (visibleColumnKeys.value === null) {
  883. visibleColumnKeys.value = [...defaultColumnKeys.value]
  884. }
  885. showColumnSettings.value = true
  886. }
  887. const confirmColumnSettings = () => {
  888. if (visibleColumnKeys.value !== null && !visibleColumnKeys.value.length) {
  889. ElMessage.warning('至少保留一列')
  890. return
  891. }
  892. persistColumns()
  893. showColumnSettings.value = false
  894. }
  895. const resetColumns = () => {
  896. visibleColumnKeys.value = null
  897. persistColumns()
  898. showColumnSettings.value = false
  899. }
  900. // Methods
  901. const calcPoints = (v: any) => {
  902. // Prefer the explicit values list (plan_data.variables / AI-generated plans
  903. // store values arrays); fall back to a min/max/step range otherwise so both
  904. // legacy and current plan shapes compute a non-zero point count (P0-1).
  905. if (Array.isArray(v.values) && v.values.length) return v.values.length
  906. const step = v.step ?? v.step_size
  907. if (!step || step <= 0) return 0
  908. const min = v.min_value ?? v.start
  909. const max = v.max_value ?? v.stop
  910. if (min == null || max == null) return 0
  911. return Math.floor((max - min) / step + 1e-9) + 1
  912. }
  913. const getDefaultValue = (name: string) => {
  914. const def = ALL_FIXED_PARAM_TEMPLATE.find(t => t.name === name)
  915. return def ? def.value : '-'
  916. }
  917. const fixedParamsByCategory = (cat: string) => {
  918. return fixedParams.value.filter((p: any) => String(p.category_cn || p.category) === cat)
  919. }
  920. const toggleCategory = (cat: string) => {
  921. // Categories are expanded by default; the map only records explicit collapse.
  922. expandedCategories[cat] = expandedCategories[cat] === false
  923. }
  924. const isFailed = (row: any) => row.status === 'FAILED' || row.status === 'failed'
  925. const formatCell = (val: any) => {
  926. if (val === null || val === undefined) return '-'
  927. if (typeof val === 'number') return Number.isInteger(val) ? val : val.toFixed(4)
  928. return String(val)
  929. }
  930. const goBack = () => router.back()
  931. const onVarSelect = (name: string) => {
  932. const template = variableCatalog.value?.template || ALL_FIXED_PARAM_TEMPLATE
  933. const p = template.find((t: any) => t.name === name)
  934. if (p) {
  935. newVar.name_cn = p.name_cn || p.name
  936. newVar.unit = p.unit
  937. const baseVal = Number(p.value) || 1
  938. newVar.min_value = baseVal * 0.8
  939. newVar.max_value = baseVal * 1.2
  940. newVar.step = Math.abs(baseVal * 0.05) || 0.1
  941. }
  942. }
  943. // Ensure plan_data.variables exists and return it (scan variables are stored
  944. // under plan_data.variables in the plan payload).
  945. const ensureVariables = () => {
  946. if (!plan.plan_data) plan.plan_data = {}
  947. if (!Array.isArray(plan.plan_data.variables)) plan.plan_data.variables = []
  948. return plan.plan_data.variables
  949. }
  950. const confirmAddVar = () => {
  951. if (!newVar.name) { ElMessage.warning('请选择变量名'); return }
  952. ensureVariables().push({ ...newVar })
  953. scanVarsDirty.value = true
  954. showAddVar.value = false
  955. Object.assign(newVar, { name: '', name_cn: '', min_value: 0, max_value: 1, step: 0.1, unit: '' })
  956. ElMessage.success('变量已添加,点击"保存修改"后生效')
  957. }
  958. const removeVariable = (idx: number) => {
  959. ensureVariables().splice(idx, 1)
  960. scanVarsDirty.value = true
  961. }
  962. // Persist scan-variable edits to the backend (full plan_data replacement,
  963. // validated server-side by the single-source plan schema).
  964. const saveScanVariables = async () => {
  965. savingVars.value = true
  966. try {
  967. const planData = { ...(plan.plan_data || {}), variables: ensureVariables() }
  968. await api.put(`/plans/${planId.value}`, { plan_data: planData })
  969. scanVarsDirty.value = false
  970. ElMessage.success('方案参数已保存')
  971. await loadPlan()
  972. } catch (e: any) {
  973. ElMessage.error('保存失败: ' + (e.message || e))
  974. } finally {
  975. savingVars.value = false
  976. }
  977. }
  978. // Boundary-condition editing: inline edit mode on the plan's BC. Values the
  979. // user changes are tagged "edited" in bc_meta so the source stays traceable.
  980. const bcEditing = ref(false)
  981. const bcSaving = ref(false)
  982. const bcEditForm = reactive<Record<string, any>>({})
  983. const startBcEdit = () => {
  984. const bc = plan.plan_data?.boundary_conditions || {}
  985. bcFieldCatalog.value.forEach(f => { bcEditForm[f.key] = bc[f.key] ?? null })
  986. bcEditing.value = true
  987. }
  988. const saveBcEdit = async () => {
  989. bcSaving.value = true
  990. try {
  991. const oldBc = plan.plan_data?.boundary_conditions || {}
  992. const oldMeta = { ...(plan.plan_data?.bc_meta || {}) }
  993. const newBc: Record<string, any> = {}
  994. for (const [k, v] of Object.entries(bcEditForm)) {
  995. if (v !== null && v !== undefined && v !== '') newBc[k] = v
  996. }
  997. for (const k of Object.keys(newBc)) {
  998. const changed = String(newBc[k]) !== String(oldBc[k] ?? '')
  999. if (changed || !oldMeta[k]) oldMeta[k] = { source: 'edited' }
  1000. }
  1001. const planData = {
  1002. ...(plan.plan_data || {}),
  1003. boundary_conditions: newBc,
  1004. bc_meta: oldMeta,
  1005. }
  1006. await api.put(`/plans/${planId.value}`, { plan_data: planData })
  1007. bcEditing.value = false
  1008. ElMessage.success('边界条件已保存')
  1009. await loadPlan()
  1010. } catch (e: any) {
  1011. ElMessage.error('保存失败: ' + (e.message || e))
  1012. } finally {
  1013. bcSaving.value = false
  1014. }
  1015. }
  1016. // Fixed-parameter inline editing: enter edit mode -> all categories expand,
  1017. // value cells become inputs; save writes the full fixed_params list back via
  1018. // PUT plan_data (server-side schema validation applies).
  1019. const fixedEditing = ref(false)
  1020. const fixedSaving = ref(false)
  1021. const fixedEditValues = reactive<Record<string, any>>({})
  1022. const startFixedEdit = () => {
  1023. ;(fixedParams.value as any[]).forEach((p: any) => { fixedEditValues[p.name] = p.value })
  1024. fixedEditing.value = true
  1025. }
  1026. const isFixedModified = (row: any) => {
  1027. const def = ALL_FIXED_PARAM_TEMPLATE.find(t => t.name === row.name)
  1028. if (!def) return true
  1029. return String(row.value) !== String(def.value)
  1030. }
  1031. const saveFixedParams = async () => {
  1032. fixedSaving.value = true
  1033. try {
  1034. const newFixed = (fixedParams.value as any[]).map((p: any) => ({
  1035. ...p,
  1036. value: fixedEditValues[p.name] !== undefined ? fixedEditValues[p.name] : p.value,
  1037. }))
  1038. const planData = { ...(plan.plan_data || {}), fixed_params: newFixed }
  1039. await api.put(`/plans/${planId.value}`, { plan_data: planData })
  1040. fixedEditing.value = false
  1041. ElMessage.success('固定参数已保存')
  1042. await loadPlan()
  1043. } catch (e: any) {
  1044. ElMessage.error('保存失败: ' + (e.message || e))
  1045. } finally {
  1046. fixedSaving.value = false
  1047. }
  1048. }
  1049. // Pre-flight checklist: key -> localized label (backend returns keys only).
  1050. const PREFLIGHT_LABELS: Record<string, string> = {
  1051. model_path: '模型文件',
  1052. unverified_vars: '变量名确认',
  1053. scan_vars: '扫描变量',
  1054. point_count: '数据点规模',
  1055. executor: '本地执行器',
  1056. }
  1057. function preflightMessage(c: any): string {
  1058. switch (c.key) {
  1059. case 'model_path':
  1060. return c.status === 'pass' ? `已就绪:${c.value}` : (c.value ? `模型文件不存在:${c.value}` : '未设置模型路径(model_path 为空)')
  1061. case 'unverified_vars':
  1062. return c.status === 'pass' ? '全部固定参数变量名已映射' : `${(c.items || []).length} 个变量名未经 Motor-CAD 验证:${(c.items || []).join('、')}`
  1063. case 'scan_vars':
  1064. return c.status === 'pass' ? `${c.count} 个扫描变量` : '未定义扫描变量(至少 1 个)'
  1065. case 'point_count':
  1066. return c.status === 'warn' ? `${c.count} 个数据点,规模较大,请确认` : `${c.count} 个数据点`
  1067. case 'executor':
  1068. return c.online > 0 ? `${c.online} 个执行器在线` : '未检测到在线执行器(任务将排队等待)'
  1069. default:
  1070. return ''
  1071. }
  1072. }
  1073. // P6: task-level thermal mode (off/steady/coupled), chosen at one-click start.
  1074. const thermalMode = ref('steady')
  1075. const startSimulation = async () => {
  1076. // Run the pre-flight checklist first; the start button in the dialog is
  1077. // disabled while any check has status 'fail'.
  1078. preflightLoading.value = true
  1079. try {
  1080. const res: any = await api.get(`/plans/${planId.value}/preflight`)
  1081. preflight.value = res
  1082. showPreflight.value = true
  1083. } catch (e: any) {
  1084. ElMessage.error('仿真前检查失败: ' + (e.message || e))
  1085. } finally {
  1086. preflightLoading.value = false
  1087. }
  1088. }
  1089. const confirmStartSimulation = async () => {
  1090. showPreflight.value = false
  1091. starting.value = true
  1092. try {
  1093. await api.post(`/plans/${planId.value}/start-simulation`, {
  1094. thermal_mode: thermalMode.value,
  1095. })
  1096. ElMessage.success('仿真已启动')
  1097. isRunning.value = true
  1098. activeTab.value = 'overview'
  1099. } catch (e: any) {
  1100. ElMessage.error('启动失败: ' + (e.message || e))
  1101. } finally {
  1102. starting.value = false
  1103. }
  1104. }
  1105. // One-click repair for a failed model_path check: write the topology's
  1106. // default base model into the plan, then re-run preflight so the checklist
  1107. // flips green in place.
  1108. const applyDefaultModel = async (defaultModel: string) => {
  1109. applyingDefaultModel.value = true
  1110. try {
  1111. const planData = { ...(plan.plan_data || {}), model_path: defaultModel }
  1112. await api.put(`/plans/${planId.value}`, { plan_data: planData })
  1113. ElMessage.success('已应用拓扑默认模型')
  1114. await loadPlan()
  1115. const res: any = await api.get(`/plans/${planId.value}/preflight`)
  1116. preflight.value = res
  1117. } catch (e: any) {
  1118. ElMessage.error('应用默认模型失败: ' + (e.message || e))
  1119. } finally {
  1120. applyingDefaultModel.value = false
  1121. }
  1122. }
  1123. const stopSimulation = async () => {
  1124. try {
  1125. await ElMessageBox.confirm('确认停止当前仿真?', '停止仿真', { type: 'warning' })
  1126. stopping.value = true
  1127. // API call to stop would go here
  1128. isRunning.value = false
  1129. ElMessage.success('仿真已停止')
  1130. } catch { /* cancelled */ }
  1131. finally { stopping.value = false }
  1132. }
  1133. const onFileChange = (file: any) => {
  1134. uploadFile.value = file.raw
  1135. }
  1136. const confirmUpload = async () => {
  1137. if (!uploadFile.value) return
  1138. uploading.value = true
  1139. try {
  1140. const formData = new FormData()
  1141. formData.append('file', uploadFile.value)
  1142. await api.post(`/plans/${planId.value}/upload-results`, formData, {
  1143. headers: { 'Content-Type': 'multipart/form-data' },
  1144. })
  1145. ElMessage.success('结果上传成功')
  1146. showUpload.value = false
  1147. loadResults()
  1148. } catch (e: any) {
  1149. ElMessage.error('上传失败: ' + (e.message || e))
  1150. } finally {
  1151. uploading.value = false
  1152. }
  1153. }
  1154. const downloadResults = () => {
  1155. window.open(`/api/plans/${planId.value}/download`, '_blank')
  1156. }
  1157. const runAIAnalysis = async () => {
  1158. analyzing.value = true
  1159. try {
  1160. const res: any = await api.post(`/plans/${planId.value}/ai-analyze`, {}, { timeout: 60000 })
  1161. aiAnalysis.value = res
  1162. aiStep.value = 1
  1163. ElMessage.success('AI 分析完成')
  1164. } catch (e: any) {
  1165. ElMessage.error('分析失败: ' + (e.message || e))
  1166. } finally {
  1167. analyzing.value = false
  1168. }
  1169. }
  1170. const generateIteration = async () => {
  1171. generating.value = true
  1172. try {
  1173. const res: any = await api.post(`/plans/${planId.value}/generate-iteration`, {}, { timeout: 60000 })
  1174. iterationPlan.value = res
  1175. aiStep.value = 2
  1176. ElMessage.success('迭代方案已生成')
  1177. } catch (e: any) {
  1178. ElMessage.error('生成失败: ' + (e.message || e))
  1179. } finally {
  1180. generating.value = false
  1181. }
  1182. }
  1183. const viewIteration = () => {
  1184. if (iterationPlan.value?.id) {
  1185. router.push(`/plans/${iterationPlan.value.id}`)
  1186. }
  1187. }
  1188. const extractExperience = async () => {
  1189. extracting.value = true
  1190. try {
  1191. await api.post(`/experience/from-plan/${planId.value}/smart-extract`, {})
  1192. experienceExtracted.value = true
  1193. aiStep.value = 3
  1194. ElMessage.success('经验已提取')
  1195. } catch (e: any) {
  1196. ElMessage.error('提取失败: ' + (e.message || e))
  1197. } finally {
  1198. extracting.value = false
  1199. }
  1200. }
  1201. // Data loading
  1202. const loadPlan = async () => {
  1203. try {
  1204. const res: any = await api.get(`/plans/${planId.value}`)
  1205. Object.assign(plan, res)
  1206. } catch (e: any) {
  1207. ElMessage.error('加载方案失败: ' + (e.message || e))
  1208. }
  1209. }
  1210. const loadResults = async () => {
  1211. try {
  1212. const res: any = await api.get(`/plans/${planId.value}/results`)
  1213. const raw = res.items || res.results || res.data || []
  1214. // Flatten nested params/metrics into a flat object for table display.
  1215. // Alias legacy metric names to the canonical afmcore keys (tavg_nm /
  1216. // ripple_pct) so older results still populate the columns.
  1217. results.value = raw.map((r: any) => {
  1218. const flat = { ...r, ...(r.params || {}), ...(r.metrics || {}) }
  1219. if (flat.tavg_nm == null && flat.average_torque_nm != null) flat.tavg_nm = flat.average_torque_nm
  1220. if (flat.ripple_pct == null && flat.torque_ripple_pct != null) flat.ripple_pct = flat.torque_ripple_pct
  1221. return flat
  1222. })
  1223. } catch {
  1224. results.value = []
  1225. }
  1226. }
  1227. const loadActiveTask = async () => {
  1228. try {
  1229. const res: any = await api.get(`/plans/${planId.value}/active-task`)
  1230. activeTask.value = res.task || res
  1231. isRunning.value = activeTask.value && ['running', 'dispatched'].includes(activeTask.value.status)
  1232. } catch {
  1233. activeTask.value = null
  1234. isRunning.value = false
  1235. }
  1236. }
  1237. const loadBcFieldCatalog = async () => {
  1238. try {
  1239. const res: any = await api.get('/bc-fields')
  1240. bcFieldCatalog.value = res.fields || []
  1241. } catch { /* optional: boundary display stays empty */ }
  1242. }
  1243. const loadSolveTimeStats = async () => {
  1244. try {
  1245. const res: any = await api.get('/analytics/solve-time-stats')
  1246. solveTimeStats.value = res
  1247. } catch { /* optional: fall back to heuristic estimate */ }
  1248. }
  1249. let pollTimer: any = null
  1250. onMounted(() => {
  1251. loadPlan()
  1252. loadResults()
  1253. loadActiveTask()
  1254. loadVariableCatalog()
  1255. loadBcFieldCatalog()
  1256. loadSolveTimeStats()
  1257. pollTimer = setInterval(() => {
  1258. if (isRunning.value) {
  1259. loadActiveTask()
  1260. loadResults()
  1261. }
  1262. }, 5000)
  1263. })
  1264. onUnmounted(() => {
  1265. if (pollTimer) clearInterval(pollTimer)
  1266. })
  1267. watch(activeTab, (tab) => {
  1268. if (tab === 'results') loadResults()
  1269. })
  1270. </script>
  1271. <style scoped>
  1272. .plan-detail {
  1273. padding: var(--space-6);
  1274. max-width: 1600px;
  1275. margin: 0 auto;
  1276. }
  1277. /* Progress Banner */
  1278. .progress-banner {
  1279. background: linear-gradient(135deg, var(--color-primary-bg), #e0e7ff);
  1280. border: 1px solid var(--color-primary-light);
  1281. border-radius: var(--radius-lg);
  1282. padding: var(--space-4) var(--space-5);
  1283. margin-bottom: var(--space-5);
  1284. }
  1285. .progress-info {
  1286. display: flex;
  1287. align-items: center;
  1288. gap: var(--space-3);
  1289. margin-bottom: var(--space-2);
  1290. }
  1291. .progress-title {
  1292. font-weight: 600;
  1293. color: var(--color-primary-dark);
  1294. }
  1295. .progress-detail {
  1296. font-size: var(--font-size-sm);
  1297. color: var(--color-text-secondary);
  1298. }
  1299. .progress-bar {
  1300. margin: 0;
  1301. }
  1302. /* Tabs */
  1303. .plan-tabs {
  1304. --el-tabs-header-height: 48px;
  1305. }
  1306. .plan-tabs :deep(.el-tabs__header) {
  1307. margin-bottom: var(--space-5);
  1308. border-bottom: 2px solid var(--color-border-light);
  1309. }
  1310. .plan-tabs :deep(.el-tabs__nav-wrap::after) {
  1311. display: none;
  1312. }
  1313. .plan-tabs :deep(.el-tabs__item) {
  1314. font-size: var(--font-size-base);
  1315. font-weight: 500;
  1316. height: 48px;
  1317. line-height: 48px;
  1318. }
  1319. /* Stat row */
  1320. .stat-row {
  1321. margin-bottom: var(--space-5);
  1322. }
  1323. /* AI reasoning */
  1324. .ai-reasoning {
  1325. font-size: var(--font-size-sm);
  1326. line-height: 1.8;
  1327. color: var(--color-text-secondary);
  1328. white-space: pre-wrap;
  1329. background: var(--color-border-light);
  1330. padding: var(--space-4);
  1331. border-radius: var(--radius-md);
  1332. border-left: 3px solid var(--color-primary);
  1333. }
  1334. /* Criteria */
  1335. .criteria-list {
  1336. display: flex;
  1337. flex-direction: column;
  1338. gap: var(--space-2);
  1339. }
  1340. .criteria-item {
  1341. display: flex;
  1342. align-items: center;
  1343. gap: var(--space-2);
  1344. font-size: var(--font-size-sm);
  1345. color: var(--color-text-secondary);
  1346. }
  1347. .criteria-icon {
  1348. color: var(--color-success);
  1349. flex-shrink: 0;
  1350. }
  1351. /* Quick actions */
  1352. .quick-actions {
  1353. display: grid;
  1354. grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  1355. gap: var(--space-4);
  1356. }
  1357. .quick-action-card {
  1358. border: 1px solid var(--color-border);
  1359. border-radius: var(--radius-lg);
  1360. padding: var(--space-5);
  1361. cursor: pointer;
  1362. transition: all var(--transition-fast);
  1363. text-align: center;
  1364. }
  1365. .quick-action-card:hover {
  1366. border-color: var(--color-primary);
  1367. box-shadow: var(--shadow-md);
  1368. transform: translateY(-2px);
  1369. }
  1370. .qa-title {
  1371. font-weight: 600;
  1372. font-size: var(--font-size-base);
  1373. color: var(--color-text-primary);
  1374. margin-top: var(--space-2);
  1375. }
  1376. .qa-desc {
  1377. font-size: var(--font-size-xs);
  1378. color: var(--color-text-muted);
  1379. margin-top: var(--space-1);
  1380. }
  1381. /* Fixed params */
  1382. .fixed-summary {
  1383. font-size: var(--font-size-sm);
  1384. color: var(--color-text-muted);
  1385. margin-right: var(--space-3);
  1386. }
  1387. .fixed-modified {
  1388. margin-bottom: var(--space-5);
  1389. }
  1390. .fixed-group-title {
  1391. display: flex;
  1392. align-items: center;
  1393. gap: var(--space-2);
  1394. font-size: var(--font-size-sm);
  1395. font-weight: 600;
  1396. color: var(--color-warning);
  1397. margin-bottom: var(--space-3);
  1398. }
  1399. .modified-value {
  1400. font-weight: 600;
  1401. color: var(--color-primary);
  1402. }
  1403. .var-code {
  1404. font-family: var(--font-mono);
  1405. font-size: 12px;
  1406. background: var(--color-border-light);
  1407. padding: 2px 6px;
  1408. border-radius: var(--radius-sm);
  1409. color: var(--color-text-secondary);
  1410. }
  1411. .fixed-category {
  1412. margin-bottom: var(--space-3);
  1413. }
  1414. .fixed-category-title {
  1415. display: flex;
  1416. align-items: center;
  1417. gap: var(--space-2);
  1418. padding: var(--space-2) var(--space-3);
  1419. background: var(--color-border-light);
  1420. border-radius: var(--radius-md);
  1421. cursor: pointer;
  1422. font-size: var(--font-size-sm);
  1423. font-weight: 600;
  1424. color: var(--color-text-secondary);
  1425. transition: background var(--transition-fast);
  1426. }
  1427. .fixed-category-title:hover {
  1428. background: var(--color-primary-light);
  1429. }
  1430. .cat-arrow {
  1431. font-size: 12px;
  1432. transition: transform var(--transition-fast);
  1433. }
  1434. .cat-count {
  1435. font-weight: 400;
  1436. color: var(--color-text-muted);
  1437. font-size: var(--font-size-xs);
  1438. }
  1439. /* AI steps */
  1440. .ai-steps {
  1441. margin-bottom: var(--space-6);
  1442. padding: var(--space-5);
  1443. background: var(--color-surface);
  1444. border-radius: var(--radius-lg);
  1445. border: 1px solid var(--color-border);
  1446. }
  1447. .ai-analysis-content {
  1448. display: flex;
  1449. flex-direction: column;
  1450. gap: var(--space-4);
  1451. }
  1452. .ai-section {
  1453. border: 1px solid var(--color-border-light);
  1454. border-radius: var(--radius-md);
  1455. overflow: hidden;
  1456. }
  1457. .ai-section-title {
  1458. background: var(--color-border-light);
  1459. padding: var(--space-2) var(--space-4);
  1460. font-size: var(--font-size-sm);
  1461. font-weight: 600;
  1462. color: var(--color-text-secondary);
  1463. }
  1464. .ai-section-body {
  1465. padding: var(--space-4);
  1466. font-size: var(--font-size-sm);
  1467. line-height: 1.7;
  1468. color: var(--color-text-secondary);
  1469. white-space: pre-wrap;
  1470. }
  1471. .iteration-content,
  1472. .experience-content {
  1473. padding: var(--space-2) 0;
  1474. }
  1475. /* Upload */
  1476. :deep(.el-upload-dragger) {
  1477. border-radius: var(--radius-lg);
  1478. }
  1479. /* Pre-flight checklist */
  1480. .preflight-body {
  1481. display: flex;
  1482. flex-direction: column;
  1483. gap: var(--space-2);
  1484. }
  1485. .thermal-mode-row {
  1486. display: flex;
  1487. align-items: center;
  1488. gap: var(--space-3);
  1489. }
  1490. .thermal-mode-label {
  1491. font-size: 13px;
  1492. color: var(--color-text-secondary);
  1493. font-weight: 500;
  1494. }
  1495. .preflight-item {
  1496. display: flex;
  1497. align-items: flex-start;
  1498. gap: var(--space-3);
  1499. padding: var(--space-3);
  1500. border: 1px solid var(--color-border);
  1501. border-radius: var(--radius-md);
  1502. }
  1503. .preflight-icon {
  1504. font-size: 20px;
  1505. margin-top: 2px;
  1506. }
  1507. .preflight-item.is-pass .preflight-icon { color: var(--color-success); }
  1508. .preflight-item.is-warn .preflight-icon { color: var(--color-warning); }
  1509. .preflight-item.is-fail .preflight-icon { color: var(--color-danger); }
  1510. .preflight-item.is-fail { border-color: var(--color-danger); background: #fef2f2; }
  1511. .preflight-label {
  1512. font-weight: 600;
  1513. font-size: var(--font-size-sm);
  1514. color: var(--color-text-primary);
  1515. }
  1516. .preflight-message {
  1517. font-size: var(--font-size-sm);
  1518. color: var(--color-text-secondary);
  1519. margin-top: 2px;
  1520. word-break: break-all;
  1521. }
  1522. .preflight-fix {
  1523. margin-top: 6px;
  1524. }
  1525. .est-basis {
  1526. margin-top: 4px;
  1527. font-size: 11px;
  1528. color: var(--color-text-muted);
  1529. text-align: center;
  1530. }
  1531. /* Result column settings */
  1532. .column-settings-tip {
  1533. font-size: var(--font-size-sm);
  1534. color: var(--color-text-muted);
  1535. margin-bottom: var(--space-3);
  1536. }
  1537. .column-settings-group {
  1538. display: grid;
  1539. grid-template-columns: 1fr 1fr;
  1540. gap: 4px 16px;
  1541. max-height: 400px;
  1542. overflow-y: auto;
  1543. }
  1544. .column-settings-item {
  1545. margin-right: 0;
  1546. }
  1547. /* Failed-status cell with error tooltip */
  1548. .status-failed-cell {
  1549. cursor: help;
  1550. border-bottom: 1px dashed var(--color-danger);
  1551. }
  1552. .bc-source-tag {
  1553. margin-left: 6px;
  1554. font-size: 10px;
  1555. height: 18px;
  1556. line-height: 16px;
  1557. padding: 0 4px;
  1558. }
  1559. .criteria-text {
  1560. flex: 1;
  1561. }
  1562. .criteria-origin {
  1563. margin-left: 8px;
  1564. flex-shrink: 0;
  1565. }
  1566. .var-values {
  1567. font-family: var(--font-mono, monospace);
  1568. font-size: 12px;
  1569. }
  1570. </style>