提交
This commit is contained in:
1 parent
2a4767a014
commit
f269a994f4
61 files changed
+27430
-8
No files matched your search
@@ -0,0 +1,891 @@
|
||||
<!-- 工艺库管理 -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<header class="page-head">
|
||||
<h1>工艺库管理</h1>
|
||||
<p class="page-desc">管理工艺工序及其关联的试剂、耗材与产出物配置。</p>
|
||||
</header>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">工艺列表</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="关键词">
|
||||
<el-input
|
||||
v-model="searchForm.keyword"
|
||||
placeholder="工序代码/名称"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">按工序代码、名称模糊查询。</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" @click="handleReset">重置</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleSearch">搜索</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新增工艺
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
type="danger"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="handleBatchDelete"
|
||||
>
|
||||
批量删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="tableData"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="processCode"
|
||||
label="工序代码"
|
||||
min-width="130"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="processName"
|
||||
label="工序名称"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
label="工序分类"
|
||||
min-width="130"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ categoryMap[row.categoryId] || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="description"
|
||||
label="描述"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="equipmentName"
|
||||
label="设备名称"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="estimatedDuration"
|
||||
label="预估耗时"
|
||||
min-width="100"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
label="创建时间"
|
||||
min-width="180"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button class="btn-op-item" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
:current-page="pagination.page"
|
||||
:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
|
||||
@current-change="(val) => ((pagination.page = val), loadData())"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增/编辑弹窗 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
width="1000px"
|
||||
class="dialog-form-layout process-dialog"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="process-dialog-form"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<el-tabs v-model="activeTab" type="border-card">
|
||||
<!-- Tab 1: 基本信息 -->
|
||||
<el-tab-pane label="基本信息" name="basic">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="工序代码" prop="processCode">
|
||||
<el-input v-model="formData.processCode" placeholder="请输入工序代码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="工序名称" prop="processName">
|
||||
<el-input v-model="formData.processName" placeholder="请输入工序名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="工序分类">
|
||||
<el-select
|
||||
v-model="formData.categoryId"
|
||||
placeholder="请选择分类"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="cat in categoryOptions"
|
||||
:key="cat.id"
|
||||
:label="cat.categoryName || cat.name"
|
||||
:value="cat.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称">
|
||||
<el-input v-model="formData.equipmentName" placeholder="请输入设备名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="预估耗时">
|
||||
<el-input v-model="formData.estimatedDuration" placeholder="如 30min" />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联SOP">
|
||||
<el-select
|
||||
v-model="formData.sopIds"
|
||||
placeholder="请选择SOP文档"
|
||||
multiple
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="sop in sopOptions"
|
||||
:key="sop.id"
|
||||
:label="sop.sopName || sop.name"
|
||||
:value="sop.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" class="form-col-span-2">
|
||||
<el-input
|
||||
v-model="formData.description"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
placeholder="请输入描述"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" class="form-col-span-2">
|
||||
<el-input v-model="formData.remark" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- Tab 2: 试剂关联 -->
|
||||
<el-tab-pane label="试剂关联" name="reagents">
|
||||
<div class="tab-toolbar">
|
||||
<el-button class="btn-main" type="primary" size="small" @click="openAddReagentDialog">
|
||||
<el-icon><Plus /></el-icon>
|
||||
添加试剂
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table :data="reagentList" stripe size="small" class="inner-table">
|
||||
<el-table-column prop="reagentCode" label="试剂编码" min-width="110" align="center" header-align="center" />
|
||||
<el-table-column prop="reagentName" label="试剂名称" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="spec" label="规格" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column label="标准用量" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.standardUsage" placeholder="用量" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="unit" label="单位" min-width="80" align="center" header-align="center" />
|
||||
<el-table-column label="关键物料" width="90" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.isKeyMaterial" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" align="center" header-align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" size="small" @click="reagentList.splice($index, 1)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty v-if="reagentList.length === 0" description="暂无试剂,点击上方按钮添加" :image-size="48" />
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- Tab 3: 耗材关联 -->
|
||||
<el-tab-pane label="耗材关联" name="consumables">
|
||||
<div class="tab-toolbar">
|
||||
<div class="tab-toolbar-left">
|
||||
<el-button class="btn-main" type="primary" size="small" @click="openAddConsumableDialog">
|
||||
<el-icon><Plus /></el-icon>
|
||||
添加耗材
|
||||
</el-button>
|
||||
<el-select
|
||||
v-model="selectedPackId"
|
||||
placeholder="从耗材包导入"
|
||||
clearable
|
||||
filterable
|
||||
size="small"
|
||||
style="width: 200px"
|
||||
@change="handleImportPack"
|
||||
>
|
||||
<el-option
|
||||
v-for="pack in packOptions"
|
||||
:key="pack.id"
|
||||
:label="pack.packName"
|
||||
:value="pack.id"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<el-table :data="consumableList" stripe size="small" class="inner-table">
|
||||
<el-table-column prop="consumableCode" label="耗材编码" min-width="110" align="center" header-align="center" />
|
||||
<el-table-column prop="consumableName" label="耗材名称" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="specModel" label="规格型号" min-width="110" align="center" header-align="center" />
|
||||
<el-table-column label="标准用量" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.standardUsage" placeholder="用量" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="必填" width="80" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.isRequired" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.remark" placeholder="备注" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" align="center" header-align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" size="small" @click="consumableList.splice($index, 1)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty v-if="consumableList.length === 0" description="暂无耗材,点击上方按钮添加" :image-size="48" />
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- Tab 4: 产出物 -->
|
||||
<el-tab-pane label="产出物" name="outputs">
|
||||
<div class="tab-toolbar">
|
||||
<el-button class="btn-main" type="primary" size="small" @click="addOutputRow">
|
||||
<el-icon><Plus /></el-icon>
|
||||
添加产出物
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table :data="outputList" stripe size="small" class="inner-table">
|
||||
<el-table-column label="产出物类型" min-width="150" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.outputTypeId" placeholder="选择类型" size="small" filterable>
|
||||
<el-option
|
||||
v-for="ot in outputTypeOptions"
|
||||
:key="ot.id"
|
||||
:label="ot.typeName || ot.name"
|
||||
:value="ot.id"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产出物名称" min-width="150" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.outputName" placeholder="名称" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产出物条码" min-width="150" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.outputBarcode" placeholder="条码" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" align="center" header-align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" size="small" @click="outputList.splice($index, 1)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty v-if="outputList.length === 0" description="暂无产出物,点击上方按钮添加" :image-size="48" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogVisible = false">
|
||||
<el-icon><Close /></el-icon>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="submitLoading" @click="handleSubmit">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 选择试剂内弹窗 -->
|
||||
<el-dialog
|
||||
v-model="selectReagentVisible"
|
||||
title="选择试剂"
|
||||
width="700px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-input
|
||||
v-model="reagentKeyword"
|
||||
placeholder="搜索试剂编码/名称"
|
||||
clearable
|
||||
style="margin-bottom: 12px"
|
||||
@input="filterReagents"
|
||||
/>
|
||||
<el-table
|
||||
:data="filteredReagentList"
|
||||
stripe
|
||||
size="small"
|
||||
height="360"
|
||||
highlight-current-row
|
||||
@current-change="handleReagentSelect"
|
||||
>
|
||||
<el-table-column prop="reagentCode" label="试剂编码" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="reagentName" label="试剂名称" min-width="140" align="center" header-align="center" />
|
||||
<el-table-column prop="spec" label="规格" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column prop="unit" label="单位" min-width="80" align="center" header-align="center" />
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="selectReagentVisible = false">取消</el-button>
|
||||
<el-button class="btn-main" type="primary" :disabled="!selectedReagent" @click="confirmAddReagent">
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 选择耗材内弹窗 -->
|
||||
<el-dialog
|
||||
v-model="selectConsumableVisible"
|
||||
title="选择耗材"
|
||||
width="700px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-input
|
||||
v-model="consumableKeyword"
|
||||
placeholder="搜索耗材编码/名称"
|
||||
clearable
|
||||
style="margin-bottom: 12px"
|
||||
@input="filterConsumables"
|
||||
/>
|
||||
<el-table
|
||||
:data="filteredConsumableList"
|
||||
stripe
|
||||
size="small"
|
||||
height="360"
|
||||
highlight-current-row
|
||||
@current-change="handleConsumableRowSelect"
|
||||
>
|
||||
<el-table-column prop="consumableCode" label="耗材编码" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="consumableName" label="耗材名称" min-width="140" align="center" header-align="center" />
|
||||
<el-table-column prop="specModel" label="规格型号" min-width="120" align="center" header-align="center" />
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="selectConsumableVisible = false">取消</el-button>
|
||||
<el-button class="btn-main" type="primary" :disabled="!selectedConsumable" @click="confirmAddConsumable">
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Plus, Close, Check } from '@element-plus/icons-vue'
|
||||
import {
|
||||
fetchProcessList,
|
||||
fetchProcessDetail,
|
||||
fetchCreateProcess,
|
||||
fetchUpdateProcess,
|
||||
fetchDeleteProcess,
|
||||
fetchAllProcessCategories,
|
||||
fetchAllSopDocuments,
|
||||
fetchAllReagents,
|
||||
fetchAllConsumables,
|
||||
fetchAllOutputTypes,
|
||||
fetchAllConsumablePacks
|
||||
} from '@/api/production'
|
||||
|
||||
defineOptions({ name: 'ProductionProcess' })
|
||||
|
||||
// 搜索 & 列表
|
||||
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
|
||||
const tableData = ref<any[]>([])
|
||||
const selectedRows = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
|
||||
// 弹窗状态
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增工艺')
|
||||
const isEdit = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const formRef = ref()
|
||||
const editingId = ref<string | null>(null)
|
||||
const activeTab = ref('basic')
|
||||
|
||||
// 下拉选项
|
||||
const categoryOptions = ref<any[]>([])
|
||||
const sopOptions = ref<any[]>([])
|
||||
const outputTypeOptions = ref<any[]>([])
|
||||
const packOptions = ref<any[]>([])
|
||||
const allReagentOptions = ref<any[]>([])
|
||||
const allConsumableOptions = ref<any[]>([])
|
||||
|
||||
// 列表中的分类映射
|
||||
const categoryMap = computed(() => {
|
||||
const map: Record<string, string> = {}
|
||||
categoryOptions.value.forEach((c: any) => {
|
||||
map[c.id] = c.categoryName || c.name || ''
|
||||
})
|
||||
return map
|
||||
})
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
processCode: '',
|
||||
processName: '',
|
||||
categoryId: '',
|
||||
description: '',
|
||||
equipmentName: '',
|
||||
estimatedDuration: '',
|
||||
sopIds: [] as string[],
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
processCode: [{ required: true, message: '请输入工序代码', trigger: 'blur' }],
|
||||
processName: [{ required: true, message: '请输入工序名称', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
// 子表数据
|
||||
const reagentList = ref<any[]>([])
|
||||
const consumableList = ref<any[]>([])
|
||||
const outputList = ref<any[]>([])
|
||||
|
||||
// 选择试剂弹窗
|
||||
const selectReagentVisible = ref(false)
|
||||
const filteredReagentList = ref<any[]>([])
|
||||
const reagentKeyword = ref('')
|
||||
const selectedReagent = ref<any>(null)
|
||||
|
||||
// 选择耗材弹窗
|
||||
const selectConsumableVisible = ref(false)
|
||||
const filteredConsumableList = ref<any[]>([])
|
||||
const consumableKeyword = ref('')
|
||||
const selectedConsumable = ref<any>(null)
|
||||
|
||||
// 耗材包导入
|
||||
const selectedPackId = ref<string | undefined>(undefined)
|
||||
|
||||
const handleSelectionChange = (rows: any[]) => {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchProcessList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined
|
||||
})
|
||||
tableData.value = res.list || []
|
||||
pagination.total = res.total ?? 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 加载所有下拉参考数据
|
||||
async function loadReferenceData() {
|
||||
try {
|
||||
const [cats, sops, reagents, consumables, outputTypes, packs] = await Promise.all([
|
||||
fetchAllProcessCategories(),
|
||||
fetchAllSopDocuments(),
|
||||
fetchAllReagents(),
|
||||
fetchAllConsumables(),
|
||||
fetchAllOutputTypes(),
|
||||
fetchAllConsumablePacks()
|
||||
])
|
||||
categoryOptions.value = cats || []
|
||||
sopOptions.value = sops || []
|
||||
allReagentOptions.value = reagents || []
|
||||
allConsumableOptions.value = consumables || []
|
||||
outputTypeOptions.value = outputTypes || []
|
||||
packOptions.value = packs || []
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.keyword = ''
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formData.processCode = ''
|
||||
formData.processName = ''
|
||||
formData.categoryId = ''
|
||||
formData.description = ''
|
||||
formData.equipmentName = ''
|
||||
formData.estimatedDuration = ''
|
||||
formData.sopIds = []
|
||||
formData.remark = ''
|
||||
reagentList.value = []
|
||||
consumableList.value = []
|
||||
outputList.value = []
|
||||
editingId.value = null
|
||||
activeTab.value = 'basic'
|
||||
selectedPackId.value = undefined
|
||||
}
|
||||
|
||||
async function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增工艺'
|
||||
resetForm()
|
||||
await loadReferenceData()
|
||||
dialogVisible.value = true
|
||||
nextTick(() => formRef.value?.clearValidate?.())
|
||||
}
|
||||
|
||||
async function handleEdit(row: any) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑工艺'
|
||||
editingId.value = row.id
|
||||
resetForm()
|
||||
await loadReferenceData()
|
||||
try {
|
||||
const detail = await fetchProcessDetail(row.id)
|
||||
formData.processCode = detail.processCode || ''
|
||||
formData.processName = detail.processName || ''
|
||||
formData.categoryId = detail.categoryId || ''
|
||||
formData.description = detail.description || ''
|
||||
formData.equipmentName = detail.equipmentName || ''
|
||||
formData.estimatedDuration = detail.estimatedDuration || ''
|
||||
formData.sopIds = detail.sopIds || []
|
||||
formData.remark = detail.remark || ''
|
||||
reagentList.value = (detail.reagents || []).map((r: any) => ({ ...r }))
|
||||
consumableList.value = (detail.consumables || []).map((c: any) => ({ ...c }))
|
||||
outputList.value = (detail.outputs || []).map((o: any) => ({ ...o }))
|
||||
} catch {
|
||||
ElMessage.error('加载详情失败')
|
||||
}
|
||||
dialogVisible.value = true
|
||||
nextTick(() => formRef.value?.clearValidate?.())
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate?.()
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
processCode: formData.processCode.trim(),
|
||||
processName: formData.processName.trim(),
|
||||
categoryId: formData.categoryId || undefined,
|
||||
description: formData.description?.trim() || undefined,
|
||||
equipmentName: formData.equipmentName?.trim() || undefined,
|
||||
estimatedDuration: formData.estimatedDuration?.trim() || undefined,
|
||||
sopIds: formData.sopIds,
|
||||
remark: formData.remark?.trim() || undefined,
|
||||
reagents: reagentList.value.map((r) => ({
|
||||
reagentId: r.reagentId || r.id,
|
||||
reagentCode: r.reagentCode,
|
||||
reagentName: r.reagentName,
|
||||
spec: r.spec,
|
||||
standardUsage: r.standardUsage,
|
||||
unit: r.unit,
|
||||
isKeyMaterial: r.isKeyMaterial || false
|
||||
})),
|
||||
consumables: consumableList.value.map((c) => ({
|
||||
consumableId: c.consumableId || c.id,
|
||||
consumableCode: c.consumableCode,
|
||||
consumableName: c.consumableName,
|
||||
specModel: c.specModel,
|
||||
standardUsage: c.standardUsage,
|
||||
isRequired: c.isRequired || false,
|
||||
remark: c.remark || ''
|
||||
})),
|
||||
outputs: outputList.value.map((o) => ({
|
||||
outputTypeId: o.outputTypeId,
|
||||
outputName: o.outputName,
|
||||
outputBarcode: o.outputBarcode
|
||||
}))
|
||||
}
|
||||
if (isEdit.value && editingId.value) {
|
||||
await fetchUpdateProcess(editingId.value, payload)
|
||||
} else {
|
||||
await fetchCreateProcess(payload)
|
||||
}
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
|
||||
dialogVisible.value = false
|
||||
await loadData()
|
||||
} catch {
|
||||
/* 校验或接口错误已由全局处理 */
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
await ElMessageBox.confirm('确定要删除该工艺吗?', '提示', { type: 'warning' })
|
||||
await fetchDeleteProcess(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
await loadData()
|
||||
}
|
||||
|
||||
async function handleBatchDelete() {
|
||||
const ids = selectedRows.value.map((r) => r.id)
|
||||
if (!ids.length) return
|
||||
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个工艺吗?`, '提示', { type: 'warning' })
|
||||
for (const id of ids) {
|
||||
await fetchDeleteProcess(id)
|
||||
}
|
||||
ElMessage.success('批量删除成功')
|
||||
selectedRows.value = []
|
||||
await loadData()
|
||||
}
|
||||
|
||||
// =============== 试剂弹窗 ===============
|
||||
function openAddReagentDialog() {
|
||||
selectedReagent.value = null
|
||||
reagentKeyword.value = ''
|
||||
filteredReagentList.value = [...allReagentOptions.value]
|
||||
selectReagentVisible.value = true
|
||||
}
|
||||
|
||||
function filterReagents() {
|
||||
const kw = reagentKeyword.value.trim().toLowerCase()
|
||||
if (!kw) {
|
||||
filteredReagentList.value = [...allReagentOptions.value]
|
||||
return
|
||||
}
|
||||
filteredReagentList.value = allReagentOptions.value.filter(
|
||||
(r) =>
|
||||
(r.reagentCode || '').toLowerCase().includes(kw) ||
|
||||
(r.reagentName || '').toLowerCase().includes(kw)
|
||||
)
|
||||
}
|
||||
|
||||
function handleReagentSelect(row: any) {
|
||||
selectedReagent.value = row
|
||||
}
|
||||
|
||||
function confirmAddReagent() {
|
||||
if (!selectedReagent.value) return
|
||||
const r = selectedReagent.value
|
||||
const exists = reagentList.value.some(
|
||||
(item) => item.reagentId === r.id || item.reagentCode === r.reagentCode
|
||||
)
|
||||
if (exists) {
|
||||
ElMessage.warning('该试剂已在列表中')
|
||||
return
|
||||
}
|
||||
reagentList.value.push({
|
||||
reagentId: r.id,
|
||||
reagentCode: r.reagentCode || '',
|
||||
reagentName: r.reagentName || '',
|
||||
spec: r.spec || '',
|
||||
standardUsage: '',
|
||||
unit: r.unit || '',
|
||||
isKeyMaterial: false
|
||||
})
|
||||
selectReagentVisible.value = false
|
||||
}
|
||||
|
||||
// =============== 耗材弹窗 ===============
|
||||
function openAddConsumableDialog() {
|
||||
selectedConsumable.value = null
|
||||
consumableKeyword.value = ''
|
||||
filteredConsumableList.value = [...allConsumableOptions.value]
|
||||
selectConsumableVisible.value = true
|
||||
}
|
||||
|
||||
function filterConsumables() {
|
||||
const kw = consumableKeyword.value.trim().toLowerCase()
|
||||
if (!kw) {
|
||||
filteredConsumableList.value = [...allConsumableOptions.value]
|
||||
return
|
||||
}
|
||||
filteredConsumableList.value = allConsumableOptions.value.filter(
|
||||
(c) =>
|
||||
(c.consumableCode || '').toLowerCase().includes(kw) ||
|
||||
(c.consumableName || '').toLowerCase().includes(kw)
|
||||
)
|
||||
}
|
||||
|
||||
function handleConsumableRowSelect(row: any) {
|
||||
selectedConsumable.value = row
|
||||
}
|
||||
|
||||
function confirmAddConsumable() {
|
||||
if (!selectedConsumable.value) return
|
||||
const c = selectedConsumable.value
|
||||
const exists = consumableList.value.some(
|
||||
(item) => item.consumableId === c.id || item.consumableCode === c.consumableCode
|
||||
)
|
||||
if (exists) {
|
||||
ElMessage.warning('该耗材已在列表中')
|
||||
return
|
||||
}
|
||||
consumableList.value.push({
|
||||
consumableId: c.id,
|
||||
consumableCode: c.consumableCode || '',
|
||||
consumableName: c.consumableName || '',
|
||||
specModel: c.specModel || '',
|
||||
standardUsage: '',
|
||||
isRequired: false,
|
||||
remark: ''
|
||||
})
|
||||
selectConsumableVisible.value = false
|
||||
}
|
||||
|
||||
// =============== 从耗材包导入 ===============
|
||||
async function handleImportPack(packId: string | undefined) {
|
||||
if (!packId) return
|
||||
// 在 packOptions 中找到对应的包,然后查看它的 items
|
||||
// 由于 packOptions 来自 fetchAllConsumablePacks,可能不含 items
|
||||
// 需要用 fetchConsumablePackDetail 加载详情
|
||||
try {
|
||||
const { fetchConsumablePackDetail } = await import('@/api/production')
|
||||
const detail = await fetchConsumablePackDetail(packId)
|
||||
const packItems = detail.items || []
|
||||
let added = 0
|
||||
for (const item of packItems) {
|
||||
const exists = consumableList.value.some(
|
||||
(c) => c.consumableId === item.consumableId || c.consumableCode === item.consumableCode
|
||||
)
|
||||
if (!exists) {
|
||||
consumableList.value.push({
|
||||
consumableId: item.consumableId,
|
||||
consumableCode: item.consumableCode || '',
|
||||
consumableName: item.consumableName || '',
|
||||
specModel: item.specModel || '',
|
||||
standardUsage: item.standardUsage || '',
|
||||
isRequired: false,
|
||||
remark: ''
|
||||
})
|
||||
added++
|
||||
}
|
||||
}
|
||||
ElMessage.success(`导入成功,新增 ${added} 项耗材`)
|
||||
} catch {
|
||||
ElMessage.error('导入耗材包失败')
|
||||
}
|
||||
selectedPackId.value = undefined
|
||||
}
|
||||
|
||||
// =============== 产出物 ===============
|
||||
function addOutputRow() {
|
||||
outputList.value.push({
|
||||
outputTypeId: '',
|
||||
outputName: '',
|
||||
outputBarcode: ''
|
||||
})
|
||||
}
|
||||
|
||||
// 初始化加载列表 & 分类数据(用于列表列的分类名映射)
|
||||
onMounted(async () => {
|
||||
await loadData()
|
||||
// 静默加载分类数据用于列表展示
|
||||
try {
|
||||
categoryOptions.value = (await fetchAllProcessCategories()) || []
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.process-dialog-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.process-dialog {
|
||||
:deep(.el-dialog__body) {
|
||||
max-height: calc(100vh - 200px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
|
||||
.tab-toolbar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.inner-table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.form-col-span-2 {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user