cmvr-wms/scripts/projectdev/web-design-checks.cjs
lixiaolong ca1f5a27f9 feat(mobile): 优化移动端界面和功能
- 添加移动工作空间对话框全屏样式支持
- 更新应用主视图以支持桌面视口布局
- 重构Excel导入对话框增加预览和校验功能
- 在移动端主页增加生产与交付模块和项目借还功能
- 移动端库存列表显示项目名称和成品标识
- 增加入库记录批量操作和撤销功能
- 优化分页组件在桌面视口中的滚动行为
- 更新路由配置和数据库连接配置
- 调整仓库领域模型移除预期日期字段
- 优化智能代理服务的正则匹配和出库类型处理
2026-10-12 16:41:42 +08:00

72 lines
13 KiB
JavaScript

// Design-contract checks, not a substitute for browser acceptance.
const fs=require('node:fs'),path=require('node:path'),assert=require('node:assert/strict');
const root=path.resolve(__dirname,'../..'),compiler=require(path.join(root,'ruoyi-ui/node_modules/vue-template-compiler'));
const read=p=>fs.readFileSync(path.join(root,'ruoyi-ui/src',p),'utf8');
const targets=['components/BusinessPageHeader/index.vue','views/businessHome/index.vue','views/project/info/index.vue','views/project/detail/index.vue','components/ProjectWorkspace/index.vue','components/ProjectWorkspace/Budget.vue','components/ProjectWorkspace/Costs.vue','components/ProjectLoans/index.vue','components/BomEditor/ProjectProducts.vue','components/SupplierPicker/index.vue','components/Production/ActionDialog.vue','components/Production/ActionHistory.vue','components/Production/BatchActions.vue','components/Production/StockOperations.vue','views/warehouse/pending/index.vue','views/warehouse/loans/index.vue','views/warehouse/suppliers/index.vue','views/warehouse/inRecord/index.vue','views/warehouse/outRecord/index.vue','views/warehouse/stock/index.vue','views/warehouse/purchase/index.vue','views/warehouse/arrival/index.vue','views/warehouse/product/index.vue','views/warehouse/area/index.vue','views/warehouse/stockCheck/index.vue','views/production/product/index.vue','views/production/bom/index.vue','views/production/tasks/index.vue','views/production/cost/index.vue','views/production/operations/index.vue','views/system/businessDictionaries/index.vue','views/system/initialization/index.vue','views/system/user/index.vue','views/system/role/index.vue','views/system/menu/index.vue','views/monitor/operlog/index.vue'];
targets.push('components/InventoryAssistant/index.vue','components/BomEditor/index.vue','components/BomEditor/ProductPicker.vue');
assert.ok(!read('layout/components/AppMain.vue').includes('name="fade-transform"'),'business pages must not animate flex/min-height while entering');
for(const p of targets){const parsed=compiler.parseComponent(read(p));assert.ok(parsed.template,p+' template missing');const result=compiler.compile(parsed.template.content);assert.equal(result.errors.length,0,p+': '+result.errors.join(';'));}
const workspace=read('components/ProjectWorkspace/index.vue');
for(const label of ['总览','分类预算','产品与BOM','采购','库存','借用与归还','生产','成本与损耗'])assert.ok(workspace.includes(`label="${label}"`),'missing tab '+label);
for(const component of ['project-budget','project-products','purchase-page','stock-page','project-loans','production-tasks','project-costs'])assert.ok(workspace.includes('<'+component),'missing embedded business '+component);
assert.ok(!workspace.includes('查看 / 维护项目产品与BOM'));
const purchase=read('views/warehouse/purchase/index.vue');assert.ok(!purchase.includes('@row-click="openDetail"'));assert.ok(!purchase.includes('<div class="task-board"'));assert.ok(purchase.includes(':page-sizes="[20,50,100]"'));assert.ok(purchase.includes('if(this.projectId || this.$route.query.projectId)this.queryParams.projectId='));
for(const label of ['物品名称','品牌','规格型号','项目','费用分类','用途','单位','最终单价'])assert.ok(purchase.includes(`label="${label}"`),'missing flat purchase column '+label);
assert.ok(!purchase.includes('label="物品编码"'),'item codes should be hidden from daily purchase tables');
assert.ok(purchase.includes(":label=\"arrivalMode ? '采购数量' : '数量'\""),'missing purchase/arrival quantity column');
for(const removed of ['expectedDate','预计到货','期望到货','label="申请人"','queryParams.applicantName'])assert.ok(!purchase.includes(removed),'removed purchase field returned: '+removed);
const mobilePurchase=read('views/mobile/components/MobilePurchase.vue');for(const removed of ['expectedDate','预计到货','期望到货','query.applicantName','筛选申请人','item.applicantName'])assert.ok(!mobilePurchase.includes(removed),'removed mobile purchase field returned: '+removed);
const projectInfo=read('views/project/info/index.vue');for(const removed of ['managerId','memberIds','startDate','endDate','项目负责人','项目成员','开始日期','结束日期','项目优先级','资金状态'])assert.ok(!projectInfo.includes(removed),'removed project field returned: '+removed);
assert.ok(projectInfo.includes(':selectable="canSelectProject"'),'protected legacy project must not be selectable for edit/delete');
for(const retired of ['TRIAL','OTHER','LEGACY'])assert.ok(!purchase.includes(`expenseCategoryCode: '${retired}'`),'retired category leaked into purchase page: '+retired);
const arrivalPage=read('views/warehouse/arrival/index.vue');
assert.ok(arrivalPage.includes('initial-view="arrival"'),'arrival route must activate arrival workbench');
for(const marker of ['arrival-workbench-page','arrivalQueueCards','applyArrivalQueue','arrivalActionLabel','canSelectArrival','批量登记 / 验收'])assert.ok(purchase.includes(marker),'arrival workbench missing '+marker);
for(const procurementOnly of ['新增采购批次','新增未分批明细','智能导入','锁定价格','批量修改项目 / 分类 / 用途'])assert.ok(purchase.includes(procurementOnly),'purchase maintenance action missing '+procurementOnly);
for(const view of ['batches','details','unbatched'])assert.ok(purchase.includes('label="'+view+'"'),'missing unified procurement view '+view);
assert.ok(purchase.includes('openBatchFromRow'));assert.ok(purchase.includes('采购批次 / 供应商'));assert.ok(purchase.includes('focusArrivalBatch'));
assert.ok(purchase.includes('<template v-if="!arrivalMode">'),'purchase maintenance actions must be hidden in arrival mode');
const pageHeaderTargets=['views/businessHome/index.vue','views/project/info/index.vue','components/ProjectWorkspace/index.vue','views/warehouse/purchase/index.vue','views/warehouse/inRecord/index.vue','views/warehouse/outRecord/index.vue','views/warehouse/stock/index.vue','views/warehouse/loans/index.vue','views/warehouse/stockCheck/index.vue','views/production/tasks/index.vue','views/warehouse/product/index.vue','views/production/product/index.vue','views/production/bom/index.vue','views/warehouse/suppliers/index.vue','views/warehouse/area/index.vue','views/system/businessDictionaries/index.vue','views/system/initialization/index.vue','views/system/user/index.vue','views/system/role/index.vue','views/system/menu/index.vue','views/monitor/operlog/index.vue'];
for(const page of pageHeaderTargets){if(page==='views/warehouse/purchase/index.vue'){assert.ok(read(page).includes('<purchase-sheet'),'procurement must retain its integrated spreadsheet toolbar');continue}assert.ok(read(page).includes('<business-page-header'),page+' missing unified page header');}
assert.ok(fs.readFileSync(path.join(root,'ruoyi-ui/src/assets/styles/index.scss'),'utf8').includes("@import './business-ui.scss'"),'unified business theme is not loaded');
const pageHeader=read('components/BusinessPageHeader/index.vue');
const businessTheme=fs.readFileSync(path.join(root,'ruoyi-ui/src/assets/styles/business-ui.scss'),'utf8');
assert.ok(!pageHeader.includes('business-page-header__icon'),'decorative page-header icon returned');
assert.ok(pageHeader.includes('v-if="$slots.actions"'),'empty title-only page header must not create a separate block');
assert.ok(!businessTheme.includes('linear-gradient'),'decorative gradient returned to business theme');
assert.ok(!businessTheme.includes('--cmvr-shadow'),'global card shadow returned to business theme');
assert.ok(businessTheme.includes('--cmvr-primary: #409eff'),'business theme must use RuoYi/Element primary color');
assert.ok(businessTheme.includes('background: #f5f7fa !important'),'tables must share the neutral gray header');
assert.ok(businessTheme.includes('border-right:0 !important'),'tables must share horizontal separators without vertical grids');
assert.ok(read('views/production/product/index.vue').includes('openBoms'));assert.ok(read('views/production/product/index.vue').includes('设为默认'));
assert.ok(read('views/production/tasks/index.vue').includes('<product-picker v-model="form.itemId"'));
assert.ok(!read('views/warehouse/product/index.vue').includes('label="物品编码"'));
assert.ok(!read('components/SupplierPicker/index.vue').includes('>删除未使用<'));
assert.ok(!purchase.includes('transform: translateY'),'floating dashboard-card effect returned to procurement pages');
const pending=read('views/warehouse/inRecord/index.vue');assert.ok(pending.includes('pendingOnly:Boolean'));assert.ok(pending.includes('if(this.pendingOnly)this.queryParams.inStatus=0'));
assert.ok(pending.includes(':selectable="canSelectPendingRecord"'),'inbound selection must only include pending records');
const stock=read('views/warehouse/stock/index.vue');for(const marker of ['finishedProduct','canSelectStock','SCRAP_STOCK','SCRAP_FINISHED','DELIVERY'])assert.ok(stock.includes(marker),'stock business control missing '+marker);
const stockOperations=read('components/Production/StockOperations.vue');for(const marker of ['operationOptions','targetAreas','只有产品档案中的成品库存','请填写交付接收方'])assert.ok(stockOperations.includes(marker),'stock operation guard missing '+marker);
const actionDialog=read('components/Production/ActionDialog.vue');assert.ok(actionDialog.includes('stockMatchesKind'));assert.ok(actionDialog.includes("task.status === 'SETTLED'"));
const productionTasks=read('views/production/tasks/index.vue');for(const marker of ['canSelectTask','needOutstanding','hasIssuableNeeds',"detail.status==='OPEN'"])assert.ok(productionTasks.includes(marker),'production task state control missing '+marker);
for(const marker of ['继续生产','reopenTask','await this.$confirm','settleTask(id,version)','production-task-dialog','command="SCRAP_ASSEMBLY"'])assert.ok(productionTasks.includes(marker),'production usability control missing '+marker);
assert.ok(read('components/BomEditor/ProjectProducts.vue').includes('<product-picker v-model="form.itemId"'),'project association must select product archives');
assert.ok(read('components/BomEditor/index.vue').includes('<product-picker v-if="!form.id"'),'BOM output must select product archives');
assert.ok(actionDialog.includes('task.needs||[]'),'issue stock choices must match the task BOM');
assert.ok(actionDialog.includes('loadOperationTasks') && actionDialog.includes('领料记录'),'scrap operations must identify task/source');
const actionHistory=read('components/Production/ActionHistory.vue');assert.ok(actionHistory.includes(':selectable="canSelectAction"'));assert.ok(actionHistory.includes('canBatch(kind)'));
const stockCheck=read('views/warehouse/stockCheck/index.vue');assert.ok(stockCheck.includes(':selectable="canSelectCheck"'),'stock-check selection must only include drafts');
const outRecord=read('views/warehouse/outRecord/index.vue');assert.ok(outRecord.includes('remainingOut(s.row)>0'),'return action must require an outstanding quantity');
const projectLoans=read('components/ProjectLoans/index.vue');assert.ok(projectLoans.includes(':selectable="canSelectLoan"'));assert.ok(projectLoans.includes('canRevokeLoan'));
for(const marker of ['canBatchArrivalSelection','canBulkEditSelection','canLockSelection','canDeleteSelection','canEditPrice','receivedQuantity'])assert.ok(purchase.includes(marker),'purchase business control missing '+marker);
const home=read('views/businessHome/index.vue');assert.ok(home.includes('<inventory-assistant v-if="canAssistant"'));assert.ok(home.includes("ai:assistant:use"));assert.ok(!home.includes('出库登记'));
assert.ok(home.includes('v-for="q in todoQueues"') && home.includes('home-followups'),'home waiting progress must be separate from operator todos');
const sheet=read('components/PurchaseSheet/index.vue');assert.ok(sheet.includes("field:'category',label:'物品类别',width:120,required:true"),'item category must remain visible and required');assert.ok(!sheet.includes('计划 / 类别 / 备注'));
assert.ok(read('utils/purchase-sheet.js').includes("if(!clean(row.category))throw new Error('请选择物品类别')"));
const assistant=read('components/InventoryAssistant/index.vue');for(const guard of ['commandId','hasActionPermission','text.trim()===this.analyzedText','this.busy','this.$confirm','executeAgent({plan})'])assert.ok(assistant.includes(guard),'AI assistant execution guard missing '+guard);
const product=read('views/warehouse/product/index.vue');assert.ok(product.includes("dicts:['wms_item_category','wms_item_unit']"));
const routes=read('router/index.js');for(const target of ['@/views/businessHome','@/views/project/detail'])assert.ok(routes.includes(target));
for(const migration of ['018_web_business_navigation.sql','022_confirmed_web_navigation.sql']){const sql=fs.readFileSync(path.join(root,'sql/projectdev',migration),'utf8');for(const match of sql.matchAll(/'((?:warehouse|production|system)\/[a-zA-Z]+\/index)'/g))assert.ok(fs.existsSync(path.join(root,'ruoyi-ui/src/views',match[1]+'.vue')),match[1]+' missing menu page');}
const navigation=fs.readFileSync(path.join(root,'sql/projectdev/022_confirmed_web_navigation.sql'),'utf8');for(const label of ['项目管理','采购管理','库存管理','生产管理','材料成本','基础资料','系统管理','采购明细','到货验收','业务字典','历史数据补录','操作日志'])assert.ok(navigation.includes(`'${label}'`),'missing confirmed navigation '+label);
console.log(`PASS: ${targets.length} templates and business navigation/design contracts. Browser interaction NOT tested.`);