提交
This commit is contained in:
1 parent
0b50eff3d8
commit
ee364e24aa
323 files changed
+57731
-35766
No files matched your search
@@ -3,47 +3,58 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-pill-tabs panel-pill-tabs--lg">
|
||||
<div class="panel-pill-tabs__track" role="tablist">
|
||||
<button
|
||||
v-for="tab in PRODUCTION_WORK_ORDER_VISIBLE_TABS"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="panel-pill-tabs__btn"
|
||||
:class="{ 'is-active': activeTabKey === tab.key }"
|
||||
:aria-selected="activeTabKey === tab.key"
|
||||
@click="handleTabChange(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<ProductionWorkOrderTabBar
|
||||
ref="tabBarRef"
|
||||
:active-tab-key="activeTabKey"
|
||||
scope="mine"
|
||||
@change="handleTabChange"
|
||||
/>
|
||||
|
||||
<component :is="activeTabComponent" :key="activeTabKey" page-mode="mine" />
|
||||
<ProductionWorkOrderTabPanel
|
||||
ref="activeTabRef"
|
||||
:key="activeTabKey"
|
||||
:tab-key="activeTabKey"
|
||||
page-mode="mine"
|
||||
@data-changed="reloadTabCounts"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
PRODUCTION_WORK_ORDER_VISIBLE_TABS,
|
||||
parseProductionWorkOrderTabKey,
|
||||
type ProductionWorkOrderTabKey
|
||||
} from '@/utils/production-work-order-tabs'
|
||||
import { getProductionWorkOrderTabComponent } from '../production-work-order/tabs/tab-registry'
|
||||
import { refreshProductionMenuBadges } from '@/utils/production-menu-badge'
|
||||
import ProductionWorkOrderTabBar from '../production-work-order/ProductionWorkOrderTabBar.vue'
|
||||
import ProductionWorkOrderTabPanel from '../production-work-order/tabs/ProductionWorkOrderTabPanel.vue'
|
||||
|
||||
defineOptions({ name: 'ProductionMyProductionTask' })
|
||||
|
||||
type ProductionWorkOrderTabPanelExpose = {
|
||||
reload: () => Promise<void>
|
||||
}
|
||||
|
||||
type ProductionWorkOrderTabBarExpose = {
|
||||
reload: () => Promise<void>
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const tabBarRef = ref<ProductionWorkOrderTabBarExpose | null>(null)
|
||||
const activeTabRef = ref<ProductionWorkOrderTabPanelExpose | null>(null)
|
||||
|
||||
const activeTabKey = ref<ProductionWorkOrderTabKey>(
|
||||
parseProductionWorkOrderTabKey(route.query.tab as string)
|
||||
)
|
||||
const activeTabComponent = computed(() => getProductionWorkOrderTabComponent(activeTabKey.value))
|
||||
|
||||
function reloadTabCounts() {
|
||||
tabBarRef.value?.reload()
|
||||
void refreshProductionMenuBadges()
|
||||
}
|
||||
|
||||
function handleTabChange(key: ProductionWorkOrderTabKey) {
|
||||
if (activeTabKey.value === key) return
|
||||
|
||||
@@ -129,6 +129,13 @@
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="productionDate"
|
||||
label="生产日期"
|
||||
min-width="110"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="materialCode"
|
||||
label="物料编码"
|
||||
@@ -326,6 +333,15 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="生产日期" prop="productionDate">
|
||||
<el-date-picker
|
||||
v-model="formData.productionDate"
|
||||
type="date"
|
||||
placeholder="选择生产日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="货号" prop="catalogNo">
|
||||
<el-input v-model="formData.catalogNo" placeholder="请输入货号" />
|
||||
</el-form-item>
|
||||
@@ -514,6 +530,15 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="生产日期">
|
||||
<el-date-picker
|
||||
v-model="stockInForm.productionDate"
|
||||
type="date"
|
||||
placeholder="选择生产日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="货号" prop="catalogNo">
|
||||
<el-input v-model="stockInForm.catalogNo" placeholder="请输入货号" />
|
||||
</el-form-item>
|
||||
@@ -736,6 +761,16 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="生产日期">
|
||||
<el-date-picker
|
||||
v-model="row.productionDate"
|
||||
size="small"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="可选"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="货号">
|
||||
<el-input v-model="row.catalogNo" size="small" placeholder="必填" />
|
||||
</el-form-item>
|
||||
@@ -1541,6 +1576,7 @@
|
||||
stockInNo: '',
|
||||
stockInDate: '',
|
||||
expireDate: '',
|
||||
productionDate: '',
|
||||
catalogNo: '',
|
||||
batchNo: '',
|
||||
manufacturer: '',
|
||||
@@ -1586,6 +1622,7 @@
|
||||
stockInNo: '',
|
||||
stockInDate: '',
|
||||
expireDate: '',
|
||||
productionDate: '',
|
||||
catalogNo: '',
|
||||
batchNo: '',
|
||||
manufacturer: '',
|
||||
@@ -1676,6 +1713,7 @@
|
||||
stockInNo: string
|
||||
stockInDate: string
|
||||
expireDate: string
|
||||
productionDate: string
|
||||
catalogNo: string
|
||||
batchNo: string
|
||||
manufacturer: string
|
||||
@@ -1786,6 +1824,7 @@
|
||||
stockInNo: { title: '入库编号' },
|
||||
stockInDate: { title: '入库日期' },
|
||||
expireDate: { title: '过期日期' },
|
||||
productionDate: { title: '生产日期' },
|
||||
materialCode: { title: '物料编码' },
|
||||
materialName: { title: '物料名称' },
|
||||
materialType: {
|
||||
@@ -1815,6 +1854,7 @@
|
||||
stockInNo: row.stockInNo,
|
||||
stockInDate: row.stockInDate,
|
||||
expireDate: row.expireDate,
|
||||
productionDate: row.productionDate || '',
|
||||
materialCode: row.materialCode,
|
||||
materialName: row.materialName,
|
||||
materialType: row.materialType,
|
||||
@@ -1865,6 +1905,7 @@
|
||||
{ label: '入库编号', value: row.stockInNo },
|
||||
{ label: '入库日期', value: row.stockInDate },
|
||||
{ label: '过期日期', value: row.expireDate },
|
||||
{ label: '生产日期', value: row.productionDate || '—' },
|
||||
{ label: '货号', value: row.catalogNo },
|
||||
{ label: '批号', value: row.batchNo },
|
||||
{ label: '厂家', value: row.manufacturer },
|
||||
@@ -1979,6 +2020,7 @@
|
||||
formData.stockInNo = row.stockInNo || ''
|
||||
formData.stockInDate = row.stockInDate || ''
|
||||
formData.expireDate = row.expireDate || ''
|
||||
formData.productionDate = row.productionDate || ''
|
||||
formData.catalogNo = row.catalogNo || ''
|
||||
formData.batchNo = row.batchNo || ''
|
||||
formData.manufacturer = row.manufacturer || ''
|
||||
@@ -2010,6 +2052,7 @@
|
||||
stockInNo: formData.stockInNo.trim(),
|
||||
stockInDate: formData.stockInDate,
|
||||
expireDate: formData.expireDate,
|
||||
productionDate: formData.productionDate || undefined,
|
||||
catalogNo: formData.catalogNo.trim(),
|
||||
batchNo: formData.batchNo.trim(),
|
||||
manufacturer: formData.manufacturer.trim(),
|
||||
@@ -2121,6 +2164,7 @@
|
||||
stockInForm.stockInNo = ''
|
||||
stockInForm.stockInDate = formatTodayDate()
|
||||
stockInForm.expireDate = ''
|
||||
stockInForm.productionDate = ''
|
||||
stockInForm.catalogNo = ''
|
||||
stockInForm.batchNo = ''
|
||||
stockInForm.manufacturer = ''
|
||||
@@ -2153,6 +2197,7 @@
|
||||
stockInNo: stockInForm.stockInNo.trim(),
|
||||
stockInDate: stockInForm.stockInDate,
|
||||
expireDate: stockInForm.expireDate,
|
||||
productionDate: stockInForm.productionDate || undefined,
|
||||
catalogNo: stockInForm.catalogNo.trim(),
|
||||
batchNo: stockInForm.batchNo.trim(),
|
||||
manufacturer: stockInForm.manufacturer.trim(),
|
||||
@@ -2183,6 +2228,7 @@
|
||||
stockInNo: '',
|
||||
stockInDate: formatTodayDate(),
|
||||
expireDate: '',
|
||||
productionDate: '',
|
||||
catalogNo: '',
|
||||
batchNo: '',
|
||||
manufacturer: '',
|
||||
@@ -2434,6 +2480,7 @@
|
||||
stockInNo: l.stockInNo.trim(),
|
||||
stockInDate: l.stockInDate,
|
||||
expireDate: l.expireDate,
|
||||
productionDate: l.productionDate || undefined,
|
||||
catalogNo: l.catalogNo.trim(),
|
||||
batchNo: l.batchNo.trim(),
|
||||
manufacturer: l.manufacturer.trim(),
|
||||
|
||||
@@ -47,10 +47,10 @@
|
||||
<template #default="{ row }">
|
||||
<el-date-picker
|
||||
v-model="row.plannedStartTime"
|
||||
type="datetime"
|
||||
type="date"
|
||||
placeholder="可选"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
value-format="YYYY-MM-DDTHH:mm:00"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
/>
|
||||
@@ -75,6 +75,7 @@
|
||||
import { Close, Check } from '@element-plus/icons-vue'
|
||||
import { fetchUserList } from '@/api/admin'
|
||||
import { fetchProductionTaskDetail, fetchDispatchProductionTaskSteps } from '@/api/production-task'
|
||||
import { normalizePlannedStartDate } from '@/utils/production-labels'
|
||||
|
||||
defineOptions({ name: 'DispatchStepDialog' })
|
||||
|
||||
@@ -154,7 +155,7 @@
|
||||
stepId: s.id,
|
||||
processName: s.processName || '未命名步骤',
|
||||
assigneeUserIds: [...(s.assigneeUserIds || [])],
|
||||
plannedStartTime: s.plannedStartTime || null,
|
||||
plannedStartTime: normalizePlannedStartDate(s.plannedStartTime),
|
||||
presetUsers: (s.assignees || []).map((a: Record<string, any>) => ({
|
||||
id: a.userId,
|
||||
nickName: a.nickName,
|
||||
|
||||
+5
-1
@@ -511,7 +511,7 @@
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 8px 16px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
@@ -662,6 +662,10 @@
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.production-work-order-card__tasks :deep(.work-order-task-step-sublist) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.production-work-order-cards-empty {
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<!-- 生产工单 Tab 栏(工艺步骤到期/未安排角标) -->
|
||||
<template>
|
||||
<div class="panel-pill-tabs panel-pill-tabs--lg">
|
||||
<div class="panel-pill-tabs__track" role="tablist">
|
||||
<button
|
||||
v-for="tab in PRODUCTION_WORK_ORDER_VISIBLE_TABS"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="panel-pill-tabs__btn"
|
||||
:class="{ 'is-active': activeTabKey === tab.key }"
|
||||
:aria-selected="activeTabKey === tab.key"
|
||||
@click="emit('change', tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<span
|
||||
class="panel-pill-tabs__badge panel-pill-tabs__badge--dual"
|
||||
:class="{
|
||||
'panel-pill-tabs__badge--zero': isProductionWorkOrderTabStepBadgeZero(getTabCount(tab.key))
|
||||
}"
|
||||
>
|
||||
{{ formatProductionWorkOrderTabStepBadge(getTabCount(tab.key)) }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
formatProductionWorkOrderTabStepBadge,
|
||||
isProductionWorkOrderTabStepBadgeZero
|
||||
} from '@/api/production-work-order'
|
||||
import {
|
||||
PRODUCTION_WORK_ORDER_VISIBLE_TABS,
|
||||
type ProductionWorkOrderTabKey
|
||||
} from '@/utils/production-work-order-tabs'
|
||||
import {
|
||||
useProductionWorkOrderTabStepCounts,
|
||||
type ProductionWorkOrderTabCountScope
|
||||
} from './composables/useProductionWorkOrderTabStepCounts'
|
||||
|
||||
defineOptions({ name: 'ProductionWorkOrderTabBar' })
|
||||
|
||||
const props = defineProps<{
|
||||
activeTabKey: ProductionWorkOrderTabKey
|
||||
scope: ProductionWorkOrderTabCountScope
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
change: [key: ProductionWorkOrderTabKey]
|
||||
}>()
|
||||
|
||||
const { getTabCount, loadTabCounts } = useProductionWorkOrderTabStepCounts(props.scope)
|
||||
|
||||
defineExpose({
|
||||
reload: loadTabCounts
|
||||
})
|
||||
</script>
|
||||
@@ -199,9 +199,7 @@
|
||||
prop="labStorageCode"
|
||||
>
|
||||
<template #label>
|
||||
实验室入库编码<span class="form-label-tip"
|
||||
>RK+接收日期+序号,保存后不可修改</span
|
||||
>
|
||||
实验室入库编码<span class="form-label-tip">保存后不可修改</span>
|
||||
</template>
|
||||
<el-input
|
||||
v-model="receiveForm.labStorageCode"
|
||||
|
||||
@@ -172,10 +172,10 @@
|
||||
>
|
||||
<el-date-picker
|
||||
v-model="editor.selectedStep.value.plannedStartTime"
|
||||
type="datetime"
|
||||
type="date"
|
||||
placeholder="可选"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
value-format="YYYY-MM-DDTHH:mm:00"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
/>
|
||||
@@ -185,7 +185,7 @@
|
||||
label="计划开始时间"
|
||||
class="step-form-col-half"
|
||||
>
|
||||
<span>{{ editor.selectedStep.value.plannedStartTime || '—' }}</span>
|
||||
<span>{{ formatPlannedStartDate(editor.selectedStep.value.plannedStartTime) || '—' }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" class="step-form-col-half">
|
||||
<el-input
|
||||
@@ -938,6 +938,7 @@
|
||||
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
||||
import { downloadAttachmentFile } from '@/utils/download-attachment'
|
||||
import { SHOW_PROCESS_REAGENT_CONSUMABLE } from '@/utils/process-material-ui'
|
||||
import { formatPlannedStartDate } from '@/utils/production-labels'
|
||||
import { useTaskStepEditor } from './useTaskStepEditor'
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@@ -396,6 +396,8 @@
|
||||
readonly?: boolean
|
||||
operateScope?: ProductionTaskOperateScope
|
||||
allowForward?: boolean
|
||||
/** 打开时预选工艺步骤 */
|
||||
initialStepId?: string
|
||||
/** 挂到 body,避免表格展开行 / fixed 列层叠遮挡 */
|
||||
appendToBody?: boolean
|
||||
}>(),
|
||||
@@ -468,6 +470,13 @@
|
||||
mode: 'execution',
|
||||
operateScope: props.readonly ? undefined : props.operateScope
|
||||
})
|
||||
const stepId = (props.initialStepId || '').trim()
|
||||
if (stepId) {
|
||||
const step = editor.stepList.value.find((s) => s.id === stepId)
|
||||
if (step) {
|
||||
editor.selectStep(step)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
<!-- 生产工单 · 工艺步骤子列表(嵌入生产任务 Tab 内) -->
|
||||
<template>
|
||||
<div
|
||||
class="work-order-task-step-sublist"
|
||||
:class="{ 'work-order-task-step-sublist--embedded': embedded }"
|
||||
v-loading="loading"
|
||||
>
|
||||
<div v-if="tableData.length" class="work-order-step-cards-wrap">
|
||||
<div class="work-order-step-cards-grid">
|
||||
<div
|
||||
v-for="(row, idx) in tableData"
|
||||
:key="row.id || idx"
|
||||
class="work-order-step-card work-order-step-card--compact"
|
||||
@dblclick="handleViewStep(row)"
|
||||
>
|
||||
<div class="work-order-step-card__main">
|
||||
<div class="work-order-step-card__left">
|
||||
<div class="work-order-step-card__title-row">
|
||||
<span class="work-order-step-card__seq">{{
|
||||
row.stepStatus === 'ywc' ? '✓' : row.stepOrder ?? idx + 1
|
||||
}}</span>
|
||||
<span class="work-order-step-card__name">{{ row.processName || '未命名步骤' }}</span>
|
||||
</div>
|
||||
<div class="work-order-step-card__tags">
|
||||
<el-tag :type="productionStepStatusTag(row.stepStatus).type" size="small">
|
||||
{{ productionStepStatusTag(row.stepStatus).label }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="stepAssigneeLabels(row).length" class="work-order-step-card__right">
|
||||
<div class="work-order-step-card__assignees">
|
||||
<span
|
||||
v-for="(name, ai) in stepAssigneeLabels(row)"
|
||||
:key="`${row.id || idx}-assignee-${ai}`"
|
||||
class="work-order-step-card__assignee-item"
|
||||
>{{ name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-order-step-card__footer">
|
||||
<span v-if="stepStartTimeText(row)" class="work-order-step-card__start-time">{{
|
||||
stepStartTimeText(row)
|
||||
}}</span>
|
||||
<div class="work-order-task-step-sublist__ops">
|
||||
<el-button
|
||||
v-if="canEnterStep(row)"
|
||||
class="btn-op-item primary"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click.stop="handleEnterStep(row)"
|
||||
>
|
||||
<el-icon><VideoPlay /></el-icon>进入执行
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
class="btn-op-item primary"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click.stop="handleViewStep(row)"
|
||||
>
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!loading" class="work-order-task-step-sublist__empty hint-muted">
|
||||
暂无工艺步骤
|
||||
</div>
|
||||
|
||||
<TaskExecutionDialog
|
||||
v-model:visible="executionDialogVisible"
|
||||
:task-id="executionTaskId"
|
||||
:task-name="executionTaskName"
|
||||
:initial-step-id="executionStepId"
|
||||
:readonly="executionReadonly"
|
||||
:operate-scope="operateScope"
|
||||
:allow-forward="false"
|
||||
append-to-body
|
||||
@success="handleStepMutationSuccess"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { VideoPlay, View } from '@element-plus/icons-vue'
|
||||
import {
|
||||
fetchProductionTaskDetail,
|
||||
type ProductionTaskOperateScope
|
||||
} from '@/api/production-task'
|
||||
import {
|
||||
extractProductionTaskSteps,
|
||||
formatPlannedStartDate,
|
||||
productionStepStatusTag
|
||||
} from '@/utils/production-labels'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import TaskExecutionDialog from './TaskExecutionDialog.vue'
|
||||
|
||||
defineOptions({ name: 'WorkOrderTaskStepSubList' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
task: Record<string, any>
|
||||
listMode?: 'workOrder' | 'mine' | 'mine-current' | 'mine-history'
|
||||
embedded?: boolean
|
||||
refreshToken?: number
|
||||
presetSteps?: Record<string, any>[]
|
||||
}>(),
|
||||
{
|
||||
listMode: 'workOrder'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
changed: []
|
||||
}>()
|
||||
|
||||
const userStore = useUserStore()
|
||||
const isMineMode = computed(() => props.listMode.startsWith('mine'))
|
||||
const usesPresetSteps = computed(() => props.presetSteps !== undefined)
|
||||
|
||||
const operateScope = computed<ProductionTaskOperateScope>(() =>
|
||||
isMineMode.value ? 'mine' : 'manage'
|
||||
)
|
||||
|
||||
const tableData = ref<Record<string, any>[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
function assigneeDisplayName(raw: string): string {
|
||||
const s = String(raw || '').trim()
|
||||
if (!s) return ''
|
||||
const matched = s.match(/^(.+?)[((][^))]*[))]$/)
|
||||
if (matched) return matched[1].trim()
|
||||
return s
|
||||
}
|
||||
|
||||
function stepAssigneeLabels(row: Record<string, any>): string[] {
|
||||
const namesStr = String(row.assigneeUserNames || '').trim()
|
||||
if (namesStr) {
|
||||
return namesStr
|
||||
.split(/[,,、]/)
|
||||
.map((n) => assigneeDisplayName(n))
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
const namesArr: string[] = Array.isArray(row.assigneeNames) ? row.assigneeNames : []
|
||||
const fromNamesArr = namesArr
|
||||
.map((n) => assigneeDisplayName(String(n || '')))
|
||||
.filter(Boolean)
|
||||
if (fromNamesArr.length) return fromNamesArr
|
||||
|
||||
const assignees: Array<{ nickName?: string; userNo?: string }> = Array.isArray(row.assignees)
|
||||
? row.assignees
|
||||
: []
|
||||
if (assignees.length) {
|
||||
return assignees
|
||||
.map((a) => String(a.nickName || '').trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
function stepStartTimeText(row: Record<string, any>): string {
|
||||
return formatPlannedStartDate(row.plannedStartTime)
|
||||
}
|
||||
|
||||
function isCurrentTaskAssignee() {
|
||||
const uid = String(userStore.info?.id || userStore.info?.userId || '').trim()
|
||||
if (!uid) return false
|
||||
if (String(props.task.currentAssigneeUserId || '') === uid) return true
|
||||
if (isMineMode.value && props.listMode !== 'mine-history' && !props.task.handoverTime) return true
|
||||
return false
|
||||
}
|
||||
|
||||
function isStepAssignee(row: Record<string, any>) {
|
||||
const uid = String(userStore.info?.id || userStore.info?.userId || '').trim()
|
||||
if (!uid) return false
|
||||
const ids: string[] = row.assigneeUserIds || []
|
||||
if (ids.includes(uid)) return true
|
||||
if (!ids.length && isCurrentTaskAssignee()) return true
|
||||
return false
|
||||
}
|
||||
|
||||
function canEnterStep(row: Record<string, any>) {
|
||||
if (row.stepStatus === 'ywc') return false
|
||||
if (props.task.taskStatus === 'ywc') return false
|
||||
if (isMineMode.value) return isStepAssignee(row)
|
||||
return props.task.taskStatus === 'dpz' || props.task.taskStatus === 'jxz'
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
const taskId = props.task?.id
|
||||
if (!taskId) {
|
||||
tableData.value = []
|
||||
return
|
||||
}
|
||||
if (usesPresetSteps.value) {
|
||||
tableData.value = props.presetSteps || []
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const detail = await fetchProductionTaskDetail(taskId)
|
||||
tableData.value = extractProductionTaskSteps(detail)
|
||||
} catch {
|
||||
tableData.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleStepMutationSuccess() {
|
||||
if (!usesPresetSteps.value) {
|
||||
loadData()
|
||||
}
|
||||
emit('changed')
|
||||
}
|
||||
|
||||
const executionDialogVisible = ref(false)
|
||||
const executionTaskId = ref('')
|
||||
const executionTaskName = ref('')
|
||||
const executionStepId = ref('')
|
||||
const executionReadonly = ref(false)
|
||||
|
||||
function openExecution(row: Record<string, any>, readonly: boolean) {
|
||||
executionTaskId.value = props.task.id
|
||||
executionTaskName.value = props.task.taskName || ''
|
||||
executionStepId.value = row.id
|
||||
executionReadonly.value = readonly
|
||||
executionDialogVisible.value = true
|
||||
}
|
||||
|
||||
function handleEnterStep(row: Record<string, any>) {
|
||||
openExecution(row, false)
|
||||
}
|
||||
|
||||
function handleViewStep(row: Record<string, any>) {
|
||||
openExecution(row, true)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.task?.id, props.refreshToken, props.presetSteps] as const,
|
||||
() => {
|
||||
loadData()
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.work-order-task-step-sublist {
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.work-order-task-step-sublist--embedded {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.work-order-step-cards-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.work-order-step-cards-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.work-order-step-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
cursor: default;
|
||||
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: #a8d4c4;
|
||||
box-shadow: 0 2px 6px rgba(4, 120, 87, 0.1);
|
||||
}
|
||||
|
||||
&--compact {
|
||||
flex: 0 0 auto;
|
||||
width: 208px;
|
||||
max-width: 208px;
|
||||
min-height: 96px;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.work-order-step-card__main {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.work-order-step-card__left {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.work-order-step-card__title-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.work-order-step-card__right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
flex: 0 0 72px;
|
||||
width: 72px;
|
||||
max-width: 72px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.work-order-step-card__assignees {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.work-order-step-card__assignee-item {
|
||||
display: block;
|
||||
width: 100%;
|
||||
font-size: 10px;
|
||||
color: var(--mint-text-muted, #334155);
|
||||
line-height: 1.35;
|
||||
text-align: right;
|
||||
word-break: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.work-order-step-card__footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 6px;
|
||||
margin-top: auto;
|
||||
padding-top: 6px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.work-order-step-card__start-time {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 10px;
|
||||
line-height: 1.35;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
text-align: left;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.work-order-task-step-sublist__ops {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.work-order-step-card__seq {
|
||||
flex-shrink: 0;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-top: 1px;
|
||||
border-radius: 50%;
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.work-order-step-card__name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
line-height: 1.35;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.work-order-step-card__tags {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.work-order-task-step-sublist__empty {
|
||||
padding: 8px 0;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,140 +1,155 @@
|
||||
<!-- 生产工单 · 生产任务子列表 -->
|
||||
<!-- 生产工单 · 生产任务 Tab 子列表(Tab 内嵌工艺步骤卡片) -->
|
||||
<template>
|
||||
<div class="work-order-task-sublist" :class="{ 'work-order-task-sublist--embedded': embedded }">
|
||||
<div class="work-order-task-sublist__panel" v-loading="loading">
|
||||
<div v-if="tableData.length" class="work-order-task-cards-area">
|
||||
<div class="work-order-task-sublist__head">
|
||||
<div class="work-order-task-sublist__head-title">生产任务</div>
|
||||
<div class="work-order-task-sublist__head-extra">
|
||||
<span class="work-order-task-sublist__count">共 {{ tableData.length }} 项任务</span>
|
||||
<el-button
|
||||
class="work-order-task-sublist__refresh-icon"
|
||||
link
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="loadData"
|
||||
>
|
||||
<el-icon><RefreshLeft /></el-icon>
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!embedded"
|
||||
class="btn-main work-order-task-sublist__dispatch"
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="!canDispatch"
|
||||
@click="handleDispatch"
|
||||
>
|
||||
<el-icon><Position /></el-icon>派发任务
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-order-task-cards-grid">
|
||||
<div
|
||||
v-for="(row, idx) in tableData"
|
||||
:key="row.id || idx"
|
||||
class="work-order-task-card"
|
||||
@dblclick="handleViewDetail(row)"
|
||||
<div
|
||||
class="work-order-task-sublist"
|
||||
:class="{ 'work-order-task-sublist--embedded': embedded }"
|
||||
v-loading="sectionsLoading"
|
||||
>
|
||||
<div class="work-order-task-sublist__panel">
|
||||
<div v-if="!embedded" class="work-order-task-sublist__head">
|
||||
<div class="work-order-task-sublist__head-extra">
|
||||
<el-button
|
||||
class="work-order-task-sublist__refresh-icon"
|
||||
link
|
||||
type="primary"
|
||||
:loading="sectionsLoading"
|
||||
@click="loadData"
|
||||
>
|
||||
<div class="work-order-task-card__line work-order-task-card__line--top">
|
||||
<span class="work-order-task-card__name">{{ row.taskName || row.taskNo || '—' }}</span>
|
||||
<div class="work-order-task-card__tags">
|
||||
<el-tag :type="taskStatusTag(row.taskStatus).type" size="small">
|
||||
{{ taskStatusTag(row.taskStatus).label }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="productionConclusionTagType(row.conclusion)"
|
||||
:type="productionConclusionTagType(row.conclusion)"
|
||||
size="small"
|
||||
>
|
||||
{{ row.conclusionLabel || productionConclusionLabel(row.conclusion) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="work-order-task-card__line work-order-task-card__line--bottom">
|
||||
<span class="work-order-task-card__code">{{ row.taskNo || '—' }}</span>
|
||||
<span class="work-order-task-card__sep">·</span>
|
||||
<span v-if="row.currentAssigneeUserName" class="work-order-task-card__assignee">{{
|
||||
row.currentAssigneeUserName
|
||||
}}</span>
|
||||
<span v-if="row.currentAssigneeUserName" class="work-order-task-card__sep">·</span>
|
||||
<el-tag :type="productionTaskTypeTag(row.taskType, row.orderSource).type" size="small">
|
||||
{{ productionTaskTypeTag(row.taskType, row.orderSource).label }}
|
||||
</el-tag>
|
||||
<span v-if="isMineHistoryRow(row) && row.handoverTime" class="work-order-task-card__sep">·</span>
|
||||
<span v-if="isMineHistoryRow(row) && row.handoverTime" class="work-order-task-card__handover"
|
||||
>转出 {{ row.handoverTime }}</span
|
||||
>
|
||||
<div class="work-order-task-sublist__ops">
|
||||
<el-button
|
||||
v-if="canEnterExecution(row)"
|
||||
class="btn-op-item primary"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click.stop="handleEnterExecution(row)"
|
||||
>
|
||||
<el-icon><VideoPlay /></el-icon>{{ isMineHistoryRow(row) ? '查看' : '进入执行' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
class="btn-op-item primary"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click.stop="handleViewDetail(row)"
|
||||
>
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-dropdown
|
||||
v-if="hasMoreTaskActions(row)"
|
||||
trigger="hover"
|
||||
@command="(cmd) => handleDropdownCommand(cmd, row)"
|
||||
>
|
||||
<el-button class="btn-op-item" size="small" @click.stop>
|
||||
<el-icon><More /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-if="canEnterExecution(row)" command="view">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="canDispatchSteps(row)" command="stepDispatch">
|
||||
<el-icon><Position /></el-icon>步骤派发
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="canEditTask(row)" command="editInfo">
|
||||
<el-icon><EditPen /></el-icon>编辑信息
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="canEditTask(row)" command="editRoute">
|
||||
<el-icon><EditPen /></el-icon>编辑工艺
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="canDeleteTask(row)" command="delete" divided>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-icon><RefreshLeft /></el-icon>
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-main work-order-task-sublist__dispatch"
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="!canDispatch"
|
||||
@click="handleDispatch"
|
||||
>
|
||||
<el-icon><Position /></el-icon>派发任务
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!loading" class="work-order-task-cards-area work-order-task-cards-area--empty">
|
||||
<div class="work-order-task-sublist__head">
|
||||
<div class="work-order-task-sublist__head-title">生产任务</div>
|
||||
|
||||
<template v-if="taskSections.length">
|
||||
<el-tabs
|
||||
v-model="activeTaskKey"
|
||||
class="panel-pill-tabs panel-pill-tabs--start production-task-tabs"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="section in taskSections"
|
||||
:key="section.key"
|
||||
:name="section.key"
|
||||
lazy
|
||||
>
|
||||
<template #label>
|
||||
<span class="production-task-tabs__label">{{ section.taskName }}</span>
|
||||
<span class="production-task-tabs__count">
|
||||
{{ section.completedStepCount }}/{{ section.stepCount }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="activeTaskKey === section.key">
|
||||
<div class="production-task-tabs__meta">
|
||||
<span v-if="section.taskNo" class="production-task-tabs__meta-item">{{
|
||||
section.taskNo
|
||||
}}</span>
|
||||
<span v-if="section.assigneeUserName" class="production-task-tabs__meta-item">
|
||||
负责人:{{ section.assigneeUserName }}
|
||||
</span>
|
||||
<el-tag :type="taskStatusTag(section.taskStatus).type" size="small">
|
||||
{{ taskStatusTag(section.taskStatus).label }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="productionConclusionTagType(section.conclusion)"
|
||||
:type="productionConclusionTagType(section.conclusion)"
|
||||
size="small"
|
||||
>
|
||||
{{ section.conclusionLabel || productionConclusionLabel(section.conclusion) }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
:type="productionTaskTypeTag(section.taskType, section.orderSource).type"
|
||||
size="small"
|
||||
>
|
||||
{{ productionTaskTypeTag(section.taskType, section.orderSource).label }}
|
||||
</el-tag>
|
||||
<div class="production-task-tabs__ops">
|
||||
<el-button
|
||||
v-if="canEnterExecution(section.task)"
|
||||
class="btn-op-item primary"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleEnterExecution(section.task)"
|
||||
>
|
||||
<el-icon><VideoPlay /></el-icon
|
||||
>{{ isMineHistoryRow(section.task) ? '查看' : '进入执行' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
class="btn-op-item primary"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleViewDetail(section.task)"
|
||||
>
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-dropdown
|
||||
v-if="hasMoreTaskActions(section.task)"
|
||||
trigger="hover"
|
||||
@command="(cmd) => handleDropdownCommand(cmd, section.task)"
|
||||
>
|
||||
<el-button class="btn-op-item" size="small" @click.stop>
|
||||
<el-icon><More /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-if="canEnterExecution(section.task)" command="view">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="canDispatchSteps(section.task)" command="stepDispatch">
|
||||
<el-icon><Position /></el-icon>步骤派发
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="canEditTask(section.task)" command="editInfo">
|
||||
<el-icon><EditPen /></el-icon>编辑信息
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="canEditTask(section.task)" command="editRoute">
|
||||
<el-icon><EditPen /></el-icon>编辑工艺
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="canDeleteTask(section.task)" command="delete" divided>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
<WorkOrderTaskStepSubList
|
||||
embedded
|
||||
:task="section.task"
|
||||
:list-mode="listMode"
|
||||
:preset-steps="section.steps"
|
||||
:refresh-token="refreshToken"
|
||||
@changed="handleStepChanged"
|
||||
/>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
<div v-else-if="!sectionsLoading" class="work-order-task-sublist__empty-wrap">
|
||||
<div v-if="embedded" class="work-order-task-sublist__head">
|
||||
<div class="work-order-task-sublist__head-extra">
|
||||
<el-button
|
||||
v-if="!isMineMode"
|
||||
class="work-order-task-sublist__refresh-icon"
|
||||
link
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
:loading="sectionsLoading"
|
||||
@click="loadData"
|
||||
>
|
||||
<el-icon><RefreshLeft /></el-icon>
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!embedded"
|
||||
v-if="!isMineMode && canDispatch"
|
||||
class="btn-main work-order-task-sublist__dispatch"
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="!canDispatch"
|
||||
@click="handleDispatch"
|
||||
>
|
||||
<el-icon><Position /></el-icon>派发任务
|
||||
@@ -143,7 +158,7 @@
|
||||
</div>
|
||||
<el-empty
|
||||
class="work-order-task-sublist__empty"
|
||||
description="暂无任务,可点击「派发任务」创建"
|
||||
:description="isMineMode ? '暂无生产任务' : '暂无任务,可点击「派发任务」创建'"
|
||||
:image-size="56"
|
||||
/>
|
||||
</div>
|
||||
@@ -206,22 +221,41 @@
|
||||
import {
|
||||
fetchProductionTaskList,
|
||||
fetchMyProductionTasks,
|
||||
fetchProductionTaskDetail,
|
||||
fetchDeleteProductionTask,
|
||||
type ProductionTaskOperateScope
|
||||
} from '@/api/production-task'
|
||||
import TaskExecutionDialog from './TaskExecutionDialog.vue'
|
||||
import DispatchTaskDialog from './DispatchTaskDialog.vue'
|
||||
import DispatchStepDialog from './DispatchStepDialog.vue'
|
||||
import EditTaskInfoDialog from './EditTaskInfoDialog.vue'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import {
|
||||
extractProductionTaskSteps,
|
||||
productionConclusionLabel,
|
||||
productionConclusionTagType,
|
||||
productionTaskTypeTag
|
||||
} from '@/utils/production-labels'
|
||||
import TaskExecutionDialog from './TaskExecutionDialog.vue'
|
||||
import DispatchTaskDialog from './DispatchTaskDialog.vue'
|
||||
import DispatchStepDialog from './DispatchStepDialog.vue'
|
||||
import EditTaskInfoDialog from './EditTaskInfoDialog.vue'
|
||||
import WorkOrderTaskStepSubList from './WorkOrderTaskStepSubList.vue'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
|
||||
defineOptions({ name: 'WorkOrderTaskSubList' })
|
||||
|
||||
type ProductionTaskSection = {
|
||||
key: string
|
||||
task: Record<string, any>
|
||||
taskName: string
|
||||
taskNo: string
|
||||
taskStatus: string
|
||||
orderSource?: string
|
||||
taskType?: string
|
||||
conclusion?: string
|
||||
conclusionLabel?: string
|
||||
assigneeUserName?: string
|
||||
steps: Record<string, any>[]
|
||||
stepCount: number
|
||||
completedStepCount: number
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
workOrder?: Record<string, any>
|
||||
listMode?: 'workOrder' | 'mine' | 'mine-current' | 'mine-history'
|
||||
@@ -249,8 +283,9 @@
|
||||
isMineMode.value ? 'mine' : 'manage'
|
||||
)
|
||||
|
||||
const tableData = ref<Record<string, any>[]>([])
|
||||
const loading = ref(false)
|
||||
const taskSections = ref<ProductionTaskSection[]>([])
|
||||
const sectionsLoading = ref(false)
|
||||
const activeTaskKey = ref('')
|
||||
|
||||
const canDispatch = computed(() => {
|
||||
if (isMineMode.value) return false
|
||||
@@ -267,61 +302,61 @@
|
||||
return map[status] || { label: status, type: 'info' }
|
||||
}
|
||||
|
||||
function isCurrentAssignee(row: Record<string, any>) {
|
||||
const uid = String(userStore.info?.id || userStore.info?.userId || '').trim()
|
||||
if (!uid) return false
|
||||
if (String(row.currentAssigneeUserId || '') === uid) return true
|
||||
if (isMineMode.value && props.listMode !== 'mine-history' && !row.handoverTime) return true
|
||||
return false
|
||||
function buildSection(task: Record<string, any>, steps: Record<string, any>[]): ProductionTaskSection {
|
||||
const completedStepCount = steps.filter((s) => s.stepStatus === 'ywc').length
|
||||
return {
|
||||
key: task.id,
|
||||
task,
|
||||
taskName: task.taskName || task.taskNo || '生产任务',
|
||||
taskNo: task.taskNo || '',
|
||||
taskStatus: task.taskStatus || '',
|
||||
orderSource: task.orderSource,
|
||||
taskType: task.taskType,
|
||||
conclusion: task.conclusion,
|
||||
conclusionLabel: task.conclusionLabel,
|
||||
assigneeUserName: task.currentAssigneeUserName || '',
|
||||
steps,
|
||||
stepCount: steps.length,
|
||||
completedStepCount
|
||||
}
|
||||
}
|
||||
|
||||
function isMineHistoryRow(row: Record<string, any>) {
|
||||
if (!isMineMode.value) return false
|
||||
if (props.listMode === 'mine-history') return true
|
||||
return !isCurrentAssignee(row)
|
||||
function ensureActiveTaskKey(sections: ProductionTaskSection[]) {
|
||||
if (!sections.length) {
|
||||
activeTaskKey.value = ''
|
||||
return
|
||||
}
|
||||
const keys = new Set(sections.map((s) => s.key))
|
||||
if (!activeTaskKey.value || !keys.has(activeTaskKey.value)) {
|
||||
activeTaskKey.value = sections[0].key
|
||||
}
|
||||
}
|
||||
|
||||
function canEnterExecution(row: Record<string, any>) {
|
||||
if (isMineHistoryRow(row)) return false
|
||||
if (row.taskStatus === 'ywc') return false
|
||||
if (isMineMode.value) return isCurrentAssignee(row)
|
||||
return row.taskStatus === 'dpz' || row.taskStatus === 'jxz'
|
||||
}
|
||||
|
||||
function canForwardTask(_row: Record<string, any>) {
|
||||
return false
|
||||
}
|
||||
|
||||
function canReassignTask(_row: Record<string, any>) {
|
||||
return false
|
||||
}
|
||||
|
||||
function canDispatchSteps(row: Record<string, any>) {
|
||||
if (isMineMode.value) return false
|
||||
return row.taskStatus === 'dpz' || row.taskStatus === 'jxz'
|
||||
}
|
||||
|
||||
function canEditTask(row: Record<string, any>) {
|
||||
if (isMineHistoryRow(row)) return false
|
||||
if (isMineMode.value) return isCurrentAssignee(row)
|
||||
return row.taskStatus === 'dpz' || row.taskStatus === 'jxz'
|
||||
}
|
||||
|
||||
function canDeleteTask(row: Record<string, any>) {
|
||||
if (isMineMode.value) return false
|
||||
return row.taskStatus === 'dpz'
|
||||
}
|
||||
|
||||
function hasMoreTaskActions(row: Record<string, any>) {
|
||||
if (canEnterExecution(row)) return true
|
||||
return canEditTask(row) || canDeleteTask(row) || canDispatchSteps(row)
|
||||
async function loadTaskSections(tasks: Record<string, any>[]) {
|
||||
if (!tasks.length) {
|
||||
taskSections.value = []
|
||||
return
|
||||
}
|
||||
const sections = await Promise.all(
|
||||
tasks.map(async (task) => {
|
||||
try {
|
||||
const detail = await fetchProductionTaskDetail(task.id)
|
||||
const steps = extractProductionTaskSteps(detail)
|
||||
return buildSection({ ...task, ...(detail || {}) }, steps)
|
||||
} catch {
|
||||
return buildSection(task, [])
|
||||
}
|
||||
})
|
||||
)
|
||||
taskSections.value = sections
|
||||
ensureActiveTaskKey(sections)
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
sectionsLoading.value = true
|
||||
try {
|
||||
if (usesPresetTasks.value) {
|
||||
tableData.value = props.presetTasks || []
|
||||
await loadTaskSections(props.presetTasks || [])
|
||||
return
|
||||
}
|
||||
if (isMineMode.value) {
|
||||
@@ -333,23 +368,31 @@
|
||||
taskStatus: props.mineFilters?.taskStatus || undefined,
|
||||
workOrderType: props.mineFilters?.workOrderType || undefined
|
||||
})
|
||||
tableData.value = res.list || []
|
||||
const tasks = (res.list || []).filter(
|
||||
(t) => !props.workOrder?.id || t.workOrderId === props.workOrder.id
|
||||
)
|
||||
await loadTaskSections(tasks)
|
||||
emit('update:total', res.total || 0)
|
||||
return
|
||||
}
|
||||
const workOrderId = props.workOrder?.id
|
||||
if (!workOrderId) {
|
||||
tableData.value = []
|
||||
taskSections.value = []
|
||||
return
|
||||
}
|
||||
const res = await fetchProductionTaskList({ workOrderId, pageSize: 100 })
|
||||
tableData.value = res.list || []
|
||||
await loadTaskSections(res.list || [])
|
||||
} finally {
|
||||
loading.value = false
|
||||
sectionsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleTaskMutationSuccess() {
|
||||
loadData()
|
||||
emit('changed')
|
||||
}
|
||||
|
||||
function handleStepChanged() {
|
||||
if (!usesPresetTasks.value) {
|
||||
loadData()
|
||||
}
|
||||
@@ -387,6 +430,48 @@
|
||||
const executionTaskName = ref('')
|
||||
const executionReadonly = ref(false)
|
||||
|
||||
function isCurrentAssignee(row: Record<string, any>) {
|
||||
const uid = String(userStore.info?.id || userStore.info?.userId || '').trim()
|
||||
if (!uid) return false
|
||||
if (String(row.currentAssigneeUserId || '') === uid) return true
|
||||
if (isMineMode.value && props.listMode !== 'mine-history' && !row.handoverTime) return true
|
||||
return false
|
||||
}
|
||||
|
||||
function isMineHistoryRow(row: Record<string, any>) {
|
||||
if (!isMineMode.value) return false
|
||||
if (props.listMode === 'mine-history') return true
|
||||
return !isCurrentAssignee(row)
|
||||
}
|
||||
|
||||
function canEnterExecution(row: Record<string, any>) {
|
||||
if (isMineHistoryRow(row)) return false
|
||||
if (row.taskStatus === 'ywc') return false
|
||||
if (isMineMode.value) return isCurrentAssignee(row)
|
||||
return row.taskStatus === 'dpz' || row.taskStatus === 'jxz'
|
||||
}
|
||||
|
||||
function canDispatchSteps(row: Record<string, any>) {
|
||||
if (isMineMode.value) return false
|
||||
return row.taskStatus === 'dpz' || row.taskStatus === 'jxz'
|
||||
}
|
||||
|
||||
function canEditTask(row: Record<string, any>) {
|
||||
if (isMineHistoryRow(row)) return false
|
||||
if (isMineMode.value) return isCurrentAssignee(row)
|
||||
return row.taskStatus === 'dpz' || row.taskStatus === 'jxz'
|
||||
}
|
||||
|
||||
function canDeleteTask(row: Record<string, any>) {
|
||||
if (isMineMode.value) return false
|
||||
return row.taskStatus === 'dpz'
|
||||
}
|
||||
|
||||
function hasMoreTaskActions(row: Record<string, any>) {
|
||||
if (canEnterExecution(row)) return true
|
||||
return canEditTask(row) || canDeleteTask(row) || canDispatchSteps(row)
|
||||
}
|
||||
|
||||
function handleEnterExecution(row: Record<string, any>) {
|
||||
executionTaskId.value = row.id
|
||||
executionTaskName.value = row.taskName || ''
|
||||
@@ -454,7 +539,7 @@
|
||||
() => {
|
||||
loadData()
|
||||
},
|
||||
{ immediate: true }
|
||||
{ immediate: true, deep: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
@@ -474,29 +559,13 @@
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.work-order-task-cards-area {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
|
||||
&--empty {
|
||||
gap: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.work-order-task-sublist__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.work-order-task-sublist__head-title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--mint-text-muted, #334155);
|
||||
letter-spacing: 0.02em;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.work-order-task-sublist__head-extra {
|
||||
@@ -506,31 +575,6 @@
|
||||
gap: 4px 8px;
|
||||
}
|
||||
|
||||
.work-order-task-cards-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.work-order-task-cards-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.work-order-task-cards-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.work-order-task-sublist__count {
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #334155);
|
||||
line-height: 1.35;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.work-order-task-sublist__refresh-icon {
|
||||
flex-shrink: 0;
|
||||
padding: 0 2px;
|
||||
@@ -546,6 +590,59 @@
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.production-task-tabs {
|
||||
&.panel-pill-tabs.el-tabs > :deep(.el-tabs__header) {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
&.panel-pill-tabs.el-tabs :deep(.el-tabs__nav-scroll) {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&.panel-pill-tabs.el-tabs :deep(.el-tabs__item) {
|
||||
min-width: 96px;
|
||||
padding: 6px 14px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.production-task-tabs__label {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.production-task-tabs__count {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.production-task-tabs__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.production-task-tabs__meta-item {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
|
||||
.production-task-tabs__ops {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.work-order-task-sublist__empty-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.work-order-task-sublist__empty {
|
||||
padding: 4px 0;
|
||||
|
||||
@@ -553,84 +650,4 @@
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.work-order-task-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
cursor: default;
|
||||
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: #a8d4c4;
|
||||
box-shadow: 0 2px 6px rgba(4, 120, 87, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.work-order-task-card__line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
|
||||
&--top {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 4px;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
&--bottom {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.work-order-task-card__name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
line-height: 1.35;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 1;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.work-order-task-card__tags {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.work-order-task-card__code {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 11px;
|
||||
color: var(--mint-text-muted, #334155);
|
||||
line-height: 1.35;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.work-order-task-card__sep {
|
||||
flex-shrink: 0;
|
||||
color: #cbd5e1;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.work-order-task-sublist__ops {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-left: auto;
|
||||
}
|
||||
</style>
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import {
|
||||
fetchMineProductionWorkOrderTabStepCounts,
|
||||
fetchProductionWorkOrderTabStepCounts,
|
||||
type ProductionWorkOrderTabStepCount,
|
||||
type ProductionWorkOrderTabStepCounts
|
||||
} from '@/api/production-work-order'
|
||||
import {
|
||||
PRODUCTION_WORK_ORDER_VISIBLE_TABS,
|
||||
type ProductionWorkOrderTabKey
|
||||
} from '@/utils/production-work-order-tabs'
|
||||
|
||||
export type ProductionWorkOrderTabCountScope = 'manage' | 'mine'
|
||||
|
||||
const EMPTY_COUNT: ProductionWorkOrderTabStepCount = {
|
||||
overdueIncomplete: 0,
|
||||
unassigned: 0
|
||||
}
|
||||
|
||||
function emptyTabCounts(): ProductionWorkOrderTabStepCounts {
|
||||
const counts = {} as ProductionWorkOrderTabStepCounts
|
||||
for (const tab of PRODUCTION_WORK_ORDER_VISIBLE_TABS) {
|
||||
counts[tab.key] = { ...EMPTY_COUNT }
|
||||
}
|
||||
return counts
|
||||
}
|
||||
|
||||
export function useProductionWorkOrderTabStepCounts(scope: ProductionWorkOrderTabCountScope) {
|
||||
const tabCounts = ref<ProductionWorkOrderTabStepCounts>(emptyTabCounts())
|
||||
const loading = ref(false)
|
||||
|
||||
async function loadTabCounts() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data =
|
||||
scope === 'mine'
|
||||
? await fetchMineProductionWorkOrderTabStepCounts()
|
||||
: await fetchProductionWorkOrderTabStepCounts()
|
||||
tabCounts.value = { ...emptyTabCounts(), ...(data || {}) }
|
||||
} catch {
|
||||
tabCounts.value = emptyTabCounts()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getTabCount(tabKey: ProductionWorkOrderTabKey): ProductionWorkOrderTabStepCount {
|
||||
return tabCounts.value[tabKey] ?? { ...EMPTY_COUNT }
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadTabCounts()
|
||||
})
|
||||
|
||||
return {
|
||||
tabCounts,
|
||||
loading,
|
||||
loadTabCounts,
|
||||
getTabCount
|
||||
}
|
||||
}
|
||||
@@ -3,22 +3,12 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-pill-tabs panel-pill-tabs--lg">
|
||||
<div class="panel-pill-tabs__track" role="tablist">
|
||||
<button
|
||||
v-for="tab in PRODUCTION_WORK_ORDER_VISIBLE_TABS"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="panel-pill-tabs__btn"
|
||||
:class="{ 'is-active': activeTabKey === tab.key }"
|
||||
:aria-selected="activeTabKey === tab.key"
|
||||
@click="handleTabChange(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<ProductionWorkOrderTabBar
|
||||
ref="tabBarRef"
|
||||
:active-tab-key="activeTabKey"
|
||||
scope="manage"
|
||||
@change="handleTabChange"
|
||||
/>
|
||||
|
||||
<ProductionWorkOrderTabPanel
|
||||
ref="activeTabRef"
|
||||
@@ -31,6 +21,7 @@
|
||||
@command="handleDropdownCommand"
|
||||
@add-temporary="handleAddTemporary"
|
||||
@open-sample-reception="handleOpenSampleReception"
|
||||
@data-changed="reloadTabCounts"
|
||||
/>
|
||||
|
||||
<el-dialog
|
||||
@@ -119,10 +110,11 @@
|
||||
type ProductionWorkOrderItem
|
||||
} from '@/api/production-work-order'
|
||||
import {
|
||||
PRODUCTION_WORK_ORDER_VISIBLE_TABS,
|
||||
parseProductionWorkOrderTabKey,
|
||||
type ProductionWorkOrderTabKey
|
||||
} from '@/utils/production-work-order-tabs'
|
||||
import { refreshProductionMenuBadges } from '@/utils/production-menu-badge'
|
||||
import ProductionWorkOrderTabBar from './ProductionWorkOrderTabBar.vue'
|
||||
import ProductionWorkOrderTabPanel from './tabs/ProductionWorkOrderTabPanel.vue'
|
||||
import DispatchTaskDialog from './DispatchTaskDialog.vue'
|
||||
import DispatchStepDialog from './DispatchStepDialog.vue'
|
||||
@@ -138,8 +130,13 @@
|
||||
clearSelection: () => void
|
||||
}
|
||||
|
||||
type ProductionWorkOrderTabBarExpose = {
|
||||
reload: () => Promise<void>
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const tabBarRef = ref<ProductionWorkOrderTabBarExpose | null>(null)
|
||||
const activeTabRef = ref<ProductionWorkOrderTabPanelExpose | null>(null)
|
||||
const activeTabKey = ref<ProductionWorkOrderTabKey>(
|
||||
parseProductionWorkOrderTabKey(route.query.tab as string)
|
||||
@@ -147,9 +144,15 @@
|
||||
|
||||
async function refreshActiveTab() {
|
||||
activeTabRef.value?.bumpTaskRefresh()
|
||||
reloadTabCounts()
|
||||
await activeTabRef.value?.reload()
|
||||
}
|
||||
|
||||
function reloadTabCounts() {
|
||||
tabBarRef.value?.reload()
|
||||
void refreshProductionMenuBadges()
|
||||
}
|
||||
|
||||
function handleTabChange(key: ProductionWorkOrderTabKey) {
|
||||
if (activeTabKey.value === key) return
|
||||
activeTabKey.value = key
|
||||
|
||||
+8
-1
@@ -137,7 +137,7 @@
|
||||
@complete="(row) => emit('complete', row)"
|
||||
@command="handleCommand"
|
||||
@toggle-select="handleCardToggleSelect"
|
||||
@tasks-changed="handleWorkOrderTasksChanged"
|
||||
@tasks-changed="onTasksChanged"
|
||||
@open-sample-reception="handleOpenSampleReception"
|
||||
@page-change="onWorkOrderPageChange"
|
||||
@page-size-change="onWorkOrderPageSizeChange"
|
||||
@@ -186,6 +186,7 @@
|
||||
(e: 'command', command: string, row: ProductionWorkOrderItem): void
|
||||
(e: 'add-temporary'): void
|
||||
(e: 'open-sample-reception', row: ProductionWorkOrderItem): void
|
||||
(e: 'data-changed'): void
|
||||
}>()
|
||||
|
||||
const pageModeComputed = computed(() => props.pageMode || 'manage')
|
||||
@@ -223,6 +224,11 @@
|
||||
bumpTaskRefresh
|
||||
} = useProductionWorkOrderTabPage(tabKeyRef, pageModeComputed)
|
||||
|
||||
async function onTasksChanged() {
|
||||
await handleWorkOrderTasksChanged()
|
||||
emit('data-changed')
|
||||
}
|
||||
|
||||
function handleCommand(command: string, row: ProductionWorkOrderItem) {
|
||||
if (command === 'view') {
|
||||
handleView(row)
|
||||
@@ -244,6 +250,7 @@
|
||||
function handleSampleReceptionSuccess() {
|
||||
bumpTaskRefresh()
|
||||
loadData()
|
||||
emit('data-changed')
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
import type { FinanceAttachmentItem } from '@/components/business/protocol-finance-confirm-fields/finance-attachments'
|
||||
import { financeAttachmentsToUrlString } from '@/components/business/protocol-finance-confirm-fields/finance-attachments'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { normalizePlannedStartDate } from '@/utils/production-labels'
|
||||
|
||||
// ── helpers ──────────────────────────────────────────────────────────
|
||||
function parseTaskAttachmentsFromUrls(urls: string): FinanceAttachmentItem[] {
|
||||
@@ -65,7 +66,7 @@ function normalizeStepSubTables(step: Record<string, any>) {
|
||||
: (step.assignees || [])
|
||||
.map((a: Record<string, any>) => a.userId)
|
||||
.filter((id: string) => String(id || '').trim())
|
||||
const plannedStartTime = step.plannedStartTime || null
|
||||
const plannedStartTime = normalizePlannedStartDate(step.plannedStartTime)
|
||||
return {
|
||||
...step,
|
||||
equipmentIds: parseEquipmentIds(step.equipmentIds || step.equipmentName),
|
||||
|
||||
@@ -58,11 +58,11 @@
|
||||
<el-form-item label="检测时间">
|
||||
<el-date-picker
|
||||
v-model="detectTimeRange"
|
||||
type="datetimerange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
@@ -88,6 +88,14 @@
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>新增登记
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
:disabled="selectedRows.length === 0"
|
||||
:loading="batchDownloadLoading"
|
||||
@click="handleBatchDownloadAttachments"
|
||||
>
|
||||
<el-icon><Download /></el-icon>批量下载附件
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
type="danger"
|
||||
@@ -128,7 +136,14 @@
|
||||
<el-table-column
|
||||
prop="detectTime"
|
||||
label="检测时间"
|
||||
min-width="170"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="resultTime"
|
||||
label="结果时间"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
@@ -155,13 +170,6 @@
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
label="创建时间"
|
||||
min-width="170"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
min-width="260"
|
||||
@@ -219,12 +227,22 @@
|
||||
<el-form-item label="检测时间" prop="detectTime">
|
||||
<el-date-picker
|
||||
v-model="formData.detectTime"
|
||||
type="datetime"
|
||||
placeholder="选择检测时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="date"
|
||||
placeholder="选择检测日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="结果时间" prop="resultTime">
|
||||
<el-date-picker
|
||||
v-model="formData.resultTime"
|
||||
type="date"
|
||||
placeholder="选择结果日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="检测项目" prop="envDetectItemId">
|
||||
<el-select
|
||||
v-model="formData.envDetectItemId"
|
||||
@@ -246,7 +264,7 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="检测人" prop="inspectorIds" class="form-col-span-2">
|
||||
<el-form-item label="检测人" prop="inspectorIds">
|
||||
<el-select
|
||||
v-model="formData.inspectorIds"
|
||||
multiple
|
||||
@@ -427,8 +445,10 @@
|
||||
} from '@element-plus/icons-vue'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { fetchUserList } from '@/api/admin'
|
||||
import { fetchUploadAttachment } from '@/api/business'
|
||||
import { fetchUploadAttachment, fetchAttachmentDownloadUrl } from '@/api/business'
|
||||
import { downloadAttachmentFile } from '@/utils/download-attachment'
|
||||
import FileSaver from 'file-saver'
|
||||
import JSZip from 'jszip'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
||||
import { fetchEnvDetectItemList, type EnvDetectItem } from '@/api/env-detect-item'
|
||||
@@ -472,6 +492,7 @@
|
||||
const dialogTitle = ref('新增登记')
|
||||
const isEdit = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const batchDownloadLoading = ref(false)
|
||||
const formRef = ref()
|
||||
const editingId = ref<string | null>(null)
|
||||
const attachmentFiles = ref<AttachmentItem[]>([])
|
||||
@@ -487,6 +508,7 @@
|
||||
|
||||
const formData = reactive({
|
||||
detectTime: '',
|
||||
resultTime: '',
|
||||
inspectorIds: [] as string[],
|
||||
envDetectItemId: '',
|
||||
resultDesc: '',
|
||||
@@ -494,7 +516,7 @@
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
detectTime: [{ required: true, message: '请选择检测时间', trigger: 'change' }],
|
||||
detectTime: [{ required: true, message: '请选择检测日期', trigger: 'change' }],
|
||||
inspectorIds: [
|
||||
{
|
||||
required: true,
|
||||
@@ -516,12 +538,13 @@
|
||||
title: '登记信息',
|
||||
fields: [
|
||||
{ label: '登记编号', value: row.recordNo },
|
||||
{ label: '创建时间', value: row.createTime },
|
||||
{ label: '检测时间', value: row.detectTime },
|
||||
{ label: '检测人', value: row.inspectorDisplay, span: true },
|
||||
{ label: '检测项目', value: `${row.itemName}(${row.itemCode})`, span: true },
|
||||
{ label: '结果时间', value: row.resultTime || '—' },
|
||||
{ label: '检测项目', value: `${row.itemName}(${row.itemCode})` },
|
||||
{ label: '检测人', value: row.inspectorDisplay },
|
||||
{ label: '检测结果描述', value: row.resultDesc, span: true },
|
||||
{ label: '备注', value: row.remark, span: true },
|
||||
{ label: '创建时间', value: row.createTime }
|
||||
{ label: '备注', value: row.remark, span: true }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -743,10 +766,100 @@
|
||||
if (visible) void remoteSearchActiveItems('')
|
||||
}
|
||||
|
||||
function formatNowDatetime() {
|
||||
function formatToday() {
|
||||
const now = new Date()
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
|
||||
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
|
||||
}
|
||||
|
||||
function toDateOnly(value: string) {
|
||||
if (!value) return ''
|
||||
return value.slice(0, 10)
|
||||
}
|
||||
|
||||
function getAttachmentExtension(file: { fileName?: string; fileUrl?: string }) {
|
||||
const raw = String(file.fileName || file.fileUrl?.split('/').pop() || '')
|
||||
.split('?')[0]
|
||||
.trim()
|
||||
const dot = raw.lastIndexOf('.')
|
||||
if (dot > 0 && dot < raw.length - 1) {
|
||||
return raw.slice(dot + 1).toLowerCase()
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function sanitizeDownloadBaseName(value: string) {
|
||||
return value.replace(/[\\/:*?"<>|]/g, '_').replace(/\s+/g, ' ').trim()
|
||||
}
|
||||
|
||||
function resolveEnvDetectItemName() {
|
||||
const row = viewRow.value
|
||||
if (row?.itemName) return row.itemName
|
||||
const item = activeItemOptions.value.find((i) => i.id === formData.envDetectItemId)
|
||||
return item?.itemName || '环境检测'
|
||||
}
|
||||
|
||||
function buildEnvDetectAttachmentName(
|
||||
context: { detectTime: string; itemName: string },
|
||||
file: { fileName?: string; fileUrl?: string },
|
||||
index: number,
|
||||
totalInRecord: number
|
||||
) {
|
||||
const detectTime = toDateOnly(context.detectTime) || '未知日期'
|
||||
const itemName = sanitizeDownloadBaseName(context.itemName || '环境检测')
|
||||
const ext = getAttachmentExtension(file)
|
||||
const seqPart = totalInRecord > 1 ? ` ${String(index + 1).padStart(3, '0')}` : ''
|
||||
const base = `${detectTime} ${itemName}${seqPart}`
|
||||
return ext ? `${base}.${ext}` : base
|
||||
}
|
||||
|
||||
function ensureUniqueZipEntryName(name: string, used: Set<string>) {
|
||||
if (!used.has(name)) {
|
||||
used.add(name)
|
||||
return name
|
||||
}
|
||||
const dot = name.lastIndexOf('.')
|
||||
const base = dot > 0 ? name.slice(0, dot) : name
|
||||
const ext = dot > 0 ? name.slice(dot) : ''
|
||||
let n = 2
|
||||
while (used.has(`${base}(${n})${ext}`)) n += 1
|
||||
const unique = `${base}(${n})${ext}`
|
||||
used.add(unique)
|
||||
return unique
|
||||
}
|
||||
|
||||
function resolveAttachmentNameContext() {
|
||||
return {
|
||||
detectTime: viewRow.value?.detectTime || formData.detectTime,
|
||||
itemName: viewRow.value?.itemName || resolveEnvDetectItemName()
|
||||
}
|
||||
}
|
||||
|
||||
function listDialogAttachmentFiles() {
|
||||
return attachmentFiles.value.filter((f) => f.fileUrl && !f._uploading)
|
||||
}
|
||||
|
||||
async function fetchAttachmentBlob(fileUrl: string, fileName: string) {
|
||||
const url = String(fileUrl || '').trim()
|
||||
if (!url) return null
|
||||
try {
|
||||
const res = await fetchAttachmentDownloadUrl({ fileUrl: url, fileName })
|
||||
if (res?.downloadUrl) {
|
||||
const response = await fetch(res.downloadUrl)
|
||||
if (response.ok) return await response.blob()
|
||||
}
|
||||
} catch {
|
||||
// 预签名失败时回退直连
|
||||
}
|
||||
const href = fullFileUrl(url)
|
||||
if (!href) return null
|
||||
try {
|
||||
const response = await fetch(href)
|
||||
if (response.ok) return await response.blob()
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const handleSelectionChange = (rows: EnvDetectRecord[]) => {
|
||||
@@ -787,7 +900,8 @@
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formData.detectTime = formatNowDatetime()
|
||||
formData.detectTime = formatToday()
|
||||
formData.resultTime = ''
|
||||
const { userId } = getCurrentUserHandler()
|
||||
formData.inspectorIds = userId ? [userId] : []
|
||||
formData.envDetectItemId = ''
|
||||
@@ -811,7 +925,8 @@
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑登记'
|
||||
editingId.value = row.id
|
||||
formData.detectTime = row.detectTime
|
||||
formData.detectTime = toDateOnly(row.detectTime)
|
||||
formData.resultTime = toDateOnly(row.resultTime || '')
|
||||
formData.inspectorIds = [...(row.inspectorIds || [])]
|
||||
formData.envDetectItemId = row.envDetectItemId
|
||||
formData.resultDesc = row.resultDesc
|
||||
@@ -908,7 +1023,55 @@
|
||||
}
|
||||
|
||||
function handleDownloadAttachment(file: AttachmentItem) {
|
||||
downloadAttachmentFile(file, { fullFileUrl })
|
||||
const files = viewVisible.value ? viewAttachmentFiles.value : listDialogAttachmentFiles()
|
||||
const idx = files.findIndex((f) => f.fileUrl === file.fileUrl)
|
||||
const downloadName = buildEnvDetectAttachmentName(
|
||||
resolveAttachmentNameContext(),
|
||||
file,
|
||||
idx >= 0 ? idx : 0,
|
||||
files.length || 1
|
||||
)
|
||||
downloadAttachmentFile({ ...file, fileName: downloadName }, { fullFileUrl })
|
||||
}
|
||||
|
||||
async function handleBatchDownloadAttachments() {
|
||||
const rows = selectedRows.value.filter((row) => (row.attachmentUrls || '').trim())
|
||||
if (!selectedRows.value.length) return
|
||||
if (!rows.length) {
|
||||
ElMessage.warning('所选登记暂无附件')
|
||||
return
|
||||
}
|
||||
batchDownloadLoading.value = true
|
||||
try {
|
||||
const zip = new JSZip()
|
||||
const usedNames = new Set<string>()
|
||||
let added = 0
|
||||
for (const row of rows) {
|
||||
const files = urlsToAttachmentFiles(row.attachmentUrls)
|
||||
const context = { detectTime: row.detectTime, itemName: row.itemName }
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i]
|
||||
const entryName = ensureUniqueZipEntryName(
|
||||
buildEnvDetectAttachmentName(context, file, i, files.length),
|
||||
usedNames
|
||||
)
|
||||
const blob = await fetchAttachmentBlob(file.fileUrl, entryName)
|
||||
if (blob) {
|
||||
zip.file(entryName, blob)
|
||||
added += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
if (added === 0) {
|
||||
ElMessage.error('附件下载失败,请稍后重试')
|
||||
return
|
||||
}
|
||||
const content = await zip.generateAsync({ type: 'blob' })
|
||||
FileSaver.saveAs(content, `环境检测附件_${formatToday()}.zip`)
|
||||
ElMessage.success(`已打包下载 ${added} 个附件`)
|
||||
} finally {
|
||||
batchDownloadLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
@@ -922,6 +1085,9 @@
|
||||
try {
|
||||
const payload = {
|
||||
detectTime: formData.detectTime,
|
||||
resultTime: isEdit.value
|
||||
? formData.resultTime || ''
|
||||
: formData.resultTime || undefined,
|
||||
inspectorIds: formData.inspectorIds,
|
||||
envDetectItemId: formData.envDetectItemId,
|
||||
resultDesc: formData.resultDesc,
|
||||
|
||||
@@ -478,6 +478,15 @@
|
||||
header-align="center"
|
||||
:index="(i) => i + 1"
|
||||
/>
|
||||
<el-table-column type="expand" min-width="40">
|
||||
<template #default="{ $index }">
|
||||
<QcItemParamSelectEditor
|
||||
v-if="itemParams[$index]?.paramType === 'select'"
|
||||
v-model:param="itemParams[$index]"
|
||||
class="param-select-editor-in-table"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="参数名称" min-width="140" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.paramName" placeholder="参数名称" class="inner-cell-input" />
|
||||
@@ -512,9 +521,14 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.paramType" class="inner-cell-select">
|
||||
<el-select
|
||||
v-model="row.paramType"
|
||||
class="inner-cell-select"
|
||||
@change="onItemParamTypeChange(row)"
|
||||
>
|
||||
<el-option label="文本" value="text" />
|
||||
<el-option label="数字" value="number" />
|
||||
<el-option label="单选" value="select" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -621,6 +635,13 @@
|
||||
} from '@/api/qc-third-party-item'
|
||||
import { fetchQcItemParams, fetchSaveQcItemParams, type QcItemParam } from '@/api/qc-item-param'
|
||||
import { fetchItemUnitList } from '@/api/admin'
|
||||
import QcItemParamSelectEditor from '@/components/business/qc-item-param-select-editor/index.vue'
|
||||
import {
|
||||
hydrateQcItemParamsForForm,
|
||||
onQcItemParamTypeChange,
|
||||
serializeQcItemParamsForSave,
|
||||
validateQcItemParamsBeforeSave
|
||||
} from '@/utils/qc-item-param-options'
|
||||
import AmountInput from '@/components/common/amount-input/index.vue'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
|
||||
@@ -979,6 +1000,10 @@
|
||||
itemParams.value = []
|
||||
}
|
||||
|
||||
function onItemParamTypeChange(param: QcItemParam) {
|
||||
onQcItemParamTypeChange(param)
|
||||
}
|
||||
|
||||
function addItemParam() {
|
||||
itemParams.value.push({
|
||||
paramName: '',
|
||||
@@ -1083,7 +1108,7 @@
|
||||
itemForm.remark = row.remark || ''
|
||||
fetchQcItemParams('third_party', row.id)
|
||||
.then((res) => {
|
||||
itemParams.value = res || []
|
||||
itemParams.value = hydrateQcItemParamsForForm(res || [])
|
||||
for (const p of itemParams.value) {
|
||||
ensureUnitOption(p.paramUnit || '')
|
||||
}
|
||||
@@ -1104,6 +1129,11 @@
|
||||
const valid = await itemFormRef.value?.validate?.().catch(() => false)
|
||||
if (!valid) return
|
||||
if (!currentCompanyId.value) return
|
||||
const paramErr = validateQcItemParamsBeforeSave(itemParams.value)
|
||||
if (paramErr) {
|
||||
ElMessage.warning(paramErr)
|
||||
return
|
||||
}
|
||||
itemSubmitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
@@ -1124,7 +1154,11 @@
|
||||
ElMessage.success('已新增')
|
||||
}
|
||||
if (savedId && itemParams.value.length > 0) {
|
||||
await fetchSaveQcItemParams('third_party', savedId, itemParams.value).catch(() => {})
|
||||
await fetchSaveQcItemParams(
|
||||
'third_party',
|
||||
savedId,
|
||||
serializeQcItemParamsForSave(itemParams.value)
|
||||
).catch(() => {})
|
||||
}
|
||||
itemFormVisible.value = false
|
||||
await loadData()
|
||||
@@ -1313,6 +1347,10 @@
|
||||
.inner-cell-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.param-select-editor-in-table {
|
||||
padding: 4px 12px 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.form-grid-3 .form-col-span-2-in-grid3 {
|
||||
|
||||
@@ -161,35 +161,47 @@
|
||||
>
|
||||
暂无参数,点击下方按钮添加
|
||||
</div>
|
||||
<div v-for="(param, idx) in itemParams" :key="idx" class="param-row">
|
||||
<el-input v-model="param.paramName" placeholder="参数名称" style="flex: 2" />
|
||||
<el-input v-model="param.paramCode" placeholder="参数编码" style="flex: 1.5" />
|
||||
<el-select
|
||||
v-model="param.paramUnit"
|
||||
placeholder="单位"
|
||||
clearable
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
:loading="unitOptionsLoading"
|
||||
:remote-method="searchUnitOptions"
|
||||
style="flex: 1"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in unitOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select v-model="param.paramType" style="flex: 1">
|
||||
<el-option label="文本" value="text" />
|
||||
<el-option label="数字" value="number" />
|
||||
</el-select>
|
||||
<el-switch v-model="param.requiredFlag" active-value="1" inactive-value="0" />
|
||||
<el-button class="btn-op-item" @click="removeParam(idx)">
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
<div v-for="(param, idx) in itemParams" :key="idx" class="param-block">
|
||||
<div class="param-row">
|
||||
<el-input v-model="param.paramName" placeholder="参数名称" style="flex: 2" />
|
||||
<el-input v-model="param.paramCode" placeholder="参数编码" style="flex: 1.5" />
|
||||
<el-select
|
||||
v-model="param.paramUnit"
|
||||
placeholder="单位"
|
||||
clearable
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
:loading="unitOptionsLoading"
|
||||
:remote-method="searchUnitOptions"
|
||||
style="flex: 1"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in unitOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="param.paramType"
|
||||
style="flex: 1"
|
||||
@change="onParamTypeChange(param)"
|
||||
>
|
||||
<el-option label="文本" value="text" />
|
||||
<el-option label="数字" value="number" />
|
||||
<el-option label="单选" value="select" />
|
||||
</el-select>
|
||||
<el-switch v-model="param.requiredFlag" active-value="1" inactive-value="0" />
|
||||
<el-button class="btn-op-item" @click="removeParam(idx)">
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<QcItemParamSelectEditor
|
||||
v-if="param.paramType === 'select'"
|
||||
v-model:param="itemParams[idx]"
|
||||
class="param-select-editor-wrap"
|
||||
/>
|
||||
</div>
|
||||
<el-button type="primary" plain style="margin-top: 8px" @click="addParam">
|
||||
<el-icon><Plus /></el-icon>添加参数
|
||||
@@ -251,6 +263,13 @@
|
||||
import { fetchQcItemParams, fetchSaveQcItemParams, type QcItemParam } from '@/api/qc-item-param'
|
||||
import { fetchItemUnitList } from '@/api/admin'
|
||||
import ThirdPartyCompanyTab from './ThirdPartyCompanyTab.vue'
|
||||
import QcItemParamSelectEditor from '@/components/business/qc-item-param-select-editor/index.vue'
|
||||
import {
|
||||
hydrateQcItemParamsForForm,
|
||||
onQcItemParamTypeChange,
|
||||
serializeQcItemParamsForSave,
|
||||
validateQcItemParamsBeforeSave
|
||||
} from '@/utils/qc-item-param-options'
|
||||
|
||||
defineOptions({ name: 'QualityInspectionLabTestItem' })
|
||||
|
||||
@@ -328,6 +347,10 @@
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||
}
|
||||
|
||||
function onParamTypeChange(param: QcItemParam) {
|
||||
onQcItemParamTypeChange(param)
|
||||
}
|
||||
|
||||
function addParam() {
|
||||
itemParams.value.push({
|
||||
paramName: '',
|
||||
@@ -395,7 +418,7 @@
|
||||
})
|
||||
fetchQcItemParams('lab', row.id)
|
||||
.then((res) => {
|
||||
itemParams.value = res || []
|
||||
itemParams.value = hydrateQcItemParamsForForm(res || [])
|
||||
for (const p of itemParams.value) {
|
||||
ensureUnitOption(p.paramUnit || '')
|
||||
}
|
||||
@@ -409,6 +432,11 @@
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!(await formRef.value?.validate?.().catch(() => false))) return
|
||||
const paramErr = validateQcItemParamsBeforeSave(itemParams.value)
|
||||
if (paramErr) {
|
||||
ElMessage.warning(paramErr)
|
||||
return
|
||||
}
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
@@ -427,7 +455,11 @@
|
||||
}
|
||||
dialogVisible.value = false
|
||||
if (savedId && itemParams.value.length > 0) {
|
||||
await fetchSaveQcItemParams('lab', savedId, itemParams.value).catch(() => {})
|
||||
await fetchSaveQcItemParams(
|
||||
'lab',
|
||||
savedId,
|
||||
serializeQcItemParamsForSave(itemParams.value)
|
||||
).catch(() => {})
|
||||
}
|
||||
loadData()
|
||||
} finally {
|
||||
@@ -633,11 +665,22 @@
|
||||
border-left: 3px solid #047857;
|
||||
}
|
||||
|
||||
.param-block {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.param-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.param-select-editor-wrap {
|
||||
margin: 8px 0 0 12px;
|
||||
padding: 8px 12px;
|
||||
background: var(--surface, #fff);
|
||||
border: 1px dashed var(--mint-border, #d9e8e2);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.param-row-header {
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
<!-- 质检管理 — 我的质检任务(六 Tab,仅展示本人任务) -->
|
||||
<!-- 质检管理 — 我的质检任务(含「所有」Tab) -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-pill-tabs panel-pill-tabs--lg">
|
||||
<div class="panel-pill-tabs__track" role="tablist">
|
||||
<button
|
||||
v-for="tab in QC_WORK_ORDER_VISIBLE_TABS"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="panel-pill-tabs__btn"
|
||||
:class="{ 'is-active': activeTabKey === tab.key }"
|
||||
:aria-selected="activeTabKey === tab.key"
|
||||
@click="handleTabChange(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<QcWorkOrderTabBar
|
||||
ref="tabBarRef"
|
||||
:active-tab-key="activeTabKey"
|
||||
scope="mine"
|
||||
@change="handleTabChange"
|
||||
/>
|
||||
|
||||
<component :is="activeTabComponent" :key="activeTabKey" page-mode="mine" />
|
||||
<component
|
||||
:is="activeTabComponent"
|
||||
:key="activeTabKey"
|
||||
page-mode="mine"
|
||||
@data-changed="reloadTabCounts"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -28,21 +23,25 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
QC_WORK_ORDER_VISIBLE_TABS,
|
||||
parseQcWorkOrderTabKey,
|
||||
type QcWorkOrderTabKey
|
||||
} from '@/utils/qc-work-order-tabs'
|
||||
import { parseQcWorkOrderTabKey, type QcWorkOrderTabKey } from '@/utils/qc-work-order-tabs'
|
||||
import QcWorkOrderTabBar from '../qc-work-order/QcWorkOrderTabBar.vue'
|
||||
import { getQcWorkOrderTabComponent } from '../qc-work-order/tabs/tab-registry'
|
||||
import { refreshQcMenuBadges } from '@/utils/qc-menu-badge'
|
||||
|
||||
defineOptions({ name: 'QualityInspectionMyQcTask' })
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const tabBarRef = ref<{ reload: () => Promise<void> } | null>(null)
|
||||
const activeTabKey = ref<QcWorkOrderTabKey>(parseQcWorkOrderTabKey(route.query.tab as string))
|
||||
const activeTabComponent = computed(() => getQcWorkOrderTabComponent(activeTabKey.value))
|
||||
|
||||
function reloadTabCounts() {
|
||||
tabBarRef.value?.reload()
|
||||
void refreshQcMenuBadges()
|
||||
}
|
||||
|
||||
function handleTabChange(key: QcWorkOrderTabKey) {
|
||||
if (activeTabKey.value === key) return
|
||||
activeTabKey.value = key
|
||||
|
||||
@@ -313,7 +313,9 @@
|
||||
<div><span class="ro-label">领用时间</span>{{ activeRequisition.useTime || '—' }}</div>
|
||||
<div><span class="ro-label">规格</span>{{ activeRequisition.specModel || '—' }}</div>
|
||||
<div><span class="ro-label">厂家</span>{{ activeRequisition.manufacturer || '—' }}</div>
|
||||
<div><span class="ro-label">单价</span>{{ displayMoney(activeRequisition.unitPrice) }}</div>
|
||||
<div v-if="showAmountColumns">
|
||||
<span class="ro-label">单价</span>{{ displayMoney(activeRequisition.unitPrice) }}
|
||||
</div>
|
||||
<div><span class="ro-label">过期日期</span>{{ activeRequisition.expireDate || '—' }}</div>
|
||||
</div>
|
||||
<el-form label-position="top" class="unused-edit-form">
|
||||
@@ -328,7 +330,7 @@
|
||||
@blur="dbgQtyInputBlur"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="剩余金额(元)">
|
||||
<el-form-item v-if="showAmountColumns" label="剩余金额(元)">
|
||||
<el-input
|
||||
:model-value="displayMoney(calcLineAmount(activeDraft.unitPrice, activeDraft.unusedQty))"
|
||||
disabled
|
||||
@@ -381,7 +383,9 @@
|
||||
<div><span class="ro-label">批号</span>{{ manualDraft.batchNo || '—' }}</div>
|
||||
<div><span class="ro-label">规格</span>{{ manualDraft.specModel || '—' }}</div>
|
||||
<div><span class="ro-label">厂家</span>{{ manualDraft.manufacturer || '—' }}</div>
|
||||
<div><span class="ro-label">单价</span>{{ displayMoney(manualDraft.unitPrice) }}</div>
|
||||
<div v-if="showAmountColumns">
|
||||
<span class="ro-label">单价</span>{{ displayMoney(manualDraft.unitPrice) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="未用完数量" required>
|
||||
@@ -393,7 +397,7 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="剩余金额(元)">
|
||||
<el-form-item v-if="showAmountColumns" label="剩余金额(元)">
|
||||
<el-input
|
||||
:model-value="displayMoney(calcLineAmount(manualDraft.unitPrice, manualDraft.unusedQty))"
|
||||
disabled
|
||||
@@ -491,10 +495,22 @@
|
||||
<el-table-column label="厂家" min-width="110" align="center" header-align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ displayText(row.manufacturer) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单价(元)" min-width="100" align="center" header-align="center">
|
||||
<el-table-column
|
||||
v-if="showAmountColumns"
|
||||
label="单价(元)"
|
||||
min-width="100"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ displayMoney(row.unitPrice) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="剩余金额(元)" min-width="120" align="center" header-align="center">
|
||||
<el-table-column
|
||||
v-if="showAmountColumns"
|
||||
label="剩余金额(元)"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ displayMoney(row.remainingAmount ?? calcLineAmount(row.unitPrice, row.remainingQty)) }}
|
||||
</template>
|
||||
@@ -544,10 +560,22 @@
|
||||
<el-table-column label="厂家" min-width="110" align="center" header-align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ displayText(row.manufacturer) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单价(元)" min-width="100" align="center" header-align="center">
|
||||
<el-table-column
|
||||
v-if="showAmountColumns"
|
||||
label="单价(元)"
|
||||
min-width="100"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ displayMoney(row.unitPrice) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="剩余金额(元)" min-width="120" align="center" header-align="center">
|
||||
<el-table-column
|
||||
v-if="showAmountColumns"
|
||||
label="剩余金额(元)"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ displayMoney(row.remainingAmount ?? calcLineAmount(row.unitPrice, row.unusedQty)) }}
|
||||
</template>
|
||||
@@ -599,6 +627,7 @@
|
||||
import * as XLSX from 'xlsx'
|
||||
import FileSaver from 'file-saver'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { useMenuPerm } from '@/hooks/core/useMenuPerm'
|
||||
import { fetchQcMaterialBatchOptions, type QcMaterialBatchOption } from '@/api/qc-material'
|
||||
import { fetchMarkQcMaterialUsageFullyUsed } from '@/api/qc-material-usage'
|
||||
import {
|
||||
@@ -619,6 +648,9 @@
|
||||
|
||||
defineOptions({ name: 'QcMaterialStockCheckTab' })
|
||||
|
||||
const { hasQcMaterialViewAmount } = useMenuPerm()
|
||||
const showAmountColumns = computed(() => hasQcMaterialViewAmount.value)
|
||||
|
||||
const searchForm = reactive({ keyword: '', status: '' })
|
||||
const dateRange = ref<[string, string] | null>(null)
|
||||
const tableData = ref<QcMaterialStockCheck[]>([])
|
||||
@@ -1382,23 +1414,30 @@
|
||||
const viewDetail = ref<QcMaterialStockCheckDetail | null>(null)
|
||||
const exportLoadingId = ref('')
|
||||
|
||||
const MERGED_EXPORT_HEADERS = [
|
||||
'序号',
|
||||
'入库编号',
|
||||
'入库日期',
|
||||
'过期日期',
|
||||
'物料编码',
|
||||
'物料名称',
|
||||
'规格型号',
|
||||
'单位',
|
||||
'货号',
|
||||
'批号',
|
||||
'厂家',
|
||||
'单价(元)',
|
||||
'数量',
|
||||
'剩余金额(元)',
|
||||
'备注'
|
||||
]
|
||||
const mergedExportHeaders = computed(() => {
|
||||
const headers = [
|
||||
'序号',
|
||||
'入库编号',
|
||||
'入库日期',
|
||||
'过期日期',
|
||||
'物料编码',
|
||||
'物料名称',
|
||||
'规格型号',
|
||||
'单位',
|
||||
'货号',
|
||||
'批号',
|
||||
'厂家'
|
||||
]
|
||||
if (showAmountColumns.value) {
|
||||
headers.push('单价(元)')
|
||||
}
|
||||
headers.push('数量')
|
||||
if (showAmountColumns.value) {
|
||||
headers.push('剩余金额(元)')
|
||||
}
|
||||
headers.push('备注')
|
||||
return headers
|
||||
})
|
||||
|
||||
type StockCheckExportLine = {
|
||||
groupKey: string
|
||||
@@ -1521,7 +1560,7 @@
|
||||
|
||||
return Array.from(groups.values()).map((group, index) => {
|
||||
const { meta, totalQty, totalAmount, remarks } = group
|
||||
return {
|
||||
const row: Record<string, unknown> = {
|
||||
序号: index + 1,
|
||||
入库编号: exportCell(meta.stockInNo),
|
||||
入库日期: exportCell(meta.stockInDate),
|
||||
@@ -1532,12 +1571,17 @@
|
||||
单位: exportCell(meta.unit),
|
||||
货号: exportCell(meta.catalogNo),
|
||||
批号: exportCell(meta.batchNo),
|
||||
厂家: exportCell(meta.manufacturer),
|
||||
'单价(元)': exportMoney(meta.unitPrice),
|
||||
数量: exportCell(totalQty),
|
||||
'剩余金额(元)': exportMoney(Math.round(totalAmount * 100) / 100),
|
||||
备注: remarks.join(';')
|
||||
厂家: exportCell(meta.manufacturer)
|
||||
}
|
||||
if (showAmountColumns.value) {
|
||||
row['单价(元)'] = exportMoney(meta.unitPrice)
|
||||
}
|
||||
row['数量'] = exportCell(totalQty)
|
||||
if (showAmountColumns.value) {
|
||||
row['剩余金额(元)'] = exportMoney(Math.round(totalAmount * 100) / 100)
|
||||
}
|
||||
row['备注'] = remarks.join(';')
|
||||
return row
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1554,7 +1598,7 @@
|
||||
|
||||
XLSX.utils.book_append_sheet(
|
||||
workbook,
|
||||
buildExportWorksheet(MERGED_EXPORT_HEADERS, mergedRows),
|
||||
buildExportWorksheet(mergedExportHeaders.value, mergedRows),
|
||||
sanitizeSheetName('库存盘点')
|
||||
)
|
||||
|
||||
|
||||
@@ -406,10 +406,10 @@
|
||||
)
|
||||
|
||||
const route = useRoute()
|
||||
const { hasMyQcMaterialUsageViewAmount } = useMenuPerm()
|
||||
const { hasMyQcMaterialUsageViewAmount, hasQcMaterialViewAmount } = useMenuPerm()
|
||||
|
||||
const showAmountColumns = computed(
|
||||
() => !props.mineOnly || hasMyQcMaterialUsageViewAmount.value
|
||||
const showAmountColumns = computed(() =>
|
||||
props.mineOnly ? hasMyQcMaterialUsageViewAmount.value : hasQcMaterialViewAmount.value
|
||||
)
|
||||
|
||||
const searchForm = reactive<{
|
||||
|
||||
@@ -174,10 +174,22 @@
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="单价(元)" min-width="110" align="center" header-align="center">
|
||||
<el-table-column
|
||||
v-if="showAmountColumns"
|
||||
label="单价(元)"
|
||||
min-width="110"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ formatMoneyDisplay(row.unitPrice) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额(元)" min-width="110" align="center" header-align="center">
|
||||
<el-table-column
|
||||
v-if="showAmountColumns"
|
||||
label="金额(元)"
|
||||
min-width="110"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ formatMoneyDisplay(row.amount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@@ -324,7 +336,7 @@
|
||||
<el-form-item label="入库数量">
|
||||
<el-input :model-value="String(formData.inQty ?? 0)" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="单价(元)" prop="unitPrice">
|
||||
<el-form-item v-if="showAmountColumns" label="单价(元)" prop="unitPrice">
|
||||
<AmountInput
|
||||
v-model="formData.unitPrice"
|
||||
:min="0"
|
||||
@@ -332,7 +344,7 @@
|
||||
@change="onEditPriceQtyChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="金额(元)" prop="amount">
|
||||
<el-form-item v-if="showAmountColumns" label="金额(元)" prop="amount">
|
||||
<AmountInput
|
||||
v-model="formData.amount"
|
||||
:min="0"
|
||||
@@ -1191,9 +1203,13 @@
|
||||
import QcMaterialUsageTab from './QcMaterialUsageTab.vue'
|
||||
import QcMaterialStockCheckTab from './QcMaterialStockCheckTab.vue'
|
||||
import QcMaterialBatchAttachmentDialog from './QcMaterialBatchAttachmentDialog.vue'
|
||||
import { useMenuPerm } from '@/hooks/core/useMenuPerm'
|
||||
|
||||
defineOptions({ name: 'QualityInspectionQcMaterial' })
|
||||
|
||||
const { hasQcMaterialViewAmount } = useMenuPerm()
|
||||
const showAmountColumns = computed(() => hasQcMaterialViewAmount.value)
|
||||
|
||||
/** 暂时隐藏批量入库入口,恢复时改为 true */
|
||||
const batchStockInButtonVisible = false
|
||||
|
||||
@@ -1333,18 +1349,23 @@
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
stockInNo: [{ required: true, message: '请输入入库编号', trigger: 'blur' }],
|
||||
stockInDate: [{ required: true, message: '请选择入库日期', trigger: 'change' }],
|
||||
expireDate: [{ required: true, message: '请选择过期日期', trigger: 'change' }],
|
||||
catalogNo: [{ required: true, message: '请输入货号', trigger: 'blur' }],
|
||||
batchNo: [{ required: true, message: '请输入批号', trigger: 'blur' }],
|
||||
manufacturer: [{ required: true, message: '请输入厂家', trigger: 'blur' }],
|
||||
unitPrice: [{ required: true, message: '请输入单价', trigger: 'change' }],
|
||||
amount: [{ required: true, message: '请输入金额', trigger: 'change' }],
|
||||
materialCode: [{ required: true, message: '请输入物料编码', trigger: 'blur' }],
|
||||
materialName: [{ required: true, message: '请输入物料名称', trigger: 'blur' }]
|
||||
}
|
||||
const formRules = computed(() => {
|
||||
const rules: Record<string, unknown[]> = {
|
||||
stockInNo: [{ required: true, message: '请输入入库编号', trigger: 'blur' }],
|
||||
stockInDate: [{ required: true, message: '请选择入库日期', trigger: 'change' }],
|
||||
expireDate: [{ required: true, message: '请选择过期日期', trigger: 'change' }],
|
||||
catalogNo: [{ required: true, message: '请输入货号', trigger: 'blur' }],
|
||||
batchNo: [{ required: true, message: '请输入批号', trigger: 'blur' }],
|
||||
manufacturer: [{ required: true, message: '请输入厂家', trigger: 'blur' }],
|
||||
materialCode: [{ required: true, message: '请输入物料编码', trigger: 'blur' }],
|
||||
materialName: [{ required: true, message: '请输入物料名称', trigger: 'blur' }]
|
||||
}
|
||||
if (showAmountColumns.value) {
|
||||
rules.unitPrice = [{ required: true, message: '请输入单价', trigger: 'change' }]
|
||||
rules.amount = [{ required: true, message: '请输入金额', trigger: 'change' }]
|
||||
}
|
||||
return rules
|
||||
})
|
||||
|
||||
// 入库
|
||||
const stockInVisible = ref(false)
|
||||
@@ -1552,48 +1573,58 @@
|
||||
|
||||
const qcMaterialExportFilename = 'qc_material_batch_export'
|
||||
|
||||
const qcMaterialExportColumns = {
|
||||
stockInNo: { title: '入库编号' },
|
||||
stockInDate: { title: '入库日期' },
|
||||
expireDate: { title: '过期日期' },
|
||||
materialCode: { title: '物料编码' },
|
||||
materialName: { title: '物料名称' },
|
||||
specModel: { title: '规格型号' },
|
||||
unit: { title: '单位' },
|
||||
catalogNo: { title: '货号' },
|
||||
batchNo: { title: '批号' },
|
||||
manufacturer: { title: '厂家' },
|
||||
unitPrice: {
|
||||
title: '单价(元)',
|
||||
formatter: (v: unknown) => formatMoneyDisplay(v as number)
|
||||
},
|
||||
amount: {
|
||||
title: '金额(元)',
|
||||
formatter: (v: unknown) => formatMoneyDisplay(v as number)
|
||||
},
|
||||
inQty: { title: '入库数量' },
|
||||
remainingQty: { title: '剩余数量' },
|
||||
remark: { title: '备注' }
|
||||
} as const
|
||||
|
||||
const mapQcMaterialExportRow = (row: QcMaterialBatch) => ({
|
||||
stockInNo: row.stockInNo,
|
||||
stockInDate: row.stockInDate,
|
||||
expireDate: row.expireDate,
|
||||
materialCode: row.materialCode,
|
||||
materialName: row.materialName,
|
||||
specModel: row.specModel,
|
||||
unit: row.unit,
|
||||
catalogNo: row.catalogNo,
|
||||
batchNo: row.batchNo,
|
||||
manufacturer: row.manufacturer,
|
||||
unitPrice: row.unitPrice,
|
||||
amount: row.amount,
|
||||
inQty: row.inQty,
|
||||
remainingQty: row.remainingQty,
|
||||
remark: row.remark
|
||||
const qcMaterialExportColumns = computed(() => {
|
||||
const cols: Record<string, { title: string; formatter?: (v: unknown) => string }> = {
|
||||
stockInNo: { title: '入库编号' },
|
||||
stockInDate: { title: '入库日期' },
|
||||
expireDate: { title: '过期日期' },
|
||||
materialCode: { title: '物料编码' },
|
||||
materialName: { title: '物料名称' },
|
||||
specModel: { title: '规格型号' },
|
||||
unit: { title: '单位' },
|
||||
catalogNo: { title: '货号' },
|
||||
batchNo: { title: '批号' },
|
||||
manufacturer: { title: '厂家' },
|
||||
inQty: { title: '入库数量' },
|
||||
remainingQty: { title: '剩余数量' },
|
||||
remark: { title: '备注' }
|
||||
}
|
||||
if (showAmountColumns.value) {
|
||||
cols.unitPrice = {
|
||||
title: '单价(元)',
|
||||
formatter: (v: unknown) => formatMoneyDisplay(v as number)
|
||||
}
|
||||
cols.amount = {
|
||||
title: '金额(元)',
|
||||
formatter: (v: unknown) => formatMoneyDisplay(v as number)
|
||||
}
|
||||
}
|
||||
return cols
|
||||
})
|
||||
|
||||
const mapQcMaterialExportRow = (row: QcMaterialBatch) => {
|
||||
const base: Record<string, unknown> = {
|
||||
stockInNo: row.stockInNo,
|
||||
stockInDate: row.stockInDate,
|
||||
expireDate: row.expireDate,
|
||||
materialCode: row.materialCode,
|
||||
materialName: row.materialName,
|
||||
specModel: row.specModel,
|
||||
unit: row.unit,
|
||||
catalogNo: row.catalogNo,
|
||||
batchNo: row.batchNo,
|
||||
manufacturer: row.manufacturer,
|
||||
inQty: row.inQty,
|
||||
remainingQty: row.remainingQty,
|
||||
remark: row.remark
|
||||
}
|
||||
if (showAmountColumns.value) {
|
||||
base.unitPrice = row.unitPrice
|
||||
base.amount = row.amount
|
||||
}
|
||||
return base
|
||||
}
|
||||
|
||||
const batchExportData = computed(() => {
|
||||
const sel = selectedRows.value || []
|
||||
if (sel.length === 0) return []
|
||||
@@ -1629,8 +1660,12 @@
|
||||
{ label: '货号', value: row.catalogNo },
|
||||
{ label: '批号', value: row.batchNo },
|
||||
{ label: '厂家', value: row.manufacturer },
|
||||
{ label: '单价(元)', value: formatMoneyDisplay(row.unitPrice) },
|
||||
{ label: '金额(元)', value: formatMoneyDisplay(row.amount) },
|
||||
...(showAmountColumns.value
|
||||
? [
|
||||
{ label: '单价(元)', value: formatMoneyDisplay(row.unitPrice) },
|
||||
{ label: '金额(元)', value: formatMoneyDisplay(row.amount) }
|
||||
]
|
||||
: []),
|
||||
{ label: '入库数量', value: String(row.inQty ?? 0) },
|
||||
{ label: '剩余数量', value: String(row.remainingQty ?? 0) }
|
||||
]
|
||||
@@ -1741,15 +1776,13 @@
|
||||
if (!editingBatchId.value) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
await fetchUpdateQcMaterialBatch(editingBatchId.value, {
|
||||
const payload: Record<string, unknown> = {
|
||||
stockInNo: formData.stockInNo.trim(),
|
||||
stockInDate: formData.stockInDate,
|
||||
expireDate: formData.expireDate,
|
||||
catalogNo: formData.catalogNo.trim(),
|
||||
batchNo: formData.batchNo.trim(),
|
||||
manufacturer: formData.manufacturer.trim(),
|
||||
unitPrice: Number(formData.unitPrice) || 0,
|
||||
amount: Number(formData.amount) || 0,
|
||||
materialCode: formData.materialCode.trim(),
|
||||
materialName: formData.materialName.trim(),
|
||||
specModel: formData.specModel?.trim() || undefined,
|
||||
@@ -1757,7 +1790,12 @@
|
||||
warningQty: formData.warningQty,
|
||||
status: String(formData.status ?? '1'),
|
||||
remark: formData.remark?.trim() || undefined
|
||||
})
|
||||
}
|
||||
if (showAmountColumns.value) {
|
||||
payload.unitPrice = Number(formData.unitPrice) || 0
|
||||
payload.amount = Number(formData.amount) || 0
|
||||
}
|
||||
await fetchUpdateQcMaterialBatch(editingBatchId.value, payload as any)
|
||||
ElMessage.success('更新成功')
|
||||
dialogVisible.value = false
|
||||
await loadData()
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
<!-- 质检工单展开行 · 按检测批次 Tab 展示任务 -->
|
||||
<template>
|
||||
<div
|
||||
class="qc-work-order-batch-sublist"
|
||||
:class="{ 'qc-work-order-batch-sublist--embedded': embedded }"
|
||||
v-loading="loading"
|
||||
>
|
||||
<template v-if="batchSections.length">
|
||||
<el-tabs
|
||||
v-model="activeBatchKey"
|
||||
class="panel-pill-tabs panel-pill-tabs--start qc-batch-tabs"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="section in batchSections"
|
||||
:key="section.key"
|
||||
:name="section.key"
|
||||
lazy
|
||||
>
|
||||
<template #label>
|
||||
<span class="qc-batch-tabs__label">{{ section.batchName }}</span>
|
||||
<span class="qc-batch-tabs__count">
|
||||
{{ section.completedTaskCount }}/{{ section.taskCount }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="activeBatchKey === section.key">
|
||||
<div v-if="section.batchNo || section.assigneeUserNames" class="qc-batch-tabs__meta">
|
||||
<span v-if="section.batchNo" class="qc-batch-tabs__meta-item">{{ section.batchNo }}</span>
|
||||
<span v-if="section.assigneeUserNames" class="qc-batch-tabs__meta-item">
|
||||
负责人:{{ section.assigneeUserNames }}
|
||||
</span>
|
||||
</div>
|
||||
<QcWorkOrderTaskSubList
|
||||
embedded
|
||||
:work-order="workOrder"
|
||||
:list-mode="listMode"
|
||||
:preset-tasks="section.tasks"
|
||||
@changed="handleTaskChanged"
|
||||
/>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
<div v-else-if="!loading" class="qc-work-order-batch-sublist__empty hint-muted">
|
||||
暂无检测批次或任务
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import type { QcWorkOrder } from '@/api/qc-work-order'
|
||||
import type { QcTask } from '@/api/qc-task'
|
||||
import {
|
||||
fetchQcInspectionBatches,
|
||||
resolveBatchSections,
|
||||
type QcBatchTaskSection,
|
||||
type QcInspectionBatch
|
||||
} from '@/utils/qc-inspection-batch'
|
||||
import QcWorkOrderTaskSubList from './QcWorkOrderTaskSubList.vue'
|
||||
|
||||
defineOptions({ name: 'QcWorkOrderBatchSubList' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
workOrder: QcWorkOrder
|
||||
listMode?: 'workOrder' | 'mine'
|
||||
embedded?: boolean
|
||||
refreshToken?: number
|
||||
presetTasks?: QcTask[]
|
||||
}>(),
|
||||
{
|
||||
listMode: 'workOrder'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
changed: []
|
||||
}>()
|
||||
|
||||
const loading = ref(false)
|
||||
const batches = ref<QcInspectionBatch[]>([])
|
||||
const activeBatchKey = ref('')
|
||||
|
||||
const batchSections = computed<QcBatchTaskSection<QcTask>[]>(() =>
|
||||
resolveBatchSections(batches.value, props.presetTasks)
|
||||
)
|
||||
|
||||
function ensureActiveBatchKey(sections: QcBatchTaskSection<QcTask>[]) {
|
||||
if (!sections.length) {
|
||||
activeBatchKey.value = ''
|
||||
return
|
||||
}
|
||||
const keys = new Set(sections.map((s) => s.key))
|
||||
if (activeBatchKey.value && !keys.has(activeBatchKey.value)) {
|
||||
activeBatchKey.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
async function loadBatches() {
|
||||
const woId = props.workOrder?.id
|
||||
if (!woId) {
|
||||
batches.value = []
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const list = await fetchQcInspectionBatches(woId)
|
||||
batches.value = list || []
|
||||
} catch {
|
||||
batches.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleTaskChanged() {
|
||||
emit('changed')
|
||||
if (!props.presetTasks) {
|
||||
loadBatches()
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
batchSections,
|
||||
(sections) => {
|
||||
ensureActiveBatchKey(sections)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => [props.workOrder?.id, props.refreshToken] as const,
|
||||
() => {
|
||||
if (props.presetTasks === undefined) {
|
||||
loadBatches()
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.qc-batch-tabs {
|
||||
&.panel-pill-tabs.el-tabs > :deep(.el-tabs__header) {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
&.panel-pill-tabs.el-tabs :deep(.el-tabs__nav-scroll) {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
&.panel-pill-tabs.el-tabs :deep(.el-tabs__item) {
|
||||
min-width: 96px;
|
||||
padding: 6px 14px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.qc-batch-tabs__label {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.qc-batch-tabs__count {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.qc-batch-tabs__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 16px;
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.qc-work-order-batch-sublist__empty {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.qc-work-order-batch-sublist--embedded {
|
||||
padding: 10px 14px 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,24 +1,81 @@
|
||||
<!-- 质检工单 · 卡片列表(入库按样本分组 + 出库/临时单列) -->
|
||||
<!-- 质检工单 · 卡片列表(入库按协议分组 + 出库/临时单列) -->
|
||||
<template>
|
||||
<div class="list-body list-wrap qc-work-order-cards-body">
|
||||
<div v-loading="loading" class="qc-work-order-cards-wrap">
|
||||
<template v-if="useGroupedList">
|
||||
<QcWorkOrderSampleGroup
|
||||
v-for="(group, idx) in groupedRows"
|
||||
:key="group.groupKey"
|
||||
:group="group"
|
||||
:group-index="cardIndex(idx)"
|
||||
:card-meta-config="cardMetaConfig"
|
||||
:task-refresh-token="taskRefreshToken"
|
||||
:show-work-order-ops="!isMineMode"
|
||||
:show-work-order-view-only="isMineMode"
|
||||
:task-list-mode="isMineMode ? 'mine' : 'workOrder'"
|
||||
:preset-tasks-by-work-order-id="presetTasksByWorkOrderId"
|
||||
@configure="(row) => emit('configure', row)"
|
||||
@view="(row) => emit('view', row)"
|
||||
@command="(cmd, row) => emit('command', cmd, row)"
|
||||
@tasks-changed="emit('tasks-changed')"
|
||||
/>
|
||||
<template v-if="isAllTabList">
|
||||
<template v-for="(item, idx) in allTabListItems">
|
||||
<QcWorkOrderSampleGroup
|
||||
v-if="item.kind === 'sample-group'"
|
||||
:key="allTabItemKey(item, idx)"
|
||||
:group="item.group"
|
||||
:group-index="cardIndex(idx)"
|
||||
:card-meta-config="cardMetaConfig"
|
||||
:task-refresh-token="taskRefreshToken"
|
||||
:show-work-order-ops="!isMineMode"
|
||||
:show-work-order-view-only="isMineMode"
|
||||
:task-list-mode="isMineMode ? 'mine' : 'workOrder'"
|
||||
:preset-tasks-by-work-order-id="presetTasksByWorkOrderId"
|
||||
@configure="(row) => emit('configure', row)"
|
||||
@view="(row) => emit('view', row)"
|
||||
@command="(cmd, row) => emit('command', cmd, row)"
|
||||
@tasks-changed="emit('tasks-changed')"
|
||||
/>
|
||||
<QcWorkOrderSingleCard
|
||||
v-else
|
||||
:key="allTabItemKey(item, idx)"
|
||||
layout="standalone"
|
||||
:row="item.row"
|
||||
:card-meta-config="cardMetaConfig"
|
||||
:card-index="cardIndex(idx)"
|
||||
:task-refresh-token="taskRefreshToken"
|
||||
:preset-tasks="isMineMode ? presetTasksByWorkOrderId?.[item.row.id] : undefined"
|
||||
:show-work-order-ops="!isMineMode"
|
||||
:show-work-order-view-only="isMineMode"
|
||||
:task-list-mode="isMineMode ? 'mine' : 'workOrder'"
|
||||
@configure="(row) => emit('configure', row)"
|
||||
@view="(row) => emit('view', row)"
|
||||
@command="(cmd, row) => emit('command', cmd, row)"
|
||||
@tasks-changed="emit('tasks-changed')"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
<template v-else-if="useGroupedList">
|
||||
<template v-if="cardMetaUsesInboundGroups(cardMetaConfig.tabKey)">
|
||||
<QcWorkOrderProtocolGroup
|
||||
v-for="(group, idx) in protocolGroupedRows"
|
||||
:key="group.groupKey"
|
||||
:group="group"
|
||||
:group-index="cardIndex(idx)"
|
||||
:card-meta-config="cardMetaConfig"
|
||||
:task-refresh-token="taskRefreshToken"
|
||||
:show-work-order-ops="!isMineMode"
|
||||
:show-work-order-view-only="isMineMode"
|
||||
:task-list-mode="isMineMode ? 'mine' : 'workOrder'"
|
||||
:preset-tasks-by-work-order-id="presetTasksByWorkOrderId"
|
||||
@configure="(row) => emit('configure', row)"
|
||||
@view="(row) => emit('view', row)"
|
||||
@command="(cmd, row) => emit('command', cmd, row)"
|
||||
@tasks-changed="emit('tasks-changed')"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<QcWorkOrderSampleGroup
|
||||
v-for="(group, idx) in groupedRows"
|
||||
:key="group.groupKey"
|
||||
:group="group"
|
||||
:group-index="cardIndex(idx)"
|
||||
:card-meta-config="cardMetaConfig"
|
||||
:task-refresh-token="taskRefreshToken"
|
||||
:show-work-order-ops="!isMineMode"
|
||||
:show-work-order-view-only="isMineMode"
|
||||
:task-list-mode="isMineMode ? 'mine' : 'workOrder'"
|
||||
:preset-tasks-by-work-order-id="presetTasksByWorkOrderId"
|
||||
@configure="(row) => emit('configure', row)"
|
||||
@view="(row) => emit('view', row)"
|
||||
@command="(cmd, row) => emit('command', cmd, row)"
|
||||
@tasks-changed="emit('tasks-changed')"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
<template v-else>
|
||||
<QcWorkOrderSingleCard
|
||||
@@ -63,13 +120,20 @@
|
||||
import { computed } from 'vue'
|
||||
import type { QcWorkOrder } from '@/api/qc-work-order'
|
||||
import type { QcTask } from '@/api/qc-task'
|
||||
import { groupInboundQcWorkOrders, groupOutboundQcWorkOrders } from '@/utils/qc-work-order-groups'
|
||||
import {
|
||||
groupInboundQcWorkOrdersByProtocol,
|
||||
groupOutboundQcWorkOrders,
|
||||
buildAllTabListItems,
|
||||
type QcWorkOrderAllTabListItem
|
||||
} from '@/utils/qc-work-order-groups'
|
||||
import type { QcWorkOrderCardMetaConfig } from '@/utils/qc-work-order-card-meta'
|
||||
import {
|
||||
cardMetaUsesInboundGroups,
|
||||
cardMetaUsesOutboundGroups,
|
||||
cardMetaUsesGroupedList
|
||||
} from '@/utils/qc-work-order-card-meta'
|
||||
import { isAllQcWorkOrderTab } from '@/utils/qc-work-order-tabs'
|
||||
import QcWorkOrderProtocolGroup from './QcWorkOrderProtocolGroup.vue'
|
||||
import QcWorkOrderSampleGroup from './QcWorkOrderSampleGroup.vue'
|
||||
import QcWorkOrderSingleCard from './QcWorkOrderSingleCard.vue'
|
||||
|
||||
@@ -103,12 +167,20 @@
|
||||
'page-size-change': [size: number]
|
||||
}>()
|
||||
|
||||
const useGroupedList = computed(() => cardMetaUsesGroupedList(props.cardMetaConfig.tabKey))
|
||||
const isAllTabList = computed(() => isAllQcWorkOrderTab(props.cardMetaConfig.tabKey))
|
||||
|
||||
const useGroupedList = computed(
|
||||
() => !isAllTabList.value && cardMetaUsesGroupedList(props.cardMetaConfig.tabKey)
|
||||
)
|
||||
|
||||
const allTabListItems = computed(() => buildAllTabListItems(props.rows))
|
||||
|
||||
const protocolGroupedRows = computed(() => {
|
||||
if (!cardMetaUsesInboundGroups(props.cardMetaConfig.tabKey)) return []
|
||||
return groupInboundQcWorkOrdersByProtocol(props.rows)
|
||||
})
|
||||
|
||||
const groupedRows = computed(() => {
|
||||
if (cardMetaUsesInboundGroups(props.cardMetaConfig.tabKey)) {
|
||||
return groupInboundQcWorkOrders(props.rows)
|
||||
}
|
||||
if (cardMetaUsesOutboundGroups(props.cardMetaConfig.tabKey)) {
|
||||
return groupOutboundQcWorkOrders(props.rows)
|
||||
}
|
||||
@@ -118,6 +190,11 @@
|
||||
function cardIndex(i: number) {
|
||||
return (props.page - 1) * props.pageSize + i + 1
|
||||
}
|
||||
|
||||
function allTabItemKey(item: QcWorkOrderAllTabListItem, idx: number) {
|
||||
if (item.kind === 'sample-group') return `group-${item.group.groupKey}`
|
||||
return item.row.id || `standalone-${idx}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -133,7 +210,8 @@
|
||||
padding: 16px;
|
||||
background: #f1f5f9;
|
||||
|
||||
:deep(.qc-sample-row) {
|
||||
:deep(.qc-sample-row),
|
||||
:deep(.qc-protocol-row) {
|
||||
box-shadow:
|
||||
0 1px 3px rgba(15, 23, 42, 0.06),
|
||||
0 1px 2px rgba(15, 23, 42, 0.04);
|
||||
|
||||
@@ -0,0 +1,568 @@
|
||||
<!-- 质检工单 — 检测批次配置(Tab + 左右分栏选项目) -->
|
||||
<template>
|
||||
<div class="qc-batch-config">
|
||||
<div class="qc-batch-config__toolbar">
|
||||
<span class="hint-muted">按批次配置检测项目与负责人;批次内项目不可重复,不同批次可重复同一项目。</span>
|
||||
<div class="qc-batch-config__toolbar-actions">
|
||||
<el-button v-if="batches.length > 1" class="btn-ghost" type="danger" @click="removeActiveBatch">
|
||||
<el-icon><Delete /></el-icon>删除当前批次
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="addBatch">
|
||||
<el-icon><Plus /></el-icon>添加批次
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!batches.length" class="qc-batch-config__empty hint-muted">请添加至少一个检测批次</div>
|
||||
|
||||
<el-tabs
|
||||
v-else
|
||||
v-model="activeTabKey"
|
||||
class="panel-pill-tabs panel-pill-tabs--start qc-batch-config__tabs"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="(batch, index) in batches"
|
||||
:key="tabKey(batch, index)"
|
||||
:name="tabKey(batch, index)"
|
||||
:label="batchTabLabel(batch, index)"
|
||||
>
|
||||
<div class="form-grid-2 qc-batch-config__head-row">
|
||||
<el-form-item label="批次名称">
|
||||
<el-input v-model="batch.batchName" placeholder="如 20260625检测" clearable maxlength="200" />
|
||||
</el-form-item>
|
||||
<el-form-item label="批次负责人">
|
||||
<el-select
|
||||
v-model="batch.assigneeUserIds"
|
||||
multiple
|
||||
filterable
|
||||
placeholder="选择负责人(可多选)"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="u in userOptions"
|
||||
:key="u.value"
|
||||
:label="u.label"
|
||||
:value="u.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<div class="qc-config-split">
|
||||
<div class="qc-config-split__panel">
|
||||
<div class="qc-config-split__title">实验室自检项目</div>
|
||||
<div class="qc-config-split__body">
|
||||
<el-checkbox-group
|
||||
v-model="batch.labItemIds"
|
||||
class="qc-config-check-group qc-config-check-group--single"
|
||||
@change="syncBatchFlags(batch)"
|
||||
>
|
||||
<el-checkbox v-for="item in labOptions" :key="item.id" :value="item.id">
|
||||
{{ item.itemName }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
<p v-if="!labOptions.length" class="hint-muted">暂无启用的实验室项目</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="qc-config-split__panel">
|
||||
<div class="qc-config-split__title">第三方检测项目</div>
|
||||
<div class="qc-config-split__body qc-config-split__body--third">
|
||||
<template v-if="thirdOptionsGrouped.length">
|
||||
<div class="qc-config-third-split">
|
||||
<div class="qc-config-third-split__companies">
|
||||
<button
|
||||
v-for="group in thirdOptionsGrouped"
|
||||
:key="group.companyId"
|
||||
type="button"
|
||||
class="qc-config-third-split__company"
|
||||
:class="{ 'is-active': selectedCompanyId(index) === group.companyId }"
|
||||
@click="setSelectedCompany(index, group.companyId)"
|
||||
>
|
||||
{{ group.companyName || '未命名公司' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="qc-config-third-split__items">
|
||||
<template v-if="activeThirdGroup(index)">
|
||||
<el-checkbox-group
|
||||
v-model="batch.thirdPartyItemIds"
|
||||
class="qc-config-check-group qc-config-check-group--single"
|
||||
@change="syncBatchFlags(batch)"
|
||||
>
|
||||
<el-checkbox
|
||||
v-for="item in activeThirdGroup(index)!.items"
|
||||
:key="item.id"
|
||||
:value="item.id"
|
||||
>
|
||||
{{ item.itemName }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
<p v-if="!activeThirdGroup(index)!.items.length" class="hint-muted">
|
||||
该公司暂无检测项目
|
||||
</p>
|
||||
</template>
|
||||
<p v-else class="hint-muted">请选择左侧第三方公司</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="hint-muted">暂无启用的第三方项目</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="qc-batch-config__selected">
|
||||
<div class="qc-batch-config__selected-head">
|
||||
<span class="qc-batch-config__selected-title">已选项目</span>
|
||||
<span class="qc-batch-config__selected-count">
|
||||
共 {{ batchSelectedCount(batch) }} 项
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="batchSelectedCount(batch)" class="qc-batch-config__selected-body">
|
||||
<div v-if="selectedLabItems(batch).length" class="qc-batch-config__selected-group">
|
||||
<span class="qc-batch-config__selected-label">实验室自检</span>
|
||||
<div class="qc-batch-config__selected-tags">
|
||||
<el-tag
|
||||
v-for="item in selectedLabItems(batch)"
|
||||
:key="'sel-lab-' + item.id"
|
||||
type="success"
|
||||
size="small"
|
||||
closable
|
||||
@close="removeLabItem(batch, item.id)"
|
||||
>
|
||||
{{ item.itemName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="selectedThirdGroups(batch).length" class="qc-batch-config__selected-third">
|
||||
<span class="qc-batch-config__selected-label">第三方检测</span>
|
||||
<div class="qc-batch-config__selected-third-groups">
|
||||
<div
|
||||
v-for="group in selectedThirdGroups(batch)"
|
||||
:key="'sel-company-' + group.companyId"
|
||||
class="qc-batch-config__selected-company"
|
||||
>
|
||||
<span class="qc-batch-config__selected-company-name">{{
|
||||
group.companyName || '未命名公司'
|
||||
}}</span>
|
||||
<div class="qc-batch-config__selected-tags">
|
||||
<el-tag
|
||||
v-for="item in group.items"
|
||||
:key="'sel-third-' + item.id"
|
||||
type="primary"
|
||||
size="small"
|
||||
closable
|
||||
@close="removeThirdItem(batch, item.id)"
|
||||
>
|
||||
{{ item.itemName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="qc-batch-config__selected-empty hint-muted">暂未选择检测项目</p>
|
||||
</section>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { Delete, Plus } from '@element-plus/icons-vue'
|
||||
import type { QcInspectionBatchConfigureItem } from '@/utils/qc-inspection-batch'
|
||||
import { createEmptyInspectionBatch } from '@/utils/qc-inspection-batch'
|
||||
|
||||
type LabOption = { id: string; itemName: string; itemCode: string }
|
||||
type ThirdOption = {
|
||||
id: string
|
||||
itemName: string
|
||||
itemCode: string
|
||||
companyId?: string
|
||||
companyName?: string
|
||||
}
|
||||
type ThirdGroup = { companyId: string; companyName: string; items: ThirdOption[] }
|
||||
type UserOption = { label: string; value: string }
|
||||
|
||||
const batches = defineModel<QcInspectionBatchConfigureItem[]>('batches', { required: true })
|
||||
|
||||
const props = defineProps<{
|
||||
labOptions: LabOption[]
|
||||
thirdOptions: ThirdOption[]
|
||||
thirdOptionsGrouped: ThirdGroup[]
|
||||
userOptions: UserOption[]
|
||||
}>()
|
||||
|
||||
const activeTabKey = ref('')
|
||||
const selectedCompanyByIndex = ref<Record<number, string>>({})
|
||||
|
||||
function tabKey(batch: QcInspectionBatchConfigureItem, index: number) {
|
||||
return batch.id || `new-${index}`
|
||||
}
|
||||
|
||||
function batchTabLabel(batch: QcInspectionBatchConfigureItem, index: number) {
|
||||
const name = (batch.batchName || '').trim()
|
||||
return name || `批次 ${index + 1}`
|
||||
}
|
||||
|
||||
function ensureActiveTab() {
|
||||
if (!batches.value.length) {
|
||||
activeTabKey.value = ''
|
||||
return
|
||||
}
|
||||
const keys = batches.value.map((b, i) => tabKey(b, i))
|
||||
if (!keys.includes(activeTabKey.value)) {
|
||||
activeTabKey.value = keys[keys.length - 1]
|
||||
}
|
||||
}
|
||||
|
||||
function ensureCompanySelection(index: number) {
|
||||
const groups = props.thirdOptionsGrouped
|
||||
if (!groups.length) {
|
||||
selectedCompanyByIndex.value[index] = ''
|
||||
return
|
||||
}
|
||||
const current = selectedCompanyByIndex.value[index]
|
||||
if (!current || !groups.some((g) => g.companyId === current)) {
|
||||
selectedCompanyByIndex.value[index] = groups[0].companyId
|
||||
}
|
||||
}
|
||||
|
||||
function selectedCompanyId(index: number) {
|
||||
ensureCompanySelection(index)
|
||||
return selectedCompanyByIndex.value[index] || ''
|
||||
}
|
||||
|
||||
function setSelectedCompany(index: number, companyId: string) {
|
||||
selectedCompanyByIndex.value[index] = companyId
|
||||
}
|
||||
|
||||
function activeThirdGroup(index: number) {
|
||||
const cid = selectedCompanyId(index)
|
||||
if (!cid) return null
|
||||
return props.thirdOptionsGrouped.find((g) => g.companyId === cid) || null
|
||||
}
|
||||
|
||||
function syncBatchFlags(batch: QcInspectionBatchConfigureItem) {
|
||||
batch.hasLab = batch.labItemIds.length > 0
|
||||
batch.hasThirdParty = batch.thirdPartyItemIds.length > 0
|
||||
}
|
||||
|
||||
function selectedLabItems(batch: QcInspectionBatchConfigureItem) {
|
||||
return batch.labItemIds
|
||||
.map((id) => props.labOptions.find((o) => o.id === id))
|
||||
.filter((item): item is LabOption => !!item)
|
||||
}
|
||||
|
||||
function selectedThirdGroups(batch: QcInspectionBatchConfigureItem) {
|
||||
const selectedSet = new Set(batch.thirdPartyItemIds)
|
||||
return props.thirdOptionsGrouped
|
||||
.map((group) => ({
|
||||
companyId: group.companyId,
|
||||
companyName: group.companyName,
|
||||
items: group.items.filter((item) => selectedSet.has(item.id))
|
||||
}))
|
||||
.filter((group) => group.items.length > 0)
|
||||
}
|
||||
|
||||
function batchSelectedCount(batch: QcInspectionBatchConfigureItem) {
|
||||
return batch.labItemIds.length + batch.thirdPartyItemIds.length
|
||||
}
|
||||
|
||||
function removeLabItem(batch: QcInspectionBatchConfigureItem, itemId: string) {
|
||||
batch.labItemIds = batch.labItemIds.filter((id) => id !== itemId)
|
||||
syncBatchFlags(batch)
|
||||
}
|
||||
|
||||
function removeThirdItem(batch: QcInspectionBatchConfigureItem, itemId: string) {
|
||||
batch.thirdPartyItemIds = batch.thirdPartyItemIds.filter((id) => id !== itemId)
|
||||
syncBatchFlags(batch)
|
||||
}
|
||||
|
||||
function suggestNextBatchName() {
|
||||
const today = new Date()
|
||||
const y = today.getFullYear()
|
||||
const m = String(today.getMonth() + 1).padStart(2, '0')
|
||||
const d = String(today.getDate()).padStart(2, '0')
|
||||
const base = `${y}${m}${d}检测`
|
||||
const used = new Set(batches.value.map((b) => (b.batchName || '').trim()))
|
||||
if (!used.has(base)) return base
|
||||
let n = 2
|
||||
while (used.has(`${base}-${n}`)) n += 1
|
||||
return `${base}-${n}`
|
||||
}
|
||||
|
||||
function addBatch() {
|
||||
batches.value.push({
|
||||
...createEmptyInspectionBatch(),
|
||||
batchName: suggestNextBatchName()
|
||||
})
|
||||
const idx = batches.value.length - 1
|
||||
ensureCompanySelection(idx)
|
||||
activeTabKey.value = tabKey(batches.value[idx], idx)
|
||||
}
|
||||
|
||||
function removeActiveBatch() {
|
||||
const idx = batches.value.findIndex((b, i) => tabKey(b, i) === activeTabKey.value)
|
||||
if (idx < 0 || batches.value.length <= 1) return
|
||||
batches.value.splice(idx, 1)
|
||||
const next: Record<number, string> = {}
|
||||
batches.value.forEach((_, i) => {
|
||||
const oldIdx = i >= idx ? i + 1 : i
|
||||
if (selectedCompanyByIndex.value[oldIdx]) {
|
||||
next[i] = selectedCompanyByIndex.value[oldIdx]
|
||||
}
|
||||
})
|
||||
selectedCompanyByIndex.value = next
|
||||
ensureActiveTab()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => batches.value.length,
|
||||
() => {
|
||||
batches.value.forEach((_, i) => ensureCompanySelection(i))
|
||||
ensureActiveTab()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.thirdOptionsGrouped,
|
||||
() => {
|
||||
batches.value.forEach((_, i) => ensureCompanySelection(i))
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.qc-batch-config__toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.qc-batch-config__toolbar-actions {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.qc-batch-config__empty {
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
border: 1px dashed var(--el-border-color);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.qc-batch-config__tabs.panel-pill-tabs.el-tabs > :deep(.el-tabs__header) {
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
|
||||
.qc-batch-config__head-row {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.qc-config-split {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 16px;
|
||||
min-height: 360px;
|
||||
}
|
||||
|
||||
.qc-config-split__panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.qc-config-split__title {
|
||||
flex-shrink: 0;
|
||||
padding: 10px 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
background: #f8fafc;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.qc-config-split__body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 12px 14px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.qc-config-split__body--third {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.qc-config-third-split {
|
||||
display: grid;
|
||||
grid-template-columns: 168px minmax(0, 1fr);
|
||||
min-height: 320px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.qc-config-third-split__companies {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 10px 8px;
|
||||
border-right: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.qc-config-third-split__company {
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
text-align: left;
|
||||
color: #334155;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background 0.15s,
|
||||
color 0.15s;
|
||||
|
||||
&:hover:not(.is-active) {
|
||||
background: #ecfdf5;
|
||||
color: #065f46;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background: var(--primary-bg, #ecfdf5);
|
||||
color: var(--primary-dark, #059669);
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.qc-config-third-split__items {
|
||||
min-width: 0;
|
||||
padding: 12px 14px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.qc-config-check-group {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected {
|
||||
margin-top: 16px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 4px;
|
||||
height: 12px;
|
||||
margin-right: 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--primary-dark, #059669);
|
||||
vertical-align: -1px;
|
||||
}
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-count {
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: 8px 12px;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-third {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: 8px 12px;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-third-groups {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-company {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: 8px 10px;
|
||||
padding: 8px 10px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-company-name {
|
||||
flex-shrink: 0;
|
||||
min-width: 72px;
|
||||
padding-top: 2px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-label {
|
||||
flex-shrink: 0;
|
||||
min-width: 72px;
|
||||
padding-top: 2px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-tags {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.qc-batch-config__selected-empty {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,463 @@
|
||||
<!-- 质检工单 · 同协议多样本分组(协议组头 + 样本 Tab + SampleGroup) -->
|
||||
<template>
|
||||
<article class="qc-protocol-row">
|
||||
<div
|
||||
class="qc-protocol-row__ctx"
|
||||
:class="{ 'qc-protocol-row__ctx--has-sample-tabs': group.sampleGroups.length > 1 }"
|
||||
>
|
||||
<div class="qc-protocol-row__ctx-left">
|
||||
<span class="qc-protocol-row__idx">{{ groupIndex }}</span>
|
||||
<span class="qc-protocol-row__code">{{ group.protocolNo || '—' }}</span>
|
||||
<el-tag v-if="protocolStatus.label" :type="protocolStatus.tagType" size="small">
|
||||
{{ protocolStatus.label }}
|
||||
</el-tag>
|
||||
<span class="qc-protocol-row__sub">
|
||||
{{ sampleCountLabel }}
|
||||
<template v-if="progressLabel"> · {{ progressLabel }}</template>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="group.sampleGroups.length > 1"
|
||||
class="qc-protocol-row__ctx-center qc-protocol-sample-tabs"
|
||||
role="tablist"
|
||||
aria-label="同协议样本"
|
||||
>
|
||||
<button
|
||||
v-for="(sampleGroup, tabIndex) in group.sampleGroups"
|
||||
:key="sampleTabKey(sampleGroup)"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="qc-wo-indep-tabs__btn qc-wo-indep-tabs__btn--reception"
|
||||
:class="{ 'is-active': sampleTabKey(sampleGroup) === activeSampleKey }"
|
||||
:aria-selected="sampleTabKey(sampleGroup) === activeSampleKey"
|
||||
@click="activeSampleKey = sampleTabKey(sampleGroup)"
|
||||
>
|
||||
<span class="qc-wo-tab__index">{{ tabIndex + 1 }}</span>
|
||||
<span class="qc-wo-tab__no">{{ sampleGroup.sampleCode || '—' }}</span>
|
||||
<span
|
||||
v-if="sampleTypeLabel(sampleGroup)"
|
||||
class="qc-wo-tab__source qc-wo-tab__source--reception"
|
||||
>
|
||||
{{ sampleTypeLabel(sampleGroup) }}
|
||||
</span>
|
||||
<el-tag
|
||||
v-if="gateWorkOrder(sampleGroup)"
|
||||
:type="sampleTabStatusTagType(sampleGroup)"
|
||||
size="small"
|
||||
class="qc-wo-tab__status"
|
||||
>
|
||||
{{ sampleTabStatusLabel(sampleGroup) }}
|
||||
</el-tag>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="qc-protocol-row__ctx-right">
|
||||
<span v-if="group.workOrders.length > 1" class="qc-protocol-row__badge">
|
||||
{{ group.workOrders.length }} 条质检
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<QcWorkOrderProtocolPaymentPanel
|
||||
v-if="protocolPaymentSummary"
|
||||
:summary="protocolPaymentSummary"
|
||||
compact
|
||||
class="qc-protocol-row__fee"
|
||||
/>
|
||||
|
||||
<QcWorkOrderSampleGroup
|
||||
v-if="activeSampleGroup"
|
||||
:group="activeSampleGroup"
|
||||
:group-index="groupIndex"
|
||||
:card-meta-config="cardMetaConfig"
|
||||
:task-refresh-token="taskRefreshToken"
|
||||
:show-work-order-ops="showWorkOrderOps"
|
||||
:show-work-order-view-only="showWorkOrderViewOnly"
|
||||
:task-list-mode="taskListMode"
|
||||
:preset-tasks-by-work-order-id="presetTasksByWorkOrderId"
|
||||
hide-context-bar
|
||||
:hide-protocol-fee-summary="!!protocolPaymentSummary"
|
||||
@configure="(row) => emit('configure', row)"
|
||||
@view="(row) => emit('view', row)"
|
||||
@command="(cmd, row) => emit('command', cmd, row)"
|
||||
@tasks-changed="emit('tasks-changed')"
|
||||
/>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import type { QcWorkOrder } from '@/api/qc-work-order'
|
||||
import type { QcTask } from '@/api/qc-task'
|
||||
import { workOrderStatusLabel } from '@/utils/qc-labels'
|
||||
import type { TagType } from '@/utils/status-tag-registry'
|
||||
import {
|
||||
type QcWorkOrderProtocolGroupModel,
|
||||
type QcWorkOrderSampleGroupModel,
|
||||
resolveGateWorkOrderForSampleGroup
|
||||
} from '@/utils/qc-work-order-groups'
|
||||
import type { QcWorkOrderCardMetaConfig } from '@/utils/qc-work-order-card-meta'
|
||||
import {
|
||||
buildProtocolGroupProgressLabel,
|
||||
resolveProtocolGroupPaymentSummary,
|
||||
resolveProtocolGroupStatus
|
||||
} from '@/utils/qc-work-order-card-meta'
|
||||
import QcWorkOrderSampleGroup from './QcWorkOrderSampleGroup.vue'
|
||||
import QcWorkOrderProtocolPaymentPanel from './QcWorkOrderProtocolPaymentPanel.vue'
|
||||
|
||||
defineOptions({ name: 'QcWorkOrderProtocolGroup' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
group: QcWorkOrderProtocolGroupModel
|
||||
groupIndex: number
|
||||
cardMetaConfig: QcWorkOrderCardMetaConfig
|
||||
taskRefreshToken: number
|
||||
showWorkOrderOps?: boolean
|
||||
showWorkOrderViewOnly?: boolean
|
||||
taskListMode?: 'workOrder' | 'mine'
|
||||
presetTasksByWorkOrderId?: Record<string, QcTask[]>
|
||||
}>(),
|
||||
{
|
||||
showWorkOrderOps: true,
|
||||
showWorkOrderViewOnly: false,
|
||||
taskListMode: 'workOrder'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
configure: [row: QcWorkOrder]
|
||||
view: [row: QcWorkOrder]
|
||||
command: [cmd: string, row: QcWorkOrder]
|
||||
'tasks-changed': []
|
||||
}>()
|
||||
|
||||
function sampleTabKey(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||||
return sampleGroup.groupKey
|
||||
}
|
||||
|
||||
const activeSampleKey = ref(
|
||||
props.group.sampleGroups[0] ? sampleTabKey(props.group.sampleGroups[0]) : ''
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.group.sampleGroups.map((g) => sampleTabKey(g)).join(','),
|
||||
() => {
|
||||
const keys = props.group.sampleGroups.map((g) => sampleTabKey(g))
|
||||
if (!keys.includes(activeSampleKey.value)) {
|
||||
activeSampleKey.value = keys[0] || ''
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const activeSampleGroup = computed(() =>
|
||||
props.group.sampleGroups.find((g) => sampleTabKey(g) === activeSampleKey.value)
|
||||
)
|
||||
|
||||
const gateRow = computed(() =>
|
||||
resolveGateWorkOrderForSampleGroup(
|
||||
props.group.sampleGroups[0]?.workOrders || props.group.workOrders
|
||||
)
|
||||
)
|
||||
|
||||
const protocolStatus = computed(() =>
|
||||
gateRow.value
|
||||
? resolveProtocolGroupStatus(gateRow.value)
|
||||
: { label: '', tagType: 'info' as TagType }
|
||||
)
|
||||
|
||||
const sampleCountLabel = computed(() => `${props.group.sampleGroups.length} 个样本`)
|
||||
|
||||
const progressLabel = computed(() => buildProtocolGroupProgressLabel(props.group))
|
||||
|
||||
const protocolPaymentSummary = computed(() => resolveProtocolGroupPaymentSummary(props.group))
|
||||
|
||||
function sampleTypeLabel(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||||
const gate = resolveGateWorkOrderForSampleGroup(sampleGroup.workOrders)
|
||||
return (gate?.sampleTypeName || sampleGroup.workOrders[0]?.sampleTypeName || '').trim()
|
||||
}
|
||||
|
||||
function gateWorkOrder(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||||
return resolveGateWorkOrderForSampleGroup(sampleGroup.workOrders)
|
||||
}
|
||||
|
||||
function sampleTabStatusLabel(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||||
const gate = gateWorkOrder(sampleGroup)
|
||||
return gate ? workOrderStatusLabel(gate.workOrderStatus) : ''
|
||||
}
|
||||
|
||||
function sampleTabStatusTagType(sampleGroup: QcWorkOrderSampleGroupModel): TagType {
|
||||
const gate = gateWorkOrder(sampleGroup)
|
||||
return gate ? workOrderStatusTagType(gate.workOrderStatus) : 'info'
|
||||
}
|
||||
|
||||
function workOrderStatusTagType(status: string): TagType {
|
||||
if (status === 'ywc') return 'success'
|
||||
if (status === 'ypz') return 'warning'
|
||||
if (status === 'yzf') return 'danger'
|
||||
return 'info'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.qc-protocol-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
transition:
|
||||
border-color 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: #a8d4c4;
|
||||
box-shadow: 0 2px 8px rgba(4, 120, 87, 0.08);
|
||||
}
|
||||
}
|
||||
|
||||
.qc-protocol-row__ctx {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 12px 16px;
|
||||
padding: 12px 16px;
|
||||
background: linear-gradient(180deg, var(--primary-bg, #ecfdf5) 0%, #fff 100%);
|
||||
border-bottom: 1px solid #d1fae5;
|
||||
}
|
||||
|
||||
.qc-protocol-row__ctx--has-sample-tabs {
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.qc-protocol-row__ctx-left {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
min-width: 0;
|
||||
justify-self: start;
|
||||
}
|
||||
|
||||
.qc-protocol-row__ctx-center {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px 24px;
|
||||
min-width: 0;
|
||||
justify-self: center;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.qc-protocol-row__ctx-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
min-width: 0;
|
||||
justify-self: end;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.qc-protocol-row__ctx,
|
||||
.qc-protocol-row__ctx--has-sample-tabs {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.qc-protocol-row__ctx-center {
|
||||
justify-self: stretch;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.qc-protocol-row__ctx-right {
|
||||
justify-self: start;
|
||||
}
|
||||
}
|
||||
|
||||
.qc-protocol-row__idx {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
min-width: 20px;
|
||||
}
|
||||
|
||||
.qc-protocol-row__code {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
|
||||
.qc-protocol-row__sub {
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.qc-protocol-row__badge {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
background: var(--primary-bg, #ecfdf5);
|
||||
color: #047857;
|
||||
border: 1px solid #d1fae5;
|
||||
}
|
||||
|
||||
.qc-protocol-row__fee {
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.qc-wo-indep-tabs__btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
min-height: 34px;
|
||||
padding: 8px 16px;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
font-size: 12px;
|
||||
color: #1e293b;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
|
||||
transition:
|
||||
background 0.15s ease,
|
||||
color 0.15s ease,
|
||||
border-color 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid #10b981;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
&:not(.is-active) {
|
||||
.qc-wo-tab__index {
|
||||
color: #1e293b;
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
.qc-wo-tab__source--reception,
|
||||
.qc-wo-tab__source--schedule {
|
||||
color: #047857;
|
||||
background: #ecfdf5;
|
||||
}
|
||||
|
||||
.qc-wo-tab__no {
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.qc-wo-tab__status.el-tag,
|
||||
.qc-wo-tab__status.el-tag.el-tag--success,
|
||||
.qc-wo-tab__status.el-tag.el-tag--warning,
|
||||
.qc-wo-tab__status.el-tag.el-tag--danger,
|
||||
.qc-wo-tab__status.el-tag.el-tag--info {
|
||||
--el-tag-text-color: #1e293b;
|
||||
--el-tag-bg-color: #f1f5f9;
|
||||
--el-tag-border-color: #e2e8f0;
|
||||
color: #1e293b;
|
||||
background-color: #f1f5f9;
|
||||
border-color: #e2e8f0;
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.is-active):hover {
|
||||
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
|
||||
}
|
||||
|
||||
&--reception:not(.is-active) {
|
||||
border-color: #a7f3d0;
|
||||
|
||||
&:hover {
|
||||
border-color: #047857;
|
||||
background: #ecfdf5;
|
||||
}
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
color: #fff;
|
||||
background: var(--primary, #10b981);
|
||||
border-color: var(--primary, #10b981);
|
||||
box-shadow: 0 2px 6px rgba(16, 185, 129, 0.28);
|
||||
|
||||
.qc-wo-tab__index {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 28%);
|
||||
}
|
||||
|
||||
.qc-wo-tab__source,
|
||||
.qc-wo-tab__source--reception,
|
||||
.qc-wo-tab__source--schedule {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 22%);
|
||||
}
|
||||
|
||||
.qc-wo-tab__no {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.qc-wo-tab__status.el-tag,
|
||||
.qc-wo-tab__status.el-tag.el-tag--success,
|
||||
.qc-wo-tab__status.el-tag.el-tag--warning,
|
||||
.qc-wo-tab__status.el-tag.el-tag--danger,
|
||||
.qc-wo-tab__status.el-tag.el-tag--info {
|
||||
--el-tag-text-color: #fff;
|
||||
--el-tag-bg-color: rgb(255 255 255 / 22%);
|
||||
--el-tag-border-color: rgb(255 255 255 / 35%);
|
||||
color: #fff;
|
||||
background-color: rgb(255 255 255 / 22%);
|
||||
border-color: rgb(255 255 255 / 35%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.qc-wo-tab__index {
|
||||
flex-shrink: 0;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.qc-wo-tab__source {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.qc-wo-tab__no {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
|
||||
.qc-wo-tab__status {
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.qc-protocol-row :deep(.qc-sample-row) {
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.qc-protocol-row :deep(.qc-sample-row:hover) {
|
||||
border-color: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<!-- 质检工单 · 同样本分组(上下文条 + Tab + 单工单卡片) -->
|
||||
<template>
|
||||
<article class="qc-sample-row">
|
||||
<div class="qc-sample-row__ctx">
|
||||
<div v-if="!hideContextBar" class="qc-sample-row__ctx">
|
||||
<span class="qc-sample-row__idx">{{ groupIndex }}</span>
|
||||
<span class="qc-sample-row__code">{{ group.groupTitle || group.sampleCode || '—' }}</span>
|
||||
<span class="qc-sample-row__sub">{{ contextSubtitle }}</span>
|
||||
@@ -33,7 +33,7 @@
|
||||
<span class="qc-wo-tab__dot"></span>
|
||||
{{ triggerSourceTabLabel(wo) }}
|
||||
</span>
|
||||
<span class="qc-wo-tab__no">{{ wo.workOrderNo }}</span>
|
||||
<span class="qc-wo-tab__no">{{ workOrderTabTitle(wo) }}</span>
|
||||
<el-tag
|
||||
:type="workOrderStatusTagType(wo.workOrderStatus)"
|
||||
size="small"
|
||||
@@ -55,6 +55,7 @@
|
||||
:show-work-order-view-only="showWorkOrderViewOnly"
|
||||
:task-list-mode="taskListMode"
|
||||
:preset-tasks="activePresetTasks"
|
||||
:hide-protocol-fee-summary="hideProtocolFeeSummary"
|
||||
@configure="(row) => emit('configure', row)"
|
||||
@view="(row) => emit('view', row)"
|
||||
@command="(cmd, row) => emit('command', cmd, row)"
|
||||
@@ -75,7 +76,8 @@
|
||||
isGateTriggerSource
|
||||
} from '@/utils/qc-work-order-groups'
|
||||
import type { QcWorkOrderCardMetaConfig } from '@/utils/qc-work-order-card-meta'
|
||||
import { buildGroupContextSubtitle } from '@/utils/qc-work-order-card-meta'
|
||||
import { buildGroupContextSubtitle, cardMetaUsesInboundGroups, resolveInboundWorkOrderCardTitle } from '@/utils/qc-work-order-card-meta'
|
||||
import { resolveEffectiveRowTabKey } from '@/utils/qc-work-order-tabs'
|
||||
import QcWorkOrderSingleCard from './QcWorkOrderSingleCard.vue'
|
||||
|
||||
defineOptions({ name: 'QcWorkOrderSampleGroup' })
|
||||
@@ -90,11 +92,15 @@
|
||||
showWorkOrderViewOnly?: boolean
|
||||
taskListMode?: 'workOrder' | 'mine'
|
||||
presetTasksByWorkOrderId?: Record<string, QcTask[]>
|
||||
hideContextBar?: boolean
|
||||
hideProtocolFeeSummary?: boolean
|
||||
}>(),
|
||||
{
|
||||
showWorkOrderOps: true,
|
||||
showWorkOrderViewOnly: false,
|
||||
taskListMode: 'workOrder'
|
||||
taskListMode: 'workOrder',
|
||||
hideContextBar: false,
|
||||
hideProtocolFeeSummary: false
|
||||
}
|
||||
)
|
||||
|
||||
@@ -150,9 +156,18 @@
|
||||
const contextSubtitle = computed(() => {
|
||||
const row = contextRow.value
|
||||
if (!row) return '—'
|
||||
return buildGroupContextSubtitle(row, props.cardMetaConfig.tabKey)
|
||||
const tabKey = resolveEffectiveRowTabKey(props.cardMetaConfig.tabKey, row)
|
||||
return buildGroupContextSubtitle(row, tabKey)
|
||||
})
|
||||
|
||||
function workOrderTabTitle(wo: QcWorkOrder) {
|
||||
const tabKey = resolveEffectiveRowTabKey(props.cardMetaConfig.tabKey, wo)
|
||||
if (cardMetaUsesInboundGroups(tabKey)) {
|
||||
return resolveInboundWorkOrderCardTitle(wo)
|
||||
}
|
||||
return wo.workOrderNo || '—'
|
||||
}
|
||||
|
||||
function workOrderStatusTagType(status: string): TagType {
|
||||
if (status === 'ywc') return 'success'
|
||||
if (status === 'ypz') return 'warning'
|
||||
|
||||
@@ -6,12 +6,19 @@
|
||||
<div class="qc-work-order-card__head-main">
|
||||
<div class="qc-work-order-card__title-row">
|
||||
<span v-if="cardIndex != null" class="qc-work-order-card__index">{{ cardIndex }}</span>
|
||||
<span class="qc-work-order-card__no">{{ row.workOrderNo || '—' }}</span>
|
||||
<span class="qc-work-order-card__no">{{ cardTitle }}</span>
|
||||
<el-tag
|
||||
v-if="effectiveCardMeta.showCategoryTag"
|
||||
:type="qcWorkOrderCategoryTagType(row)"
|
||||
size="small"
|
||||
>
|
||||
{{ qcWorkOrderCategoryLabel(row) }}
|
||||
</el-tag>
|
||||
<el-tag :type="workOrderStatusTagType(row.workOrderStatus)" size="small">
|
||||
{{ workOrderStatusLabel(row.workOrderStatus) }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="cardMetaConfig.showTriggerTag"
|
||||
v-if="effectiveCardMeta.showTriggerTag"
|
||||
:type="resolveTriggerTagType(row)"
|
||||
size="small"
|
||||
>
|
||||
@@ -42,10 +49,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</dl>
|
||||
<section
|
||||
v-if="showCellProductSection(row)"
|
||||
class="qc-work-order-card__cells"
|
||||
>
|
||||
<section v-if="showCellProductSection(row)" class="qc-work-order-card__cells">
|
||||
<template v-if="isScheduleTrigger(row)">
|
||||
<div v-if="scheduleCellProducts(row).length" class="qc-work-order-card__cell-list">
|
||||
<div
|
||||
@@ -113,10 +117,7 @@
|
||||
</template>
|
||||
</section>
|
||||
</div>
|
||||
<div
|
||||
v-if="showWorkOrderOps || showWorkOrderViewOnly"
|
||||
class="qc-work-order-card__ops"
|
||||
>
|
||||
<div v-if="showWorkOrderOps || showWorkOrderViewOnly" class="qc-work-order-card__ops">
|
||||
<template v-if="showWorkOrderViewOnly">
|
||||
<el-button class="btn-op-item primary" type="primary" @click="emit('view', row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
@@ -177,7 +178,7 @@
|
||||
/>
|
||||
</header>
|
||||
<section class="qc-work-order-card__tasks">
|
||||
<QcWorkOrderTaskSubList
|
||||
<QcWorkOrderBatchSubList
|
||||
embedded
|
||||
:work-order="row"
|
||||
:list-mode="taskListMode"
|
||||
@@ -197,9 +198,23 @@
|
||||
import { workOrderStatusLabel } from '@/utils/qc-labels'
|
||||
import type { TagType } from '@/utils/status-tag-registry'
|
||||
import { productStatusLabel, productStatusTagType } from '@/utils/status-tag-registry'
|
||||
import {
|
||||
cardMetaUsesInboundGroups,
|
||||
resolveInboundWorkOrderCardTitle,
|
||||
resolveCardMetaForRow
|
||||
} from '@/utils/qc-work-order-card-meta'
|
||||
import type { QcWorkOrderCardMetaConfig } from '@/utils/qc-work-order-card-meta'
|
||||
import { triggerSourceTabLabel, temporaryQcSourceLabel, temporaryQcSourceTagType } from '@/utils/qc-work-order-groups'
|
||||
import QcWorkOrderTaskSubList from './QcWorkOrderTaskSubList.vue'
|
||||
import {
|
||||
qcWorkOrderCategoryLabel,
|
||||
qcWorkOrderCategoryTagType
|
||||
} from '@/utils/qc-work-order-category'
|
||||
import { resolveEffectiveRowTabKey } from '@/utils/qc-work-order-tabs'
|
||||
import {
|
||||
triggerSourceTabLabel,
|
||||
temporaryQcSourceLabel,
|
||||
temporaryQcSourceTagType
|
||||
} from '@/utils/qc-work-order-groups'
|
||||
import QcWorkOrderBatchSubList from './QcWorkOrderBatchSubList.vue'
|
||||
import QcWorkOrderFeeSummaryBar from './QcWorkOrderFeeSummaryBar.vue'
|
||||
import QcWorkOrderProtocolPaymentPanel from './QcWorkOrderProtocolPaymentPanel.vue'
|
||||
|
||||
@@ -218,11 +233,13 @@
|
||||
showWorkOrderViewOnly?: boolean
|
||||
presetTasks?: QcTask[]
|
||||
taskListMode?: 'workOrder' | 'mine'
|
||||
hideProtocolFeeSummary?: boolean
|
||||
}>(),
|
||||
{
|
||||
showWorkOrderOps: true,
|
||||
showWorkOrderViewOnly: false,
|
||||
taskListMode: 'workOrder'
|
||||
taskListMode: 'workOrder',
|
||||
hideProtocolFeeSummary: false
|
||||
}
|
||||
)
|
||||
|
||||
@@ -233,16 +250,34 @@
|
||||
'tasks-changed': []
|
||||
}>()
|
||||
|
||||
const visibleMetaFields = computed(() =>
|
||||
props.cardMetaConfig.metaFields.filter((field) => !field.visible || field.visible(props.row))
|
||||
const effectiveCardMeta = computed(() =>
|
||||
resolveCardMetaForRow(props.row, props.cardMetaConfig.tabKey)
|
||||
)
|
||||
|
||||
const effectiveRowTabKey = computed(() =>
|
||||
resolveEffectiveRowTabKey(props.cardMetaConfig.tabKey, props.row)
|
||||
)
|
||||
|
||||
const visibleMetaFields = computed(() =>
|
||||
effectiveCardMeta.value.metaFields.filter((field) => !field.visible || field.visible(props.row))
|
||||
)
|
||||
|
||||
const cardTitle = computed(() => {
|
||||
if (cardMetaUsesInboundGroups(effectiveRowTabKey.value)) {
|
||||
return resolveInboundWorkOrderCardTitle(props.row)
|
||||
}
|
||||
return props.row.workOrderNo || '—'
|
||||
})
|
||||
|
||||
const showProtocolFeeSummary = computed(
|
||||
() => props.cardMetaConfig.showProtocolFeeSummary && !!props.row.paymentSummary
|
||||
() =>
|
||||
!props.hideProtocolFeeSummary &&
|
||||
effectiveCardMeta.value.showProtocolFeeSummary &&
|
||||
!!props.row.paymentSummary
|
||||
)
|
||||
|
||||
const showOutboundFeeSummary = computed(
|
||||
() => props.cardMetaConfig.showOutboundFeeSummary && !!props.row.feeSummary
|
||||
() => effectiveCardMeta.value.showOutboundFeeSummary && !!props.row.feeSummary
|
||||
)
|
||||
|
||||
function triggerSourceTagType(source?: string): TagType {
|
||||
@@ -253,7 +288,7 @@
|
||||
}
|
||||
|
||||
function showCellProductSection(row: QcWorkOrder) {
|
||||
if (!props.cardMetaConfig.showCellProducts) return false
|
||||
if (!effectiveCardMeta.value.showCellProducts) return false
|
||||
const ts = row.triggerSource || ''
|
||||
return ts === 'schedule' || ts === 'production'
|
||||
}
|
||||
@@ -282,14 +317,14 @@
|
||||
}
|
||||
|
||||
function resolveTriggerTagLabel(row: QcWorkOrder) {
|
||||
if (props.cardMetaConfig.tabKey === 'temporary') {
|
||||
if (effectiveRowTabKey.value === 'temporary') {
|
||||
return temporaryQcSourceLabel(row)
|
||||
}
|
||||
return row.triggerSourceLabel || triggerSourceTabLabel(row)
|
||||
}
|
||||
|
||||
function resolveTriggerTagType(row: QcWorkOrder): TagType {
|
||||
if (props.cardMetaConfig.tabKey === 'temporary') {
|
||||
if (effectiveRowTabKey.value === 'temporary') {
|
||||
return temporaryQcSourceTagType(row)
|
||||
}
|
||||
return triggerSourceTagType(row.triggerSource)
|
||||
@@ -307,19 +342,19 @@
|
||||
}
|
||||
|
||||
function canEditTemporaryWorkOrder() {
|
||||
return props.cardMetaConfig.allowEditTemporary
|
||||
return effectiveCardMeta.value.allowEditTemporary
|
||||
}
|
||||
|
||||
function canEditRemarkWorkOrder(row: QcWorkOrder) {
|
||||
if (!props.cardMetaConfig.allowEditRemark) return false
|
||||
if (props.cardMetaConfig.tabKey.startsWith('outbound_')) {
|
||||
if (!effectiveCardMeta.value.allowEditRemark) return false
|
||||
if (effectiveRowTabKey.value.startsWith('outbound_')) {
|
||||
return row.workOrderStatus !== 'ywc' && row.workOrderStatus !== 'yzf'
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function canDeleteWorkOrder(row: QcWorkOrder) {
|
||||
if (!props.cardMetaConfig.allowDelete) return false
|
||||
if (!effectiveCardMeta.value.allowDelete) return false
|
||||
return row.workOrderStatus !== 'ywc'
|
||||
}
|
||||
|
||||
@@ -529,8 +564,13 @@
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.qc-work-order-card__tasks :deep(.qc-work-order-task-sublist) {
|
||||
.qc-work-order-card__tasks :deep(.qc-work-order-batch-sublist--embedded) {
|
||||
padding: 10px 14px 12px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.qc-work-order-card__tasks :deep(.qc-work-order-task-sublist) {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
<!-- 质检工单 Tab 栏(含未完成数量角标) -->
|
||||
<template>
|
||||
<div class="panel-pill-tabs panel-pill-tabs--lg">
|
||||
<div class="panel-pill-tabs__track" role="tablist">
|
||||
<button
|
||||
v-for="tab in QC_WORK_ORDER_VISIBLE_TABS"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="panel-pill-tabs__btn"
|
||||
:class="{ 'is-active': activeTabKey === tab.key }"
|
||||
:aria-selected="activeTabKey === tab.key"
|
||||
@click="emit('change', tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<span
|
||||
class="panel-pill-tabs__badge"
|
||||
:class="{ 'panel-pill-tabs__badge--zero': getTabCount(tab.key) === 0 }"
|
||||
>
|
||||
{{ formatQcWorkOrderTabBadgeCount(getTabCount(tab.key)) }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { formatQcWorkOrderTabBadgeCount } from '@/api/qc-work-order'
|
||||
import { QC_WORK_ORDER_VISIBLE_TABS, type QcWorkOrderTabKey } from '@/utils/qc-work-order-tabs'
|
||||
import {
|
||||
useQcWorkOrderTabUnfinishedCounts,
|
||||
type QcWorkOrderTabCountScope
|
||||
} from './composables/useQcWorkOrderTabUnfinishedCounts'
|
||||
|
||||
defineOptions({ name: 'QcWorkOrderTabBar' })
|
||||
|
||||
const props = defineProps<{
|
||||
activeTabKey: QcWorkOrderTabKey
|
||||
scope: QcWorkOrderTabCountScope
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
change: [key: QcWorkOrderTabKey]
|
||||
}>()
|
||||
|
||||
const { getTabCount, loadTabCounts } = useQcWorkOrderTabUnfinishedCounts(props.scope)
|
||||
|
||||
defineExpose({
|
||||
reload: loadTabCounts
|
||||
})
|
||||
</script>
|
||||
+19
-10
@@ -1,7 +1,7 @@
|
||||
<!-- 质检工单查看弹窗 — 实验室 / 第三方项目卡片面板 -->
|
||||
<template>
|
||||
<div class="qc-wo-task-result-panel">
|
||||
<template v-if="!tasks.length && configuredItems.length">
|
||||
<template v-if="!displayTasks.length && configuredItems.length">
|
||||
<div class="qc-wo-configured-list">
|
||||
<article
|
||||
v-for="(item, idx) in configuredItems"
|
||||
@@ -16,11 +16,11 @@
|
||||
<p class="qc-wo-task-result-panel__hint">已配置检测项目,任务待派发</p>
|
||||
</template>
|
||||
|
||||
<div v-else-if="tasks.length" class="qc-wo-task-cards">
|
||||
<article v-for="(task, idx) in tasks" :key="task.id || idx" class="qc-wo-task-card">
|
||||
<div v-else-if="displayTasks.length" class="qc-wo-task-cards">
|
||||
<article v-for="(task, idx) in displayTasks" :key="task.id || idx" class="qc-wo-task-card">
|
||||
<header class="qc-wo-task-card__head">
|
||||
<div class="qc-wo-task-card__title">
|
||||
<span v-if="tasks.length > 1" class="qc-wo-task-card__index">{{ idx + 1 }}</span>
|
||||
<span v-if="displayTasks.length > 1" class="qc-wo-task-card__index">{{ idx + 1 }}</span>
|
||||
<span class="qc-wo-task-card__name">{{ task.itemName || '—' }}</span>
|
||||
<span v-if="task.itemCode" class="qc-wo-task-card__code">{{ task.itemCode }}</span>
|
||||
</div>
|
||||
@@ -45,11 +45,14 @@
|
||||
<dt>任务号</dt>
|
||||
<dd>{{ task.taskNo || '—' }}</dd>
|
||||
</div>
|
||||
<div v-if="taskType === 'dsfjc'" class="qc-wo-task-card__meta-item">
|
||||
<div v-if="task.taskType === 'dsfjc'" class="qc-wo-task-card__meta-item">
|
||||
<dt>第三方公司</dt>
|
||||
<dd>{{ task.companyName || '—' }}</dd>
|
||||
</div>
|
||||
<div v-if="taskType === 'dsfjc' && task.feeAmount != null" class="qc-wo-task-card__meta-item">
|
||||
<div
|
||||
v-if="task.taskType === 'dsfjc' && task.feeAmount != null"
|
||||
class="qc-wo-task-card__meta-item"
|
||||
>
|
||||
<dt>费用(元)</dt>
|
||||
<dd>¥{{ formatMoneyDisplay(task.feeAmount) }}</dd>
|
||||
</div>
|
||||
@@ -80,7 +83,7 @@
|
||||
<p class="qc-wo-task-card__remark">{{ task.remark }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="taskType === 'sysz' && showMaterialUsage" class="qc-wo-task-card__block">
|
||||
<div v-if="task.taskType === 'sysz' && showMaterialUsage" class="qc-wo-task-card__block">
|
||||
<div class="qc-wo-task-card__block-label">物料使用</div>
|
||||
<div v-if="task.materialUsages?.length" class="view-subtable-wrap">
|
||||
<el-table :data="task.materialUsages" stripe class="list-table view-subtable">
|
||||
@@ -129,7 +132,9 @@
|
||||
</div>
|
||||
|
||||
<div class="qc-wo-task-card__block">
|
||||
<div class="qc-wo-task-card__block-label">{{ attachmentLabel }}</div>
|
||||
<div class="qc-wo-task-card__block-label">{{
|
||||
task.taskType === 'dsfjc' ? '检测材料' : '检测附件'
|
||||
}}</div>
|
||||
<ProtocolAttachmentReadonly
|
||||
v-if="task.attachmentFiles?.length"
|
||||
:files="task.attachmentFiles"
|
||||
@@ -165,7 +170,7 @@
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
taskType: 'sysz' | 'dsfjc'
|
||||
taskType?: 'sysz' | 'dsfjc'
|
||||
tasks: QcWorkOrderTaskView[]
|
||||
labItems?: QcWorkOrderDetail['labItems']
|
||||
thirdPartyItems?: QcWorkOrderDetail['thirdPartyItems']
|
||||
@@ -173,9 +178,13 @@
|
||||
|
||||
const showMaterialUsage = SHOW_QC_TASK_MATERIAL_USAGE
|
||||
|
||||
const attachmentLabel = computed(() => (props.taskType === 'dsfjc' ? '检测材料' : '检测附件'))
|
||||
const displayTasks = computed(() => {
|
||||
if (!props.taskType) return props.tasks
|
||||
return props.tasks.filter((t) => t.taskType === props.taskType)
|
||||
})
|
||||
|
||||
const configuredItems = computed<ConfiguredItem[]>(() => {
|
||||
if (!props.taskType) return []
|
||||
if (props.taskType === 'sysz') {
|
||||
return (props.labItems || []).map((li) => ({
|
||||
primary: li.itemName || '—',
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
@dblclick="handleView(row)"
|
||||
>
|
||||
<div class="qc-task-card__line qc-task-card__line--top">
|
||||
<span class="qc-task-card__name">{{ row.itemName || row.taskNo || '—' }}</span>
|
||||
<span class="qc-task-card__name">{{ row.itemName || '—' }}</span>
|
||||
<div class="qc-task-card__tags">
|
||||
<el-tag :type="taskStatusTagType(row.taskStatus)" size="small">
|
||||
{{ taskStatusLabel(row.taskStatus) }}
|
||||
@@ -51,8 +51,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="qc-task-card__line qc-task-card__line--bottom">
|
||||
<span class="qc-task-card__code">{{ row.taskNo || '—' }}</span>
|
||||
<span class="qc-task-card__sep">·</span>
|
||||
<span class="qc-task-card__assignees">{{
|
||||
row.assigneeUserNames || '—'
|
||||
}}</span>
|
||||
@@ -167,13 +165,33 @@
|
||||
placeholder="请输入"
|
||||
/>
|
||||
<el-input-number
|
||||
v-else
|
||||
v-else-if="param.paramType === 'number'"
|
||||
:model-value="toResultNumber(param.paramValue)"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
placeholder="请输入"
|
||||
@update:model-value="(v) => setResultNumber(param, v)"
|
||||
/>
|
||||
<el-select
|
||||
v-else-if="param.paramType === 'select'"
|
||||
v-model="param.paramValue"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in parseQcParamOptions(param.options)"
|
||||
:key="opt"
|
||||
:label="opt"
|
||||
:value="opt"
|
||||
/>
|
||||
</el-select>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="param.paramValue"
|
||||
placeholder="请输入"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
@@ -513,6 +531,7 @@
|
||||
} from '@/api/qc-material-usage'
|
||||
import { fetchItemUnitList } from '@/api/admin'
|
||||
import { SHOW_QC_TASK_MATERIAL_USAGE } from '@/utils/qc-material-ui'
|
||||
import { parseQcParamOptions } from '@/utils/qc-item-param-options'
|
||||
import {
|
||||
taskTypeLabel,
|
||||
taskTypeTagType,
|
||||
@@ -1246,7 +1265,7 @@
|
||||
resultTaskId.value = row.id
|
||||
resultTaskType.value = row.taskType
|
||||
resultRemark.value = row.remark || ''
|
||||
resultConclusion.value = ''
|
||||
resultConclusion.value = 'tg'
|
||||
resultAttachments.value = apiFilesToFinanceItems(row.attachmentFiles)
|
||||
materialUsages.value = []
|
||||
requisitionOptions.value = []
|
||||
@@ -1255,7 +1274,7 @@
|
||||
const detail = await fetchQcTaskDetail(row.id)
|
||||
resultTaskStatus.value = detail.taskStatus || row.taskStatus
|
||||
resultRemark.value = detail.remark || row.remark || ''
|
||||
resultConclusion.value = detail.conclusion || ''
|
||||
resultConclusion.value = detail.conclusion || 'tg'
|
||||
resultAttachments.value = apiFilesToFinanceItems(detail.attachmentFiles)
|
||||
const results = await fetchQcTaskResults(row.id)
|
||||
resultParams.value = normalizeResultParams(results || [])
|
||||
@@ -1286,6 +1305,12 @@
|
||||
ElMessage.warning('请选择检测结论')
|
||||
return
|
||||
}
|
||||
for (const p of resultParams.value) {
|
||||
if (p.requiredFlag === '1' && !hasResultValue(p.paramValue)) {
|
||||
ElMessage.warning(`请填写参数「${p.paramName}」`)
|
||||
return
|
||||
}
|
||||
}
|
||||
if (
|
||||
resultTaskType.value === 'dsfjc' &&
|
||||
!financeAttachmentsToUrlString(resultAttachments.value)
|
||||
@@ -1421,19 +1446,14 @@
|
||||
|
||||
.qc-task-cards-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.qc-task-cards-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
grid-template-columns: repeat(auto-fill, minmax(196px, 220px));
|
||||
gap: 8px;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.qc-task-cards-grid {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1533,12 +1553,13 @@
|
||||
}
|
||||
|
||||
&--compact {
|
||||
min-height: 68px;
|
||||
min-height: 60px;
|
||||
height: auto;
|
||||
flex: unset;
|
||||
width: auto;
|
||||
max-width: none;
|
||||
gap: 5px;
|
||||
padding: 7px 10px;
|
||||
width: 100%;
|
||||
max-width: 220px;
|
||||
gap: 4px;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1554,6 +1575,12 @@
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.qc-task-card--compact &--top {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
&--bottom {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 4px;
|
||||
@@ -1567,9 +1594,19 @@
|
||||
}
|
||||
|
||||
.qc-task-card--compact .qc-task-card__name {
|
||||
width: 100%;
|
||||
min-height: auto;
|
||||
-webkit-line-clamp: 1;
|
||||
flex: 1;
|
||||
flex: none;
|
||||
display: block;
|
||||
overflow: visible;
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.qc-task-card--compact .qc-task-card__tags {
|
||||
flex-wrap: wrap;
|
||||
overflow: visible;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.qc-task-card--compact .qc-task-card__assignees {
|
||||
@@ -1583,15 +1620,10 @@
|
||||
|
||||
.qc-task-card__name {
|
||||
min-width: 0;
|
||||
min-height: 36px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
line-height: 1.35;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -17,6 +17,7 @@ import {
|
||||
appendTaskResultSections,
|
||||
type QcWorkOrderTaskView
|
||||
} from './useQcWorkOrderTaskViewSections'
|
||||
import type { QcInspectionBatch } from '@/utils/qc-inspection-batch'
|
||||
import {
|
||||
isTemporaryQcFromProduction,
|
||||
temporaryQcSourceLabel,
|
||||
@@ -129,7 +130,8 @@ function buildInboundBasicSection(
|
||||
/** 采集入库:含协议缴费 */
|
||||
export function buildInboundCellStorageViewSections(
|
||||
detail: QcWorkOrderDetail,
|
||||
tasks: QcWorkOrderTaskView[]
|
||||
tasks: QcWorkOrderTaskView[],
|
||||
batches?: QcInspectionBatch[] | null
|
||||
): ViewSection[] {
|
||||
const r = detail.reception || {}
|
||||
const statusLabel = protocolStatusLabel(String(detail.protocolStatus || ''))
|
||||
@@ -139,14 +141,15 @@ export function buildInboundCellStorageViewSections(
|
||||
...buildTransportSection(r),
|
||||
{ title: '协议缴费信息', fields: [], slot: 'protocol-payment-details' },
|
||||
...buildReceptionSection(detail),
|
||||
...appendTaskResultSections(detail, tasks)
|
||||
...appendTaskResultSections(detail, tasks, batches)
|
||||
]
|
||||
}
|
||||
|
||||
/** 捐赠入库:无协议缴费;协议状态字段展示捐赠状态 */
|
||||
export function buildInboundResearchDonationViewSections(
|
||||
detail: QcWorkOrderDetail,
|
||||
tasks: QcWorkOrderTaskView[]
|
||||
tasks: QcWorkOrderTaskView[],
|
||||
batches?: QcInspectionBatch[] | null
|
||||
): ViewSection[] {
|
||||
const r = detail.reception || {}
|
||||
const statusLabel = donationStatusLabel(String(detail.protocolStatus || ''))
|
||||
@@ -155,14 +158,15 @@ export function buildInboundResearchDonationViewSections(
|
||||
buildInboundBasicSection(detail, '捐赠状态', statusLabel, statusTag),
|
||||
...buildTransportSection(r),
|
||||
...buildReceptionSection(detail),
|
||||
...appendTaskResultSections(detail, tasks)
|
||||
...appendTaskResultSections(detail, tasks, batches)
|
||||
]
|
||||
}
|
||||
|
||||
/** 临时工单:仅产品 + 任务 */
|
||||
export function buildTemporaryViewSections(
|
||||
detail: QcWorkOrderDetail,
|
||||
tasks: QcWorkOrderTaskView[]
|
||||
tasks: QcWorkOrderTaskView[],
|
||||
batches?: QcInspectionBatch[] | null
|
||||
): ViewSection[] {
|
||||
const basicFields: ViewSection['fields'] = [
|
||||
{ label: '工单号', value: detail.workOrderNo },
|
||||
@@ -208,6 +212,6 @@ export function buildTemporaryViewSections(
|
||||
title: '基本信息',
|
||||
fields: basicFields
|
||||
},
|
||||
...appendTaskResultSections(detail, tasks)
|
||||
...appendTaskResultSections(detail, tasks, batches)
|
||||
]
|
||||
}
|
||||
+16
-3
@@ -1,6 +1,7 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { fetchQcWorkOrderDetail, type QcWorkOrderDetail } from '@/api/qc-work-order'
|
||||
import type { ViewSection } from '@/components/business/system-view-dialog/index.vue'
|
||||
import { loadQcInspectionBatches, type QcInspectionBatch } from '@/utils/qc-inspection-batch'
|
||||
import {
|
||||
loadEnrichedQcWorkOrderTasks,
|
||||
type QcWorkOrderTaskView
|
||||
@@ -12,15 +13,20 @@ import {
|
||||
} from './useQcViewAttachmentHelpers'
|
||||
|
||||
export function useInboundQcViewDialog(
|
||||
buildSections: (detail: QcWorkOrderDetail, tasks: QcWorkOrderTaskView[]) => ViewSection[]
|
||||
buildSections: (
|
||||
detail: QcWorkOrderDetail,
|
||||
tasks: QcWorkOrderTaskView[],
|
||||
batches?: QcInspectionBatch[] | null
|
||||
) => ViewSection[]
|
||||
) {
|
||||
const loading = ref(false)
|
||||
const detail = ref<QcWorkOrderDetail | null>(null)
|
||||
const viewTasks = ref<QcWorkOrderTaskView[]>([])
|
||||
const viewBatches = ref<QcInspectionBatch[]>([])
|
||||
|
||||
const sections = computed(() => {
|
||||
if (!detail.value) return []
|
||||
return buildSections(detail.value, viewTasks.value)
|
||||
return buildSections(detail.value, viewTasks.value, viewBatches.value)
|
||||
})
|
||||
|
||||
const viewReceptionAttachmentFiles = computed(() => {
|
||||
@@ -35,11 +41,17 @@ export function useInboundQcViewDialog(
|
||||
async function load(workOrderId: string) {
|
||||
loading.value = true
|
||||
viewTasks.value = []
|
||||
viewBatches.value = []
|
||||
detail.value = null
|
||||
try {
|
||||
const d = await fetchQcWorkOrderDetail(workOrderId)
|
||||
detail.value = d
|
||||
viewTasks.value = await loadEnrichedQcWorkOrderTasks((d.tasks || []) as QcWorkOrderTaskView[])
|
||||
const [tasks, batches] = await Promise.all([
|
||||
loadEnrichedQcWorkOrderTasks((d.tasks || []) as QcWorkOrderTaskView[]),
|
||||
loadQcInspectionBatches(workOrderId, d.inspectionBatches)
|
||||
])
|
||||
viewTasks.value = tasks
|
||||
viewBatches.value = batches
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -50,6 +62,7 @@ export function useInboundQcViewDialog(
|
||||
detail,
|
||||
sections,
|
||||
viewTasks,
|
||||
viewBatches,
|
||||
viewReceptionAttachmentFiles,
|
||||
handleReceptionAttachmentPreview: qcPreviewAttachment,
|
||||
handleReceptionAttachmentDownload: qcDownloadAttachment,
|
||||
|
||||
+11
-2
@@ -13,6 +13,7 @@ import {
|
||||
type OutboundViewContextVariant
|
||||
} from '@/utils/outbound-qc-pilot-view-sections'
|
||||
import type { ViewField, ViewSection } from '@/components/business/system-view-dialog/index.vue'
|
||||
import { loadQcInspectionBatches, type QcInspectionBatch } from '@/utils/qc-inspection-batch'
|
||||
import {
|
||||
appendTaskResultSections,
|
||||
loadEnrichedQcWorkOrderTasks,
|
||||
@@ -31,6 +32,7 @@ export function useOutboundQcViewDialog(options: {
|
||||
const loading = ref(false)
|
||||
const detail = ref<OutboundQcDetail | null>(null)
|
||||
const viewTasks = ref<QcWorkOrderTaskView[]>([])
|
||||
const viewBatches = ref<QcInspectionBatch[]>([])
|
||||
|
||||
const diagnosisAttachmentFiles = computed(() => {
|
||||
const urls = detail.value?.patient?.diagnosisAttachments || ''
|
||||
@@ -126,19 +128,25 @@ export function useOutboundQcViewDialog(options: {
|
||||
})
|
||||
}
|
||||
|
||||
result.push(...appendTaskResultSections(wo, viewTasks.value))
|
||||
result.push(...appendTaskResultSections(wo, viewTasks.value, viewBatches.value))
|
||||
return result
|
||||
})
|
||||
|
||||
async function load(workOrderId: string) {
|
||||
loading.value = true
|
||||
viewTasks.value = []
|
||||
viewBatches.value = []
|
||||
detail.value = null
|
||||
try {
|
||||
const d = await fetchOutboundQcDetail(workOrderId)
|
||||
detail.value = d
|
||||
const rawTasks = (d.workOrder?.tasks || d.tasks || []) as QcWorkOrderTaskView[]
|
||||
viewTasks.value = await loadEnrichedQcWorkOrderTasks(rawTasks)
|
||||
const [tasks, batches] = await Promise.all([
|
||||
loadEnrichedQcWorkOrderTasks(rawTasks),
|
||||
loadQcInspectionBatches(workOrderId, d.inspectionBatches || d.workOrder?.inspectionBatches)
|
||||
])
|
||||
viewTasks.value = tasks
|
||||
viewBatches.value = batches
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -150,6 +158,7 @@ export function useOutboundQcViewDialog(options: {
|
||||
detail,
|
||||
sections,
|
||||
viewTasks,
|
||||
viewBatches,
|
||||
diagnosisAttachmentFiles,
|
||||
handlePreview: qcPreviewAttachment,
|
||||
handleDownload: qcDownloadAttachment,
|
||||
|
||||
+42
-21
@@ -16,11 +16,15 @@ import {
|
||||
keywordPlaceholderForTab,
|
||||
filterTimeLabelForTab,
|
||||
filterTimeHintForTab,
|
||||
isAllQcWorkOrderTab,
|
||||
resolveTabKeyFromWorkOrder,
|
||||
type QcWorkOrderTabKey
|
||||
} from '@/utils/qc-work-order-tabs'
|
||||
import { toAllTabListQuery } from '@/utils/qc-work-order-category'
|
||||
import { getCardMetaConfig } from '@/utils/qc-work-order-card-meta'
|
||||
|
||||
function shouldApplyTriggerSourceFilter(tabKey: QcWorkOrderTabKey, tabLayout: string) {
|
||||
if (isAllQcWorkOrderTab(tabKey)) return true
|
||||
return tabLayout !== 'standalone' || tabKey === 'temporary'
|
||||
}
|
||||
|
||||
@@ -37,12 +41,17 @@ export function useQcWorkOrderTabPage(
|
||||
const filterTimeLabel = computed(() => filterTimeLabelForTab(tabConfig.value))
|
||||
const filterTimeHint = computed(() => {
|
||||
if (pageModeValue.value === 'mine') {
|
||||
return '仅展示指派给当前登录人的质检任务。'
|
||||
const base = '仅展示指派给当前登录人的质检任务。'
|
||||
if (isAllQcWorkOrderTab(tabKey.value)) {
|
||||
return `${base}出库工单按输注/交付时间筛选请进入对应分类 Tab。`
|
||||
}
|
||||
return base
|
||||
}
|
||||
return filterTimeHintForTab(tabConfig.value)
|
||||
})
|
||||
|
||||
const searchForm = reactive({
|
||||
qcCategory: '',
|
||||
keyword: '',
|
||||
workOrderStatus: '',
|
||||
triggerSource: '',
|
||||
@@ -54,26 +63,29 @@ export function useQcWorkOrderTabPage(
|
||||
const tableData = ref<QcWorkOrder[]>([])
|
||||
const presetTasksByWorkOrderId = ref<Record<string, QcTask[]>>({})
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
const pagination = reactive({ page: 1, pageSize: 100, total: 0 })
|
||||
const taskSubListRefreshToken = ref(0)
|
||||
|
||||
const viewVisible = ref(false)
|
||||
const viewWorkOrderId = ref('')
|
||||
const viewTabKey = ref<QcWorkOrderTabKey>(tabKey.value)
|
||||
|
||||
function buildMineWorkOrderSearchFilters() {
|
||||
const tab = tabConfig.value
|
||||
const timeParams = tabUsesInfusionTimeFilter(tab)
|
||||
? {
|
||||
infusionTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
infusionTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
}
|
||||
: {
|
||||
createTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
createTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
}
|
||||
const timeParams =
|
||||
isAllQcWorkOrderTab(tabKey.value) || !tabUsesInfusionTimeFilter(tab)
|
||||
? {
|
||||
createTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
createTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
}
|
||||
: {
|
||||
infusionTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
infusionTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
}
|
||||
return {
|
||||
keyword: searchForm.keyword || undefined,
|
||||
workOrderStatus: searchForm.workOrderStatus || undefined,
|
||||
qcCategory: searchForm.qcCategory || undefined,
|
||||
triggerSource:
|
||||
shouldApplyTriggerSourceFilter(tabKey.value, tab.listLayout) && searchForm.triggerSource
|
||||
? searchForm.triggerSource
|
||||
@@ -105,15 +117,19 @@ export function useQcWorkOrderTabPage(
|
||||
}
|
||||
|
||||
const tab = tabConfig.value
|
||||
const timeParams = tabUsesInfusionTimeFilter(tab)
|
||||
? {
|
||||
infusionTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
infusionTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
}
|
||||
: {
|
||||
createTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
createTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
}
|
||||
const timeParams =
|
||||
isAllQcWorkOrderTab(tabKey.value) || !tabUsesInfusionTimeFilter(tab)
|
||||
? {
|
||||
createTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
createTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
}
|
||||
: {
|
||||
infusionTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
infusionTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
}
|
||||
const listQuery = isAllQcWorkOrderTab(tabKey.value)
|
||||
? toAllTabListQuery(searchForm.qcCategory)
|
||||
: toWorkOrderListQuery(tab)
|
||||
const res = await fetchQcWorkOrderList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
@@ -123,7 +139,7 @@ export function useQcWorkOrderTabPage(
|
||||
shouldApplyTriggerSourceFilter(tabKey.value, tab.listLayout) && searchForm.triggerSource
|
||||
? searchForm.triggerSource
|
||||
: undefined,
|
||||
...toWorkOrderListQuery(tab),
|
||||
...listQuery,
|
||||
...timeParams
|
||||
})
|
||||
tableData.value = res.list || []
|
||||
@@ -139,6 +155,7 @@ export function useQcWorkOrderTabPage(
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.qcCategory = ''
|
||||
searchForm.keyword = ''
|
||||
searchForm.workOrderStatus = ''
|
||||
searchForm.triggerSource = ''
|
||||
@@ -167,6 +184,9 @@ export function useQcWorkOrderTabPage(
|
||||
}
|
||||
|
||||
function handleView(row: QcWorkOrder) {
|
||||
viewTabKey.value = isAllQcWorkOrderTab(tabKey.value)
|
||||
? resolveTabKeyFromWorkOrder(row)
|
||||
: tabKey.value
|
||||
viewWorkOrderId.value = row.id
|
||||
viewVisible.value = true
|
||||
}
|
||||
@@ -210,6 +230,7 @@ export function useQcWorkOrderTabPage(
|
||||
taskSubListRefreshToken,
|
||||
viewVisible,
|
||||
viewWorkOrderId,
|
||||
viewTabKey,
|
||||
loadData,
|
||||
handleSearch,
|
||||
handleReset,
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import {
|
||||
fetchQcWorkOrderTabUnfinishedCounts,
|
||||
fetchMineQcWorkOrderTabUnfinishedCounts,
|
||||
type QcWorkOrderTabUnfinishedCounts
|
||||
} from '@/api/qc-work-order'
|
||||
import { QC_WORK_ORDER_VISIBLE_TABS, type QcWorkOrderTabKey } from '@/utils/qc-work-order-tabs'
|
||||
|
||||
export type QcWorkOrderTabCountScope = 'manage' | 'mine'
|
||||
|
||||
function emptyTabCounts(): QcWorkOrderTabUnfinishedCounts {
|
||||
const counts = {} as QcWorkOrderTabUnfinishedCounts
|
||||
for (const tab of QC_WORK_ORDER_VISIBLE_TABS) {
|
||||
counts[tab.key] = 0
|
||||
}
|
||||
return counts
|
||||
}
|
||||
|
||||
export function useQcWorkOrderTabUnfinishedCounts(scope: QcWorkOrderTabCountScope) {
|
||||
const tabCounts = ref<QcWorkOrderTabUnfinishedCounts>(emptyTabCounts())
|
||||
const loading = ref(false)
|
||||
|
||||
async function loadTabCounts() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data =
|
||||
scope === 'mine'
|
||||
? await fetchMineQcWorkOrderTabUnfinishedCounts()
|
||||
: await fetchQcWorkOrderTabUnfinishedCounts()
|
||||
tabCounts.value = { ...emptyTabCounts(), ...(data || {}) }
|
||||
} catch {
|
||||
tabCounts.value = emptyTabCounts()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getTabCount(tabKey: QcWorkOrderTabKey): number {
|
||||
return tabCounts.value[tabKey] ?? 0
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadTabCounts()
|
||||
})
|
||||
|
||||
return {
|
||||
tabCounts,
|
||||
loading,
|
||||
loadTabCounts,
|
||||
getTabCount
|
||||
}
|
||||
}
|
||||
+40
-1
@@ -9,6 +9,11 @@ import {
|
||||
} from '@/api/qc-task-result'
|
||||
import { SHOW_QC_TASK_MATERIAL_USAGE } from '@/utils/qc-material-ui'
|
||||
import type { ViewSection } from '@/components/business/system-view-dialog/index.vue'
|
||||
import {
|
||||
batchTasksPanelSlot,
|
||||
resolveBatchSections,
|
||||
type QcInspectionBatch
|
||||
} from '@/utils/qc-inspection-batch'
|
||||
|
||||
export type ViewMaterialUsageRow = {
|
||||
stockInNo: string
|
||||
@@ -36,6 +41,10 @@ export function taskMaterialSlotName(taskId: string) {
|
||||
export const LAB_TASKS_PANEL_SLOT = 'lab-tasks-panel'
|
||||
export const THIRD_TASKS_PANEL_SLOT = 'third-tasks-panel'
|
||||
|
||||
export function isBatchTaskPanelSlot(slot?: string) {
|
||||
return !!slot && (slot.startsWith('batch-tasks-') || slot === LAB_TASKS_PANEL_SLOT || slot === THIRD_TASKS_PANEL_SLOT)
|
||||
}
|
||||
|
||||
export type QcTaskPanelContext = Pick<
|
||||
QcWorkOrderDetail,
|
||||
'hasLab' | 'hasThirdParty' | 'labItems' | 'thirdPartyItems'
|
||||
@@ -92,8 +101,27 @@ function buildConfiguredOnlySection(
|
||||
|
||||
export function appendTaskResultSections(
|
||||
detail: QcTaskPanelContext,
|
||||
tasks: QcWorkOrderTaskView[]
|
||||
tasks: QcWorkOrderTaskView[],
|
||||
batches?: QcInspectionBatch[] | null
|
||||
): ViewSection[] {
|
||||
const batchSections = resolveBatchSections(batches, tasks)
|
||||
if (batchSections.length) {
|
||||
return batchSections.map((section) => ({
|
||||
title: `检测批次 · ${section.batchName}`,
|
||||
fields: [
|
||||
...(section.batchNo ? [{ label: '批次编号', value: section.batchNo }] : []),
|
||||
...(section.assigneeUserNames
|
||||
? [{ label: '负责人', value: section.assigneeUserNames }]
|
||||
: []),
|
||||
{
|
||||
label: '进度',
|
||||
value: `${section.completedTaskCount}/${section.taskCount} 已完成`
|
||||
}
|
||||
],
|
||||
slot: batchTasksPanelSlot(section.key)
|
||||
}))
|
||||
}
|
||||
|
||||
const result: ViewSection[] = []
|
||||
const hasLabTasks = tasks.some((t) => t.taskType === 'sysz')
|
||||
const hasThirdTasks = tasks.some((t) => t.taskType === 'dsfjc')
|
||||
@@ -107,6 +135,17 @@ export function appendTaskResultSections(
|
||||
return result
|
||||
}
|
||||
|
||||
export function batchTasksForPanelSlot(
|
||||
slot: string | undefined,
|
||||
batches: QcInspectionBatch[] | null | undefined,
|
||||
tasks: QcWorkOrderTaskView[]
|
||||
): QcWorkOrderTaskView[] {
|
||||
if (!slot?.startsWith('batch-tasks-')) return []
|
||||
const batchKey = slot.slice('batch-tasks-'.length)
|
||||
const section = resolveBatchSections(batches, tasks).find((s) => s.key === batchKey)
|
||||
return (section?.tasks || []) as QcWorkOrderTaskView[]
|
||||
}
|
||||
|
||||
export function useQcWorkOrderTaskSlotHelpers(viewTasks: Ref<QcWorkOrderTaskView[]>) {
|
||||
const labTasks = computed(() => viewTasks.value.filter((t) => t.taskType === 'sysz'))
|
||||
const thirdPartyTasks = computed(() => viewTasks.value.filter((t) => t.taskType === 'dsfjc'))
|
||||
|
||||
@@ -3,22 +3,12 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-pill-tabs panel-pill-tabs--lg">
|
||||
<div class="panel-pill-tabs__track" role="tablist">
|
||||
<button
|
||||
v-for="tab in QC_WORK_ORDER_VISIBLE_TABS"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="panel-pill-tabs__btn"
|
||||
:class="{ 'is-active': activeTabKey === tab.key }"
|
||||
:aria-selected="activeTabKey === tab.key"
|
||||
@click="handleTabChange(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<QcWorkOrderTabBar
|
||||
ref="tabBarRef"
|
||||
:active-tab-key="activeTabKey"
|
||||
scope="manage"
|
||||
@change="handleTabChange"
|
||||
/>
|
||||
|
||||
<QcWorkOrderTabPanel
|
||||
ref="activeTabRef"
|
||||
@@ -29,6 +19,7 @@
|
||||
@command="handleDropdownCommand"
|
||||
@add-inbound="handleAddInbound"
|
||||
@add-temporary="handleAddTemporary"
|
||||
@data-changed="reloadTabCounts"
|
||||
/>
|
||||
|
||||
<el-dialog
|
||||
@@ -43,132 +34,13 @@
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form label-position="top" class="biz-dialog-form">
|
||||
<el-form-item label="检测方式">
|
||||
<el-checkbox v-model="configureForm.hasLab">实验室自检</el-checkbox>
|
||||
<el-checkbox v-model="configureForm.hasThirdParty" style="margin-left: 16px"
|
||||
>第三方检测</el-checkbox
|
||||
>
|
||||
</el-form-item>
|
||||
|
||||
<div class="qc-config-split">
|
||||
<div class="qc-config-split__panel qc-config-split__panel--items">
|
||||
<div class="qc-config-split__title">检测项目</div>
|
||||
<div class="qc-config-split__body">
|
||||
<template v-if="configureForm.hasLab">
|
||||
<div class="qc-config-split__section-label">实验室自检</div>
|
||||
<el-checkbox-group
|
||||
v-model="configureForm.labItemIds"
|
||||
class="qc-config-check-group qc-config-check-group--single"
|
||||
>
|
||||
<el-checkbox v-for="item in labOptions" :key="item.id" :value="item.id"
|
||||
>{{ item.itemName }}({{ item.itemCode }})</el-checkbox
|
||||
>
|
||||
</el-checkbox-group>
|
||||
<p v-if="!labOptions.length" class="hint-muted">暂无启用的实验室项目</p>
|
||||
</template>
|
||||
<template v-if="configureForm.hasThirdParty">
|
||||
<div
|
||||
class="qc-config-split__section-label"
|
||||
:class="{ 'qc-config-split__section-label--spaced': configureForm.hasLab }"
|
||||
>第三方检测</div
|
||||
>
|
||||
<el-checkbox-group
|
||||
v-model="configureForm.thirdPartyItemIds"
|
||||
class="qc-config-check-group qc-config-check-group--single"
|
||||
>
|
||||
<div
|
||||
v-for="group in thirdOptionsGrouped"
|
||||
:key="group.companyId"
|
||||
class="qc-company-group"
|
||||
>
|
||||
<div class="qc-company-group-title">{{ group.companyName }}</div>
|
||||
<div class="qc-company-group-items qc-company-group-items--single">
|
||||
<el-checkbox v-for="item in group.items" :key="item.id" :value="item.id">
|
||||
{{ item.itemName }}({{ item.itemCode }})¥{{
|
||||
formatMoneyDisplay(item.feeAmount)
|
||||
}}
|
||||
</el-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</el-checkbox-group>
|
||||
<p v-if="!thirdOptions.length" class="hint-muted">暂无启用的第三方项目</p>
|
||||
</template>
|
||||
<p
|
||||
v-if="!configureForm.hasLab && !configureForm.hasThirdParty"
|
||||
class="hint-muted qc-config-split__empty"
|
||||
>请先勾选上方检测方式</p
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="qc-config-split__panel qc-config-split__panel--assignees">
|
||||
<div class="qc-config-split__title">负责人配置</div>
|
||||
<div class="qc-config-split__body">
|
||||
<template v-if="configureHasSelectedItems">
|
||||
<template v-if="configureForm.hasLab && configureForm.labItemIds.length">
|
||||
<div class="qc-config-split__section-label">实验室自检</div>
|
||||
<el-form-item
|
||||
v-for="lid in configureForm.labItemIds"
|
||||
:key="'lab-assignee-' + lid"
|
||||
:label="labItemAssigneeLabel(lid)"
|
||||
class="qc-config-assignee-item"
|
||||
>
|
||||
<el-select
|
||||
v-model="configureForm.labItemAssignees[lid]"
|
||||
multiple
|
||||
filterable
|
||||
placeholder="选择负责人"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="u in configureUserOptions"
|
||||
:key="u.value"
|
||||
:label="u.label"
|
||||
:value="u.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template
|
||||
v-if="configureForm.hasThirdParty && configureForm.thirdPartyItemIds.length"
|
||||
>
|
||||
<div
|
||||
class="qc-config-split__section-label"
|
||||
:class="{
|
||||
'qc-config-split__section-label--spaced':
|
||||
configureForm.hasLab && configureForm.labItemIds.length
|
||||
}"
|
||||
>第三方检测</div
|
||||
>
|
||||
<el-form-item
|
||||
v-for="tid in configureForm.thirdPartyItemIds"
|
||||
:key="'third-assignee-' + tid"
|
||||
:label="thirdItemAssigneeLabel(tid)"
|
||||
class="qc-config-assignee-item"
|
||||
>
|
||||
<el-select
|
||||
v-model="configureForm.thirdPartyItemAssignees[tid]"
|
||||
multiple
|
||||
filterable
|
||||
placeholder="选择负责人"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="u in configureUserOptions"
|
||||
:key="u.value"
|
||||
:label="u.label"
|
||||
:value="u.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</template>
|
||||
<p v-else class="hint-muted qc-config-split__empty"
|
||||
>请先在左侧勾选检测项目,再为每项指定负责人</p
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<QcWorkOrderConfigureBatches
|
||||
v-model:batches="configureBatches"
|
||||
:lab-options="labOptions"
|
||||
:third-options="thirdOptions"
|
||||
:third-options-grouped="thirdOptionsGrouped"
|
||||
:user-options="configureUserOptions"
|
||||
/>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="configureVisible = false"
|
||||
@@ -286,7 +158,6 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { ref, reactive, computed, onMounted, nextTick, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
@@ -294,24 +165,29 @@
|
||||
import { fetchQcLabTestItemsActive, type QcLabTestItem } from '@/api/qc-lab-test-item'
|
||||
import { fetchQcThirdPartyItemsActive, type QcThirdPartyItem } from '@/api/qc-third-party-item'
|
||||
import {
|
||||
fetchQcWorkOrderDetail,
|
||||
fetchConfigureQcWorkOrder,
|
||||
fetchCreateQcWorkOrder,
|
||||
fetchUpdateQcWorkOrder,
|
||||
fetchDeleteQcWorkOrder,
|
||||
type QcWorkOrder,
|
||||
type QcWorkOrderDetail
|
||||
type QcWorkOrder
|
||||
} from '@/api/qc-work-order'
|
||||
import { fetchCellProductList } from '@/api/cell-product'
|
||||
import { fetchUserOptions } from '@/api/admin'
|
||||
import WorkOrderRemarkDialog from '@/components/business/work-order-remark-dialog/index.vue'
|
||||
import QcWorkOrderTabPanel from './tabs/QcWorkOrderTabPanel.vue'
|
||||
import QcWorkOrderTabBar from './QcWorkOrderTabBar.vue'
|
||||
import QcWorkOrderConfigureBatches from './QcWorkOrderConfigureBatches.vue'
|
||||
import {
|
||||
createEmptyInspectionBatch,
|
||||
fetchQcInspectionBatches,
|
||||
type QcInspectionBatchConfigureItem
|
||||
} from '@/utils/qc-inspection-batch'
|
||||
import {
|
||||
QC_WORK_ORDER_VISIBLE_TABS,
|
||||
DEFAULT_QC_WORK_ORDER_TAB,
|
||||
parseQcWorkOrderTabKey,
|
||||
type QcWorkOrderTabKey
|
||||
} from '@/utils/qc-work-order-tabs'
|
||||
import { refreshQcMenuBadges } from '@/utils/qc-menu-badge'
|
||||
|
||||
defineOptions({ name: 'QualityInspectionQcWorkOrder' })
|
||||
|
||||
@@ -321,14 +197,25 @@
|
||||
bumpTaskRefresh: () => void
|
||||
}
|
||||
|
||||
type QcWorkOrderTabBarExpose = {
|
||||
reload: () => Promise<void>
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const activeTabRef = ref<QcWorkOrderTabPanelExpose | null>(null)
|
||||
const tabBarRef = ref<QcWorkOrderTabBarExpose | null>(null)
|
||||
|
||||
const activeTabKey = ref<QcWorkOrderTabKey>(parseQcWorkOrderTabKey(route.query.tab as string))
|
||||
|
||||
function reloadTabCounts() {
|
||||
tabBarRef.value?.reload()
|
||||
void refreshQcMenuBadges()
|
||||
}
|
||||
|
||||
async function refreshActiveTab() {
|
||||
reloadTabCounts()
|
||||
activeTabRef.value?.bumpTaskRefresh()
|
||||
await activeTabRef.value?.reload()
|
||||
}
|
||||
@@ -566,66 +453,38 @@
|
||||
return Array.from(map.values())
|
||||
})
|
||||
const configureUserOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const configureForm = reactive({
|
||||
hasLab: false,
|
||||
hasThirdParty: false,
|
||||
labItemIds: [] as string[],
|
||||
thirdPartyItemIds: [] as string[],
|
||||
labItemAssignees: {} as Record<string, string[]>,
|
||||
thirdPartyItemAssignees: {} as Record<string, string[]>
|
||||
})
|
||||
const configureBatches = ref<QcInspectionBatchConfigureItem[]>([])
|
||||
|
||||
const configureHasSelectedItems = computed(() => {
|
||||
const labCount = configureForm.hasLab ? configureForm.labItemIds.length : 0
|
||||
const thirdCount = configureForm.hasThirdParty ? configureForm.thirdPartyItemIds.length : 0
|
||||
return labCount + thirdCount > 0
|
||||
})
|
||||
|
||||
function labItemAssigneeLabel(itemId: string) {
|
||||
const item = labOptions.value.find((o) => o.id === itemId)
|
||||
return item ? item.itemName : '检测项目'
|
||||
}
|
||||
|
||||
function thirdItemAssigneeLabel(itemId: string) {
|
||||
const item = thirdOptions.value.find((o) => o.id === itemId)
|
||||
return item ? item.itemName : '检测项目'
|
||||
}
|
||||
|
||||
function resetConfigureAssignees() {
|
||||
configureForm.labItemAssignees = {}
|
||||
configureForm.thirdPartyItemAssignees = {}
|
||||
}
|
||||
|
||||
function buildConfigureAssigneesFromDetail(d: QcWorkOrderDetail) {
|
||||
resetConfigureAssignees()
|
||||
const lineAssignees: Record<string, string[]> = {}
|
||||
for (const t of d.tasks || []) {
|
||||
if (t.sourceLineId) {
|
||||
lineAssignees[t.sourceLineId] = t.assigneeUserIds || []
|
||||
}
|
||||
function validateConfigureBatches(): boolean {
|
||||
if (!configureBatches.value.length) {
|
||||
ElMessage.warning('请至少添加一个检测批次')
|
||||
return false
|
||||
}
|
||||
for (const li of d.labItems || []) {
|
||||
if (li.labTestItemId) {
|
||||
configureForm.labItemAssignees[li.labTestItemId] = lineAssignees[li.id] || []
|
||||
}
|
||||
}
|
||||
for (const ti of d.thirdPartyItems || []) {
|
||||
if (ti.thirdPartyItemId) {
|
||||
configureForm.thirdPartyItemAssignees[ti.thirdPartyItemId] = lineAssignees[ti.id] || []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateConfigureAssignees(): boolean {
|
||||
for (const id of configureForm.labItemIds) {
|
||||
if (!(configureForm.labItemAssignees[id] || []).length) {
|
||||
ElMessage.warning(`请为「${labItemAssigneeLabel(id)}」指定负责人`)
|
||||
for (let i = 0; i < configureBatches.value.length; i++) {
|
||||
const b = configureBatches.value[i]
|
||||
const label = (b.batchName || '').trim() || `批次 ${i + 1}`
|
||||
if (!(b.batchName || '').trim()) {
|
||||
ElMessage.warning(`批次 ${i + 1}:请填写批次名称`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
for (const id of configureForm.thirdPartyItemIds) {
|
||||
if (!(configureForm.thirdPartyItemAssignees[id] || []).length) {
|
||||
ElMessage.warning(`请为「${thirdItemAssigneeLabel(id)}」指定负责人`)
|
||||
const hasLab = b.labItemIds.length > 0
|
||||
const hasThird = b.thirdPartyItemIds.length > 0
|
||||
if (!hasLab && !hasThird) {
|
||||
ElMessage.warning(`${label}:请至少选择一项检测项目`)
|
||||
return false
|
||||
}
|
||||
if (!b.assigneeUserIds.length) {
|
||||
ElMessage.warning(`${label}:请指定负责人`)
|
||||
return false
|
||||
}
|
||||
const labSet = new Set(b.labItemIds)
|
||||
if (labSet.size !== b.labItemIds.length) {
|
||||
ElMessage.warning(`${label}:实验室项目不能重复`)
|
||||
return false
|
||||
}
|
||||
const thirdSet = new Set(b.thirdPartyItemIds)
|
||||
if (thirdSet.size !== b.thirdPartyItemIds.length) {
|
||||
ElMessage.warning(`${label}:第三方项目不能重复`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -639,30 +498,6 @@
|
||||
await refreshActiveTab()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => configureForm.labItemIds,
|
||||
(ids) => {
|
||||
for (const id of ids) {
|
||||
if (!configureForm.labItemAssignees[id]) {
|
||||
configureForm.labItemAssignees[id] = []
|
||||
}
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => configureForm.thirdPartyItemIds,
|
||||
(ids) => {
|
||||
for (const id of ids) {
|
||||
if (!configureForm.thirdPartyItemAssignees[id]) {
|
||||
configureForm.thirdPartyItemAssignees[id] = []
|
||||
}
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
async function handleConfigure(row: QcWorkOrder) {
|
||||
configuringId.value = row.id
|
||||
configureIsEdit.value = row.workOrderStatus !== 'dpz'
|
||||
@@ -675,33 +510,41 @@
|
||||
thirdOptions.value = thirdList || []
|
||||
configureUserOptions.value = users || []
|
||||
if (configureIsEdit.value) {
|
||||
const d = await fetchQcWorkOrderDetail(row.id)
|
||||
configureForm.hasLab = !!d.hasLab
|
||||
configureForm.hasThirdParty = !!d.hasThirdParty
|
||||
configureForm.labItemIds = (d.labItems || []).map((li) => li.labTestItemId).filter(Boolean)
|
||||
configureForm.thirdPartyItemIds = (d.thirdPartyItems || [])
|
||||
.map((li) => li.thirdPartyItemId)
|
||||
.filter(Boolean)
|
||||
buildConfigureAssigneesFromDetail(d)
|
||||
const batchList = await fetchQcInspectionBatches(row.id).catch(() => [])
|
||||
if (batchList?.length) {
|
||||
configureBatches.value = batchList.map((b) => ({
|
||||
id: b.id,
|
||||
batchName: b.batchName || '',
|
||||
assigneeUserIds: [...(b.assigneeUserIds || [])],
|
||||
hasLab: !!(b.labItemIds?.length),
|
||||
hasThirdParty: !!(b.thirdPartyItemIds?.length),
|
||||
labItemIds: [...(b.labItemIds || [])],
|
||||
thirdPartyItemIds: [...(b.thirdPartyItemIds || [])]
|
||||
}))
|
||||
} else {
|
||||
configureBatches.value = [createEmptyInspectionBatch()]
|
||||
}
|
||||
} else {
|
||||
configureForm.hasLab = false
|
||||
configureForm.hasThirdParty = false
|
||||
configureForm.labItemIds = []
|
||||
configureForm.thirdPartyItemIds = []
|
||||
resetConfigureAssignees()
|
||||
configureBatches.value = [createEmptyInspectionBatch()]
|
||||
}
|
||||
configureVisible.value = true
|
||||
}
|
||||
|
||||
async function submitConfigure() {
|
||||
if (!configureForm.hasLab && !configureForm.hasThirdParty) {
|
||||
ElMessage.warning('请至少选择一种检测方式')
|
||||
return
|
||||
}
|
||||
if (!validateConfigureAssignees()) return
|
||||
if (!validateConfigureBatches()) return
|
||||
configureLoading.value = true
|
||||
try {
|
||||
await fetchConfigureQcWorkOrder(configuringId.value, { ...configureForm })
|
||||
await fetchConfigureQcWorkOrder(configuringId.value, {
|
||||
batches: configureBatches.value.map((b) => ({
|
||||
id: b.id,
|
||||
batchName: (b.batchName || '').trim(),
|
||||
assigneeUserIds: b.assigneeUserIds,
|
||||
hasLab: b.labItemIds.length > 0,
|
||||
hasThirdParty: b.thirdPartyItemIds.length > 0,
|
||||
labItemIds: b.labItemIds,
|
||||
thirdPartyItemIds: b.thirdPartyItemIds
|
||||
}))
|
||||
})
|
||||
ElMessage.success(configureIsEdit.value ? '检测项目已更新' : '配置成功,已生成质检任务')
|
||||
configureVisible.value = false
|
||||
await refreshActiveTab()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import QcWorkOrderTabPanel from './QcWorkOrderTabPanel.vue'
|
||||
|
||||
defineOptions({ name: 'AllQcWorkOrderTab' })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QcWorkOrderTabPanel tab-key="all" v-bind="$attrs" />
|
||||
</template>
|
||||
@@ -5,6 +5,22 @@
|
||||
<div v-if="pageMode === 'manage'" class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item v-if="isAllTab" label="质检类型">
|
||||
<el-select
|
||||
v-model="searchForm.qcCategory"
|
||||
placeholder="全部"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option
|
||||
v-for="opt in QC_WORK_ORDER_CATEGORY_OPTIONS"
|
||||
:key="opt.key"
|
||||
:label="opt.label"
|
||||
:value="opt.key"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关键词">
|
||||
<el-input v-model="searchForm.keyword" :placeholder="keywordPlaceholder" clearable />
|
||||
</el-form-item>
|
||||
@@ -21,7 +37,10 @@
|
||||
<el-option label="已作废" value="yzf" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="tabConfig.listLayout !== 'standalone' || tabKey === 'temporary'" label="工单来源">
|
||||
<el-form-item
|
||||
v-if="!isAllTab && (tabConfig.listLayout !== 'standalone' || tabKey === 'temporary')"
|
||||
label="工单来源"
|
||||
>
|
||||
<el-select
|
||||
v-model="searchForm.triggerSource"
|
||||
placeholder="全部"
|
||||
@@ -53,8 +72,44 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">{{ filterTimeHint }}</span>
|
||||
|
||||
<div v-show="isAllTab && filterExpanded" class="filter-extra">
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="工单来源">
|
||||
<el-select
|
||||
v-model="searchForm.triggerSource"
|
||||
placeholder="全部"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in QC_ALL_TAB_TRIGGER_SOURCE_OPTIONS"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="filter-actions-row" :class="{ 'filter-actions': isAllTab }">
|
||||
<template v-if="isAllTab">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="btn-filter-toggle"
|
||||
:aria-expanded="String(filterExpanded)"
|
||||
@click="filterExpanded = !filterExpanded"
|
||||
>
|
||||
<el-icon class="btn-filter-toggle-ic">
|
||||
<ArrowDown v-if="!filterExpanded" />
|
||||
<ArrowUp v-else />
|
||||
</el-icon>
|
||||
{{ filterExpanded ? '收起更多条件' : '展开更多条件' }}
|
||||
</el-button>
|
||||
</template>
|
||||
<span v-else class="filter-hint">{{ filterTimeHint }}</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
@@ -64,13 +119,33 @@
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="isAllTab" class="filter-hint filter-hint--below">{{ filterTimeHint }}</p>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div v-else class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" label-position="top" @submit.prevent>
|
||||
<p class="filter-hint">{{ filterTimeHint }}</p>
|
||||
<div class="filter-grid my-qc-task-filter-main-grid">
|
||||
<div
|
||||
class="filter-grid my-qc-task-filter-main-grid"
|
||||
:class="{ 'my-qc-task-filter-all-grid': isAllTab }"
|
||||
>
|
||||
<el-form-item v-if="isAllTab" label="质检类型">
|
||||
<el-select
|
||||
v-model="searchForm.qcCategory"
|
||||
placeholder="全部"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option
|
||||
v-for="opt in QC_WORK_ORDER_CATEGORY_OPTIONS"
|
||||
:key="opt.key"
|
||||
:label="opt.label"
|
||||
:value="opt.key"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关键词">
|
||||
<el-input
|
||||
v-model="searchForm.keyword"
|
||||
@@ -120,7 +195,7 @@
|
||||
<div v-show="filterExpanded" id="my-qc-task-filter-extra" class="filter-extra">
|
||||
<div class="filter-grid my-qc-task-filter-extra-grid">
|
||||
<el-form-item
|
||||
v-if="tabConfig.listLayout !== 'standalone' || tabKey === 'temporary'"
|
||||
v-if="isAllTab || tabConfig.listLayout !== 'standalone' || tabKey === 'temporary'"
|
||||
label="工单来源"
|
||||
>
|
||||
<el-select
|
||||
@@ -129,7 +204,15 @@
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<template v-if="tabKey === 'temporary'">
|
||||
<template v-if="isAllTab">
|
||||
<el-option
|
||||
v-for="opt in QC_ALL_TAB_TRIGGER_SOURCE_OPTIONS"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="tabKey === 'temporary'">
|
||||
<el-option label="生产派发" value="production" />
|
||||
<el-option label="手动创建" value="manual" />
|
||||
</template>
|
||||
@@ -139,7 +222,11 @@
|
||||
<template v-else-if="tabConfig.listLayout === 'outbound-grouped'">
|
||||
<el-option label="计划质检" value="schedule" />
|
||||
</template>
|
||||
<el-option v-if="tabKey !== 'temporary'" label="生产过程" value="production" />
|
||||
<el-option
|
||||
v-if="!isAllTab && tabKey !== 'temporary'"
|
||||
label="生产过程"
|
||||
value="production"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="任务类型">
|
||||
@@ -204,7 +291,7 @@
|
||||
@configure="(row) => emit('configure', row)"
|
||||
@view="handleView"
|
||||
@command="handleCommand"
|
||||
@tasks-changed="handleWorkOrderTasksChanged"
|
||||
@tasks-changed="onWorkOrderTasksChanged"
|
||||
@page-change="onWorkOrderPageChange"
|
||||
@page-size-change="onWorkOrderPageSizeChange"
|
||||
/>
|
||||
@@ -222,6 +309,11 @@
|
||||
import { Search, RefreshLeft, Plus, ArrowDown, ArrowUp } from '@element-plus/icons-vue'
|
||||
import type { QcWorkOrder } from '@/api/qc-work-order'
|
||||
import type { QcWorkOrderTabKey } from '@/utils/qc-work-order-tabs'
|
||||
import { isAllQcWorkOrderTab } from '@/utils/qc-work-order-tabs'
|
||||
import {
|
||||
QC_WORK_ORDER_CATEGORY_OPTIONS,
|
||||
QC_ALL_TAB_TRIGGER_SOURCE_OPTIONS
|
||||
} from '@/utils/qc-work-order-category'
|
||||
import QcWorkOrderCardList from '../QcWorkOrderCardList.vue'
|
||||
import { QC_WORK_ORDER_VIEW_DIALOG_COMPONENTS } from '../view-dialogs/view-dialog-registry'
|
||||
import {
|
||||
@@ -241,11 +333,12 @@
|
||||
(e: 'command', command: string, row: QcWorkOrder): void
|
||||
(e: 'add-inbound'): void
|
||||
(e: 'add-temporary'): void
|
||||
(e: 'data-changed'): void
|
||||
}>()
|
||||
|
||||
const pageModeComputed = computed(() => props.pageMode || 'manage')
|
||||
const tabKeyRef = toRef(props, 'tabKey')
|
||||
const viewDialogComponent = computed(() => QC_WORK_ORDER_VIEW_DIALOG_COMPONENTS[props.tabKey])
|
||||
const isAllTab = computed(() => isAllQcWorkOrderTab(props.tabKey))
|
||||
|
||||
const {
|
||||
tabConfig,
|
||||
@@ -263,6 +356,7 @@
|
||||
taskSubListRefreshToken,
|
||||
viewVisible,
|
||||
viewWorkOrderId,
|
||||
viewTabKey,
|
||||
loadData,
|
||||
handleSearch,
|
||||
handleReset,
|
||||
@@ -274,6 +368,13 @@
|
||||
bumpTaskRefresh
|
||||
} = useQcWorkOrderTabPage(tabKeyRef, pageModeComputed)
|
||||
|
||||
const viewDialogComponent = computed(() => QC_WORK_ORDER_VIEW_DIALOG_COMPONENTS[viewTabKey.value])
|
||||
|
||||
async function onWorkOrderTasksChanged() {
|
||||
await handleWorkOrderTasksChanged()
|
||||
emit('data-changed')
|
||||
}
|
||||
|
||||
function handleCommand(command: string, row: QcWorkOrder) {
|
||||
if (command === 'view') {
|
||||
handleView(row)
|
||||
@@ -295,6 +396,14 @@
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.my-qc-task-filter-all-grid {
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.filter-hint--below {
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.my-qc-task-filter-main-grid,
|
||||
.my-qc-task-filter-extra-grid {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Component } from 'vue'
|
||||
import type { QcWorkOrderTabKey } from '@/utils/qc-work-order-tabs'
|
||||
import AllTab from './AllTab.vue'
|
||||
import InboundCellStorageTab from './InboundCellStorageTab.vue'
|
||||
import InboundResearchDonationTab from './InboundResearchDonationTab.vue'
|
||||
import OutboundPilotTab from './OutboundPilotTab.vue'
|
||||
@@ -8,6 +9,7 @@ import OutboundClinicalTab from './OutboundClinicalTab.vue'
|
||||
import TemporaryTab from './TemporaryTab.vue'
|
||||
|
||||
export const QC_WORK_ORDER_TAB_COMPONENTS: Record<QcWorkOrderTabKey, Component> = {
|
||||
all: AllTab,
|
||||
inbound_cell_storage: InboundCellStorageTab,
|
||||
inbound_research_donation: InboundResearchDonationTab,
|
||||
outbound_pilot_service: OutboundPilotTab,
|
||||
|
||||
+2
@@ -14,6 +14,7 @@
|
||||
modal-class="qc-work-order-view-dialog-mask"
|
||||
:detail="detail"
|
||||
:view-tasks="viewTasks"
|
||||
:view-batches="viewBatches"
|
||||
>
|
||||
<template #protocol-payment-details>
|
||||
<QcWorkOrderProtocolPaymentPanel :summary="detail?.paymentSummary" embedded />
|
||||
@@ -65,6 +66,7 @@
|
||||
detail,
|
||||
sections,
|
||||
viewTasks,
|
||||
viewBatches,
|
||||
viewReceptionAttachmentFiles,
|
||||
handleReceptionAttachmentPreview,
|
||||
handleReceptionAttachmentDownload,
|
||||
|
||||
+2
@@ -14,6 +14,7 @@
|
||||
modal-class="qc-work-order-view-dialog-mask"
|
||||
:detail="detail"
|
||||
:view-tasks="viewTasks"
|
||||
:view-batches="viewBatches"
|
||||
>
|
||||
<template #reception-extra>
|
||||
<div class="view-reception-attachments">
|
||||
@@ -61,6 +62,7 @@
|
||||
detail,
|
||||
sections,
|
||||
viewTasks,
|
||||
viewBatches,
|
||||
viewReceptionAttachmentFiles,
|
||||
handleReceptionAttachmentPreview,
|
||||
handleReceptionAttachmentDownload,
|
||||
|
||||
+2
-1
@@ -13,6 +13,7 @@
|
||||
:sections="sections"
|
||||
:detail="detail?.workOrder"
|
||||
:view-tasks="viewTasks"
|
||||
:view-batches="viewBatches"
|
||||
>
|
||||
<template #product-table>
|
||||
<OutboundQcProductTable :products="detail?.products" biz-type="basic_experiment" />
|
||||
@@ -42,7 +43,7 @@
|
||||
set: (v) => emit('update:visible', v)
|
||||
})
|
||||
|
||||
const { Document, loading, detail, sections, viewTasks, load } =
|
||||
const { Document, loading, detail, sections, viewTasks, viewBatches, load } =
|
||||
useOutboundQcViewDialog({ variant: 'basic_experiment', showFeeSection: true })
|
||||
|
||||
watch(
|
||||
|
||||
+2
@@ -13,6 +13,7 @@
|
||||
:sections="sections"
|
||||
:detail="detail?.workOrder"
|
||||
:view-tasks="viewTasks"
|
||||
:view-batches="viewBatches"
|
||||
>
|
||||
<template #diagnosis-attachments>
|
||||
<OutboundQcDiagnosisAttachments :files="diagnosisAttachmentFiles" />
|
||||
@@ -52,6 +53,7 @@
|
||||
detail,
|
||||
sections,
|
||||
viewTasks,
|
||||
viewBatches,
|
||||
diagnosisAttachmentFiles,
|
||||
load
|
||||
} = useOutboundQcViewDialog({ variant: 'clinical_application', showFeeSection: true })
|
||||
|
||||
+2
@@ -13,6 +13,7 @@
|
||||
:sections="sections"
|
||||
:detail="detail?.workOrder"
|
||||
:view-tasks="viewTasks"
|
||||
:view-batches="viewBatches"
|
||||
>
|
||||
<template #diagnosis-attachments>
|
||||
<OutboundQcDiagnosisAttachments :files="diagnosisAttachmentFiles" />
|
||||
@@ -52,6 +53,7 @@
|
||||
detail,
|
||||
sections,
|
||||
viewTasks,
|
||||
viewBatches,
|
||||
diagnosisAttachmentFiles,
|
||||
load
|
||||
} = useOutboundQcViewDialog({ variant: 'pilot_service', showFeeSection: false })
|
||||
|
||||
+18
-3
@@ -5,6 +5,9 @@
|
||||
<template v-for="name in extraSlotNames" #[name]>
|
||||
<slot :name="name" />
|
||||
</template>
|
||||
<template v-for="panel in batchPanels" #[panel.slot]>
|
||||
<QcWorkOrderTaskResultPanel :key="panel.slot" :tasks="panel.tasks" />
|
||||
</template>
|
||||
<template #[LAB_TASKS_PANEL_SLOT]>
|
||||
<QcWorkOrderTaskResultPanel
|
||||
task-type="sysz"
|
||||
@@ -27,9 +30,15 @@
|
||||
import type { QcWorkOrderDetail } from '@/api/qc-work-order'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import QcWorkOrderTaskResultPanel from '../QcWorkOrderTaskResultPanel.vue'
|
||||
import {
|
||||
batchTasksPanelSlot,
|
||||
resolveBatchSections,
|
||||
type QcInspectionBatch
|
||||
} from '@/utils/qc-inspection-batch'
|
||||
import {
|
||||
LAB_TASKS_PANEL_SLOT,
|
||||
THIRD_TASKS_PANEL_SLOT,
|
||||
isBatchTaskPanelSlot,
|
||||
type QcWorkOrderTaskView
|
||||
} from '../composables/useQcWorkOrderTaskViewSections'
|
||||
|
||||
@@ -39,6 +48,7 @@
|
||||
visible: boolean
|
||||
detail?: Partial<QcWorkOrderDetail> | null
|
||||
viewTasks?: QcWorkOrderTaskView[]
|
||||
viewBatches?: QcInspectionBatch[] | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -48,9 +58,7 @@
|
||||
const attrs = useAttrs()
|
||||
const slots = useSlots()
|
||||
const extraSlotNames = computed(() =>
|
||||
Object.keys(slots).filter(
|
||||
(name) => name !== LAB_TASKS_PANEL_SLOT && name !== THIRD_TASKS_PANEL_SLOT
|
||||
)
|
||||
Object.keys(slots).filter((name) => !isBatchTaskPanelSlot(name))
|
||||
)
|
||||
|
||||
const dialogVisible = computed({
|
||||
@@ -58,6 +66,13 @@
|
||||
set: (v) => emit('update:visible', v)
|
||||
})
|
||||
|
||||
const batchPanels = computed(() =>
|
||||
resolveBatchSections(props.viewBatches, props.viewTasks).map((section) => ({
|
||||
slot: batchTasksPanelSlot(section.key),
|
||||
tasks: section.tasks as QcWorkOrderTaskView[]
|
||||
}))
|
||||
)
|
||||
|
||||
const labTasks = computed(() =>
|
||||
(props.viewTasks || []).filter((t) => t.taskType === 'sysz')
|
||||
)
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@
|
||||
modal-class="qc-work-order-view-dialog-mask"
|
||||
:detail="detail"
|
||||
:view-tasks="viewTasks"
|
||||
:view-batches="viewBatches"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -40,7 +41,7 @@
|
||||
set: (v) => emit('update:visible', v)
|
||||
})
|
||||
|
||||
const { loading, detail, sections, viewTasks, load } =
|
||||
const { loading, detail, sections, viewTasks, viewBatches, load } =
|
||||
useInboundQcViewDialog(buildTemporaryViewSections)
|
||||
|
||||
watch(
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ import OutboundClinicalViewDialog from './OutboundClinicalViewDialog.vue'
|
||||
import TemporaryQcViewDialog from './TemporaryQcViewDialog.vue'
|
||||
|
||||
export const QC_WORK_ORDER_VIEW_DIALOG_COMPONENTS: Record<QcWorkOrderTabKey, Component> = {
|
||||
all: InboundCellStorageViewDialog,
|
||||
inbound_cell_storage: InboundCellStorageViewDialog,
|
||||
inbound_research_donation: InboundResearchDonationViewDialog,
|
||||
outbound_pilot_service: OutboundPilotViewDialog,
|
||||
|
||||
@@ -168,7 +168,6 @@
|
||||
<el-input
|
||||
v-model="formData.itemCode"
|
||||
placeholder="租户内唯一,如 packaging"
|
||||
:disabled="isEdit"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="检查项名称" prop="itemName">
|
||||
|
||||
@@ -306,13 +306,11 @@
|
||||
prop="labStorageCode"
|
||||
>
|
||||
<template #label>
|
||||
实验室入库编码<span class="form-label-tip"
|
||||
>RK+接收日期+序号,保存后不可修改</span
|
||||
>
|
||||
实验室入库编码<span class="form-label-tip">保存后不可修改</span>
|
||||
</template>
|
||||
<el-input
|
||||
v-model="receiveForm.labStorageCode"
|
||||
placeholder="自动生成"
|
||||
placeholder="请填写"
|
||||
clearable
|
||||
:disabled="labStorageCodeReadonly"
|
||||
@input="onLabStorageCodeManualInput"
|
||||
@@ -625,11 +623,11 @@
|
||||
</el-form-item>
|
||||
<el-form-item v-if="entry.acceptConclusion === 'js'" label="实验室入库编码" required>
|
||||
<template #label>
|
||||
实验室入库编码<span class="form-label-tip">RK+接收日期+序号</span>
|
||||
实验室入库编码
|
||||
</template>
|
||||
<el-input
|
||||
v-model="entry.labStorageCode"
|
||||
placeholder="自动生成"
|
||||
placeholder="请填写"
|
||||
clearable
|
||||
@input="() => onBatchLabStorageCodeManualInput(entry)"
|
||||
/>
|
||||
@@ -688,7 +686,6 @@
|
||||
fetchSampleReceptionSubmit,
|
||||
fetchSampleReceptionUpdate,
|
||||
fetchSampleReceptionDetail,
|
||||
fetchAllocateLabStorageCodes,
|
||||
type SampleReceptionCheckResult
|
||||
} from '@/api/sample-reception'
|
||||
import {
|
||||
@@ -714,6 +711,10 @@
|
||||
donationStatusTagType
|
||||
} from '@/utils/status-tag-registry'
|
||||
import type { TagType } from '@/utils/status-tag-registry'
|
||||
import {
|
||||
buildPrefilledLabStorageCode,
|
||||
parseLabStorageReferenceDate
|
||||
} from '@/utils/sample-reception-lab-storage-code'
|
||||
|
||||
/** 根据来源类型返回协议状态标签 */
|
||||
function protocolStatusLabelBySource(status: string, source: string): string {
|
||||
@@ -1038,32 +1039,35 @@
|
||||
return s.length >= 10 ? s.slice(0, 10) : ''
|
||||
}
|
||||
|
||||
async function allocateLabStorageCodes(receptionDate: string, count = 1) {
|
||||
const date = extractReceptionDate(receptionDate ? `${receptionDate} 00:00:00` : '')
|
||||
if (!date) throw new Error('请先选择样本接收时间')
|
||||
const res = await fetchAllocateLabStorageCodes({ receptionDate: date, count })
|
||||
return res?.codes || []
|
||||
function resolvePrefilledLabStorageCode(
|
||||
sourceType: string,
|
||||
sampleTypeName: string,
|
||||
receptionTime: string
|
||||
) {
|
||||
return buildPrefilledLabStorageCode(
|
||||
sourceType,
|
||||
sampleTypeName,
|
||||
parseLabStorageReferenceDate(receptionTime)
|
||||
)
|
||||
}
|
||||
|
||||
async function refreshReceiveLabStorageCode(force = false) {
|
||||
function refreshReceiveLabStorageCode(force = false) {
|
||||
if (receiveForm.acceptConclusion !== 'js') {
|
||||
receiveForm.labStorageCode = ''
|
||||
return
|
||||
}
|
||||
if (labStorageCodeReadonly.value) return
|
||||
const date = extractReceptionDate(receiveForm.receptionTime)
|
||||
if (!date) return
|
||||
if (!force && labStorageCodeManuallyEdited.value) return
|
||||
if (!force && date === lastAllocatedReceptionDate.value && receiveForm.labStorageCode) return
|
||||
try {
|
||||
const codes = await allocateLabStorageCodes(date, 1)
|
||||
receiveForm.labStorageCode = codes[0] || ''
|
||||
labStorageCodeManuallyEdited.value = false
|
||||
lastAllocatedReceptionDate.value = date
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : '实验室入库编码生成失败'
|
||||
ElMessage.warning(msg)
|
||||
}
|
||||
|
||||
const row = currentRow.value
|
||||
if (!row) return
|
||||
|
||||
receiveForm.labStorageCode = resolvePrefilledLabStorageCode(
|
||||
String(row.sourceType || 'cell_storage'),
|
||||
String(row.sampleTypeName || ''),
|
||||
receiveForm.receptionTime
|
||||
)
|
||||
lastAllocatedReceptionDate.value = extractReceptionDate(receiveForm.receptionTime)
|
||||
}
|
||||
|
||||
function onLabStorageCodeManualInput() {
|
||||
@@ -1074,11 +1078,10 @@
|
||||
const date = extractReceptionDate(receiveForm.receptionTime)
|
||||
if (!date || receiveForm.acceptConclusion !== 'js' || labStorageCodeReadonly.value) return
|
||||
if (labStorageCodeManuallyEdited.value) return
|
||||
if (date === lastAllocatedReceptionDate.value) return
|
||||
await refreshReceiveLabStorageCode(true)
|
||||
refreshReceiveLabStorageCode(true)
|
||||
}
|
||||
|
||||
async function onReceiveAcceptConclusionChange(val: string | number | boolean | undefined) {
|
||||
function onReceiveAcceptConclusionChange(val: string | number | boolean | undefined) {
|
||||
if (val === 'bj') {
|
||||
receiveForm.labStorageCode = ''
|
||||
labStorageCodeManuallyEdited.value = false
|
||||
@@ -1086,55 +1089,41 @@
|
||||
return
|
||||
}
|
||||
if (labStorageCodeReadonly.value) return
|
||||
await refreshReceiveLabStorageCode(true)
|
||||
refreshReceiveLabStorageCode(true)
|
||||
}
|
||||
|
||||
async function allocateBatchLabStorageCodes() {
|
||||
const jsEntries = batchEntries.value.filter((e) => e.acceptConclusion === 'js')
|
||||
if (!jsEntries.length) return
|
||||
const groups = new Map<string, BatchReceiveEntry[]>()
|
||||
for (const entry of jsEntries) {
|
||||
const date = extractReceptionDate(entry.receptionTime)
|
||||
if (!date) continue
|
||||
const list = groups.get(date) || []
|
||||
list.push(entry)
|
||||
groups.set(date, list)
|
||||
}
|
||||
for (const [date, entries] of groups) {
|
||||
try {
|
||||
const codes = await allocateLabStorageCodes(date, entries.length)
|
||||
entries.forEach((entry, index) => {
|
||||
entry.labStorageCode = codes[index] || ''
|
||||
entry.labStorageCodeManuallyEdited = false
|
||||
entry.lastAllocatedReceptionDate = date
|
||||
})
|
||||
} catch {
|
||||
entries.forEach((entry) => {
|
||||
entry.labStorageCode = ''
|
||||
})
|
||||
function allocateBatchLabStorageCodes() {
|
||||
for (const entry of batchEntries.value) {
|
||||
if (entry.acceptConclusion !== 'js') {
|
||||
entry.labStorageCode = ''
|
||||
entry.labStorageCodeManuallyEdited = false
|
||||
entry.lastAllocatedReceptionDate = ''
|
||||
continue
|
||||
}
|
||||
if (entry.labStorageCodeManuallyEdited) continue
|
||||
entry.labStorageCode = resolvePrefilledLabStorageCode(
|
||||
entry.sourceType,
|
||||
entry.sampleTypeName,
|
||||
entry.receptionTime
|
||||
)
|
||||
entry.lastAllocatedReceptionDate = extractReceptionDate(entry.receptionTime)
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshBatchEntryLabStorageCode(entry: BatchReceiveEntry, force = false) {
|
||||
function refreshBatchEntryLabStorageCode(entry: BatchReceiveEntry, force = false) {
|
||||
if (entry.acceptConclusion !== 'js') {
|
||||
entry.labStorageCode = ''
|
||||
entry.labStorageCodeManuallyEdited = false
|
||||
entry.lastAllocatedReceptionDate = ''
|
||||
return
|
||||
}
|
||||
const date = extractReceptionDate(entry.receptionTime)
|
||||
if (!date) return
|
||||
if (!force && entry.labStorageCodeManuallyEdited) return
|
||||
if (!force && date === entry.lastAllocatedReceptionDate && entry.labStorageCode) return
|
||||
try {
|
||||
const codes = await allocateLabStorageCodes(date, 1)
|
||||
entry.labStorageCode = codes[0] || ''
|
||||
entry.labStorageCodeManuallyEdited = false
|
||||
entry.lastAllocatedReceptionDate = date
|
||||
} catch {
|
||||
entry.labStorageCode = ''
|
||||
}
|
||||
entry.labStorageCode = resolvePrefilledLabStorageCode(
|
||||
entry.sourceType,
|
||||
entry.sampleTypeName,
|
||||
entry.receptionTime
|
||||
)
|
||||
entry.lastAllocatedReceptionDate = extractReceptionDate(entry.receptionTime)
|
||||
}
|
||||
|
||||
function onBatchLabStorageCodeManualInput(entry: BatchReceiveEntry) {
|
||||
@@ -1143,19 +1132,17 @@
|
||||
|
||||
async function onBatchReceptionTimeChange(entry: BatchReceiveEntry) {
|
||||
if (entry.acceptConclusion !== 'js' || entry.labStorageCodeManuallyEdited) return
|
||||
const date = extractReceptionDate(entry.receptionTime)
|
||||
if (!date || date === entry.lastAllocatedReceptionDate) return
|
||||
await refreshBatchEntryLabStorageCode(entry, true)
|
||||
refreshBatchEntryLabStorageCode(entry, true)
|
||||
}
|
||||
|
||||
async function onBatchAcceptConclusionChange(entry: BatchReceiveEntry) {
|
||||
function onBatchAcceptConclusionChange(entry: BatchReceiveEntry) {
|
||||
if (entry.acceptConclusion === 'bj') {
|
||||
entry.labStorageCode = ''
|
||||
entry.labStorageCodeManuallyEdited = false
|
||||
entry.lastAllocatedReceptionDate = ''
|
||||
return
|
||||
}
|
||||
await refreshBatchEntryLabStorageCode(entry, true)
|
||||
refreshBatchEntryLabStorageCode(entry, true)
|
||||
}
|
||||
|
||||
function resetReceiveForm() {
|
||||
@@ -1245,7 +1232,7 @@
|
||||
}
|
||||
batchEntries.value = selectedPendingRows.value.map((row) => createBatchEntry(row))
|
||||
batchReceiveDialogVisible.value = true
|
||||
await allocateBatchLabStorageCodes()
|
||||
allocateBatchLabStorageCodes()
|
||||
}
|
||||
|
||||
function validateBatchEntry(entry: BatchReceiveEntry, index: number): string | null {
|
||||
@@ -1417,7 +1404,7 @@
|
||||
resetReceiveForm()
|
||||
resetCheckValues(activeCheckItems.value)
|
||||
receiveDialogVisible.value = true
|
||||
await refreshReceiveLabStorageCode(true)
|
||||
refreshReceiveLabStorageCode(true)
|
||||
}
|
||||
|
||||
async function openEdit(row: Record<string, unknown>) {
|
||||
|
||||
Reference in new issue
Block a user