| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <script setup lang="ts"> |
| | | import { computed, nextTick, onMounted, onUnmounted, ref } from 'vue'; |
| | | |
| | | import { message } from 'ant-design-vue'; |
| | | import { IconifyIcon } from '@vben/icons'; |
| | | import { gsap } from 'gsap'; |
| | | |
| | | import { |
| | | submitSeedQuality, |
| | | type MesQcSeedQualityApi, |
| | | } from '#/api/mes/qc/seedQuality'; |
| | | |
| | | interface IndicatorForm { |
| | | code: string; |
| | | label: string; |
| | | unit: string; |
| | | value?: number; |
| | | minValue?: number; |
| | | maxValue?: number; |
| | | } |
| | | |
| | | const pageRoot = ref<HTMLElement>(); |
| | | const code = ref(''); |
| | | const itemId = ref<number>(); |
| | | const batchCode = ref(''); |
| | | const reason = ref(''); |
| | | const loading = ref(false); |
| | | const submittedId = ref<number>(); |
| | | let animationContext: gsap.Context | undefined; |
| | | |
| | | const indicators = ref<IndicatorForm[]>([ |
| | | { code: 'purity', label: '纯度', unit: '%', minValue: 0, maxValue: 100 }, |
| | | { code: 'cleanliness', label: 'å度', unit: '%', minValue: 0, maxValue: 100 }, |
| | | { code: 'germination_rate', label: 'åè½ç', unit: '%', minValue: 0, maxValue: 100 }, |
| | | { code: 'moisture', label: 'æ°´å', unit: '%', minValue: 0, maxValue: 100 }, |
| | | ]); |
| | | |
| | | const enteredCount = computed(() => indicators.value.filter((item) => item.value !== undefined && item.value !== null).length); |
| | | const passedCount = computed(() => indicators.value.filter(isPassed).length); |
| | | const allEntered = computed(() => enteredCount.value === indicators.value.length); |
| | | const overallPassed = computed(() => allEntered.value && passedCount.value === indicators.value.length); |
| | | |
| | | function isPassed(item: IndicatorForm) { |
| | | return item.value !== undefined && item.value !== null |
| | | && item.minValue !== undefined && item.maxValue !== undefined |
| | | && item.value >= item.minValue && item.value <= item.maxValue; |
| | | } |
| | | |
| | | function resetForm(clearResult = true) { |
| | | code.value = ''; |
| | | itemId.value = undefined; |
| | | batchCode.value = ''; |
| | | reason.value = ''; |
| | | if (clearResult) submittedId.value = undefined; |
| | | indicators.value.forEach((item) => { |
| | | item.value = undefined; |
| | | item.minValue = 0; |
| | | item.maxValue = 100; |
| | | }); |
| | | } |
| | | |
| | | async function submit() { |
| | | if (!code.value.trim() || !itemId.value) { |
| | | message.warning('请填åè¢ç åç©æ ID'); |
| | | return; |
| | | } |
| | | if (!allEntered.value) { |
| | | message.warning('请å
å¡«ååé¡¹ææ ç宿µå¼'); |
| | | return; |
| | | } |
| | | if (indicators.value.some((item) => item.minValue === undefined || item.maxValue === undefined || item.minValue > item.maxValue)) { |
| | | message.warning('ææ ä¸éä¸è½å¤§äºä¸é'); |
| | | return; |
| | | } |
| | | if (!overallPassed.value && !reason.value.trim()) { |
| | | message.warning('æ£éªä¸åæ ¼æ¶å¿
须填åä¸åæ ¼åå '); |
| | | return; |
| | | } |
| | | |
| | | loading.value = true; |
| | | try { |
| | | submittedId.value = await submitSeedQuality({ |
| | | code: code.value.trim(), |
| | | itemId: itemId.value, |
| | | batchCode: batchCode.value.trim() || undefined, |
| | | indicators: indicators.value.map(({ code: indicatorCode, value, minValue, maxValue }) => ({ |
| | | code: indicatorCode, |
| | | value: value as number, |
| | | minValue: minValue as number, |
| | | maxValue: maxValue as number, |
| | | })), |
| | | reason: reason.value.trim() || undefined, |
| | | }); |
| | | message.success(`è´¨æ£æäº¤æåï¼è´¨æ£ç¼å·ï¼${submittedId.value}`); |
| | | if (pageRoot.value && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) { |
| | | gsap.fromTo('.result-card', { scale: 0.97, autoAlpha: 0.5 }, { scale: 1, autoAlpha: 1, duration: 0.35, ease: 'power2.out' }); |
| | | } |
| | | resetForm(false); |
| | | } catch (error) { |
| | | const response = error as { message?: string; msg?: string }; |
| | | message.error(response.message ?? response.msg ?? 'è´¨æ£æäº¤å¤±è´¥ï¼è¯·æ£æ¥è¡¨ååéè¯'); |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | | } |
| | | |
| | | onMounted(async () => { |
| | | await nextTick(); |
| | | if (!pageRoot.value) return; |
| | | animationContext = gsap.context(() => { |
| | | const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; |
| | | gsap.from('.page-header, .summary-card, .form-card, .result-card', { |
| | | autoAlpha: reduceMotion ? 1 : 0, |
| | | y: reduceMotion ? 0 : 14, |
| | | duration: reduceMotion ? 0 : 0.4, |
| | | stagger: reduceMotion ? 0 : 0.06, |
| | | ease: 'power2.out', |
| | | }); |
| | | }, pageRoot.value); |
| | | }); |
| | | |
| | | onUnmounted(() => animationContext?.revert()); |
| | | </script> |
| | | |
| | | <template> |
| | | <div ref="pageRoot" class="quality-page"> |
| | | <header class="page-header"> |
| | | <div> |
| | | <div class="eyebrow">MES / è´¨é管ç</div> |
| | | <h1>ç§åè´¨æ£</h1> |
| | | <p>å½å
¥çº¯åº¦ãå度ãåè½çåæ°´åï¼ç³»ç»æ ¹æ®æ åèå´èªå¨å¤å®æ£éªç»è®º</p> |
| | | </div> |
| | | <div class="header-badge"><IconifyIcon icon="ep:checked" /> åé¡¹ææ æ£éª</div> |
| | | </header> |
| | | |
| | | <section class="summary-grid" aria-label="è´¨æ£æè¦"> |
| | | <div class="summary-card blue"><IconifyIcon icon="ep:document-checked" /><div><span>æ£éªé¡¹ç®</span><strong>4</strong><small>纯度ãå度ãåè½çãæ°´å</small></div></div> |
| | | <div class="summary-card green"><IconifyIcon icon="ep:success-filled" /><div><span>å½ååæ ¼é¡¹</span><strong>{{ passedCount }} / 4</strong><small>宿¶ä¾æ®ä¸ä¸é夿</small></div></div> |
| | | <div class="summary-card" :class="overallPassed ? 'green' : allEntered ? 'red' : 'blue'"><IconifyIcon :icon="overallPassed ? 'ep:circle-check-filled' : allEntered ? 'ep:warning-filled' : 'ep:edit-pen'" /><div><span>æ»ä½ç»è®º</span><strong>{{ overallPassed ? 'åæ ¼' : allEntered ? 'ä¸åæ ¼' : 'å¾
å½å
¥' }}</strong><small>{{ overallPassed ? 'å¯æäº¤åæ ¼ç»æ' : allEntered ? '请填åä¸åæ ¼åå ' : `å·²å½å
¥ ${enteredCount} / 4 项` }}</small></div></div> |
| | | </section> |
| | | |
| | | <section class="content-grid"> |
| | | <a-card class="form-card" :bordered="false"> |
| | | <template #title><div class="card-title"><IconifyIcon icon="ep:edit-pen" />è´¨æ£ä¿¡æ¯</div></template> |
| | | <a-form layout="vertical"> |
| | | <div class="base-grid"> |
| | | <a-form-item label="è¢ç " required><a-input v-model:value="code" size="large" placeholder="请è¾å
¥ææ«æè¢ç " /></a-form-item> |
| | | <a-form-item label="ç©æ ID" required><a-input-number v-model:value="itemId" class="full-width" size="large" :min="1" placeholder="请è¾å
¥ç©æç¼å·" /></a-form-item> |
| | | <a-form-item label="çäº§æ¹æ¬¡"><a-input v-model:value="batchCode" size="large" placeholder="请è¾å
¥æ¹æ¬¡å·ï¼éå¡«ï¼" /></a-form-item> |
| | | </div> |
| | | |
| | | <a-divider orientation="left">ææ ç»æ</a-divider> |
| | | <div class="indicator-list"> |
| | | <div v-for="item in indicators" :key="item.code" class="indicator-row" :class="{ failed: !isPassed(item) }"> |
| | | <div class="indicator-name"><span class="indicator-dot" :class="isPassed(item) ? 'pass' : 'fail'" /><strong>{{ item.label }}</strong><small>{{ item.unit }}</small></div> |
| | | <a-input-number v-model:value="item.value" class="indicator-input" :min="0" :precision="3" placeholder="宿µå¼" /> |
| | | <span class="range-separator">èå´</span> |
| | | <a-input-number v-model:value="item.minValue" class="range-input" :min="0" :precision="3" placeholder="ä¸é" /> |
| | | <span>â</span> |
| | | <a-input-number v-model:value="item.maxValue" class="range-input" :min="0" :precision="3" placeholder="ä¸é" /> |
| | | <a-tag :color="isPassed(item) ? 'success' : 'error'">{{ isPassed(item) ? 'åæ ¼' : 'è¶
åºèå´' }}</a-tag> |
| | | </div> |
| | | </div> |
| | | |
| | | <a-form-item label="ä¸åæ ¼åå " :required="!overallPassed" class="reason-item"><a-textarea v-model:value="reason" :rows="3" :maxlength="500" show-count :placeholder="overallPassed ? 'åæ ¼ç»ææ éå¡«å' : '请说æä¸åæ ¼åå '" /></a-form-item> |
| | | <div class="form-actions"><a-button @click="resetForm">éç½®</a-button><a-button type="primary" size="large" :loading="loading" @click="submit"><IconifyIcon icon="ep:upload-filled" />æäº¤è´¨æ£</a-button></div> |
| | | </a-form> |
| | | </a-card> |
| | | |
| | | <a-card class="result-card" :bordered="false"> |
| | | <template #title><div class="card-title"><IconifyIcon icon="ep:data-analysis" />å¤å®è¯´æ</div></template> |
| | | <div class="result-hero" :class="overallPassed ? 'passed' : allEntered ? 'failed-result' : 'pending-result'"><IconifyIcon :icon="overallPassed ? 'ep:circle-check-filled' : allEntered ? 'ep:warning-filled' : 'ep:edit-pen'" /><strong>{{ overallPassed ? 'å½åç»æåæ ¼' : allEntered ? 'å½ååå¨ä¸åæ ¼é¡¹' : 'çå¾
å½å
¥ææ ' }}</strong><span>{{ allEntered ? '宿µå¼éå¤äºæå°å¼ä¸æå¤§å¼ä¹é´' : `å·²å½å
¥ ${enteredCount} / 4 项宿µå¼` }}</span></div> |
| | | <div class="rule-list"><div><IconifyIcon icon="ep:check" /><span>åé¡¹ææ å¿
é¡»å
¨é¨æäº¤</span></div><div><IconifyIcon icon="ep:check" /><span>è¾¹çå¼æåæ ¼å¤ç</span></div><div><IconifyIcon icon="ep:check" /><span>ä¸åæ ¼ç»æéä¿çåå </span></div><div><IconifyIcon icon="ep:check" /><span>è´¨æ£å䏿£éªæ¶é´ç±æå¡ç«¯è®°å½</span></div></div> |
| | | <a-alert message="åºåä½ç½®ç±åå°é
置解æ" description="æ¬é¡µé¢åªæäº¤è¢ç ãç©æãæ¹æ¬¡åæ£éªææ ï¼ä¸å
许åç«¯éæ©ä»åºãåºåºæåºä½ã" type="info" show-icon /> |
| | | <div v-if="submittedId" class="success-note"><IconifyIcon icon="ep:success-filled" /><span>æè¿æäº¤è´¨æ£ç¼å·ï¼<strong>{{ submittedId }}</strong></span></div> |
| | | </a-card> |
| | | </section> |
| | | </div> |
| | | </template> |
| | | |
| | | <style scoped> |
| | | .quality-page { min-height: 100%; padding: 24px; background: #f4f7fb; color: #172033; } |
| | | .page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }.eyebrow { color: #1677ff; font-size: 12px; font-weight: 700; letter-spacing: .08em; }.page-header h1 { margin: 6px 0; font-size: 28px; }.page-header p { margin: 0; color: #718096; }.header-badge { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid #cfe0fb; border-radius: 7px; color: #1677ff; background: #f0f6ff; font-size: 13px; font-weight: 600; } |
| | | .summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }.summary-card { display: flex; align-items: flex-start; gap: 14px; padding: 17px 19px; border: 1px solid #e8edf5; border-radius: 10px; background: #fff; box-shadow: 0 3px 12px #243b5310; }.summary-card > .iconify { flex: 0 0 38px; width: 38px; height: 38px; padding: 9px; border-radius: 8px; font-size: 20px; }.summary-card.blue > .iconify { color: #1677ff; background: #eaf3ff; }.summary-card.green > .iconify { color: #17a673; background: #e6f8f0; }.summary-card.red > .iconify { color: #e05252; background: #fff0f0; }.summary-card span, .summary-card small { display: block; color: #7b8799; font-size: 12px; }.summary-card strong { display: block; margin: 4px 0; font-size: 23px; }.content-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(310px, .75fr); gap: 18px; }.form-card, .result-card { border-radius: 10px; box-shadow: 0 3px 12px #243b5310; }.card-title { display: flex; align-items: center; gap: 9px; font-weight: 700; }.card-title :deep(.iconify) { color: #1677ff; }.base-grid { display: grid; grid-template-columns: 1.3fr 1fr 1.2fr; gap: 16px; }.full-width { width: 100%; } |
| | | .indicator-list { display: flex; flex-direction: column; gap: 10px; }.indicator-row { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid #e8edf5; border-radius: 7px; background: #fbfcfe; }.indicator-row.failed { border-color: #ffd6d6; background: #fffafa; }.indicator-name { display: flex; align-items: center; gap: 8px; min-width: 82px; }.indicator-name small { color: #8793a5; font-size: 12px; }.indicator-dot { width: 8px; height: 8px; border-radius: 50%; }.indicator-dot.pass { background: #20b878; }.indicator-dot.fail { background: #e05252; }.indicator-input { width: 105px; }.range-input { width: 88px; }.range-separator { margin-left: auto; color: #8793a5; font-size: 12px; }.reason-item { margin-top: 18px; }.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 5px; }.form-actions :deep(.iconify) { margin-right: 5px; } |
| | | .result-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 8px 0 22px; padding: 25px 15px; border-radius: 8px; text-align: center; }.result-hero :deep(.iconify) { font-size: 35px; }.result-hero strong { font-size: 18px; }.result-hero span { color: #718096; font-size: 12px; }.result-hero.passed { color: #16835b; background: #effaf5; }.result-hero.failed-result { color: #c53e3e; background: #fff3f3; }.result-hero.pending-result { color: #1677ff; background: #f0f6ff; }.rule-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }.rule-list div { display: flex; align-items: center; gap: 9px; color: #59677b; font-size: 13px; }.rule-list :deep(.iconify) { color: #20b878; }.success-note { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 11px 12px; border-radius: 7px; color: #16835b; background: #effaf5; font-size: 13px; } |
| | | @media (max-width: 1050px) { .content-grid { grid-template-columns: 1fr; }.base-grid { grid-template-columns: repeat(3, 1fr); } } |
| | | @media (max-width: 760px) { .quality-page { padding: 14px; }.page-header { display: block; }.header-badge { margin-top: 14px; }.summary-grid, .base-grid { grid-template-columns: 1fr; }.indicator-row { flex-wrap: wrap; }.range-separator { margin-left: 0; }.indicator-input { flex: 1; min-width: 105px; }.range-input { flex: 1; min-width: 75px; } } |
| | | </style> |