提交
This commit is contained in:
1 parent
7e9155fef1
commit
2fd826dbe1
80 files changed
+32546
-36145
No files matched your search
@@ -25,6 +25,7 @@ export type ProductionTaskSet = {
|
||||
itemCount?: number
|
||||
items?: ProductionTaskSetItem[]
|
||||
remark?: string
|
||||
isBuiltin?: string
|
||||
createTime?: string
|
||||
skippedEmptyNameCount?: number
|
||||
}
|
||||
|
||||
@@ -36,7 +36,11 @@
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="isOaUploadImageFile(file)">
|
||||
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
||||
<img
|
||||
class="el-upload-list__item-thumbnail"
|
||||
:src="attachmentFullUrl(file.url || '') || file.url"
|
||||
alt=""
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="isOaUploadVideoFile(file)">
|
||||
<div class="oa-fc-upload-card__icon oa-fc-upload-card__icon--video">
|
||||
@@ -227,16 +231,18 @@
|
||||
isOaUploadImageFile,
|
||||
isOaUploadVideoFile,
|
||||
getOaUploadDisplayName,
|
||||
attachmentFullUrl,
|
||||
handlePreview(file: UploadFile) {
|
||||
if (typeof this.onPreview === 'function') {
|
||||
this.onPreview(file)
|
||||
return
|
||||
}
|
||||
const full = attachmentFullUrl(String(file?.url || '')) || String(file?.url || '')
|
||||
if (this.resolvedListType === 'text' || !isOaUploadImageFile(file)) {
|
||||
if (file?.url) window.open(file.url, '_blank')
|
||||
if (full) window.open(full, '_blank')
|
||||
return
|
||||
}
|
||||
this.previewImage = file.url || ''
|
||||
this.previewImage = full
|
||||
this.previewVisible = true
|
||||
},
|
||||
async handleDownload(file: UploadFile) {
|
||||
|
||||
@@ -2,11 +2,40 @@ import { downloadAttachmentFile } from '@/utils/download-attachment'
|
||||
|
||||
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
|
||||
/**
|
||||
* 附件存储路径 → 浏览器可访问 URL。
|
||||
* 兼容:
|
||||
* - 完整 http(s) URL
|
||||
* - 同域网关路径 `/minio/{bucket}/objectKey`(上传回写常见形态)
|
||||
* - 相对 object key,如 `oa-approval/202608/10/xxx.png`
|
||||
*
|
||||
* 注意:对已带 `/minio/...` 的路径不得再拼一次 `VITE_MINIO_BASE_URL`,否则会变成
|
||||
* `http://host/zkxw/minio/zkxw/...` 导致缩略图破图。
|
||||
*/
|
||||
export function attachmentFullUrl(url: string) {
|
||||
const u = String(url || '').trim()
|
||||
if (!u) return ''
|
||||
if (/^https?:\/\//i.test(u)) return u
|
||||
return minioBaseUrl ? `${minioBaseUrl}/${u.replace(/^\//, '')}` : u
|
||||
|
||||
const base = minioBaseUrl
|
||||
|
||||
// `/minio/zkxw/oa-approval/...` → 按环境改写或原样返回
|
||||
if (u.startsWith('/minio/')) {
|
||||
const parts = u.split('/').filter(Boolean) // minio, bucket, ...key
|
||||
const objectKey = parts.length >= 3 ? parts.slice(2).join('/') : ''
|
||||
if (objectKey && /^https?:\/\//i.test(base)) {
|
||||
// 本地开发:VITE_MINIO_BASE_URL=http://host:port/bucket
|
||||
return `${base}/${objectKey}`
|
||||
}
|
||||
// 生产/同域反代:路径本身即可访问
|
||||
if (!base || u === base || u.startsWith(`${base}/`)) return u
|
||||
if (objectKey) return `${base}/${objectKey}`
|
||||
return u
|
||||
}
|
||||
|
||||
if (base && (u === base || u.startsWith(`${base}/`))) return u
|
||||
if (!base) return u
|
||||
return `${base}/${u.replace(/^\//, '')}`
|
||||
}
|
||||
|
||||
export function useAttachmentActions() {
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import { fetchAttachmentDownloadUrl } from '@/api/business'
|
||||
import { attachmentFullUrl } from '@/composables/useAttachmentActions'
|
||||
|
||||
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
|
||||
export function attachmentFullUrl(url: string) {
|
||||
const u = String(url || '').trim()
|
||||
if (!u) return ''
|
||||
if (/^https?:\/\//i.test(u)) return u
|
||||
return minioBaseUrl ? `${minioBaseUrl}/${u.replace(/^\//, '')}` : u
|
||||
}
|
||||
export { attachmentFullUrl }
|
||||
|
||||
export function sanitizeZipPathSegment(value: string, fallback = '未命名') {
|
||||
const cleaned = String(value || '')
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { mapWorkOrderTasksToSetItems } from './production-task-set'
|
||||
import {
|
||||
mapWorkOrderTasksToSetItems,
|
||||
revertTaskNamePlaceholders,
|
||||
resolveWorkOrderLabStorageCode,
|
||||
LAB_STORAGE_CODE_PLACEHOLDER
|
||||
} from './production-task-set'
|
||||
|
||||
describe('mapWorkOrderTasksToSetItems', () => {
|
||||
it('skips empty names and keeps route/description/remark', () => {
|
||||
@@ -28,3 +33,36 @@ describe('mapWorkOrderTasksToSetItems', () => {
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('revertTaskNamePlaceholders', () => {
|
||||
it('replaces lab storage code with placeholder', () => {
|
||||
assert.equal(
|
||||
revertTaskNamePlaceholders('LS001样本处理', 'LS001'),
|
||||
`${LAB_STORAGE_CODE_PLACEHOLDER}样本处理`
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps name when code empty', () => {
|
||||
assert.equal(revertTaskNamePlaceholders('LS001样本处理', ''), 'LS001样本处理')
|
||||
})
|
||||
})
|
||||
|
||||
describe('mapWorkOrderTasksToSetItems with labStorageCode', () => {
|
||||
it('reverts names when mapping', () => {
|
||||
const { items } = mapWorkOrderTasksToSetItems(
|
||||
[{ taskName: 'LS001分离', routeId: 'r1', routeName: 'A' }],
|
||||
{ labStorageCode: 'LS001' }
|
||||
)
|
||||
assert.equal(items[0].taskName, `${LAB_STORAGE_CODE_PLACEHOLDER}分离`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolveWorkOrderLabStorageCode', () => {
|
||||
it('prefers row field then reception', () => {
|
||||
assert.equal(resolveWorkOrderLabStorageCode({ labStorageCode: 'A' }), 'A')
|
||||
assert.equal(
|
||||
resolveWorkOrderLabStorageCode({ reception: { labStorageCode: 'B' } }),
|
||||
'B'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,3 +1,5 @@
|
||||
export const LAB_STORAGE_CODE_PLACEHOLDER = '{lab_storage_code}'
|
||||
|
||||
export type ProductionTaskSetItemPreview = {
|
||||
taskName: string
|
||||
routeId: string
|
||||
@@ -6,10 +8,24 @@ export type ProductionTaskSetItemPreview = {
|
||||
remark: string
|
||||
}
|
||||
|
||||
export function mapWorkOrderTasksToSetItems(tasks: Record<string, any>[] | undefined): {
|
||||
export function revertTaskNamePlaceholders(
|
||||
taskName: string,
|
||||
labStorageCode?: string | null
|
||||
): string {
|
||||
const text = String(taskName || '')
|
||||
const code = String(labStorageCode || '').trim()
|
||||
if (!code) return text
|
||||
return text.split(code).join(LAB_STORAGE_CODE_PLACEHOLDER)
|
||||
}
|
||||
|
||||
export function mapWorkOrderTasksToSetItems(
|
||||
tasks: Record<string, any>[] | undefined,
|
||||
options?: { labStorageCode?: string | null }
|
||||
): {
|
||||
items: ProductionTaskSetItemPreview[]
|
||||
skippedEmptyNameCount: number
|
||||
} {
|
||||
const labStorageCode = options?.labStorageCode
|
||||
const items: ProductionTaskSetItemPreview[] = []
|
||||
let skippedEmptyNameCount = 0
|
||||
for (const row of tasks || []) {
|
||||
@@ -19,7 +35,7 @@ export function mapWorkOrderTasksToSetItems(tasks: Record<string, any>[] | undef
|
||||
continue
|
||||
}
|
||||
items.push({
|
||||
taskName,
|
||||
taskName: revertTaskNamePlaceholders(taskName, labStorageCode),
|
||||
routeId: String(row.routeId || '').trim(),
|
||||
routeName: String(row.routeName || '').trim(),
|
||||
description: String(row.description || '').trim(),
|
||||
@@ -28,3 +44,14 @@ export function mapWorkOrderTasksToSetItems(tasks: Record<string, any>[] | undef
|
||||
}
|
||||
return { items, skippedEmptyNameCount }
|
||||
}
|
||||
|
||||
export function resolveWorkOrderLabStorageCode(
|
||||
row: Record<string, any> | null | undefined
|
||||
): string {
|
||||
if (!row) return ''
|
||||
const fromRow = String(row.labStorageCode || '').trim()
|
||||
if (fromRow) return fromRow
|
||||
return String(
|
||||
(row.reception as Record<string, any> | undefined)?.labStorageCode || ''
|
||||
).trim()
|
||||
}
|
||||
@@ -179,11 +179,17 @@
|
||||
:initial-index="imagePreviewIndex(row, label, file.url)"
|
||||
fit="cover"
|
||||
preview-teleported
|
||||
hide-on-click-modal
|
||||
>
|
||||
<template #error>
|
||||
<div class="hist-attach__fallback">
|
||||
<button
|
||||
type="button"
|
||||
class="hist-attach__fallback"
|
||||
title="图片加载失败,点击尝试打开"
|
||||
@click.stop="previewFile(file)"
|
||||
>
|
||||
<el-icon :size="18"><Picture /></el-icon>
|
||||
</div>
|
||||
</button>
|
||||
</template>
|
||||
</el-image>
|
||||
<button
|
||||
@@ -399,7 +405,7 @@
|
||||
}
|
||||
|
||||
function previewColumnMinWidth(label: string) {
|
||||
return isUploadPreviewLabel(label) ? 168 : 120
|
||||
return isUploadPreviewLabel(label) ? 220 : 120
|
||||
}
|
||||
|
||||
function syncWorktabTitle() {
|
||||
|
||||
@@ -151,13 +151,37 @@
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px">
|
||||
<el-button class="btn-op-item primary" @click="handleOpenConfig(row)">
|
||||
<el-tooltip
|
||||
v-if="!canMaintainRoute(row)"
|
||||
content="内置模版仅超级管理员可配置"
|
||||
placement="top"
|
||||
>
|
||||
<span>
|
||||
<el-button class="btn-op-item primary" disabled>
|
||||
<el-icon><Rank /></el-icon>路线图配置
|
||||
</el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-button
|
||||
v-else
|
||||
class="btn-op-item primary"
|
||||
@click="handleOpenConfig(row)"
|
||||
>
|
||||
<el-icon><Rank /></el-icon>路线图配置
|
||||
</el-button>
|
||||
<el-button v-if="!row.isCurrent" class="btn-op-item" @click="handleSetCurrent(row)">
|
||||
<el-button
|
||||
v-if="!row.isCurrent"
|
||||
class="btn-op-item"
|
||||
:disabled="!canMaintainRoute(row)"
|
||||
@click="handleSetCurrent(row)"
|
||||
>
|
||||
设为当前
|
||||
</el-button>
|
||||
<el-dropdown trigger="hover" @command="(cmd: string) => handleDropdownCommand(cmd, row)">
|
||||
<el-dropdown
|
||||
v-if="canMaintainRoute(row)"
|
||||
trigger="hover"
|
||||
@command="(cmd: string) => handleDropdownCommand(cmd, row)"
|
||||
>
|
||||
<el-button class="btn-op-item">
|
||||
<el-icon><More /></el-icon>
|
||||
</el-button>
|
||||
@@ -1183,9 +1207,21 @@
|
||||
SHOW_PROCESS_DURATION_DESC_SOP,
|
||||
PROCESS_ROUTE_DEFAULT_SUB_TAB
|
||||
} from '@/utils/process-material-ui'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
|
||||
defineOptions({ name: 'ProcessRouteTab' })
|
||||
|
||||
const userStore = useUserStore()
|
||||
const isSuperAdmin = computed(() => !!userStore.isSuperAdmin)
|
||||
|
||||
function isBuiltinRoute(row: Record<string, any> | null | undefined) {
|
||||
return String(row?.isBuiltin || '') === '1'
|
||||
}
|
||||
|
||||
function canMaintainRoute(row: Record<string, any> | null | undefined) {
|
||||
return isSuperAdmin.value || !isBuiltinRoute(row)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 列表页
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1316,6 +1352,10 @@
|
||||
}
|
||||
|
||||
function handleEdit(row: Record<string, any>) {
|
||||
if (!canMaintainRoute(row)) {
|
||||
ElMessage.warning('内置模版仅超级管理员可修改')
|
||||
return
|
||||
}
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑路线'
|
||||
editingId.value = row.id
|
||||
@@ -1356,6 +1396,10 @@
|
||||
}
|
||||
|
||||
async function handleSetCurrent(row: Record<string, any>) {
|
||||
if (!canMaintainRoute(row)) {
|
||||
ElMessage.warning('内置模版仅超级管理员可修改')
|
||||
return
|
||||
}
|
||||
await ElMessageBox.confirm('确定将该路线设为当前版本吗?', '提示', { type: 'warning' })
|
||||
await fetchSetCurrentProcessRoute(row.id)
|
||||
ElMessage.success('设置成功')
|
||||
@@ -1370,6 +1414,10 @@
|
||||
}
|
||||
|
||||
async function handleDelete(row: Record<string, any>) {
|
||||
if (!canMaintainRoute(row)) {
|
||||
ElMessage.warning('内置模版仅超级管理员可修改')
|
||||
return
|
||||
}
|
||||
await ElMessageBox.confirm('确定要删除该路线吗?删除后不可恢复。', '提示', { type: 'warning' })
|
||||
await fetchDeleteProcessRoute(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
@@ -1377,8 +1425,13 @@
|
||||
}
|
||||
|
||||
async function handleBatchDelete() {
|
||||
const ids = selectedRows.value.map((r) => r.id)
|
||||
if (!ids.length) return
|
||||
const rows = selectedRows.value
|
||||
if (!rows.length) return
|
||||
if (rows.some((r) => !canMaintainRoute(r))) {
|
||||
ElMessage.warning('选中项包含内置模版,仅超级管理员可删除;请取消勾选内置模版后再试')
|
||||
return
|
||||
}
|
||||
const ids = rows.map((r) => r.id)
|
||||
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 条路线吗?`, '提示', {
|
||||
type: 'warning'
|
||||
})
|
||||
@@ -1939,6 +1992,10 @@
|
||||
}
|
||||
|
||||
async function handleOpenConfig(row: Record<string, any>) {
|
||||
if (!canMaintainRoute(row)) {
|
||||
ElMessage.warning('内置模版仅超级管理员可配置')
|
||||
return
|
||||
}
|
||||
configRouteId.value = row.id
|
||||
configRouteName.value = row.routeName || ''
|
||||
configRouteVersion.value = row.version || ''
|
||||
|
||||
@@ -112,13 +112,25 @@
|
||||
<el-button class="btn-op-item" @click="handleView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button v-if="canEdit" class="btn-op-item primary" @click="handleEdit(row)">
|
||||
<el-button
|
||||
v-if="canEdit && canMaintainSet(row)"
|
||||
class="btn-op-item primary"
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button v-if="canEdit" class="btn-op-item" @click="handleToggleStatus(row)">
|
||||
<el-button
|
||||
v-if="canEdit && canMaintainSet(row)"
|
||||
class="btn-op-item"
|
||||
@click="handleToggleStatus(row)"
|
||||
>
|
||||
<el-icon><Switch /></el-icon>{{ row.status === '1' ? '停用' : '启用' }}
|
||||
</el-button>
|
||||
<el-button v-if="canRemove" class="btn-op-item" @click="handleDelete(row)">
|
||||
<el-button
|
||||
v-if="canRemove && canMaintainSet(row)"
|
||||
class="btn-op-item"
|
||||
@click="handleDelete(row)"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
@@ -182,6 +194,9 @@
|
||||
</el-form-item>
|
||||
<el-form-item class="form-col-span-2 set-items-field" prop="items" label="任务条目">
|
||||
<div class="set-items-block">
|
||||
<p class="set-items-tip form-tip">
|
||||
任务名称支持动态参数:{lab_storage_code}(实验室入库编码)。按模版派发时按工单关联样本接收自动替换;无入库编码则置空。保存为模版时,会将任务名中的入库编码还原为该占位符。
|
||||
</p>
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<el-button class="btn-main" type="primary" @click="addItem">
|
||||
@@ -416,16 +431,22 @@
|
||||
type ProductionTaskSet,
|
||||
type ProductionTaskSetItem
|
||||
} from '@/api/production-task-set'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
|
||||
defineOptions({ name: 'ProductionTaskSet' })
|
||||
|
||||
type FormItem = ProductionTaskSetItem & { _key: string }
|
||||
|
||||
const { hasMenuPerm } = useMenuPerm()
|
||||
const userStore = useUserStore()
|
||||
const isSuperAdmin = computed(() => !!userStore.isSuperAdmin)
|
||||
const canAdd = computed(() => hasMenuPerm('production:task-set:add'))
|
||||
const canEdit = computed(() => hasMenuPerm('production:task-set:edit'))
|
||||
const canRemove = computed(() => hasMenuPerm('production:task-set:remove'))
|
||||
|
||||
function canMaintainSet(row: ProductionTaskSet | null | undefined) {
|
||||
return isSuperAdmin.value || String(row?.isBuiltin || '') !== '1'
|
||||
}
|
||||
const searchForm = reactive({ keyword: '', status: '' as string })
|
||||
const tableData = ref<ProductionTaskSet[]>([])
|
||||
const loading = ref(false)
|
||||
@@ -617,6 +638,10 @@
|
||||
}
|
||||
|
||||
async function handleEdit(row: ProductionTaskSet) {
|
||||
if (!canMaintainSet(row)) {
|
||||
ElMessage.warning('内置模版仅超级管理员可修改')
|
||||
return
|
||||
}
|
||||
dialogMode.value = 'edit'
|
||||
dialogTitle.value = '编辑集合'
|
||||
resetForm()
|
||||
@@ -675,6 +700,10 @@
|
||||
}
|
||||
|
||||
async function handleToggleStatus(row: ProductionTaskSet) {
|
||||
if (!canMaintainSet(row)) {
|
||||
ElMessage.warning('内置模版仅超级管理员可修改')
|
||||
return
|
||||
}
|
||||
const next = row.status === '1' ? '0' : '1'
|
||||
const tip = next === '1' ? '启用' : '停用'
|
||||
await ElMessageBox.confirm(`确定${tip}集合「${row.setName}」?`, '提示', {
|
||||
@@ -686,6 +715,10 @@
|
||||
}
|
||||
|
||||
async function handleDelete(row: ProductionTaskSet) {
|
||||
if (!canMaintainSet(row)) {
|
||||
ElMessage.warning('内置模版仅超级管理员可修改')
|
||||
return
|
||||
}
|
||||
await ElMessageBox.confirm(`确定删除集合「${row.setName}」?`, '提示', { type: 'warning' })
|
||||
await fetchDeleteProductionTaskSet(row.id)
|
||||
ElMessage.success('已删除')
|
||||
@@ -705,6 +738,19 @@
|
||||
.set-items-block {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.set-items-tip {
|
||||
margin: 0;
|
||||
margin-left: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.list-toolbar {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.inner-table-wrap {
|
||||
|
||||
+4
-1
@@ -172,6 +172,7 @@
|
||||
visible: boolean
|
||||
workOrderId: string
|
||||
tasks?: Record<string, any>[]
|
||||
labStorageCode?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -280,7 +281,9 @@
|
||||
async function initForm() {
|
||||
form.setName = ''
|
||||
form.remark = ''
|
||||
const mapped = mapWorkOrderTasksToSetItems(props.tasks)
|
||||
const mapped = mapWorkOrderTasksToSetItems(props.tasks, {
|
||||
labStorageCode: props.labStorageCode
|
||||
})
|
||||
form.items = mapped.items.length
|
||||
? mapped.items.map((item) => createItem(item))
|
||||
: [createItem()]
|
||||
|
||||
+5
@@ -225,6 +225,7 @@
|
||||
v-model:visible="saveSetVisible"
|
||||
:work-order-id="saveSetRow?.id || ''"
|
||||
:tasks="saveSetTasks"
|
||||
:lab-storage-code="saveSetLabStorageCode"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -246,6 +247,7 @@
|
||||
useProductionWorkOrderTabPage,
|
||||
type ProductionWorkOrderTabPageMode
|
||||
} from '../composables/useProductionWorkOrderTabPage'
|
||||
import { resolveWorkOrderLabStorageCode } from '@/utils/production-task-set'
|
||||
|
||||
defineOptions({ name: 'ProductionWorkOrderTabPanel' })
|
||||
|
||||
@@ -275,6 +277,9 @@
|
||||
const qcViewRow = ref<ProductionWorkOrderItem | null>(null)
|
||||
const saveSetVisible = ref(false)
|
||||
const saveSetRow = ref<ProductionWorkOrderItem | null>(null)
|
||||
const saveSetLabStorageCode = computed(() =>
|
||||
resolveWorkOrderLabStorageCode(saveSetRow.value)
|
||||
)
|
||||
|
||||
const {
|
||||
cardMetaConfig,
|
||||
|
||||
Reference in new issue
Block a user